public static function PollVote() { $poll_id = $_POST['poll_id']; $oPoll = GFontsDB::GetPoll($poll_id); $width = $_POST['width']; $height = $_POST['height']; $legend = $_POST['legend']; if (!$oPoll) { _e('Wrong poll ID.', self::PLUGIN_SLUG); die; } else { $client_mode = $oPoll->client_mode; $allowed = true; $ip = $_SERVER['REMOTE_ADDR']; if (isset($_SERVER['HTTP_X_REAL_IP'])) { $ip = $_SERVER['HTTP_X_REAL_IP']; } $allowed = $oPoll->voting_enabled == 1; if ($allowed) { $enddate = strtotime($oPoll->voting_end_date); $today = time(); if ($enddate < $today) { $allowed = false; } } if ($client_mode == 0) { if (isset($_COOKIE['poll_vote_' . $poll_id])) { $allowed = false; } } else { $c = GFontsDB::CheckVoteIpForPoll($poll_id, $ip); if ($c > 0) { $allowed = false; } } if (!$allowed) { echo GF_Poll_Output::GeneratePollOutput($oPoll, $_POST['area'], $width, $height, $legend); } else { $answer_id = isset($_POST['answer_id']) ? intval($_POST['answer_id']) : 0; if ($answer_id == 0) { echo GF_Poll_Output::GeneratePollOutput($oPoll, $_POST['area'], $width, $height, $legend); } else { GFontsDB::AddPollHit($poll_id, $answer_id, $client_mode, $ip); if ($client_mode == 0) { setcookie('poll_vote_' . $poll_id, 1, time() + 7776000, '/'); } echo GF_Poll_Output::GeneratePollOutput($oPoll, $_POST['area'], $width, $height, $legend); } } } die; }