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.

admin/modified.php (1 issue)

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\Helper;
21
22
require __DIR__ . '/admin_header.php';
23
// Template
24
$templateMain = 'tdmdownloads_admin_modified.tpl';
25
$helper = Helper::getInstance();
26
//On recupere la valeur de l'argument op dans l'URL$
27
$op = \Xmf\Request::getCmd('op', 'list');
28
xoops_cp_header();
29
//Les valeurs de op qui vont permettre d'aller dans les differentes parties de la page
30
switch ($op) {
31
    // show list
32
    case 'list':
33
        $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__)));
34
        $criteria = new \CriteriaCompo();
35
        if (\Xmf\Request::hasVar('limit', 'REQUEST')) {
36
            $criteria->setLimit(\Xmf\Request::getInt('limit', 0, 'REQUEST'));
37
            $limit = \Xmf\Request::getInt('limit', 0, 'REQUEST');
38
        } else {
39
            $criteria->setLimit($helper->getConfig('perpageadmin'));
40
            $limit = $helper->getConfig('perpageadmin');
41
        }
42
        if (\Xmf\Request::hasVar('start', 'REQUEST')) {
43
            $criteria->setStart(\Xmf\Request::getInt('start', 0, 'REQUEST'));
44
            $start = \Xmf\Request::getInt('start', 0, 'REQUEST');
45
        } else {
46
            $criteria->setStart(0);
47
            $start = 0;
48
        }
49
        $criteria->setSort('requestid');
50
        $criteria->setOrder('ASC');
51
        $downloadsmod_arr = $modifiedHandler->getAll($criteria);
52
        //        $numrows          = $modifiedHandler->getCount($criteria);
53
        $numrows = $modifiedHandler->getCount(); //Ggoffy
54
        if ($numrows > $limit) {
55
            $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'op=liste&limit=' . $limit);
56
            $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4));
57
        } else {
58
            $pagenav = '';
59
        }
60
        //Affichage du tableau des téléchargements modifiés
61
        if ($numrows > 0) {
62
            $GLOBALS['xoopsTpl']->assign('modified_count', $numrows);
63
            foreach (array_keys($downloadsmod_arr) as $i) {
64
                /** @var \XoopsModules\Tdmdownloads\Modified[] $downloadsmod_arr */
65
                $downloads = $downloadsHandler->get($downloadsmod_arr[$i]->getVar('lid'));
66
                // pour savoir si le fichier est nouveau
67
                $downloads_url    = $downloads->getVar('url');
68
                $moddownloads_url = $downloadsmod_arr[$i]->getVar('url');
69
                $new_file         = ($downloads_url != $moddownloads_url);
70
                $modified         = [
71
                    'lid'             => $downloadsmod_arr[$i]->getVar('lid'),
72
                    'requestid'       => $downloadsmod_arr[$i]->getVar('requestid'),
73
                    'new_file'        => $new_file,
74
                    'download_title'  => $downloads->getVar('title'),
75
                    'modifysubmitter' => XoopsUser::getUnameFromId($downloadsmod_arr[$i]->getVar('modifysubmitter')),
76
                ];
77
                $GLOBALS['xoopsTpl']->append('modified_list', $modified);
78
                unset($modified);
79
            }
80
        } else {
81
            $GLOBALS['xoopsTpl']->assign('message_erreur', _AM_TDMDOWNLOADS_ERREUR_NOBMODDOWNLOADS);
82
        }
83
        break;
84
    // show a comparision of the versions
85
    case 'view_downloads':
86
        $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__)));
87
        $adminObject->addItemButton(_MI_TDMDOWNLOADS_ADMENU5, 'modified.php', 'list');
88
        $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left'));
89
        //information du téléchargement
90
        $viewDownloads = $downloadsHandler->get(\Xmf\Request::getInt('downloads_lid', 0, 'REQUEST'));
91
        //information du téléchargement modifié
92
        $viewModdownloads = $modifiedHandler->get(\Xmf\Request::getInt('mod_id', 0, 'REQUEST'));
93
        // original
94
        $downloads_title = $viewDownloads->getVar('title');
95
        $downloads_url   = $viewDownloads->getVar('url');
96
        //catégorie
97
        $view_category         = $categoryHandler->get($viewDownloads->getVar('cid'));
98
        $downloads_category    = $view_category->getVar('cat_title');
99
        $downloads_homepage    = $viewDownloads->getVar('homepage');
100
        $downloads_version     = $viewDownloads->getVar('version');
101
        $downloads_size        = $viewDownloads->getVar('size');
102
        $downloads_platform    = $viewDownloads->getVar('platform');
103
        $downloads_description = $viewDownloads->getVar('description');
