/** * * Проголосовать или показать результат * * @param integer $thread_id id треда * @param array $answers id ответов (если 0, то просто отобразить результат) */ function BlogsPoll_Vote($thread_id, $answers, $sess) { require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/blogs.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/users.php"; session_start(); $uid = intval($_SESSION['uid']); $user = new users(); $thread_id = intval($thread_id); if (!is_array($answers)) { $answers = array($answers); } $tmp = array(); foreach ($answers as $k => $v) { if (is_numeric($v)) { $tmp[] = intval($v); } } $answers = $tmp; $objResponse = new xajaxResponse(); $ban_where = $user->GetField($uid, $error, "ban_where"); if ($ban_where == 1) { $objResponse->alert('Вам закрыт доступ в блоги'); return $objResponse; } $blog = new blogs(); if (!empty($answers)) { if ($sess && $sess == $_SESSION['rand']) { $res = $blog->Poll_Vote($uid, $answers, $error); } if (!$res) { if (!$error) { $error = 'Ошибка <> ' . $sess . ' <> ' . $_SESSION['rand']; } $objResponse->alert($error); } } $poll = $blog->Poll_Answers($thread_id); $voted = $blog->Poll_Voted($uid, $thread_id); BlogsPoll_ShowResult($thread_id, $objResponse, $poll, $voted); return $objResponse; }