if (navigator.userAgent.match(/mobile/i)) { window.location = "http://my.cnki.net/m/"; } function setCookie(cname, cvalue) { var expires = "expires=" + new Date(Date.now() + 365 * 24 * 60 * 60 * 1000); document.cookie = cname + "=" + escape(cvalue) + "; " + expires + "; path=/; domain=cnki.net"; } function getClientIP() { var clientIP = "-1"; var sortedParams2 = ''; var timestamp = Date.parse(new Date()); Math.random = function (seed) { return Math.sin(seed) .toString() .substr(6); }; var nonce = Math.random(timestamp); var signatureold = timestamp + nonce + "xzqp8ak940bb56p87y8ctpub3z0l89iv" + '' + ''; signatureold = signatureold.replace(/\s*/g, ""); var signature = MD5(signatureold); var appID = "shibeiWeb"; //通过Ajax获取数据 $.ajax({ type: "get", async: false, url: "http://my.cnki.net/RCDService/api/Biz/GetUserIP", dataType: "text", headers: { 'Content-Type': 'application/x-www-form-urlencoded', "timestamp": timestamp, "nonce": nonce, "signature": signature, "appID": appID, "ClientID": '' }, success: function (result) { var useripmessage = JSON.parse(result); if (useripmessage.Success == true) { clientIP = useripmessage.Data; } else { clientIP = '-1' } }, error: function (xmlHttpRequest, textStatus, errorThrown) { console.log(textStatus); } }); return clientIP; } var userip = getClientIP(); setCookie('Ecp_ClientIp', userip); window.localStorage.setItem("webuserip", userip); function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(";"); for (var i = 0; i < ca.length; i++) { var c = ca[i].trim(); if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return null; } // 获取当前时间 function getNowFormatDate() { //获取当前的日期时间 格式“yyyy-MM-dd HH:MM” var date = new Date(); var seperator1 = "-"; var seperator2 = ":"; var month = date.getMonth() + 1; var strDate = date.getDate(); if (month >= 1 && month <= 9) { month = "0" + month; } var hour = date.getHours(); var minute = date.getMinutes(); if (parseInt(hour) < 10) hour = "0" + hour; if (parseInt(minute) < 10) minute = "0" + minute; var curT = hour + ':' + minute; if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate + " " + curT // + seperator2 + date.getSeconds(); return currentdate; } // 获取uid var userUID = localStorage.getItem("webuid"); var cookieonlinetime = getCookie("c_m_expire"); if (cookieonlinetime == undefined || cookieonlinetime == "" || cookieonlinetime == 'null' || cookieonlinetime == null) { localStorage.removeItem("webuid"); localStorage.removeItem("webuserid"); } else { var nowtime = getNowFormatDate(); if (cookieonlinetime < nowtime) { localStorage.removeItem("webuid"); localStorage.removeItem("webuserid"); } else { if (userUID == undefined || userUID == "" || userUID == 'null' || userUID == null) { var shibeiLid = getCookie("c_m_LinID"); if (shibeiLid == undefined || shibeiLid == "" || shibeiLid == 'null' || shibeiLid == null) { localStorage.removeItem("webuid"); localStorage.removeItem("webuserid"); } else { var Lidfirst = shibeiLid.indexOf("="); var Lidlast = shibeiLid.lastIndexOf("&"); var cookieuid = shibeiLid.substring(Lidfirst + 1, Lidlast); window.localStorage.setItem("webuid", cookieuid); } } } } function getClientID() { var clientID = "-1"; var sortedParams2 = ''; var timestamp = Date.parse(new Date()); Math.random = function (seed) { return Math.sin(seed) .toString() .substr(6); }; var nonce = Math.random(timestamp); var signatureold = timestamp + nonce + "xzqp8ak940bb56p87y8ctpub3z0l89iv" + '' + ''; signatureold = signatureold.replace(/\s*/g, ""); var signature = MD5(signatureold); var appID = "shibeiWeb"; //通过Ajax获取数据 $.ajax({ type: "get", async: false, url: "http://my.cnki.net/RCDService/api/Biz/GetClientID", dataType: "text", headers: { 'Content-Type': 'application/x-www-form-urlencoded', "timestamp": timestamp, "nonce": nonce, "signature": signature, "appID": appID, "ClientID": '' }, success: function (result) { var clientIdMessage = JSON.parse(result); if (clientIdMessage.Success == true) { clientID = clientIdMessage.Data; } else { clientID = '' } }, error: function (xmlHttpRequest, textStatus, errorThrown) { console.log(textStatus); } }); return clientID; } var cookieclientid = getCookie("Ecp_ClientId"); if (cookieclientid == undefined || cookieclientid == "" || cookieclientid == null) { cookieclientid = getClientID(); setCookie('Ecp_ClientId', cookieclientid); window.localStorage.setItem("webclientid", cookieclientid); } else { window.localStorage.setItem("webclientid", cookieclientid); }