Mercurial > hg > fapweb
diff vote.inc.php @ 110:ff511f5351df
Work on voting.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 21 Oct 2013 22:48:55 +0300 |
parents | 0f00192e64af |
children | 9a52fa9d4ecc |
line wrap: on
line diff
--- a/vote.inc.php Mon Oct 21 22:48:27 2013 +0300 +++ b/vote.inc.php Mon Oct 21 22:48:55 2013 +0300 @@ -2,41 +2,47 @@ $sessionType = "user"; $userKeyLen = stGetSetting("userKeyLength"); + +function stGetVoteButton() +{ + return + "<div class=\"votectrl\">". + stGetFormSubmitInput("vote", "Submit votes!", "return false"). + "</div>\n"; +} + // 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"; - - $status = -1; } else -if (stUserSessionAuth()) +if (!stUserSessionAuth(FALSE)) { - $status = stGetSessionItem("status"); - stStartSubmitStatus($status, "vote", "vsubmit.php", "Vote system"); -} else - $status = 0; - - -if ($status == 0) -{ + // Perform authentication if we are not in session already echo - "<h1>Voting system</h1>\n". - stGetFormStart("vote", "usrlogin.php"). - " ".stGetFormHiddenInput("mode", "key")."\n". - " ".stGetFormHiddenInput("goto", "vote")."\n". - " <div class=\"votectrl\">\n". - " Enter your vote key:\n". - " ".stGetFormTextInput($userKeyLen > 30 ? $userKeyLen : 30, $userKeyLen, 30, "key", "", "", stGetSessionItem("key"), "autocomplete=\"off\"")."\n". - " ".stGetFormSubmitInput("login", "Login")."\n". - " </div>\n". - "</form>\n"; + "<h1>Voting system</h1>\n". + (stGetSessionItem("mode") == "error" ? "<p>ERROR occured, try again</p>." : ""). + stGetFormStart("vote", "usrlogin.php"). + " ".stGetFormHiddenInput("mode", "vote")."\n". + " ".stGetFormHiddenInput("goto", "vote")."\n". + " <div class=\"votectrl\">\n". + " Enter your vote key:\n". + " ".stGetFormTextInput($userKeyLen > 30 ? $userKeyLen : 30, $userKeyLen, "key", "", "", "", "autocomplete=\"off\"")."\n". + " ".stGetFormSubmitInput("login", "Login")."\n". + " </div>\n". + "</form>\n"; } else -if ($status == 1) +if (($mode = stGetSessionItem("mode")) == "vote") { +?> +<script type="text/javascript"> +// <? include "ajax.js"; ?> +</script> +<? stGetCompoList(TRUE, TRUE); // Try fetching previously stored votes @@ -55,11 +61,11 @@ // Output voting system HTML echo "<h1>Voting system</h1>\n". - stGetFormStart("vote", "vsubmit.php"). + stGetFormStart("vote", "usrvote.php"). " ".stGetFormHiddenInput("mode", "vote")."\n". " ".stGetFormHiddenInput("goto", "vote")."\n". " ".stGetFormHiddenInput("key", stGetSessionItem("key"))."\n". - " <div class=\"votectrl\">".stGetFormSubmitInput("vote", "Submit votes!")."</div>\n"; + stGetVoteButton(); foreach ($compos as $id => $compo) if (count($compo["entries"]) > 0) @@ -109,15 +115,15 @@ } echo - " <div class=\"votectrl\">".stGetFormSubmitInput("vote", "Submit votes!")."</div>\n". + stGetVoteButton(). "</form>\n"; } else -if ($status == 2) +if ($mode == "done") { // Voting finished echo "<h1>Yay, you have voted!</h1>\n". "<p>Now go FAP some more! And make a demo about it.</p>"; stSessionEnd(SESS_USER); } -?> \ No newline at end of file +?> \ No newline at end of file