Mercurial > hg > fapweb
view vote.inc.php @ 20:02ff0c29df8a
s/voter/entry/.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 06 Dec 2012 18:45:43 +0200 |
parents | ea0f98a0bed8 |
children | 5bc8bd5c7ecc |
line wrap: on
line source
<? function stGetSessionItem($name, $default = "") { return isset($_SESSION[$name]) ? trim($_SESSION[$name]) : $default; } // Check if voting is enabled if (!stChkSetting("allowVoting")) { echo "<h1>Sorry, voting disabled!</h1>\n". "<p>Voting functionality not available at this time.</p>\n"; } else { stVoteSessionAuth(); $mode = stGetSessionItem("status", 0); if ($mode < 0) { echo "<h1>Oh noes, an error!</h1>\n". "<ul>\n".stGetSessionItem("message", "")."</ul>\n". "<form name=\"vote\" action=\"vote\" method=\"post\">\n". " <input type=\"submit\" value=\" Go back \" />\n". "</form>\n"; stSetVoteStatus(0); } else if ($mode == 0) { echo "<h1>Voting system</h1>\n". "<form name=\"vote\" action=\"dovote.php\" method=\"post\">\n". " ".stGetFormHiddenInput("mode", "key")."\n". " <div class=\"votectrl\">\n". " Enter your vote key:\n". " ".stGetFormTextInput(30, 30, "key", "", "", stGetSessionItem("key"), "autocomplete=\"off\"")."\n". " <input type=\"submit\" value=\" Login \" />\n". " </div>\n". "</form>\n"; } else if ($mode == 1) { $showAuthors = stGetSetting("showVoteAuthors"); stGetCompoList(FALSE); echo "<h1>Voting system</h1>\n". "<form name=\"vote\" action=\"dovote.php\" method=\"post\">\n". stGetFormHiddenInput("mode", "check")."\n". stGetFormHiddenInput("key", stGetSessionItem("key"))."\n". " <div class=\"votectrl\">\n". " <input type=\"submit\" value=\" Submit votes! \" />". " </div>\n"; foreach ($compos as $id => $compo) if (count($compo["entries"]) > 0) { echo " <table class=\"vote\">\n". " <tr><th colspan=\"3\">".chentities($compo["name"])."</th></tr>\n". " <tr>\n". " <th class=\"vtitle\">Title</th>\n". ($showAuthors ? " <th class=\"vauthor\">Author</th>\n" : ""). " "; for ($i = stGetSetting("voteMin"); $i <= stGetSetting("voteMax"); $i++) { echo "<th class=\"vvalue\">".$i."</th>"; } echo "\n". " </tr>\n"; $row = 0; foreach ($compo["entries"] as $eid => $entry) { echo " <tr class=\"".($row % 2 == 1 ? "rodd" : "reven")."\">\n". " <td class=\"vtitle\">".$entry["name"]."</td>\n". ($showAuthors ? " <td class=\"vauthor\">".$entry["author"]."</td>\n" : ""). " "; for ($i = stGetSetting("voteMin"); $i <= stGetSetting("voteMax"); $i++) { $name = "entry".$eid; echo "<td class=\"vvalue\"><input type=\"radio\" name=\"".$name."\" ". ($i == stGetSessionItem($name, 0) ? "checked=\"checked\" " : "")."value=\"".$i."\" /></td>"; } echo "\n". " </tr>\n"; $row++; } echo " </table>\n"; } echo "<div class=\"votectrl\"><input type=\"submit\" value=\" Submit votes! \" /></div>\n"; echo "</form>\n"; } else if ($mode == 2) { echo "<h1>Yay, you have voted!</h1>\n". "<p>Now go FAP some more! And make a demo about it.</p>"; stSessionEnd(TRUE); } } ?>