| 1 | <?php |
|---|
| 2 | // $Id: main.php,v 1.6 2005/10/25 02:57:28 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 | // Author: Kazumi Ono (AKA onokazu) // |
|---|
| 28 | // URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // |
|---|
| 29 | // Project: The XOOPS Project // |
|---|
| 30 | // ------------------------------------------------------------------------- // |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->getVar('mid')) ) { |
|---|
| 34 | exit("Access Denied"); |
|---|
| 35 | } else { |
|---|
| 36 | $op = 'list'; |
|---|
| 37 | if (isset($_GET['op'])) { |
|---|
| 38 | $op = trim($_GET['op']); |
|---|
| 39 | } |
|---|
| 40 | switch ($op) { |
|---|
| 41 | case 'list': |
|---|
| 42 | include_once XOOPS_ROOT_PATH.'/include/comment_constants.php'; |
|---|
| 43 | include_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/comment.php'; |
|---|
| 44 | $limit_array = array(10, 20, 50, 100); |
|---|
| 45 | $status_array = array(XOOPS_COMMENT_PENDING => _CM_PENDING, XOOPS_COMMENT_ACTIVE => _CM_ACTIVE, XOOPS_COMMENT_HIDDEN => _CM_HIDDEN); |
|---|
| 46 | $status_array2 = array(XOOPS_COMMENT_PENDING => '<span style="text-decoration: none; font-weight: bold; color: #00ff00;">'._CM_PENDING.'</span>', XOOPS_COMMENT_ACTIVE => '<span style="text-decoration: none; font-weight: bold; color: #ff0000;">'._CM_ACTIVE.'</span>', XOOPS_COMMENT_HIDDEN => '<span style="text-decoration: none; font-weight: bold; color: #0000ff;">'._CM_HIDDEN.'</span>'); |
|---|
| 47 | $status = (!isset($_GET['status']) || !in_array(intval($_GET['status']), array_keys($status_array))) ? 0 : intval($_GET['status']); |
|---|
| 48 | $module = !isset($_GET['module']) ? 0 : intval($_GET['module']); |
|---|
| 49 | $module_handler =& xoops_gethandler('module'); |
|---|
| 50 | $module_array =& $module_handler->getList(new Criteria('hascomments', 1)); |
|---|
| 51 | $comment_handler =& xoops_gethandler('comment'); |
|---|
| 52 | $criteria = new CriteriaCompo(); |
|---|
| 53 | if ($status > 0) { |
|---|
| 54 | $criteria->add(new Criteria('com_status', $status)); |
|---|
| 55 | } |
|---|
| 56 | if ($module > 0) { |
|---|
| 57 | $criteria->add(new Criteria('com_modid', $module)); |
|---|
| 58 | } |
|---|
| 59 | $total = $comment_handler->getCount($criteria); |
|---|
| 60 | if ($total > 0) { |
|---|
| 61 | $start = isset($_GET['start']) ? intval($_GET['start']) : 0; |
|---|
| 62 | $limit = isset($_GET['limit']) ? intval($_GET['limit']) : 0; |
|---|
| 63 | if (!in_array($limit, $limit_array)) { |
|---|
| 64 | $limit = 50; |
|---|
| 65 | } |
|---|
| 66 | $sort = (!isset($_GET['sort']) || !in_array($_GET['sort'], array('com_modid', 'com_status', 'com_created', 'com_uid', 'com_ip', 'com_title'))) ? 'com_id' : $_GET['sort']; |
|---|
| 67 | if (!isset($_GET['order']) || $_GET['order'] != 'ASC') { |
|---|
| 68 | $order = 'DESC'; |
|---|
| 69 | $otherorder = 'ASC'; |
|---|
| 70 | } else { |
|---|
| 71 | $order = 'ASC'; |
|---|
| 72 | $otherorder = 'DESC'; |
|---|
| 73 | } |
|---|
| 74 | $criteria->setSort($sort); |
|---|
| 75 | $criteria->setOrder($order); |
|---|
| 76 | $criteria->setLimit($limit); |
|---|
| 77 | $criteria->setStart($start); |
|---|
| 78 | $comments =& $comment_handler->getObjects($criteria, true); |
|---|
| 79 | } else { |
|---|
| 80 | $start = 0; |
|---|
| 81 | $limit = 0; |
|---|
| 82 | $otherorder = 'DESC'; |
|---|
| 83 | $comments = array(); |
|---|
| 84 | } |
|---|
| 85 | $form = '<form action="admin.php" method="get">'; |
|---|
| 86 | $form .= '<select name="module">'; |
|---|
| 87 | $module_array[0] = _MD_AM_ALLMODS; |
|---|
| 88 | foreach ($module_array as $k => $v) { |
|---|
| 89 | $sel = ''; |
|---|
| 90 | if ($k == $module) { |
|---|
| 91 | $sel = ' selected="selected"'; |
|---|
| 92 | } |
|---|
| 93 | $form .= '<option value="'.$k.'"'.$sel.'>'.$v.'</option>'; |
|---|
| 94 | } |
|---|
| 95 | $form .= '</select> <select name="status">'; |
|---|
| 96 | $status_array[0] = _MD_AM_ALLSTATUS; |
|---|
| 97 | foreach ($status_array as $k => $v) { |
|---|
| 98 | $sel = ''; |
|---|
| 99 | if (isset($status) && $k == $status) { |
|---|
| 100 | $sel = ' selected="selected"'; |
|---|
| 101 | } |
|---|
| 102 | $form .= '<option value="'.$k.'"'.$sel.'>'.$v.'</option>'; |
|---|
| 103 | } |
|---|
| 104 | $form .= '</select> <select name="limit">'; |
|---|
| 105 | foreach ($limit_array as $k) { |
|---|
| 106 | $sel = ''; |
|---|
| 107 | if (isset($limit) && $k == $limit) { |
|---|
| 108 | $sel = ' selected="selected"'; |
|---|
| 109 | } |
|---|
| 110 | $form .= '<option value="'.$k.'"'.$sel.'>'.$k.'</option>'; |
|---|
| 111 | } |
|---|
| 112 | $form .= '</select> <input type="hidden" name="fct" value="comments" /><input type="submit" value="'._GO.'" name="selsubmit" /></form>'; |
|---|
| 113 | |
|---|
| 114 | xoops_cp_header(); |
|---|
| 115 | echo '<h4 style="text-align:left">'._MD_AM_COMMMAN.'</h4>'; |
|---|
| 116 | echo $form; |
|---|
| 117 | echo '<table width="100%" class="outer" cellspacing="1"><tr><th colspan="8">'._MD_AM_LISTCOMM.'</th></tr><tr align="center"><td class="head"> </td><td class="head" align="left"><a href="admin.php?fct=comments&op=list&sort=com_title&order='.$otherorder.'&module='.$module.'&status='.$status.'&start='.$start.'&limit='.$limit.'">'._CM_TITLE.'</a></td><td class="head"><a href="admin.php?fct=comments&op=list&sort=com_created&order='.$otherorder.'&module='.$module.'&status='.$status.'&start='.$start.'&limit='.$limit.'">'._CM_POSTED.'</a></td><td class="head"><a href="admin.php?fct=comments&op=list&sort=com_uid&order='.$otherorder.'&module='.$module.'&status='.$status.'&start='.$start.'&limit='.$limit.'">'._CM_POSTER.'</a></td><td class="head"><a href="admin.php?fct=comments&op=list&sort=com_ip&order='.$otherorder.'&module='.$module.'&status='.$status.'&start='.$start.'&limit='.$limit.'">IP</a></td><td class="head"><a href="admin.php?fct=comments&op=list&sort=com_modid&order='.$otherorder.'&module='.$module.'&status='.$status.'&start='.$start.'&limit='.$limit.'">'._MD_AM_MODULE.'</a></td><td class="head"><a href="admin.php?fct=comments&op=list&sort=com_status&order='.$otherorder.'&module='.$module.'&status='.$status.'&start='.$start.'&limit='.$limit.'">'._CM_STATUS.'</a></td><td class="head"> </td></tr>'; |
|---|
| 118 | $class = 'even'; |
|---|
| 119 | foreach (array_keys($comments) as $i) { |
|---|
| 120 | $class = ($class == 'odd') ? 'even' : 'odd'; |
|---|
| 121 | $poster_uname = $xoopsConfig['anonymous']; |
|---|
| 122 | if ($comments[$i]->getVar('com_uid') > 0) { |
|---|
| 123 | $poster =& $member_handler->getUser($comments[$i]->getVar('com_uid')); |
|---|
| 124 | if (is_object($poster)) { |
|---|
| 125 | $poster_uname = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$comments[$i]->getVar('com_uid').'">'.$poster->getVar('uname').'</a>'; |
|---|
| 126 | } |
|---|
| 127 | } |
|---|
| 128 | $icon = ($comments[$i]->getVar('com_icon') != '') ? '<img src="'.XOOPS_URL.'/images/subject/'.htmlspecialchars($comments[$i]->getVar('com_icon')).'" alt="" />' : '<img src="'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" />'; |
|---|
| 129 | echo '<tr align="center"><td class="'.$class.'">'.$icon.'</td><td class="'.$class.'" align="left"><a href="admin.php?fct=comments&op=jump&com_id='.$i.'">'. $comments[$i]->getVar('com_title').'</a></td><td class="'.$class.'">'.formatTimestamp($comments[$i]->getVar('com_created'), 'm').'</td><td class="'.$class.'">'.$poster_uname.'</td><td class="'.$class.'">'.$comments[$i]->getVar('com_ip').'</td><td class="'.$class.'">'.$module_array[$comments[$i]->getVar('com_modid')].'</td><td class="'.$class.'">'.$status_array2[$comments[$i]->getVar('com_status')].'</td><td class="'.$class.'" align="right"><a href="admin/comments/comment_edit.php?com_id='.$i.'">'._EDIT.'</a> <a href="admin/comments/comment_delete.php?com_id='.$i.'">'._DELETE.'</a></td></tr>'; |
|---|
| 130 | } |
|---|
| 131 | echo '</table>'; |
|---|
| 132 | echo '<table style="width: 100%; border: 0; margin: 3px; padding: 3px;"><tr><td>'.sprintf(_MD_AM_COMFOUND, '<b>'.$total.'</b>'); |
|---|
| 133 | if ($total > $limit) { |
|---|
| 134 | include_once XOOPS_ROOT_PATH.'/class/pagenav.php'; |
|---|
| 135 | $nav = new XoopsPageNav($total, $limit, $start, 'start', 'fct=comments&op=list&limit='.$limit.'&sort='.$sort.'&order='.$order.'&module='.$module); |
|---|
| 136 | echo '</td><td align="right">'.$nav->renderNav(); |
|---|
| 137 | } |
|---|
| 138 | echo '</td></tr></table>'; |
|---|
| 139 | xoops_cp_footer(); |
|---|
| 140 | break; |
|---|
| 141 | |
|---|
| 142 | case 'jump': |
|---|
| 143 | $com_id = (isset($_GET['com_id'])) ? intval($_GET['com_id']) : 0; |
|---|
| 144 | if ($com_id > 0) { |
|---|
| 145 | $comment_handler =& xoops_gethandler('comment'); |
|---|
| 146 | $comment =& $comment_handler->get($com_id); |
|---|
| 147 | if (is_object($comment)) { |
|---|
| 148 | $module_handler =& xoops_gethandler('module'); |
|---|
| 149 | $module =& $module_handler->get($comment->getVar('com_modid')); |
|---|
| 150 | $comment_config = $module->getInfo('comments'); |
|---|
| 151 | header('Location: '.XOOPS_URL.'/modules/'.$module->getVar('dirname').'/'.$comment_config['pageName'].'?'.$comment_config['itemName'].'='.$comment->getVar('com_itemid').'&com_id='.$comment->getVar('com_id').'&com_rootid='.$comment->getVar('com_rootid').'&com_mode=thread&'.$comment->getVar('com_exparams').'#comment'.$comment->getVar('com_id')); |
|---|
| 152 | exit(); |
|---|
| 153 | } |
|---|
| 154 | } |
|---|
| 155 | redirect_header('admin.php?fct=comments', 1); |
|---|
| 156 | break; |
|---|
| 157 | |
|---|
| 158 | default: |
|---|
| 159 | break; |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | } |
|---|
| 163 | ?> |
|---|