104
        $downloads_logourl     = $viewDownloads->getVar('logourl');
105
        // modifié
106
        $moddownloads_title = $viewModdownloads->getVar('title');
107
        $moddownloads_url   = $viewModdownloads->getVar('url');
108
        //catégorie
109
        $view_category            = $categoryHandler->get($viewModdownloads->getVar('cid'));
110
        $moddownloads_category    = $view_category->getVar('cat_title');
111
        $moddownloads_homepage    = $viewModdownloads->getVar('homepage');
112
        $moddownloads_version     = $viewModdownloads->getVar('version');
113
        $moddownloads_size        = $viewModdownloads->getVar('size');
114
        $moddownloads_platform    = $viewModdownloads->getVar('platform');
115
        $moddownloads_description = $viewModdownloads->getVar('description');
116
        $moddownloads_logourl     = $viewModdownloads->getVar('logourl');
117
        $compare['title']         = ['info' => _AM_TDMDOWNLOADS_FORMTITLE, 'current' => $downloads_title, 'modified' => $moddownloads_title];
118
        $compare['description']   = ['info' => _AM_TDMDOWNLOADS_FORMTEXT, 'current' => $downloads_description, 'modified' => $moddownloads_description];
119
        $compare['url']           = ['info' => _AM_TDMDOWNLOADS_FORMURL, 'current' => $downloads_url, 'modified' => $moddownloads_url];
120
        $compare['category']      = ['info' => _AM_TDMDOWNLOADS_FORMCAT, 'current' => $downloads_category, 'modified' => $moddownloads_category];
121
        $criteria                 = new \CriteriaCompo();
122
        $criteria->setSort('weight ASC, title');
123
        $criteria->setOrder('ASC');
124
        $criteria->add(new \Criteria('status', 1));
125
        $downloads_field = $fieldHandler->getAll($criteria);
126
        foreach (array_keys($downloads_field) as $i) {
127
            /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */
128
            if (1 == $downloads_field[$i]->getVar('status_def')) {
129
                if (1 == $downloads_field[$i]->getVar('fid')) {
130
                    //page d'accueil
131
                    $compare['cfields'][] = ['info' => _AM_TDMDOWNLOADS_FORMHOMEPAGE, 'current' => $downloads_homepage, 'modified' => $moddownloads_homepage];
132
                }
133
                if (2 == $downloads_field[$i]->getVar('fid')) {
134
                    //version
135
                    $compare['cfields'][] = ['info' => _AM_TDMDOWNLOADS_FORMVERSION, 'current' => $downloads_version, 'modified' => $moddownloads_version];
136
                }
137
                if (3 == $downloads_field[$i]->getVar('fid')) {
138
                    //taille du fichier
139
                    $compare['cfields'][] = ['info' => _AM_TDMDOWNLOADS_FORMSIZE_WHEN_SUBMIT, 'current' => $downloads_size, 'modified' => $moddownloads_size];
140
                }
141
                if (4 == $downloads_field[$i]->getVar('fid')) {
142
                    //plateforme
143
                    $compare['cfields'][] = ['info' => _AM_TDMDOWNLOADS_FORMPLATFORM, 'current' => $downloads_platform, 'modified' => $moddownloads_platform];
144
                }
145
            } else {
146
                //original
147
                $contenu  = '';
148
                $criteria = new \CriteriaCompo();
149
                $criteria->add(new \Criteria('lid', \Xmf\Request::getInt('downloads_lid', 0, 'REQUEST')));
150
                $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid')));
151
                $downloadsfielddata = $fielddataHandler->getAll($criteria);
152
                foreach (array_keys($downloadsfielddata) as $j) {
153
                    /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloadsfielddata */
154
                    //                    $contenu = $downloadsfielddata[$j]->getVar('data');
155
                    $contenu = $downloadsfielddata[$j]->getVar('data', 'e');
156
                }
157
                //proposé
158
                $contentModified = '';
159
                $criteria        = new \CriteriaCompo();
160
                $criteria->add(new \Criteria('lid', \Xmf\Request::getInt('mod_id', 0, 'REQUEST')));
161
                $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid')));
162
                $downloadsfieldmoddata = $modifieddataHandler->getAll($criteria);
163
                foreach (array_keys($downloadsfieldmoddata) as $j) {
164
                    /** @var \XoopsModules\Tdmdownloads\Modified[] $downloadsfieldmoddata */
165
                    $contentModified = $downloadsfieldmoddata[$j]->getVar('moddata', 'e');
166
                }
167
                //                echo '<tr><td valign="top" width="40%"><small><span class="' . ($contenu == $contentModified ? 'style_ide' : 'style_dif') . '">' . $downloads_field[$i]->getVar('title') . '</span>: ' . $contentModified . '</small></td></tr>';
168
                $compare['cfields'][] = ['info' => $downloads_field[$i]->getVar('title'), 'current' => $contenu, 'modified' => $contentModified];
169
            }
170
        }
