mambax7 /
cardealer
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 |
||||||
| 2 | |||||||
| 3 | /* |
||||||
| 4 | You may not change or alter any portion of this comment or credits |
||||||
| 5 | of supporting developers from this source code or any supporting source code |
||||||
| 6 | which is considered copyrighted (c) material of the original comment or credit authors. |
||||||
| 7 | |||||||
| 8 | This program is distributed in the hope that it will be useful, |
||||||
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||||
| 11 | */ |
||||||
| 12 | |||||||
| 13 | /** |
||||||
| 14 | * Module: cardealer |
||||||
| 15 | * |
||||||
| 16 | * @category Module |
||||||
| 17 | * @package cardealer |
||||||
| 18 | * @author XOOPS Development Team <[email protected]> - <https://xoops.org> |
||||||
| 19 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||||||
| 20 | * @license GPL 2.0 or later |
||||||
| 21 | * @link https://xoops.org/ |
||||||
| 22 | * @since 1.0.0 |
||||||
| 23 | */ |
||||||
| 24 | |||||||
| 25 | use Xmf\Module\Helper\Permission; |
||||||
| 26 | use Xmf\Request; |
||||||
| 27 | |||||||
| 28 | require __DIR__ . '/admin_header.php'; |
||||||
| 29 | xoops_cp_header(); |
||||||
| 30 | //It recovered the value of argument op in URL$ |
||||||
| 31 | $op = Request::getString('op', 'list'); |
||||||
| 32 | $order = Request::getString('order', 'desc'); |
||||||
| 33 | $sort = Request::getString('sort', ''); |
||||||
| 34 | |||||||
| 35 | $adminObject->displayNavigation(basename(__FILE__)); |
||||||
| 36 | /** @var Permission $permHelper */ |
||||||
| 37 | $permHelper = new \Xmf\Module\Helper\Permission(); |
||||||
| 38 | $uploadDir = XOOPS_UPLOAD_PATH . '/cardealer/images/'; |
||||||
| 39 | $uploadUrl = XOOPS_UPLOAD_URL . '/cardealer/images/'; |
||||||
| 40 | |||||||
| 41 | switch ($op) { |
||||||
| 42 | case 'new': |
||||||
| 43 | $adminObject->addItemButton(AM_CARDEALER_PART_LIST, 'part.php', 'list'); |
||||||
| 44 | $adminObject->displayButton('left'); |
||||||
| 45 | |||||||
| 46 | $partObject = $partHandler->create(); |
||||||
| 47 | $form = $partObject->getForm(); |
||||||
| 48 | $form->display(); |
||||||
| 49 | break; |
||||||
| 50 | |||||||
| 51 | case 'save': |
||||||
| 52 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||||
| 53 | redirect_header('part.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||||||
| 54 | } |
||||||
| 55 | if (0 != Request::getInt('partnum', 0)) { |
||||||
| 56 | $partObject = $partHandler->get(Request::getInt('partnum', 0)); |
||||||
| 57 | } else { |
||||||
| 58 | $partObject = $partHandler->create(); |
||||||
| 59 | } |
||||||
| 60 | // Form save fields |
||||||
| 61 | $partObject->setVar('price', Request::getVar('price', '')); |
||||||
| 62 | $partObject->setVar('stock', Request::getVar('stock', '')); |
||||||
| 63 | $partObject->setVar('title', Request::getVar('title', '')); |
||||||
| 64 | $partObject->setVar('description', Request::getText('description', '')); |
||||||
| 65 | |||||||
| 66 | require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
||||||
| 67 | $uploadDir = XOOPS_UPLOAD_PATH . '/cardealer/images/'; |
||||||
| 68 | $uploader = new \XoopsMediaUploader($uploadDir, xoops_getModuleOption('mimetypes', 'cardealer'), xoops_getModuleOption('maxsize', 'cardealer'), null, null); |
||||||
|
0 ignored issues
–
show
Deprecated Code
introduced
by
Loading history...
xoops_getModuleOption('maxsize', 'cardealer') of type boolean is incompatible with the type integer expected by parameter $maxFileSize of XoopsMediaUploader::__construct().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
xoops_getModuleOption('mimetypes', 'cardealer') of type boolean is incompatible with the type array expected by parameter $allowedMimeTypes of XoopsMediaUploader::__construct().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 69 | if ($uploader->fetchMedia(Request::getArray('xoops_upload_file', '', 'POST')[0])) { |
||||||
| 70 | |||||||
| 71 | $uploader->setPrefix('picture_'); |
||||||
| 72 | $uploader->fetchMedia(Request::getArray('xoops_upload_file', '', 'POST')[0]); |
||||||
| 73 | if (!$uploader->upload()) { |
||||||
| 74 | $errors = $uploader->getErrors(); |
||||||
| 75 | redirect_header('javascript:history.go(-1)', 3, $errors); |
||||||
| 76 | } else { |
||||||
| 77 | $partObject->setVar('picture', $uploader->getSavedFileName()); |
||||||
| 78 | } |
||||||
| 79 | } else { |
||||||
| 80 | $partObject->setVar('picture', Request::getVar('picture', '')); |
||||||
| 81 | } |
||||||
| 82 | |||||||
| 83 | if ($partHandler->insert($partObject)) { |
||||||
| 84 | redirect_header('part.php?op=list', 2, AM_CARDEALER_FORMOK); |
||||||
| 85 | } |
||||||
| 86 | |||||||
| 87 | echo $partObject->getHtmlErrors(); |
||||||
| 88 | $form = $partObject->getForm(); |
||||||
| 89 | $form->display(); |
||||||
| 90 | break; |
||||||
| 91 | |||||||
| 92 | case 'edit': |
||||||
| 93 | $adminObject->addItemButton(AM_CARDEALER_ADD_PART, 'part.php?op=new', 'add'); |
||||||
| 94 | $adminObject->addItemButton(AM_CARDEALER_PART_LIST, 'part.php', 'list'); |
||||||
| 95 | $adminObject->displayButton('left'); |
||||||
| 96 | $partObject = $partHandler->get(Request::getString('partnum', '')); |
||||||
| 97 | $form = $partObject->getForm(); |
||||||
| 98 | $form->display(); |
||||||
| 99 | break; |
||||||
| 100 | |||||||
| 101 | case 'delete': |
||||||
| 102 | $partObject = $partHandler->get(Request::getString('partnum', '')); |
||||||
| 103 | if (1 == Request::getInt('ok', 0)) { |
||||||
| 104 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||||
| 105 | redirect_header('part.php', 3, implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||||||
| 106 | } |
||||||
| 107 | if ($partHandler->delete($partObject)) { |
||||||
| 108 | redirect_header('part.php', 3, AM_CARDEALER_FORMDELOK); |
||||||
| 109 | } else { |
||||||
| 110 | echo $partObject->getHtmlErrors(); |
||||||
| 111 | } |
||||||
| 112 | } else { |
||||||
| 113 | xoops_confirm(['ok' => 1, |
||||||
| 114 | 'partnum' => Request::getString('partnum', ''), |
||||||
| 115 | 'op' => 'delete' |
||||||
| 116 | ], Request::getUrl('REQUEST_URI', '', 'SERVER'), sprintf(AM_CARDEALER_FORMSUREDEL, $partObject->getVar('title'))); |
||||||
| 117 | } |
||||||
| 118 | break; |
||||||
| 119 | |||||||
| 120 | case 'clone': |
||||||
| 121 | |||||||
| 122 | $id_field = Request::getString('partnum', ''); |
||||||
| 123 | |||||||
| 124 | if ($utility::cloneRecord('cardealer_part', 'partnum', $id_field)) { |
||||||
| 125 | redirect_header('part.php', 3, AM_CARDEALER_CLONED_OK); |
||||||
| 126 | } else { |
||||||
| 127 | redirect_header('part.php', 3, AM_CARDEALER_CLONED_FAILED); |
||||||
| 128 | } |
||||||
| 129 | |||||||
| 130 | break; |
||||||
| 131 | case 'list': |
||||||
| 132 | default: |
||||||
| 133 | $adminObject->addItemButton(AM_CARDEALER_ADD_PART, 'part.php?op=new', 'add'); |
||||||
| 134 | $adminObject->displayButton('left'); |
||||||
| 135 | $start = Request::getInt('start', 0); |
||||||
| 136 | $partPaginationLimit = $helper->getConfig('userpager'); |
||||||
| 137 | |||||||
| 138 | $criteria = new \CriteriaCompo(); |
||||||
| 139 | $criteria->setSort('partnum ASC, title'); |
||||||
| 140 | $criteria->setOrder('ASC'); |
||||||
| 141 | $criteria->setLimit($partPaginationLimit); |
||||||
| 142 | $criteria->setStart($start); |
||||||
| 143 | $partTempRows = $partHandler->getCount(); |
||||||
| 144 | $partTempArray = $partHandler->getAll($criteria); |
||||||
| 145 | |||||||
| 146 | // Display Page Navigation |
||||||
| 147 | if ($partTempRows > $partPaginationLimit) { |
||||||
| 148 | xoops_load('XoopsPageNav'); |
||||||
| 149 | |||||||
| 150 | $pagenav = new \XoopsPageNav($partTempRows, $partPaginationLimit, $start, 'start', 'op=list' . '&sort=' . $sort . '&order=' . $order . ''); |
||||||
| 151 | $GLOBALS['xoopsTpl']->assign('pagenav', null === $pagenav ? $pagenav->renderNav() : ''); |
||||||
| 152 | } |
||||||
| 153 | |||||||
| 154 | $GLOBALS['xoopsTpl']->assign('partRows', $partTempRows); |
||||||
| 155 | $partArray = []; |
||||||
| 156 | |||||||
| 157 | $criteria = new \CriteriaCompo(); |
||||||
| 158 | |||||||
| 159 | //$criteria->setOrder('DESC'); |
||||||
| 160 | $criteria->setSort($sort); |
||||||
| 161 | $criteria->setOrder($order); |
||||||
| 162 | $criteria->setLimit($partPaginationLimit); |
||||||
| 163 | $criteria->setStart($start); |
||||||
| 164 | |||||||
| 165 | $partCount = $partHandler->getCount($criteria); |
||||||
| 166 | $partTempArray = $partHandler->getAll($criteria); |
||||||
| 167 | |||||||
| 168 | // for ($i = 0; $i < $fieldsCount; ++$i) { |
||||||
| 169 | if ($partCount > 0) { |
||||||
| 170 | foreach (array_keys($partTempArray) as $i) { |
||||||
| 171 | |||||||
| 172 | |||||||
| 173 | // $field = explode(':', $fields[$i]); |
||||||
| 174 | |||||||
| 175 | $selectorpartnum = $utility::selectSorting(AM_CARDEALER_PART_PARTNUM, 'partnum'); |
||||||
| 176 | $GLOBALS['xoopsTpl']->assign('selectorpartnum', $selectorpartnum); |
||||||
| 177 | $partArray['partnum'] = $partTempArray[$i]->getVar('partnum'); |
||||||
| 178 | |||||||
| 179 | $selectorprice = $utility::selectSorting(AM_CARDEALER_PART_PRICE, 'price'); |
||||||
| 180 | $GLOBALS['xoopsTpl']->assign('selectorprice', $selectorprice); |
||||||
| 181 | $partArray['price'] = $partTempArray[$i]->getVar('price'); |
||||||
| 182 | |||||||
| 183 | $selectorstock = $utility::selectSorting(AM_CARDEALER_PART_STOCK, 'stock'); |
||||||
| 184 | $GLOBALS['xoopsTpl']->assign('selectorstock', $selectorstock); |
||||||
| 185 | $partArray['stock'] = $partTempArray[$i]->getVar('stock'); |
||||||
| 186 | |||||||
| 187 | $selectortitle = $utility::selectSorting(AM_CARDEALER_PART_TITLE, 'title'); |
||||||
| 188 | $GLOBALS['xoopsTpl']->assign('selectortitle', $selectortitle); |
||||||
| 189 | $partArray['title'] = $partTempArray[$i]->getVar('title'); |
||||||
| 190 | |||||||
| 191 | $selectordescription = $utility::selectSorting(AM_CARDEALER_PART_DESCRIPTION, 'description'); |
||||||
| 192 | $GLOBALS['xoopsTpl']->assign('selectordescription', $selectordescription); |
||||||
| 193 | $partArray['description'] = $partTempArray[$i]->getVar('description'); |
||||||
| 194 | |||||||
| 195 | $selectorpicture = $utility::selectSorting(AM_CARDEALER_PART_PICTURE, 'picture'); |
||||||
| 196 | $GLOBALS['xoopsTpl']->assign('selectorpicture', $selectorpicture); |
||||||
| 197 | $partArray['picture'] = "<img src='" . $uploadUrl . $partTempArray[$i]->getVar('picture') . "' name='" . 'name' . "' id=" . 'id' . " alt='' style='max-width:100px'>"; |
||||||
| 198 | $partArray['edit_delete'] |
||||||
| 199 | = "<a href='part.php?op=edit&partnum=" . $i . "'><img src=" . $pathIcon16 . "/edit.png alt='" . _EDIT . "' title='" . _EDIT . "'></a> |
||||||
| 200 | <a href='part.php?op=delete&partnum=" . $i . "'><img src=" . $pathIcon16 . "/delete.png alt='" . _DELETE . "' title='" . _DELETE . "'></a> |
||||||
| 201 | <a href='part.php?op=clone&partnum=" . $i . "'><img src=" . $pathIcon16 . "/editcopy.png alt='" . _CLONE . "' title='" . _CLONE . "'></a>"; |
||||||
| 202 | |||||||
| 203 | $GLOBALS['xoopsTpl']->append_by_ref('partArrays', $partArray); |
||||||
| 204 | unset($partArray); |
||||||
| 205 | } |
||||||
| 206 | unset($partTempArray); |
||||||
| 207 | // Display Navigation |
||||||
| 208 | if ($partCount > $partPaginationLimit) { |
||||||
| 209 | xoops_load('XoopsPageNav'); |
||||||
| 210 | $pagenav = new \XoopsPageNav($partCount, $partPaginationLimit, $start, 'start', 'op=list' . '&sort=' . $sort . '&order=' . $order . ''); |
||||||
| 211 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
||||||
| 212 | } |
||||||
| 213 | |||||||
| 214 | // echo "<td class='center width5'> |
||||||
| 215 | |||||||
| 216 | // <a href='part.php?op=edit&partnum=".$i."'><img src=".$pathIcon16."/edit.png alt='"._EDIT."' title='"._EDIT."'></a> |
||||||
| 217 | // <a href='part.php?op=delete&partnum=".$i."'><img src=".$pathIcon16."/delete.png alt='"._DELETE."' title='"._DELETE."'></a> |
||||||
| 218 | // </td>"; |
||||||
| 219 | |||||||
| 220 | // echo "</tr>"; |
||||||
| 221 | |||||||
| 222 | // } |
||||||
| 223 | |||||||
| 224 | // echo "</table><br><br>"; |
||||||
| 225 | |||||||
| 226 | // } else { |
||||||
| 227 | |||||||
| 228 | // echo "<table width='100%' cellspacing='1' class='outer'> |
||||||
| 229 | |||||||
| 230 | // <tr> |
||||||
| 231 | |||||||
| 232 | // <th class='center width5'>".AM_CARDEALER_FORM_ACTION."XXX</th> |
||||||
| 233 | // </tr><tr><td class='errorMsg' colspan='7'>There are noXXX part</td></tr>"; |
||||||
| 234 | // echo "</table><br><br>"; |
||||||
| 235 | |||||||
| 236 | //------------------------------------------- |
||||||
| 237 | |||||||
| 238 | echo $GLOBALS['xoopsTpl']->fetch(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . '/templates/admin/cardealer_admin_part.tpl'); |
||||||
| 239 | } |
||||||
| 240 | |||||||
| 241 | break; |
||||||
| 242 | } |
||||||
| 243 | require __DIR__ . '/admin_footer.php'; |
||||||
| 244 |