private function addToPoll() { $dates = app_controller::$strcln->esc($_POST['dates']); app_controller::$poll_id = app_controller::$strcln->esc($_POST['poll_id']); $email = app_controller::$strcln->esc($_SESSION[SESSION_EMAIL]); $name = app_controller::$strcln->esc($_SESSION[SESSION_NAME]); $poll_id = app_controller::$poll_id; /** @var pointer to poll data gatherer $pollDataGetter */ $pollDataGetter = new database_selectpolldata(); /** @var data from the database about the polls $poll */ $poll = $pollDataGetter->selectPollData(); /** if the poll is empty it means, the poll doesn't exist */ if (!$poll) { return; } /** @var poll participants and poll choices $pollData */ $pollData = unserialize($poll['poll']); //exit(print_r($pollData)); if ($this->isInPoll($pollData, $email)) { app_controller::$err->add('already_in_poll'); return; } else { $userArray['email'] = $email; $userArray['name'] = $name; array_push($userArray, explode(",", $dates)); $pollData[$email] = $userArray; //exit(print_r($pollData)); $pollData = serialize($pollData); $query = "UPDATE tables SET poll='{$pollData}' WHERE url='{$poll_id}'"; $this->doQuery->tryQuery($query); } }
public function __construct() { parent::__construct(); }
private function getPostPollId() { if (isset($_POST['post_type'])) { if ($_POST['post_type'] == "delete") { if ($_SESSION[SESSION_ADMIN] == ADMIN_DECLARATION) { new app_removepersonfrompoll(app_controller::$strcln->esc($_POST['user'])); } else { new app_removepersonfrompoll(); } } else { if ($_POST['post_type'] == "add") { new app_addpersontopoll(); } else { if ($_POST['post_type'] == "delete_poll") { $this->deletePoll(); } else { if ($_POST['post_type'] == "remove_person") { $this->removePerson(); } else { if ($_POST['post_type'] == "confirm_poll") { $this->confirmPoll(); } else { if ($_POST['post_type'] == "admin_add_person") { $this->adminAddPerson(); } } } } } } if (app_controller::$poll_id == null && $_POST['post_type'] == "delete") { } else { if (app_controller::$poll_id == null) { return; } } } app_controller::$poll_id = app_controller::$strcln->esc($_POST['poll_id']); }
private function makeUrl() { $url = "poll_"; $hash = hash('sha256', uniqid()); $url .= substr($hash, 5); app_controller::$poll_id = $url; return $url; }