171
        $compare['img'] = ['info' => _AM_TDMDOWNLOADS_FORMIMG, 'current' => $downloads_logourl, 'modified' => $moddownloads_logourl];
172
        //permet de savoir si le fichier est nouveau
173
        $new_file = ($downloads_url != $moddownloads_url);
174
        $buttons  = [
175
            myTextForm('modified.php?op=approve&mod_id=' . \Xmf\Request::getInt('mod_id', 0, 'GET') . '&new_file=' . $new_file, _AM_TDMDOWNLOADS_FORMAPPROVE),
176
            myTextForm('downloads.php?op=edit_downloads&downloads_lid=' . \Xmf\Request::getInt('downloads_lid', 0, 'GET'), _AM_TDMDOWNLOADS_FORMEDIT),
177
            myTextForm('modified.php?op=del_moddownloads&mod_id=' . \Xmf\Request::getInt('mod_id', 0, 'GET') . '&new_file=' . $new_file, _AM_TDMDOWNLOADS_FORMIGNORE),
178
        ];
179
        $GLOBALS['xoopsTpl']->assign('compare_list', $compare);
180
        $GLOBALS['xoopsTpl']->assign('cbuttons', $buttons);
181
        $GLOBALS['xoopsTpl']->assign('uploadurl_shots', $uploadurl_shots);
182
        break;
183
    // permet de suprimmer le téléchargment modifié
184
    case 'del_moddownloads':
185
        $obj = $modifiedHandler->get(\Xmf\Request::getInt('mod_id', 0, 'REQUEST'));
186
        if (1 === \Xmf\Request::getInt('ok', 0, 'POST')) {
187
            if (!$GLOBALS['xoopsSecurity']->check()) {
188
                redirect_header('downloads.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
189
            }
190
            if (true === \Xmf\Request::getBool('new_file', false, 'REQUEST')) {
191
                $urlfile = substr_replace($obj->getVar('url'), '', 0, mb_strlen($uploadurl_downloads));
192
                // permet de donner le chemin du fichier
193
                $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 ignore-type  annotation

193
                $urlfile = $uploaddir_downloads . /** @scrutinizer ignore-type */ $urlfile;
Loading history...
194
                // si le fichier est sur le serveur il es détruit
195
                if (is_file($urlfile)) {
196
                    chmod($urlfile, 0777);
197
                    unlink($urlfile);
198
                }
199
            }
200
            // supression des data des champs sup
201
            $criteria = new \CriteriaCompo();
202
            $criteria->add(new \Criteria('lid', \Xmf\Request::getInt('mod_id', 0, 'REQUEST')));
203
            $downloads_fielddata = $modifieddataHandler->getAll($criteria);
204
            foreach (array_keys($downloads_fielddata) as $i) {
205
                /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloads_fielddata */
206
                $objfielddata = $modifieddataHandler->get($downloads_fielddata[$i]->getVar('modiddata'));
207
                $modifieddataHandler->delete($objfielddata) || $objvfielddata->getHtmlErrors();
208
            }
209
            if ($modifiedHandler->delete($obj)) {
210
                redirect_header('modified.php', 1, _AM_TDMDOWNLOADS_REDIRECT_DELOK);
211
            }
212
            $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors());
213
        } else {
214
            $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__)));
215
            $adminObject->addItemButton(_MI_TDMDOWNLOADS_ADMENU5, 'modified.php', 'list');
216
            $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left'));
217
            xoops_confirm(
218
                [
219
                    'ok'       => 1,
220
                    'mod_id'   => \Xmf\Request::getInt('mod_id', 0, 'REQUEST'),
221
                    'new_file' => \Xmf\Request::getString('new_file', 0, 'REQUEST'),
222
                    'op'       => 'del_moddownloads',
223
                ],
224
                $_SERVER['REQUEST_URI'],
225
                _AM_TDMDOWNLOADS_MODIFIED_SURDEL . '<br>'
226
            );
227
        }
228
        break;
229
    // permet d'accépter la modification
230
    case 'approve':
231
        // choix du téléchargement:
232
        $viewModdownloads = $modifiedHandler->get(\Xmf\Request::getInt('mod_id', 0, 'REQUEST'));
233
        $obj              = $downloadsHandler->get($viewModdownloads->getVar('lid'));
234
        // delete the current file if a new proposed file is accepted.
