Mercurial > hg > fapweb
diff showajax.php @ 126:71c35d5302c2
More work on cleanups, and AJAX modularization.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 22 Oct 2013 17:00:49 +0300 |
parents | |
children | aeebfedb5709 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/showajax.php Tue Oct 22 17:00:49 2013 +0300 @@ -0,0 +1,70 @@ +<? +// +// Party system / compoviewer AJAX request handler backend module +// +require "mconfig.inc.php"; +require "msite.inc.php"; + +stSetupCacheControl(); + +// Initiate SQL database connection +if (!stConnectSQLDB()) + die("Could not connect to SQL database."); + +// Fetch non-"hardcoded" settings from SQL database +stReloadSettings(); + + +// XMLHttp responses +$action = "ERROR"; +if (stChkRequestItem("action") && stChkRequestItem("type")) +{ + $action = $_REQUEST["action"]; + $type = $_REQUEST["type"]; +} + +switch ($action) +{ + case "get": + // + // Get specific data + // + switch ($type) + { + case "votes": + $sql = "SELECT * FROM votes ORDER BY utime DESC"; + break; + } + + // + // Perform query if we need to, output results + // + if (isset($sql) && ($res = stExecSQLCond($sql, "")) !== FALSE) + { + if ($type == "votes") + { + } + } + break; + + case "set": + // + // Set vote + // + if ($type == "votes" && stChkRequestItem("voter_id") && + stChkRequestItem("entry_id") && stChkRequestItem("vote")) + { + stGetCompoList(FALSE); + + stSubmitOneVote(stGetRequestItem("voter_id"), stGetRequestItem("entry_id"), stGetRequestItem("vote")); + } + else + stSetStatus(902, "No data."); + break; + + default: + stSetStatus(404, "Not Found"); + break; +} + +?> \ No newline at end of file