require("$_SERVER[DOCUMENT_ROOT]/lib/header.inc.php"); $currHeader->setPageTitle("Random Timers"); $currBanner->addContent("Random Timers"); $currNavbar->setCustomLinksTitle("Random Timers"); $currNavbar->addCustomLink("/timers.php?action=add", "Add a timer"); $currNavbar->addCustomLink("/timers.php?action=viewUsers", "Top Ranked Submitters"); $currNavbar->addCustomLink("/timers.php?action=showAll", "Show Every Timer"); // if the person wants to be added, lets give them a form. if ($_REQUEST["action"] == "add") { ?>
This will let you add a timer. It'll start showing up on the site randomly, and life will be good. If you aren't logged in, then Anonymous Coward will own the timer. (you can tell if you're logged in at the top right corner, if user has your name beside it, then you're good).
} // to actually do an add command elseif ($_REQUEST["action"] == "doAdd") { if (auth(1, false)) { // make sure people don't stick html in here $quoteText = htmlspecialchars($_POST["text"]); $query = "INSERT INTO randomTimers(owner, timerDate, timerDirection, timerIncrement, timerText, timerEndDate, dateAdded) VALUES($_SESSION[userid], '$_POST[timerdate]', '$_POST[direction]', '$_POST[increment]', '$quoteText', '$_POST[timerenddate]', CURDATE())"; $result = mysql_query($query); if ($result) { print("Timer added successfully!
"); // zero the counter so the quote will show up randomly $query = "UPDATE randomTimers SET counter = 0"; mysql_query($query); } if (!$result) print("We could not add that timer. Perhaps it is already in use, or you did not fill out all fields. Here is the exact error: " . mysql_error() . "
"); } else { print("Sorry, you do not have permission to do that. As usual, you can blame this on a few idiots (or actually, just one from Alberta) ruining it for everybody else.
"); } } // if we're viewing the submitters list elseif ($_REQUEST["action"] == "viewUsers") { $query = "SELECT users.username, users.id, COUNT(randomTimers.owner) AS timercount FROM randomTimers, users WHERE users.id = randomTimers.owner GROUP BY users.id ORDER BY timercount DESC, username ASC"; $title = "Who has the most timers?"; $result = mysql_query($query); print("| User | Timers |
|---|---|
| Owner | Timer | Timer Date |
|---|---|---|
| $row[username] | $timerText | $timerDate |
Random Timers are those boxes that appear on the site which tell you either how close something is, or how long ago it happened. They serve no real purpose whatsoever, except that they're neat.
} require("$_SERVER[DOCUMENT_ROOT]/lib/footer.inc.php"); ?>