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/groups/'; |
||
| 31 | $uploadUrl = XOOPS_UPLOAD_URL . '/suico/groups/'; |
||
| 32 | switch ($op) { |
||
| 33 | case 'new': |
||
| 34 | $adminObject->addItemButton(AM_SUICO_GROUPS_LIST, 'groups.php', 'list'); |
||
| 35 | $adminObject->displayButton('left'); |
||
| 36 | $groupsObject = $groupsHandler->create(); |
||
| 37 | $form = $groupsObject->getForm(); |
||
| 38 | $form->display(); |
||
| 39 | break; |
||
| 40 | case 'save': |
||
| 41 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 42 | redirect_header('groups.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 43 | } |
||
| 44 | if (0 !== Request::getInt('group_id', 0)) { |
||
| 45 | $groupsObject = $groupsHandler->get(Request::getInt('group_id', 0)); |
||
| 46 | } else { |
||
| 47 | $groupsObject = $groupsHandler->create(); |
||
| 48 | } |
||
| 49 | // Form save fields |
||
| 50 | $groupsObject->setVar('owner_uid', Request::getVar('owner_uid', '')); |
||
| 51 | $groupsObject->setVar('group_title', Request::getVar('group_title', '')); |
||
| 52 | $groupsObject->setVar('group_desc', Request::getText('group_desc', '')); |
||
| 53 | require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
||
| 54 | $uploadDir = XOOPS_UPLOAD_PATH . '/suico/groups/'; |
||
| 55 | $uploader = new \XoopsMediaUploader( |
||
| 56 | $uploadDir, |
||
| 57 | $helper->getConfig('mimetypes'), |
||
| 58 | $helper->getConfig('maxsize'), |
||
| 59 | null, |
||
| 60 | null |
||
| 61 | ); |
||
| 62 | if ($uploader->fetchMedia(Request::getArray('xoops_upload_file', '', 'POST')[0])) { |
||
| 63 | //$extension = preg_replace( '/^.+\.([^.]+)$/sU' , '' , $_FILES['attachedfile']['name']); |
||
| 64 | //$imgName = str_replace(' ', '', $_POST['group_img']).'.'.$extension; |
||
| 65 | $uploader->setPrefix('group_img_'); |
||
| 66 | $uploader->fetchMedia(Request::getArray('xoops_upload_file', '', 'POST')[0]); |
||
| 67 | if ($uploader->upload()) { |
||
| 68 | $groupsObject->setVar('group_img', $uploader->getSavedFileName()); |
||
| 69 | } else { |
||
| 70 | $errors = $uploader->getErrors(); |
||
| 71 | redirect_header('javascript:history.go(-1)', 3, $errors); |
||
| 72 | } |
||
| 73 | } else { |
||
| 74 | $groupsObject->setVar('group_img', Request::getVar('group_img', '')); |
||
| 75 | } |
||
| 76 | $dateTimeObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('date_created', '', 'POST')); |
||
| 77 | $groupsObject->setVar('date_created', $dateTimeObj->getTimestamp()); |
||
| 78 | $dateTimeObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('date_updated', '', 'POST')); |
||
| 79 | $groupsObject->setVar('date_updated', $dateTimeObj->getTimestamp()); |
||
| 80 | if ($groupsHandler->insert($groupsObject)) { |
||
| 81 | redirect_header('groups.php?op=list', 2, AM_SUICO_FORMOK); |
||
| 82 | } |
||
| 83 | echo $groupsObject->getHtmlErrors(); |
||
| 84 | $form = $groupsObject->getForm(); |
||
| 85 | $form->display(); |
||
| 86 | break; |
||
| 87 | case 'edit': |
||
| 88 | $adminObject->addItemButton(AM_SUICO_ADD_GROUPS, 'groups.php?op=new', 'add'); |
||
| 89 | $adminObject->addItemButton(AM_SUICO_GROUPS_LIST, 'groups.php', 'list'); |
||
| 90 | $adminObject->displayButton('left'); |
||
| 91 | $groupsObject = $groupsHandler->get(Request::getString('group_id', '')); |
||
| 92 | $form = $groupsObject->getForm(); |
||
| 93 | $form->display(); |
||
| 94 | break; |
||
| 95 | case 'delete': |
||
| 96 | $groupsObject = $groupsHandler->get(Request::getString('group_id', '')); |
||
| 97 | if (1 === Request::getInt('ok', 0)) { |
||
| 98 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 99 | redirect_header('groups.php', 3, implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||
| 100 | } |
||
| 101 | if ($groupsHandler->delete($groupsObject)) { |
||
| 102 | redirect_header('groups.php', 3, AM_SUICO_FORMDELOK); |
||
| 103 | } else { |
||
| 104 | echo $groupsObject->getHtmlErrors(); |
||
| 105 | } |
||
| 106 | } else { |
||
| 107 | xoops_confirm( |
||
| 108 | [ |
||
| 109 | 'ok' => 1, |
||
| 110 | 'group_id' => Request::getString('group_id', ''), |
||
| 111 | 'op' => 'delete', |
||
| 112 | ], |
||
| 113 | Request::getUrl('REQUEST_URI', '', 'SERVER'), |
||
| 114 | sprintf( |
||
| 115 | AM_SUICO_FORMSUREDEL, |
||
| 116 | $groupsObject->getVar('group_title') |
||
| 117 | ) |
||
| 118 | ); |
||
| 119 | } |
||
| 120 | break; |
||
| 121 | case 'clone': |
||
| 122 | $id_field = Request::getString('group_id', ''); |
||
| 123 | if ($utility::cloneRecord('suico_groups', 'group_id', $id_field)) { |
||
| 124 | redirect_header('groups.php', 3, AM_SUICO_CLONED_OK); |
||
| 125 | } else { |
||
| 126 | redirect_header('groups.php', 3, AM_SUICO_CLONED_FAILED); |
||
| 127 | } |
||
| 128 | break; |
||
| 129 | case 'list': |
||
| 130 | default: |
||
| 131 | $adminObject->addItemButton(AM_SUICO_ADD_GROUPS, 'groups.php?op=new', 'add'); |
||
| 132 | $adminObject->displayButton('left'); |
||
| 133 | $start = Request::getInt('start', 0); |
||
| 134 | $groupsPaginationLimit = $helper->getConfig('userpager'); |
||
| 135 | $criteria = new CriteriaCompo(); |
||
| 136 | $criteria->setSort('group_id ASC, group_title'); |
||
| 137 | $criteria->setOrder('ASC'); |
||
| 138 | $criteria->setLimit($groupsPaginationLimit); |
||
| 139 | $criteria->setStart($start); |
||
| 140 | $groupsTempRows = $groupsHandler->getCount(); |
||
| 141 | $groupsTempArray = $groupsHandler->getAll($criteria); |
||
| 142 | /* |
||
| 143 | // |
||
| 144 | // |
||
| 145 | <th class='center width5'>".AM_SUICO_FORM_ACTION."</th> |
||
| 146 | // </tr>"; |
||
| 147 | // $class = "odd"; |
||
| 148 | */ |
||
| 149 | // Display Page Navigation |
||
| 150 | if ($groupsTempRows > $groupsPaginationLimit) { |
||
| 151 | xoops_load('XoopsPageNav'); |
||
| 152 | $pagenav = new \XoopsPageNav( |
||
| 153 | $groupsTempRows, |
||
| 154 | $groupsPaginationLimit, |
||
| 155 | $start, |
||
| 156 | 'start', |
||
| 157 | 'op=list' . '&sort=' . $sort . '&order=' . $order . '' |
||
| 158 | ); |
||
| 159 | $GLOBALS['xoopsTpl']->assign('pagenav', null === $pagenav ? $pagenav->renderNav() : ''); |
||
| 160 | } |
||
| 161 | $GLOBALS['xoopsTpl']->assign('groupsRows', $groupsTempRows); |
||
| 162 | $groupsArray = []; |
||
| 163 | // $fields = explode('|', group_id:int:11::NOT NULL::primary:group_id|owner_uid:int:11::NOT NULL:::owner_uid|group_title:varchar:255::NOT NULL:::group_title|group_desc:tinytext:0::NOT NULL:::group_desc|group_img:varchar:255::NOT NULL:::group_img); |
||
| 164 | // $fieldsCount = count($fields); |
||
| 165 | $criteria = new CriteriaCompo(); |
||
| 166 | //$criteria->setOrder('DESC'); |
||
| 167 | $criteria->setSort($sort); |
||
| 168 | $criteria->setOrder($order); |
||
| 169 | $criteria->setLimit($groupsPaginationLimit); |
||
| 170 | $criteria->setStart($start); |
||
| 171 | $groupsCount = $groupsHandler->getCount($criteria); |
||
| 172 | $groupsTempArray = $groupsHandler->getAll($criteria); |
||
| 173 | // for ($i = 0; $i < $fieldsCount; ++$i) { |
||
| 174 | if ($groupsCount > 0) { |
||
| 175 | foreach (array_keys($groupsTempArray) as $i) { |
||
| 176 | // $field = explode(':', $fields[$i]); |
||
| 177 | $GLOBALS['xoopsTpl']->assign( |
||
| 178 | 'selectorgroup_id', |
||
| 179 | AM_SUICO_GROUPS_GROUP_ID |
||
| 180 | ); |
||
| 181 | $groupsArray['group_id'] = $groupsTempArray[$i]->getVar('group_id'); |
||
| 182 | $GLOBALS['xoopsTpl']->assign('selectorowner_uid', AM_SUICO_GROUPS_OWNER_UID); |
||
| 183 | $groupsArray['owner_uid'] = strip_tags( |
||
| 184 | XoopsUser::getUnameFromId($groupsTempArray[$i]->getVar('owner_uid')) |
||
| 185 | ); |
||
| 186 | $GLOBALS['xoopsTpl']->assign('selectorgroup_title', AM_SUICO_GROUPS_GROUP_TITLE); |
||
| 187 | $groupsArray['group_title'] = $groupsTempArray[$i]->getVar('group_title'); |
||
| 188 | $GLOBALS['xoopsTpl']->assign('selectorgroup_desc', AM_SUICO_GROUPS_GROUP_DESC); |
||
| 189 | $groupsArray['group_desc'] = $groupsTempArray[$i]->getVar('group_desc'); |
||
| 190 | $GLOBALS['xoopsTpl']->assign('selectorgroup_img', AM_SUICO_GROUPS_GROUP_IMG); |
||
| 191 | $groupsArray['group_img'] = "<img src='" . $uploadUrl . $groupsTempArray[$i]->getVar( |
||
| 192 | 'group_img' |
||
| 193 | ) . "' name='" . 'name' . "' id=" . 'id' . " alt='' style='max-width:100px'>"; |
||
| 194 | $GLOBALS['xoopsTpl']->assign('selectordate_created', AM_SUICO_GROUPS_DATE_CREATED); |
||
| 195 | $groupsArray['date_created'] = formatTimestamp($groupsTempArray[$i]->getVar('date_created'), 's'); |
||
| 196 | $GLOBALS['xoopsTpl']->assign('selectordate_updated', AM_SUICO_GROUPS_DATE_UPDATED); |
||
| 197 | $groupsArray['date_updated'] = formatTimestamp($groupsTempArray[$i]->getVar('date_updated'), 's'); |
||
| 198 | $groupsArray['edit_delete'] = "<a href='groups.php?op=edit&group_id=" . $i . "'><img src=" . $pathIcon16 . "/edit.png alt='" . _EDIT . "' title='" . _EDIT . "'></a> |
||
| 199 | <a href='groups.php?op=delete&group_id=" . $i . "'><img src=" . $pathIcon16 . "/delete.png alt='" . _DELETE . "' title='" . _DELETE . "'></a> |
||
| 200 | <a href='groups.php?op=clone&group_id=" . $i . "'><img src=" . $pathIcon16 . "/editcopy.png alt='" . _CLONE . "' title='" . _CLONE . "'></a>"; |
||
| 201 | $GLOBALS['xoopsTpl']->append_by_ref('groupsArrays', $groupsArray); |
||
| 202 | unset($groupsArray); |
||
| 203 | } |
||
| 204 | unset($groupsTempArray); |
||
| 205 | // Display Navigation |
||
| 206 | if ($groupsCount > $groupsPaginationLimit) { |
||
| 207 | xoops_load('XoopsPageNav'); |
||
| 208 | $pagenav = new \XoopsPageNav( |
||
| 209 | $groupsCount, |
||
| 210 | $groupsPaginationLimit, |
||
| 211 | $start, |
||
| 212 | 'start', |
||
| 213 | 'op=list' . '&sort=' . $sort . '&order=' . $order . '' |
||
| 214 | ); |
||
| 215 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
||
| 216 | } |
||
| 217 | echo $GLOBALS['xoopsTpl']->fetch( |
||
| 218 | XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['xoopsModule']->getVar( |
||
| 219 | 'dirname' |
||
| 220 | ) . '/templates/admin/suico_admin_groups.tpl' |
||
| 221 | ); |
||
| 222 | } |
||
| 223 | break; |
||
| 224 | } |
||
| 225 | require_once __DIR__ . '/admin_footer.php'; |
||
| 226 |
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: