// http://reloadcms.sf.net // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY, without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // // // // This product released under GNU General Public License v2 // //////////////////////////////////////////////////////////////////////////////// if (!empty($_POST['poll_new'])) { rcms_showAdminMessage($lang['results']['polls'][poll_create($_POST['poll_question'], $_POST['poll_variants'])]); } if (!empty($_POST['rmpoll'])) { rcms_showAdminMessage($lang['results']['polls'][poll_remove()]); } if (!poll_is_running()) { $frm = new InputForm("", "post", $lang['general']['submit']); $frm->addbreak($lang['admincp']['poll']['poll']['new']); $frm->hidden('poll_new', '1'); $frm->addrow($lang['poll']['question'], $frm->text_box("poll_question", '', 40)); $frm->addrow($lang['poll']['answers'], $frm->textarea("poll_variants", '', 50, 10), 'top'); $frm->show(); } else { $polldata = poll_get(); $frm = new InputForm("", "post", $lang['general']['submit']); $frm->addrow($lang['poll']['question'] . ': ' . $polldata['q']); foreach ($polldata['v'] as $id => $answer) { $frm->addrow($polldata['c'][$id], $answer); } $frm->addrow($frm->checkbox('rmpoll', '1', $lang['admincp']['poll']['poll']['del'])); $frm->show(); }
function light_poll_display($tid, $msg_count, $folder_fid, $in_list = true, $closed = false, $limit_text = true, $is_preview = false) { $webtag = get_webtag(); forum_check_webtag_available($webtag); $total_votes = 0; $user_votes = 0; $guest_votes = 0; $poll_data = poll_get($tid); $poll_results = poll_get_votes($tid); $user_poll_votes_array = poll_get_user_votes($tid); poll_get_total_votes($tid, $total_votes, $user_votes, $guest_votes); $request_uri = get_request_uri(); $poll_display = "<div class=\"poll\">\n"; $poll_display .= "<form accept-charset=\"utf-8\" method=\"post\" action=\"{$request_uri}\" target=\"_self\">\n"; $poll_display .= form_csrf_token_field(); $poll_display .= form_input_hidden('webtag', htmlentities_array($webtag)); $poll_display .= form_input_hidden('msg', htmlentities_array("{$tid}.1")); if ((!is_array($user_poll_votes_array) || $poll_data['CHANGEVOTE'] == POLL_VOTE_MULTI) && ($_SESSION['UID'] > 0 || $poll_data['ALLOWGUESTS'] == POLL_GUEST_ALLOWED && forum_get_setting('poll_allow_guests', 'Y')) && ($poll_data['CLOSES'] == 0 || $poll_data['CLOSES'] > time()) && !$is_preview) { foreach ($poll_results as $question_id => $poll_question) { $poll_display .= "<h3>" . word_filter_add_ob_tags($poll_question['QUESTION'], true) . "</h3>\n"; if ($poll_data['OPTIONTYPE'] == POLL_OPTIONS_DROPDOWN) { $dropdown_options_array = array_map('poll_dropdown_options_callback', $poll_question['OPTIONS_ARRAY']); $poll_display .= light_form_dropdown_array("poll_vote[{$question_id}]", $dropdown_options_array); } else { foreach ($poll_question['OPTIONS_ARRAY'] as $option_id => $option) { if (sizeof($poll_question['OPTIONS_ARRAY']) == 1 || $poll_question['ALLOW_MULTI'] == 'Y') { $poll_display .= light_form_checkbox("poll_vote[{$question_id}][{$option_id}]", 'Y', word_filter_add_ob_tags($option['OPTION_NAME'])); } else { $poll_display .= light_form_radio("poll_vote[{$question_id}]", $option_id, word_filter_add_ob_tags($option['OPTION_NAME'])); } } } } } else { if ($poll_data['SHOWRESULTS'] == POLL_SHOW_RESULTS || $poll_data['CLOSES'] > 0 && $poll_data['CLOSES'] < time()) { $poll_display .= "<div class=\"poll_results\">\n"; foreach ($poll_results as $poll_question) { $poll_display .= "<h3>" . word_filter_add_ob_tags($poll_question['QUESTION'], true) . "</h3>\n"; $poll_display .= light_poll_graph_display($poll_question['OPTIONS_ARRAY']); } $poll_display .= "</div>\n"; } else { $poll_display .= "<div class=\"poll_results\">\n"; foreach ($poll_results as $poll_question) { $poll_display .= "<h3>" . word_filter_add_ob_tags($poll_question['QUESTION'], true) . "</h3>\n"; foreach ($poll_question['OPTIONS_ARRAY'] as $option) { $poll_display .= word_filter_add_ob_tags($option['OPTION_NAME']); } } $poll_display .= "</div>\n"; } } if (!$is_preview) { $poll_display .= "<div class=\"poll_vote_counts\">" . poll_format_vote_counts($poll_data, $user_votes, $guest_votes) . "</div>\n"; if ($poll_data['CLOSES'] <= time() && $poll_data['CLOSES'] != 0) { $poll_display .= "<div class=\"poll_vote_closed\">" . gettext("Poll has ended") . "</div>\n"; if (is_array($user_poll_votes_array) && sizeof($user_poll_votes_array) > 0) { $poll_display .= poll_display_user_votes($user_poll_votes_array); } } else { if (is_array($user_poll_votes_array) && sizeof($user_poll_votes_array) > 0) { $poll_display .= poll_display_user_votes($user_poll_votes_array); if ($poll_data['CHANGEVOTE'] == POLL_VOTE_MULTI) { $poll_display .= "<div class=\"poll_buttons\">" . light_form_submit('poll_submit', gettext("Vote")) . "</div>"; } if ($poll_data['CHANGEVOTE'] != POLL_VOTE_CANNOT_CHANGE) { $poll_display .= "<div class=\"poll_buttons\">" . light_form_submit('poll_change_vote', gettext("Change vote")) . "</div>\n"; } if ($poll_data['VOTETYPE'] == POLL_VOTE_PUBLIC && $poll_data['CHANGEVOTE'] < POLL_VOTE_MULTI && $poll_data['POLLTYPE'] != POLL_TABLE_GRAPH) { $poll_display .= "<div class=\"poll_type_warning\">" . gettext("<b>Warning</b>: This is a public ballot. Your name will be visible next to the option you vote for.") . "</div>\n"; } } else { if ($_SESSION['UID'] > 0 || $poll_data['ALLOWGUESTS'] == POLL_GUEST_ALLOWED && forum_get_setting('poll_allow_guests', 'Y')) { $poll_display .= "<div class=\"poll_buttons\">" . light_form_submit('poll_submit', gettext("Vote")) . "</div>"; if ($poll_data['VOTETYPE'] == POLL_VOTE_PUBLIC && $poll_data['CHANGEVOTE'] < POLL_VOTE_MULTI && $poll_data['POLLTYPE'] != POLL_TABLE_GRAPH) { $poll_display .= "<div class=\"poll_type_warning\">" . gettext("<b>Warning</b>: This is a public ballot. Your name will be visible next to the option you vote for.") . "</div>\n"; } } } } } $poll_display .= "</form>\n"; $poll_display .= "</div>\n"; $poll_data['CONTENT'] = $poll_display; light_message_display($tid, $poll_data, $msg_count, 1, $folder_fid, $in_list, $closed, $limit_text, true, $is_preview); }
function poll_vote($tid, $vote_array) { if (($uid = session::get_value('UID')) === false) { return false; } if (!is_numeric($tid)) { return false; } if (!is_array($vote_array)) { return false; } if (!($db = db::get())) { return false; } if (!($table_prefix = get_table_prefix())) { return false; } $poll_data = poll_get($tid); $poll_results = poll_get_votes($tid); $current_datetime = date(MYSQL_DATETIME, time()); if (!poll_get_user_votes($tid) || $poll_data['CHANGEVOTE'] == POLL_VOTE_MULTI || !session::logged_in() && ($poll_data['ALLOWGUESTS'] == POLL_GUEST_ALLOWED && forum_get_setting('poll_allow_guests', 'Y'))) { foreach ($vote_array as $question_id => $option_data) { if (!is_numeric($question_id) || !isset($poll_results[$question_id])) { continue; } if (is_array($option_data) && sizeof($option_data) > 0) { foreach ($option_data as $option_id => $option_value) { if (!is_numeric($option_id) || $option_value != 'Y') { continue; } if (!isset($poll_results[$question_id]['OPTIONS_ARRAY'][$option_id])) { continue; } $sql = "INSERT INTO `{$table_prefix}USER_POLL_VOTES` (TID, UID, QUESTION_ID, OPTION_ID, VOTED) "; $sql .= "VALUES ('{$tid}', '{$uid}', '{$question_id}', '{$option_id}', CAST('{$current_datetime}' AS DATETIME))"; if (!$db->query($sql)) { return false; } } } else { if (is_numeric($option_data)) { if (!isset($poll_results[$question_id]['OPTIONS_ARRAY'][$option_data])) { continue; } $sql = "INSERT INTO `{$table_prefix}USER_POLL_VOTES` (TID, UID, QUESTION_ID, OPTION_ID, VOTED) "; $sql .= "VALUES ('{$tid}', '{$uid}', '{$question_id}', '{$option_data}', CAST('{$current_datetime}' AS DATETIME))"; if (!$db->query($sql)) { return false; } } } } } return true; }
html_draw_top(sprintf("title=%s", gettext("Error"))); html_display_error_msg(gettext("That post does not exist in this thread!")); html_draw_bottom(); exit; } $post_edit_time = forum_get_setting('post_edit_time', null, 0); $show_sigs = session::get_value('VIEW_SIGS') == 'N' ? false : true; $page_prefs = session::get_post_page_prefs(); $uid = session::get_value('UID'); if ((forum_get_setting('allow_post_editing', 'N') || $uid != $edit_message['FROM_UID'] && !(perm_get_user_permissions($edit_message['FROM_UID']) & USER_PERM_PILLORIED) || session::check_perm(USER_PERM_PILLORIED, 0) || $post_edit_time > 0 && time() - $edit_message['CREATED'] >= $post_edit_time * HOUR_IN_SECONDS) && !session::check_perm(USER_PERM_FOLDER_MODERATE, $fid)) { html_draw_error(gettext("You are not permitted to edit this message."), 'discussion.php', 'get', array('back' => gettext("Back")), array('msg' => $edit_msg)); } if (forum_get_setting('require_post_approval', 'Y') && isset($edit_message['APPROVED']) && $edit_message['APPROVED'] == 0 && !session::check_perm(USER_PERM_FOLDER_MODERATE, $fid)) { html_draw_error(gettext("You are not permitted to edit this message."), 'discussion.php', 'get', array('back' => gettext("Back")), array('msg' => $edit_msg)); } $poll_data = poll_get($tid); $poll_questions_array = poll_get_votes($tid); $valid = true; if (isset($_POST['thread_title'])) { if (strlen(trim($_POST['thread_title'])) > 0) { $thread_title = trim($_POST['thread_title']); } else { $thread_title = ''; } } else { $thread_title = $thread_data['TITLE']; } if (isset($_POST['fid'])) { if (is_numeric($_POST['fid']) && $_POST['fid'] > 0) { $fid = $_POST['fid']; } else {
if (isset($_GET['tid']) && is_numeric($_GET['tid'])) { $tid = $_GET['tid']; if (!($t_fid = thread_get_folder_fid($tid))) { html_draw_error(gettext("The requested thread could not be found or access was denied.")); } } else { html_draw_error(gettext("You must specify a poll to view.")); } if (!($folder_data = thread_get_folder($tid))) { html_draw_error(gettext("The requested folder could not be found or access was denied.")); } $perm_folder_moderate = session::check_perm(USER_PERM_FOLDER_MODERATE, $folder_data['FID']); if (!($thread_data = thread_get($tid, $perm_folder_moderate, false, $perm_folder_moderate))) { html_draw_error(gettext("The requested thread could not be found or access was denied.")); } if (!($poll_data = poll_get($tid))) { html_draw_error(gettext("The requested thread could not be found or access was denied.")); } $show_sigs = session::show_sigs(); $highlight_array = array(); $poll_user_count = 0; $poll_results = poll_get_votes($tid); $user_poll_votes_array = poll_get_user_votes($tid); html_draw_top(array('title' => $thread_data['TITLE'], 'pm_popup_disabled' => true, 'class' => 'window_title', 'js' => array('js/poll.js'))); echo "<div align=\"center\">\n"; echo "<table width=\"96%\" border=\"0\">\n"; echo " <tr>\n"; echo " <td align=\"left\">"; messages_top($tid, 1, $thread_data['FID'], $folder_data['TITLE'], $thread_data['TITLE'], $thread_data['INTEREST'], $folder_data['INTEREST'], $thread_data['STICKY'], $thread_data['CLOSED'], $thread_data['ADMIN_LOCK'], $thread_data['DELETED'] == 'Y', false, array()); echo " </td>\n"; echo " </tr>\n";
<?php //////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2004 ReloadCMS Development Team // // http://reloadcms.sf.net // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY, without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // // // // This product released under GNU General Public License v2 // //////////////////////////////////////////////////////////////////////////////// if (!empty($system->results['vote'])) { $system->showModuleWindow('', $lang['results']['polls'][$system->results['vote']], 'center'); } if ($poll = poll_get()) { $voted = poll_is_voted($_SERVER['REMOTE_ADDR']); $result = ' <table cellspacing="1" cellpadding="1" border="0" width="100%"> <form action="" method="post"> <tr> <th colspan="3">' . $poll['q'] . '</th> </tr>'; foreach ($poll['v'] as $v_id => $v_title) { $result .= ' <tr class="row1"> <td>' . (!$voted ? '<input type="radio" name="poll_vote" value="' . $v_id . '">' : '') . '</td> <td align="left" width="100%">' . $v_title . '</td> <td align="right">' . $poll['c'][$v_id] . '</td> </tr> <tr>