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.
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
    Helper,
22
    Tree
23
};
24
25
require_once __DIR__ . '/header.php';
26
$helper = Helper::getInstance();
27
// template d'affichage
28
$moduleDirName                           = basename(__DIR__);
29
$GLOBALS['xoopsOption']['template_main'] = 'tdmdownloads_index.tpl';
30
require_once XOOPS_ROOT_PATH . '/header.php';
31
/** @var \xos_opal_Theme $xoTheme */
32
$xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $moduleDirName . '/assets/css/styles.css', null);
33
// pour les permissions
34
$categories = $utility->getItemIds('tdmdownloads_view', $moduleDirName);
35
//tableau des téléchargements
36
$criteria = new \CriteriaCompo();
37
$criteria->add(new \Criteria('status', 0, '!='));
38
$criteria->add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN'));
39
$downloadsArray = $downloadsHandler->getAll($criteria);
40
$xoopsTpl->assign('lang_thereare', sprintf(_MD_TDMDOWNLOADS_INDEX_THEREARE, count($downloadsArray)));
41
//tableau des catégories
42
$criteria = new \CriteriaCompo();
43
$criteria->setSort('cat_weight ASC, cat_title');
44
$criteria->setOrder('ASC');
45
$criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN'));
46
$downloadscatArray = $categoryHandler->getAll($criteria);
47
$mytree            = new Tree($downloadscatArray, 'cat_cid', 'cat_pid');
48
//affichage des catégories
49
$xoopsTpl->assign('nb_catcol', $helper->getConfig('nb_catcol'));
50
$count    = 1;
51
$keywords = '';
52
foreach (array_keys($downloadscatArray) as $i) {
53
    /** @var \XoopsModules\Tdmdownloads\Category[] $downloadscatArray */
54
    if (0 === $downloadscatArray[$i]->getVar('cat_pid')) {
55
        $totaldownloads    = $utility->getNumbersOfEntries($mytree, $categories, $downloadsArray, $downloadscatArray[$i]->getVar('cat_cid'));
56
        $subcategories_arr = $mytree->getFirstChild($downloadscatArray[$i]->getVar('cat_cid'));
0 ignored issues
show
It seems like $downloadscatArray[$i]->getVar('cat_cid') can also be of type array and array; however, parameter $key of XoopsObjectTree::getFirstChild() 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

56
        $subcategories_arr = $mytree->getFirstChild(/** @scrutinizer ignore-type */ $downloadscatArray[$i]->getVar('cat_cid'));
Loading history...
57
        $chcount           = 0;
58
        $subcategories     = '';
59
        //pour les mots clef
60
        $keywords .= $downloadscatArray[$i]->getVar('cat_title') . ',';
61
        foreach (array_keys($subcategories_arr) as $j) {
62
            /** @var \XoopsModules\Tdmdownloads\Category[] $subcategories_arr */
63
            if ($chcount >= $helper->getConfig('nbsouscat')) {
64
                $subcategories .= '<li>[<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/viewcat.php?cid=' . $downloadscatArray[$i]->getVar('cat_cid') . '">+</a>]</li>';
65
                break;
66
            }
67
            $subcategories .= '<li><a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/viewcat.php?cid=' . $subcategories_arr[$j]->getVar('cat_cid') . '">' . $subcategories_arr[$j]->getVar('cat_title') . '</a></li>';
68
            $keywords      .= $downloadscatArray[$i]->getVar('cat_title') . ',';
69
            ++$chcount;
70
        }
71
        $xoopsTpl->append('categories', [
72
            'image'            => $uploadurl . $downloadscatArray[$i]->getVar('cat_imgurl'),
73
            'id'               => $downloadscatArray[$i]->getVar('cat_cid'),
74
            'title'            => $downloadscatArray[$i]->getVar('cat_title'),
75
            'description_main' => $downloadscatArray[$i]->getVar('cat_description_main'),
76
            'subcategories'    => $subcategories,
77
            'countsubs'        => count($subcategories_arr),
78
            'totaldownloads'   => $totaldownloads,
79
            'count'            => $count,
80
        ]);
81
        ++$count;
82
    }
83
}
84
//pour afficher les résumés
85
//----------------------------------------------------------------------------------------------------------------------------------------------------
86
//téléchargements récents
87
if (1 == $helper->getConfig('bldate')) {
88
    $criteria = new \CriteriaCompo();
89
    $criteria->add(new \Criteria('status', 0, '!='));
90
    $criteria->add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN'));
91
    $criteria->setSort('date');
92
    $criteria->setOrder('DESC');
93
    $criteria->setLimit($helper->getConfig('nbbl'));
94
    $downloads_arr_date = $downloadsHandler->getAll($criteria);
95
    foreach (array_keys($downloads_arr_date) as $i) {
96
        /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloads_arr_date */
97
        $title = $downloads_arr_date[$i]->getVar('title');
98
        if (mb_strlen($title) >= $helper->getConfig('longbl')) {
99
            $title = mb_substr($title, 0, $helper->getConfig('longbl')) . '...';
100
        }
101
        $date = formatTimestamp($downloads_arr_date[$i]->getVar('date'), 's');
102
        $xoopsTpl->append('bl_date', [
103
            'id'    => $downloads_arr_date[$i]->getVar('lid'),
104
            'cid'   => $downloads_arr_date[$i]->getVar('cid'),
105
            'date'  => $date,
106
            'title' => $title,
107
        ]);
108
    }
109
}
110
//plus téléchargés
111
if (1 == $helper->getConfig('blpop')) {
112
    $criteria = new \CriteriaCompo();
113
    $criteria->add(new \Criteria('status', 0, '!='));
114
    $criteria->add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN'));
115
    $criteria->setSort('hits');
116
    $criteria->setOrder('DESC');
117
    $criteria->setLimit($helper->getConfig('nbbl'));
118
    $downloads_arr_hits = $downloadsHandler->getAll($criteria);
119
    foreach (array_keys($downloads_arr_hits) as $i) {
120
        /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloads_arr_hits */
121
        $title = $downloads_arr_hits[$i]->getVar('title');
122
        if (mb_strlen($title) >= $helper->getConfig('longbl')) {
123
            $title = mb_substr($title, 0, $helper->getConfig('longbl')) . '...';
124
        }
125
        $xoopsTpl->append('bl_pop', [
126
            'id'    => $downloads_arr_hits[$i]->getVar('lid'),
127
            'cid'   => $downloads_arr_hits[$i]->getVar('cid'),
128
            'hits'  => $downloads_arr_hits[$i]->getVar('hits'),
129
            'title' => $title,
130
        ]);
131
    }
132
}
133
//mieux notés
134
if (1 == $helper->getConfig('blrating')) {
135
    $criteria = new \CriteriaCompo();
136
    $criteria->add(new \Criteria('status', 0, '!='));
137
    $criteria->add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN'));
138
    $criteria->setSort('rating');
139
    $criteria->setOrder('DESC');
140
    $criteria->setLimit($helper->getConfig('nbbl'));
141
    $downloads_arr_rating = $downloadsHandler->getAll($criteria);
142
    foreach (array_keys($downloads_arr_rating) as $i) {
143
        /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloads_arr_rating */
144
        $title = $downloads_arr_rating[$i]->getVar('title');
145
        if (mb_strlen($title) >= $helper->getConfig('longbl')) {
146
            $title = mb_substr($title, 0, $helper->getConfig('longbl')) . '...';
147
        }
148
        $rating = number_format((float)$downloads_arr_rating[$i]->getVar('rating'), 1);
149
        $xoopsTpl->append('bl_rating', [
150
            'id'     => $downloads_arr_rating[$i]->getVar('lid'),
151
            'cid'    => $downloads_arr_rating[$i]->getVar('cid'),
152
            'rating' => $rating,
153
            'title'  => $title,
154
        ]);
155
    }
156
}
157
$bl_affichage = 1;
158
if (0 === $helper->getConfig('bldate') && 0 === $helper->getConfig('blpop') && 0 === $helper->getConfig('blrating')) {
159
    $bl_affichage = 0;
160
}
161
$xoopsTpl->assign('bl_affichage', $bl_affichage);
162
$xoopsTpl->assign('show_latest_files', $helper->getConfig('show_latest_files'));
163
//----------------------------------------------------------------------------------------------------------------------------------------------------
164
// affichage des téléchargements
165
if ($helper->getConfig('newdownloads') > 0) {
166
    $xoopsTpl->assign('nb_dowcol', $helper->getConfig('nb_dowcol'));
167
    //Utilisation d'une copie d'écran avec la largeur selon les préférences
168
    if (1 == $helper->getConfig('useshots')) {
169
        $xoopsTpl->assign('shotwidth', $helper->getConfig('shotwidth'));
170
        $xoopsTpl->assign('show_screenshot', true);
171
        $xoopsTpl->assign('img_float', $helper->getConfig('img_float'));
172
    }
173
    $criteria = new \CriteriaCompo();
174
    $criteria->add(new \Criteria('status', 0, '!='));
175
    $criteria->add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN'));
176
    $criteria->setLimit($helper->getConfig('newdownloads'));
177
    $tblsort     = [];
178
    $tblsort[1]  = 'date';
179
    $tblsort[2]  = 'date';
180
    $tblsort[3]  = 'hits';
181
    $tblsort[4]  = 'hits';
182
    $tblsort[5]  = 'rating';
183
    $tblsort[6]  = 'rating';
184
    $tblsort[7]  = 'title';
185
    $tblsort[8]  = 'title';
186
    $tblorder    = [];
187
    $tblorder[1] = 'DESC';
188
    $tblorder[2] = 'ASC';
189
    $tblorder[3] = 'DESC';
190
    $tblorder[4] = 'ASC';
191
    $tblorder[5] = 'DESC';
192
    $tblorder[6] = 'ASC';
193
    $tblorder[7] = 'DESC';
194
    $tblorder[8] = 'ASC';
195
    $sort        = $helper->getConfig('toporder') ?? 1;
196
    $order       = $helper->getConfig('toporder') ?? 1;
197
    $criteria->setSort($tblsort[$sort]);
198
    $criteria->setOrder($tblorder[$order]);
199
    $downloadsArray = $downloadsHandler->getAll($criteria);
200
    $categories     = $utility->getItemIds('tdmdownloads_download', $moduleDirName);
201
    $item           = $utility->getItemIds('tdmdownloads_download_item', $moduleDirName);
202
    $count          = 1;
203
    foreach (array_keys($downloadsArray) as $i) {
204
        /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloadsArray */
205
        if ('blank.gif' === $downloadsArray[$i]->getVar('logourl')) {
206
            $logourl = '';
207
        } else {
208
            $logourl = $downloadsArray[$i]->getVar('logourl');
209
            $logourl = $uploadurl_shots . $logourl;
210
        }
211
        $datetime    = formatTimestamp($downloadsArray[$i]->getVar('date'), 's');
212
        $submitter   = \XoopsUser::getUnameFromId($downloadsArray[$i]->getVar('submitter'));
213
        $description = $downloadsArray[$i]->getVar('description');
214
        //permet d'afficher uniquement la description courte
215
        if (false === mb_strpos($description, '[pagebreak]')) {
216
            $descriptionShort = $description;
217
        } else {
218
            $descriptionShort = mb_substr($description, 0, mb_strpos($description, '[pagebreak]'));
219
        }
220
        // pour les vignettes "new" et "mis à jour"
221
        $new = $utility->getStatusImage($downloadsArray[$i]->getVar('date'), $downloadsArray[$i]->getVar('status'));
222
        $pop = $utility->getPopularImage($downloadsArray[$i]->getVar('hits'));
223
        // Défini si la personne est un admin
224
        $adminlink = '';
225
        if (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) {
226
            $adminlink = '<a href="'
227
                         . XOOPS_URL
228
                         . '/modules/'
229
                         . $moduleDirName
230
                         . '/admin/downloads.php?op=view_downloads&amp;downloads_lid='
231
                         . $downloadsArray[$i]->getVar('lid')
232
                         . '" title="'
233
                         . _MD_TDMDOWNLOADS_EDITTHISDL
234
                         . '"><img src="'
235
                         . XOOPS_URL
236
                         . '/modules/'
237
                         . $moduleDirName
238
                         . '/assets/images/icons/16/edit.png" width="16px" height="16px" border="0" alt="'
239
                         . _MD_TDMDOWNLOADS_EDITTHISDL
240
                         . '"></a>';
241
        }
242
        //permission de télécharger
243
        $downloadPermission = true;
244
        if (1 === $helper->getConfig('permission_download')) {
245
            if (!in_array($downloadsArray[$i]->getVar('cid'), $categories)) {
246
                $downloadPermission = false;
247
            }
248
        } else {
249
            if (!in_array($downloadsArray[$i]->getVar('lid'), $item)) {
250
                $downloadPermission = false;
251
            }
252
        }
253
        $xoopsTpl->append('file', [
254
            'id'                => $downloadsArray[$i]->getVar('lid'),
255
            'cid'               => $downloadsArray[$i]->getVar('cid'),
256
            'title'             => $downloadsArray[$i]->getVar('title'),
257
            'rating'            => $downloadsArray[$i]->getVar('rating'),
258
            'hits'              => $downloadsArray[$i]->getVar('hits'),
259
            'new'               => $new,
260
            'pop'               => $pop,
261
            'logourl'           => $logourl,
262
            'updated'           => $datetime,
263
            'description_short' => $descriptionShort,
264
            'adminlink'         => $adminlink,
265
            'submitter'         => $submitter,
266
            'perm_download'     => $downloadPermission,
267
            'count'             => $count,
268
        ]);
269
        //pour les mots clef
270
        $keywords .= $downloadsArray[$i]->getVar('title') . ',';
271
        ++$count;
272
    }
273
}
274
// référencement
275
//description
276
$xoTheme->addMeta('meta', 'description', strip_tags($xoopsModule->name()));
277
//keywords
278
$keywords = mb_substr($keywords, 0, -1);
279
$xoTheme->addMeta('meta', 'keywords', $keywords);
280
require XOOPS_ROOT_PATH . '/footer.php';
281