forked from qangel/EECS-341-Project
-
Notifications
You must be signed in to change notification settings - Fork 1
/
user.jsp
134 lines (128 loc) · 3.73 KB
/
user.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<%@page language="java" import="java.sql.*"%>
<%
String redirect = null; // Where to send the user.
boolean hasCookie = false;
Cookie cookie = null;
String user = "";
String password = "";
String team = "";
String week = "";
String alt_user = "";
String show = request.getParameter("show");
if(show==null) show = "";
/* Initialize the sql connection. */
Driver drs = (Driver)Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/jlj",
"jlj","fanball");
String command = "{call isUser(?,?)}";
CallableStatement cs = conn.prepareCall(command);
ResultSet rs = null;
ResultSet rs1 = null;
ResultSetMetaData rsmd = null;
ResultSetMetaData rsmd1 = null;
/* Parse cookies for username and password */
Cookie[] cookies = request.getCookies();
if(cookies != null) {
for(int i=0; i<cookies.length; i++) {
cookie = cookies[i];
if(cookie.getName().equals("uname"))
if(!cookie.getValue().equals(""))
user = cookie.getValue();
if(cookie.getName().equals("password"))
if(!cookie.getValue().equals(""))
password = cookie.getValue();
}
}
if(!user.equals("") && !password.equals("")) {
cs.setString(1, user);
cs.setString(2, password);
rs = cs.executeQuery();
rs.first();
if(rs.getString(1).equals("0")) {
cookie = new Cookie("uname", "");
response.addCookie(cookie);
cookie = new Cookie("password", "");
response.addCookie(cookie);
redirect = "login.jsp";
}
}
else redirect = "login.jsp";
if(redirect == null) {
String query;
Statement srs = conn.createStatement();
%>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Fantasy Football</title>
</head>
<body>
<div align="center">
<table>
<tr>
<td align="center"><h3>Fantasy Football</h3></td>
</tr>
</table>
<table border cellpadding=8>
<tr>
<td><a href="user.jsp">League Statistics</a></td>
<td><a href="user.jsp?show=team">My Team</a></td>
<td><a href="user.jsp?show=match">My Matchup</a></td>
<td><a href="user.jsp?show=players">Available Players</a></td>
</tr>
<tr>
<td><a href="logout.jsp">logout</a></td>
<td><a href="user.jsp?show=roster">Other Rosters</a></td>
<td><a href="user.jsp?show=other_match">Other Matchups</a></td>
<td><a href="user.jsp?show=draft">Draft Players</a></td>
</tr>
<%if(user.equals("admin")) {%>
<tr>
<td colspan=4 align="center">
<a href="admin.jsp">Admin Control Panel</a>
</td>
</tr>
<%}%>
</table>
<br />
<table>
<%if(show.equals("team")) {%>
<%@include file="team.jsp"%>
<%} else if(show.equals("match")) {%>
<%@include file="match.jsp"%>
<%} else if(show.equals("players")) {%>
<%@include file="players.jsp"%>
<%} else if(show.equals("draft")) {%>
<%@include file="draft.jsp"%>
<%} else if(show.equals("roster")) {%>
<%@include file="roster.jsp"%>
<%} else if(show.equals("other_match")) {%>
<%@include file="other_match.jsp"%>
<%} else {%>
<%@include file="league.jsp"%>
<% } %>
</table>
</div>
</body>
</html>
<%
} else {
/* Display a redirect page */
%>
<!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">
<head>
<meta http-equiv="Refresh" content="5; URL=<%= redirect %>" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Fantasy Football</title>
</head>
<body>
<div align="center">
Click <a href="<%= redirect %>">here</a> if your browser does not redirect
you.
</div>
</body>
</html>
<% } %>