XoopsModules25x /
tdmdownloads
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 | declare(strict_types=1); |
||||
| 4 | |||||
| 5 | use Xmf\Module\Admin; |
||||
| 6 | use XoopsModules\Tag\Helper as TagHelper; |
||||
| 7 | use XoopsModules\Tag\LinkHandler; |
||||
| 8 | use XoopsModules\Tdmdownloads\{ |
||||
| 9 | Helper, |
||||
| 10 | Tree |
||||
| 11 | }; |
||||
| 12 | |||||
| 13 | /** |
||||
| 14 | * TDMDownload |
||||
| 15 | * |
||||
| 16 | * You may not change or alter any portion of this comment or credits |
||||
| 17 | * of supporting developers from this source code or any supporting source code |
||||
| 18 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||||
| 19 | * This program is distributed in the hope that it will be useful, |
||||
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
| 22 | * |
||||
| 23 | * @copyright Gregory Mage (Aka Mage) |
||||
| 24 | * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||||
| 25 | * @author Gregory Mage (Aka Mage) |
||||
| 26 | */ |
||||
| 27 | require __DIR__ . '/admin_header.php'; |
||||
| 28 | // Template |
||||
| 29 | $templateMain = 'tdmdownloads_admin_category.tpl'; |
||||
| 30 | /** @var \Helper $helper */ |
||||
| 31 | $helper = Helper::getInstance(); |
||||
| 32 | //On recupere la valeur de l'argument op dans l'URL$ |
||||
| 33 | $op = \Xmf\Request::getCmd('op', 'list'); |
||||
| 34 | //Les valeurs de op qui vont permettre d'aller dans les differentes parties de la page |
||||
| 35 | switch ($op) { |
||||
| 36 | // Vue liste |
||||
| 37 | case 'list': |
||||
| 38 | //Affichage de la partie haute de l'administration de Xoops |
||||
| 39 | xoops_cp_header(); |
||||
| 40 | $moduleDirName = basename(dirname(__DIR__)); |
||||
| 41 | $adminObject = Admin::getInstance(); |
||||
| 42 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); |
||||
| 43 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_CAT_NEW, 'category.php?op=new_cat', 'add'); |
||||
| 44 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||||
| 45 | $GLOBALS['xoopsTpl']->assign('tdmdownloads_url', TDMDOWNLOADS_URL); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 46 | $criteria = new \CriteriaCompo(); |
||||
| 47 | $criteria->setSort('cat_weight ASC, cat_title'); |
||||
| 48 | $criteria->setOrder('ASC'); |
||||
| 49 | $downloads_cat = $categoryHandler->getAll($criteria); |
||||
| 50 | //Affichage du tableau |
||||
| 51 | // if (count($downloads_cat) > 0) { |
||||
| 52 | if (count($downloads_cat) > 0) { |
||||
| 53 | $GLOBALS['xoopsTpl']->assign('categories_count', count($downloads_cat)); |
||||
| 54 | $mytree = new Tree($downloads_cat, 'cat_cid', 'cat_pid'); |
||||
| 55 | $category_ArrayTree = $mytree->makeArrayTree('cat_title', '<img src="../assets/images/deco/arrow.gif">'); |
||||
| 56 | $category = []; |
||||
| 57 | foreach (array_keys($category_ArrayTree) as $i) { |
||||
| 58 | /** @var \XoopsModules\Tdmdownloads\Category[] $downloads_cat */ |
||||
| 59 | $category = [ |
||||
| 60 | 'cid' => $i, |
||||
| 61 | 'title' => $downloads_cat[$i]->getVar('cat_title'), |
||||
| 62 | 'category' => $category_ArrayTree[$i], |
||||
| 63 | 'cat_imgurl' => $uploadurl . $downloads_cat[$i]->getVar('cat_imgurl'), |
||||
| 64 | 'cat_description_main' => $downloads_cat[$i]->getVar('cat_description_main'), |
||||
| 65 | 'cat_weight' => $downloads_cat[$i]->getVar('cat_weight'), |
||||
| 66 | ]; |
||||
| 67 | $GLOBALS['xoopsTpl']->append('categories_list', $category); |
||||
| 68 | unset($category); |
||||
| 69 | } |
||||
| 70 | } |
||||
| 71 | break; |
||||
| 72 | // vue création |
||||
| 73 | case 'new_cat': |
||||
| 74 | //Affichage de la partie haute de l'administration de Xoops |
||||
| 75 | xoops_cp_header(); |
||||
| 76 | $adminObject = Admin::getInstance(); |
||||
| 77 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); |
||||
| 78 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_CAT_LIST, 'category.php?op=list', 'list'); |
||||
| 79 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||||
| 80 | //Affichage du formulaire de création des catégories |
||||
| 81 | /** @var \XoopsModules\Tdmdownloads\Category $obj */ |
||||
| 82 | $obj = $categoryHandler->create(); |
||||
| 83 | $form = $obj->getForm(); |
||||
| 84 | $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); |
||||
| 85 | break; |
||||
| 86 | // Pour éditer une catégorie |
||||
| 87 | case 'edit_cat': |
||||
| 88 | //Affichage de la partie haute de l'administration de Xoops |
||||
| 89 | xoops_cp_header(); |
||||
| 90 | $adminObject = Admin::getInstance(); |
||||
| 91 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); |
||||
| 92 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_CAT_LIST, 'category.php?op=list', 'list'); |
||||
| 93 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_CAT_NEW, 'category.php?op=new_cat', 'add'); |
||||
| 94 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||||
| 95 | //Affichage du formulaire de création des catégories |
||||
| 96 | $categoryId = \Xmf\Request::getInt('downloadscat_cid', 0, 'GET'); |
||||
| 97 | /** @var \XoopsModules\Tdmdownloads\Category $obj */ |
||||
| 98 | $obj = $categoryHandler->get($categoryId); |
||||
| 99 | $form = $obj->getForm(); |
||||
| 100 | $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); |
||||
| 101 | break; |
||||
| 102 | // Pour supprimer une catégorie |
||||
| 103 | case 'del_cat': |
||||
| 104 | global $xoopsModule; |
||||
| 105 | $categoryId = \Xmf\Request::getInt('downloadscat_cid', 0, 'GET'); |
||||
| 106 | /** @var \XoopsModules\Tdmdownloads\Category $obj */ |
||||
| 107 | $obj = $categoryHandler->get($categoryId); |
||||
| 108 | if (\Xmf\Request::hasVar('ok', 'REQUEST') && 1 == \Xmf\Request::getInt('ok', 0, 'REQUEST')) { |
||||
| 109 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||
| 110 | redirect_header('category.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||||
| 111 | } |
||||
| 112 | // supression des téléchargements de la catégorie |
||||
| 113 | $criteria = new \CriteriaCompo(); |
||||
| 114 | $criteria->add(new \Criteria('cid', $categoryId)); |
||||
| 115 | $downloadsArray = $downloadsHandler->getAll($criteria); |
||||
| 116 | foreach (array_keys($downloadsArray) as $i) { |
||||
| 117 | /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloadsArray */ |
||||
| 118 | // supression des votes |
||||
| 119 | $criteria_1 = new \CriteriaCompo(); |
||||
| 120 | $criteria_1->add(new \Criteria('lid', $downloadsArray[$i]->getVar('lid'))); |
||||
|
0 ignored issues
–
show
It seems like
$downloadsArray[$i]->getVar('lid') can also be of type array and array; however, parameter $value of Criteria::__construct() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 121 | $votedata = $ratingHandler->getAll($criteria_1); |
||||
| 122 | foreach (array_keys($votedata) as $j) { |
||||
| 123 | /** @var \XoopsModules\Tdmdownloads\Rating[] $votedata */ |
||||
| 124 | $objvotedata = $ratingHandler->get($votedata[$j]->getVar('ratingid')); |
||||
| 125 | $ratingHandler->delete($objvotedata) || $objvotedata->getHtmlErrors(); |
||||
| 126 | } |
||||
| 127 | // supression des rapports de fichier brisé |
||||
| 128 | $criteria_2 = new \CriteriaCompo(); |
||||
| 129 | $criteria_2->add(new \Criteria('lid', $downloadsArray[$i]->getVar('lid'))); |
||||
| 130 | $downloads_broken = $brokenHandler->getAll($criteria_2); |
||||
| 131 | foreach (array_keys($downloads_broken) as $j) { |
||||
| 132 | /** @var \XoopsModules\Tdmdownloads\Broken[] $downloads_broken */ |
||||
| 133 | $objbroken = $brokenHandler->get($downloads_broken[$j]->getVar('reportid')); |
||||
| 134 | $brokenHandler->delete($objbroken) || $objbroken->getHtmlErrors(); |
||||
| 135 | } |
||||
| 136 | // supression des data des champs sup. |
||||
| 137 | $criteria_3 = new \CriteriaCompo(); |
||||
| 138 | $criteria_3->add(new \Criteria('lid', $downloadsArray[$i]->getVar('lid'))); |
||||
| 139 | $downloads_fielddata = $fielddataHandler->getAll($criteria_3); |
||||
| 140 | if ($fielddataHandler->getCount($criteria_3) > 0) { |
||||
| 141 | foreach (array_keys($downloads_fielddata) as $j) { |
||||
| 142 | /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloads_fielddata */ |
||||
| 143 | $objfielddata = $fielddataHandler->get($downloads_fielddata[$j]->getVar('iddata')); |
||||
| 144 | $fielddataHandler->delete($objfielddata) || $objvfielddata->getHtmlErrors(); |
||||
| 145 | } |
||||
| 146 | } |
||||
| 147 | // supression des commentaires |
||||
| 148 | if ($downloadsArray[$i]->getVar('comments') > 0) { |
||||
| 149 | xoops_comment_delete($xoopsModule->getVar('mid'), $downloadsArray[$i]->getVar('lid')); |
||||
| 150 | } |
||||
| 151 | //supression des tags |
||||
| 152 | if (1 == $helper->getConfig('usetag') && class_exists(LinkHandler::class)) { |
||||
| 153 | /** @var \XoopsModules\Tag\LinkHandler $linkHandler */ |
||||
| 154 | $linkHandler = TagHelper::getInstance()->getHandler('Link'); |
||||
| 155 | $criteria = new \CriteriaCompo(); |
||||
| 156 | $criteria->add(new \Criteria('tag_itemid', $downloadsArray[$i]->getVar('lid'))); |
||||
| 157 | $downloadsTags = $linkHandler->getAll($criteria); |
||||
| 158 | if (count($downloadsTags) > 0) { |
||||
| 159 | foreach (array_keys($downloadsTags) as $j) { |
||||
| 160 | /** @var \XoopsModules\Tag\Link[] $downloadsTags */ |
||||
| 161 | $objtags = $linkHandler->get($downloadsTags[$j]->getVar('tl_id')); |
||||
| 162 | $linkHandler->delete($objtags) || $objtags->getHtmlErrors(); |
||||
|
0 ignored issues
–
show
It seems like
$objtags can also be of type null; however, parameter $object of XoopsPersistableObjectHandler::delete() does only seem to accept XoopsObject, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 163 | } |
||||
| 164 | } |
||||
| 165 | } |
||||
| 166 | // supression du fichier |
||||
| 167 | // pour extraire le nom du fichier |
||||
| 168 | $urlfile = substr_replace($downloadsArray[$i]->getVar('url'), '', 0, mb_strlen($uploadurl_downloads)); |
||||
|
0 ignored issues
–
show
It seems like
$downloadsArray[$i]->getVar('url') can also be of type boolean and null; however, parameter $string of substr_replace() does only seem to accept array|string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 169 | // chemin du fichier |
||||
| 170 | $urlfile = $uploaddir_downloads . $urlfile; |
||||
|
0 ignored issues
–
show
Are you sure
$urlfile of type array|string can be used in concatenation?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 171 | if (is_file($urlfile)) { |
||||
| 172 | chmod($urlfile, 0777); |
||||
| 173 | unlink($urlfile); |
||||
| 174 | } |
||||
| 175 | // supression du téléchargment |
||||
| 176 | $objdownloads = $downloadsHandler->get($downloadsArray[$i]->getVar('lid')); |
||||
| 177 | $downloadsHandler->delete($objdownloads) || $objdownloads->getHtmlErrors(); |
||||
| 178 | } |
||||
| 179 | // supression des sous catégories avec leurs téléchargements |
||||
| 180 | $downloadscatArray = $categoryHandler->getAll(); |
||||
| 181 | $mytree = new Tree($downloadscatArray, 'cat_cid', 'cat_pid'); |
||||
| 182 | $downloads_childcat = $mytree->getAllChild($categoryId); |
||||
| 183 | foreach (array_keys($downloads_childcat) as $i) { |
||||
| 184 | /** @var \XoopsModules\Tdmdownloads\Category[] $downloads_childcat */ |
||||
| 185 | // supression de la catégorie |
||||
| 186 | $objchild = $categoryHandler->get($downloads_childcat[$i]->getVar('cat_cid')); |
||||
| 187 | $categoryHandler->delete($objchild) || $objchild->getHtmlErrors(); |
||||
| 188 | // supression des téléchargements associés |
||||
| 189 | $criteria = new \CriteriaCompo(); |
||||
| 190 | $criteria->add(new \Criteria('cid', $downloads_childcat[$i]->getVar('cat_cid'))); |
||||
| 191 | $downloadsArray = $downloadsHandler->getAll($criteria); |
||||
| 192 | foreach (array_keys($downloadsArray) as $j) { |
||||
| 193 | // supression des votes |
||||
| 194 | $criteria = new \CriteriaCompo(); |
||||
| 195 | $criteria->add(new \Criteria('lid', $downloadsArray[$j]->getVar('lid'))); |
||||
| 196 | $votedata = $ratingHandler->getAll($criteria); |
||||
| 197 | foreach (array_keys($votedata) as $k) { |
||||
| 198 | $objvotedata = $ratingHandler->get($votedata[$k]->getVar('ratingid')); |
||||
| 199 | $ratingHandler->delete($objvotedata) || $objvotedata->getHtmlErrors(); |
||||
| 200 | } |
||||
| 201 | // supression des rapports de fichier brisé |
||||
| 202 | $criteria = new \CriteriaCompo(); |
||||
| 203 | $criteria->add(new \Criteria('lid', $downloadsArray[$j]->getVar('lid'))); |
||||
| 204 | $downloads_broken = $brokenHandler->getAll($criteria); |
||||
| 205 | foreach (array_keys($downloads_broken) as $k) { |
||||
| 206 | $objbroken = $brokenHandler->get($downloads_broken[$k]->getVar('reportid')); |
||||
| 207 | $brokenHandler->delete($objbroken) || $objbroken->getHtmlErrors(); |
||||
| 208 | } |
||||
| 209 | // supression des data des champs sup. |
||||
| 210 | $criteria = new \CriteriaCompo(); |
||||
| 211 | $criteria->add(new \Criteria('lid', $downloadsArray[$j]->getVar('lid'))); |
||||
| 212 | $downloads_fielddata = $fielddataHandler->getAll($criteria); |
||||
| 213 | foreach (array_keys($downloads_fielddata) as $k) { |
||||
| 214 | $objfielddata = $fielddataHandler->get($downloads_fielddata[$k]->getVar('iddata')); |
||||
| 215 | $fielddataHandler->delete($objfielddata) || $objvfielddata->getHtmlErrors(); |
||||
| 216 | } |
||||
| 217 | // supression des commentaires |
||||
| 218 | if ($downloadsArray[$j]->getVar('comments') > 0) { |
||||
| 219 | xoops_comment_delete($xoopsModule->getVar('mid'), $downloadsArray[$j]->getVar('lid')); |
||||
| 220 | } |
||||
| 221 | //supression des tags |
||||
| 222 | if (1 == $helper->getConfig('usetag') && class_exists(LinkHandler::class)) { |
||||
| 223 | /** @var \XoopsModules\Tag\LinkHandler $linkHandler */ |
||||
| 224 | $linkHandler = TagHelper::getInstance()->getHandler('Link'); |
||||
| 225 | $criteria = new \CriteriaCompo(); |
||||
| 226 | $criteria->add(new \Criteria('tag_itemid', $downloadsArray[$j]->getVar('lid'))); |
||||
| 227 | $downloadsTags = $linkHandler->getAll($criteria); |
||||
| 228 | if (count($downloadsTags) > 0) { |
||||
| 229 | foreach (array_keys($downloadsTags) as $k) { |
||||
| 230 | $objtags = $linkHandler->get($downloadsTags[$k]->getVar('tl_id')); |
||||
| 231 | $linkHandler->delete($objtags) || $objtags->getHtmlErrors(); |
||||
| 232 | } |
||||
| 233 | } |
||||
| 234 | } |
||||
| 235 | // supression du fichier |
||||
| 236 | $urlfile = substr_replace($downloadsArray[$j]->getVar('url'), '', 0, mb_strlen($uploadurl_downloads)); // pour extraire le nom du fichier |
||||
| 237 | $urlfile = $uploaddir_downloads . $urlfile; // chemin du fichier |
||||
| 238 | if (is_file($urlfile)) { |
||||
| 239 | chmod($urlfile, 0777); |
||||
| 240 | unlink($urlfile); |
||||
| 241 | } |
||||
| 242 | // supression du téléchargment |
||||
| 243 | $objdownloads = $downloadsHandler->get($downloadsArray[$j]->getVar('lid')); |
||||
| 244 | $downloadsHandler->delete($objdownloads) || $objdownloads->getHtmlErrors(); |
||||
| 245 | } |
||||
| 246 | } |
||||
| 247 | if ($categoryHandler->delete($obj)) { |
||||
| 248 | redirect_header('category.php', 1, _AM_TDMDOWNLOADS_REDIRECT_DELOK); |
||||
| 249 | } else { |
||||
| 250 | $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); |
||||
| 251 | } |
||||
| 252 | } else { |
||||
| 253 | $message = ''; |
||||
| 254 | $criteria = new \CriteriaCompo(); |
||||
| 255 | $criteria->add(new \Criteria('cid', $categoryId)); |
||||
| 256 | $downloadsArray = $downloadsHandler->getAll($criteria); |
||||
| 257 | if (count($downloadsArray) > 0) { |
||||
| 258 | $message .= _AM_TDMDOWNLOADS_DELDOWNLOADS . '<br>'; |
||||
| 259 | foreach (array_keys($downloadsArray) as $i) { |
||||
| 260 | /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloadsArray */ |
||||
| 261 | $message .= '<span style="color : #ff0000">' . $downloadsArray[$i]->getVar('title') . '</span><br>'; |
||||
| 262 | } |
||||
| 263 | } |
||||
| 264 | $downloadscatArray = $categoryHandler->getAll(); |
||||
| 265 | $mytree = new Tree($downloadscatArray, 'cat_cid', 'cat_pid'); |
||||
| 266 | $downloads_childcat = $mytree->getAllChild($categoryId); |
||||
| 267 | if (count($downloads_childcat) > 0) { |
||||
| 268 | $message .= _AM_TDMDOWNLOADS_DELSOUSCAT . ' <br><br>'; |
||||
| 269 | foreach (array_keys($downloads_childcat) as $i) { |
||||
| 270 | /** @var \XoopsModules\Tdmdownloads\Category[] $downloads_childcat */ |
||||
| 271 | $message .= '<b><span style="color : #ff0000">' . $downloads_childcat[$i]->getVar('cat_title') . '</span></b><br>'; |
||||
| 272 | $criteria = new \CriteriaCompo(); |
||||
| 273 | $criteria->add(new \Criteria('cid', $downloads_childcat[$i]->getVar('cat_cid'))); |
||||
| 274 | $downloadsArray = $downloadsHandler->getAll($criteria); |
||||
| 275 | if (count($downloadsArray) > 0) { |
||||
| 276 | $message .= _AM_TDMDOWNLOADS_DELDOWNLOADS . '<br>'; |
||||
| 277 | foreach (array_keys($downloadsArray) as $k) { |
||||
| 278 | $message .= '<span style="color: #ff0000;">' . $downloadsArray[$k]->getVar('title') . '</span><br>'; |
||||
| 279 | } |
||||
| 280 | } |
||||
| 281 | } |
||||
| 282 | } else { |
||||
| 283 | $message .= ''; |
||||
| 284 | } |
||||
| 285 | //Affichage de la partie haute de l'administration de Xoops |
||||
| 286 | xoops_cp_header(); |
||||
| 287 | $adminObject = Admin::getInstance(); |
||||
| 288 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); |
||||
| 289 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_CAT_LIST, 'category.php?op=list', 'list'); |
||||
| 290 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_CAT_NEW, 'category.php?op=new_cat', 'add'); |
||||
| 291 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||||
| 292 | xoops_confirm( |
||||
| 293 | [ |
||||
| 294 | 'ok' => 1, |
||||
| 295 | 'downloadscat_cid' => $categoryId, |
||||
| 296 | 'op' => 'del_cat', |
||||
| 297 | ], |
||||
| 298 | $_SERVER['REQUEST_URI'], |
||||
| 299 | sprintf(_AM_TDMDOWNLOADS_FORMSUREDEL, $obj->getVar('cat_title')) . '<br><br>' . $message |
||||
|
0 ignored issues
–
show
It seems like
$obj->getVar('cat_title') can also be of type array and array; however, parameter $values of sprintf() does only seem to accept double|integer|string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 300 | ); |
||||
| 301 | } |
||||
| 302 | break; |
||||
| 303 | // Pour sauver une catégorie |
||||
| 304 | case 'save_cat': |
||||
| 305 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||
| 306 | redirect_header('category.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||||
| 307 | } |
||||
| 308 | xoops_cp_header(); |
||||
| 309 | $cat_cid = \Xmf\Request::getInt('cat_cid', 0, 'POST'); |
||||
| 310 | if (0 !== $cat_cid) { |
||||
| 311 | $obj = $categoryHandler->get($cat_cid); |
||||
| 312 | } else { |
||||
| 313 | $obj = $categoryHandler->create(); |
||||
| 314 | } |
||||
| 315 | $erreur = false; |
||||
| 316 | $errorMessage = ''; |
||||
| 317 | // Récupération des variables: |
||||
| 318 | // Pour l'image |
||||
| 319 | require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
||||
| 320 | $uploader = new \XoopsMediaUploader( |
||||
| 321 | $uploaddir, [ |
||||
| 322 | 'image/gif', |
||||
| 323 | 'image/jpeg', |
||||
| 324 | 'image/pjpeg', |
||||
| 325 | 'image/x-png', |
||||
| 326 | 'image/png', |
||||
| 327 | ], $helper->getConfig('maxuploadsize'), null, null |
||||
| 328 | ); |
||||
| 329 | if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
||||
| 330 | $uploader->setPrefix('downloads_'); |
||||
| 331 | $uploader->fetchMedia($_POST['xoops_upload_file'][0]); |
||||
| 332 | if (!$uploader->upload()) { |
||||
| 333 | $errors = $uploader->getErrors(); |
||||
| 334 | redirect_header('javascript:history.go(-1)', 3, $errors); |
||||
| 335 | } else { |
||||
| 336 | $obj->setVar('cat_imgurl', $uploader->getSavedFileName()); |
||||
| 337 | } |
||||
| 338 | } else { |
||||
| 339 | $obj->setVar('cat_imgurl', \Xmf\Request::getString('downloadscat_img', '', 'REQUEST')); |
||||
| 340 | } |
||||
| 341 | // Pour les autres variables |
||||
| 342 | $obj->setVar('cat_pid', \Xmf\Request::getInt('cat_pid', 0, 'POST')); //$_POST['cat_pid']); |
||||
| 343 | $obj->setVar('cat_title', \Xmf\Request::getString('cat_title', '', 'POST')); //$_POST['cat_title']); |
||||
| 344 | $obj->setVar('cat_description_main', \Xmf\Request::getString('cat_description_main', '', 'POST')); //$_POST['cat_description_main']); |
||||
| 345 | $obj->setVar('cat_weight', \Xmf\Request::getInt('cat_weight', 0, 'POST')); |
||||
| 346 | if (\Xmf\Request::hasVar('cat_cid', 'REQUEST')) { |
||||
| 347 | if ($cat_cid === \Xmf\Request::getInt('cat_pid', 0, 'POST')) { |
||||
| 348 | $erreur = true; |
||||
| 349 | $errorMessage .= _AM_TDMDOWNLOADS_ERREUR_CAT; |
||||
| 350 | } |
||||
| 351 | } |
||||
| 352 | if (true === $erreur) { |
||||
| 353 | $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); |
||||
| 354 | } else { |
||||
| 355 | if ($categoryHandler->insert($obj)) { |
||||
| 356 | /** @var \XoopsModules\Tdmdownloads\Category $obj */ |
||||
| 357 | $newcat_cid = $obj->getNewEnreg($db); |
||||
| 358 | //permission pour voir |
||||
| 359 | $perm_id = \Xmf\Request::hasVar('cat_cid', 'POST') ? $cat_cid : $newcat_cid; |
||||
| 360 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||||
| 361 | $grouppermHandler = xoops_getHandler('groupperm'); |
||||
| 362 | $criteria = new \CriteriaCompo(); |
||||
| 363 | $criteria->add(new \Criteria('gperm_itemid', $perm_id, '=')); |
||||
| 364 | $criteria->add(new \Criteria('gperm_modid', $xoopsModule->getVar('mid'), '=')); |
||||
| 365 | $criteria->add(new \Criteria('gperm_name', 'tdmdownloads_view', '=')); |
||||
| 366 | $grouppermHandler->deleteAll($criteria); |
||||
| 367 | if (\Xmf\Request::hasVar('groups_view', 'POST')) { |
||||
| 368 | foreach ($_POST['groups_view'] as $onegroup_id) { |
||||
| 369 | $grouppermHandler->addRight('tdmdownloads_view', $perm_id, $onegroup_id, $xoopsModule->getVar('mid')); |
||||
|
0 ignored issues
–
show
It seems like
$perm_id can also be of type string; however, parameter $gperm_itemid of XoopsGroupPermHandler::addRight() does only seem to accept integer, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 370 | } |
||||
| 371 | } |
||||
| 372 | //permission pour editer |
||||
| 373 | $perm_id = \Xmf\Request::getInt('cat_cid', $newcat_cid, 'POST'); |
||||
|
0 ignored issues
–
show
It seems like
$newcat_cid can also be of type string; however, parameter $default of Xmf\Request::getInt() does only seem to accept integer, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 374 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||||
| 375 | $grouppermHandler = xoops_getHandler('groupperm'); |
||||
| 376 | $criteria = new \CriteriaCompo(); |
||||
| 377 | $criteria->add(new \Criteria('gperm_itemid', $perm_id, '=')); |
||||
| 378 | $criteria->add(new \Criteria('gperm_modid', $xoopsModule->getVar('mid'), '=')); |
||||
| 379 | $criteria->add(new \Criteria('gperm_name', 'tdmdownloads_submit', '=')); |
||||
| 380 | $grouppermHandler->deleteAll($criteria); |
||||
| 381 | if (\Xmf\Request::hasVar('groups_submit', 'POST')) { |
||||
| 382 | foreach ($_POST['groups_submit'] as $onegroup_id) { |
||||
| 383 | $grouppermHandler->addRight('tdmdownloads_submit', $perm_id, $onegroup_id, $xoopsModule->getVar('mid')); |
||||
| 384 | } |
||||
| 385 | } |
||||
| 386 | //permission pour télécharger |
||||
| 387 | if (1 == $helper->getConfig('permission_download')) { |
||||
| 388 | $perm_id = \Xmf\Request::getInt('cat_cid', $newcat_cid, 'POST'); |
||||
| 389 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||||
| 390 | $grouppermHandler = xoops_getHandler('groupperm'); |
||||
| 391 | $criteria = new \CriteriaCompo(); |
||||
| 392 | $criteria->add(new \Criteria('gperm_itemid', $perm_id, '=')); |
||||
| 393 | $criteria->add(new \Criteria('gperm_modid', $xoopsModule->getVar('mid'), '=')); |
||||
| 394 | $criteria->add(new \Criteria('gperm_name', 'tdmdownloads_download', '=')); |
||||
| 395 | $grouppermHandler->deleteAll($criteria); |
||||
| 396 | if (\Xmf\Request::hasVar('groups_download', 'POST')) { |
||||
| 397 | foreach ($_POST['groups_download'] as $onegroup_id) { |
||||
| 398 | $grouppermHandler->addRight('tdmdownloads_download', $perm_id, $onegroup_id, $xoopsModule->getVar('mid')); |
||||
| 399 | } |
||||
| 400 | } |
||||
| 401 | } |
||||
| 402 | //notification |
||||
| 403 | if (!\Xmf\Request::hasVar('categorie_modified', 'POST')) { |
||||
| 404 | $tags = []; |
||||
| 405 | $tags['CATEGORY_NAME'] = \Xmf\Request::getString('cat_title', '', 'POST'); |
||||
| 406 | $tags['CATEGORY_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/viewcat.php?cid=' . $newcat_cid; |
||||
| 407 | /** @var \XoopsNotificationHandler $notificationHandler */ |
||||
| 408 | $notificationHandler = xoops_getHandler('notification'); |
||||
| 409 | $notificationHandler->triggerEvent('global', 0, 'new_category', $tags); |
||||
| 410 | } |
||||
| 411 | redirect_header('category.php?op=list', 1, _AM_TDMDOWNLOADS_REDIRECT_SAVE); |
||||
| 412 | } |
||||
| 413 | $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); |
||||
| 414 | } |
||||
| 415 | $form = $obj->getForm(); |
||||
| 416 | $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); |
||||
| 417 | break; |
||||
| 418 | } |
||||
| 419 | // Local icons path |
||||
| 420 | if (is_object($helper->getModule())) { |
||||
| 421 | $pathModIcon16 = $helper->getModule()->getInfo('modicons16'); |
||||
| 422 | $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); |
||||
| 423 | $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16); |
||||
| 424 | $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32); |
||||
| 425 | } |
||||
| 426 | //Affichage de la partie basse de l'administration de Xoops |
||||
| 427 | require_once __DIR__ . '/admin_footer.php'; |
||||
| 428 |