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 | /** |
||||
6 | * TDMDownload |
||||
7 | * |
||||
8 | * You may not change or alter any portion of this comment or credits |
||||
9 | * of supporting developers from this source code or any supporting source code |
||||
10 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||||
11 | * This program is distributed in the hope that it will be useful, |
||||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
14 | * |
||||
15 | * @copyright Gregory Mage (Aka Mage) |
||||
16 | * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||||
17 | * @author Gregory Mage (Aka Mage) |
||||
18 | */ |
||||
19 | |||||
20 | use Xmf\Module\Admin; |
||||
21 | use XoopsModules\Tdmdownloads\Helper; |
||||
22 | |||||
23 | require __DIR__ . '/admin_header.php'; |
||||
24 | require dirname(__DIR__) . '/include/common.php'; |
||||
25 | // Template |
||||
26 | $templateMain = 'tdmdownloads_admin_field.tpl'; |
||||
27 | $helper = Helper::getInstance(); |
||||
28 | //On recupere la valeur de l'argument op dans l'URL$ |
||||
29 | $op = \Xmf\Request::getCmd('op', 'list'); |
||||
30 | //Les valeurs de op qui vont permettre d'aller dans les differentes parties de la page |
||||
31 | switch ($op) { |
||||
32 | // Vue liste |
||||
33 | case 'list': |
||||
34 | //Affichage de la partie haute de l'administration de Xoops |
||||
35 | xoops_cp_header(); |
||||
36 | $adminObject = Admin::getInstance(); |
||||
37 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); |
||||
38 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_FIELD_NEW, 'field.php?op=new_field', 'add'); |
||||
39 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||||
40 | $criteria = new \CriteriaCompo(); |
||||
41 | $criteria->setSort('weight ASC, title'); |
||||
42 | $criteria->setOrder('ASC'); |
||||
43 | $downloads_field = $fieldHandler->getAll($criteria); |
||||
44 | $numrows = count($downloads_field); |
||||
45 | //Affichage du tableau |
||||
46 | if ($numrows > 0) { |
||||
47 | $GLOBALS['xoopsTpl']->assign('fields_count', $numrows); |
||||
48 | foreach (array_keys($downloads_field) as $i) { |
||||
49 | /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ |
||||
50 | $field = [ |
||||
51 | 'title' => $downloads_field[$i]->getVar('title'), |
||||
52 | 'img' => $uploadurl_field . $downloads_field[$i]->getVar('img'), |
||||
53 | 'weight' => $downloads_field[$i]->getVar('weight'), |
||||
54 | 'fid' => $downloads_field[$i]->getVar('fid'), |
||||
55 | 'status' => $downloads_field[$i]->getVar('status'), |
||||
56 | 'search' => $downloads_field[$i]->getVar('search'), |
||||
57 | 'status_def' => $downloads_field[$i]->getVar('status_def'), |
||||
58 | 'search' => $downloads_field[$i]->getVar('search'), |
||||
59 | ]; |
||||
60 | $GLOBALS['xoopsTpl']->append('fields_list', $field); |
||||
61 | unset($field); |
||||
62 | } |
||||
63 | } |
||||
64 | break; |
||||
65 | case 'update_status': |
||||
66 | $obj = $fieldHandler->get(\Xmf\Request::getInt('fid', 0, 'REQUEST')); |
||||
67 | $obj->setVar('status', \Xmf\Request::getInt('aff', 0, 'REQUEST')); |
||||
68 | if ($fieldHandler->insert($obj)) { |
||||
69 | redirect_header('field.php?op=list', 1, _AM_TDMDOWNLOADS_REDIRECT_SAVE); |
||||
70 | } |
||||
71 | $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); |
||||
72 | break; |
||||
73 | case 'update_search': |
||||
74 | $obj = $fieldHandler->get(\Xmf\Request::getInt('fid', 0, 'REQUEST')); |
||||
75 | $obj->setVar('search', \Xmf\Request::getInt('aff', 0, 'REQUEST')); |
||||
76 | if ($fieldHandler->insert($obj)) { |
||||
77 | redirect_header('field.php?op=list', 1, _AM_TDMDOWNLOADS_REDIRECT_SAVE); |
||||
78 | } |
||||
79 | $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); |
||||
80 | break; |
||||
81 | // vue création |
||||
82 | case 'new_field': |
||||
83 | //Affichage de la partie haute de l'administration de Xoops |
||||
84 | xoops_cp_header(); |
||||
85 | $adminObject = Admin::getInstance(); |
||||
86 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); |
||||
87 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_FIELD_LIST, 'field.php?op=list', 'list'); |
||||
88 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||||
89 | //Affichage du formulaire de création des champs |
||||
90 | /** @var \XoopsModules\Tdmdownloads\Field $obj */ |
||||
91 | $obj = $fieldHandler->create(); |
||||
92 | /** @var \XoopsThemeForm $form */ |
||||
93 | $form = $obj->getForm(); |
||||
94 | $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); |
||||
95 | break; |
||||
96 | // Pour éditer un champ |
||||
97 | case 'edit_field': |
||||
98 | //Affichage de la partie haute de l'administration de Xoops |
||||
99 | xoops_cp_header(); |
||||
100 | $adminObject = Admin::getInstance(); |
||||
101 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); |
||||
102 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_FIELD_NEW, 'field.php?op=new_field', 'add'); |
||||
103 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_FIELD_LIST, 'field.php?op=list', 'list'); |
||||
104 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||||
105 | //Affichage du formulaire de création des champs |
||||
106 | /** @var \XoopsModules\Tdmdownloads\Field $obj */ |
||||
107 | $obj = $fieldHandler->get(\Xmf\Request::getInt('fid', 0, 'GET')); |
||||
108 | /** @var \XoopsThemeForm $form */ |
||||
109 | $form = $obj->getForm(); |
||||
110 | $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); |
||||
111 | break; |
||||
112 | // Pour supprimer un champ |
||||
113 | case 'del_field': |
||||
114 | global $xoopsModule; |
||||
115 | $obj = $fieldHandler->get(\Xmf\Request::getInt('fid', 0, 'GET')); |
||||
116 | if (\Xmf\Request::hasVar('ok', 'POST') && 1 == \Xmf\Request::getInt('ok', 0, 'POST')) { |
||||
117 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||
118 | redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||||
119 | } |
||||
120 | // supression des entrée du champ |
||||
121 | $criteria = new \CriteriaCompo(); |
||||
122 | $criteria->add(new \Criteria('fid', \Xmf\Request::getInt('fid', 0))); |
||||
123 | $downloadsArray = $fielddataHandler->getAll($criteria); |
||||
124 | foreach (array_keys($downloadsArray) as $i) { |
||||
125 | /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloadsArray */ |
||||
126 | // supression de l'entrée |
||||
127 | $objdownloadsfielddata = $fielddataHandler->get($downloadsArray[$i]->getVar('iddata')); |
||||
128 | $fielddataHandler->delete($objdownloadsfielddata) || $objdownloads->getHtmlErrors(); |
||||
129 | } |
||||
130 | if ($fieldHandler->delete($obj)) { |
||||
131 | redirect_header('field.php', 1, _AM_TDMDOWNLOADS_REDIRECT_DELOK); |
||||
132 | } else { |
||||
133 | $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); |
||||
134 | } |
||||
135 | } else { |
||||
136 | $downloadsfield = $fieldHandler->get(\Xmf\Request::getInt('fid', 0, 'GET')); |
||||
137 | if (1 == $downloadsfield->getVar('status_def')) { |
||||
138 | redirect_header('field.php', 2, _AM_TDMDOWNLOADS_REDIRECT_NODELFIELD); |
||||
139 | } |
||||
140 | $message = ''; |
||||
141 | $criteria = new \CriteriaCompo(); |
||||
142 | $criteria->add(new \Criteria('fid', \Xmf\Request::getInt('fid', 0, 'GET'))); |
||||
143 | /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloadsArray */ |
||||
144 | $downloadsArray = $fielddataHandler->getAll($criteria); |
||||
145 | if (count($downloadsArray) > 0) { |
||||
146 | $message .= _AM_TDMDOWNLOADS_DELDATA . '<br>'; |
||||
147 | foreach (array_keys($downloadsArray) as $i) { |
||||
148 | $message .= '<span style="color: #ff0000;">' . $downloadsArray[$i]->getVar('data') . '</span><br>'; |
||||
149 | } |
||||
150 | } |
||||
151 | //Affichage de la partie haute de l'administration de Xoops |
||||
152 | xoops_cp_header(); |
||||
153 | $adminObject = Admin::getInstance(); |
||||
154 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); |
||||
155 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_FIELD_NEW, 'field.php?op=new_field', 'add'); |
||||
156 | $adminObject->addItemButton(_AM_TDMDOWNLOADS_FIELD_LIST, 'field.php?op=list', 'list'); |
||||
157 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||||
158 | xoops_confirm(['ok' => 1, 'fid' => \Xmf\Request::getInt('fid', 0, 'GET'), 'op' => 'del_field'], $_SERVER['REQUEST_URI'], sprintf(_AM_TDMDOWNLOADS_FORMSUREDEL, $obj->getVar('title')) . '<br><br>' . $message); |
||||
159 | } |
||||
160 | break; |
||||
161 | // Pour sauver un champ |
||||
162 | case 'save_field': |
||||
163 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||
164 | redirect_header('field.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||||
165 | } |
||||
166 | /** @var \XoopsModules\Tdmdownloads\Field $obj */ |
||||
167 | if (\Xmf\Request::hasVar('fid', 'POST')) { |
||||
168 | $obj = $fieldHandler->get(\Xmf\Request::getInt('fid', 0, 'POST')); |
||||
169 | } else { |
||||
170 | $obj = $fieldHandler->create(); |
||||
171 | } |
||||
172 | $erreur = false; |
||||
173 | $errorMessage = ''; |
||||
174 | // Récupération des variables: |
||||
175 | // Pour l'image |
||||
176 | require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
||||
177 | $uploader = new \XoopsMediaUploader( |
||||
178 | $uploaddir_field, [ |
||||
179 | 'image/gif', |
||||
180 | 'image/jpeg', |
||||
181 | 'image/pjpeg', |
||||
182 | 'image/x-png', |
||||
183 | 'image/png', |
||||
184 | ], $helper->getConfig('maxuploadsize'), 16, null |
||||
185 | ); |
||||
186 | if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
||||
187 | $uploader->setPrefix('downloads_'); |
||||
188 | $uploader->fetchMedia($_POST['xoops_upload_file'][0]); |
||||
189 | if (!$uploader->upload()) { |
||||
190 | $errors = $uploader->getErrors(); |
||||
191 | redirect_header('javascript:history.go(-1)', 3, $errors); |
||||
192 | } else { |
||||
193 | $obj->setVar('img', $uploader->getSavedFileName()); |
||||
194 | } |
||||
195 | } else { |
||||
196 | $obj->setVar('img', \Xmf\Request::getString('downloadsfield_img', '', 'POST')); |
||||
197 | } |
||||
198 | // Pour les autres variables |
||||
199 | $obj->setVar('title', \Xmf\Request::getString('title', '', 'POST')); |
||||
200 | $obj->setVar('weight', \Xmf\Request::getInt('weight', 0, 'POST')); |
||||
201 | $obj->setVar('status', \Xmf\Request::getInt('status', 0, 'POST')); |
||||
202 | $obj->setVar('search', \Xmf\Request::getInt('search', 0, 'POST')); |
||||
203 | $obj->setVar('status_def', \Xmf\Request::getInt('status_def', 0, 'POST')); |
||||
204 | if (true === $erreur) { |
||||
0 ignored issues
–
show
introduced
by
![]() |
|||||
205 | xoops_cp_header(); |
||||
206 | $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); |
||||
207 | } else { |
||||
208 | if ($fieldHandler->insert($obj)) { |
||||
209 | redirect_header('field.php', 1, _AM_TDMDOWNLOADS_REDIRECT_SAVE); |
||||
210 | } |
||||
211 | xoops_cp_header(); |
||||
212 | $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors()); |
||||
213 | } |
||||
214 | $form = $obj->getForm(); |
||||
215 | $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); |
||||
216 | break; |
||||
217 | } |
||||
218 | // Local icons path |
||||
219 | if (is_object($helper->getModule())) { |
||||
220 | $pathModIcon16 = $helper->getModule()->getInfo('modicons16'); |
||||
221 | $pathModIcon32 = $helper->getModule()->getInfo('modicons32'); |
||||
222 | $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16); |
||||
0 ignored issues
–
show
Are you sure
$pathModIcon16 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
![]() |
|||||
223 | $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32); |
||||
224 | } |
||||
225 | //Affichage de la partie basse de l'administration de Xoops |
||||
226 | require_once __DIR__ . '/admin_footer.php'; |
||||
227 |