/** * @see Page::readData() */ public function readData() { parent::readData(); $this->polls = new Polls($this->pollID, $this->canVotePoll); $this->poll = $this->polls->getPoll($this->pollID); if ($this->poll->isPublic) { // get sorted options foreach ($this->poll->getSortedPollOptions() as $pollOption) { $this->votes[$pollOption->pollOptionID] = array('pollOption' => $pollOption, 'users' => array(), 'guests' => 0); } // get poll votes $sql = "SELECT \t\tpoll_option_vote.*,\n\t\t\t\t\t\toption_value.*, user_table.*\n\t\t\t\tFROM \t\twcf" . WCF_N . "_poll_option_vote poll_option_vote\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user user_table\n\t\t\t\tON\t\t(user_table.userID = poll_option_vote.userID)\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_option_value option_value\n\t\t\t\tON\t\t(option_value.userID = user_table.userID)\n\t\t\t\tWHERE \t\tpoll_option_vote.pollID = " . $this->pollID . "\n\t\t\t\tORDER BY \tuser_table.username"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if (isset($this->votes[$row['pollOptionID']])) { if ($row['userID']) { $this->votes[$row['pollOptionID']]['users'][] = new UserProfile(null, $row); } else { $this->votes[$row['pollOptionID']]['guests']++; } } } } }
<?php echo '<h3>Existing Polls</h3>'; if (!$start) { $start = 0; } $polls = Polls::getAll(false); $end = count($polls); if (count($polls)) { // { $navlinks = ''; if ($start) { $navlinks .= '|<a href="' . $_url . '&action=showPolls&start=' . ($start > 99 ? $start - 100 : 0) . '">Prev</a>| '; } if ($start + 100 <= $end) { $navlinks .= '|<a href="' . $_url . '&action=showPolls&start=' . ($start + 100) . '">Next</a>| '; } // } echo '<table><tr><th>Name</th><th>Enabled</th><th>' . $navlinks . '</th></tr>'; $polls = array_slice($polls, $start, 100); foreach ($polls as $r) { echo '<tr><td>' . htmlspecialchars($r->name) . '</td><td>' . ($r->enabled ? 'Yes' : 'No') . '</td><td><a href="' . $_url . '&action=editPoll&id=' . $r->id . '&start=' . $start . '">edit</a>, <a href="' . $_url . '&action=deletePoll&id=' . $r->id . '&start=' . $start . '" onclick="return confirm(\'are you sur' . 'e you want to delete this poll?\')">[x]</a></td></tr>'; } echo '<tr><td> </td><td> </td><td>' . $navlinks . '</td></tr></table>'; } else { echo '<em>none yet</em>'; }
$polls = new Polls($db, $user); httpResponse($polls->vote($params[2], (int) $postdata["choise"])); break; case validateRoute('POST', 'polls'): $forum = new Forum($db, $user); $polls = new Polls($db, $user, $forum); $polls->create($postdata); httpResponse(); break; case validateRoute('PATCH', 'polls/\\d+'): $polls = new Polls($db, $user); $polls->update($params[1], $postdata); httpResponse(); break; case validateRoute('DELETE', 'polls/\\d+'): $polls = new Polls($db, $user); $polls->delete($params[1], $postdata); httpResponse(); break; case validateRoute('GET', 'torrents'): $torrent = new Torrent($db, $user); list($torrents, $total) = $torrent->search($_GET["categories"], $_GET['section'], $_GET["index"], $_GET["limit"], $_GET["sort"], $_GET["order"], $_GET["searchText"], $_GET["hideOld"], $_GET["p2p"], $_GET["extendedSearch"], $_GET["watchview"]); if ($_GET["page"]) { $user->updateLastTorrentViewAccess($_GET["page"]); } httpResponse($torrents, $total); break; case validateRoute('GET', 'torrents/\\d+'): $torrent = new Torrent($db); $myTorrent = $torrent->get($params[1]); httpResponse($myTorrent);
<section id="results"> <?php require 'libraries/Polls.php'; $address = $_GET['address']; $polls = new Polls(); $result = $polls->locate($address); if ($result['status'] != 'success') { $errors = array('noStreetSegmentFound' => 'The API currently has no information about what electoral precinct and/or district this address belongs to. It may be that we are still sourcing/processing new data, or that there are no voters who have registered to vote at this address.', 'addressUnparseable' => 'The requested address is not formatted correctly or cannot be geocoded (i.e. the Google Maps API does not know anything about this address).', 'noAddressParameter' => 'No address was provided.', 'multipleStreetSegmentsFound' => 'The API cannot find information for the specified address, but it has information about nearby addresses. The user should contact their election official for more information.', 'electionOver' => 'The requested election is over. API results for the election are no longer available. Make an electionQuery to find an id for an upcoming election.', 'electionUnknown' => 'The requested election id is invalid. Make an electionQuery to find a valid id.', 'internalLookupFailure' => 'An unspecified error occurred processing the request.'); ?> <div class="error"> <?php echo $errors[$result['status']]; ?> <br> <br><!-- Wooooo Break Tags --> <a href="/">Click here to try again</a> </div> <?php } else { ?> <h1>U.S. 2012 General Election on November 6</h1> <?php if (isset($result['pollingLocations'])) { foreach ($result['pollingLocations'] as $pollLocation) { ?> <div class="polling-location">
<?php require_once "smarty-3.1.27/libs/Smarty.class.php"; require_once "classes/group.poll.php"; require_once "classes/group.user.php"; require_once "classes/class.dbconnect.php"; $smarty = new Smarty(); $smarty->setTemplateDir("views"); $smarty->setCompileDir("tmp"); $polls = new Polls(); $users = new Users(); $connect = new dbConnect(); date_default_timezone_set('Africa/Lagos'); $smarty->assign("user", $_COOKIE['user']); switch ($_SERVER['REQUEST_URI']) { case "/api/login": $users->login(); break; case "/api/register": $users->register(); break; case "/api/createPoll": $polls->add(); break; case "/api/vote": $polls->vote(); break; case "/api/getVotes": $polls->getVotes($_POST["pollid"]); break; case "/api/createPollUI":