/* used in contact form and telephone page and main page */ function checkIP(theIP,theURI) { //console .log('v3'); var xmlhttp = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); var ip_address = theIP var the_uri = theURI; //var url = "https://ipfind.co/?auth=fd1391bb-a5ec-41d7-8694-65cd5fdfaf9d&ip=" + ip_address; var url = 'https://ipapi.co/'+ip_address+'/json/?key=353b12f305315990a9aca491fc6aea5230fd4bcc' xmlhttp.onreadystatechange = function() { if (this.readyState == 4) { var geoEndTime = new Date().getTime(); var geotime = (geoEndTime - geoStartTime)/1000; var result = {}; if (this.status == 200) { try { result = JSON2.parse(this.responseText); } catch(err) { //console .log('json err:'+err); } //console .log(result); //if (result.country_code == 'CA' && result.region == 'Ontario') outputOntario(true); if (result.country == 'CA' && result.region == 'Ontario') outputOntario(true); else if (window.P4B_homePage) outputOntario(false); } else { if (window.P4B_homePage) outputOntario(false); } // var xmlhttp2 = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); var theString = ""; theString += "&geouri="+ ((the_uri) ? the_uri : 'missing'); theString += "&geoip="+ ((ip_address) ? ip_address : 'missing'); theString += "&georeturncode="+ ((this.status == 200) ? 1 : -1); theString += "&georegion=" + ((result.region) ? result.region : 'missing'); theString += "&geostring=" + ((this.responseText) ? this.responseText : 'missing'); theString += "&echo=yes"; theString += "&geotime="+ geotime; xmlhttp2.open("GET", "/php/geotracker.php?qs="+(new Date().getTime())+theString+"&", true); xmlhttp2.send(); // } }; var geoStartTime = new Date().getTime(); try { xmlhttp.open("GET", url, true); } catch(err) { if (window.P4B_homePage) outputOntario(false); return false; } if (window.P4B_homePage) xmlhttp.timeout = 3000; try { xmlhttp.send(); } catch(err) { if (window.P4B_homePage) outputOntario(false); return false; } }