| 1 | <?php |
|---|
| 2 | // $Id: pollresults.php,v 1.3 2005/09/04 20:46:12 onokazu Exp $ |
|---|
| 3 | // ------------------------------------------------------------------------ // |
|---|
| 4 | // XOOPS - PHP Content Management System // |
|---|
| 5 | // Copyright (c) 2000 XOOPS.org // |
|---|
| 6 | // <http://www.xoops.org/> // |
|---|
| 7 | // ------------------------------------------------------------------------ // |
|---|
| 8 | // This program is free software; you can redistribute it and/or modify // |
|---|
| 9 | // it under the terms of the GNU General Public License as published by // |
|---|
| 10 | // the Free Software Foundation; either version 2 of the License, or // |
|---|
| 11 | // (at your option) any later version. // |
|---|
| 12 | // // |
|---|
| 13 | // You may not change or alter any portion of this comment or credits // |
|---|
| 14 | // of supporting developers from this source code or any supporting // |
|---|
| 15 | // source code which is considered copyrighted (c) material of the // |
|---|
| 16 | // original comment or credit authors. // |
|---|
| 17 | // // |
|---|
| 18 | // This program is distributed in the hope that it will be useful, // |
|---|
| 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|---|
| 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|---|
| 21 | // GNU General Public License for more details. // |
|---|
| 22 | // // |
|---|
| 23 | // You should have received a copy of the GNU General Public License // |
|---|
| 24 | // along with this program; if not, write to the Free Software // |
|---|
| 25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|---|
| 26 | // ------------------------------------------------------------------------ // |
|---|
| 27 | |
|---|
| 28 | include "../../mainfile.php"; |
|---|
| 29 | include XOOPS_ROOT_PATH.'/class/pagenav.php'; |
|---|
| 30 | include XOOPS_ROOT_PATH."/modules/xoopspoll/include/constants.php"; |
|---|
| 31 | include_once XOOPS_ROOT_PATH."/modules/xoopspoll/class/xoopspoll.php"; |
|---|
| 32 | include_once XOOPS_ROOT_PATH."/modules/xoopspoll/class/xoopspolloption.php"; |
|---|
| 33 | include_once XOOPS_ROOT_PATH."/modules/xoopspoll/class/xoopspolllog.php"; |
|---|
| 34 | include_once XOOPS_ROOT_PATH."/modules/xoopspoll/class/xoopspollrenderer.php"; |
|---|
| 35 | |
|---|
| 36 | $poll_id = $_GET['poll_id']; |
|---|
| 37 | $option_id = $_GET['option_id']; |
|---|
| 38 | if(empty($option_id)) $option_id = $_POST['option_id']; |
|---|
| 39 | |
|---|
| 40 | // ¥ª¥×¥·¥ç¥óID¤¬Èô¤ó¤Ç¤¤Æ¤¤¤ë¤«¥Á¥§¥Ã¥¯ |
|---|
| 41 | $option_id = (!empty($option_id)) ? intval($option_id) : 0; |
|---|
| 42 | if (empty($option_id)) { |
|---|
| 43 | redirect_header("pollresults.php?poll_id=".$poll_id,0); |
|---|
| 44 | exit(); |
|---|
| 45 | } |
|---|
| 46 | $start = !empty($_GET['start']) ? intval($_GET['start']) : 0; |
|---|
| 47 | |
|---|
| 48 | switch($_POST['mode']) { |
|---|
| 49 | case 'rating': |
|---|
| 50 | $poll_id = $_POST['poll_id']; |
|---|
| 51 | $arrErr = lfErrCheck($_POST); |
|---|
| 52 | if(count($arrErr) <= 0) { |
|---|
| 53 | $poll = new XoopsPoll($poll_id); |
|---|
| 54 | if ( $xoopsUser ) { |
|---|
| 55 | $uid = $xoopsUser->getVar("uid"); |
|---|
| 56 | } else { |
|---|
| 57 | $uid = 0; |
|---|
| 58 | } |
|---|
| 59 | $poll->vote($option_id, xoops_getenv('REMOTE_ADDR'), $uid, $_POST['rating_id'], $_POST['comment']); |
|---|
| 60 | $poll->updateCount(); |
|---|
| 61 | redirect_header(XOOPS_URL."/modules/xoopspoll/pollresults.php?poll_id=".$poll_id, 1, $msg); |
|---|
| 62 | exit(); |
|---|
| 63 | } |
|---|
| 64 | break; |
|---|
| 65 | default: |
|---|
| 66 | break; |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | $xoopsOption['template_main'] = 'xoopspoll_rating.html'; |
|---|
| 70 | include XOOPS_ROOT_PATH."/header.php"; |
|---|
| 71 | |
|---|
| 72 | $dummy = ""; |
|---|
| 73 | $renderer = new XoopsPollRenderer($dummy); |
|---|
| 74 | |
|---|
| 75 | $renderer->assignOption($xoopsTpl, $option_id); |
|---|
| 76 | $count = $renderer->assignComment($xoopsTpl, $option_id, $start, POLL_COMMENT_VIEW); |
|---|
| 77 | |
|---|
| 78 | $nav = new XoopsPageNav($count, POLL_OPTION_VIEW, $start, "start", 'poll_id='.$poll_id.'&option_id='.$option_id); |
|---|
| 79 | $xoopsTpl->assign('forum_pagenav', $nav->renderNav(4)); |
|---|
| 80 | |
|---|
| 81 | $xoopsTpl->assign('arrForm', $_POST); |
|---|
| 82 | $xoopsTpl->assign('arrStatus', $arrStatus); |
|---|
| 83 | $xoopsTpl->assign('arrCat', $arrCategory); |
|---|
| 84 | $xoopsTpl->assign('arrRating', $arrRating); |
|---|
| 85 | $xoopsTpl->assign('poll_id', $poll_id); |
|---|
| 86 | $xoopsTpl->assign('start', $start); |
|---|
| 87 | $xoopsTpl->assign('arrErr', $arrErr); |
|---|
| 88 | |
|---|
| 89 | include XOOPS_ROOT_PATH.'/include/comment_view.php'; |
|---|
| 90 | |
|---|
| 91 | include XOOPS_ROOT_PATH."/footer.php"; |
|---|
| 92 | |
|---|
| 93 | //--------------------------------------------------------------------------------------------------- |
|---|
| 94 | |
|---|
| 95 | function lfErrCheck($arrForm) { |
|---|
| 96 | |
|---|
| 97 | $body_len = 200; |
|---|
| 98 | |
|---|
| 99 | $arrErr = array(); |
|---|
| 100 | |
|---|
| 101 | if(mb_strlen($arrForm['comment']) > $title_len) { |
|---|
| 102 | $arrErr['title'] = " ¢¨ ¥³¥á¥ó¥È¤Ï".$body_len."ʸ»ú°ÊÆâ¤ÇÆþÎϤ·¤Æ²¼¤µ¤¤¡£"; |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | return $arrErr; |
|---|
| 106 | } |
|---|
| 107 | ?> |
|---|