annotate usrlogin.php @ 110:ff511f5351df

Work on voting.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 21 Oct 2013 22:48:55 +0300
parents
children 5837b9333964
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 <?
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 $sessionType = "user";
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 require "mconfig.inc.php";
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 require "msite.inc.php";
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 require "msession.inc.php";
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 stSetupCacheControl();
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 // Initiate SQL database connection
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 if (!stConnectSQLDB())
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 die("Could not connect to SQL database.");
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 // Fetch non-"hardcoded" settings from SQL database
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 stReloadSettings();
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15
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 $gotoPage = stGetRequestItem("goto", FALSE);
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 $password = stGetRequestItem("key", FALSE);
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 $sql = stPrepareSQL("SELECT id FROM votekeys WHERE key=%s", $password);
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 if (($votekey_id = stFetchSQLColumn($sql)) !== false)
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 {
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 if (!stSessionStart(SESS_USER, $votekey_id, "userTimeout"))
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 {
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 error_log("User session AUTH LOGIN failed (session setup)");
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 $gotoPage = "loginerror";
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 }
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 else
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 stSetSessionItem("mode", stGetRequestItem("mode", "error"));
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 }
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 else
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 {
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 error_log("User session AUTH LOGIN failed (password)");
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 $gotoPage = "loginerror";
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 }
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 header("Location: ".($gotoPage !== FALSE ? $gotoPage : "news"));
ff511f5351df Work on voting.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 ?>