Mercurial > hg > fapweb
changeset 514:8693052c66a9
Move normal pages under a sub-directory.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 08 Dec 2013 14:34:27 +0200 |
parents | afdb381c71cb |
children | 2fc7bd9e209f |
files | about.inc.php attendees.inc.php compos.inc.php index.php news.inc.php pages/about.inc.php pages/attendees.inc.php pages/compos.inc.php pages/news.inc.php pages/register.inc.php pages/results.inc.php pages/schedule.inc.php pages/vote.inc.php register.inc.php results.inc.php schedule.inc.php vote.inc.php |
diffstat | 17 files changed, 579 insertions(+), 578 deletions(-) [+] |
line wrap: on
line diff
--- a/about.inc.php Sun Dec 08 14:23:11 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -<? -// -// FAPWeb Simple Demoparty System -// About page -// (C) Copyright 2012-2013 Tecnic Software productions (TNSP) -// -echo stGetSetting("aboutDescription"); - -if (stGetSetting("showNewsOnAbout") && - ($res = stExecSQL("SELECT * FROM news ORDER BY utime DESC LIMIT 2")) !== FALSE) -{ - foreach ($res as $item) - stPrintNewsItem($item); - - echo "<a class=\"moreNews\" href=\"news\">More news ...</a>\n"; -} -?>
--- a/attendees.inc.php Sun Dec 08 14:23:11 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -<? -// -// FAPWeb Simple Demoparty System -// Attendee list page -// (C) Copyright 2012-2013 Tecnic Software productions (TNSP) -// -if (stCheckRegistrationAvailable()) -{ -?> -<div class="reglink"> -To register, use <a href="register">this form</a>. -</div> -<? -} - -echo "<p>Total of <b>".$numAttendees. - "</b> people registered to attend"; - -if ($maxAttendeesHard > 0) - echo " (<b>".$maxAttendeesHard."</b> max)"; - -echo ".</p>\n"; - -?> -<table class="attendees"> - <tr> - <th class="name">Name</th> - <th class="groups">Group(s)</th> - <th class="regtime">Registered</th> - <th class="oneliner">Oneliner</th> - </tr> -<? -if (($res = stExecSQL("SELECT * FROM attendees ORDER BY regtime DESC")) !== FALSE) -{ - $index = $numAttendees; - $row = 0; - foreach ($res as $item) - { - // Check hard limit first - if ($maxAttendeesHard > 0) - $over = $index > $maxAttendeesHard; - else - // Then check soft limit - if ($maxAttendeesSoft > 0) - $over = $index > $maxAttendeesSoft; - - stPrintAttendee($item, $row++, TRUE, FALSE, FALSE, $over ? " overbooked" : ""); - $index--; - } -} -?> -</table>
--- a/compos.inc.php Sun Dec 08 14:23:11 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -<? -// -// FAPWeb Simple Demoparty System -// Competitions page -// (C) Copyright 2012-2013 Tecnic Software productions (TNSP) -// -echo stGetSetting("compoDescription"); - -$sql = "SELECT id,name FROM compos WHERE visible<>0 ORDER BY id ASC"; - -if (($res = stExecSQL($sql)) !== FALSE) -{ - $list = array(); - foreach ($res as $item) - { - $list[] = "<a href=\"#compo".$item["id"]."\">".chentities($item["name"])."</a>"; - } - echo "<p class=\"compolist\">".join($list, " | ")."</p>"; -} - - -$sql = "SELECT * FROM compos WHERE visible<>0 ORDER BY id ASC"; - -if (($res = stExecSQL($sql)) !== FALSE) -{ - foreach ($res as $item) - { - echo - "<div id=\"compo".$item["id"]."\">\n". - "<h2>".chentities($item["name"])."</h2>\n". - stConvertCommonDesc($item["description"], FALSE). - "</div>\n"; - } -} -?>
--- a/index.php Sun Dec 08 14:23:11 2013 +0200 +++ b/index.php Sun Dec 08 14:34:27 2013 +0200 @@ -80,13 +80,14 @@ echo stGetSetting("siteExtraHTML"); // Get the name of the page +$pagePath = "pages/"; +$pageExt = ".inc.php"; $pageName = isset($_GET["page"]) ? $_GET["page"] : stGetSetting("defaultPage"); $pageBasename = basename($pageName); -$pageFilename = $pageBasename.".inc.php"; // Default to set default page if selected page does not exist -if (!file_exists($pageBasename.".inc.php")) - $pageBasename = stGetSetting("defaultPage"); +if (!file_exists($pagePath.$pageBasename.$pageExt)) + $pageBasename = $pagePath.stGetSetting("defaultPage"); echo "<div id=\"infobox\">".strtoupper($pageBasename)."</div>\n"; @@ -94,8 +95,8 @@ <div id="mainContent"> <div> <? -if (file_exists($pageBasename.".inc.php")) - include($pageBasename.".inc.php"); +if (file_exists($pagePath.$pageBasename.$pageExt)) + include($pagePath.$pageBasename.$pageExt); ?> </div> </div>
--- a/news.inc.php Sun Dec 08 14:23:11 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -<? -// -// FAPWeb Simple Demoparty System -// News page -// (C) Copyright 2012-2013 Tecnic Software productions (TNSP) -// -echo stGetSetting("newsHeader"); - -if (($res = stExecSQL("SELECT * FROM news ORDER BY utime DESC")) !== FALSE) -{ - foreach ($res as $item) - stPrintNewsItem($item); -} -?>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pages/about.inc.php Sun Dec 08 14:34:27 2013 +0200 @@ -0,0 +1,17 @@ +<? +// +// FAPWeb Simple Demoparty System +// About page +// (C) Copyright 2012-2013 Tecnic Software productions (TNSP) +// +echo stGetSetting("aboutDescription"); + +if (stGetSetting("showNewsOnAbout") && + ($res = stExecSQL("SELECT * FROM news ORDER BY utime DESC LIMIT 2")) !== FALSE) +{ + foreach ($res as $item) + stPrintNewsItem($item); + + echo "<a class=\"moreNews\" href=\"news\">More news ...</a>\n"; +} +?>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pages/attendees.inc.php Sun Dec 08 14:34:27 2013 +0200 @@ -0,0 +1,52 @@ +<? +// +// FAPWeb Simple Demoparty System +// Attendee list page +// (C) Copyright 2012-2013 Tecnic Software productions (TNSP) +// +if (stCheckRegistrationAvailable()) +{ +?> +<div class="reglink"> +To register, use <a href="register">this form</a>. +</div> +<? +} + +echo "<p>Total of <b>".$numAttendees. + "</b> people registered to attend"; + +if ($maxAttendeesHard > 0) + echo " (<b>".$maxAttendeesHard."</b> max)"; + +echo ".</p>\n"; + +?> +<table class="attendees"> + <tr> + <th class="name">Name</th> + <th class="groups">Group(s)</th> + <th class="regtime">Registered</th> + <th class="oneliner">Oneliner</th> + </tr> +<? +if (($res = stExecSQL("SELECT * FROM attendees ORDER BY regtime DESC")) !== FALSE) +{ + $index = $numAttendees; + $row = 0; + foreach ($res as $item) + { + // Check hard limit first + if ($maxAttendeesHard > 0) + $over = $index > $maxAttendeesHard; + else + // Then check soft limit + if ($maxAttendeesSoft > 0) + $over = $index > $maxAttendeesSoft; + + stPrintAttendee($item, $row++, TRUE, FALSE, FALSE, $over ? " overbooked" : ""); + $index--; + } +} +?> +</table>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pages/compos.inc.php Sun Dec 08 14:34:27 2013 +0200 @@ -0,0 +1,35 @@ +<? +// +// FAPWeb Simple Demoparty System +// Competitions page +// (C) Copyright 2012-2013 Tecnic Software productions (TNSP) +// +echo stGetSetting("compoDescription"); + +$sql = "SELECT id,name FROM compos WHERE visible<>0 ORDER BY id ASC"; + +if (($res = stExecSQL($sql)) !== FALSE) +{ + $list = array(); + foreach ($res as $item) + { + $list[] = "<a href=\"#compo".$item["id"]."\">".chentities($item["name"])."</a>"; + } + echo "<p class=\"compolist\">".join($list, " | ")."</p>"; +} + + +$sql = "SELECT * FROM compos WHERE visible<>0 ORDER BY id ASC"; + +if (($res = stExecSQL($sql)) !== FALSE) +{ + foreach ($res as $item) + { + echo + "<div id=\"compo".$item["id"]."\">\n". + "<h2>".chentities($item["name"])."</h2>\n". + stConvertCommonDesc($item["description"], FALSE). + "</div>\n"; + } +} +?>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pages/news.inc.php Sun Dec 08 14:34:27 2013 +0200 @@ -0,0 +1,14 @@ +<? +// +// FAPWeb Simple Demoparty System +// News page +// (C) Copyright 2012-2013 Tecnic Software productions (TNSP) +// +echo stGetSetting("newsHeader"); + +if (($res = stExecSQL("SELECT * FROM news ORDER BY utime DESC")) !== FALSE) +{ + foreach ($res as $item) + stPrintNewsItem($item); +} +?>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pages/register.inc.php Sun Dec 08 14:34:27 2013 +0200 @@ -0,0 +1,224 @@ +<? +// +// FAPWeb Simple Demoparty System +// Attendee registration page +// (C) Copyright 2012-2013 Tecnic Software productions (TNSP) +// +$mode = stGetRequestItem("mode", "start"); + +// Settings for robot check hash generator +$botCheckIDs = "aBcdefghIjklmnopqrsTuvxyz0123456"; +$botCheckOPs = "bit"; +$botCheckROPs = "+-*"; + +$formFields = array( + "name" => "Name", + "groups" => "Group(s)", + "email" => "E-mail", + "oneliner" => "Oneliner", + "hash" => FALSE, + "botcheck" => FALSE, +); + + +function stPrintFormData($button, $mode = "start", $exclude = array()) +{ + global $formFields; + + echo + stGetFormStart("register"). + " ".stGetFormSubmitInput("continue", $button)."\n"; + + stPrintFormHiddenInput("mode", $mode); + + foreach ($formFields as $name => $title) + { + if (!in_array($name, $exclude)) + stPrintFormHiddenInput($name, stGetRequestItem($name)); + } + + echo "</form>\n"; +} + + +// Convert integer value to hash code +function intValueToHash($val) +{ + global $botCheckIDs; + $str = ""; + do + { + $str = $botCheckIDs[$val & 31].$str; + $val >>= 5; + } + while ($val > 0); + return $str; +} + + +// Convert integer hash to integer value +function intHashToValue($hash) +{ + global $botCheckIDs; + for ($val = 0, $i = 0; $i < strlen($hash); $i++) + { + $val *= 32; + $n = strpos($botCheckIDs, $hash[$i]); + if ($n !== FALSE) + $val += $n; + else + return -2; + } + return $val; +} + + +// Split hash into parts +function splitHash($hash) +{ + global $botCheckOPs; + return preg_split("/([".$botCheckOPs."])/", $hash, -1, PREG_SPLIT_DELIM_CAPTURE); +} + + +function hashToCheckStr($hash) +{ + global $botCheckOPs, $botCheckROPs; + $out = ""; + + foreach (splitHash($hash) as $val) + { + $i = strpos($botCheckOPs, $val); + if ($i !== FALSE) + $out .= " ".$botCheckROPs[$i]." "; + else + $out .= intHashToValue($val); + } + return $out; +} + + +function hashToAnswer($hash) +{ + eval("\$res = ".hashToCheckStr($hash).";"); + return $res; +} + +// Check if user registration is available +stCheckRegistrationAvailable(); + +// Check if registration is enabled +if (!stChkSetting("allowRegister")) +{ + echo stGetSetting("registerNotEnabled"); +} +else +if ($maxAttendeesHard > 0 && $numAttendees >= $maxAttendeesHard) +{ + echo stGetSetting("registerLimitExceeded"); +} +else +if ($mode == "start") +{ + // + // Show registration form + // + // Generate bot-check + $botCheckHash = + intValueToHash(rand(1,5)). + $botCheckOPs[rand(0,2)]. + intValueToHash(rand(1,5)). + $botCheckOPs[rand(0,2)]. + intValueToHash(5 * rand(1,5)); + + echo + "<h1>Registration</h1>\n". + stGetFormStart("register"). + " ".stGetFormHiddenInput("mode", "check")."\n". + " ".stGetFormHiddenInput("hash", $botCheckHash)."\n". + " <table class=\"register\">\n"; + stPrintFormTextInput("Handle:", "(elite)", 20, SET_LEN_USERNAME, "name"); + stPrintFormTextInput("Group(s):", "(elite crew^supahmen)", 30, SET_LEN_GROUPS, "groups"); + stPrintFormTextInput("E-mail:", "(to be informed of location etc)", 30, SET_LEN_EMAIL, "email"); + stPrintFormTextInput("Oneliner:", "(whatever)", 30, SET_LEN_ONELINER, "oneliner"); + stPrintFormTextInput(hashToCheckStr($botCheckHash)." = ", "(I.Q. / robot check". + //" [".hashToAnswer($botCheckHash)."]". + ")", 20, 20, "botcheck", "autocomplete=\"off\""); + echo + " <tr><td colspan=\"2\"></td><td>".stGetFormSubmitInput("register", "Continue")."</td></tr>\n". + " </table>\n". + "</form>\n"; + + echo stGetSetting("registerInfoText"); +} +else +if ($mode == "check" || $mode == "register") +{ + // + // Check the registrant's details + // + stChkRequestItem("hash", $hash, + array(CHK_GTEQ, VT_STR, 0, "Invalid data.")); + + stValidateRequestUserData(FALSE); + + $answer = stGetRequestItem("botcheck"); + if (hashToAnswer($hash) != intval($answer)) + stError("Incorrect answer to I.Q. / bot check."); + + if ($errorSet) + { + echo + "<p>Following errors occured:</p>\n". + "<ul>\n"; + + foreach ($errorMsgs as $msg) + echo " <li>".$msg."</li>\n"; + + echo "</ul>\n"; + stPrintFormData("Go back", "start", array("botcheck")); + } + else + if ($mode == "register") + { + $sql = stPrepareSQL( + "INSERT INTO attendees (regtime,name,groups,oneliner,email) VALUES (%d,%S,%S,%S,%S)", + time(), "name", "groups", "oneliner", "email"); + + if (stExecSQL($sql) !== FALSE) + { + echo stGetSetting("registerPostText"); + + if (strlen($email) < 4) + echo stGetSetting("registerPostNoEmail"); + } + else + { + echo + "<h1>An error occured.</h1>\n". + "<p>Oh noes! SQL error happenstance!</p>"; + } + } + else + { + echo + "<h1>Verify your information</h1>\n". + "<p>Is the following information correct?</p>\n". + "<table class=\"register\">\n"; + + foreach ($formFields as $name => $title) + { + if ($title !== FALSE) + { + echo + " <tr><td class=\"".$name."\">".chentities($title).":</td>". + "<td>".chentities(stGetRequestItem($name))."</td></tr>\n"; + } + } + echo "</table>\n"; + + stPrintFormData("Go back", "start", array("botcheck")); + stPrintFormData("Register", "register"); + } +} +?> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pages/results.inc.php Sun Dec 08 14:34:27 2013 +0200 @@ -0,0 +1,32 @@ +<? +// +// FAPWeb Simple Demoparty System +// Competition results page +// (C) Copyright 2012-2013 Tecnic Software productions (TNSP) +// +$showResults = stGetSetting("showResults"); +$showAuthors = stGetSetting("showResAuthors"); + + +echo "<h1>Results</h1>\n"; + +// Show everything for the admin session +if (stAdmSessionAuth()) +{ + if (!$showResults) + echo "<p class=\"notice\">Results hidden from normal users.</p>"; + if (!$showAuthors) + echo "<p class=\"notice\">Entry authors hidden from normal users.</p>"; + + $showResults = $showAuthors = TRUE; +} + + +if ($showResults) + echo stGetCompoResultsASCIIStr($showAuthors, TRUE); +else +{ + echo "<p>Sorry, no results available! Nothing to see here, move along.</p>"; +} + +?> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pages/schedule.inc.php Sun Dec 08 14:34:27 2013 +0200 @@ -0,0 +1,8 @@ +<? +// +// FAPWeb Simple Demoparty System +// Event schedule / description +// (C) Copyright 2012-2013 Tecnic Software productions (TNSP) +// +echo stGetSetting("eventDescription"); +?>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pages/vote.inc.php Sun Dec 08 14:34:27 2013 +0200 @@ -0,0 +1,191 @@ +<? +// +// FAPWeb Simple Demoparty System +// Competition voting page +// (C) Copyright 2012-2013 Tecnic Software productions (TNSP) +// +$sessionType = "user"; +require_once "majax.inc.php"; + + +function stGetVoteButton() +{ + return + " <div class=\"votectrl\">\n". + " ".stGetFormSubmitInput("vote", "Submit votes and log out", "")."\n". + " </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"; +} +else +if (!stUserSessionAuth(FALSE)) +{ + // Perform authentication if we are not in session already + $userKeyLen = stGetSetting("userKeyLength"); + + if (($error = stGetRequestItem("error", 0, TRUE)) != 0) + { + echo + "<h1>Voting system login failed</h1>\n". + "<p class=\"notice\">\n"; + + switch ($error) + { + case 1: + echo "The votekey does not exist. Please try again."; + break; + + case 2: + echo "There was an error in the system. Contact an administrator."; + break; + + case 3: + echo + "The votekey is not yet activated, try again later. If ". + "you are certain that it should be working now, go pester an organizer."; + break; + } + + echo + "</p>\n"; + } + else + { + echo + "<h1>Voting system</h1>\n"; + } + + echo + 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\" autofocus=\"autofocus\"")."\n". + " ".stGetFormSubmitInput("login", "Login")."\n". + " </div>\n". + "</form>\n"; +} +else +if (($mode = stGetSessionItem("mode")) == "vote") +{ + stCommonAJAX("usrajax.php", "usrlogout.php", TRUE); +?> +<script type="text/javascript"> + +function updateVote(eid, value) +{ + var msuccess = function(txt) + { + } + + var mfail = function(txt) + { + jsMessageBox("Something went wrong. :("); + } + + jsSendPOSTRequest("action=set&entry_id="+eid+"&vote="+value, msuccess, mfail); + return false; +} + +</script> +<? + // Try fetching previously stored votes + $sql = stPrepareSQL( + "SELECT entry_id,value FROM votes WHERE key_id=%d", + stGetSessionItem("key_id")); + + $votes = array(); + if (($res = stExecSQL($sql)) !== false) + { + foreach ($res as $vote) + $votes[$vote["entry_id"]] = $vote["value"]; + } + + // Output voting system HTML + echo + "<h1>Voting system</h1>\n". + stGetFormStart("vote", "usrajax.php"). + " ".stGetFormHiddenInput("mode", "done")."\n". + " ".stGetFormHiddenInput("action", "submit")."\n". + stGetVoteButton(); + + foreach (stExecSQL("SELECT * FROM compos WHERE visible<>0 AND voting<>0") as $compo) + { + $cid = $compo["id"]; + $nentries = stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$cid); + if ($nentries > 0) + { + echo + " <table class=\"vote\">\n". + " <tr><th colspan=\"".($compo["showAuthors"] ? "3" : "2")."\">".chentities($compo["name"])."</th></tr>\n". + " <tr>\n". + " <th class=\"vshown\">#</th>\n". + " <th class=\"vtitle\">Title</th>\n". + ($compo["showAuthors"] ? " <th class=\"vauthor\">Author</th>\n" : ""). + " "; + + for ($i = stGetSetting("voteMax"); $i >= stGetSetting("voteMin"); $i--) + { + echo "<th class=\"vvalue\">".$i."</th>"; + } + echo "\n". + " </tr>\n"; + + $row = 0; + foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$cid) as $entry) + { + $eid = $entry["id"]; + echo + " <tr class=\"".($row % 2 == 1 ? "rodd" : "reven")."\">\n". + " <td class=\"vshown\">".($entry["show_id"] > 0 ? $entry["show_id"] : "-")."</td>\n". + " <td class=\"vtitle\">".$entry["name"]."</td>\n". + ($compo["showAuthors"] ? " <td class=\"vauthor\">".$entry["author"]."</td>\n" : ""). + " "; + + $val = isset($votes[$eid]) ? $votes[$eid] : 0; + + for ($i = stGetSetting("voteMax"); $i >= stGetSetting("voteMin"); $i--) + { + $nid = "ve".$eid."_".$i; + echo + "<td class=\"vvalue\">". + "<input type=\"radio\" id=\"".$nid. + "\" name=\"ventry".$eid."\" value=\"".$i."\" ". + "onClick=\"updateVote(".$eid.",".$i.")\" ". + ($val == $i ? "checked=\"checked\" ": "")."/>". + "<label for=\"".$nid."\"></label>". + "</td>"; + } + + echo + "\n". + " </tr>\n"; + + $row++; + } + echo + " </table>\n"; + } + } + + echo + stGetVoteButton(). + "</form>\n"; +} +else +if ($mode == "done") +{ + // Voting finished + echo stGetSetting("voteFinishedText"); + echo "<p>Or perhaps <a href=\"vote\">vote again!</a></p>\n"; + stSessionEnd(SESS_USER); +} +?> \ No newline at end of file
--- a/register.inc.php Sun Dec 08 14:23:11 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,224 +0,0 @@ -<? -// -// FAPWeb Simple Demoparty System -// Attendee registration page -// (C) Copyright 2012-2013 Tecnic Software productions (TNSP) -// -$mode = stGetRequestItem("mode", "start"); - -// Settings for robot check hash generator -$botCheckIDs = "aBcdefghIjklmnopqrsTuvxyz0123456"; -$botCheckOPs = "bit"; -$botCheckROPs = "+-*"; - -$formFields = array( - "name" => "Name", - "groups" => "Group(s)", - "email" => "E-mail", - "oneliner" => "Oneliner", - "hash" => FALSE, - "botcheck" => FALSE, -); - - -function stPrintFormData($button, $mode = "start", $exclude = array()) -{ - global $formFields; - - echo - stGetFormStart("register"). - " ".stGetFormSubmitInput("continue", $button)."\n"; - - stPrintFormHiddenInput("mode", $mode); - - foreach ($formFields as $name => $title) - { - if (!in_array($name, $exclude)) - stPrintFormHiddenInput($name, stGetRequestItem($name)); - } - - echo "</form>\n"; -} - - -// Convert integer value to hash code -function intValueToHash($val) -{ - global $botCheckIDs; - $str = ""; - do - { - $str = $botCheckIDs[$val & 31].$str; - $val >>= 5; - } - while ($val > 0); - return $str; -} - - -// Convert integer hash to integer value -function intHashToValue($hash) -{ - global $botCheckIDs; - for ($val = 0, $i = 0; $i < strlen($hash); $i++) - { - $val *= 32; - $n = strpos($botCheckIDs, $hash[$i]); - if ($n !== FALSE) - $val += $n; - else - return -2; - } - return $val; -} - - -// Split hash into parts -function splitHash($hash) -{ - global $botCheckOPs; - return preg_split("/([".$botCheckOPs."])/", $hash, -1, PREG_SPLIT_DELIM_CAPTURE); -} - - -function hashToCheckStr($hash) -{ - global $botCheckOPs, $botCheckROPs; - $out = ""; - - foreach (splitHash($hash) as $val) - { - $i = strpos($botCheckOPs, $val); - if ($i !== FALSE) - $out .= " ".$botCheckROPs[$i]." "; - else - $out .= intHashToValue($val); - } - return $out; -} - - -function hashToAnswer($hash) -{ - eval("\$res = ".hashToCheckStr($hash).";"); - return $res; -} - -// Check if user registration is available -stCheckRegistrationAvailable(); - -// Check if registration is enabled -if (!stChkSetting("allowRegister")) -{ - echo stGetSetting("registerNotEnabled"); -} -else -if ($maxAttendeesHard > 0 && $numAttendees >= $maxAttendeesHard) -{ - echo stGetSetting("registerLimitExceeded"); -} -else -if ($mode == "start") -{ - // - // Show registration form - // - // Generate bot-check - $botCheckHash = - intValueToHash(rand(1,5)). - $botCheckOPs[rand(0,2)]. - intValueToHash(rand(1,5)). - $botCheckOPs[rand(0,2)]. - intValueToHash(5 * rand(1,5)); - - echo - "<h1>Registration</h1>\n". - stGetFormStart("register"). - " ".stGetFormHiddenInput("mode", "check")."\n". - " ".stGetFormHiddenInput("hash", $botCheckHash)."\n". - " <table class=\"register\">\n"; - stPrintFormTextInput("Handle:", "(elite)", 20, SET_LEN_USERNAME, "name"); - stPrintFormTextInput("Group(s):", "(elite crew^supahmen)", 30, SET_LEN_GROUPS, "groups"); - stPrintFormTextInput("E-mail:", "(to be informed of location etc)", 30, SET_LEN_EMAIL, "email"); - stPrintFormTextInput("Oneliner:", "(whatever)", 30, SET_LEN_ONELINER, "oneliner"); - stPrintFormTextInput(hashToCheckStr($botCheckHash)." = ", "(I.Q. / robot check". - //" [".hashToAnswer($botCheckHash)."]". - ")", 20, 20, "botcheck", "autocomplete=\"off\""); - echo - " <tr><td colspan=\"2\"></td><td>".stGetFormSubmitInput("register", "Continue")."</td></tr>\n". - " </table>\n". - "</form>\n"; - - echo stGetSetting("registerInfoText"); -} -else -if ($mode == "check" || $mode == "register") -{ - // - // Check the registrant's details - // - stChkRequestItem("hash", $hash, - array(CHK_GTEQ, VT_STR, 0, "Invalid data.")); - - stValidateRequestUserData(FALSE); - - $answer = stGetRequestItem("botcheck"); - if (hashToAnswer($hash) != intval($answer)) - stError("Incorrect answer to I.Q. / bot check."); - - if ($errorSet) - { - echo - "<p>Following errors occured:</p>\n". - "<ul>\n"; - - foreach ($errorMsgs as $msg) - echo " <li>".$msg."</li>\n"; - - echo "</ul>\n"; - stPrintFormData("Go back", "start", array("botcheck")); - } - else - if ($mode == "register") - { - $sql = stPrepareSQL( - "INSERT INTO attendees (regtime,name,groups,oneliner,email) VALUES (%d,%S,%S,%S,%S)", - time(), "name", "groups", "oneliner", "email"); - - if (stExecSQL($sql) !== FALSE) - { - echo stGetSetting("registerPostText"); - - if (strlen($email) < 4) - echo stGetSetting("registerPostNoEmail"); - } - else - { - echo - "<h1>An error occured.</h1>\n". - "<p>Oh noes! SQL error happenstance!</p>"; - } - } - else - { - echo - "<h1>Verify your information</h1>\n". - "<p>Is the following information correct?</p>\n". - "<table class=\"register\">\n"; - - foreach ($formFields as $name => $title) - { - if ($title !== FALSE) - { - echo - " <tr><td class=\"".$name."\">".chentities($title).":</td>". - "<td>".chentities(stGetRequestItem($name))."</td></tr>\n"; - } - } - echo "</table>\n"; - - stPrintFormData("Go back", "start", array("botcheck")); - stPrintFormData("Register", "register"); - } -} -?> \ No newline at end of file
--- a/results.inc.php Sun Dec 08 14:23:11 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -<? -// -// FAPWeb Simple Demoparty System -// Competition results page -// (C) Copyright 2012-2013 Tecnic Software productions (TNSP) -// -$showResults = stGetSetting("showResults"); -$showAuthors = stGetSetting("showResAuthors"); - - -echo "<h1>Results</h1>\n"; - -// Show everything for the admin session -if (stAdmSessionAuth()) -{ - if (!$showResults) - echo "<p class=\"notice\">Results hidden from normal users.</p>"; - if (!$showAuthors) - echo "<p class=\"notice\">Entry authors hidden from normal users.</p>"; - - $showResults = $showAuthors = TRUE; -} - - -if ($showResults) - echo stGetCompoResultsASCIIStr($showAuthors, TRUE); -else -{ - echo "<p>Sorry, no results available! Nothing to see here, move along.</p>"; -} - -?> \ No newline at end of file
--- a/schedule.inc.php Sun Dec 08 14:23:11 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -<? -// -// FAPWeb Simple Demoparty System -// Event schedule / description -// (C) Copyright 2012-2013 Tecnic Software productions (TNSP) -// -echo stGetSetting("eventDescription"); -?>
--- a/vote.inc.php Sun Dec 08 14:23:11 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,191 +0,0 @@ -<? -// -// FAPWeb Simple Demoparty System -// Competition voting page -// (C) Copyright 2012-2013 Tecnic Software productions (TNSP) -// -$sessionType = "user"; -require_once "majax.inc.php"; - - -function stGetVoteButton() -{ - return - " <div class=\"votectrl\">\n". - " ".stGetFormSubmitInput("vote", "Submit votes and log out", "")."\n". - " </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"; -} -else -if (!stUserSessionAuth(FALSE)) -{ - // Perform authentication if we are not in session already - $userKeyLen = stGetSetting("userKeyLength"); - - if (($error = stGetRequestItem("error", 0, TRUE)) != 0) - { - echo - "<h1>Voting system login failed</h1>\n". - "<p class=\"notice\">\n"; - - switch ($error) - { - case 1: - echo "The votekey does not exist. Please try again."; - break; - - case 2: - echo "There was an error in the system. Contact an administrator."; - break; - - case 3: - echo - "The votekey is not yet activated, try again later. If ". - "you are certain that it should be working now, go pester an organizer."; - break; - } - - echo - "</p>\n"; - } - else - { - echo - "<h1>Voting system</h1>\n"; - } - - echo - 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\" autofocus=\"autofocus\"")."\n". - " ".stGetFormSubmitInput("login", "Login")."\n". - " </div>\n". - "</form>\n"; -} -else -if (($mode = stGetSessionItem("mode")) == "vote") -{ - stCommonAJAX("usrajax.php", "usrlogout.php", TRUE); -?> -<script type="text/javascript"> - -function updateVote(eid, value) -{ - var msuccess = function(txt) - { - } - - var mfail = function(txt) - { - jsMessageBox("Something went wrong. :("); - } - - jsSendPOSTRequest("action=set&entry_id="+eid+"&vote="+value, msuccess, mfail); - return false; -} - -</script> -<? - // Try fetching previously stored votes - $sql = stPrepareSQL( - "SELECT entry_id,value FROM votes WHERE key_id=%d", - stGetSessionItem("key_id")); - - $votes = array(); - if (($res = stExecSQL($sql)) !== false) - { - foreach ($res as $vote) - $votes[$vote["entry_id"]] = $vote["value"]; - } - - // Output voting system HTML - echo - "<h1>Voting system</h1>\n". - stGetFormStart("vote", "usrajax.php"). - " ".stGetFormHiddenInput("mode", "done")."\n". - " ".stGetFormHiddenInput("action", "submit")."\n". - stGetVoteButton(); - - foreach (stExecSQL("SELECT * FROM compos WHERE visible<>0 AND voting<>0") as $compo) - { - $cid = $compo["id"]; - $nentries = stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$cid); - if ($nentries > 0) - { - echo - " <table class=\"vote\">\n". - " <tr><th colspan=\"".($compo["showAuthors"] ? "3" : "2")."\">".chentities($compo["name"])."</th></tr>\n". - " <tr>\n". - " <th class=\"vshown\">#</th>\n". - " <th class=\"vtitle\">Title</th>\n". - ($compo["showAuthors"] ? " <th class=\"vauthor\">Author</th>\n" : ""). - " "; - - for ($i = stGetSetting("voteMax"); $i >= stGetSetting("voteMin"); $i--) - { - echo "<th class=\"vvalue\">".$i."</th>"; - } - echo "\n". - " </tr>\n"; - - $row = 0; - foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$cid) as $entry) - { - $eid = $entry["id"]; - echo - " <tr class=\"".($row % 2 == 1 ? "rodd" : "reven")."\">\n". - " <td class=\"vshown\">".($entry["show_id"] > 0 ? $entry["show_id"] : "-")."</td>\n". - " <td class=\"vtitle\">".$entry["name"]."</td>\n". - ($compo["showAuthors"] ? " <td class=\"vauthor\">".$entry["author"]."</td>\n" : ""). - " "; - - $val = isset($votes[$eid]) ? $votes[$eid] : 0; - - for ($i = stGetSetting("voteMax"); $i >= stGetSetting("voteMin"); $i--) - { - $nid = "ve".$eid."_".$i; - echo - "<td class=\"vvalue\">". - "<input type=\"radio\" id=\"".$nid. - "\" name=\"ventry".$eid."\" value=\"".$i."\" ". - "onClick=\"updateVote(".$eid.",".$i.")\" ". - ($val == $i ? "checked=\"checked\" ": "")."/>". - "<label for=\"".$nid."\"></label>". - "</td>"; - } - - echo - "\n". - " </tr>\n"; - - $row++; - } - echo - " </table>\n"; - } - } - - echo - stGetVoteButton(). - "</form>\n"; -} -else -if ($mode == "done") -{ - // Voting finished - echo stGetSetting("voteFinishedText"); - echo "<p>Or perhaps <a href=\"vote\">vote again!</a></p>\n"; - stSessionEnd(SESS_USER); -} -?> \ No newline at end of file