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 XoopsModules\Tdmdownloads\{ |
||||||
21 | Helper, |
||||||
22 | Tree |
||||||
23 | }; |
||||||
24 | |||||||
25 | require_once __DIR__ . '/header.php'; |
||||||
26 | $helper = Helper::getInstance(); |
||||||
27 | // template d'affichage |
||||||
28 | $GLOBALS['xoopsOption']['template_main'] = 'tdmdownloads_modfile.tpl'; |
||||||
29 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||||||
30 | $moduleDirName = basename(__DIR__); |
||||||
31 | /** @var \xos_opal_Theme $xoTheme */ |
||||||
32 | $xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $moduleDirName . '/assets/css/styles.css', null); |
||||||
33 | //On recupere la valeur de l'argument op dans l'URL$ |
||||||
34 | $op = \Xmf\Request::getCmd('op', 'list'); |
||||||
35 | // redirection si pas de droit pour poster |
||||||
36 | if (false === $perm_modif) { |
||||||
37 | redirect_header('index.php', 2, _NOPERM); |
||||||
38 | } |
||||||
39 | $lid = \Xmf\Request::getInt('lid', 0, 'REQUEST'); |
||||||
40 | //information du téléchargement |
||||||
41 | $viewDownloads = $downloadsHandler->get($lid); |
||||||
42 | // redirection si le téléchargement n'existe pas ou n'est pas activé |
||||||
43 | if (!is_object($viewDownloads) || 0 == $viewDownloads->getVar('status')) { |
||||||
44 | redirect_header('index.php', 3, _MD_TDMDOWNLOADS_SINGLEFILE_NONEXISTENT); |
||||||
45 | } |
||||||
46 | //Les valeurs de op qui vont permettre d'aller dans les differentes parties de la page |
||||||
47 | switch ($op) { |
||||||
48 | // Vue liste |
||||||
49 | case 'list': |
||||||
50 | //navigation |
||||||
51 | $view_category = $categoryHandler->get($viewDownloads->getVar('cid')); |
||||||
52 | $categories = $utility->getItemIds('tdmdownloads_view', $moduleDirName); |
||||||
53 | if (!in_array($viewDownloads->getVar('cid'), $categories)) { |
||||||
54 | redirect_header('index.php', 2, _NOPERM); |
||||||
55 | } |
||||||
56 | //tableau des catégories |
||||||
57 | $criteria = new \CriteriaCompo(); |
||||||
58 | $criteria->setSort('cat_weight ASC, cat_title'); |
||||||
59 | $criteria->setOrder('ASC'); |
||||||
60 | $criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN')); |
||||||
61 | $downloadscatArray = $categoryHandler->getAll($criteria); |
||||||
62 | $mytree = new Tree($downloadscatArray, 'cat_cid', 'cat_pid'); |
||||||
63 | //navigation |
||||||
64 | $navigation = $utility::getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' <img src="assets/images/deco/arrow.gif" alt="arrow"> ', true, 'ASC', true); |
||||||
65 | $navigation .= ' <img src="assets/images/deco/arrow.gif" alt="arrow"> <a title="' . $viewDownloads->getVar('title') . '" href="singlefile.php?lid=' . $viewDownloads->getVar('lid') . '">' . $viewDownloads->getVar('title') . '</a>'; |
||||||
66 | $navigation .= ' <img src="assets/images/deco/arrow.gif" alt="arrow"> ' . _MD_TDMDOWNLOADS_SINGLEFILE_MODIFY; |
||||||
67 | $xoopsTpl->assign('navigation', $navigation); |
||||||
68 | // référencement |
||||||
69 | // titre de la page |
||||||
70 | $pagetitle = _MD_TDMDOWNLOADS_SINGLEFILE_MODIFY . ' - ' . $viewDownloads->getVar('title') . ' - '; |
||||||
71 | $pagetitle .= $utility::getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' - ', false, 'DESC', true); |
||||||
72 | $xoopsTpl->assign('xoops_pagetitle', $pagetitle); |
||||||
73 | //description |
||||||
74 | $xoTheme->addMeta('meta', 'description', strip_tags(_MD_TDMDOWNLOADS_SINGLEFILE_MODIFY . ' (' . $viewDownloads->getVar('title') . ')')); |
||||||
75 | //Affichage du formulaire de notation des téléchargements |
||||||
76 | if ($perm_autoapprove) { |
||||||
77 | /** @var \XoopsModules\Tdmdownloads\Downloads $obj */ |
||||||
78 | $obj = $downloadsHandler->get($lid); |
||||||
79 | $form = $obj->getForm($donnee = [], false, 'submit.php'); |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
80 | } else { |
||||||
81 | /** @var \XoopsModules\Tdmdownloads\Modified $obj */ |
||||||
82 | $obj = $modifiedHandler->create(); |
||||||
83 | $form = $obj->getForm($lid, false, $donnee = []); |
||||||
84 | } |
||||||
85 | $xoopsTpl->assign('themeForm', $form->render()); |
||||||
86 | $xoopsTpl->assign('message_erreur', false); |
||||||
87 | break; |
||||||
88 | // save |
||||||
89 | case 'save': |
||||||
90 | require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
||||||
91 | /** @var \XoopsModules\Tdmdownloads\Downloads $obj */ |
||||||
92 | $obj = $modifiedHandler->create(); |
||||||
93 | $erreur = false; |
||||||
94 | $errorMessage = ''; |
||||||
95 | $donnee = []; |
||||||
96 | $obj->setVar('title', \Xmf\Request::getString('title', '', 'POST')); //$_POST['title']); |
||||||
97 | $donnee['title'] = \Xmf\Request::getString('title', '', 'POST'); //$_POST['title']; |
||||||
98 | $obj->setVar('cid', \Xmf\Request::getInt('cid', 0, 'POST')); //$_POST['cid']); |
||||||
99 | $donnee['cid'] = \Xmf\Request::getInt('cid', 0, 'POST'); //$_POST['cid']; |
||||||
100 | $obj->setVar('lid', \Xmf\Request::getInt('lid', 0, 'POST')); //$_POST['lid']); |
||||||
101 | $obj->setVar('homepage', \Xmf\Request::getString('homepage', '', 'POST')); //formatURL($_POST["homepage"])); |
||||||
102 | $donnee['homepage'] = \Xmf\Request::getString('homepage', '', 'POST'); //formatURL($_POST["homepage"]); |
||||||
103 | $obj->setVar('version', \Xmf\Request::getString('version', '', 'POST')); //$_POST["version"]); |
||||||
104 | $donnee['version'] = \Xmf\Request::getString('version', '', 'POST'); //$_POST["version"]; |
||||||
105 | if (\Xmf\Request::hasVar('platform', 'POST')) { |
||||||
106 | $obj->setVar('platform', implode('|', \Xmf\Request::getString('platform', '', 'POST'))); //$_POST['platform'])); |
||||||
0 ignored issues
–
show
Xmf\Request::getString('platform', '', 'POST') of type string is incompatible with the type array expected by parameter $pieces of implode() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
107 | $donnee['platform'] = implode('|', \Xmf\Request::getString('platform', '', 'POST')); //$_POST["platform"]); |
||||||
108 | } else { |
||||||
109 | $donnee['platform'] = ''; |
||||||
110 | } |
||||||
111 | $obj->setVar('description', \Xmf\Request::getString('description', '', 'POST')); //$_POST["description"]); |
||||||
112 | $donnee['description'] = \Xmf\Request::getString('description', '', 'POST'); //$_POST["description"]; |
||||||
113 | $obj->setVar('modifysubmitter', !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0); |
||||||
114 | // erreur si la catégorie est vide |
||||||
115 | if (\Xmf\Request::hasVar('cid')) { |
||||||
116 | if (0 == \Xmf\Request::getInt('cid', 0, 'POST')) { |
||||||
117 | $erreur = true; |
||||||
118 | $errorMessage .= _MD_TDMDOWNLOADS_ERREUR_NOCAT . '<br>'; |
||||||
119 | } |
||||||
120 | } |
||||||
121 | // get captcha (members are skipped in class/download.php getForm |
||||||
122 | if (!$xoopsUser) { |
||||||
123 | // erreur si le captcha est faux |
||||||
124 | xoops_load('xoopscaptcha'); |
||||||
125 | $xoopsCaptcha = \XoopsCaptcha::getInstance(); |
||||||
126 | if (!$xoopsCaptcha->verify()) { |
||||||
127 | $errorMessage .= $xoopsCaptcha->getMessage() . '<br>'; |
||||||
128 | $erreur = true; |
||||||
129 | } |
||||||
130 | } |
||||||
131 | // pour enregistrer temporairement les valeur des champs sup |
||||||
132 | $criteria = new \CriteriaCompo(); |
||||||
133 | $criteria->setSort('weight ASC, title'); |
||||||
134 | $criteria->setOrder('ASC'); |
||||||
135 | $downloads_field = $fieldHandler->getAll($criteria); |
||||||
136 | foreach (array_keys($downloads_field) as $i) { |
||||||
137 | /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ |
||||||
138 | if (0 == $downloads_field[$i]->getVar('status_def')) { |
||||||
139 | $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); |
||||||
140 | $donnee[$fieldName] = \Xmf\Request::getString($fieldName, '', 'POST'); |
||||||
141 | } |
||||||
142 | } |
||||||
143 | if (true === $erreur) { |
||||||
144 | $xoopsTpl->assign('message_erreur', $errorMessage); |
||||||
145 | } else { |
||||||
146 | // Pour le fichier |
||||||
147 | $mediaSize = 0; |
||||||
148 | if (isset($_POST['xoops_upload_file'][0])) { |
||||||
149 | $uploader = new \XoopsMediaUploader($uploaddir_downloads, $helper->getConfig('mimetypes'), $helper->getConfig('maxuploadsize'), null, null); |
||||||
150 | if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
||||||
151 | if ($helper->getConfig('newnamedownload')) { |
||||||
152 | $uploader->setPrefix($helper->getConfig('prefixdownloads')); |
||||||
153 | } |
||||||
154 | $uploader->fetchMedia($_POST['xoops_upload_file'][0]); |
||||||
155 | if (!$uploader->upload()) { |
||||||
156 | $errors = $uploader->getErrors(); |
||||||
157 | redirect_header('javascript:history.go(-1)', 3, $errors); |
||||||
158 | } else { |
||||||
159 | $mediaSize = $uploader->getMediaSize(); |
||||||
160 | $obj->setVar('url', $uploadurl_downloads . $uploader->getSavedFileName()); |
||||||
161 | } |
||||||
162 | } else { |
||||||
163 | if ($_FILES['attachedfile']['name'] > '') { |
||||||
164 | // file name was given, but fetchMedia failed - show error when e.g. file size exceed maxuploadsize |
||||||
165 | $errorMessage .= $uploader->getErrors() . '<br>'; |
||||||
166 | $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); |
||||||
167 | $form = $obj->getForm($donnee, true); |
||||||
168 | $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); |
||||||
169 | break; |
||||||
170 | } |
||||||
171 | $obj->setVar('url', \Xmf\Request::getString('url', '', 'REQUEST')); |
||||||
172 | } |
||||||
173 | } else { |
||||||
174 | $obj->setVar('url', \Xmf\Request::getString('url', '', 'REQUEST')); |
||||||
175 | } |
||||||
176 | // Pour l'image |
||||||
177 | if (isset($_POST['xoops_upload_file'][1])) { |
||||||
178 | $uploader_2 = new \XoopsMediaUploader( |
||||||
179 | $uploaddir_shots, [ |
||||||
180 | 'image/gif', |
||||||
181 | 'image/jpeg', |
||||||
182 | 'image/pjpeg', |
||||||
183 | 'image/x-png', |
||||||
184 | 'image/png', |
||||||
185 | ], $helper->getConfig('maxuploadsize'), null, null |
||||||
186 | ); |
||||||
187 | if ($uploader_2->fetchMedia($_POST['xoops_upload_file'][1])) { |
||||||
188 | $uploader_2->setPrefix('downloads_'); |
||||||
189 | $uploader_2->fetchMedia($_POST['xoops_upload_file'][1]); |
||||||
190 | if (!$uploader_2->upload()) { |
||||||
191 | $errors = $uploader_2->getErrors(); |
||||||
192 | redirect_header('javascript:history.go(-1)', 3, $errors); |
||||||
193 | } else { |
||||||
194 | $obj->setVar('logourl', $uploader_2->getSavedFileName()); |
||||||
195 | } |
||||||
196 | } else { |
||||||
197 | if ($_FILES['attachedimage']['name'] > '') { |
||||||
198 | // file name was given, but fetchMedia failed - show error when e.g. file size exceed maxuploadsize |
||||||
199 | $errorMessage .= $uploader_2->getErrors() . '<br>'; |
||||||
200 | $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage); |
||||||
201 | $form = $obj->getForm($donnee, true); |
||||||
202 | $GLOBALS['xoopsTpl']->assign('themeForm', $form->render()); |
||||||
203 | break; |
||||||
204 | } |
||||||
205 | $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'REQUEST')); |
||||||
206 | } |
||||||
207 | } else { |
||||||
208 | $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'REQUEST')); |
||||||
209 | } |
||||||
210 | //Automatic file size |
||||||
211 | if ('' == Xmf\Request::getString('sizeValue', '')) { |
||||||
212 | if (0 == $mediaSize) { |
||||||
213 | $obj->setVar('size', $utility::getFileSize(Xmf\Request::getUrl('url', ''))); |
||||||
214 | } else { |
||||||
215 | $obj->setVar('size', $utility::convertFileSize($mediaSize)); |
||||||
216 | } |
||||||
217 | } else { |
||||||
218 | $obj->setVar('size', Xmf\Request::getFloat('sizeValue', 0) . ' ' . Xmf\Request::getString('sizeType', '')); |
||||||
219 | } |
||||||
220 | $timeToRedirect = 2; |
||||||
221 | if (0 == $obj->getVar('size')) { |
||||||
222 | $obj->setVar('size', ''); |
||||||
223 | $error_message = _AM_TDMDOWNLOADS_ERREUR_SIZE; |
||||||
224 | $timeToRedirect = 10; |
||||||
225 | } |
||||||
226 | if ($modifiedHandler->insert($obj)) { |
||||||
227 | $lidDownloads = $obj->getNewEnreg($db); |
||||||
228 | // Récupération des champs supplémentaires: |
||||||
229 | $criteria = new \CriteriaCompo(); |
||||||
230 | $criteria->setSort('weight ASC, title'); |
||||||
231 | $criteria->setOrder('ASC'); |
||||||
232 | $downloads_field = $fieldHandler->getAll($criteria); |
||||||
233 | foreach (array_keys($downloads_field) as $i) { |
||||||
234 | /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */ |
||||||
235 | if (0 == $downloads_field[$i]->getVar('status_def')) { |
||||||
236 | //$objdata = $modifiedfielddataHandler->create(); |
||||||
237 | $objdata = $modifieddataHandler->create(); |
||||||
238 | $fieldName = 'champ' . $downloads_field[$i]->getVar('fid'); |
||||||
239 | $objdata->setVar('moddata', \Xmf\Request::getString($fieldName, '', 'POST')); |
||||||
240 | $objdata->setVar('lid', $lidDownloads); |
||||||
241 | $objdata->setVar('fid', $downloads_field[$i]->getVar('fid')); |
||||||
242 | //$modifiedfielddataHandler->insert($objdata) || $objdata->getHtmlErrors(); |
||||||
243 | $modifieddataHandler->insert($objdata) || $objdata->getHtmlErrors(); |
||||||
244 | } |
||||||
245 | } |
||||||
246 | $tags = []; |
||||||
247 | $tags['MODIFYREPORTS_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/admin/modified.php'; |
||||||
248 | /** @var \XoopsNotificationHandler $notificationHandler */ |
||||||
249 | $notificationHandler = xoops_getHandler('notification'); |
||||||
250 | $notificationHandler->triggerEvent('global', 0, 'file_modify', $tags); |
||||||
251 | redirect_header('singlefile.php?lid=' . \Xmf\Request::getInt('lid', 0, 'REQUEST'), $timeToRedirect, _MD_TDMDOWNLOADS_MODFILE_THANKSFORINFO . '<br><br>' . $error_message); |
||||||
252 | } |
||||||
253 | echo $obj->getHtmlErrors(); |
||||||
254 | } |
||||||
255 | //Affichage du formulaire de notation des téléchargements |
||||||
256 | $form = $obj->getForm(\Xmf\Request::getInt('lid', 0, 'REQUEST'), true, $donnee); |
||||||
0 ignored issues
–
show
$donnee of type array is incompatible with the type boolean expected by parameter $action of XoopsModules\Tdmdownloads\Downloads::getForm() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() Xmf\Request::getInt('lid', 0, 'REQUEST') of type integer is incompatible with the type array expected by parameter $donnee of XoopsModules\Tdmdownloads\Downloads::getForm() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
257 | $xoopsTpl->assign('themeForm', $form->render()); |
||||||
258 | break; |
||||||
259 | } |
||||||
260 | require XOOPS_ROOT_PATH . '/footer.php'; |
||||||
261 |