-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdefault.aspx
More file actions
261 lines (209 loc) · 6.55 KB
/
default.aspx
File metadata and controls
261 lines (209 loc) · 6.55 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<%@ Page language="C#"%>
<%@ Import Namespace="System.Data.SqlClient" %>
<!--
Copyright 2002-2009 Corey Trager
Distributed under the terms of the GNU General Public License
-->
<!-- #include file = "inc.aspx" -->
<script language="C#" runat="server">
string sql;
///////////////////////////////////////////////////////////////////////
void Page_Load(Object sender, EventArgs e)
{
Util.set_context(HttpContext.Current);
Util.do_not_cache(Response);
titl.InnerText = Util.get_setting("AppTitle","BugTracker.NET") + " - "
+ "logon";
msg.InnerText = "";
// see if the connection string works
try
{
btnet.DbUtil.get_sqlconnection();
try
{
btnet.DbUtil.execute_nonquery("select count(1) from users");
}
catch (SqlException e1)
{
Util.write_to_log (e1.Message);
Util.write_to_log (Util.get_setting("ConnectionString","?"));
msg.InnerHtml = "Unable to find \"bugs\" table.<br>"
+ "Click to <a href=install.aspx>setup database tables</a>";
}
}
catch (SqlException e2)
{
msg.InnerHtml = "Unable to connect.<br>"
+ e2.Message + "<br>"
+ "Check Web.config file \"ConnectionString\" setting.<br>"
+ "Check also README.html<br>"
+ "Check also <a href=http://sourceforge.net/forum/forum.php?forum_id=226938>Help Forum</a> on Sourceforge.";
}
// Get authentication mode
string auth_mode = Util.get_setting("WindowsAuthentication","0");
HttpCookie username_cookie = Request.Cookies["user"];
string previous_auth_mode = "0";
if (username_cookie!=null) {
previous_auth_mode = username_cookie["NTLM"];
}
// If an error occured, then force the authentication to manual
if (Request.QueryString["msg"] == null)
{
// If windows authentication only, then redirect
if (auth_mode == "1")
{
btnet.Util.redirect("loginNT.aspx", Request, Response);
}
// If previous login was with windows authentication, then try it again
if ( previous_auth_mode == "1" && auth_mode == "2" )
{
Response.Cookies["user"]["name"] = "";
Response.Cookies["user"]["NTLM"] = "0";
btnet.Util.redirect("loginNT.aspx", Request, Response);
}
}
else
{
if (Request.QueryString["msg"] != "logged off")
{
msg.InnerHtml = "Error during windows authentication:<br>"
+ Request.QueryString["msg"];
}
}
// fill in the username first time in
if (!IsPostBack)
{
if ( previous_auth_mode == "0" )
{
if ((Request.QueryString["user"] == null) || (Request.QueryString["password"] == null))
{
// User name and password are not on the querystring.
if (username_cookie != null)
{
// Set the user name from the last logon.
user.Value = username_cookie["name"];
}
}
else
{
// User name and password have been passed on the querystring.
user.Value = Request.QueryString["user"];
pw.Value = Request.QueryString["password"];
on_logon();
}
}
}
else
{
on_logon();
}
}
///////////////////////////////////////////////////////////////////////
void on_logon()
{
string auth_mode = Util.get_setting("WindowsAuthentication","0");
if ( auth_mode != "0" ) {
if (user.Value.Trim() == "") {
btnet.Util.redirect("loginNT.aspx", Request, Response);
}
}
bool authenticated = btnet.Authenticate.check_password(user.Value, pw.Value);
if (authenticated)
{
sql = "select us_id from users where us_username = N'$us'";
sql = sql.Replace("$us", user.Value.Replace("'","''"));
DataRow dr = btnet.DbUtil.get_datarow(sql);
if (dr != null)
{
int us_id = (int)dr["us_id"];
btnet.Security.create_session(
Request,
Response,
us_id,
user.Value,
"0");
btnet.Util.redirect(Request, Response);
}
else
{
// How could this happen? If someday the authentication
// method uses, say LDAP, then check_password could return
// true, even though there's no user in the database";
msg.InnerText = "User not found in database";
}
}
else
{
msg.InnerText = "Invalid User or Password.";
}
}
</script>
<html>
<head>
<title id="titl" runat="server">btnet logon</title>
<link rel="StyleSheet" href="btnet.css" type="text/css">
</head>
<body onload="document.forms[0].user.focus()">
<div style="float: right;">
<span>
<a target=_blank style=" font-size: 7pt; font-family: arial; letter-spacing: 1px;" href=http://ifdefined.com/bugtrackernet.html>BugTracker.NET</a>
<br>
<a target=_blank style=" font-size: 7pt; font-family: arial; letter-spacing: 1px;" href=http://ifdefined.com/README.html>Help</a>
<br>
<a target=_blank style=" font-size: 7pt; font-family: arial; letter-spacing: 1px;" href=mailto:ctrager@yahoo.com>Feedback</a>
<br>
<a target=_blank style=" font-size: 7pt; font-family: arial; letter-spacing: 1px;" href=about.html>About</a>
<br>
<a target=_blank style=" font-size: 7pt; font-family: arial; letter-spacing: 1px;" href=http://ifdefined.com/README.html>Donate</a>
</span>
</div>
<table border=0><tr>
<%
Response.Write (Application["custom_logo"]);
%>
</table>
<div align="center">
<table border=0><tr><td>
<form class=frm runat="server">
<table border=0>
<% if (Util.get_setting("WindowsAuthentication", "0") != "0") { %>
<tr><td colspan="2" class="smallnote">To login using your Windows ID, leave User blank</td></tr>
<% } %>
<tr>
<td class=lbl>User:</td>
<td><input runat="server" type=text class=txt id="user"></td>
</tr>
<tr>
<td class=lbl>Password:</td>
<td><input runat="server" type=password class=txt id="pw"></td>
</tr>
<tr><td colspan=2 align=left>
<span runat="server" class=err id="msg"> </span>
</td></tr>
<tr><td colspan=2 align=center>
<input class=btn type=submit value="Logon" runat="server">
</td></tr>
</table>
</form>
<span>
<% if (Util.get_setting("AllowGuestWithoutLogin","0") == "1") { %>
<p>
<a style="font-size: 8pt;"href="bugs.aspx">Continue as "guest" without logging in</a>
<p>
<% } %>
<% if (Util.get_setting("AllowSelfRegistration","0") == "1") { %>
<p>
<a style="font-size: 8pt;"href="register.aspx">Register</a>
<p>
<% } %>
<% if (Util.get_setting("ShowForgotPasswordLink","1") == "1") { %>
<p>
<a style="font-size: 8pt;"href="forgot.aspx">Forgot your username or password?</a>
<p>
<% } %>
</span>
</td></tr></table>
<% Response.Write (Application["custom_welcome"]); %>
</div>
</body>
</html>