annotate showajax.php @ 136:aeebfedb5709

Add some copyright headers.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 22 Oct 2013 22:04:22 +0300
parents 71c35d5302c2
children 75cf14ee99a7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
126
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 <?
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 //
136
aeebfedb5709 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
3 // FAPWeb Simple Demoparty System
aeebfedb5709 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
4 // Party information display system AJAX backend module
aeebfedb5709 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
5 // (C) Copyright 2012-2013 Tecnic Software productions (TNSP)
126
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 //
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 require "mconfig.inc.php";
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 require "msite.inc.php";
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 stSetupCacheControl();
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 // Initiate SQL database connection
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 if (!stConnectSQLDB())
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 die("Could not connect to SQL database.");
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 // Fetch non-"hardcoded" settings from SQL database
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 stReloadSettings();
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 // XMLHttp responses
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 $action = "ERROR";
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 if (stChkRequestItem("action") && stChkRequestItem("type"))
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 {
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 $action = $_REQUEST["action"];
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 $type = $_REQUEST["type"];
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 }
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 switch ($action)
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 {
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 case "get":
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 //
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 // Get specific data
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 //
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 switch ($type)
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 {
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 case "votes":
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 $sql = "SELECT * FROM votes ORDER BY utime DESC";
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 break;
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 }
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 //
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 // Perform query if we need to, output results
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 //
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 if (isset($sql) && ($res = stExecSQLCond($sql, "")) !== FALSE)
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 {
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 if ($type == "votes")
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 {
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 }
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 }
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 break;
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 case "set":
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 //
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 // Set vote
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 //
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 if ($type == "votes" && stChkRequestItem("voter_id") &&
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 stChkRequestItem("entry_id") && stChkRequestItem("vote"))
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 {
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 stGetCompoList(FALSE);
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 stSubmitOneVote(stGetRequestItem("voter_id"), stGetRequestItem("entry_id"), stGetRequestItem("vote"));
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 }
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 else
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 stSetStatus(902, "No data.");
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 break;
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 default:
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 stSetStatus(404, "Not Found");
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 break;
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 }
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 ?>