From c394f9c902577236e134ceb13fb1d794c74a6f7c Mon Sep 17 00:00:00 2001 From: RRRosmontis Date: Tue, 18 Aug 2026 07:53:56 +0000 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=E3=80=8C/=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zoom.js | 53 ++ login_bch.js | 1763 ++++++++++++++++++++++++++++++++++++++++++++ login_self.js | 566 ++++++++++++++ security.js | 697 ++++++++++++++++++ xssFilterResult.js | 24 + 5 files changed, 3103 insertions(+) create mode 100644 Zoom.js create mode 100644 login_bch.js create mode 100644 login_self.js create mode 100644 security.js create mode 100644 xssFilterResult.js diff --git a/Zoom.js b/Zoom.js new file mode 100644 index 0000000..575be3d --- /dev/null +++ b/Zoom.js @@ -0,0 +1,53 @@ +function Zoom(){ + this._isInit = false; + this._zoom = 1; + this._zoom_w = 1; + this._zoom_h = 1; + this._w = 1440; + this._h = 900; + this._cw = window.screen.width; + this._ch = window.screen.height; + this._getZoom = function(){ + if(!this._isInit){ + this._init(); + } + return this._zoom; + }; + this._getZoom_w = function(){ + if(!this._isInit){ + this._init(); + } + return this._zoom_w; + }; + this._getZoom_h = function(){ + if(!this._isInit){ + this._init(); + } + return this._zoom_h; + }; + this._init = function(){ + /* this._zoom = (this._cw/this._w>this._ch/this._h)?this._ch/this._h:this._cw/this._w; + this._zoom_w = this._cw/this._w; + this._zoom_h = this._ch/this._h;*/ + }; +} +var _global_zoom = new Zoom(); + +function getZoom(){//图片所放值 + if(_global_zoom == null){ + _global_zoom = new Zoom(); + } + _global_zoom._getZoom(); +} +function getZoom_H(){//单纯高度缩放值 + if(_global_zoom == null){ + _global_zoom = new Zoom(); + } + _global_zoom._getZoom_h(); +} +function getZoom_W(){//宽度所放值 + if(_global_zoom == null){ + _global_zoom = new Zoom(); + } + _global_zoom._getZoom_w(); +} \ No newline at end of file diff --git a/login_bch.js b/login_bch.js new file mode 100644 index 0000000..45c1ad2 --- /dev/null +++ b/login_bch.js @@ -0,0 +1,1763 @@ +(function(window, undefined) { + var rquickExpr = /^#([\w-]*)$/; + var jQuery = function(selector) { + return new jQuery.fn.init(selector); + }; + jQuery.fn = jQuery.prototype = { + constructor:jQuery, + length: 0, + size: function() { + return this.length; + }, + init:function(selector) { + if (typeof selector === "string") { + match = rquickExpr.exec(selector); + if(match&&match[1]){ + elem = document.getElementById(match[1]); + if (elem && elem.parentNode) { + if (elem.id !== match[1]) { + jQuery.error("语法错误,元素id和参数不一致!") + } + this.length = 1; + this[0] = elem; + } + + this.context = document; + this.selector = selector; + return this; + }else{ + jQuery.error(selector+"语法错误,暂时支持id的获取!") + } + + } else if (selector.nodeType) { + this.context = this[0] = selector; + this.length = 1; + return this; + } else { + this.context = this[0] = selector; + this.length = 1; + return this; + } + } + }; + jQuery.fn.init.prototype = jQuery.fn; + jQuery.extend = jQuery.fn.extend = function() { + var target = this; + var length = arguments.length; + var i = 0; + if (length > 1) { + target = arguments[0] || {}; + i = 1; + } + + for (; i < length; i++) { + if ((options = arguments[i]) != null) { + for (name in options) { + src = target[name]; + copy = options[name]; + if (target === copy) { + continue; + } + target[name] = copy; + } + } + } + return target; + }; + var rclass = /[\t\r\n]/g; + jQuery.fn.extend({ + html:function(value) { + var elem = this[0]; + if(!elem){ + return; + } + if (value === undefined) { + return jQuery.trim(elem.nodeType === 1 ? elem.innerHTML:""); + } else { + if (elem.nodeType === 1) { + elem.innerHTML = value; + } + } + }, + width:function(){ + var elem=this[0]; + if(!elem){ + return 0; + } + if ( jQuery.isWindow( elem ) ) { + return parseInt(elem.document.documentElement[ "offsetWidth" ]); + } + return parseInt(this.css("width")); + }, + height:function(){ + var elem=this[0]; + if(!elem){ + return 0; + } + if ( jQuery.isWindow( elem ) ) { + return parseInt(elem.document.documentElement[ "offsetHeight" ]); + } + return parseInt(this.css("height")); + }, + val:function() { + var elem = this[0]; + if (elem) { + var hooks = jQuery.valHooks[elem.type] || jQuery.valHooks[elem.nodeName.toLowerCase()]; + if (hooks && "get" in hooks && (ret = hooks.get(elem, "value")) !== undefined) { + return ret; + } + ret = elem.value; + + return typeof ret === "string" ? ret.replace(/\r/g, ""):ret == null ? "":ret; + } + return ""; + }, + attr:function(name, value) { + if (value == undefined) { + if(name=="value"){ + return this.val(); + } + } + var elem = this[0]; + if(elem){ + return jQuery.attr(elem, name, value); + } + }, + removeClass:function(){ + var elem = this[0]; + if(elem){ + elem.className=""; + } + }, + toggle:function(){ + var elem = this[0]; + if(elem){ + var cur=elem.style.display; + if("none"==cur){ + this.show(); + }else{ + this.hide(); + } + } + }, + hasClass: function(selector) { + var className = " " + selector + " ", + i = 0, + l = this.length; + for ( ; i < l; i++ ) { + if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { + return true; + } + } + + return false; + }, + addClass:function(value){ + var elem = this[0]; + if(elem){ + elem.className=value; + } + }, + show:function(){ + var elem = this[0]; + if(elem){ + elem.style.display = "block"; + } + }, + hide:function(){ + var elem = this[0]; + if(elem){ + elem.style.display = "none"; + } + }, + fadeOut:function(){ + this.hide(); + }, + fadeIn:function(){ + this.show(); + }, + slideDown:function(time,fn){ + this.show(); + if(fn){ + fn(); + } + }, + slideUp:function(time,fn){ + this.hide(); + if(fn){ + fn(); + } + }, + children: function(filter) { + var elem=this[0]; + var r = []; + if(elem){ + var elems= jQuery.sibling( elem.firstChild ); + if(elems.length>0){ + for(var i=0;i
"+onShow+"
"+offShow+"
"; + this.hide(); + this.after(content); + if(that.attr("checked")){ + $("#"+id).removeClass("checkOff"); + $("#"+id).addClass("checkOn"); + $("#"+id).attr("val",on); + that.attr("value",on); + that.attr("val",on); + }else{ + $("#"+id).removeClass("checkOn"); + $("#"+id).addClass("checkOff"); + $("#"+id).attr("val",off); + that.attr("value",off); + that.attr("val",off); + } + $("#"+id).click(function(){ + if($("#"+id).attr("val")!=on){ + $("#"+id).removeClass("checkOff"); + $("#"+id).addClass("checkOn"); + $("#"+id).attr("val",on); + that.attr("value",on); + that.attr("val",on); + }else{ + $("#"+id).removeClass("checkOn"); + $("#"+id).addClass("checkOff"); + $("#"+id).attr("val",off); + that.attr("value",off); + that.attr("val",off); + clearCookies(); + } + }); + }else{ + jQuery.error("请指定on and off in iphoneStyle!") + } + + } + }, + after:function(content){ + var elem=this[0]; + if(elem){ + if ( elem.parentNode ) { + var tmp=document.createElement("div"); + var rxhtmlTag=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig + tmp.innerHTML = content.replace( rxhtmlTag, "<$1>" ); + tmp = tmp.lastChild; + elem.parentNode.insertBefore( tmp, elem.nextSibling ); + } + } + }, + css:function(name, value) { + var elem = this[0]; + if(elem){ + return jQuery.css(elem, name, value); + } + } + + }); + // 浏览器的支持特性 + jQuery.support = (function() { + var div = document.createElement("div"); + div.setAttribute("className", "t"); + div.innerHTML = "
a"; + a = div.getElementsByTagName("a")[0]; + if (!a) { + a.style.cssText = "top:1px;float:left;opacity:.5"; + } + + var support = { + getSetAttribute:div.className !== "t", + cssFloat:!!a.style.cssFloat, + style:/top/.test(a.getAttribute("style")) + } + return support; + })(); + // 标准方法 + jQuery.extend({ + ajaxSetup:function(){ + //没有任何设置,只是防止异常 + }, + trim:function(text) { + return text == null ? "":(text + "").replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""); + }, + isIE6:function(){ + return !-[1,]&&!window.XMLHttpRequest; + }, + error:function(msg) { + throw new Error(msg); + }, + isWindow: function( obj ) { + return obj != null && obj == obj.window; + }, + sibling: function( n, elem ) { + var r = []; + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + r.push( n ); + } + } + return r; + }, + parseJSON:function(data) { + if (window.JSON && window.JSON.parse) { + return window.JSON.parse(data); + } + if (data === null) { + return data; + } + if (typeof data === "string") { + data = jQuery.trim(data); + if (data) { + var rvalidchars = /^[\],:{}\s]*$/, rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g, rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g; + if (rvalidchars.test(data.replace(rvalidescape, "@").replace(rvalidtokens, "]").replace(rvalidbraces, ""))) { + return (new Function("return " + data))(); + } + } + } + + jQuery.error("Invalid JSON: " + data); + }, + getAjaxHttp:function() { + try { + return new window.XMLHttpRequest(); + } catch (e) { + try { + return new window.ActiveXObject("Microsoft.XMLHTTP"); + } catch (e) { + jQuery.error("getAjaxHttp error"); + } + } + }, + getJSON:function(url, data, callback) { + if (!data) { + data = {}; + } + var append = ""; + for (key in data) { + append = append + "&" + encodeURIComponent(key) + "=" + encodeURIComponent(data[key]); + } + if (append.length > 0 && url.indexOf("?") == -1) { + append = "?" + append.substring(1); + } + if (append.length > 0){ + append = append.substring(1); + } + jQuery.post(url,append,function(content){ + callback(jQuery.parseJSON(content)); + }) + }, + getAjaxContent:function(url, data, callback) { + if (!data) { + data = {}; + } + var append = ""; + for (key in data) { + append = append + "&" + encodeURIComponent(key) + "=" + encodeURIComponent(data[key]); + } + if (append.length > 0 && url.indexOf("?") == -1) { + append = "?" + append.substring(1); + } + if (append.length > 0){ + append = append.substring(1); + } + jQuery.post(url,append,function(content){ + callback(content); + }) + }, + get:function(url,callback) { + var request = jQuery.getAjaxHttp(); + request.onreadystatechange = function() { + if (request.readyState == 4 && request.status == 200) { + callback(request.responseText); + } + } + request.open("get", url, true); + request.send(null); + }, + post:function(url,data,callback) { + var request = jQuery.getAjaxHttp(); + request.onreadystatechange = function() { + if (request.readyState == 4 && request.status == 200) { + callback(request.responseText); + } + } + request.open("post", url, true); + request.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"); + request.send(data); + }, + each:function(obj, callback, args) { + var value, i = 0, length = obj.length; + if (args) { + for (; i < length; i++) { + value = callback.apply(obj[i], args); + if (value === false) { + break; + } + } + } else { + for (; i < length; i++) { + value = callback.call(obj[i], i, obj[i]); + if (value === false) { + break; + } + } + } + return obj; + }, + cssProps:{ + "float":jQuery.support.cssFloat ? "cssFloat":"styleFloat" + }, + camelCase:function(string) { + return string.replace(/^-ms-/, "ms-").replace(/-([\da-z])/gi, function(all, letter) { + return letter.toUpperCase(); + }); + }, + css:function(elem, name, value) { + if (value !== undefined) { + if (typeof name === "string") { + var type = typeof value; + if ( type === "number") { + value += "px"; + } + var name = jQuery.camelCase(name); + elem.style[name]=value; + } + } else { + if (typeof name === "string") { + var name = jQuery.camelCase(name); + var val; + name = jQuery.cssProps[name] || name + var hooks = jQuery.cssHooks[name] || jQuery.cssHooks[name]; + if (hooks && "get" in hooks) { + val = hooks.get(elem); + } + if(window.getComputedStyle){ + var computed=window.getComputedStyle( elem, null ); + val = computed ? computed[ name ] || computed.getPropertyValue( name ): undefined; + } + if (val === undefined) { + val = elem.style[name]; + } + if(!val){ + val=elem.currentStyle[name] + } + return val; + }else{ + for(key in name){ + var val=name[key]; + var type = typeof val; + if ( type === "number") { + val += "px"; + } + elem.style[ jQuery.camelCase(key)]=val; + } + return; + } + } + + }, + attr:function(elem, name, value) { + var ret, hooks, nType = elem.nodeType; + if (!elem || nType === 3 || nType === 8 || nType === 2) { + return; + } + name = name.toLowerCase(); + try{ + hooks = jQuery.valHooks[elem.type] ||jQuery.attrHooks[name] || jQuery.cssHooks[name] ; + }catch(e){ + return; + } + if (value !== undefined) { + if (value === null) { + elem.removeAttribute(name); + } else if (hooks && "set" in hooks && (ret = hooks.set(elem, value, name)) !== undefined) { + return ret; + } else { + elem.setAttribute(name, value + ""); + return value; + } + } else if (hooks && "get" in hooks && (ret = hooks.get(elem, name)) !== null) { + return ret; + } else { + if (typeof elem.getAttribute !== "undefined") { + ret = elem.getAttribute(name); + } + if(ret){ + return ret; + }else{ + return ""; + } + } + }, + inArray:function(elem, arr, i) { + var len; + if (arr) { + len = arr.length; + i = i ? i < 0 ? Math.max(0, len + i):i:0; + for (; i < len; i++) { + if (i in arr && arr[i] === elem) { + return i; + } + } + } + return -1; + }, + attrHooks:{ + + }, + cssHooks:{ + + }, + valHooks:{ + option:{ + get:function(elem) { + var val = elem.attributes.value; + return !val || val.specified ? elem.value:elem.text; + } + }, + input:{ + get:function(elem) { + return elem.value; + }, + set:function(elem, value) { + return elem.value = value; + } + }, + select:{ + get:function(elem) { + var value, option, options = elem.options, index = elem.selectedIndex, one = elem.type === "select-one" || index < 0, values = one ? null:[], max = one ? index + 1:options.length, i = index < 0 ? max:one ? index:0; + for (; i < max; i++) { + option = options[i]; + if (option.selected || i === index) { + value = jQuery(option).val(); + if (one) { + return value; + } + values.push(value); + } + } + return values; + }, + set:function(elem, values) { + if (!values.length) { + values = [ values ]; + } + var value, option, options = elem.options; + var max = options.length; + for (i = 0; i < max; i++) { + value = jQuery(option[i]).val(); + this.selected = jQuery.inArray(value, values) >= 0; + } + return values; + } + } + } + }); + // 修补一些浏览器的bug + if (!jQuery.support.getSetAttribute) { + jQuery.each([ "width", "height" ], function(i, name) { + jQuery.attrHooks[name] = jQuery.extend(jQuery.attrHooks[name], { + set:function(elem, value) { + if (value === "") { + elem.setAttribute(name, "auto"); + return value; + } + } + }) + }); + } + if (!jQuery.support.style) { + jQuery.attrHooks.style = { + get:function(elem) { + return elem.style.cssText || undefined; + }, + set:function(elem, value) { + return (elem.style.cssText = value + ""); + } + }; + } + ; + jQuery.each(("blur focus focusin focusout load resize scroll unload click dblclick " + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + "change select submit keydown keypress keyup error contextmenu").split(" "), function(i, name) { + jQuery.fn[name] = function() { + var elem = this[0]; + if(elem){ + if(arguments.length>0){ + var eventHandle=arguments[0]; + if (elem.addEventListener) { + elem.addEventListener(name, eventHandle, false); + } else if (elem.attachEvent) { + elem.attachEvent("on" + name, eventHandle); + } + }else{ + try{ + var meth=elem[name]; + meth.call(elem); + }catch(e){ + if(name=="click"){ + if(document.all){ + elem.click(); + }else{ + var evt = document.createEvent("MouseEvents"); + evt.initEvent("click", true, true); + elem.dispatchEvent(evt); + } + } + } + } + } + + }; + }); + jQuery.each([ "height", "width" ], function(i, name) { + jQuery.cssHooks[name] = { + get:function(elem) { + var val = name === "width" ? elem.offsetWidth:elem.offsetHeight; + if (val <= 0 || val == null) { + val = elem.style[name]; + val = parseFloat(val) || 0; + } + return val + "px"; + } + }; + }); + window.jQuery = window.$ = jQuery; +})(window); + + +/*var search = window.location.search; +var parameters = search.replace("?", "").split("&"); +var pos, paraName, paraValue; +if (parameters && parameters != "") { + for (var i = 0; i < parameters.length; i++) { + pos = parameters[i].indexOf("="); + paraName = parameters[i].substring(0, pos); + paraValue = parameters[i].substring(pos + 1); + eval("var " + paraName + "='" + paraValue + "'") + } +}*/ + +function doauthen() { + $("#serviceShowHide").hide(); + $("#isUsernameErrorImg").hide(); + $("#isPwdErrorImg").hide(); + $("#isServiceErrorImg").hide(); + $("#isValidCodeErrorImg").hide(); + $("#serviceShowHideTop").css("background-position", "-373px 0px"); + $("#username_hk_posi").css("background-position", "-373px 0px"); + $("#pwd_hk_posi").css("background-position", "-373px 0px"); + $("#left_hk_regist_validcode").css("background-position", "-373px 0px"); + disableLoginButton(); + if (checkForm() == true) { + // 改为使用接口认证 + var queryString = encodeURIComponent(encodeURIComponent(getQueryString())); + //勾选系统配置--服务配置--域名就将用户名拼接成用户名@服务名 + var username=document.getElementById("username").value; + var domainName=""; + /* if(document.getElementById("isNoDomainName")){ + domainName=document.getElementById("isNoDomainName").value; + if(domainName=='true'){ + var temp=document.getElementById("net_access_type"); + if(temp){ + username=username+"@"+temp.value; + } + } + }*/ + + + var tj=document.getElementById("Tj_yes"); + if (tj.style.display == "block" || tj.style.display == "") { + username=prefixValue+username; + } + var userId = encodeURIComponent(encodeURIComponent(username)); + //针对记住密码加密修改 + var password = document.getElementById("pwd").value; + //alert("1 = "+password); + //对是否开启密码加密进行判断 + var encrypt = document.getElementById("passwordEncrypt").value; + var macString = getQueryStringByName("mac"); + if(isNull(macString)){ + macString="111111111"; + } + if("true"==encrypt){ + if(password.length<150){ + var passwordMac = password+">"+macString; + password = encryptedPassword(passwordMac); + } + }else{ + if(password.length>150){ + encrypt = "true"; + } + } + encrypt = encodeURIComponent(encodeURIComponent(encrypt)); + var password = encodeURIComponent(encodeURIComponent(password)); + // alert("2 = "+password); + var service = ""; + if(document.getElementById("net_access_type")){ + service = encodeURIComponent(encodeURIComponent(document.getElementById("net_access_type").value)); + } + var operatorPwd=""; + var operatorUserId=""; + if(document.getElementById('isNoOperatorPasswordFrameId')){ + //运营商密码框是否显示 + var isOperatorhide=document.getElementById('isNoOperatorPasswordFrameId').style.display; + //显示运营商密码框则提交数据---校验 + if(isOperatorhide!="none"){ + operatorPwd = document.getElementById("operatorPwd").value; + if("true"==encrypt && !isNull(operatorPwd)){ + operatorPwd = encryptedPassword(operatorPwd); + operatorPwd=encodeURIComponent(encodeURIComponent(operatorPwd)); + }else{ + operatorPwd=encodeURIComponent(encodeURIComponent(document.getElementById("operatorPwd").value)); + } + } + } + + if(document.getElementById('isNoOperatorUserIdFrameId')){ + //运营商用户名框是否显示 + var isOperatorUserIdhide=document.getElementById('isNoOperatorUserIdFrameId').style.display; + //显示运营商用户名框框则提交数据---校验 + if(isOperatorUserIdhide!="none"){ + operatorUserId=encodeURIComponent(encodeURIComponent(document.getElementById("operatorUserId").value)); + } + } + + var code=""; + var isDisplayValidCode=document.getElementById('isDisplayValidCode').style.display; + if(isDisplayValidCode!="none"){ + code=document.getElementById("validCode").value; + if(code==""){ + showerror("验证码不能为空.",5); + return false; + } + } + AuthInterFace.init("./"); + AuthInterFace.login(userId,password,service,queryString,operatorPwd,operatorUserId,code,encrypt,function(authResult){ + if(authResult.result=="success"){ + if(authResult.message&&authResult.message!=""){ + alert(authResult.message); + } + var c = document.getElementById("disPlayIs_check_no"); + var a = document.getElementById("disPlayClearSave_yes"); + var d = document.getElementById("disPlayClearTj_yes"); + var b = document.getElementById("disPlayIs_tj_no"); + var macStringTemp = getQueryStringByName("mac"); + if(isNull(macStringTemp)){ + macStringTemp="111111111"; + } + if (a.style.display == "block" || a.style.display == "") { + if (document.getElementById("username")) { + setCookies("EPORTAL_COOKIE_USERNAME", document.getElementById("username").value) + } + setCookies("EPORTAL_COOKIE_NEWV","true"); + if (document.getElementById("pwd")) { + //对密码进行rsa加密保存 + var password = document.getElementById("pwd").value; + if(password.length<150){ + var passwordMacTemp = password+">"+macStringTemp; + var passwordEncrypt = encryptedPassword(passwordMacTemp); + setCookies("EPORTAL_COOKIE_PASSWORD", passwordEncrypt) + }else{ + setCookies("EPORTAL_COOKIE_PASSWORD", password); + } + } + if (document.getElementById("net_access_type")) { + setCookies("EPORTAL_COOKIE_SERVER", document.getElementById("net_access_type").value); + setCookies("EPORTAL_COOKIE_SERVER_NAME", document.getElementById("selectDisname").innerHTML) + } + if(document.getElementById("operatorPwd")){ + setCookies("EPORTAL_COOKIE_OPERATORPWD", document.getElementById("operatorPwd").value); + } + } else { + if (c.style.display == "block" || c.style.display == "") { + setCookies("EPORTAL_COOKIE_USERNAME", ""); + setCookies("EPORTAL_COOKIE_PASSWORD", ""); + setCookies("EPORTAL_COOKIE_SERVER", ""); + setCookies("EPORTAL_COOKIE_SERVER_NAME", "") + setCookies("EPORTAL_COOKIE_OPERATORPWD",""); + setCookies("EPORTAL_COOKIE_NEWV",""); + } + } + if (d.style.display == "block" || d.style.display == "") { + setCookies("EPORTAL_AUTO_LAND", "true") + } else { + setCookies("EPORTAL_AUTO_LAND", "") + } + + if(successPage&&successPage!=''&&successPage=="true"){ + + var newWin; + var _width=document.body.clientWidth-300; + var _height=document.body.clientHeight-150; + newWin = window.open ('success.jsp?page=min', '认证成功页面', 'height=100,width=250,top="'+_height+'",left="'+_width+'",toolbar=no,menubar=no, scrollbars=no, resizable=no,location=no, status=no'); //这句要写 + newWin.location.href = "success.jsp?userIndex="+authResult.userIndex+"&keepaliveInterval="+authResult.keepaliveInterval+"&page=min"; + AuthInterFace.getOnlineUserInfo(authResult.userIndex,function(onlineUserInfo){ + var userUrl = onlineUserInfo.userUrl; + if (userUrl && userUrl != "") { + window.location.href=userUrl; + } + }); + }else{ + window.location="success.jsp?userIndex="+authResult.userIndex+"&keepaliveInterval="+authResult.keepaliveInterval; + } + }else{ + //认证失败,清除cookie中的服务选项 + setCookies("EPORTAL_COOKIE_SERVER", ""); + setCookies("EPORTAL_COOKIE_SERVER_NAME", ""); + var url=authResult.validCodeUrl; + if(url!=null&&url!=""){ + $("#validImage").attr("src",url); + $("#isDisplayValidCode").show(); + $("#isDisplayValidCodeTip").show(); + } + var message=authResult.message; + //认证失败的地方 + if(message.indexOf("ERR_USER_FIRSTLOGIN_NEED_CHANGE_PASSWORD")>-1){ + if(userId!=null&&password!=null){ + document.getElementById("userIdHj").value =userId; + document.getElementById("passHj").value =password; + document.getElementById("haiJunForm").submit(); + return; + } + } + if(message.indexOf("网络协议书")>-1){ + errorTip=true; + opensetting(); + }else if(shouldDisplayOperatorInfo(message)){ + document.getElementById("isNoOperatorPasswordFrameId").style.display="block"; + document.getElementById("isNoOperatorPasswordFrameId_space").style.display="block"; + document.getElementById("isNoOperatorUserIdFrameId").style.display="block"; + document.getElementById("isNoOperatorUserIdFrameId_space").style.display="block"; + + if(document.getElementById("selectDisname").innerHTML && + document.getElementById("selectDisname").innerHTML!="" && + document.getElementById("selectDisname").innerHTML!="请选择服务"){ + $("#operatorUserId_tip").attr("value","请输入"+document.getElementById("selectDisname").innerHTML+"对应的账号"); + $("#operatorPwd_tip").attr("value","请输入"+document.getElementById("selectDisname").innerHTML+"对应的密码"); + } + + + if(message.indexOf("")){ + operatorInfo = message.split(""); + message=operatorInfo[0]; + if(operatorInfo.length>1){ + document.getElementById("operatorUserId").value =operatorInfo[1] ; + $("#operatorUserId_tip").focus(); + } + } + + showerror(message); + }else{ + if(message.indexOf("")){ + operatorInfo = message.split(""); + message=operatorInfo[0]; + } + showerror(message); + if(errorTip){ + errorTip=false; + closeSubPage(); + } + // 显示错误信息 + } + } + }); + } +} + + +function shouldDisplayOperatorInfo(errorMessage){ + + var errorMessages = $("#countTrId").attr("errorMessages"); + + if(errorMessages==null || errorMessages=="" || errorMessages == "null") { + return false; + } + var errors = errorMessages.split(""); + if(errors.length>0){ + for(var i=0;i')>-1){ + showerror('运营商账号不能包含特殊符号',7); + return false; + } + }else{ + document.getElementById("operatorUserId").value=""; + } + } + + + if(document.getElementById('isNoOperatorPasswordFrameId')){ + //运营商密码框是否显示 + var isOperatorhide=document.getElementById('isNoOperatorPasswordFrameId').style.display; + //显示运营商密码框则提交数据---校验 + if(isOperatorhide!="none"){ + var operatorPwd=$("#operatorPwd").attr("value"); + if(operatorPwd==''){ + showerror('运营商密码不能为空',6); + return false; + } + if(operatorPwd.indexOf('>')>-1){ + showerror('运营商密码不能包含特殊符号',6); + return false; + } + }else{ + document.getElementById("operatorPwd").value=""; + setCookies("EPORTAL_COOKIE_OPERATORPWD",""); + } + } + + if ($("#uuidQrCode").val("value") == "") { + if (document.getElementById("isDisplayServicesTip").style.display!="none"){ + if ($("#net_access_type").val("value") == "" && $("#username").attr("value").indexOf("``") == -1) { + showerror("请选择服务",3); + return false + } + } + } + var jsonTemp=""; + try{ + jsonTemp=decodeURIComponent(getCookie("servicesJsonStr")); + }catch(e2){ + //alert(e2); + } + if(jsonTemp&&jsonTemp!=null&&jsonTemp!=""&&jsonTemp!="null"&&jsonTemp.length>0){ + var tempBchs=jsonTemp.split("@%%username@%%"); + var name=document.getElementById("username").value; + if(tempBchs.length>1&&tempBchs[0]!=name){ + setCookies("servicesJsonStr",encodeURIComponent(name+"@%%username@%%"+tempBchs[1])); + } + } + return true +} +function showerror(c, a) { + ableLoginButton(); + showAuthFailMessage_hk(c, a); + try { + freshImage() + } catch (b) { + } + } +function freshImage() { + jQuery("#validImage").attr("src", "./validcode?rnd=?" + Math.random()); +} +function imgLoadFail(b) { + var a = $("#" + b); + if (a) { + a.attr("src", a.attr("val")) + } +} +function showAuthFailMessage_hk(b, a) { + $("#errorInfo_hk").show(); + $("#errorInfo_tupian").show(); + jQuery("#errorInfo_center").html("" + b + ""); + jQuery("#errorInfo_center").attr("val", b); + switch(a){ + case 1: + $("#username_tip").focus(); + $("#isUsernameErrorImg").show(); + $("#username_hk_posi").css("background-position", "-373px -64px"); + break; + case 2: + $("#pwd_tip").focus(); + $("#isPwdErrorImg").show(); + $("#pwd_hk_posi").css("background-position", "-373px -64px"); + break; + case 3: + $("#isServiceErrorImg").show(); + $("#serviceShowHideTop").css("background-position", "-373px -64px"); + break; + case 4: + break; + case 5: + $("#isValidCodeErrorImg").show(); + break; + case 6: + $("#isOperatorPwdErrorImg").show(); + $("#operatorPwd_hk_posi").css("background-position", "-373px -64px"); + break; + case 7: + $("#isOperatorUserIdErrorImg").show(); + $("#operatorUserId_hk_posi").css("background-position", "-373px -64px"); + break; + } +} + +function setCookies(a, b) { + var c = new Date(); + c.setTime(c.getTime() + 1000 * 24 * 3600 * 1000); + document.cookie = a + "=" + encodeURIComponent(b) + "; expires=" + c.toGMTString() + "; path=/eportal/" +} + +function getCookie(b) { + var a = document.cookie.match(new RegExp("(^| )" + b + "=([^;]*)(;|$)")); + if (a != null) { + return decodeURIComponent(a[2]) + } + return null; +} + +function delCookie(a) { + var b = new Date(); + b.setTime(b.getTime() - 1); + document.cookie = a + "=;expires=" + b.toGMTString() + "; path=/eportal/" +} + +function getQueryString(){ + var queryString = document.location.search; + if(queryString!=null&&queryString!=""){ + return queryString.substring(1); + }else{ + return ""; + } +} + +function getQueryStringByName(name) { + var result = location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i")); + if (result == null || result.length < 1) { + return ""; + } + return result[1]; +} + +function initInputFromCookies_hk() { + var isnew = getCookie("EPORTAL_COOKIE_NEWV"); + if(isnew != null && isnew != "" ){ + var b = getCookie("EPORTAL_COOKIE_USERNAME"); + if (b != null && b != "" && document.getElementById("username")) { + document.getElementById("username").value = decodeURIComponent(b); + document.getElementById("username_tip").focus(); + } + var b = getCookie("EPORTAL_COOKIE_PASSWORD"); + var flagService = false; + if (b != null && b != "" && document.getElementById("pwd")) { + document.getElementById("pwd").value = b; + document.getElementById("pwd_tip").focus(); + if (document.getElementById("net_access_type")) { + var c = getCookie("EPORTAL_COOKIE_SERVER"); + var a = getCookie("EPORTAL_COOKIE_SERVER_NAME"); + if (c == null || c == ""||((null==services||"[]"==services||""==services)&&typeflag!="true")) { + a = $defaultService; + c = $defaultValue; + setCookies("EPORTAL_COOKIE_SERVER", ""); + setCookies("EPORTAL_COOKIE_SERVER_NAME", ""); + flagService = true; + }else{ + //portal服务不为空 + if((null!=services||"[]"!=services||""!=services)&&"true"!=typeflag){ + //检测cookie中保存的服务是否正确 + for(var i=0;i= 0) { + if (document.getElementById("errorInfo_center").textContent != "") { + document.getElementById("errorInfo_hk").style.display = "block" + } + } else { + if (document.getElementById("errorInfo_center").innerText != "") { + document.getElementById("errorInfo_hk").style.display = "block" + } + } + try { + autoLan(); + $("#username_tip").focus(); + } catch (f) { + } + +} +var services = []; +function loginFrameProcess() { + var q = 35; + var j = 33; + var r = 180; + var u = 50; + var f = 42; + var c = 1; + var v = 5; + var t = navigator.userAgent.toLowerCase(); + if ($("#username").attr("value") != "") { + $("#username").show(); + $("#username_tip").hide(); + /* $("#username").focus();*/ + } + if ($("#pwd").attr("value") == "") { + $("#pwd").hide(); + $("#pwd_tip").show() + } + if($("#operatorPwd").attr("value")==""){ + $("#operatorPwd").hide(); + $("#operatorPwd_tip").show(); + } + $("#operatorPwd_tip").focus(function(){ + $("#operatorPwd").attr("value",""); + $("#operatorPwd").show(); + $("#operatorPwd").focus(); + $("#operatorPwd_tip").hide(); + $("#serviceShowHide").hide(); + }); + $("#operatorPwd_tip").keypress(function(){ + $("#operatorPwd").attr("value",""); + $("#operatorPwd").show(); + $("#operatorPwd").focus(); + $("#operatorPwd_tip").hide(); + }); + $("#operatorPwd").blur(function(){ + if ($("#operatorPwd").attr("value") == "") { + $("#operatorPwd").hide(); + $("#operatorPwd_tip").show(); + } + }); + + if($("#operatorUserId").attr("value")==""){ + $("#operatorUserId").hide(); + $("#operatorUserId_tip").show(); + } + $("#operatorUserId_tip").focus(function(){ + $("#operatorUserId").attr("value",""); + $("#operatorUserId").show(); + $("#operatorUserId").focus(); + $("#operatorUserId_tip").hide(); + $("#serviceShowHide").hide(); + }); + $("#operatorUserId_tip").keypress(function(){ + $("#operatorUserId").attr("value",""); + $("#operatorUserId").show(); + $("#operatorUserId").focus(); + $("#operatorUserId_tip").hide(); + }); + $("#operatorUserId").blur(function(){ + if ($("#operatorUserId").attr("value") == "") { + $("#operatorUserId").hide(); + $("#operatorUserId_tip").show(); + } + }); + + + if($("#validCode").attr("value")==""){ + $("#validCode").hide(); + $("#validCode_tip").show(); + } + $("#validCode_tip").focus(function(){ + $("#validCode").attr("value",""); + $("#validCode").show(); + $("#validCode").focus(); + $("#validCode_tip").hide(); + $("#serviceShowHide").hide(); + }); + $("#validCode_tip").keypress(function(){ + $("#validCode").attr("value",""); + $("#validCode").show(); + $("#validCode").focus(); + $("#validCode_tip").hide(); + }); + $("#validCode").blur(function(){ + if ($("#validCode").attr("value") == "") { + $("#validCode").hide(); + $("#validCode_tip").show(); + } + }); + var isfocus=false; + var serviceJ = -1; + //服务获取焦点 打开服务列表 + $("#selectDisname").focus(function(){ + if(typeflag=="true"&&$("#serviceShowHideTop").attr("show")!="true"){ + //sam动态下发服务 + $("#serviceShowHideTop").click(); + } + //eportal后台配置服务 + var _default_server=document.getElementById('net_access_type').value; + for(var i=0;i0){ + var tempBchs=jsonTemp.split("@%%username@%%"); + if(tempBchs.length>1&&tempBchs[0]==username){ + serviceProcessForSecondGetByUserName(jsonTemp); + return; + } + } + var url = "userV2.do?method=getServices"; + var search = window.location.search; + var data = { + "username": username, + "search": search + }; + jQuery.getAjaxContent(url, data, serviceProcessForSecondGetByUserName); + + }else{ + if($("#serviceShowHideTop").attr("show")&& $("#serviceShowHideTop").attr("show")=="true"){ + $("#serviceShowHide").hide(); + $("#serviceShowHideTop").attr("show","false"); + }else{ + $("#serviceShowHide").show(); + $("#serviceShowHideTop").attr("show","true"); + } + } + }catch(e){ + //alert(e); + } + }); + try{ + var search_bch = window.location.search; + var service_ace=false; + if(search_bch.indexOf('&t=ace')!=-1){ + service_ace=true; + } + var serviceCookie = getCookie("EPORTAL_SERVICE_NAME"); + var serviceCookieShow = ""; + var showServiceCnt=0; + var temp_bch={}; + for(var i=0;i-1) + { + if(document.getElementById("selectDisname").innerHTML && + document.getElementById("selectDisname").innerHTML!="" && + document.getElementById("selectDisname").innerHTML!="请选择服务"){ + $("#operatorPwd_tip").attr("value","请输入"+document.getElementById("selectDisname").innerHTML+"对应的密码"); + } + $("#isNoOperatorPasswordFrameId").show(); + $("#isNoOperatorPasswordFrameId_space").show(); + }else{ + var dx=dxServics; + if(serviceName==dx&&dx!=""){ + if(document.getElementById("selectDisname").innerHTML && + document.getElementById("selectDisname").innerHTML!="" && + document.getElementById("selectDisname").innerHTML!="请选择服务"){ + $("#operatorPwd_tip").attr("value","请输入"+document.getElementById("selectDisname").innerHTML+"对应的密码"); + } + $("#isNoOperatorPasswordFrameId_space").show(); + $("#isNoOperatorPasswordFrameId").show(); + }else{ + $("#isNoOperatorPasswordFrameId").hide(); + $("#isNoOperatorPasswordFrameId_space").hide(); + $("#isNoOperatorUserIdFrameId").hide(); + $("#isNoOperatorUserIdFrameId_space").hide(); + } + } + } + if(document.getElementById("isNoDomainName")){ + $("#isNoDomainName").attr("value",$("#domainName"+serviceNum).val()); + setCookies("EPORTAL_COOKIE_DOMAIN", $("#domainName"+serviceNum).val()); + }else{ + setCookies("EPORTAL_COOKIE_DOMAIN", ""); + } + + $("#net_access_type").attr("value",serviceName); + $("#serviceShowHide").hide(); + $("#serviceShowHideTop").attr("show","false"); + hideErrorTipImage(); +} +//隐藏错误图片 +function hideErrorTipImage(){ + $("#isUsernameErrorImg").hide(); + $("#isPwdErrorImg").hide(); + $("#isServiceErrorImg").hide(); + $("#isOperatorPwdErrorImg").hide(); + $("#isValidCodeErrorImg").hide(); +} +function mOver(a) { + if (a.id == $serviceId) { + return + } + $(a).css("background-color", "#e0f1e5") +} +function mOut(a) { + if (a.id == $serviceId) { + return + } + $(a).css("background-color", "#FFFFFF") +} + +function serviceProcessForSecondGetByUserName(jsonTemp){ + if(jsonTemp==null||jsonTemp==""||jsonTemp=="null"){ + var labelHtml=""; + var label="系统默认服务"; + var labelValue="[-1-1]系统默认服务[-1-1]"; + labelHtml=labelHtml +"
"+label+"
"; + $("#serviceContent").html(labelHtml); + }else{ + var jsonStr=""; + var tempBchs=jsonTemp.split("@%%username@%%"); + if(tempBchs.length>1){ + jsonTemp=tempBchs[1]; + } + var username=$('#username').attr("value"); + try{ + setCookies("servicesJsonStr",username+"@%%username@%%"+jsonTemp); + }catch(e){ + //alert(e); + } + var serviceFormats=jsonTemp.split("@"); + for(var i=0;i0){ + jsonStr=jsonStr.substring(0,jsonStr.length-1); + jsonStr="["+jsonStr+"]"; + } + services=jQuery.parseJSON(jsonStr); + var labelHtml=""; + var cc=1; + if(dxServics.indexOf("%")>0){ + if($("#isNoOperatorPasswordFrameId")&&dxServics!=''){ + dxServics=dxServics.split("%"); + cc=2; + } + } + for(var i=0;i=1){ + for(var tt=0;tt
"+label+"
"; + //为了解决选择服务的js + labelHtml=labelHtml +""; + labelHtml=labelHtml +"
"; + } + $("#serviceContent").html(labelHtml); + } + if($("#serviceShowHideTop").attr("show")&& $("#serviceShowHideTop").attr("show")=="true"){ + $("#serviceShowHide").hide(); + $("#serviceShowHideTop").attr("show","false"); + }else{ + $("#serviceShowHide").show(); + $("#serviceShowHideTop").attr("show","true"); + } +} + +function closeSubPage() { + $("#tipframe").hide(); + window.parent.document.getElementById("divPop").style.display = 'none'; + window.parent.document.getElementById("divTupian").style.display = 'none'; + window.parent.document.getElementById("divTupian3").style.display = 'none'; + window.parent.document.getElementById("divMask").style.display = 'none'; +} + +function opensetting() { + $("#tipframe").show();//ie高版本不支持div遮罩--临时使用此实现效果 + window.parent.document.getElementById("divMask").style.height = window.parent.document.body.scrollHeight; + //显示遮罩 + window.parent.document.getElementById("divMask").style.display = 'block'; + window.parent.document.getElementById("divPop").style.display = 'block'; + window.parent.document.getElementById("divTupian").style.display = 'block'; + window.parent.document.getElementById("divTupian3").style.display = 'block'; + window.top.scrollTo(0, 0); + $("#appDownDiv").hide(); + $("#settingDiv").show(); + $("#subPageUrl_chongzhi").hide(); +} + +function openAppdown(){ + $("#tipframe").show();//ie高版本不支持div遮罩--临时使用此实现效果 + window.parent.document.getElementById("divMask").style.height = window.parent.document.body.scrollHeight; + //显示遮罩 + window.parent.document.getElementById("divMask").style.display = 'block'; + window.parent.document.getElementById("divPop").style.display = 'block'; + window.parent.document.getElementById("divTupian").style.display = 'block'; + window.parent.document.getElementById("divTupian3").style.display = 'block'; + window.top.scrollTo(0, 0); + $("#settingDiv").hide(); + $("#appDownDiv").show(); + $("#subPageUrl_chongzhi").hide(); +} + +function deletePwd(){ + document.getElementById("pwd").value=""; + +} + +function deleteUserName(){ + document.getElementById("username").value=""; +} diff --git a/login_self.js b/login_self.js new file mode 100644 index 0000000..bbaf411 --- /dev/null +++ b/login_self.js @@ -0,0 +1,566 @@ +// 登录管理系统的校验 + +var loginselfjs_tip1 = ""; +var loginselfjs_tip2 = ""; + +function checkLogin() { + var name = document.getElementById("name"); + var password = document.getElementById("password"); + // 先清空原先的错误信息 + clearError(name); + clearError(password); + var result = true; + if (trim(name.value) == "") { + document.getElementById("nameDiv").className="loginInputHKErrorDiv"; + document.getElementById("nameError").style.display="block"; + document.getElementById("forErrorMsg").style.display="block"; + var loginselfjs_tip3 = document.getElementById("loginselfjs_tip3").value; + document.getElementById("ErrorMessagePanelCommon").innerHTML=loginselfjs_tip3; + + result = false; + return result; + } else if (!checkName(name)) { + result = false; + return result; + } + if (password.value == ""||password.value == loginselfjs_tip1||password.value == loginselfjs_tip2) { + document.getElementById("password_text").className="loginInputHKError"; + document.getElementById("passwordDiv").className="loginInputHKErrorDiv"; + document.getElementById("pwdError").style.display="block"; + document.getElementById("forErrorMsg").style.display="block"; + var loginselfjs_tip4 = document.getElementById("loginselfjs_tip4").value; + document.getElementById("ErrorMessagePanelCommon").innerHTML=loginselfjs_tip4; + result = false; + return result; + } else if (!checkPassword(password)) { + result = false; + return result; + } + return result; +} + +function setScreenWidth(){ + var xmlhttp = createXMLHttp(); + if (!xmlhttp){ + return; + } + var screenWidth = window.screen.availWidth; + var toPath ="getscreenwidthbyajax.jsf?screenWidth="+screenWidth; + xmlhttp.open("GET", toPath, true); + xmlhttp.onreadystatechange = function () {SubmitStateChng(xmlhttp);}; + xmlhttp.send(null); +} + +function SubmitStateChng(xmlhttp) +{ + if (xmlhttp.readyState == 4) + { + if (xmlhttp.status == 200) { +// alert(xmlhttp.responseText); + }else { + //alert("HTTP 错误,状态码:" + xmlhttp.status); + } + }else { + //document.getElementById(a).innerHTML="正在获取信息,请稍后...."; + } +} + + +// 校验码的校验 +function checkSelf() { + var result = checkLogin(); + return result; +} + +// 自助用户登录 +function selfLogin() { + if (checkSelf()) { + saveUserInfo(); + changePasswordValue(); + document.loginform.action = "login_judge.jsf"; + document.loginform.submit(); + } +} + +function changePasswordValue(){ + //对密码进行判断,看是否要登录时加密。 + //将密码进行加密 + var password = document.getElementById("password").value; + if(password.length<105){ + password = encryptedPassword(password); + } + document.getElementById("password").value=password; +} + +// 匿名用户登录 +function guestLogin() { + document.loginform.action = "login_guest_judge.jsf"; + document.loginform.submit(); +} +//直接进入用户注册界面 +function toreguserinfo() { + if(document.getElementById("isShowAgreementHidden").value&&(document.getElementById("isShowAgreementHidden").value==true||document.getElementById("isShowAgreementHidden").value=="true")){ + $("#procotolContent").html(document.getElementById("agreementInfoHidden").value); + $("#divPop").show(); + $("#tipframe").show(); + }else{ + self.location = '../../userself/web/reguserinfo_guest.jsf'; + } +} +function registerNetWorkProtocol(){ + self.location = '../../userself/web/reguserinfo_guest.jsf'; +} + +function closeSubPage(){ + $("#divPop").hide(); + $("#tipframe").hide(); +} + +//直接进入找回密码界面 +function findPassword(){ + self.location ='../../userself/web/password_retrieve.jsf'; +} + +function isSurroundWithSpace(str) { + if (/^[\x20\u3000]+.*$/.test(str)) { + return true; + } + if (/^.*[\x20\u3000]+$/.test(str)) { + return true; + } + + return false; + +} + +// 校验用户名 +function checkName(name) { + document.getElementById("verifyError").style.display="none";//清掉校验码后边的红叉 + // var value=trim(name.value); + var value = name.value; + var tempV = value+""; + if($("#_sys_is_international").val()+""=="true"){ + while(tempV.indexOf(".") > -1 || tempV.indexOf("@")>-1){ + tempV = tempV.replace(".", "").replace("@",""); + } + } + + if(/[*]/.test(tempV.trim())){ + document.getElementById("nameDiv").className="loginInputHKErrorDiv"; + document.getElementById("nameError").style.display="block"; + document.getElementById("forErrorMsg").style.display="block"; + document.getElementById("ErrorMessagePanelCommon").innerHTML="用户名不能包含*号"; + return false; + } + + if (isSurroundWithSpace(tempV) + || !tempV + .match(/^[\u4e00-\u9fa5\w\~\!\#\$\^\&\*\(\)\_\+\{\}\|\:\?\`\-\=\[\]\;\,\.\/\x20\u3000]*$/)) { + /*appendErrorMsg(name, + '不能以空格开头或结尾!可以包含任意中英文,字符和数字,但<,>,%,\\,@,\",\'等特殊字符除外!');*/ + document.getElementById("nameDiv").className="loginInputHKErrorDiv"; + document.getElementById("nameError").style.display="block"; + document.getElementById("forErrorMsg").style.display="block";/* >*/ + var loginselfjs_tip5 = document.getElementById("loginselfjs_tip5").value; + document.getElementById("ErrorMessagePanelCommon").innerHTML=""+loginselfjs_tip5+" "; + return false; + } + + var loginselfjs_tip6 = document.getElementById("loginselfjs_tip6").value; + if(value.length>32){ + document.getElementById("nameDiv").className="loginInputHKErrorDiv"; + document.getElementById("nameError").style.display="block"; + document.getElementById("forErrorMsg").style.display="block"; + document.getElementById("ErrorMessagePanelCommon").innerHTML=loginselfjs_tip6; + return false; + } + + var byteLen=0; + for(var i=0;i'~') + byteLen=byteLen+2; + else + byteLen++; + + } + + if(byteLen>32){ + document.getElementById("nameDiv").className="loginInputHKErrorDiv"; + document.getElementById("nameError").style.display="block"; + document.getElementById("forErrorMsg").style.display="block"; + document.getElementById("ErrorMessagePanelCommon").innerHTML=loginselfjs_tip6; + return false; + } + + return true; +} +function showMsg(){ + + + var showMsgObj=document.getElementById("showMsgDiv").style; + + showMsgObj.left=$("#forErrorMsg").offset().left+28; + showMsgObj.top=$("#forErrorMsg").offset().top+30; + var loginselfjs_tip7 = document.getElementById("loginselfjs_tip7").value; + document.getElementById("showMsgDiv").innerHTML=loginselfjs_tip7; + document.getElementById("showMsgDiv").style.display="block"; +} + +function hideMsg(){ + document.getElementById("showMsgDiv").style.display="none"; +} + +// 校验密码 +function checkPassword(password) { + document.getElementById("verifyError").style.display="none";//清掉校验码后边的红叉 + var value = password.value; + var byteLen=0;//字节数 + + for(var i=0;i'~') + byteLen=byteLen+2; + else + byteLen++; + + } + + + /*if (byteLen< 3 ||byteLen> 16) { + document.getElementById("passwordDiv").className="loginInputHKErrorDiv"; + document.getElementById("pwdError").style.display="block"; + document.getElementById("forErrorMsg").style.display="block"; + var loginselfjs_tip8 = document.getElementById("loginselfjs_tip8").value; + document.getElementById("ErrorMessagePanelCommon").innerHTML=loginselfjs_tip8; + return false; + }*/ + return true; +} + +// 清空错误信息 +function clearError(errorObj) { + var childNodes = errorObj.parentNode.childNodes; + for (var i = 0; i < childNodes.length; i++) { + var child = childNodes[i]; + if (child.id && child.id == "ErrorMessagePanel") { + errorObj.parentNode.removeChild(child); + } + } + document.getElementById("nameError").style.display="none"; + document.getElementById("pwdError").style.display="none"; + document.getElementById("forErrorMsg").style.display="none"; + if(document.getElementById("ErrorMessagePanel")!=null){ + document.getElementById("ErrorMessagePanel").innerHTML=""; + } + document.getElementById("ErrorMessagePanelCommon").innerHTML=""; +} +function findPWD(){ + document.loginform.action = "../../userself/web/password_find.jsf"; + document.loginform.submit(); +} + +if(document.addEventListener){//如果是Firefox + document.addEventListener("keypress",fireFoxHandler, true); + }else{ + document.attachEvent("onkeypress",ieHandler); + } + + function fireFoxHandler(evt){ +//alert("firefox"); + if(evt.keyCode==13){ + saveUserInfo(); + selfLogin();//你的代码 + } + } + + function ieHandler(evt){ + //alert("IE"); + if(evt.keyCode==13){ + saveUserInfo(); + selfLogin();//你的代码 + } + } + var checked; + function changePic(){ + + if(checked==false){ + document.getElementById('remember').className="becheckedOver"; + checked=true; + $("#rememberPwd").attr("checked", true); + }else{ + document.getElementById('remember').className="beuncheckedOver"; + checked=false; + $("#rememberPwd").attr("checked", false); + } + } + $(document).ready(function(){ + + document.getElementById("ErrorMessagePanelCommon").innerHTML=""; + $("#reguserinfo").bind("click",toreguserinfo); + $("#passwordinfo").bind("click",findPassword); + + loginselfjs_tip1 = document.getElementById("loginselfjs_tip1").value.trim(); + loginselfjs_tip2 = document.getElementById("loginselfjs_tip2").value.trim(); + document.getElementById("password_text").value = loginselfjs_tip2; + $("#password").blur(function(){ + if($(this).val()==""){ + if($("#havehkPermission").val()+"" == "true"){ + $(this).val(loginselfjs_tip1); + }else{ + $(this).val(loginselfjs_tip2); + } + if($(this).attr("type") == "password"){ + $(this).hide(); + $('#password_text').show(); + if($("#havehkPermission").val()+"" == "true"){ + $('#password_text').val(loginselfjs_tip1); + }else{ + $('#password_text').val(loginselfjs_tip2); + } + } + else{ + var pass = $('#password_text').val(); + + if(pass.length<1){ + $(this).hide(); + $('#password_text').show(); + } + } + }else{ + document.getElementById("passwordDiv").className="loginInputHKDiv"; + } + }); + $("#name").blur(function(){ + if($(this).val().trim()==""){ + $(this).hide(); + $('#name_text').removeClass("loginInputHKClicked").addClass("loginInputHK"); + $('#name_text').show(); + }else{ + document.getElementById("passwordDiv").className="loginInputHKDiv"; + } + }); + $("#password_text").focus(function(){ + if(($("#havehkPermission").val()+"" == "true" && $(this).val()==loginselfjs_tip1) || + ($("#havehkPermission").val()+"" != "true" && $(this).val()==loginselfjs_tip2)){ + $(this).val(""); + if($(this).attr("type")=="text"){ + $(this).hide(); + $('#password').show(); + $('#password').val(""); + $('#password').focus();//加上 + document.getElementById("passwordDiv").className="loginInputHKClickedDiv"; + document.getElementById("pwdError").style.display="none"; + if(document.getElementById("nameError").style.display=="block"){//兼容IE10 + document.getElementById("nameDiv").className="loginInputHKErrorDiv"; + } + }else{ + var pass = $('#password').val(); + if(pass.length<1){ + $(this).hide(); + $('#password_text').show(); + document.getElementById("passwordDiv").className="loginInputHKClickedDiv"; + } + } + } + }); + $("#name_text").focus(function(){ + $(this).hide(); + $('#name').show(); + $('#name').val(""); + $('#name').focus();//加上 + document.getElementById("nameDiv").className="loginInputHKClickedDiv"; + document.getElementById("nameError").style.display="none"; + if(document.getElementById("nameError").style.display=="block"){//兼容IE10 + document.getElementById("nameDiv").className="loginInputHKErrorDiv"; + } + }); + $("#verify").blur(function(){ + if($(this).val().trim()==""){ + $(this).hide(); + $('#verify_text').removeClass("loginInputHKClicked").addClass("loginInputHK"); + $('#verify_text').show(); + } + }); + var verifyError=document.getElementById("verifyMsg").value; + if(verifyError=="true"){ + document.getElementById("verifyError").style.display="block"; + var loginselfjs_tip9 = document.getElementById("loginselfjs_tip9").value; + document.getElementById("forErrorMsg").style.display="block"; + document.getElementById("ErrorMessagePanelCommon").innerHTML=loginselfjs_tip9; + } + $("#verify_text").focus(function(){ + $(this).hide(); + $('#verify').show(); + $('#verify').val(""); + $('#verify').focus();//加上 + document.getElementById("verifyDiv").className="loginInputHKClickedDiv"; + document.getElementById("verifyError").style.display="none"; + if(document.getElementById("verifyError").style.display=="block"){//兼容IE10 + document.getElementById("verifyDiv").className="loginInputHKErrorDiv"; + } + }); + if ($.cookie("rmbUser") == "true") { + $("#rememberPwd").attr("checked", true); + $("#name").val($.cookie("userName")); + $('#password').show(); + document.getElementById("passwordDiv").className="loginInputHKDiv"; + $('#password_text').hide(); + $("#password").val($.cookie("passWord")); + if($.cookie("userName")!='' && $("#logginErrorHidden")[0]!=null){ + $.cookie("passWord", $.cookie("oldpassWord"), { expires: 7 ,path:"/"}); + if($.cookie("passWord")==null || $.cookie("passWord") == ''){ + clearCookie(); + } + } + document.getElementById('remember').className="bechecked"; + checked=true; + } else{ + intervale=setInterval("clear()",10); + $("#rememberPwd").attr("checked", false); + /* document.getElementById("name").value=""; */ + document.getElementById('remember').className="beunchecked"; + checked=false; + } + if(document.getElementById("name").value==""){ + $("#name_text").show(); + $("#name").hide(); + $("#name_text").focus(); + }else{ + $("#name_text").hide(); + $("#name").show(); + $("#name").focus(); + $("#name").val($("#name").val()); + } + + + }); + function clearCookie(){ + $.cookie("rmbUser", "false", { expires: -1 ,path:"/"}); + $.cookie("userName", null, { expires: -1 ,path:"/"}); + $.cookie("passWord", null, { expires: -1 ,path:"/"}); + $.cookie("oldpassWord", null, { expires: -1 ,path:"/"}); + $.cookie("rmbUser", "false", { expires: -1 }); + $.cookie("userName", null, { expires: -1 }); + $.cookie("passWord", null, { expires: -1 }); + $.cookie("oldpassWord", null, { expires: -1 }); + } + var isfirst=true; + var minHeight=630; + function resize(){ + $("#bg").width($("#divTable").width()); + $("#bg").height($("#divTable").height()); + + if(document.body.clientHeight > minHeight){ + document.getElementsByTagName("body")[0].style.overflowY="hidden"; + var gapPx = 70 + document.body.clientHeight - minHeight; + $("#topGapTd").height(gapPx>110?110:gapPx); + }else{ + document.getElementsByTagName("body")[0].style.overflowY="scroll"; + $("#topGapTd").height(70); + } + if(document.body.clientWidth > 1180){ + document.getElementsByTagName("body")[0].style.overflowX="hidden"; + }else{ + document.getElementsByTagName("body")[0].style.overflowX="scroll"; + } + } + var fornamefirst=true; + function clear(){ + if(document.getElementById("name").value!="" && document.getElementById("forName") !=null){ + document.getElementById("forName").style.display="none"; + } + } + var intervale; +//初始化页面时验证是否记住了密码 + //保存用户信息 + function saveUserInfo() { + if (document.getElementById("rememberPwd").checked == true) { + var userName = $("#name").val(); + var passWord = $("#password").val(); + $.cookie("rmbUser", "true", { expires: 7 ,path:"/"}); // 存储一个带7天期限的 cookie + $.cookie("userName", userName, { expires: 7 ,path:"/"}); // 存储一个带7天期限的 cookie + if(passWord.length<105){ + passWord = encryptedPassword(passWord); + } + $.cookie("passWord", passWord, { expires: 7 ,path:"/"}); // 存储一个带7天期限的 cookie + }else { + clearCookie(); + } + } + function hideErrorImg(){ + clearInterval(intervale); + document.getElementById("nameDiv").className="loginInputHKClickedDiv"; + document.getElementById("nameError").style.display="none"; + + } + function hidePwdErrorImg(){ + document.getElementById("pwdError").style.display="none"; + document.getElementById("passwordDiv").className="loginInputHKClickedDiv"; + } + function hideVerifyErrorImg(){ + document.getElementById("verifyError").style.display="none"; + document.getElementById("verifyDiv").className="loginInputHKClickedDiv"; + } + function blurVerifyDiv(){ + document.getElementById("verifyDiv").className="loginInputHKDiv"; + } + function blurPwdDiv(){ + document.getElementById("passwordDiv").className="loginInputHKDiv"; + } + function blurNameDiv(){ + document.getElementById("nameDiv").className="loginInputHKDiv"; + } + + function appInfo(){ + var browser = {appname: 'unknown', version: 0}, + userAgent = window.navigator.userAgent.toLowerCase(); + //IE,firefox,opera,chrome,netscape + if ( /(msie|firefox|opera|chrome|netscape)\D+(\d[\d.]*)/.test( userAgent ) ){ + browser.appname = RegExp.$1; + browser.version = RegExp.$2; + } else if ( /version\D+(\d[\d.]*).*safari/.test( userAgent ) ){ // safari + browser.appname = 'safari'; + browser.version = RegExp.$2; + } + return browser; + } + function forIe7(){ + if(document.getElementById("nameError").style.display=="block"){ + document.getElementById("nameDiv").className="loginInputHKErrorDiv"; + } + } + + function mOut(){ + if(checked==true){ + document.getElementById('remember').className="bechecked"; + + }else{ + document.getElementById('remember').className="beunchecked"; + } + } + + function mOver(){ + if(checked==true){ + document.getElementById('remember').className="becheckedOver"; + }else{ + document.getElementById('remember').className="beuncheckedOver"; + } + } + + function faq(){ + var pra = "directories=0,fullscreen=0,top=0,left=0," + + "location=0,menubar=0,status=0,toolbar=0,width="+window.screen.availWidth+",height="+(window.screen.availHeight-80); + window.open('../../repairself/web/repairreportfaqselfnologin_list.jsf', "FAQ", pra); + } + +//对密码进行加密 + function encryptedPassword (password){ + //老的加密算法有问题,使用新的实现方法 + var key = document.getElementById("publicKey").value; + var split = key.split("&"); + var publicKeyExponent = split[0]; + var publicKeyModulus =split[1]; + RSAUtils.setMaxDigits(200); + var key = new RSAUtils.getKeyPair(publicKeyExponent, "", publicKeyModulus); + var passwordEncry = RSAUtils.encryptedString(key,password.split("").reverse().join(""));//这里要对字符串进行反转,否则解密的密码是反的 + return passwordEncry; + } \ No newline at end of file diff --git a/security.js b/security.js new file mode 100644 index 0000000..c056e81 --- /dev/null +++ b/security.js @@ -0,0 +1,697 @@ +/* + * RSA, a suite of routines for performing RSA public-key computations in JavaScript. + * Copyright 1998-2005 David Shapiro. + * Dave Shapiro + * dave@ohdave.com + * changed by Fuchun, 2010-05-06 + * fcrpg2005@gmail.com + */ + +(function($w) { + +if(typeof $w.RSAUtils === 'undefined') + var RSAUtils = $w.RSAUtils = {}; + +var biRadixBase = 2; +var biRadixBits = 16; +var bitsPerDigit = biRadixBits; +var biRadix = 1 << 16; // = 2^16 = 65536 +var biHalfRadix = biRadix >>> 1; +var biRadixSquared = biRadix * biRadix; +var maxDigitVal = biRadix - 1; +var maxInteger = 9999999999999998; + +//maxDigits: +//Change this to accommodate your largest number size. Use setMaxDigits() +//to change it! +// +//In general, if you're working with numbers of size N bits, you'll need 2*N +//bits of storage. Each digit holds 16 bits. So, a 1024-bit key will need +// +//1024 * 2 / 16 = 128 digits of storage. +// +var maxDigits; +var ZERO_ARRAY; +var bigZero, bigOne; + +var BigInt = $w.BigInt = function(flag) { + if (typeof flag == "boolean" && flag == true) { + this.digits = null; + } else { + this.digits = ZERO_ARRAY.slice(0); + } + this.isNeg = false; +}; + +RSAUtils.setMaxDigits = function(value) { + maxDigits = value; + ZERO_ARRAY = new Array(maxDigits); + for (var iza = 0; iza < ZERO_ARRAY.length; iza++) ZERO_ARRAY[iza] = 0; + bigZero = new BigInt(); + bigOne = new BigInt(); + bigOne.digits[0] = 1; +}; +RSAUtils.setMaxDigits(20); + +//The maximum number of digits in base 10 you can convert to an +//integer without JavaScript throwing up on you. +var dpl10 = 15; + +RSAUtils.biFromNumber = function(i) { + var result = new BigInt(); + result.isNeg = i < 0; + i = Math.abs(i); + var j = 0; + while (i > 0) { + result.digits[j++] = i & maxDigitVal; + i = Math.floor(i / biRadix); + } + return result; +}; + +//lr10 = 10 ^ dpl10 +var lr10 = RSAUtils.biFromNumber(1000000000000000); + +RSAUtils.biFromDecimal = function(s) { + var isNeg = s.charAt(0) == '-'; + var i = isNeg ? 1 : 0; + var result; + // Skip leading zeros. + while (i < s.length && s.charAt(i) == '0') ++i; + if (i == s.length) { + result = new BigInt(); + } + else { + var digitCount = s.length - i; + var fgl = digitCount % dpl10; + if (fgl == 0) fgl = dpl10; + result = RSAUtils.biFromNumber(Number(s.substr(i, fgl))); + i += fgl; + while (i < s.length) { + result = RSAUtils.biAdd(RSAUtils.biMultiply(result, lr10), + RSAUtils.biFromNumber(Number(s.substr(i, dpl10)))); + i += dpl10; + } + result.isNeg = isNeg; + } + return result; +}; + +RSAUtils.biCopy = function(bi) { + var result = new BigInt(true); + result.digits = bi.digits.slice(0); + result.isNeg = bi.isNeg; + return result; +}; + +RSAUtils.reverseStr = function(s) { + var result = ""; + for (var i = s.length - 1; i > -1; --i) { + result += s.charAt(i); + } + return result; +}; + +var hexatrigesimalToChar = [ + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', + 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', + 'u', 'v', 'w', 'x', 'y', 'z' +]; + +RSAUtils.biToString = function(x, radix) { // 2 <= radix <= 36 + var b = new BigInt(); + b.digits[0] = radix; + var qr = RSAUtils.biDivideModulo(x, b); + var result = hexatrigesimalToChar[qr[1].digits[0]]; + while (RSAUtils.biCompare(qr[0], bigZero) == 1) { + qr = RSAUtils.biDivideModulo(qr[0], b); + digit = qr[1].digits[0]; + result += hexatrigesimalToChar[qr[1].digits[0]]; + } + return (x.isNeg ? "-" : "") + RSAUtils.reverseStr(result); +}; + +RSAUtils.biToDecimal = function(x) { + var b = new BigInt(); + b.digits[0] = 10; + var qr = RSAUtils.biDivideModulo(x, b); + var result = String(qr[1].digits[0]); + while (RSAUtils.biCompare(qr[0], bigZero) == 1) { + qr = RSAUtils.biDivideModulo(qr[0], b); + result += String(qr[1].digits[0]); + } + return (x.isNeg ? "-" : "") + RSAUtils.reverseStr(result); +}; + +var hexToChar = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'a', 'b', 'c', 'd', 'e', 'f']; + +RSAUtils.digitToHex = function(n) { + var mask = 0xf; + var result = ""; + for (i = 0; i < 4; ++i) { + result += hexToChar[n & mask]; + n >>>= 4; + } + return RSAUtils.reverseStr(result); +}; + +RSAUtils.biToHex = function(x) { + var result = ""; + var n = RSAUtils.biHighIndex(x); + for (var i = RSAUtils.biHighIndex(x); i > -1; --i) { + result += RSAUtils.digitToHex(x.digits[i]); + } + return result; +}; + +RSAUtils.charToHex = function(c) { + var ZERO = 48; + var NINE = ZERO + 9; + var littleA = 97; + var littleZ = littleA + 25; + var bigA = 65; + var bigZ = 65 + 25; + var result; + + if (c >= ZERO && c <= NINE) { + result = c - ZERO; + } else if (c >= bigA && c <= bigZ) { + result = 10 + c - bigA; + } else if (c >= littleA && c <= littleZ) { + result = 10 + c - littleA; + } else { + result = 0; + } + return result; +}; + +RSAUtils.hexToDigit = function(s) { + var result = 0; + var sl = Math.min(s.length, 4); + for (var i = 0; i < sl; ++i) { + result <<= 4; + result |= RSAUtils.charToHex(s.charCodeAt(i)); + } + return result; +}; + +RSAUtils.biFromHex = function(s) { + var result = new BigInt(); + var sl = s.length; + for (var i = sl, j = 0; i > 0; i -= 4, ++j) { + result.digits[j] = RSAUtils.hexToDigit(s.substr(Math.max(i - 4, 0), Math.min(i, 4))); + } + return result; +}; + +RSAUtils.biFromString = function(s, radix) { + var isNeg = s.charAt(0) == '-'; + var istop = isNeg ? 1 : 0; + var result = new BigInt(); + var place = new BigInt(); + place.digits[0] = 1; // radix^0 + for (var i = s.length - 1; i >= istop; i--) { + var c = s.charCodeAt(i); + var digit = RSAUtils.charToHex(c); + var biDigit = RSAUtils.biMultiplyDigit(place, digit); + result = RSAUtils.biAdd(result, biDigit); + place = RSAUtils.biMultiplyDigit(place, radix); + } + result.isNeg = isNeg; + return result; +}; + +RSAUtils.biDump = function(b) { + return (b.isNeg ? "-" : "") + b.digits.join(" "); +}; + +RSAUtils.biAdd = function(x, y) { + var result; + + if (x.isNeg != y.isNeg) { + y.isNeg = !y.isNeg; + result = RSAUtils.biSubtract(x, y); + y.isNeg = !y.isNeg; + } + else { + result = new BigInt(); + var c = 0; + var n; + for (var i = 0; i < x.digits.length; ++i) { + n = x.digits[i] + y.digits[i] + c; + result.digits[i] = n % biRadix; + c = Number(n >= biRadix); + } + result.isNeg = x.isNeg; + } + return result; +}; + +RSAUtils.biSubtract = function(x, y) { + var result; + if (x.isNeg != y.isNeg) { + y.isNeg = !y.isNeg; + result = RSAUtils.biAdd(x, y); + y.isNeg = !y.isNeg; + } else { + result = new BigInt(); + var n, c; + c = 0; + for (var i = 0; i < x.digits.length; ++i) { + n = x.digits[i] - y.digits[i] + c; + result.digits[i] = n % biRadix; + // Stupid non-conforming modulus operation. + if (result.digits[i] < 0) result.digits[i] += biRadix; + c = 0 - Number(n < 0); + } + // Fix up the negative sign, if any. + if (c == -1) { + c = 0; + for (var i = 0; i < x.digits.length; ++i) { + n = 0 - result.digits[i] + c; + result.digits[i] = n % biRadix; + // Stupid non-conforming modulus operation. + if (result.digits[i] < 0) result.digits[i] += biRadix; + c = 0 - Number(n < 0); + } + // Result is opposite sign of arguments. + result.isNeg = !x.isNeg; + } else { + // Result is same sign. + result.isNeg = x.isNeg; + } + } + return result; +}; + +RSAUtils.biHighIndex = function(x) { + var result = x.digits.length - 1; + while (result > 0 && x.digits[result] == 0) --result; + return result; +}; + +RSAUtils.biNumBits = function(x) { + var n = RSAUtils.biHighIndex(x); + var d = x.digits[n]; + var m = (n + 1) * bitsPerDigit; + var result; + for (result = m; result > m - bitsPerDigit; --result) { + if ((d & 0x8000) != 0) break; + d <<= 1; + } + return result; +}; + +RSAUtils.biMultiply = function(x, y) { + var result = new BigInt(); + var c; + var n = RSAUtils.biHighIndex(x); + var t = RSAUtils.biHighIndex(y); + var u, uv, k; + + for (var i = 0; i <= t; ++i) { + c = 0; + k = i; + for (j = 0; j <= n; ++j, ++k) { + uv = result.digits[k] + x.digits[j] * y.digits[i] + c; + result.digits[k] = uv & maxDigitVal; + c = uv >>> biRadixBits; + //c = Math.floor(uv / biRadix); + } + result.digits[i + n + 1] = c; + } + // Someone give me a logical xor, please. + result.isNeg = x.isNeg != y.isNeg; + return result; +}; + +RSAUtils.biMultiplyDigit = function(x, y) { + var n, c, uv; + + result = new BigInt(); + n = RSAUtils.biHighIndex(x); + c = 0; + for (var j = 0; j <= n; ++j) { + uv = result.digits[j] + x.digits[j] * y + c; + result.digits[j] = uv & maxDigitVal; + c = uv >>> biRadixBits; + //c = Math.floor(uv / biRadix); + } + result.digits[1 + n] = c; + return result; +}; + +RSAUtils.arrayCopy = function(src, srcStart, dest, destStart, n) { + var m = Math.min(srcStart + n, src.length); + for (var i = srcStart, j = destStart; i < m; ++i, ++j) { + dest[j] = src[i]; + } +}; + +var highBitMasks = [0x0000, 0x8000, 0xC000, 0xE000, 0xF000, 0xF800, + 0xFC00, 0xFE00, 0xFF00, 0xFF80, 0xFFC0, 0xFFE0, + 0xFFF0, 0xFFF8, 0xFFFC, 0xFFFE, 0xFFFF]; + +RSAUtils.biShiftLeft = function(x, n) { + var digitCount = Math.floor(n / bitsPerDigit); + var result = new BigInt(); + RSAUtils.arrayCopy(x.digits, 0, result.digits, digitCount, + result.digits.length - digitCount); + var bits = n % bitsPerDigit; + var rightBits = bitsPerDigit - bits; + for (var i = result.digits.length - 1, i1 = i - 1; i > 0; --i, --i1) { + result.digits[i] = ((result.digits[i] << bits) & maxDigitVal) | + ((result.digits[i1] & highBitMasks[bits]) >>> + (rightBits)); + } + result.digits[0] = ((result.digits[i] << bits) & maxDigitVal); + result.isNeg = x.isNeg; + return result; +}; + +var lowBitMasks = [0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, + 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, + 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF]; + +RSAUtils.biShiftRight = function(x, n) { + var digitCount = Math.floor(n / bitsPerDigit); + var result = new BigInt(); + RSAUtils.arrayCopy(x.digits, digitCount, result.digits, 0, + x.digits.length - digitCount); + var bits = n % bitsPerDigit; + var leftBits = bitsPerDigit - bits; + for (var i = 0, i1 = i + 1; i < result.digits.length - 1; ++i, ++i1) { + result.digits[i] = (result.digits[i] >>> bits) | + ((result.digits[i1] & lowBitMasks[bits]) << leftBits); + } + result.digits[result.digits.length - 1] >>>= bits; + result.isNeg = x.isNeg; + return result; +}; + +RSAUtils.biMultiplyByRadixPower = function(x, n) { + var result = new BigInt(); + RSAUtils.arrayCopy(x.digits, 0, result.digits, n, result.digits.length - n); + return result; +}; + +RSAUtils.biDivideByRadixPower = function(x, n) { + var result = new BigInt(); + RSAUtils.arrayCopy(x.digits, n, result.digits, 0, result.digits.length - n); + return result; +}; + +RSAUtils.biModuloByRadixPower = function(x, n) { + var result = new BigInt(); + RSAUtils.arrayCopy(x.digits, 0, result.digits, 0, n); + return result; +}; + +RSAUtils.biCompare = function(x, y) { + if (x.isNeg != y.isNeg) { + return 1 - 2 * Number(x.isNeg); + } + for (var i = x.digits.length - 1; i >= 0; --i) { + if (x.digits[i] != y.digits[i]) { + if (x.isNeg) { + return 1 - 2 * Number(x.digits[i] > y.digits[i]); + } else { + return 1 - 2 * Number(x.digits[i] < y.digits[i]); + } + } + } + return 0; +}; + +RSAUtils.biDivideModulo = function(x, y) { + var nb = RSAUtils.biNumBits(x); + var tb = RSAUtils.biNumBits(y); + var origYIsNeg = y.isNeg; + var q, r; + if (nb < tb) { + // |x| < |y| + if (x.isNeg) { + q = RSAUtils.biCopy(bigOne); + q.isNeg = !y.isNeg; + x.isNeg = false; + y.isNeg = false; + r = biSubtract(y, x); + // Restore signs, 'cause they're references. + x.isNeg = true; + y.isNeg = origYIsNeg; + } else { + q = new BigInt(); + r = RSAUtils.biCopy(x); + } + return [q, r]; + } + + q = new BigInt(); + r = x; + + // Normalize Y. + var t = Math.ceil(tb / bitsPerDigit) - 1; + var lambda = 0; + while (y.digits[t] < biHalfRadix) { + y = RSAUtils.biShiftLeft(y, 1); + ++lambda; + ++tb; + t = Math.ceil(tb / bitsPerDigit) - 1; + } + // Shift r over to keep the quotient constant. We'll shift the + // remainder back at the end. + r = RSAUtils.biShiftLeft(r, lambda); + nb += lambda; // Update the bit count for x. + var n = Math.ceil(nb / bitsPerDigit) - 1; + + var b = RSAUtils.biMultiplyByRadixPower(y, n - t); + while (RSAUtils.biCompare(r, b) != -1) { + ++q.digits[n - t]; + r = RSAUtils.biSubtract(r, b); + } + for (var i = n; i > t; --i) { + var ri = (i >= r.digits.length) ? 0 : r.digits[i]; + var ri1 = (i - 1 >= r.digits.length) ? 0 : r.digits[i - 1]; + var ri2 = (i - 2 >= r.digits.length) ? 0 : r.digits[i - 2]; + var yt = (t >= y.digits.length) ? 0 : y.digits[t]; + var yt1 = (t - 1 >= y.digits.length) ? 0 : y.digits[t - 1]; + if (ri == yt) { + q.digits[i - t - 1] = maxDigitVal; + } else { + q.digits[i - t - 1] = Math.floor((ri * biRadix + ri1) / yt); + } + + var c1 = q.digits[i - t - 1] * ((yt * biRadix) + yt1); + var c2 = (ri * biRadixSquared) + ((ri1 * biRadix) + ri2); + while (c1 > c2) { + --q.digits[i - t - 1]; + c1 = q.digits[i - t - 1] * ((yt * biRadix) | yt1); + c2 = (ri * biRadix * biRadix) + ((ri1 * biRadix) + ri2); + } + + b = RSAUtils.biMultiplyByRadixPower(y, i - t - 1); + r = RSAUtils.biSubtract(r, RSAUtils.biMultiplyDigit(b, q.digits[i - t - 1])); + if (r.isNeg) { + r = RSAUtils.biAdd(r, b); + --q.digits[i - t - 1]; + } + } + r = RSAUtils.biShiftRight(r, lambda); + // Fiddle with the signs and stuff to make sure that 0 <= r < y. + q.isNeg = x.isNeg != origYIsNeg; + if (x.isNeg) { + if (origYIsNeg) { + q = RSAUtils.biAdd(q, bigOne); + } else { + q = RSAUtils.biSubtract(q, bigOne); + } + y = RSAUtils.biShiftRight(y, lambda); + r = RSAUtils.biSubtract(y, r); + } + // Check for the unbelievably stupid degenerate case of r == -0. + if (r.digits[0] == 0 && RSAUtils.biHighIndex(r) == 0) r.isNeg = false; + + return [q, r]; +}; + +RSAUtils.biDivide = function(x, y) { + return RSAUtils.biDivideModulo(x, y)[0]; +}; + +RSAUtils.biModulo = function(x, y) { + return RSAUtils.biDivideModulo(x, y)[1]; +}; + +RSAUtils.biMultiplyMod = function(x, y, m) { + return RSAUtils.biModulo(RSAUtils.biMultiply(x, y), m); +}; + +RSAUtils.biPow = function(x, y) { + var result = bigOne; + var a = x; + while (true) { + if ((y & 1) != 0) result = RSAUtils.biMultiply(result, a); + y >>= 1; + if (y == 0) break; + a = RSAUtils.biMultiply(a, a); + } + return result; +}; + +RSAUtils.biPowMod = function(x, y, m) { + var result = bigOne; + var a = x; + var k = y; + while (true) { + if ((k.digits[0] & 1) != 0) result = RSAUtils.biMultiplyMod(result, a, m); + k = RSAUtils.biShiftRight(k, 1); + if (k.digits[0] == 0 && RSAUtils.biHighIndex(k) == 0) break; + a = RSAUtils.biMultiplyMod(a, a, m); + } + return result; +}; + + +$w.BarrettMu = function(m) { + this.modulus = RSAUtils.biCopy(m); + this.k = RSAUtils.biHighIndex(this.modulus) + 1; + var b2k = new BigInt(); + b2k.digits[2 * this.k] = 1; // b2k = b^(2k) + this.mu = RSAUtils.biDivide(b2k, this.modulus); + this.bkplus1 = new BigInt(); + this.bkplus1.digits[this.k + 1] = 1; // bkplus1 = b^(k+1) + this.modulo = BarrettMu_modulo; + this.multiplyMod = BarrettMu_multiplyMod; + this.powMod = BarrettMu_powMod; +}; + +function BarrettMu_modulo(x) { + var $dmath = RSAUtils; + var q1 = $dmath.biDivideByRadixPower(x, this.k - 1); + var q2 = $dmath.biMultiply(q1, this.mu); + var q3 = $dmath.biDivideByRadixPower(q2, this.k + 1); + var r1 = $dmath.biModuloByRadixPower(x, this.k + 1); + var r2term = $dmath.biMultiply(q3, this.modulus); + var r2 = $dmath.biModuloByRadixPower(r2term, this.k + 1); + var r = $dmath.biSubtract(r1, r2); + if (r.isNeg) { + r = $dmath.biAdd(r, this.bkplus1); + } + var rgtem = $dmath.biCompare(r, this.modulus) >= 0; + while (rgtem) { + r = $dmath.biSubtract(r, this.modulus); + rgtem = $dmath.biCompare(r, this.modulus) >= 0; + } + return r; +} + +function BarrettMu_multiplyMod(x, y) { + /* + x = this.modulo(x); + y = this.modulo(y); + */ + var xy = RSAUtils.biMultiply(x, y); + return this.modulo(xy); +} + +function BarrettMu_powMod(x, y) { + var result = new BigInt(); + result.digits[0] = 1; + var a = x; + var k = y; + while (true) { + if ((k.digits[0] & 1) != 0) result = this.multiplyMod(result, a); + k = RSAUtils.biShiftRight(k, 1); + if (k.digits[0] == 0 && RSAUtils.biHighIndex(k) == 0) break; + a = this.multiplyMod(a, a); + } + return result; +} + +var RSAKeyPair = function(encryptionExponent, decryptionExponent, modulus) { + var $dmath = RSAUtils; + this.e = $dmath.biFromHex(encryptionExponent); + this.d = $dmath.biFromHex(decryptionExponent); + this.m = $dmath.biFromHex(modulus); + // We can do two bytes per digit, so + // chunkSize = 2 * (number of digits in modulus - 1). + // Since biHighIndex returns the high index, not the number of digits, 1 has + // already been subtracted. + this.chunkSize = 2 * $dmath.biHighIndex(this.m); + this.radix = 16; + this.barrett = new $w.BarrettMu(this.m); +}; + +RSAUtils.getKeyPair = function(encryptionExponent, decryptionExponent, modulus) { + return new RSAKeyPair(encryptionExponent, decryptionExponent, modulus); +}; + +if(typeof $w.twoDigit === 'undefined') { + $w.twoDigit = function(n) { + return (n < 10 ? "0" : "") + String(n); + }; +} + +// Altered by Rob Saunders (rob@robsaunders.net). New routine pads the +// string after it has been converted to an array. This fixes an +// incompatibility with Flash MX's ActionScript. +RSAUtils.encryptedString = function(key, s) { + var a = []; + var sl = s.length; + var i = 0; + while (i < sl) { + a[i] = s.charCodeAt(i); + i++; + } + + while (a.length % key.chunkSize != 0) { + a[i++] = 0; + } + + var al = a.length; + var result = ""; + var j, k, block; + for (i = 0; i < al; i += key.chunkSize) { + block = new BigInt(); + j = 0; + for (k = i; k < i + key.chunkSize; ++j) { + block.digits[j] = a[k++]; + block.digits[j] += a[k++] << 8; + } + var crypt = key.barrett.powMod(block, key.e); + var text = key.radix == 16 ? RSAUtils.biToHex(crypt) : RSAUtils.biToString(crypt, key.radix); + result += text + " "; + } + return result.substring(0, result.length - 1); // Remove last space. +}; + +RSAUtils.decryptedString = function(key, s) { + var blocks = s.split(" "); + var result = ""; + var i, j, block; + for (i = 0; i < blocks.length; ++i) { + var bi; + if (key.radix == 16) { + bi = RSAUtils.biFromHex(blocks[i]); + } + else { + bi = RSAUtils.biFromString(blocks[i], key.radix); + } + block = key.barrett.powMod(bi, key.d); + for (j = 0; j <= RSAUtils.biHighIndex(block); ++j) { + result += String.fromCharCode(block.digits[j] & 255, + block.digits[j] >> 8); + } + } + // Remove trailing null, if any. + if (result.charCodeAt(result.length - 1) == 0) { + result = result.substring(0, result.length - 1); + } + return result; +}; + +RSAUtils.setMaxDigits(130); + +})(window); \ No newline at end of file diff --git a/xssFilterResult.js b/xssFilterResult.js new file mode 100644 index 0000000..cc22b70 --- /dev/null +++ b/xssFilterResult.js @@ -0,0 +1,24 @@ +/** + * 脚本注入结果处理 + * @param XMLHttpRequest + * @param isShowAlterMsg 是否要弹出alter信息 true展示 + * @returns {Boolean} + */ +function showXssFilterErrorMessage(XMLHttpRequest){ + + var datas = eval('('+XMLHttpRequest.responseText+')'); + //alert(datas.errorCode+":"+datas.errorMsg); + if(datas==null){//不是脚本注入拦截 + return false; + }else{ + var errorCode = datas.errorCode; + var errorMsg = datas.errorMsg; + if("xssFilterErrorCode"==errorCode){ + alert(errorMsg); + return true; + }else{//不是脚本注入拦截 + return false; + } + } +} +