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.

search.php (3 issues)

Labels
Severity
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
    CategoryHandler,
22
    Downloads,
23
    DownloadsHandler,
24
    Helper,
25
    Tree,
26
    Utility
27
};
28
29
/** @var Helper $helper */
30
/** @var Utility $utility */
31
/** @var CategoryHandler $categoryHandler */
32
/** @var FieldHandler $fieldHandler */
33
require_once __DIR__ . '/header.php';
34
$moduleDirName    = basename(__DIR__);
35
$helper           = Helper::getInstance();
36
$utility          = new Utility();
37
$downloadsHandler = $helper->getHandler('Downloads');
38
require __DIR__ . '/include/common.php';
39
// template d'affichage
40
$GLOBALS['xoopsOption']['template_main'] = 'tdmdownloads_liste.tpl';
41
require_once XOOPS_ROOT_PATH . '/header.php';
42
/** @var \xos_opal_Theme $xoTheme */
43
$xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $moduleDirName . '/assets/css/styles.css', null);
44
$categories = $utility->getItemIds('tdmdownloads_view', $moduleDirName);
45
$title      = '';
46
if (\Xmf\Request::hasVar('title', 'REQUEST')) {
47
    $title = \Xmf\Request::getString('title', '', 'REQUEST');
48
}
49
$cat = 0;
50
if (\Xmf\Request::hasVar('cat', 'REQUEST')) {
51
    $cat = \Xmf\Request::getInt('cat', 0, 'REQUEST');
52
}
53
// tableau ------
54
$criteria_2 = new \CriteriaCompo();
55
$criteria_2->add(new \Criteria('status', 0, '!='));
56
$criteria_2->add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN'));
57
// ------
58
//formulaire de recherche
59
$form = new \XoopsThemeForm(_MD_TDMDOWNLOADS_SEARCH, 'search', 'search.php', 'post');
60
$form->setExtra('enctype="multipart/form-data"');
61
//recherche par titre
62
$form->addElement(new \XoopsFormText(_MD_TDMDOWNLOADS_SEARCH_TITLE, 'title', 25, 255, $title));
63
//recherche par catégorie
64
$criteria = new \CriteriaCompo();
65
$criteria->setSort('cat_weight ASC, cat_title');
66
$criteria->setOrder('ASC');
67
$criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN'));
68
/*$cat_select = new \XoopsFormSelect(_MD_TDMDOWNLOADS_SEARCH_CATEGORIES . ' ', 'cat', $cat);
69
$cat_select->addOption(0,_MD_TDMDOWNLOADS_SEARCH_ALL2);
70
$cat_select->addOptionArray($categoryHandler->getList($criteria ));
71
$form->addElement($cat_select);*/
72
$downloadscatArray = $categoryHandler->getAll($criteria);
73
$mytree            = new Tree($downloadscatArray, 'cat_cid', 'cat_pid');
74
$form->addElement($mytree->makeSelectElement('cat', 'cat_title', '--', $cat, true, 0, '', _AM_TDMDOWNLOADS_FORMINCAT), true);
75
//recherche champ sup.
76
//$fieldHandler = Helper::getInstance()->getHandler('Field');
77
$criteria = new \CriteriaCompo();
78
$criteria->add(new \Criteria('search', 1));
79
$criteria->add(new \Criteria('status', 1));
80
$criteria->setSort('weight ASC, title');
81
$criteria->setOrder('ASC');
82
$downloads_field = $fieldHandler->getAll($criteria);
83
$arguments       = '';
84
foreach (array_keys($downloads_field) as $i) {
85
    /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */
86
    $title_sup    = '';
87
    $contentArray = [];
88
    $lid_arr      = [];
89
    $fieldName    = 'champ' . $downloads_field[$i]->getVar('fid');
90
    $criteria     = new \CriteriaCompo();
91
    if (\Xmf\Request::hasVar($fieldName, 'REQUEST')) {
92
        999 !== \Xmf\Request::getInt($fieldName, 0, 'REQUEST') ? $fieldContent[$downloads_field[$i]->getVar('fid')] = \Xmf\Request::getInt($fieldName, 0, 'REQUEST') : $fieldContent[$downloads_field[$i]->getVar('fid')] = 999;
93
        $arguments .= $fieldName . '=' . \Xmf\Request::getInt($fieldName, 0, 'REQUEST') . '&amp;';
94
    } else {
95
        $fieldContent[$downloads_field[$i]->getVar('fid')] = 999;
96
        $arguments                                         .= $fieldName . '=&amp;';
97
    }
98
    if (1 == $downloads_field[$i]->getVar('status_def')) {
99
        $criteria->add(new \Criteria('status', 0, '!='));
100
        if (1 == $downloads_field[$i]->getVar('fid')) {
101
            //page d'accueil
102
            $title_sup = _AM_TDMDOWNLOADS_FORMHOMEPAGE;
103
            $criteria->setSort('homepage');
104
            $fieldNameBase = 'homepage';
105
        }
106
        if (2 == $downloads_field[$i]->getVar('fid')) {
107
            //version
108
            $title_sup = _AM_TDMDOWNLOADS_FORMVERSION;
109
            $criteria->setSort('version');
110
            $fieldNameBase = 'version';
111
        }
112
        if (3 == $downloads_field[$i]->getVar('fid')) {
113
            //taille du fichier
114
            $title_sup = _AM_TDMDOWNLOADS_FORMSIZE;
115
            $criteria->setSort('size');
116
            $fieldNameBase = 'size';
117
        }
118
        if (4 == $downloads_field[$i]->getVar('fid')) {
119
            //platform
120
            $title_sup     = _AM_TDMDOWNLOADS_FORMPLATFORM;
121
            $platformArray = explode('|', $helper->getConfig('plateform'));
0 ignored issues
show
It seems like $helper->getConfig('plateform') can also be of type null; however, parameter $string of explode() 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 ignore-type  annotation

121
            $platformArray = explode('|', /** @scrutinizer ignore-type */ $helper->getConfig('plateform'));
Loading history...
122
            foreach ($platformArray as $platform) {
123
                $contentArray[$platform] = $platform;
124
            }
125
            if (999 !== $fieldContent[$downloads_field[$i]->getVar('fid')]) {
126
                $criteria_2->add(new \Criteria('platform', '%' . $fieldContent[$downloads_field[$i]->getVar('fid')] . '%', 'LIKE'));
127
            }
128
        } else {
129
            $criteria->setOrder('ASC');
130
            /** @var Downloads $tdmdownloadsArray */
131
            $tdmdownloadsArray = $downloadsHandler->getAll($criteria);
132
            foreach (array_keys($tdmdownloadsArray) as $j) {
0 ignored issues
show
$tdmdownloadsArray of type Downloads is incompatible with the type array expected by parameter $array of array_keys(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

132
            foreach (array_keys(/** @scrutinizer ignore-type */ $tdmdownloadsArray) as $j) {
Loading history...
133
                /** @var \XoopsModules\Tdmdownloads\Downloads[] $tdmdownloadsArray */
134
                $temp                = $tdmdownloadsArray[$j]->getVar($fieldNameBase);
135
                $contentArray[$temp] = $temp;
136
            }
137
            if (999 !== $fieldContent[$downloads_field[$i]->getVar('fid')]) {
138
                $criteria_2->add(new \Criteria($fieldNameBase, $fieldContent[$downloads_field[$i]->getVar('fid')]));
139
            }
140
        }
141
    } else {
142
        $title_sup = $downloads_field[$i]->getVar('title');
143
        $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid')));
0 ignored issues
show
It seems like $downloads_field[$i]->getVar('fid') 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 ignore-type  annotation

143
        $criteria->add(new \Criteria('fid', /** @scrutinizer ignore-type */ $downloads_field[$i]->getVar('fid')));
Loading history...
144
        $criteria->setSort('data');
145
        $criteria->setOrder('ASC');
146
        $tdmdownloadsArray = $fielddataHandler->getAll($criteria);
147
        foreach (array_keys($tdmdownloadsArray) as $j) {
148
            /** @var \XoopsModules\Tdmdownloads\Downloads[] $tdmdownloadsArray */
149
            $contentArray[$tdmdownloadsArray[$j]->getVar('data', 'n')] = $tdmdownloadsArray[$j]->getVar('data');
150
        }
151
        if ('' !== $fieldContent[$downloads_field[$i]->getVar('fid')]) {
152
            $criteria_1 = new \CriteriaCompo();
153
            $criteria_1->add(new \Criteria('data', $fieldContent[$downloads_field[$i]->getVar('fid')]));
154
            $dataArray = $fielddataHandler->getAll($criteria_1);
155
            foreach (array_keys($dataArray) as $k) {
156
                /** @var \XoopsModules\Tdmdownloads\Fielddata[] $dataArray */
157
                $lid_arr[] = $dataArray[$k]->getVar('lid');
158
            }
159
        }
160
    }
161
    if (count($lid_arr) > 0) {
162
        $criteria_2->add(new \Criteria('lid', '(' . implode(',', $lid_arr) . ')', 'IN'));
163
    }
164
    $select_sup = new \XoopsFormSelect($title_sup, $fieldName, $fieldContent[$downloads_field[$i]->getVar('fid')]);
165
    $select_sup->addOption(999, _MD_TDMDOWNLOADS_SEARCH_ALL1);
166
    $select_sup->addOptionArray($contentArray);
167
    $form->addElement($select_sup);
168
    unset($select_sup);
169
    $xoopsTpl->append('field', $downloads_field[$i]->getVar('title'));
170
}
171
//bouton validation
172
$buttonTray = new \XoopsFormElementTray('', '');
173
$buttonTray->addElement(new \XoopsFormButton('', 'submit', _MD_TDMDOWNLOADS_SEARCH_BT, 'submit'));
174
$form->addElement($buttonTray);
175
if ('' !== $title) {
176
    $criteria_2->add(new \Criteria('title', '%' . $title . '%', 'LIKE'));
177
    $arguments .= 'title=' . $title . '&amp;';
178
}
179
if (0 !== $cat) {
180
    $criteria_2->add(new \Criteria('cid', $cat));
181
    $arguments .= 'cat=' . $cat . '&amp;';
182
}
183
$tblsort     = [];
184
$tblsort[1]  = 'date';
185
$tblsort[2]  = 'date';
186
$tblsort[3]  = 'hits';
187
$tblsort[4]  = 'hits';
188
$tblsort[5]  = 'rating';
189
$tblsort[6]  = 'rating';
190
$tblsort[7]  = 'title';
191
$tblsort[8]  = 'title';
192
$tblorder    = [];
193
$tblorder[1] = 'DESC';
194
$tblorder[2] = 'ASC';
195
$tblorder[3] = 'DESC';
196
$tblorder[4] = 'ASC';
197
$tblorder[5] = 'DESC';
198
$tblorder[6] = 'ASC';
199
$tblorder[7] = 'DESC';
200
$tblorder[8] = 'ASC';
201
$sort        = $helper->getConfig('searchorder') ?? 1;
202
$order       = $helper->getConfig('searchorder') ?? 1;
203
$criteria_2->setSort($tblsort[$sort]);
204
$criteria_2->setOrder($tblorder[$order]);
205
$numrows = $downloadsHandler->getCount($criteria_2);
206
if (\Xmf\Request::hasVar('limit', 'REQUEST')) {
207
    $criteria_2->setLimit(\Xmf\Request::getInt('limit', 0, 'REQUEST'));
208
    $limit = \Xmf\Request::getInt('limit', 0, 'REQUEST');
209
} else {
210
    $criteria_2->setLimit($helper->getConfig('perpageliste'));
211
    $limit = $helper->getConfig('perpageliste');
212
}
213
if (\Xmf\Request::hasVar('start', 'REQUEST')) {
214
    $criteria_2->setStart(\Xmf\Request::getInt('start', 0, 'REQUEST'));
215
    $start = \Xmf\Request::getInt('start', 0, 'REQUEST');
216
} else {
217
    $criteria_2->setStart(0);
218
    $start = 0;
219
}
220
//pour faire une jointure de table
221
$downloadsHandler->table_link   = $downloadsHandler->db->prefix('tdmdownloads_cat'); // Nom de la table en jointure
222
$downloadsHandler->field_link   = 'cat_cid'; // champ de la table en jointure
223
$downloadsHandler->field_object = 'cid'; // champ de la table courante
224
$tdmdownloadsArray              = $downloadsHandler->getByLink($criteria_2);
225
if ($numrows > $limit) {
226
    require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
227
    $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', $arguments);
228
    $pagenav = $pagenav->renderNav(4);
229
} else {
230
    $pagenav = '';
231
}
232
$xoopsTpl->assign('lang_thereare', sprintf(_MD_TDMDOWNLOADS_SEARCH_THEREARE, $downloadsHandler->getCount($criteria_2)));
233
$xoopsTpl->assign('pagenav', $pagenav);
234
$keywords = '';
235
foreach (array_keys($tdmdownloadsArray) as $i) {
236
    $tdmdownloadsTab['lid']    = $tdmdownloadsArray[$i]->getVar('lid');
237
    $tdmdownloadsTab['cid']    = $tdmdownloadsArray[$i]->getVar('cid');
238
    $tdmdownloadsTab['title']  = $tdmdownloadsArray[$i]->getVar('title');
239
    $tdmdownloadsTab['cat']    = $tdmdownloadsArray[$i]->getVar('cat_title');
240
    $tdmdownloadsTab['imgurl'] = $uploadurl . $tdmdownloadsArray[$i]->getVar('cat_imgurl');
241
    $tdmdownloadsTab['date']   = formatTimestamp($tdmdownloadsArray[$i]->getVar('date'), 'd/m/Y');
242
    $tdmdownloadsTab['rating'] = number_format((float)$tdmdownloadsArray[$i]->getVar('rating'), 0);
243
    $tdmdownloadsTab['hits']   = $tdmdownloadsArray[$i]->getVar('hits');
244
    $contenu                   = '';
245
    foreach (array_keys($downloads_field) as $j) {
246
        if (1 == $downloads_field[$j]->getVar('status_def')) {
247
            if (1 == $downloads_field[$j]->getVar('fid')) {
248
                //page d'accueil
249
                $contenu = $tdmdownloadsArray[$i]->getVar('homepage');
250
            }
251
            if (2 == $downloads_field[$j]->getVar('fid')) {
252
                //version
253
                $contenu = $tdmdownloadsArray[$i]->getVar('version');
254
            }
255
            if (3 == $downloads_field[$j]->getVar('fid')) {
256
                //taille du fichier
257
                //mb $contenu = $utilities->convertFileSize($tdmdownloads_arr[$i]->getVar('size'));
258
                $contenu = $tdmdownloadsArray[$i]->getVar('size');
259
            }
260
            if (4 == $downloads_field[$j]->getVar('fid')) {
261
                //plateforme
262
                $contenu = $tdmdownloadsArray[$i]->getVar('platform');
263
            }
264
        } else {
265
            $criteria = new \CriteriaCompo();
266
            $criteria->add(new \Criteria('lid', $tdmdownloadsArray[$i]->getVar('lid')));
267
            $criteria->add(new \Criteria('fid', $downloads_field[$j]->getVar('fid')));
268
            $downloadsfielddata = $fielddataHandler->getAll($criteria);
269
            if (count($downloadsfielddata) > 0) {
270
                foreach (array_keys($downloadsfielddata) as $k) {
271
                    /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloadsfielddata */
272
                    $contenu = $downloadsfielddata[$k]->getVar('data', 'n');
273
                }
274
            } else {
275
                $contenu = '';
276
            }
277
        }
278
        $tdmdownloadsTab['fielddata'][$j] = $contenu;
279
        unset($contenu);
280
    }
281
    $xoopsTpl->append('search_list', $tdmdownloadsTab);
282
    $keywords .= $tdmdownloadsArray[$i]->getVar('title') . ',';
283
}
284
$xoopsTpl->assign('searchForm', $form->render());
285
$xoopsTpl->assign('perm_submit', $perm_submit);
286
$xoopsTpl->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16);
287
// référencement
288
// titre de la page
289
$titre = _MD_TDMDOWNLOADS_SEARCH_PAGETITLE . ' - ' . $xoopsModule->name();
290
$xoopsTpl->assign('xoops_pagetitle', $titre);
291
//description
292
$xoTheme->addMeta('meta', 'description', strip_tags($xoopsModule->name()));
293
//keywords
294
$keywords = mb_substr($keywords, 0, -1);
295
$xoTheme->addMeta('meta', 'keywords', strip_tags($keywords));
296
$GLOBALS['xoopsTpl']->assign('mod_url', XOOPS_URL . '/modules/' . $moduleDirName);
297
require XOOPS_ROOT_PATH . '/footer.php';
298