Issues (167)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

submit.php (1 issue)

Labels
Severity
1
<?php
2
3
use XoopsModules\Tag\{
4
    Helper as TagHelper,
5
    Tag,
6
    TagHandler
7
};
8
use XoopsModules\Tdmdownloads\{
9
    Helper
10
};
11
12
/**
13
 * TDMDownload
14
 *
15
 * You may not change or alter any portion of this comment or credits
16
 * of supporting developers from this source code or any supporting source code
17
 * which is considered copyrighted (c) material of the original comment or credit authors.
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21
 *
22
 * @copyright   Gregory Mage (Aka Mage)
23
 * @license     GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
24
 * @author      Gregory Mage (Aka Mage)
25
 */
26
require_once __DIR__ . '/header.php';
27
$moduleDirName = basename(__DIR__);
28
$helper = Helper::getInstance();
29
// template d'affichage
30
$GLOBALS['xoopsOption']['template_main'] = 'tdmdownloads_submit.tpl';
31
require_once XOOPS_ROOT_PATH . '/header.php';
32
/** @var \xos_opal_Theme $xoTheme */
33
$xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $moduleDirName . '/assets/css/styles.css', null);
34
//On recupere la valeur de l'argument op dans l'URL$
35
$op  = \Xmf\Request::getString('op', 'list');
36
$lid = \Xmf\Request::getInt('lid', 0, 'REQUEST');
37
// redirection si pas de droit pour poster
38
if (false === $perm_submit) {
39
    redirect_header('index.php', 2, _NOPERM);
40
}
41
// user must have perm to autoapprove if he want to modify, otherwise modfile.php must be used
42
if (false === $perm_autoapprove && $lid > 0) {
43
    redirect_header('index.php', 2, _NOPERM);
44
}
45
//Les valeurs de op qui vont permettre d'aller dans les differentes parties de la page
46
switch ($op) {
47
    // Vue liste
48
    case 'list':
49
        //navigation
50
        $navigation = _MD_TDMDOWNLOADS_SUBMIT_PROPOSER;
51
        $xoopsTpl->assign('navigation', $navigation);
52
        // référencement
53
        // titre de la page
54
        $titre = _MD_TDMDOWNLOADS_SUBMIT_PROPOSER . '&nbsp;-&nbsp;';
55
        $titre .= $xoopsModule->name();
56
        $xoopsTpl->assign('xoops_pagetitle', $titre);
57
        //description
58
        $xoTheme->addMeta('meta', 'description', strip_tags(_MD_TDMDOWNLOADS_SUBMIT_PROPOSER));
59
        //Affichage du formulaire de notation des téléchargements
60
        /** @var \XoopsModules\Tdmdownloads\Downloads $obj */
61
        $obj = $downloadsHandler->create();
62
        $form = $obj->getForm($donnee = [], false);
63
        $xoopsTpl->assign('themeForm', $form->render());
64
        break;
65
    // save
66
    case 'save_downloads':
67
        require_once XOOPS_ROOT_PATH . '/class/uploader.php';
68
        $newUpload = true;
69
        /** @var \XoopsModules\Tdmdownloads\Downloads $obj */
70
        if (true === $perm_autoapprove && $lid > 0) {
71
            $obj       = $downloadsHandler->get($lid);
72
            $newUpload = false;
73
        } else {
74
            $obj = $downloadsHandler->create();
75
        }
76
        $erreur       = false;
77
        $errorMessage = '';
78
        $donnee       = [];
79
        $obj->setVar('title', \Xmf\Request::getString('title', '', 'POST'));
80
        $donnee['title'] = \Xmf\Request::getString('title', '', 'POST');
81
        $obj->setVar('cid', \Xmf\Request::getString('cid', '', 'POST'));
82
        $donnee['cid'] = \Xmf\Request::getString('cid', '', 'POST');
83
        $obj->setVar('homepage', formatURL(\Xmf\Request::getString('homepage', '', 'POST')));
84
        $obj->setVar('version', \Xmf\Request::getString('version', '', 'POST'));
85
        $obj->setVar('paypal', \Xmf\Request::getString('paypal', '', 'POST'));
86
        if (\Xmf\Request::hasVar('platform', 'POST')) {
87
            $obj->setVar('platform', implode('|', \Xmf\Request::getString('platform', '', 'POST')));
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 ignore-type  annotation

87
            $obj->setVar('platform', implode('|', /** @scrutinizer ignore-type */ \Xmf\Request::getString('platform', '', 'POST')));
Loading history...
88
        }
89
        $obj->setVar('description', \Xmf\Request::getString('description', '', 'POST'));
90
        if (\Xmf\Request::hasVar('submitter', 'POST')) {
91
            $obj->setVar('submitter', \Xmf\Request::getString('submitter', '', 'POST'));
92
            $donnee['submitter'] = \Xmf\Request::getString('submitter', '', 'POST');
93
        } else {
94
            $obj->setVar('submitter', !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0);
95
            $donnee['submitter'] = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0;
96
        }
97
        $obj->setVar('date', time());
98
        if (true === $perm_autoapprove) {
99
            $obj->setVar('status', 1);
100
        } else {
101
            $obj->setVar('status', 0);
102
        }
103
        if ($xoopsUser) {
104
            if ($xoopsUser->isAdmin($xoopsModule->mid())) {
105
                if (\Xmf\Request::hasVar('status', 'POST')) {
106
                    $obj->setVar('status', \Xmf\Request::getInt('status', 0, 'POST'));
107
                    $donnee['status'] = \Xmf\Request::getInt('status', 0, 'POST');
108
                } else {
109
                    $obj->setVar('status', 0);
110
                    $donnee['status'] = 0;
111
                }
112
            }
113
        }
114
        $donnee['date_update'] = 0;
115
        // erreur si la catégorie est vide
116
        if (\Xmf\Request::hasVar('cid', 'REQUEST')) {
117
            if (0 === \Xmf\Request::getInt('cid', 0, 'REQUEST')) {
118
                $erreur       = true;
119
                $errorMessage .= _MD_TDMDOWNLOADS_ERREUR_NOCAT . '<br>';
120
            }
121
        }
122
        // erreur si le captcha est faux
123
        xoops_load('xoopscaptcha');
124
        $xoopsCaptcha = \XoopsCaptcha::getInstance();
125
        if (!$xoopsCaptcha->verify()) {
126
            $errorMessage .= $xoopsCaptcha->getMessage() . '<br>';
127
            $erreur       = true;
128
        }
129
        // pour enregistrer temporairement les valeur des champs sup
130
        $criteria = new \CriteriaCompo();
131
        $criteria->setSort('weight ASC, title');
132
        $criteria->setOrder('ASC');
133
        $downloads_field = $fieldHandler->getAll($criteria);
134
        foreach (array_keys($downloads_field) as $i) {
135
            /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */
136
            if (0 === $downloads_field[$i]->getVar('status_def')) {
137
                $fieldName          = 'champ' . $downloads_field[$i]->getVar('fid');
138
                $donnee[$fieldName] = \Xmf\Request::getString($fieldName, '', 'POST');
139
            }
140
        }
141
        // enregistrement temporaire des tags
142
        if (1 == $helper->getConfig('usetag') && class_exists(Tag::class)) {
143
            $donnee['TAG'] = $_POST['tag'];
144
        }
145
        if (true === $erreur) {
146
            $xoopsTpl->assign('message_erreur', $errorMessage);
147
            /** @var \XoopsThemeForm $form */
148
            $form = $obj->getForm($donnee, true);
149
            $GLOBALS['xoopsTpl']->assign('themeForm', $form->render());
150
            break;
151
        }
152
        $obj->setVar('size', \Xmf\Request::getString('size', '', 'POST') . ' ' . \Xmf\Request::getString('type_size', '', 'POST'));
153
        // Pour le fichier
154
        $mediaSize = 0;
155
        if (isset($_POST['xoops_upload_file'][0])) {
156
            $uploader = new \XoopsMediaUploader($uploaddir_downloads, $helper->getConfig('mimetypes'), $helper->getConfig('maxuploadsize'), null, null);
157
            if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
158
                if ($helper->getConfig('newnamedownload')) {
159
                    $uploader->setPrefix($helper->getConfig('prefixdownloads'));
160
                }
161
                $uploader->fetchMedia($_POST['xoops_upload_file'][0]);
162
                if (!$uploader->upload()) {
163
                    $errors = $uploader->getErrors();
164
                    redirect_header('javascript:history.go(-1)', 3, $errors);
165
                } else {
166
                    $mediaSize = $uploader->getMediaSize();
167
                    $obj->setVar('url', $uploadurl_downloads . $uploader->getSavedFileName());
168
                }
169
            } else {
170
                if ($_FILES['attachedfile']['name'] > '') {
171
                    // file name was given, but fetchMedia failed - show error when e.g. file size exceed maxuploadsize
172
                    $errorMessage .= $uploader->getErrors() . '<br>';
173
                    $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage);
174
                    $form = $obj->getForm($donnee, true);
175
                    $GLOBALS['xoopsTpl']->assign('themeForm', $form->render());
176
                    break;
177
                }
178
                $obj->setVar('url', \Xmf\Request::getString('url', '', 'REQUEST'));
179
            }
