Mercurial > hg > fapweb
view vsubmit.php @ 76:78893039b1f6
Rename a variable.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 17 Oct 2013 18:10:39 +0300 |
parents | 36392d1d6b5f |
children |
line wrap: on
line source
<? $sessionType = "vote"; require "mconfig.inc.php"; require "msite.inc.php"; function stSubmitVotes($voter_id) { foreach ($compos as $id => $compo) foreach ($compo["entries"] as $eid => $entry) { $vote = stGetRequestItem("entry".$eid); $sql = stPrepareSQL("SELECT id FROM votes WHERE voter_id=%d AND entry_id=%d", $voter_id, $eid); if (($res = stFetchSQLColumn($sql)) === false) { $sql = stPrepareSQL( "INSERT INTO votes (voter_id,entry_id,value) VALUES (%d,%d,%d)", $voter_id, $eid, $vote); if (stExecSQL($sql) === false) return FALSE; } else { $sql = stPrepareSQL( "UPDATE votes SET value=%d WHERE voter_id=%d AND entry_id=%d", $vote, $voter_id, $eid); if (stExecSQL($sql) === false) return FALSE; } } return TRUE; } // // Start of the main code // if (stStartSubmitSession("allowVoting", $sessionType)) { // Vote submission if (!$errorSet && $mode == "vote") { stSetSessionStatus(1); stGetCompoList(FALSE); // Check the submitted vote values foreach ($compos as $id => $compo) foreach ($compo["entries"] as $eid => $entry) { $name = "entry".$eid; $vote = stGetRequestItem($name); if (!$errorSet && ($vote < stGetSetting("voteMin") || $vote > stGetSetting("voteMax"))) { stError("One or more vote value was out of bounds. Trying to cheat, eh?"); $vote = 0; } stSetSessionItem($name, $vote); } if (!$errorSet) { if (stSubmitVotes($user["id"])) stSetSessionStatus(2); } } stEndSubmitSession($sessionType); } ?>