loginsb_i.jsp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
  2. <%@page import="cn.sinobest.framework.util.ConfUtil"%>
  3. <%@page import="cn.sinobest.framework.util.HTMLEncode"%>
  4. <%
  5. response.setHeader("Pragma", "No-cache");
  6. response.setHeader("Cache-Control", "no-cache");
  7. response.setDateHeader("Expires", 0);
  8. String DeployVersion= ConfUtil.getParam("DEPLOY_VERSION");
  9. String CheckImage = ConfUtil.getParam("CHECKIMAGE_SB");//是否需要校验码,注意需要修改WEB.XML配置
  10. String isEncrypty = ConfUtil.getParam("LOGIN_ENCRYPT");//登录时是否加密传输
  11. String loginTip = ConfUtil.getParam("LOGIN_TIP");//登陆提示信息
  12. String UNSAFE_VALIDATEFORM = ConfUtil.getParam("UNSAFE_VALIDATEFORM","");
  13. String LOGINID = request.getParameter("LOGINID") == null
  14. ? ""
  15. : HTMLEncode.encode(request.getParameter("LOGINID"));
  16. String reason = (String) request.getAttribute("reason");//登录失败的原因
  17. if (reason == null) {
  18. reason = "";
  19. }
  20. String des = String.valueOf(System.currentTimeMillis());
  21. des = des.substring(des.length()-7);
  22. //清空操作员session对象
  23. request.getSession().removeAttribute("OPERNAME");
  24. request.getSession().removeAttribute("OPERID");
  25. request.getSession().removeAttribute("OPERATOR");
  26. request.getSession().removeAttribute("LOGINTYPE");
  27. request.getSession().invalidate();//清空session
  28. //Cookie cookie = request.getCookies()[0];//获取cookie
  29. //cookie.setMaxAge(0);//让cookie过期
  30. Cookie[] cookies = request.getCookies();
  31. if (cookies != null) {
  32. for(Cookie c:cookies){
  33. c.setMaxAge(0);//让cookie过期
  34. }
  35. }
  36. request.getSession(true).setAttribute("des_key", des + "hnisi");//密钥
  37. %>
  38. <html>
  39. <head>
  40. <title>系统登录界面</title>
  41. <script src="<%=request.getContextPath()%>/js/comm/fw/encrypt.js?v=<%=DeployVersion%>"></script>
  42. <script src="<%=request.getContextPath()%>/js/comm/fw/encrypt2.js?v=<%=DeployVersion%>"></script>
  43. <%-- 当需要ajax登录时 ,使用以下代码。请求ajaxlogin.do,传参:LOGINID,PASSWORD
  44. <% String jsMin = "-min"; %>
  45. <script src="<%=request.getContextPath()%>/js/comm/lib/jquery<%=jsMin%>.js"></script>
  46. <script src="<%=request.getContextPath()%>/js/comm/lib/jquery.cookie<%=jsMin%>.js"></script>
  47. <script src="<%=request.getContextPath()%>/js/comm/lib/json2<%=jsMin%>.js"></script>
  48. <script src="<%=request.getContextPath()%>/js/comm/fw/ajax<%=jsMin%>.js"></script>
  49. <script language="javascript">
  50. function doLogin(){
  51. var contextPath='<%=request.getContextPath()%>';
  52. var loginid=document.frm.LOGINID.value.toLowerCase();
  53. var password=document.frm.PASSWORD1.value.toLowerCase();
  54. for(var unsafei=0;unsafei<fwUnsafeValidateFormTokens.length;unsafei++){
  55. var lowerUnsafe = fwUnsafeValidateFormTokens[unsafei].toLowerCase().replace(" ","");
  56. if(-1 != loginid.indexOf(lowerUnsafe) || -1 != password.indexOf(lowerUnsafe)){
  57. document.all.div_error.style.display="block";
  58. document.all.div_error.innerHTML="<font color='RED'>登录失败!</font><br/>输入的用户名和密码中包含不安全字符!"
  59. return false;
  60. }
  61. }
  62. setSsoUid();
  63. _1_();
  64. frm._1_.value='';
  65. frm.PASSWORD1.value = '';
  66. var loginid=document.frm.LOGINID.value;
  67. var password=document.frm.PASSWORD.value;
  68. var args = {'LOGINID':loginid,'PASSWORD':password};
  69. $.ajax({
  70. url:contextPath+'/ajaxlogin.do'
  71. ,data:$.param(args)
  72. ,cache:false
  73. ,async:false
  74. ,type:'post'
  75. ,error:function (request, textStatus, errorThrown) {
  76. alert("登录失败!");
  77. //错误提示
  78. }
  79. ,success:function (data, textStatus) {
  80. if(data.Token!=null){
  81. token=data.Token;//更新全局变量token标志
  82. }
  83. if (data.flag == 'MFW0001') {
  84. alert("登录成功!");
  85. //转跳到首页
  86. } else {
  87. alert(data.message);
  88. //错误提示
  89. }
  90. },
  91. beforeSend:function(XMLHttpRequest ){
  92. var cToken = $.cookie("Token") || token;XMLHttpRequest.setRequestHeader('Token',cToken);
  93. }
  94. });
  95. }
  96. </script>
  97. --%>
  98. <style>
  99. body {
  100. font-size: 12px;
  101. font-family: 宋体, 微软雅黑;
  102. background: white;
  103. font: 900 12px "Arial", Helvetica, sans-serif;
  104. color: #0d5f83;
  105. }
  106. a,table,td,tr,input,select,span,div,textarea,p {
  107. font-size: 12px;
  108. font-family: 宋体, 微软雅黑;
  109. font: 900 12px "宋体", Helvetica, sans-serif;
  110. }
  111. .textbox {
  112. border: #B5B8C8 1px solid;
  113. color: #000000;
  114. width: 100%;
  115. height: 21px;
  116. background-color: white;
  117. font-size: 14px;
  118. font-weight: bold;
  119. font-family: 宋体, 微软雅黑;
  120. }
  121. .img_d {
  122. background:
  123. url('<%=request.getContextPath()%>/themes/default/images/login-d.jpg')
  124. no-repeat left top;
  125. }
  126. .img_login {
  127. background:
  128. url('<%=request.getContextPath()%>/themes/default/images/login2.jpg')
  129. no-repeat left top;
  130. }
  131. #version {
  132. width:100%;
  133. height:30px;
  134. text-align:center;
  135. color:red;
  136. }
  137. .btn {
  138. margin:0px 0px 0px 120px;
  139. padding:2px;
  140. }
  141. .btn a {
  142. float: left;
  143. text-decoration: none;
  144. color: #ccc;
  145. padding: 6px 15px 0 0;
  146. margin-right: 8px;
  147. font: 900 12px "宋体", Helvetica, sans-serif;
  148. }
  149. .btn a.current {
  150. background: url('<%=request.getContextPath()%>/themes/default/images/btn_blue.png') no-repeat top right;
  151. color: #0d5f83;
  152. }
  153. .btn a.current span {
  154. background: url('<%=request.getContextPath()%>/themes/default/images/btn_blue.png') no-repeat top left;
  155. }
  156. .btn a span {
  157. float: left;
  158. padding-top:2px;
  159. padding-right: 15px;
  160. display: block;
  161. margin-top: -6px;
  162. height: 24px;
  163. }
  164. </style>
  165. <style>
  166. .div-loading-hint{
  167. width: 300px;
  168. height: 124px;
  169. border: 1px solid grey;
  170. position: absolute;
  171. left : 50%;
  172. top :50%;
  173. margin-left:-150px;
  174. margin-top:-62px;
  175. text-align: center;
  176. background:white;
  177. display: none;
  178. z-index: 999;
  179. }
  180. .div-loading-hint div{
  181. padding-top:50px;
  182. }
  183. .box-shadow{
  184. filter: progid:DXImageTransform.Microsoft.Shadow(color='#969696', Direction=135, Strength=2);/*for ie6,7,8*/
  185. background-color: white;
  186. -moz-box-shadow:2px 2px 5px #969696;/*firefox*/
  187. -webkit-box-shadow:2px 2px 5px #969696;/*webkit*/
  188. box-shadow:2px 2px 5px #969696;/*opera或ie9*/
  189. }
  190. .div-loading-hint #loadingTooSlowText{
  191. display : none;
  192. color : red;
  193. }
  194. </style>
  195. <script language="javascript">
  196. var isEncrypty = '<%=isEncrypty%>';
  197. var fwUnsafeValidateFormTokens = "<%=UNSAFE_VALIDATEFORM%>".split("|");
  198. function fKeyPress(obj){
  199. var keycode;
  200. keycode=window.event.keyCode;
  201. if (keycode==0xD) {
  202. if(obj.name=="LOGINID" && obj.value != ""){
  203. document.frm.PASSWORD1.focus();
  204. document.frm.PASSWORD1.select();
  205. }else if(obj.name=="PASSWORD1"){
  206. if(document.frm.IMAGCHECK){
  207. document.frm.IMAGCHECK.focus();
  208. document.frm.IMAGCHECK.select();
  209. }else{
  210. doSubmit();
  211. }
  212. }else if(obj.name="IMAGCHECK"){
  213. doSubmit();
  214. }
  215. }
  216. }
  217. function _1_(){
  218. var pw = frm.PASSWORD1.value;
  219. var t = pw;
  220. if (isEncrypty == '1') {
  221. var _1 = frm._1_.value;
  222. t = stringToHex(encrypt(_1,pw));
  223. }
  224. frm.PASSWORD.value = t;
  225. }
  226. function init(){
  227. document.frm.LOGINID.focus();
  228. document.frm.LOGINID.value=GetCookie("RS_ID");
  229. document.frm.PASSWORD1.value=GetCookie("RS_PW");
  230. <%if (!reason.equals("")) {%>
  231. document.all.div_error.style.display="block";
  232. document.all.div_error.innerHTML="<font color='RED'>登录失败!</font><br/><%=reason%>";
  233. <%}else{%>
  234. //如果用户密码不为空自动登录
  235. if(document.frm.LOGINID.value != "" && document.frm.PASSWORD1.value !=""){
  236. doSubmit();
  237. }
  238. <%}%>
  239. isIE8();
  240. }
  241. function doSubmit(){
  242. if (document.frm.LOGINID.value == "" || document.frm.PASSWORD1.value =="") {
  243. document.all.div_error.style.display="block";
  244. document.all.div_error.innerHTML="<font color='RED'>登录失败!</font><br/>请输入用户名和密码!"
  245. return false;
  246. }else{
  247. var loginid=document.frm.LOGINID.value.toLowerCase();
  248. var password=document.frm.PASSWORD1.value.toLowerCase();
  249. for(var unsafei=0;unsafei<fwUnsafeValidateFormTokens.length;unsafei++){
  250. var lowerUnsafe = fwUnsafeValidateFormTokens[unsafei].toLowerCase().replace(" ","");
  251. if(-1 != loginid.indexOf(lowerUnsafe) || -1 != password.indexOf(lowerUnsafe)){
  252. document.all.div_error.style.display="block";
  253. document.all.div_error.innerHTML="<font color='RED'>登录失败!</font><br/>输入的用户名和密码中包含不安全字符!"
  254. return false;
  255. }
  256. }
  257. }
  258. <%
  259. String ENABLE_LOGINHINT = ConfUtil.getParam("ENABLE_LOGINHINT","TRUE");
  260. if(ENABLE_LOGINHINT.equalsIgnoreCase("TRUE")){
  261. %>
  262. fnShowLoadingHint();
  263. <%
  264. }
  265. %>
  266. setSsoUid();
  267. _1_();
  268. //用户记住密码时才保存cookie
  269. if(document.frm.RememberMe.checked){
  270. createCookie("RS_ID",document.frm.LOGINID.value,86400000000,"/");
  271. createCookie("RS_PW",document.frm.PASSWORD1.value,86400000000,"/");
  272. }
  273. frm._1_.value='';
  274. frm.PASSWORD1.value = '';
  275. document.frm.submit();
  276. }
  277. function doReset(){
  278. document.frm.LOGINID.value = '';
  279. document.frm.PASSWORD1.value = '';
  280. if(document.frm.IMAGCHECK){
  281. document.frm.IMAGCHECK.value='';
  282. }
  283. document.frm.LOGINID.focus();
  284. }
  285. function refresh(){
  286. var src = document.getElementById("authImg").src;
  287. document.getElementById("authImg").src=src+"?now="+new Date();
  288. }
  289. /*屏蔽特殊字符*/
  290. function LOGINID_keydown(event){
  291. switch(event.keyCode){
  292. case 220://屏蔽 \
  293. return false;
  294. default:
  295. return true;
  296. }
  297. }
  298. function isIE8(){
  299. var brower = navigator.userAgent.toLowerCase().match(/msie ([\d.]+)/);
  300. var version = brower ? brower[1] : 0;
  301. if (parseInt(version) < 8) {
  302. document.getElementById("version").innerText = "【请使用IE9版本登录使用本系统,其他浏览器或IE版本不确保完全兼容。】";
  303. }
  304. }
  305. function GetCookie(name){
  306. var arg = name + "=";
  307. var alen = arg.length;
  308. var clen = document.cookie.length;
  309. var i = 0;
  310. while (i < clen)
  311. {
  312. var j = i + alen;
  313. if (document.cookie.substring(i, j) == arg)
  314. return GetCookieVal (j);
  315. i = document.cookie.indexOf(" ", i) + 1;
  316. if (i == 0) break;
  317. }
  318. return "";
  319. }
  320. function GetCookieVal(offset){
  321. var endstr = document.cookie.indexOf (";", offset);
  322. if (endstr == -1)
  323. endstr = document.cookie.length;
  324. return unescape(document.cookie.substring(offset, endstr));
  325. }
  326. </script>
  327. </head>
  328. <body leftmargin="0" topmargin="0" onload="init()">
  329. <FORM name="frm" method="post" action="<%=request.getContextPath()%>/framework/security/loginsb!login.do">
  330. <input type="hidden" name="_rtnURL" value="<%=request.getContextPath()%>/framework/security/loginsb.do" />
  331. <input type="hidden" name="PASSWORD"></input>
  332. <input type="hidden" name="_1_" value="<%=des%>"></input>
  333. <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  334. <tr>
  335. <td width="950" height="600" class="img_login">
  336. <table height="600" border="0" align="center" cellpadding="0" cellspacing="0">
  337. <tr>
  338. <td width="450">
  339. <div style="position:relative;top:85px;color:red;font-size:20px;text-align:right" id="loginTip">
  340. </div>
  341. </td>
  342. <td valign="top">
  343. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  344. <tr>
  345. <td>&nbsp;</td>
  346. <td width="335" height="370">&nbsp;</td>
  347. </tr>
  348. <tr>
  349. <td>&nbsp;</td>
  350. <td><table width="335" border="0" align="center" cellpadding="0" cellspacing="0">
  351. <tr>
  352. <td>&nbsp;</td>
  353. <td height="45">&nbsp;</td>
  354. </tr>
  355. <tr>
  356. <td width="31%"><div align="right" class="unnamed1">登录ID:</div></td>
  357. <td width="69%"><input name="LOGINID" class="textbox" type="text" onkeydown="return LOGINID_keydown(event)" onKeyUp="fKeyPress(this)"
  358. onBlur="this.value=this.value.replace(/[\u4E00-\u9FA5]/g,'')" style="width: 154px" maxlength=18 ></td>
  359. </tr>
  360. <tr>
  361. <td>
  362. <div align="right" class="unnamed1">密&nbsp;&nbsp;码:</div></td>
  363. <td><input name="PASSWORD1" class="textbox" autocomplete="off" type="password" onKeyUp="fKeyPress(this)" style="width: 154px" maxlength=20></td>
  364. </tr>
  365. <tr>
  366. <td></td>
  367. <td><input name="RememberMe" type="checkbox">记住帐号密码</td>
  368. </tr>
  369. <%
  370. if (CheckImage.equals("1")) {
  371. %>
  372. <%--图形校验码--%>
  373. <tr>
  374. <td><div align="right" class="unnamed1">校验码:</div></td>
  375. <td><input name="IMAGCHECK" class="textbox" type="text" style="width: 90px" onKeyUp="fKeyPress(this)" size="5" maxlength="4">
  376. <a title="单击刷新" href="javascript:void(0)" onclick="refresh()"><img id="authImg" src="<%=request.getContextPath()%>/ImageCheck.jpg"
  377. height="20" border=0 align="absmiddle"
  378. />
  379. </td>
  380. </tr>
  381. <%
  382. }
  383. %>
  384. <tr>
  385. <td height="45" colspan="2" >
  386. <div class="btn" >
  387. <a href="javascript:void(0);" class="current" onclick="doSubmit();return false;"><span></span>登录</a>
  388. <a href="javascript:void(0);" class="current" onclick="doReset();return false;"><span></span>清除</a>
  389. </div>
  390. </td>
  391. </tr>
  392. </table></td>
  393. </tr>
  394. <tr>
  395. <td></td>
  396. <td width="275">
  397. <div id="div_error" style="display: none"></div>
  398. </td>
  399. </tr>
  400. </table></td>
  401. </tr>
  402. </table></td>
  403. <td height="600" class="img_d">&nbsp;</td>
  404. </tr>
  405. <tr>
  406. <td colspan="2">
  407. <div id="version">
  408. </div>
  409. </td>
  410. </tr>
  411. </table>
  412. </FORM>
  413. <div id="loadingHint" class="div-loading-hint box-shadow">
  414. <div>
  415. <span id="loadingHintText">正在登录,请稍候</span>
  416. <span id="loadingHintDot"></span>
  417. <br></br>
  418. <span id="loadingTooSlowText"><%=ConfUtil.getParam("LOGIN_SLOW_HINT","您的网络速度较为缓慢,请耐心等候") %></span>
  419. </div>
  420. </div>
  421. <DIV id="divDiableScreen" style="display:none;Z-INDEX: 100; POSITION: absolute; FILTER: alpha(opacity=15); BACKGROUND-COLOR: #000; WIDTH: 100%; HEIGHT: 100%; TOP: 0px; LEFT: 0px; opacity: 0.15" >
  422. <IFRAME style="Z-INDEX: -1; POSITION: absolute; FILTER: progid:DXImageTransform.Microsoft.Alpha(opacity:0); WIDTH: 100%; HEIGHT: 100%; TOP: 0px; LEFT: 0px" src="about:blank" frameBorder=0></IFRAME>
  423. <DIV style="Z-INDEX: -1; POSITION: absolute; WIDTH: 100%; HEIGHT: 100%; TOP: 0px; LEFT: 0px">&nbsp;</DIV>
  424. </DIV>
  425. <script>
  426. (function(){
  427. //点击提交后经过的秒数
  428. var secondsAfterSubmit = 0;
  429. var interval;
  430. window.fnShowLoadingHint = function(){
  431. divDiableScreen.style.height = document.body.scrollHeight;
  432. divDiableScreen.style.display = 'block';
  433. loadingHint.style.display = 'block';
  434. interval = setInterval(function(){
  435. secondsAfterSubmit += 0.5;
  436. loadingHintDot.innerText = loadingHintDot.innerText + '.';
  437. if(loadingHintDot.innerText.length >3){
  438. loadingHintDot.innerText = '';
  439. }
  440. if(secondsAfterSubmit>2){
  441. loadingTooSlowText.style.display = "block";
  442. }
  443. },500);
  444. }
  445. bindListener(window,'unload',function(e){
  446. clearInterval(interval);
  447. });
  448. function bindListener(obj,eventName,fun) {
  449. if (obj.addEventListener) {
  450. obj.addEventListener(eventName,fun,false);
  451. } else if (obj.attachEvent) {
  452. obj.attachEvent('on'+eventName,fun);
  453. } else {
  454. obj['on'+eventName] = fun;
  455. }
  456. }
  457. })();
  458. </script>
  459. <script>
  460. loginTip.innerHTML = "<%=loginTip%>";
  461. function characterHideAndShow(){
  462. loginTip.style.display = (loginTip.style.display=='none'?'block':'none');
  463. if('none'==loginTip.style.display){//隐藏一秒后显示
  464. setTimeout("characterHideAndShow()",1000);
  465. }else{//显示3秒后隐藏
  466. setTimeout("characterHideAndShow()",3000);
  467. }
  468. }
  469. characterHideAndShow();
  470. </script>
  471. </body>
  472. </html>