180
        } else {
181
            $obj->setVar('url', \Xmf\Request::getString('url', '', 'REQUEST'));
182
        }
183
        // Pour l'image
184
        if (isset($_POST['xoops_upload_file'][1])) {
185
            $uploader_2 = new \XoopsMediaUploader(
186
                $uploaddir_shots, [
187
                                    'image/gif',
188
                                    'image/jpeg',
189
                                    'image/pjpeg',
190
                                    'image/x-png',
191
                                    'image/png',
192
                                ], $helper->getConfig('maxuploadsize'), null, null
193
            );
194
            if ($uploader_2->fetchMedia($_POST['xoops_upload_file'][1])) {
195
                $uploader_2->setPrefix('downloads_');
196
                $uploader_2->fetchMedia($_POST['xoops_upload_file'][1]);
197
                if (!$uploader_2->upload()) {
198
                    $errors = $uploader_2->getErrors();
199
                    redirect_header('javascript:history.go(-1)', 3, $errors);
200
                } else {
201
                    $obj->setVar('logourl', $uploader_2->getSavedFileName());
202
                }
203
            } else {
204
                if ($_FILES['attachedimage']['name'] > '') {
205
                    // file name was given, but fetchMedia failed - show error when e.g. file size exceed maxuploadsize
206
                    $errorMessage .= $uploader_2->getErrors() . '<br>';
207
                    $GLOBALS['xoopsTpl']->assign('message_erreur', $errorMessage);
208
                    $form = $obj->getForm($donnee, true);
209
                    $GLOBALS['xoopsTpl']->assign('themeForm', $form->render());
210
                    break;
211
                }
212
                $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'REQUEST'));
