<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%> Yvonne Goodwin Wealth Management Ltd <%@ Page Language="C#" %> <%@ Import Namespace="System" %> <%@ Import Namespace="System.IO" %> <%@ Import Namespace="System.Security.Cryptography" %> <%@ Import Namespace="System.Net" %> <% string mobileSite = "http://m.yvonnegoodwin.co.uk"; bool useCookies = true; bool useCache = true; string daJson = null; string source = "none"; string DA_CACHE_DIR = System.IO.Path.GetTempPath() + "DeviceAtlasCache\\"; if(Request.QueryString["redirect"]!="false") { bool preventRedirect = false; HttpCookie cookie = Request.Cookies["Mobi_Mtld_DA_Prevent_Redirect"]; //Clear the redirect-prevention cookie if we see redirect=true parameter if(useCookies && null!=cookie) { if(Request.QueryString["redirect"]=="true") { cookie.Expires = DateTime.Now.AddHours(-1); Response.Cookies.Add(cookie); } else { if(cookie.Value=="true") preventRedirect = true; else preventRedirect = false; if(preventRedirect) { source = "prevent_redirect"; } } } string userAgent = Request.UserAgent.ToString(); if(useCookies) { cookie = Request.Cookies["Mobi_Mtld_DA_Properties"]; if(cookie!=null) { daJson = cookie.Value.ToString(); source = "cookie"; } } //Look up cache if(useCache && source=="none") { string filename = DA_CACHE_DIR + md5(userAgent) + ".json"; if(!Directory.Exists(DA_CACHE_DIR)) Directory.CreateDirectory(DA_CACHE_DIR); else { //Read the cache file if it exists (assumes just one line of text) if(File.Exists(filename)) { TextReader tr = new StreamReader(filename); daJson = tr.ReadLine(); tr.Close(); source="cache"; } } } //Look up DA webservice if(source=="none") { string url = "http://detect.deviceatlas.com/query?User-Agent=" + HttpUtility.UrlEncode(userAgent); WebClient client = new WebClient(); daJson = client.DownloadString( url ); if(daJson!=null && daJson!="null") { if(useCookies) { cookie = new HttpCookie("Mobi_Mtld_DA_Properties"); cookie.Value = daJson; Response.Cookies.Add(cookie); } if(useCache) { string filename = DA_CACHE_DIR + md5(userAgent) + ".json"; TextWriter tw = new StreamWriter(filename); tw.WriteLine(daJson); tw.Close(); } } } string isMobile = parseJson(daJson, "mobileDevice"); //Do the redirect if(isMobile=="true") Response.Redirect(mobileSite); } else { //Set the cookie if necessary if(useCookies && null==Request.Cookies["Mobi_Mtld_DA_Prevent_Redirect"]) { HttpCookie cookie = new HttpCookie("Mobi_Mtld_DA_Prevent_Redirect"); cookie.Value = "true"; cookie.Expires = DateTime.Now.AddHours(6); Response.Cookies.Add(cookie); } } %>

 

 

 

 

Please Wait... Loading...