# HG changeset patch # User Matti Hamalainen # Date 1382384935 -10800 # Node ID ff511f5351df373959c82d5cbf1ccd849f825268 # Parent 9a3f0ba4d72b331afd88e9f9f130a23796e09cfa Work on voting. diff -r 9a3f0ba4d72b -r ff511f5351df loginerror.inc.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/loginerror.inc.php Mon Oct 21 22:48:55 2013 +0300 @@ -0,0 +1,4 @@ +

Voting system login failed

+

+The vote key was not valid. Try again. +

diff -r 9a3f0ba4d72b -r ff511f5351df usrlogin.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/usrlogin.php Mon Oct 21 22:48:55 2013 +0300 @@ -0,0 +1,38 @@ + \ No newline at end of file diff -r 9a3f0ba4d72b -r ff511f5351df vote.inc.php --- 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 + "
". + stGetFormSubmitInput("vote", "Submit votes!", "return false"). + "
\n"; +} + // Check if voting is enabled if (!stChkSetting("allowVoting")) { echo "

Sorry, voting disabled!

\n". "

Voting functionality not available at this time.

\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 - "

Voting system

\n". - stGetFormStart("vote", "usrlogin.php"). - " ".stGetFormHiddenInput("mode", "key")."\n". - " ".stGetFormHiddenInput("goto", "vote")."\n". - "
\n". - " Enter your vote key:\n". - " ".stGetFormTextInput($userKeyLen > 30 ? $userKeyLen : 30, $userKeyLen, 30, "key", "", "", stGetSessionItem("key"), "autocomplete=\"off\"")."\n". - " ".stGetFormSubmitInput("login", "Login")."\n". - "
\n". - "\n"; + "

Voting system

\n". + (stGetSessionItem("mode") == "error" ? "

ERROR occured, try again

." : ""). + stGetFormStart("vote", "usrlogin.php"). + " ".stGetFormHiddenInput("mode", "vote")."\n". + " ".stGetFormHiddenInput("goto", "vote")."\n". + "
\n". + " Enter your vote key:\n". + " ".stGetFormTextInput($userKeyLen > 30 ? $userKeyLen : 30, $userKeyLen, "key", "", "", "", "autocomplete=\"off\"")."\n". + " ".stGetFormSubmitInput("login", "Login")."\n". + "
\n". + "\n"; } else -if ($status == 1) +if (($mode = stGetSessionItem("mode")) == "vote") { +?> + +Voting system\n". - stGetFormStart("vote", "vsubmit.php"). + stGetFormStart("vote", "usrvote.php"). " ".stGetFormHiddenInput("mode", "vote")."\n". " ".stGetFormHiddenInput("goto", "vote")."\n". " ".stGetFormHiddenInput("key", stGetSessionItem("key"))."\n". - "
".stGetFormSubmitInput("vote", "Submit votes!")."
\n"; + stGetVoteButton(); foreach ($compos as $id => $compo) if (count($compo["entries"]) > 0) @@ -109,15 +115,15 @@ } echo - "
".stGetFormSubmitInput("vote", "Submit votes!")."
\n". + stGetVoteButton(). "\n"; } else -if ($status == 2) +if ($mode == "done") { // Voting finished echo "

Yay, you have voted!

\n". "

Now go FAP some more! And make a demo about it.

"; stSessionEnd(SESS_USER); } -?> \ No newline at end of file +?> \ No newline at end of file