235
        if (true === \Xmf\Request::getBool('new_file', false, 'REQUEST')) {
236
            $urlfile = substr_replace($obj->getVar('url'), '', 0, mb_strlen($uploadurl_downloads));
237
            // permet de donner le chemin du fichier
238
            $urlfile = $uploaddir_downloads . $urlfile;
239
            // si le fichier est sur le serveur il es détruit
240
            if (is_file($urlfile)) {
241
                chmod($urlfile, 0777);
242
                unlink($urlfile);
243
            }
244
        }
245
        // mise à jour:
246
        $obj->setVar('title', $viewModdownloads->getVar('title'));
247
        $obj->setVar('url', $viewModdownloads->getVar('url'));
248
        $obj->setVar('cid', $viewModdownloads->getVar('cid'));
249
        $obj->setVar('homepage', $viewModdownloads->getVar('homepage'));
250
        $obj->setVar('version', $viewModdownloads->getVar('version'));
251
        $obj->setVar('size', $viewModdownloads->getVar('size'));
252
        $obj->setVar('platform', $viewModdownloads->getVar('platform'));
253
        $obj->setVar('description', $viewModdownloads->getVar('description'));
254
        $obj->setVar('logourl', $viewModdownloads->getVar('logourl'));
255
        $obj->setVar('date', time());
256
        $obj->setVar('status', 2);
257
        // Récupération des champs supplémentaires:
258
        $criteria = new \CriteriaCompo();
259
        $criteria->setSort('weight ASC, title');
260
        $criteria->setOrder('ASC');
261
        $downloads_field = $fieldHandler->getAll($criteria);
262
        foreach (array_keys($downloads_field) as $i) {
263
            /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */
264
            $contenu = '';
265
            $iddata  = 0;
266
            if (0 == $downloads_field[$i]->getVar('status_def')) {
267
                $criteria = new \CriteriaCompo();
268
                $criteria->add(new \Criteria('lid', $viewModdownloads->getVar('requestid')));
269
                $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid')));
270
                $downloadsfieldmoddata = $modifieddataHandler->getAll($criteria);
271
                foreach (array_keys($downloadsfieldmoddata) as $j) {
272
                    /** @var \XoopsModules\Tdmdownloads\Modified[] $downloadsfieldmoddata */
273
                    $contenu = $downloadsfieldmoddata[$j]->getVar('moddata');
274
                }
275
                $criteria = new \CriteriaCompo();
276
                $criteria->add(new \Criteria('lid', $viewModdownloads->getVar('lid')));
277
                $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid')));
278
                $downloadsfielddata = $fielddataHandler->getAll($criteria);
279
                foreach (array_keys($downloadsfielddata) as $j) {
280
                    /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloadsfielddata */
281
                    $iddata = $downloadsfielddata[$j]->getVar('iddata');
282
                }
283
                if (0 == $iddata) {
284
                    $objdata = $fielddataHandler->create();
285
                    $objdata->setVar('fid', $downloads_field[$i]->getVar('fid'));
286
                    $objdata->setVar('lid', $viewModdownloads->getVar('lid'));
287
                } else {
288
                    $objdata = $fielddataHandler->get($iddata);
289
                }
290
                $objdata->setVar('data', $contenu);
291
                $fielddataHandler->insert($objdata) || $objdata->getHtmlErrors();
292
            }
293
        }
294
        // supression du rapport de modification
295
        $objmod = $modifiedHandler->get(\Xmf\Request::getInt('mod_id', 0, 'REQUEST'));
296
        $modifiedHandler->delete($objmod);
297
        // supression des data des champs sup
298
        $criteria = new \CriteriaCompo();
299
        $criteria->add(new \Criteria('lid', \Xmf\Request::getInt('mod_id', 0, 'REQUEST')));
300
        $downloads_fielddata = $modifieddataHandler->getAll($criteria);
301
        foreach (array_keys($downloads_fielddata) as $i) {
302
            /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloads_fielddata */
303
            $objfielddata = $modifieddataHandler->get($downloads_fielddata[$i]->getVar('modiddata'));
304
            $modifieddataHandler->delete($objfielddata) || $objvfielddata->getHtmlErrors();
305
        }
306
        // enregistrement
307
        if ($downloadsHandler->insert($obj)) {
308
            redirect_header('modified.php', 1, _AM_TDMDOWNLOADS_REDIRECT_SAVE);
309
        }
310
        $GLOBALS['xoopsTpl']->assign('message_erreur', $obj->getHtmlErrors());
311
        break;
312
}
313
// Local icons path
314
if (is_object($helper->getModule())) {
315
    $pathModIcon16 = $helper->getModule()->getInfo('modicons16');
316
    $pathModIcon32 = $helper->getModule()->getInfo('modicons32');
317
    $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16);
318
    $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32);
319
}
320
require __DIR__ . '/admin_footer.php';
321