mambax7 /
newbb
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php declare(strict_types=1); |
||
| 2 | |||
| 3 | /** |
||
| 4 | * newbb |
||
| 5 | * |
||
| 6 | * @copyright XOOPS Project (https://xoops.org) |
||
| 7 | * @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
| 8 | * @author Taiwen Jiang (phppp or D.J.) <[email protected]> |
||
| 9 | * @since 4.00 |
||
| 10 | */ |
||
| 11 | |||
| 12 | use Xmf\Module\Admin; |
||
| 13 | use Xmf\Request; |
||
| 14 | use XoopsModules\Newbb\{ |
||
| 15 | Helper, |
||
| 16 | TopicHandler |
||
| 17 | }; |
||
| 18 | |||
| 19 | /** @var Admin $adminObject */ |
||
| 20 | /** @var TopicHandler $topicHandler */ |
||
| 21 | |||
| 22 | // irmtfan - TODO - should be changed completly with Newbb new function newbbSynchronization |
||
| 23 | require_once __DIR__ . '/admin_header.php'; |
||
| 24 | xoops_cp_header(); |
||
| 25 | require_once \dirname(__DIR__) . '/include/functions.recon.php'; |
||
| 26 | $form = $adminObject->displayNavigation(basename(__FILE__)); |
||
| 27 | |||
| 28 | //if (!empty($_GET['type'])) { |
||
| 29 | $start = Request::getInt('start', 0, 'GET'); //(int)( @$_GET['start'] ); |
||
| 30 | |||
| 31 | switch (Request::getString('type', '', 'GET')) {// @$_GET['type']) |
||
| 32 | // irmtfan rewrite forum sync |
||
| 33 | case 'forum': |
||
| 34 | $result = newbbSynchronization('forum'); |
||
| 35 | if ($result !== false) { |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 36 | redirect_header('admin_synchronization.php', 2, _AM_NEWBB_SYNC_TYPE_FORUM . '<br>' . _AM_NEWBB_DATABASEUPDATED); |
||
| 37 | } |
||
| 38 | break; |
||
| 39 | // irmtfan rewrite topic sync |
||
| 40 | case 'topic': |
||
| 41 | $limit = Request::getInt('limit', 1000, 'POST'); //empty($_GET['limit']) ? 1000 : (int)($_GET['limit']); |
||
| 42 | // /** @var TopicHandler $topicHandler */ |
||
| 43 | // $topicHandler = Helper::getInstance()->getHandler('Topic'); |
||
| 44 | $criteria = new \Criteria('approved', '1'); |
||
| 45 | if ($start >= ($count = $topicHandler->getCount($criteria))) { |
||
| 46 | break; |
||
| 47 | } |
||
| 48 | $criteria->setStart($start); |
||
| 49 | $criteria->setLimit($limit); |
||
| 50 | $topicObjs = $topicHandler->getAll($criteria); |
||
| 51 | foreach ($topicObjs as $tObj) { |
||
| 52 | $topicHandler->synchronization($tObj); |
||
| 53 | } |
||
| 54 | $result = newbbSynchronization('topic'); |
||
| 55 | redirect_header('admin_synchronization.php?type=topic&start=' . ($start + $limit) . "&limit={$limit}", 2, _AM_NEWBB_SYNCHING . " {$count}: {$start} - " . ($start + $limit)); |
||
| 56 | break; |
||
| 57 | // irmtfan rewrite post sync |
||
| 58 | case 'post': |
||
| 59 | $result = newbbSynchronization('post'); |
||
| 60 | if ($result !== false) { |
||
|
0 ignored issues
–
show
|
|||
| 61 | redirect_header('admin_synchronization.php', 2, _AM_NEWBB_SYNC_TYPE_POST . '<br>' . _AM_NEWBB_DATABASEUPDATED); |
||
| 62 | } |
||
| 63 | break; |
||
| 64 | // irmtfan - user is not in recon functions - only here |
||
| 65 | case 'user': |
||
| 66 | $limit = Request::getInt('limit', 1000, 'GET'); //empty($_GET['limit']) ? 1000 : (int)($_GET['limit']); |
||
| 67 | /** @var \XoopsUserHandler $userHandler */ |
||
| 68 | $userHandler = xoops_getHandler('user'); |
||
| 69 | if ($start >= ($count = $userHandler->getCount())) { |
||
| 70 | break; |
||
| 71 | } |
||
| 72 | $sql = ' SELECT uid' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('users'); |
||
| 73 | $result = $GLOBALS['xoopsDB']->query($sql, $limit, $start); |
||
| 74 | if ($GLOBALS['xoopsDB']->isResultSet($result)) { |
||
| 75 | while ([$uid] = $GLOBALS['xoopsDB']->fetchRow($result)) { |
||
| 76 | // irmtfan approved=1 AND |
||
| 77 | $sql = ' SELECT count(*)' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . " WHERE topic_poster = {$uid}"; |
||
| 78 | $ret = $GLOBALS['xoopsDB']->query($sql); |
||
| 79 | if (!$GLOBALS['xoopsDB']->isResultSet($ret)) { |
||
| 80 | \trigger_error("Query Failed! SQL: $sql- Error: " . $GLOBALS['xoopsDB']->error(), E_USER_ERROR); |
||
| 81 | } |
||
| 82 | [$topics] = $GLOBALS['xoopsDB']->fetchRow($ret); |
||
| 83 | // irmtfan approved=1 AND |
||
| 84 | $sql = ' SELECT count(*)' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_topics') . " WHERE topic_digest > 0 AND topic_poster = {$uid}"; |
||
| 85 | $ret = $GLOBALS['xoopsDB']->query($sql); |
||
| 86 | if (!$GLOBALS['xoopsDB']->isResultSet($ret)) { |
||
| 87 | \trigger_error("Query Failed! SQL: $sql- Error: " . $GLOBALS['xoopsDB']->error(), E_USER_ERROR); |
||
| 88 | } |
||
| 89 | [$digests] = $GLOBALS['xoopsDB']->fetchRow($ret); |
||
| 90 | // irmtfan approved=1 AND |
||
| 91 | $sql = ' SELECT count(*), MAX(post_time)' . ' FROM ' . $GLOBALS['xoopsDB']->prefix('newbb_posts') . " WHERE uid = {$uid}"; |
||
| 92 | $ret = $GLOBALS['xoopsDB']->query($sql); |
||
| 93 | if (!$GLOBALS['xoopsDB']->isResultSet($ret)) { |
||
| 94 | \trigger_error("Query Failed! SQL: $sql- Error: " . $GLOBALS['xoopsDB']->error(), E_USER_ERROR); |
||
| 95 | } |
||
| 96 | [$posts, $lastpost] = $GLOBALS['xoopsDB']->fetchRow($ret); |
||
| 97 | |||
| 98 | $result2 = $GLOBALS['xoopsDB']->queryF(' REPLACE INTO ' . $GLOBALS['xoopsDB']->prefix('newbb_user_stats') . " SET uid = '{$uid}', user_topics = '{$topics}', user_posts = '{$posts}', user_digests = '{$digests}', user_lastpost = '{$lastpost}'"); |
||
| 99 | } |
||
| 100 | } |
||
| 101 | |||
| 102 | redirect_header('admin_synchronization.php?type=user&start=' . ($start + $limit) . "&limit={$limit}", 2, _AM_NEWBB_SYNCHING . " {$count}: {$start} - " . ($start + $limit)); |
||
| 103 | break; |
||
| 104 | // irmtfan rewrite stats reset |
||
| 105 | case 'stats': |
||
| 106 | $result = newbbSynchronization('stats'); |
||
| 107 | break; |
||
| 108 | // START irmtfan add read sync |
||
| 109 | case 'read': |
||
| 110 | $result = newbbSynchronization(['readtopic', 'readforum']); |
||
| 111 | if ($result !== false) { |
||
|
0 ignored issues
–
show
|
|||
| 112 | redirect_header('admin_synchronization.php', 2, _AM_NEWBB_SYNC_TYPE_READ . '<br>' . _AM_NEWBB_DATABASEUPDATED); |
||
| 113 | } |
||
| 114 | exit(); |
||
| 115 | // END irmtfan add read sync |
||
| 116 | case 'misc': |
||
| 117 | default: |
||
| 118 | newbbSynchronization(); |
||
| 119 | break; |
||
| 120 | } |
||
| 121 | |||
| 122 | // <legend style="font-weight: bold; color: #900;">' . _AM_NEWBB_SYNCFORUM . '</legend>'; |
||
| 123 | |||
| 124 | $form .= '<form action="admin_synchronization.php" method="get">'; |
||
| 125 | $form .= '<div style="padding: 10px 2px;">'; |
||
| 126 | $form .= '<h2>' . _AM_NEWBB_SYNC_TYPE_FORUM . '</h2>'; |
||
| 127 | $form .= '<input type="hidden" name="type" value="forum">'; |
||
| 128 | // $form .= _AM_NEWBB_SYNC_ITEMS.'<input type="text" name="limit" value="20">'; // irmtfan remove |
||
| 129 | $form .= '<input type="submit" name="submit" value=' . _SUBMIT . ' >'; |
||
| 130 | $form .= '</div>'; |
||
| 131 | $form .= '</form>'; |
||
| 132 | |||
| 133 | $form .= '<form action="admin_synchronization.php" method="get">'; |
||
| 134 | $form .= '<div style="padding: 10px 2px;">'; |
||
| 135 | $form .= '<h2>' . _AM_NEWBB_SYNC_TYPE_TOPIC . '</h2>'; |
||
| 136 | $form .= '<input type="hidden" name="type" value="topic">'; |
||
| 137 | $form .= _AM_NEWBB_SYNC_ITEMS . '<input type="text" name="limit" value="1000">'; |
||
| 138 | $form .= '<input type="submit" name="submit" value=' . _SUBMIT . ' >'; |
||
| 139 | $form .= '</div>'; |
||
| 140 | $form .= '</form>'; |
||
| 141 | |||
| 142 | $form .= '<form action="admin_synchronization.php" method="get">'; |
||
| 143 | $form .= '<div style="padding: 10px 2px;">'; |
||
| 144 | $form .= '<h2>' . _AM_NEWBB_SYNC_TYPE_POST . '</h2>'; |
||
| 145 | $form .= '<input type="hidden" name="type" value="post">'; |
||
| 146 | // $form .= _AM_NEWBB_SYNC_ITEMS.'<input type="text" name="limit" value="1000">'; // irmtfan remove |
||
| 147 | $form .= '<input type="submit" name="submit" value=' . _SUBMIT . ' >'; |
||
| 148 | $form .= '</div>'; |
||
| 149 | $form .= '</form>'; |
||
| 150 | |||
| 151 | $form .= '<form action="admin_synchronization.php" method="get">'; |
||
| 152 | $form .= '<div style="padding: 10px 2px;">'; |
||
| 153 | $form .= '<h2>' . _AM_NEWBB_SYNC_TYPE_USER . '</h2>'; |
||
| 154 | $form .= '<input type="hidden" name="type" value="user">'; |
||
| 155 | $form .= _AM_NEWBB_SYNC_ITEMS . '<input type="text" name="limit" value="1000">'; |
||
| 156 | $form .= '<input type="submit" name="submit" value=' . _SUBMIT . ' >'; |
||
| 157 | $form .= '</div>'; |
||
| 158 | $form .= '</form>'; |
||
| 159 | // START irmtfan add read sync |
||
| 160 | $form .= '<form action="admin_synchronization.php" method="get">'; |
||
| 161 | $form .= '<div style="padding: 10px 2px;">'; |
||
| 162 | $form .= '<h2>' . _AM_NEWBB_SYNC_TYPE_READ . '</h2>'; |
||
| 163 | $form .= '<input type="hidden" name="type" value="read">'; |
||
| 164 | $form .= '<input type="submit" name="submit" value=' . _SUBMIT . ' >'; |
||
| 165 | $form .= '</div>'; |
||
| 166 | $form .= '</form>'; |
||
| 167 | // END irmtfan add read sync |
||
| 168 | |||
| 169 | $form .= '<form action="admin_synchronization.php" method="get">'; |
||
| 170 | $form .= '<div style="padding: 10px 2px;">'; |
||
| 171 | $form .= '<h2>' . _AM_NEWBB_SYNC_TYPE_STATS . '</h2>'; |
||
| 172 | $form .= '<input type="hidden" name="type" value="stats">'; |
||
| 173 | //$form .= _AM_NEWBB_SYNC_ITEMS.'<input type="text" name="limit" value="1000">'; |
||
| 174 | $form .= '<input type="submit" name="submit" value=' . _SUBMIT . ' >'; |
||
| 175 | $form .= '</div>'; |
||
| 176 | $form .= '</form>'; |
||
| 177 | |||
| 178 | $form .= '<form action="admin_synchronization.php" method="get">'; |
||
| 179 | $form .= '<div style="padding: 10px 2px;">'; |
||
| 180 | $form .= '<h2>' . _AM_NEWBB_SYNC_TYPE_MISC . '</h2>'; |
||
| 181 | $form .= '<input type="hidden" name="type" value="misc">'; |
||
| 182 | $form .= '<input type="submit" name="submit" value=' . _SUBMIT . ' >'; |
||
| 183 | $form .= '</div>'; |
||
| 184 | $form .= '</form>'; |
||
| 185 | echo "<table class='outer' style='border-collapse: separate; border-spacing: 1px; width: 100%;'>" . "<tr><td class='odd'>"; |
||
| 186 | echo $form; |
||
| 187 | echo '</td></tr></table>'; |
||
| 188 | echo '<fieldset>'; |
||
| 189 | echo '<legend> ' . _MI_NEWBB_ADMENU_SYNC . ' </legend>'; |
||
| 190 | echo _AM_NEWBB_HELP_SYNC_TAB; |
||
| 191 | echo '</fieldset>'; |
||
| 192 | require_once __DIR__ . '/admin_footer.php'; |
||
| 193 |