function POLLS_saveVote_AJAX($pid, $aid) { global $_CONF, $_PO_CONF, $_TABLES, $LANG_POLLS; $retval = array('html' => '', 'statusMessage' => ''); if (POLLS_ipAlreadyVoted($pid)) { $retval['statusMessage'] = 'You have already voted on this poll'; $retval['html'] = POLLS_pollResults($pid, 400, '', '', 2); } else { setcookie('poll-' . $pid, implode('-', $aid), time() + $_PO_CONF['pollcookietime'], $_CONF['cookie_path'], $_CONF['cookiedomain'], $_CONF['cookiesecure']); DB_change($_TABLES['polltopics'], 'voters', "voters + 1", 'pid', DB_escapeString($pid), '', true); $answers = count($aid); for ($i = 0; $i < $answers; $i++) { DB_change($_TABLES['pollanswers'], 'votes', "votes + 1", array('pid', 'qid', 'aid'), array(DB_escapeString($pid), $i, COM_applyFilter($aid[$i], true)), '', true); } DB_save($_TABLES['pollvoters'], 'ipaddress,date,pid', "'" . DB_escapeString($_SERVER['REMOTE_ADDR']) . "'," . time() . ",'" . DB_escapeString($pid) . "'"); } $eMsg = $LANG_POLLS['savedvotemsg'] . ' "' . DB_getItem($_TABLES['polltopics'], 'topic', "pid = '" . DB_escapeString($pid) . "'") . '"'; $retval['statusMessage'] = $eMsg; $retval['html'] = POLLS_pollResults($pid, 400, '', '', 2); return $retval; }
// poll doesn't exist or user doesn't have access COM_handle404($_CONF['site_url'] . '/polls/index.php'); } else { // Meta Tags $headercode = ''; if ($_PO_CONF['meta_tags'] > 0) { $headercode = LB . PLG_getMetaTags('poll', $pid, array(array('name' => 'description', 'content' => stripslashes($A['meta_description'])), array('name' => 'keywords', 'content' => stripslashes($A['meta_keywords'])))); } if ($msg > 0) { $display .= COM_showMessage($msg, 'polls'); } if (isset($_POST['aid'])) { $display .= COM_showMessageText($LANG_POLLS['answer_all'] . ' "' . $polltopic . '"', $LANG_POLLS['not_saved']); } if (DB_getItem($_TABLES['polltopics'], 'is_open', "pid = '{$pid}'") != 1) { $aid = -1; // poll closed - show result } if (!isset($_COOKIE['poll-' . $pid]) && !POLLS_ipAlreadyVoted($pid) && $aid != -1) { $display .= POLLS_pollVote($pid, true, 0, $order, $mode, $page); } else { $display .= POLLS_pollResults($pid, 400, $order, $mode, $page); } $display = COM_createHTMLDocument($display, array('pagetitle' => $polltopic, 'headercode' => $headercode)); } } else { $display .= polllist(); $display = COM_createHTMLDocument($display, array('pagetitle' => $LANG_POLLS['pollstitle'])); } } COM_output($display);