213
            }
214
        } else {
215
            $obj->setVar('logourl', \Xmf\Request::getString('logo_img', '', 'REQUEST'));
216
        }
217
        //Automatic file size
218
        if ('' == Xmf\Request::getString('sizeValue', '')) {
219
            if (0 == $mediaSize) {
220
                $obj->setVar('size', $utility::getFileSize(Xmf\Request::getUrl('url', '')));
221
            } else {
222
                $obj->setVar('size', $utility::convertFileSize($mediaSize));
223
            }
224
        } else {
225
            $obj->setVar('size', Xmf\Request::getFloat('sizeValue', 0) . ' ' . Xmf\Request::getString('sizeType', ''));
226
        }
227
        $timeToRedirect = 2;
228
        if (0 == $obj->getVar('size')) {
229
            $obj->setVar('size', '');
230
            $error_message  = _AM_TDMDOWNLOADS_ERREUR_SIZE;
231
            $timeToRedirect = 10;
232
        }
233
        if ($downloadsHandler->insert($obj)) {
234
            if ($newUpload) {
235
                $lidDownloads = $obj->getNewEnreg($db);
236
            } else {
237
                $lidDownloads = $lid;
238
            }
239
            //tags
240
            if (1 == $helper->getConfig('usetag') && class_exists(TagHandler::class)) {
241
                /** @var \XoopsModules\Tag\TagHandler $tagHandler */
242
                $tagHandler = TagHelper::getInstance()->getHandler('Tag');
243
                $tagHandler->updateByItem($_POST['tag'], $lidDownloads, $moduleDirName, 0);
244
            }
245
            // Récupération des champs supplémentaires:
246
            $criteria = new \CriteriaCompo();
247
            $criteria->setSort('weight ASC, title');
248
            $criteria->setOrder('ASC');
249
            $downloads_field = $fieldHandler->getAll($criteria);
250
            foreach (array_keys($downloads_field) as $i) {
251
                if (0 === $downloads_field[$i]->getVar('status_def')) {
252
                    $objdata   = $fielddataHandler->create();
253
                    $fieldName = 'champ' . $downloads_field[$i]->getVar('fid');
254
                    $objdata->setVar('data', \Xmf\Request::getString($fieldName, '', 'POST'));
255
                    $objdata->setVar('lid', $lidDownloads);
256
                    $objdata->setVar('fid', $downloads_field[$i]->getVar('fid'));
257
                    $fielddataHandler->insert($objdata) || $objdata->getHtmlErrors();
258
                }
259
            }
260
            if ($xoopsUser) {
261
                if ($xoopsUser->isAdmin($xoopsModule->mid())) {
262
                    //permission pour télécharger
263
                    if (1 == $helper->getConfig('permission_download')) {
264
                        /** @var \XoopsGroupPermHandler $grouppermHandler */
265
                        $grouppermHandler = xoops_getHandler('groupperm');
266
                        $criteria         = new \CriteriaCompo();
267
                        $criteria->add(new \Criteria('gperm_itemid', $lidDownloads, '='));
268
                        $criteria->add(new \Criteria('gperm_modid', $xoopsModule->getVar('mid'), '='));
269
                        $criteria->add(new \Criteria('gperm_name', 'tdmdownloads_download_item', '='));
270
                        $grouppermHandler->deleteAll($criteria);
271
                        if (\Xmf\Request::hasVar('item_download', 'POST')) {
272
                            foreach ($_POST['item_download'] as $onegroup_id) {
273
                                $grouppermHandler->addRight('tdmdownloads_download_item', $lidDownloads, $onegroup_id, $xoopsModule->getVar('mid'));
274
                            }
275
                        }
276
                    }
277
                }
278
            }
279
            /** @var \XoopsNotificationHandler $notificationHandler */
280
            $notificationHandler   = xoops_getHandler('notification');
281
            $tags                  = [];
282
            $tags['FILE_NAME']     = $donnee['title'];
283
            $tags['FILE_URL']      = XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?cid=' . $donnee['cid'] . '&lid=' . $lidDownloads;
284
            $downloadscat_cat      = $categoryHandler->get($donnee['cid']);
285
            $tags['CATEGORY_NAME'] = $downloadscat_cat->getVar('cat_title');
286
            $tags['CATEGORY_URL']  = XOOPS_URL . '/modules/' . $moduleDirName . '/viewcat.php?cid=' . $donnee['cid'];
287
            if (true === $perm_autoapprove) {
288
                $notificationHandler->triggerEvent('global', 0, 'new_file', $tags);
289
                $notificationHandler->triggerEvent('category', $donnee['cid'], 'new_file', $tags);
290
                redirect_header('index.php', $timeToRedirect, _MD_TDMDOWNLOADS_SUBMIT_RECEIVED . '<br>' . _MD_TDMDOWNLOADS_SUBMIT_ISAPPROVED . '<br><br>' . $error_message);
291
                exit;
292
            }
293
            $tags['WAITINGFILES_URL'] = XOOPS_URL . '/modules/' . $moduleDirName . '/admin/index.php?op=listNewDownloads';
294
            $notificationHandler->triggerEvent('global', 0, 'file_submit', $tags);
295
            $notificationHandler->triggerEvent('category', $donnee['cid'], 'file_submit', $tags);
296
            redirect_header('index.php', $timeToRedirect, _MD_TDMDOWNLOADS_SUBMIT_RECEIVED . '<br><br>' . $error_message);
297
            exit;
298
        }
299
        $errors = $obj->getHtmlErrors();
300
        $form   = $obj->getForm($donnee, true);
301
        $xoopsTpl->assign('themeForm', $form->render());
302
        break;
303
}
304
$GLOBALS['xoopsTpl']->assign('mod_url', XOOPS_URL . '/modules/' . $moduleDirName);
305
require XOOPS_ROOT_PATH . '/footer.php';
306