Mercurial > hg > fapweb
annotate usrlogin.php @ 306:6610311ac48e
Improve user login handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 26 Nov 2013 19:51:11 +0200 |
parents | 7181350076c1 |
children | 2f46b6254ff2 |
rev | line source |
---|---|
110 | 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 | 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 | 11 |
156 | 12 // |
13 // Initialize | |
14 // | |
110 | 15 stSetupCacheControl(); |
16 | |
17 if (!stConnectSQLDB()) | |
18 die("Could not connect to SQL database."); | |
19 | |
20 stReloadSettings(); | |
21 | |
22 | |
156 | 23 // |
24 // Authenticate | |
25 // | |
110 | 26 $gotoPage = stGetRequestItem("goto", FALSE); |
306
6610311ac48e
Improve user login handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
304
diff
changeset
|
27 $errorPage = stGetRequestItem("error", FALSE); |
110 | 28 $password = stGetRequestItem("key", FALSE); |
306
6610311ac48e
Improve user login handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
304
diff
changeset
|
29 $error = 0; |
110 | 30 |
31 $sql = stPrepareSQL("SELECT id FROM votekeys WHERE key=%s", $password); | |
32 if (($votekey_id = stFetchSQLColumn($sql)) !== false) | |
33 { | |
129 | 34 if (!stSessionStart(SESS_USER, $password, "userTimeout")) |
110 | 35 { |
36 error_log("User session AUTH LOGIN failed (session setup)"); | |
306
6610311ac48e
Improve user login handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
304
diff
changeset
|
37 $error = 2; |
110 | 38 } |
39 else | |
40 stSetSessionItem("mode", stGetRequestItem("mode", "error")); | |
41 } | |
42 else | |
43 { | |
44 error_log("User session AUTH LOGIN failed (password)"); | |
306
6610311ac48e
Improve user login handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
304
diff
changeset
|
45 $error = 1; |
110 | 46 } |
47 | |
306
6610311ac48e
Improve user login handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
304
diff
changeset
|
48 $nextPage = ($error != 0) ? $errorPage : $gotoPage; |
6610311ac48e
Improve user login handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
304
diff
changeset
|
49 |
6610311ac48e
Improve user login handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
304
diff
changeset
|
50 header("Location: ".($nextPage !== FALSE ? $nextPage : stGetSetting("defaultPage")) |
6610311ac48e
Improve user login handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
304
diff
changeset
|
51 ($error ? "?error=".$error : ""); |
110 | 52 ?> |