// Init js object var DWSIpDetail = new Object(); DWSIpDetail.ctr = 'DWS_IP_Tracking'; DWSIpDetail.rv = ''; DWSIpDetail.sc1 = null; DWSIpDetail.hasData = false; DWSIpDetail.currentIndexMethod = 1; DWSIpDetail.timerGetIp = null; DWSIpDetail.pingIp2Phrase = true; DWSIpDetail.pingGeoup = true; DWSIpDetail.pingMaxMind = true; DWSIpDetail.pingIpInfoDB = true; //DWSIpDetail.URL_IpInfoDB = 'http://localhost:1270/Code 3.0.0/IpInfoDB.aspx'; DWSIpDetail.URL_IpInfoDB = 'http://IPTracking.info/IpInfoDB.aspx'; // Form submit information DWSIpDetail.formId = ''; DWSIpDetail.ipAddress = '38.107.179.218'; DWSIpDetail.ipBrowser = 'Unknown 0.0'; DWSIpDetail.ipReferrerUrl = ''; DWSIpDetail.ipCountry = 'N/A'; DWSIpDetail.ipState = 'N/A'; DWSIpDetail.ipCity = 'N/A'; DWSIpDetail.ipISP = 'N/A'; DWSIpDetail.currentLoad = null; /// THIS PROPERTIES SET TIME TO WAIT DATA DWSIpDetail.dataDelay = 1000; // 1 second DWSIpDetail.call = function(ws) { if (this.sc1) this.sc1.parentNode.removeChild(this.sc1); this.sc1 = document.createElement('SCRIPT'); this.sc1.id = this.ctr + '_sc1'; this.sc1.type = 'text/javascript'; this.sc1.src = ws; try { document.getElementsByTagName('head')[0].appendChild(this.sc1); } catch (ex) { document.body.appendChild(this.sc1); } } DWSIpDetail.getIpAddress = function() { if (document.forms[this.formId].Contact0_ipaddress) document.forms[this.formId].Contact0_ipaddress.value = this.ipAddress; if (document.forms[this.formId].Contact0_ipbrowser) document.forms[this.formId].Contact0_ipbrowser.value = this.ipBrowser; if (document.forms[this.formId].Contact0_ipreferrerurl) document.forms[this.formId].Contact0_ipreferrerurl.value = this.ipReferrerUrl; DWSIpDetail.checkAndGetIp(); } if (typeof DWSIpDetailConfig != 'undefined') { for (prop in DWSIpDetailConfig) { this[prop] = DWSIpDetailConfig[prop]; } } // Firs start, get configs DWSIpDetail.self = document.getElementById('DWSIpDetail'); if (DWSIpDetail.self) { DWSIpDetail.formId = DWSIpDetail.self.getAttribute('formId'); } // Override document.write function var myWrite = document.write; var currentTemp = 0; document.write = function(str) { var tempContent = document.getElementById('tempContent'); if (typeof tempContent == 'undefined' || tempContent == null) { tempContent = document.createElement('div'); tempContent.setAttribute('id', 'tempContent'); tempContent.style.display = 'none'; document.body.appendChild(tempContent); } var newdiv = document.createElement('div'); newdiv.setAttribute('id', 'temp' + currentTemp); newdiv.innerHTML = str; tempContent.appendChild(newdiv); currentTemp++; }; DWSIpDetail.cleanUpScript = function() { if (navigator.appName == "Microsoft Internet Explorer") { window.document.execCommand('Stop'); } else { window.stop(); } } // Add script to head DWSIpDetail.addScript = function(url) { if (DWSIpDetail.currentLoad != null) DWSIpDetail.currentLoad.parentNode.removeChild(DWSIpDetail.currentLoad); DWSIpDetail.currentLoad = document.createElement('SCRIPT'); DWSIpDetail.currentLoad.id = DWSIpDetail.ctr + '_DataScript'; DWSIpDetail.currentLoad.type = 'text/javascript'; DWSIpDetail.currentLoad.src = url; try { document.getElementsByTagName('head')[0].appendChild(DWSIpDetail.currentLoad); } catch (ex) { document.body.appendChild(DWSIpDetail.currentLoad); } } DWSIpDetail.checkAndGetIp = function() { if (DWSIpDetail.hasData == false) { switch (DWSIpDetail.currentIndexMethod) { case 1: DWSIpDetail.addScript('http://www.ip2phrase.com/ip2phrase.asp?template='); window.setTimeout(function() { DWSIpDetail.getIp2Phrase(); DWSIpDetail.currentIndexMethod++; if (DWSIpDetail.hasData == false) { DWSIpDetail.cleanUpScript(); DWSIpDetail.checkAndGetIp(); } }, DWSIpDetail.dataDelay); break; case 2: DWSIpDetail.addScript('http://map.geoup.com/~67852/geoup?template=hidden'); window.setTimeout(function() { DWSIpDetail.getGeoup(); DWSIpDetail.currentIndexMethod++; if (DWSIpDetail.hasData == false) { DWSIpDetail.cleanUpScript(); DWSIpDetail.checkAndGetIp(); } }, DWSIpDetail.dataDelay); break; case 3: DWSIpDetail.addScript('http://j.maxmind.com/app/geoip.js'); window.setTimeout(function() { DWSIpDetail.getMaxMind(); DWSIpDetail.currentIndexMethod++; if (DWSIpDetail.hasData == false) { DWSIpDetail.cleanUpScript(); DWSIpDetail.checkAndGetIp(); } }, DWSIpDetail.dataDelay); break; case 4: DWSIpDetail.addScript(DWSIpDetail.URL_IpInfoDB); window.setTimeout(function() { DWSIpDetail.getIpInfoDB(); DWSIpDetail.currentIndexMethod++; if (DWSIpDetail.hasData == false) { DWSIpDetail.cleanUpScript(); DWSIpDetail.checkAndGetIp(); } }, DWSIpDetail.dataDelay); break; default: DWSIpDetail.cleanUpScript(); break; } } } DWSIpDetail.setDataToForm = function() { if (document.forms[this.formId].Contact0_ipcountry) document.forms[this.formId].Contact0_ipcountry.value = this.ipCountry; if (document.forms[this.formId].Contact0_IpState) document.forms[this.formId].Contact0_IpState.value = this.ipState; if (document.forms[this.formId].Contact0_IPCity) document.forms[this.formId].Contact0_IPCity.value = this.ipCity; if (document.forms[this.formId].Contact0_ipinternetprovider) document.forms[this.formId].Contact0_ipinternetprovider.value = this.ipISP; this.hasData = true; } DWSIpDetail.getIp2Phrase = function() { if (this.pingIp2Phrase == false) return false; var result = false; var dvCountry = document.getElementById('div_ip2phrase_country'); if (dvCountry) { this.ipCountry = dvCountry.lastChild.nodeValue; result = true; } var dvState = document.getElementById('div_ip2phrase_state'); if (dvState) { this.ipState = dvState.lastChild.nodeValue; result = true; } var dvCity = document.getElementById('div_ip2phrase_city'); if (dvCity) { this.ipCity = dvCity.lastChild.nodeValue; result = true; } var dvISP = document.getElementById('div_ip2phrase_isp'); if (dvISP) { this.ipISP = dvISP.lastChild.nodeValue; result = true; } if (result) { this.setDataToForm(); } } DWSIpDetail.getGeoup = function() { if (this.pingGeoup == false) return false; var result = false; var dvCountry = document.getElementById('div_geoup_country'); if (dvCountry) { this.ipCountry = dvCountry.lastChild.nodeValue; result = true; } var dvState = document.getElementById('div_geoup_state'); if (dvState) { this.ipState = dvState.lastChild.nodeValue; result = true; } var dvCity = document.getElementById('div_geoup_city'); if (dvCity) { this.ipCity = dvCity.lastChild.nodeValue; result = true; } var dvISP = document.getElementById('div_geoup_isp'); if (dvISP) { this.ipISP = dvISP.lastChild.nodeValue; result = true; } if (result) this.setDataToForm(); } DWSIpDetail.getMaxMind = function() { if (this.pingMaxMind == false) return false; var result = false; try { this.ipCountry = geoip_country_name(); this.ipState = geoip_region_name(); this.ipCity = geoip_city(); this.ipISP = 'N/A'; // Set data to textbox result = true; } catch (ex) { } if (result) this.setDataToForm(); } DWSIpDetail.getIpInfoDB = function() { if (this.pingIpInfoDB == false) return false; var result = false; try { this.ipCountry = ipinfodb_get_country(); this.ipState = ipinfodb_get_state(); this.ipCity = ipinfodb_get_city(); this.ipISP = 'N/A'; result = true; } catch (ex) { } if (result) { this.setDataToForm(); } } window.setTimeout("DWSIpDetail.getIpAddress()", 500);