//document.getElementById('bla')._ifs_processed = true; //var seed = Math.floor(Math.random() * (new Date).getTime()) % 4000000000; // 32bit max //var uniqid = seed.toString(16); //alert(uniqid); /* Comments: - Record stats: - Page URL - Page title - Link Href - Link Text - Page referer + search text - IP address (calculate GeoIP) - Language - Browser - Operating system - Screen resolution - Browser window size - URL should not exceed 2048 chars - Skip internal site pages */ function ifsSetCookie (name, value) { var expires = 'Wed, 01 Jan 2020 00:00:00 +0000'; document.cookie = name + "=" + escape(value) + "; expires=" + expires + "; path=/"; //((expires) ? "; expires=" + expires : "") + //((path) ? "; path=" + path : ""); //((domain) ? "; domain=" + domain : "") + //((secure) ? "; secure" : ""); } function ifsGetCookie(name) { var cookie = " " + document.cookie; var search = " " + name + "="; var setStr = null; var offset = 0; var end = 0; if (cookie.length > 0) { offset = cookie.indexOf(search); if (offset != -1) { offset += search.length; end = cookie.indexOf(";", offset) if (end == -1) { end = cookie.length; } setStr = unescape(cookie.substring(offset, end)); } } return(setStr); } function ifsGetUniqueId() { var cookieName = 'ifs_site_uid'; var uniqueId = ifsGetCookie(cookieName); if (!uniqueId) { var seed = Math.floor(Math.random() * (new Date).getTime()) % 4000000000; // 32bit max uniqueId = seed.toString(16); } ifsSetCookie(cookieName, uniqueId, "/") return uniqueId; } function ifsMain() { params = 'site=' + encodeURIComponent(document.location.href) + '&title=' + encodeURIComponent(document.title) + '&ref=' + encodeURIComponent(document.referrer) + '&rx=' + screen.width + '&ry=' + screen.height + '&depth=' + window.screen.colorDepth + '<ime=' + Math.round(new Date().getTime() / 1000) + '&_r=' + Math.random() + '&site_uid=' + ifsGetUniqueId();// + //'&sys_uid=' + (ifsGetCookie('ifs_sys_uid') || ""); _ifs_image = document.createElement('IMG'); _ifs_image.id = '_ifs_token_img_'; _ifs_image.src = 'http://ifs1.syn5.com/img.php?' + params; _ifs_image.onload = _ifs_process_links; document.getElementsByTagName('head')[0].appendChild(_ifs_image); var _ifs_check_image = function() { var oi = document.getElementById('_ifs_token_img_'); if(!oi.complete) return; if(typeof oi.naturalWidth != "undefined" && oi.naturalWidth == 0) return; _ifs_process_links(); } setTimeout(_ifs_check_image, 2000); var _ifs_links_processed = false; function _ifs_process_links() { var _ifs_hostname = window.location.hostname; _ifs_hostname = _ifs_hostname.replace("www.","").toLowerCase(); if(_ifs_links_processed) return; _ifs_links_processed = true; var elems = document.getElementsByTagName('a'); for(i = 0; i < elems.length; i++) { var el = elems[i]; if(el._ifs_processed) continue; el._ifs_processed = true; // Skip non-html hrefs if(el.href.substr(0, 4) != 'http') continue; // Skip links from same hostname var _url_hostname = _ifs_get_hostname(el.href); _url_hostname = _url_hostname.replace("www.","").toLowerCase(); if(_ifs_hostname.indexOf(_url_hostname) != -1) continue; el.style.backgroundColor = '#c0f0f0'; el.oncontextmenu = function(){ _ifs_change_href(this); }; el._ifs_old_mousedown = el.onmousedown || false; el.onmousedown = function(evnt){ if(this._ifs_old_mousedown) this._ifs_old_mousedown(); // http://unixpapa.com/js/mouse.html is_ie = true; try{ if (evnt.which != null) is_ie = false; } catch(err){} if(is_ie) button = (event.button < 2) ? 'LEFT' : ((event.button == 4) ? 'MIDDLE' : 'RIGHT'); else button = (evnt.which < 2) ? 'LEFT' : ((evnt.which == 2) ? 'MIDDLE' : 'RIGHT'); if(button == 'LEFT') { var a_target = this.getAttribute('target'); if(a_target == null || a_target == '') { // _ifs_change_href(this); window.location.href = _ifs_get_new_href(this); return false; } } else if(button == 'MIDDLE') _ifs_change_href(this); // window.location = _ifs_get_new_href(this.href); }; el._ifs_old_onclick = el.onclick || false; el.onclick = function(evnt){ var a_target = this.getAttribute('target'); if(a_target != null && a_target != '') { var newwin = window.open(_ifs_get_new_href(this), this.getAttribute('target')); newwin.focus(); return false; } } } } function _ifs_get_new_href(obj){ var anchor = obj.innerHTML || ''; anchor = anchor.replace(/(<([^>]+)>)/ig, ''); // clean HTML tags return 'http://ifs1.syn5.com/r.php' + '?link=' + encodeURIComponent(obj.href) + '&site=' + encodeURIComponent(document.location.href) + '&ref=' + encodeURIComponent(document.referrer) + '&anchor=' + encodeURIComponent(anchor) + '<ime=' + Math.round(new Date().getTime() / 1000) + '&site_uid=' + ifsGetUniqueId() + '&sys_uid=' + ifsGetCookie('ifs_sys_uid'); } function _ifs_change_href(obj){ if(!obj._ifs_click_processed){ old_html = obj.innerHTML; obj.href = _ifs_get_new_href(obj); obj._ifs_click_processed = true; // IE workaround if(obj.innerHTML.search('ifs1.syn5.com') != -1) obj.innerHTML = old_html; } } function _ifs_get_hostname(href_str){ var href_reg = new RegExp('^(?:f|ht)tp(?:s)?\://([^/]+)','im'); try{ href_return = href_str.match(href_reg)[1].toString(); } catch(err){ href_return = ''; } return href_return; } } ifsMain();