annotate usrlogin.php @ 304:7181350076c1

Change how user login errors are handled.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 26 Nov 2013 06:27:06 +0200
parents 8df523e6326a
children 6610311ac48e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 <?
155
5b92f130ba87 Add copyright header blurbs.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
2 //
5b92f130ba87 Add copyright header blurbs.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
3 // FAPWeb Simple Demoparty System
5b92f130ba87 Add copyright header blurbs.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
4 // Administration interface session login handler
5b92f130ba87 Add copyright header blurbs.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
5 // (C) Copyright 2012-2013 Tecnic Software productions (TNSP)
5b92f130ba87 Add copyright header blurbs.
Matti Hamalainen <ccr@tnsp.org>
parents: 129
diff changeset
6 //
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 $sessionType = "user";
175
8df523e6326a User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
8 require_once "mconfig.inc.php";
8df523e6326a User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
9 require_once "msite.inc.php";
8df523e6326a User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents: 156
diff changeset
10 require_once "msession.inc.php";
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11
156
fa7f3defffd0 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 155
diff changeset
12 //
fa7f3defffd0 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 155
diff changeset
13 // Initialize
fa7f3defffd0 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 155
diff changeset
14 //
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 stSetupCacheControl();
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 if (!stConnectSQLDB())
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 die("Could not connect to SQL database.");
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 stReloadSettings();
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22
156
fa7f3defffd0 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 155
diff changeset
23 //
fa7f3defffd0 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 155
diff changeset
24 // Authenticate
fa7f3defffd0 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 155
diff changeset
25 //
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 $gotoPage = stGetRequestItem("goto", FALSE);
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 $password = stGetRequestItem("key", FALSE);
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 $sql = stPrepareSQL("SELECT id FROM votekeys WHERE key=%s", $password);
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 if (($votekey_id = stFetchSQLColumn($sql)) !== false)
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 {
129
Matti Hamalainen <ccr@tnsp.org>
parents: 123
diff changeset
32 if (!stSessionStart(SESS_USER, $password, "userTimeout"))
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 {
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 error_log("User session AUTH LOGIN failed (session setup)");
304
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
35 $gotoPage = "vote?error=2";
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 }
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 else
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 stSetSessionItem("mode", stGetRequestItem("mode", "error"));
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 }
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 else
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 {
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 error_log("User session AUTH LOGIN failed (password)");
304
7181350076c1 Change how user login errors are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
43 $gotoPage = "vote?error=1";
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 }
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45
123
5837b9333964 Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents: 110
diff changeset
46 header("Location: ".($gotoPage !== FALSE ? $gotoPage : stGetSetting("defaultPage")));
110
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 ?>