XoopsModules25x /
suico
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 | You may not change or alter any portion of this comment or credits |
||
| 4 | of supporting developers from this source code or any supporting source code |
||
| 5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 6 | |||
| 7 | This program is distributed in the hope that it will be useful, |
||
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 10 | */ |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @category Module |
||
| 14 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 15 | * @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
| 16 | * @author Marcello Brandão aka Suico, Mamba, LioMJ <https://xoops.org> |
||
| 17 | */ |
||
| 18 | |||
| 19 | use Xmf\Module\Helper\Permission; |
||
| 20 | use Xmf\Request; |
||
|
0 ignored issues
–
show
|
|||
| 21 | |||
| 22 | require_once __DIR__ . '/admin_header.php'; |
||
| 23 | xoops_cp_header(); |
||
| 24 | //It recovered the value of argument op in URL$ |
||
| 25 | $op = Request::getString('op', 'list'); |
||
| 26 | $order = Request::getString('order', 'desc'); |
||
| 27 | $sort = Request::getString('sort', ''); |
||
| 28 | $adminObject->displayNavigation(basename(__FILE__)); |
||
| 29 | $permHelper = new Permission(); |
||
| 30 | $uploadDir = XOOPS_UPLOAD_PATH . '/suico/images/'; |
||
| 31 | $uploadUrl = XOOPS_UPLOAD_URL . '/suico/images/'; |
||
| 32 | switch ($op) { |
||
| 33 | case 'new': |
||
| 34 | $adminObject->addItemButton(AM_SUICO_NOTES_LIST, 'notes.php', 'list'); |
||
| 35 | $adminObject->displayButton('left'); |
||
| 36 | $notesObject = $notesHandler->create(); |
||
| 37 | $form = $notesObject->getForm(); |
||
| 38 | $form->display(); |
||
| 39 | break; |
||
| 40 | case 'save': |
||
| 41 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 42 | redirect_header('notes.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 43 | } |
||
| 44 | if (0 !== Request::getInt('note_id', 0)) { |
||
| 45 | $notesObject = $notesHandler->get(Request::getInt('note_id', 0)); |
||
| 46 | } else { |
||
| 47 | $notesObject = $notesHandler->create(); |
||
| 48 | } |
||
| 49 | // Form save fields |
||
| 50 | $notesObject->setVar('note_text', Request::getText('note_text', '')); |
||
| 51 | $notesObject->setVar('note_from', Request::getVar('note_from', '')); |
||
| 52 | $notesObject->setVar('note_to', Request::getVar('note_to', '')); |
||
| 53 | $notesObject->setVar('private', (1 === Request::getInt('private', 0) ? '1' : '0')); |
||
| 54 | $dateTimeObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('date_created', '', 'POST')); |
||
| 55 | $notesObject->setVar('date_created', $dateTimeObj->getTimestamp()); |
||
| 56 | if ($notesHandler->insert($notesObject)) { |
||
| 57 | redirect_header('notes.php?op=list', 2, AM_SUICO_FORMOK); |
||
| 58 | } |
||
| 59 | echo $notesObject->getHtmlErrors(); |
||
| 60 | $form = $notesObject->getForm(); |
||
| 61 | $form->display(); |
||
| 62 | break; |
||
| 63 | case 'edit': |
||
| 64 | $adminObject->addItemButton(AM_SUICO_ADD_NOTES, 'notes.php?op=new', 'add'); |
||
| 65 | $adminObject->addItemButton(AM_SUICO_NOTES_LIST, 'notes.php', 'list'); |
||
| 66 | $adminObject->displayButton('left'); |
||
| 67 | $notesObject = $notesHandler->get(Request::getString('note_id', '')); |
||
| 68 | $form = $notesObject->getForm(); |
||
| 69 | $form->display(); |
||
| 70 | break; |
||
| 71 | case 'delete': |
||
| 72 | $notesObject = $notesHandler->get(Request::getString('note_id', '')); |
||
| 73 | if (1 === Request::getInt('ok', 0)) { |
||
| 74 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 75 | redirect_header('notes.php', 3, implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 76 | } |
||
| 77 | if ($notesHandler->delete($notesObject)) { |
||
| 78 | redirect_header('notes.php', 3, AM_SUICO_FORMDELOK); |
||
| 79 | } else { |
||
| 80 | echo $notesObject->getHtmlErrors(); |
||
| 81 | } |
||
| 82 | } else { |
||
| 83 | xoops_confirm( |
||
| 84 | [ |
||
| 85 | 'ok' => 1, |
||
| 86 | 'note_id' => Request::getString('note_id', ''), |
||
| 87 | 'op' => 'delete', |
||
| 88 | ], |
||
| 89 | Request::getUrl('REQUEST_URI', '', 'SERVER'), |
||
| 90 | sprintf( |
||
| 91 | AM_SUICO_FORMSUREDEL, |
||
| 92 | $notesObject->getVar('note_id') |
||
| 93 | ) |
||
| 94 | ); |
||
| 95 | } |
||
| 96 | break; |
||
| 97 | case 'clone': |
||
| 98 | $id_field = Request::getString('note_id', ''); |
||
| 99 | if ($utility::cloneRecord('suico_notes', 'note_id', $id_field)) { |
||
| 100 | redirect_header('notes.php', 3, AM_SUICO_CLONED_OK); |
||
| 101 | } else { |
||
| 102 | redirect_header('notes.php', 3, AM_SUICO_CLONED_FAILED); |
||
| 103 | } |
||
| 104 | break; |
||
| 105 | case 'list': |
||
| 106 | default: |
||
| 107 | $adminObject->addItemButton(AM_SUICO_ADD_NOTES, 'notes.php?op=new', 'add'); |
||
| 108 | $adminObject->displayButton('left'); |
||
| 109 | $start = Request::getInt('start', 0); |
||
| 110 | $notesPaginationLimit = $helper->getConfig('userpager'); |
||
| 111 | $criteria = new CriteriaCompo(); |
||
| 112 | $criteria->setSort('note_id ASC, note_id'); |
||
| 113 | $criteria->setOrder('ASC'); |
||
| 114 | $criteria->setLimit($notesPaginationLimit); |
||
| 115 | $criteria->setStart($start); |
||
| 116 | $notesTempRows = $notesHandler->getCount(); |
||
| 117 | $notesTempArray = $notesHandler->getAll($criteria); |
||
| 118 | /* |
||
| 119 | // |
||
| 120 | // |
||
| 121 | <th class='center width5'>".AM_SUICO_FORM_ACTION."</th> |
||
| 122 | // </tr>"; |
||
| 123 | // $class = "odd"; |
||
| 124 | */ |
||
| 125 | // Display Page Navigation |
||
| 126 | if ($notesTempRows > $notesPaginationLimit) { |
||
| 127 | xoops_load('XoopsPageNav'); |
||
| 128 | $pagenav = new \XoopsPageNav( |
||
| 129 | $notesTempRows, |
||
| 130 | $notesPaginationLimit, |
||
| 131 | $start, |
||
| 132 | 'start', |
||
| 133 | 'op=list' . '&sort=' . $sort . '&order=' . $order . '' |
||
| 134 | ); |
||
| 135 | $GLOBALS['xoopsTpl']->assign('pagenav', null === $pagenav ? $pagenav->renderNav() : ''); |
||
| 136 | } |
||
| 137 | $GLOBALS['xoopsTpl']->assign('notesRows', $notesTempRows); |
||
| 138 | $notesArray = []; |
||
| 139 | // $fields = explode('|', note_id:int:11::NOT NULL::primary:ID:0|note_text:text:0::NOT NULL:::Text:1|note_from:int:11::NOT NULL:::From:2|note_to:int:11::NOT NULL:::To:3|private:tinyint:1::NOT NULL:::Private:4|date_created:int:11::NOT NULL:CURRENT_TIMESTAMP::Date:5); |
||
| 140 | // $fieldsCount = count($fields); |
||
| 141 | $criteria = new CriteriaCompo(); |
||
| 142 | //$criteria->setOrder('DESC'); |
||
| 143 | $criteria->setSort($sort); |
||
| 144 | $criteria->setOrder($order); |
||
| 145 | $criteria->setLimit($notesPaginationLimit); |
||
| 146 | $criteria->setStart($start); |
||
| 147 | $notesCount = $notesHandler->getCount($criteria); |
||
| 148 | $notesTempArray = $notesHandler->getAll($criteria); |
||
| 149 | // for ($i = 0; $i < $fieldsCount; ++$i) { |
||
| 150 | if ($notesCount > 0) { |
||
| 151 | foreach (array_keys($notesTempArray) as $i) { |
||
| 152 | // $field = explode(':', $fields[$i]); |
||
| 153 | $GLOBALS['xoopsTpl']->assign( |
||
| 154 | 'selectornote_id', |
||
| 155 | AM_SUICO_NOTES_NOTE_ID |
||
| 156 | ); |
||
| 157 | $notesArray['note_id'] = $notesTempArray[$i]->getVar('note_id'); |
||
| 158 | $GLOBALS['xoopsTpl']->assign('selectornote_text', AM_SUICO_NOTES_NOTE_TEXT); |
||
| 159 | $notesArray['note_text'] = $notesTempArray[$i]->getVar('note_text'); |
||
| 160 | $notesArray['note_text'] = $utility::truncateHtml($notesArray['note_text'], $helper->getConfig('truncatelength')); |
||
| 161 | $GLOBALS['xoopsTpl']->assign('selectornote_from', AM_SUICO_NOTES_NOTE_FROM); |
||
| 162 | $notesArray['note_from'] = strip_tags( |
||
| 163 | XoopsUser::getUnameFromId($notesTempArray[$i]->getVar('note_from')) |
||
| 164 | ); |
||
| 165 | $GLOBALS['xoopsTpl']->assign('selectornote_to', AM_SUICO_NOTES_NOTE_TO); |
||
| 166 | $notesArray['note_to'] = strip_tags( |
||
| 167 | XoopsUser::getUnameFromId($notesTempArray[$i]->getVar('note_to')) |
||
| 168 | ); |
||
| 169 | $GLOBALS['xoopsTpl']->assign('selectorprivate', AM_SUICO_NOTES_PRIVATE); |
||
| 170 | $notesArray['private'] = $notesTempArray[$i]->getVar('private'); |
||
| 171 | $GLOBALS['xoopsTpl']->assign('selectordate', AM_SUICO_NOTES_DATE); |
||
| 172 | $notesArray['date_created'] = formatTimestamp($notesTempArray[$i]->getVar('date_created'), 's'); |
||
| 173 | $notesArray['edit_delete'] = "<a href='notes.php?op=edit¬e_id=" . $i . "'><img src=" . $pathIcon16 . "/edit.png alt='" . _EDIT . "' title='" . _EDIT . "'></a> |
||
| 174 | <a href='notes.php?op=delete¬e_id=" . $i . "'><img src=" . $pathIcon16 . "/delete.png alt='" . _DELETE . "' title='" . _DELETE . "'></a> |
||
| 175 | <a href='notes.php?op=clone¬e_id=" . $i . "'><img src=" . $pathIcon16 . "/editcopy.png alt='" . _CLONE . "' title='" . _CLONE . "'></a>"; |
||
| 176 | $GLOBALS['xoopsTpl']->append_by_ref('notesArrays', $notesArray); |
||
| 177 | unset($notesArray); |
||
| 178 | } |
||
| 179 | unset($notesTempArray); |
||
| 180 | // Display Navigation |
||
| 181 | if ($notesCount > $notesPaginationLimit) { |
||
| 182 | xoops_load('XoopsPageNav'); |
||
| 183 | $pagenav = new \XoopsPageNav( |
||
| 184 | $notesCount, |
||
| 185 | $notesPaginationLimit, |
||
| 186 | $start, |
||
| 187 | 'start', |
||
| 188 | 'op=list' . '&sort=' . $sort . '&order=' . $order . '' |
||
| 189 | ); |
||
| 190 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
||
| 191 | } |
||
| 192 | echo $GLOBALS['xoopsTpl']->fetch( |
||
| 193 | XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['xoopsModule']->getVar( |
||
| 194 | 'dirname' |
||
| 195 | ) . '/templates/admin/suico_admin_notes.tpl' |
||
| 196 | ); |
||
| 197 | } |
||
| 198 | break; |
||
| 199 | } |
||
| 200 | require_once __DIR__ . '/admin_footer.php'; |
||
| 201 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: