function string_encode(str) { var s = ""; for(var i=0, n = str.length; i=0 && str.charCodeAt(i)<=255 ) { s += escape( str.charAt(i) ); } else { s += str.charAt(i); } } return s; } function get_domain(host) { var d = ''; d.replace(/^www\./,''); return d; } function set_cookie(name, val, hours) { var date = cookie = ''; if(hours != null) { date = new Date( (new Date()).getTime() + hours * 3600000 ); cookie = name+"="+ escape(val) +";expires="+date.toGMTString()+";"; var d = get_domain(document.domain); if(d!="") { cookie += 'domain='+ d +';'; } cookie += 'path=/;'; document.cookie = cookie; } } function get_cookie(name) { var cookies = document.cookie; var cookieval = cookieindex = start = ''; cookieindex = cookies.indexOf(name); if( cookieindex > -1) { valindex = cookies.indexOf(';', cookieindex); start = cookieindex + name.length + 1; if(valindex<0) { cookieval = cookies.substring(start); }else{ cookieval = cookies.substring(start, valindex); } } return unescape(cookieval); } function statistics() { var sessionid = guid = viewstat = viewstatstr = ''; var isfirstview = 0; var viewstatarr = parameterarr = []; var novisit = url = lastpage = ''; var citycode = get_cookie('hj_citycode'); sessionid = get_cookie('sessionid'); if(sessionid.length < 10) { sessionid = '3d5b9a89ba339e2636136109994c0fd6'; set_cookie('sessionid', sessionid, 1); } url = document.URL; lastpage = get_cookie('view_lastpage'); if(lastpage == url) { novisit = false; }else{ set_cookie('view_lastpage', url, 0.5); // 半小时 novisit = true; } if(novisit) { viewstatstr = get_cookie('view_stat'); if(viewstatstr == '') { isfirstview = 0; guidleft = Math.floor((Math.random()*6000000000)); guidright = Math.floor(Math.random()*6000000000); guid = guidleft.toString() + guidright.toString(); viewstat = guid+'|'+isfirstview; set_cookie('view_stat', viewstat, 1); }else{ viewstatarr = viewstatstr.split('|'); isfirstview = parseInt(viewstatarr[1])+1; guid = viewstatarr[0]; viewstat = guid+'|'+isfirstview; set_cookie('view_stat', viewstat, 1); } parameterarr.push('modulename=' + (typeof modulename != 'undefined' ? modulename : '')); parameterarr.push('contentid=' + (typeof contentid != 'undefined' ? contentid : '')); parameterarr.push('moduletype=' + (typeof moduletype != 'undefined' ? moduletype : '')); parameterarr.push('citycode=' + citycode ); parameterarr.push('sessionid=' + sessionid ); parameterarr.push('isfirstview=' + isfirstview); parameterarr.push('guid=' + guid); parameterarr.push('agent=' + string_encode(navigator.userAgent) ); parameterarr.push('url=' + string_encode(url) ); parameterarr.push('referer=' + string_encode(document.referrer)); parameterstr = parameterarr.join('&'); parameter = parameterstr.substring(0,1) == "?" ? parameterstr : '?'+parameterstr; statisticsurl = 'http://app.haoju.cn/count/statistics.php' + parameter; // 加载 document.write(''); } } // 入口 statistics();