Пример #1
0
        unset($polls);
    }
    include XOOPS_ROOT_PATH . "/footer.php";
} elseif (!empty($_POST['option_id'])) {
    $voted_polls = !empty($HTTP_COOKIE_VARS['voted_polls']) ? $HTTP_COOKIE_VARS['voted_polls'] : array();
    $mail_author = false;
    $poll = new XoopsPoll($poll_id);
    if (!$poll->hasExpired()) {
        if ($poll->isAllowedToVote()) {
            if (empty($voted_polls[$poll_id])) {
                if ($xoopsUser) {
                    if (XoopsPollLog::hasVoted($poll_id, xoops_getenv('REMOTE_ADDR'), $xoopsUser->getVar("uid"))) {
                        setcookie("voted_polls[{$poll_id}]", 1, 0);
                        $msg = _PL_ALREADYVOTED;
                    } else {
                        $poll->vote($_POST['option_id'], xoops_getenv('REMOTE_ADDR'), $xoopsUser->getVar("uid"));
                        $poll->updateCount();
                        setcookie("voted_polls[{$poll_id}]", 1, 0);
                        $msg = _PL_THANKSFORVOTE;
                    }
                } else {
                    if (XoopsPollLog::hasVoted($poll_id, xoops_getenv('REMOTE_ADDR'))) {
                        setcookie("voted_polls[{$poll_id}]", 1, 0);
                        $msg = _PL_ALREADYVOTED;
                    } else {
                        $poll->vote($_POST['option_id'], xoops_getenv('REMOTE_ADDR'));
                        $poll->updateCount();
                        setcookie("voted_polls[{$poll_id}]", 1, 0);
                        $msg = _PL_THANKSFORVOTE;
                    }
                }
Пример #2
0
$topic_handler =& xoops_getmodulehandler('topic', 'xforum');
$topic_obj =& $topic_handler->get($topic_id);
if (!$topic_handler->getPermission($topic_obj->getVar("forum_id"), $topic_obj->getVar('topic_status'), "vote")){
    	redirect_header("javascript:history.go(-1);", 2, _NOPERM);
}

if ( !empty($_POST['option_id']) ) {
	$mail_author = false;
	$poll = new XoopsPoll($poll_id);

		if ( is_object($xoopsUser) ) {
			if ( XoopsPollLog::hasVoted($poll_id, $_SERVER['REMOTE_ADDR'], $xoopsUser->getVar("uid")) ) {
				$msg = _PL_ALREADYVOTED;
				setcookie("xf_polls[$poll_id]", 1);
			} else {
				$poll->vote($_POST['option_id'], '', $xoopsUser->getVar("uid"));
				$poll->updateCount();
				$msg = _PL_THANKSFORVOTE;
				setcookie("xf_polls[$poll_id]", 1);
			}
		} else {
			if ( XoopsPollLog::hasVoted($poll_id, $_SERVER['REMOTE_ADDR']) ) {
				$msg = _PL_ALREADYVOTED;
				setcookie("xf_polls[$poll_id]", 1);
			} else {
				$poll->vote($_POST['option_id'], $_SERVER['REMOTE_ADDR']);
				$poll->updateCount();
				$msg = _PL_THANKSFORVOTE;
				setcookie("xf_polls[$poll_id]", 1);
			}
		}