private function remove($doQuery, $user) { $poll_id = app_controller::$strcln->esc($_POST['poll_id']); if ($user != null) { if ($_SESSION[SESSION_ADMIN] == ADMIN_DECLARATION) { $email = $user; } else { app_controller::$err->add('not_an_admin'); return; } } else { $email = app_controller::$strcln->esc($_SESSION[SESSION_EMAIL]); } $pollDataGetter = new database_selectpolldata(); $poll = $pollDataGetter->selectPollData($poll_id); if (!$poll) { return; } $pollData = unserialize($poll['poll']); foreach ($pollData as $user) { if ($user['email'] == $email) { unset($pollData[$email]); break; } } $sPollData = serialize($pollData); $query = "UPDATE tables SET poll='{$sPollData}' WHERE url='{$poll_id}'"; $doQuery->tryQuery($query); }
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); } }
private function deletePoll() { if ($_POST['post_type'] == "delete_poll") { $pollDataGetter = new database_selectpolldata(); $poll_id = app_controller::$strcln->esc($_POST['poll_id']); $poll = $pollDataGetter->selectPollDataParam($poll_id); $isOwnerOfPoll = new database_isownerofpoll(); $isAdminOfPoll = new security_isuseradmin(); if ($isOwnerOfPoll->checkOwner($poll['email']) || $isAdminOfPoll->isAdmin()) { new app_deletepoll($poll['url']); app_controller::$poll_id = null; } } }
public function __construct() { new printing_printbackbutton(); //echo app_controller::$poll_id.' pollpage.php'; $pollDataGetter = new database_selectpolldata(); $poll = $pollDataGetter->selectPollData(); if (!$poll) { return; } $with_dates = $poll['with_dates']; $isOwnerOfPoll = new database_isownerofpoll(); $isAdminOfPoll = new security_isuseradmin(); if ($isOwnerOfPoll->checkOwner($poll['email']) || $isAdminOfPoll->isAdmin()) { new printing_printdeletebutton(); } $this->selectPollUsers($poll); new printing_printpollinfo($poll); $this->isPersonInPoll($with_dates, $poll); }
function __construct() { //echo "some thing "; $poll_id = app_controller::$strcln->esc($_POST['poll_id']); $pollDataGetter = new database_selectpolldata(); $poll = $pollDataGetter->selectPollData($poll_id); if (!$poll) { return; } $options = unserialize($poll['custom']); $count = 0; $newOptions = array(); foreach ($options as $option) { $cleanOptions = app_controller::$strcln->esc($_POST['option' . $count]); if ($cleanOptions != "") { array_push($newOptions, $cleanOptions); } $count++; } if (isset($_POST['option' . $count])) { $cleanOptions = app_controller::$strcln->esc($_POST['option' . $count]); if ($cleanOptions != "") { array_push($newOptions, $cleanOptions); } } $sNewOptions = serialize($newOptions); //exit(print_r($newOptions)); $doQuery = new database_doquery(); $sql = "UPDATE tables SET custom='{$sNewOptions}' WHERE url='{$poll_id}'"; $doQuery->tryQuery($sql); $users = unserialize($poll['poll']); $colCount = count($options); $rowCount = 0; foreach ($users as $user) { $rowCount++; $userCount = 0; $inPoll = false; foreach ($users as $user) { $userCount++; if (isset($_POST['user_' . $userCount])) { $delUserValue = app_controller::$strcln->esc($_POST['user_' . $userCount]); if ($delUserValue === $user['email']) { $inPoll = true; break; } } } if ($inPoll === true) { unset($users[$user['email']]); continue; } $newArray = array(); for ($i = 1; $i <= $colCount; $i++) { if (isset($_POST['usr_' . $rowCount . '_' . $i])) { array_push($newArray, $_POST['usr_' . $rowCount . '_' . $i]); } } $users[$user['email']][0] = $newArray; //array_replace($user[0], $newArray); } $sChoices = serialize($users); $sql = "UPDATE tables SET poll='{$sChoices}' WHERE url='{$poll_id}'"; $doQuery->tryQuery($sql); /* $options = unserialize($poll['custom']); $optionsCount = count($options); $count = 0; $data = Array(); foreach ($options as $option) { $count++; for ($i = 0; $i < $optionsCount; $i++) { $item = $_POST['usr_'.$count.'_'.$i]; array_push($data, $item); } } exit(print_r($data)); */ }