//////////////////////////////// 자바스크립트 함수 ///////////////////////////////////// // 브라우져 종류 var Station = { check : function(type, checkStr, checkPoint) { var name = "ETC"; for ( var list in checkPoint ) { if (checkStr.indexOf(list) != -1) name = checkPoint[list]; } escape("this." + type + " = function() { return name }"); return name; }, browser : function() { var checkStr = navigator.userAgent.toLowerCase(); var checkPoint = { "msie 6":"ie6" , "msie 7":"ie7", "msie 8":"ie8", "msie 9":"ie9", "msie 10":"ie10", "firefox":"ff", "navigator":"netscape", "opera":"op", "safari":"sf", "chrome":"cr" } return this.check("browser", checkStr, checkPoint); } } // netscape 빼고 크롬 넣을 것 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.A.B.C Safari/525.13 // OS 정보 function getOSInfoStr() { var strOs = ''; var ua = navigator.userAgent; if (ua.indexOf("NT 5.1") != -1) strOs = "xp"; else if(ua.indexOf("NT 6.2") != -1) strOs = "win8"; else if(ua.indexOf("NT 6.1") != -1) strOs = "win7"; else if(ua.indexOf("NT 6.0") != -1) strOs = "vista"; else if(ua.indexOf("NT 5.0") != -1) strOs = "w2000"; else if(ua.indexOf("Macintosh") != -1) strOs = "mac"; else if(ua.indexOf("iPhone") != -1) strOs = "iphone"; else if(ua.indexOf("Android") != -1) strOs = "android"; else if(ua.indexOf("Linux") != -1) strOs = "linux"; else strOs = "etc"; return strOs; } // 쿠키값 function getCookieVal(offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return decodeURIComponent(document.cookie.substring(offset, endstr)); } // 쿠키값 리턴 function GetCookie(name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { //while open var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal(j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } // 쿠키값 저장 SetCookie(name, value, [expires], [path], [domain], [secure]) //var ExpDate = new Date(); //ExpDate.setTime(ExpDate.getDate()+expiredays); //SetCookie('myCookie', 1234, ExpDate); function SetCookie(name, value) { var argv = SetCookie.arguments; var argc = SetCookie.arguments.length; var expires = (2 < argc) ? argv[2] : null; var path = (3 < argc) ? argv[3] : null; var domain = (4 < argc) ? argv[4] : null; var secure = (5 < argc) ? argv[5] : false; document.cookie = name + "=" + encodeURIComponent(value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } // 인코딩, 디코딩 var Base64 = { // private property _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", // public method for encoding encode : function(input) { var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var i = 0; input = Base64._utf8_encode(input); while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) enc3 = enc4 = 64; else if (isNaN(chr3)) enc4 = 64; output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); } return output; }, // public method for decoding decode : function(input) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < input.length) { enc1 = this._keyStr.indexOf(input.charAt(i++)); enc2 = this._keyStr.indexOf(input.charAt(i++)); enc3 = this._keyStr.indexOf(input.charAt(i++)); enc4 = this._keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) output = output + String.fromCharCode(chr2); if (enc4 != 64) output = output + String.fromCharCode(chr3); } output = Base64._utf8_decode(output); return output; }, // private method for UTF-8 encoding _utf8_encode : function(string) { string = string.replace(/\r\n/g,"\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); } } return utftext; }, // private method for UTF-8 decoding _utf8_decode : function(utftext) { var string = ""; var i = 0; var c = c1 = c2 = 0; while ( i < utftext.length ) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i+1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; } } return string; } } // 에러 상태 function HandleError(message, url, line, state) { var str = "에러발생(" + line + ") : " + message; if(state) alert(str); else window.status = str ; id = ln = line; msg = message; return true; } // URI 인코드 function uriChk(uri) { try { return encodeURIComponent(uri); } catch (err) { HandleError(err.message + ' ', '', 'error', 1); return "error"; } } // 저장 function logSend(log) { var obj = document.createElement('script'); obj.setAttribute('type','text/javascript'); obj.setAttribute('src','http://log.intertrack.co.kr/log.php?' + log); document.getElementsByTagName('head')[0].appendChild(obj); } // 사이트 아이디 function getUrlHost() { var Dns; Dns = location.href; Dns = Dns.replace("www.",""); Dns = Dns.split("//"); Dns = Dns[1].substr(0,Dns[1].indexOf("/")); Dns = Dns.split("."); return Dns[0]; } //////////////////////////////// 사이트 ///////////////////////////////////// var mtype = "site"; var urlHost = getUrlHost(); var ln = msg = ""; if (urlHost) { var gcode = urlHost; var market = urlHost; var url = document.URL; var ref = document.referrer; } //////////////////////////////// 일반 변수 ///////////////////////////////////// var br = Station.browser(); var os = getOSInfoStr(); var visit_new = 1; var visit_path = 1; var visit_count = 1; var ExpDate = new Date(); ExpDate.setTime(ExpDate.getTime() + 1000 * 3600 * 24 * 30); // 30일 // 새로운 방문 if (GetCookie(gcode) == null) { // 사이트내에서 얼마나 봤는지 알아봄 if (GetCookie("visit_path") != null) visit_path = parseInt(GetCookie("visit_path")) + 1; } else { if (GetCookie("visit_path") == null) { visit_count = parseInt(GetCookie(gcode)) + 1; } else { visit_new = 2; visit_path = GetCookie("visit_path"); visit_count = GetCookie(gcode); } } SetCookie(gcode, visit_count); SetCookie("visit_path", visit_path, ExpDate); //////////////////////////////// 데이터전송 ///////////////////////////////////// window.onerror = HandleError; // 전송전 에러 체크 저장 if (visit_new == 1) { var user_ss = screen.width + "*" + screen.height; var user_sc = screen.colorDepth; var log = "mode=in"; log += "&p_gcd=" + gcode + "&p_mt=" + mtype + "&p_mk=" + market; log += "&p_vn=" + visit_new + "&p_vp=" + visit_path + "&p_ct=" + visit_count; log += "&p_uss=" + uriChk(user_ss) +"&p_usc=" + uriChk(user_sc) + "&p_br=" + uriChk(br) + "&p_os=" + uriChk(os); log += "&p_hlen=" + history.length; log += "&p_lr=" + Base64.encode(ref) + "&p_lu=" + Base64.encode(url); logSend(log); }