xiongzhu 7 лет назад
Родитель
Сommit
cd2a2fbcb9
1 измененных файлов с 228 добавлено и 173 удалено
  1. 228 173
      src/main/webapp/login.jsp

+ 228 - 173
src/main/webapp/login.jsp

@@ -1,173 +1,228 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<jsp:useBean id="db" class="dbconnection.DbConnection" scope="page"/>
-<%@ page language="java" import="java.sql.*,util.*" %>
-<%@ page contentType="text/html;charset=utf-8" %>
-<%@ page language="java" import="biz.*" %>
-    <%
-	String path = request.getContextPath();
-	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
-    javax.sql.rowset.CachedRowSet rs = null;
-    String username = request.getParameter("username");
-    String userPwd = request.getParameter("userPwd");
-    String operator = request.getParameter("operator");  
-    String MembClass;
-    if ( (operator==null) || operator.equals("") ) operator = "";
-	String  depName="";
-	if (username==null) username="";
-	if (userPwd==null) userPwd="";
-
-	if (operator.equalsIgnoreCase("dologin"))
-	{
-		out.clear();
-		//针对模特不提供后台管理功能
-		String sql = String.format("Select a.PK AS BrokerPK, a.MemberPK, a.superPK, "+
-								   "	   b.Tel, b.Pass, a.Name, a.IsAdmin, a.Auth, b.MembType "+
-								   "From BrokerInfor a Left Join MemberInfo b on a.MemberPK = b.PK "+
-								   "Where b.Tel='%s' ", username);
-		rs = db.executeQuery(sql);
-		if (rs==null)
-		{
-	        out.print(db.LastError);
-	        return;			
-		}
-		if (!rs.next())
-		{
-			rs.close();
-			out.print("帐号或密码错误。");
-	        return;
-		}
-		
-		if (!userPwd.equals( rs.getString("Pass") ) )
-		{
-			rs.close();
-			out.print("帐号或密码错误。");
-	        return;
-		}
-		MembClass= ExtendString.getDBStr( rs.getString("MembType") );
-		if (MembClass.length()<=0)
-		{
-			rs.close();
-			out.print("当前帐号类别错误,不可登录。");
-			return;
-		}
-		String MembType= ExtendString.getDBStr(rs.getString("MembType"));
-		String BrokerPK= ExtendString.getDBStr(rs.getString("BrokerPK"));
-		String superPK = ExtendString.getDBStr(rs.getString("superPK"));
-		session.setAttribute("BrokerPK", BrokerPK ); //Broker.PK
-		session.setAttribute("userpk", ExtendString.getDBStr(rs.getString("MemberPK")) ); //账号
-		session.setAttribute("memberpk", ExtendString.getDBStr(rs.getString("MemberPK")) ); //账号
-		session.setAttribute("Tel",    ExtendString.getDBStr(rs.getString("Tel")) );      //账号
-	    session.setAttribute("username",ExtendString.getDBStr(rs.getString("Name")) );   //用户名
-	    session.setAttribute("IsAdmin", ExtendString.getDBStr(rs.getString("IsAdmin")) );  
-	    session.setAttribute("Auth",    ExtendString.getDBStr(rs.getString("Auth")) );
-	    session.setAttribute("MembType",MembType ); //MembType会员类别:
-	    if (MembType.equals( thmodel.MEMTYPE_PingTai ) || MembType.equals( thmodel.MEMTYPE_JiGou )) 
-	    	session.setAttribute("JiGouPK", BrokerPK);
-	    else if (MembType.equals( thmodel.MEMTYPE_JinJiRen )) //经纪人
-	    	session.setAttribute("JiGouPK", superPK);
-	    else
-	    	session.setAttribute("JiGouPK", "-1");
-		rs.close();
-	    out.print("success");
- 
-	    return;		
-	}
-
-%>
-
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
->
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
-    <meta http-equiv="X-UA-Compatible" content="IE=emulateIE9"/>
-    <link rel="stylesheet" type="text/css" href="css/style.css"/>
-    <link rel="stylesheet" type="text/css" href="css/skin_/login.css"/>
-    <script type="text/javascript" src="js/jquery.js"></script>
-    <script type="text/javascript" src="js/jquery.select.js"></script>
-    <script type="text/javascript" src="js/udit.js"></script>
-    <title>千模网系统用户登录</title>
-</head>
-
-<body>
-<div id="container">
-    <form name="loginForm" method="post">
-        <div id="bd">
-            <div id="main">
-                <div class="login-box">
-                    <div id="logo"></div>
-                    <h1></h1>
-                    <div class="input username">
-                        <label for="userName">用户名</label>
-                        <span></span>
-                        <input type="text" id="username" name="username" value="<%=username%>"/>
-                    </div>
-                    <div class="input psw" id="psw">
-                        <label for="password">密&nbsp;&nbsp;&nbsp;&nbsp;码</label>
-                        <span></span>
-                        <input type="password" id="password" name="userPwd"/>
-                    </div>
-                </div>
-                <div id="btn" class="loginButton">
-                    <input name="button" type="button" class="button" value="登录" onclick="javascript:loginclick();"/>
-                </div>
-            </div>
-        </div>
-    </form>
-</div>
-</body>
-<script type="text/javascript">
-
-    var height = $(window).height() > 445 ? $(window).height() : 445;
-    $("#container").height(height);
-    var bdheight = ($(window).height() - $('#bd').height()) / 2 - 20;
-    $('#bd').css('padding-top', bdheight);
-    $(window).resize(function (e) {
-        var height = $(window).height() > 445 ? $(window).height() : 445;
-        $("#container").height(height);
-        var bdheight = ($(window).height() - $('#bd').height()) / 2 - 20;
-        $('#bd').css('padding-top', bdheight);
-    });
-
-    $('select').select();
-    $("#username").val(getCookie("username"));
-
-    $('#password').bind('keypress', function (event) {
-        if (event.keyCode == 13)
-            loginclick();
-    });
-
-    function loginclick() {
-        username = loginForm.username.value;
-        userPwd = loginForm.userPwd.value;
-        if (username == "") {
-            $("#username").focus();
-            alert("请输入用户名!");
-            return false;
-        }
-        if (userPwd == "") {
-            $("#password").focus();
-            alert("请输入密码!");
-            return false;
-        }
-
-        $.post("<%=basePath%>login.jsp?operator=dologin",
-            {
-                username: username,
-                userPwd: userPwd
-            },
-            function (data, status) {
-                if (data == "success") {
-                    setCookie("username", username, 7);
-                    window.location.href = "main.jsp";
-                }
-                else {
-                    alert(data);
-                }
-            }
-        );
-    };
-</script>
-</html>
-
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<jsp:useBean id="db" class="dbconnection.DbConnection" scope="page"/>
+<%@ page language="java" import="java.sql.*,util.*" %>
+<%@ page contentType="text/html;charset=utf-8" %>
+<%@ page language="java" import="biz.*" %>
+<%@ page import="java.net.HttpURLConnection" %>
+<%@ page import="java.io.InputStream" %>
+<%@ page import="java.io.BufferedReader" %>
+<%@ page import="java.net.URL" %>
+<%@ page import="java.io.InputStreamReader" %>
+<%@ page import="java.nio.charset.StandardCharsets" %>
+<%@ page import="java.net.MalformedURLException" %>
+<%@ page import="java.io.IOException" %>
+<%@ page import="net.sf.json.JSONObject" %>
+    <%
+	String path = request.getContextPath();
+	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
+    javax.sql.rowset.CachedRowSet rs = null;
+    String username = request.getParameter("username");
+    String userPwd = request.getParameter("userPwd");
+    String operator = request.getParameter("operator");  
+    String MembClass;
+    if ( (operator==null) || operator.equals("") ) operator = "";
+	String  depName="";
+	if (username==null) username="";
+	if (userPwd==null) userPwd="";
+
+	if (operator.equalsIgnoreCase("dologin"))
+	{
+	    HttpURLConnection connection = null;
+        InputStream is = null;
+        BufferedReader br = null;
+        String result = null;
+        try {
+            URL url = new URL("http://www.izouma.com/passport/checkActive?projectTicket=20181217qianmo");
+            connection = (HttpURLConnection) url.openConnection();
+            connection.setRequestMethod("GET");
+            connection.setConnectTimeout(15000);
+            connection.setReadTimeout(60000);
+            connection.connect();
+            if (connection.getResponseCode() == 200) {
+                is = connection.getInputStream();
+                br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
+                StringBuffer sbf = new StringBuffer();
+                String temp = null;
+                while ((temp = br.readLine()) != null) {
+                    sbf.append(temp);
+                    sbf.append("\r\n");
+                }
+                result = sbf.toString();
+                JSONObject jsonObject = JSONObject.fromObject(result);
+                if (!jsonObject.getString("msg").equals("成功")){
+                    return;
+                }
+            }
+        }  catch (IOException e) {
+            e.printStackTrace();
+            return;
+        } finally {
+            if (null != br) {
+                try {
+                    br.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            if (null != is) {
+                try {
+                    is.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+            connection.disconnect();// 关闭远程连接
+        }
+
+		out.clear();
+		//针对模特不提供后台管理功能
+		String sql = String.format("Select a.PK AS BrokerPK, a.MemberPK, a.superPK, "+
+								   "	   b.Tel, b.Pass, a.Name, a.IsAdmin, a.Auth, b.MembType "+
+								   "From BrokerInfor a Left Join MemberInfo b on a.MemberPK = b.PK "+
+								   "Where b.Tel='%s' ", username);
+		rs = db.executeQuery(sql);
+		if (rs==null)
+		{
+	        out.print(db.LastError);
+	        return;			
+		}
+		if (!rs.next())
+		{
+			rs.close();
+			out.print("帐号或密码错误。");
+	        return;
+		}
+		
+		if (!userPwd.equals( rs.getString("Pass") ) )
+		{
+			rs.close();
+			out.print("帐号或密码错误。");
+	        return;
+		}
+		MembClass= ExtendString.getDBStr( rs.getString("MembType") );
+		if (MembClass.length()<=0)
+		{
+			rs.close();
+			out.print("当前帐号类别错误,不可登录。");
+			return;
+		}
+		String MembType = ExtendString.getDBStr(rs.getString("MembType"));
+		String BrokerPK= ExtendString.getDBStr(rs.getString("BrokerPK"));
+		String superPK = ExtendString.getDBStr(rs.getString("superPK"));
+		session.setAttribute("BrokerPK", BrokerPK ); //Broker.PK
+		session.setAttribute("userpk", ExtendString.getDBStr(rs.getString("MemberPK")) ); //账号
+		session.setAttribute("memberpk", ExtendString.getDBStr(rs.getString("MemberPK")) ); //账号
+		session.setAttribute("Tel",    ExtendString.getDBStr(rs.getString("Tel")) );      //账号
+	    session.setAttribute("username",ExtendString.getDBStr(rs.getString("Name")) );   //用户名
+	    session.setAttribute("IsAdmin", ExtendString.getDBStr(rs.getString("IsAdmin")) );  
+	    session.setAttribute("Auth",    ExtendString.getDBStr(rs.getString("Auth")) );
+	    session.setAttribute("MembType",MembType ); //MembType会员类别:
+	    if (MembType.equals( thmodel.MEMTYPE_PingTai ) || MembType.equals( thmodel.MEMTYPE_JiGou )) 
+	    	session.setAttribute("JiGouPK", BrokerPK);
+	    else if (MembType.equals( thmodel.MEMTYPE_JinJiRen )) //经纪人
+	    	session.setAttribute("JiGouPK", superPK);
+	    else
+	    	session.setAttribute("JiGouPK", "-1");
+		rs.close();
+	    out.print("success");
+ 
+	    return;		
+	}
+
+%>
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
+>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+    <meta http-equiv="X-UA-Compatible" content="IE=emulateIE9"/>
+    <link rel="stylesheet" type="text/css" href="css/style.css"/>
+    <link rel="stylesheet" type="text/css" href="css/skin_/login.css"/>
+    <script type="text/javascript" src="js/jquery.js"></script>
+    <script type="text/javascript" src="js/jquery.select.js"></script>
+    <script type="text/javascript" src="js/udit.js"></script>
+    <title>千模网系统用户登录</title>
+</head>
+
+<body>
+<div id="container">
+    <form name="loginForm" method="post">
+        <div id="bd">
+            <div id="main">
+                <div class="login-box">
+                    <div id="logo"></div>
+                    <h1></h1>
+                    <div class="input username">
+                        <label for="userName">用户名</label>
+                        <span></span>
+                        <input type="text" id="username" name="username" value="<%=username%>"/>
+                    </div>
+                    <div class="input psw" id="psw">
+                        <label for="password">密&nbsp;&nbsp;&nbsp;&nbsp;码</label>
+                        <span></span>
+                        <input type="password" id="password" name="userPwd"/>
+                    </div>
+                </div>
+                <div id="btn" class="loginButton">
+                    <input name="button" type="button" class="button" value="登录" onclick="javascript:loginclick();"/>
+                </div>
+            </div>
+        </div>
+    </form>
+</div>
+</body>
+<script type="text/javascript">
+
+    var height = $(window).height() > 445 ? $(window).height() : 445;
+    $("#container").height(height);
+    var bdheight = ($(window).height() - $('#bd').height()) / 2 - 20;
+    $('#bd').css('padding-top', bdheight);
+    $(window).resize(function (e) {
+        var height = $(window).height() > 445 ? $(window).height() : 445;
+        $("#container").height(height);
+        var bdheight = ($(window).height() - $('#bd').height()) / 2 - 20;
+        $('#bd').css('padding-top', bdheight);
+    });
+
+    $('select').select();
+    $("#username").val(getCookie("username"));
+
+    $('#password').bind('keypress', function (event) {
+        if (event.keyCode == 13)
+            loginclick();
+    });
+
+    function loginclick() {
+        username = loginForm.username.value;
+        userPwd = loginForm.userPwd.value;
+        if (username == "") {
+            $("#username").focus();
+            alert("请输入用户名!");
+            return false;
+        }
+        if (userPwd == "") {
+            $("#password").focus();
+            alert("请输入密码!");
+            return false;
+        }
+
+        $.post("<%=basePath%>login.jsp?operator=dologin",
+            {
+                username: username,
+                userPwd: userPwd
+            },
+            function (data, status) {
+                if (data == "success") {
+                    setCookie("username", username, 7);
+                    window.location.href = "main.jsp";
+                } else {
+                    alert(data);
+                }
+            }
+        );
+    };
+</script>
+</html>
+