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.

singlefile.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
use Xmf\Metagen;
6
use XoopsModules\Tag\Tag;
7
use XoopsModules\Tdmdownloads\{
8
    Helper,
9
    Tree
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
$helper        = Helper::getInstance();
28
$moduleDirName = basename(__DIR__);
29
// template d'affichage
30
$GLOBALS['xoopsOption']['template_main'] = 'tdmdownloads_singlefile.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
$xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $moduleDirName . '/assets/css/blocks.css', null);
35
$lid = \Xmf\Request::getInt('lid', 0, 'REQUEST');
36
//information du téléchargement
37
$viewDownloads = $downloadsHandler->get($lid);
38
// redirection si le téléchargement n'existe pas ou n'est pas activé
39
if ((is_array($viewDownloads) && 0 == count($viewDownloads)) || 0 == $viewDownloads->getVar('status')) {
40
    redirect_header('index.php', 3, _MD_TDMDOWNLOADS_SINGLEFILE_NONEXISTENT);
41
}
42
// pour les permissions
43
$categories = $utility->getItemIds('tdmdownloads_view', $moduleDirName);
44
if (!in_array($viewDownloads->getVar('cid'), $categories)) {
45
    redirect_header(XOOPS_URL, 2, _NOPERM);
46
}
47
//tableau des catégories
48
$criteria = new \CriteriaCompo();
49
$criteria->setSort('cat_weight ASC, cat_title');
50
$criteria->setOrder('ASC');
51
$criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN'));
52
$downloadscatArray = $categoryHandler->getAll($criteria);
53
$mytree            = new Tree($downloadscatArray, 'cat_cid', 'cat_pid');
54
//navigation
55
$navigation = $utility::getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' <img src="assets/images/deco/arrow.gif" alt="arrow"> ', true, 'ASC', true);
56
$navigation .= ' <img src="assets/images/deco/arrow.gif" alt="arrow"> ' . $viewDownloads->getVar('title');
57
$xoopsTpl->assign('navigation', $navigation);
58
// sortie des informations
59
//Utilisation d'une copie d'écran avec la largeur selon les préférences
60
if (1 == $helper->getConfig('useshots')) {
61
    $xoopsTpl->assign('shotwidth', $helper->getConfig('shotwidth'));
62
    $xoopsTpl->assign('show_screenshot', true);
63
    $xoopsTpl->assign('img_float', $helper->getConfig('img_float'));
64
}
65
if ('ltr' === $helper->getConfig('download_float')) {
66
    $xoopsTpl->assign('textfloat', 'floatleft');
67
    $xoopsTpl->assign('infofloat', 'floatright');
68
} else {
69
    $xoopsTpl->assign('textfloat', 'floatright');
70
    $xoopsTpl->assign('infofloat', 'floatleft');
71
}
72
// sortie des informations
73
if ('blank.gif' === $viewDownloads->getVar('logourl')) {
74
    $logourl = '';
75
} else {
76
    $logourl = $viewDownloads->getVar('logourl');
77
    $logourl = $uploadurl_shots . $logourl;
78
}
79
// Défini si la personne est un admin
80
$adminlink = '';
81
if (is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) {
82
    $adminlink = '<a href="'
83
                 . XOOPS_URL
84
                 . '/modules/'
85
                 . $moduleDirName
86
                 . '/admin/downloads.php?op=view_downloads&amp;downloads_lid='
87
                 . \Xmf\Request::getInt('lid', 0, 'REQUEST')
88
                 . '" title="'
89
                 . _MD_TDMDOWNLOADS_EDITTHISDL
90
                 . '"><img src="'
91
                 . XOOPS_URL
92
                 . '/modules/'
93
                 . $moduleDirName
94
                 . '/assets/images/icons/16/edit.png" width="16px" height="16px" border="0" alt="'
95
                 . _MD_TDMDOWNLOADS_EDITTHISDL
96
                 . '"></a>';
97
}
98
$description = $viewDownloads->getVar('description');
99
$xoopsTpl->assign('description', str_replace('[pagebreak]', '', $description));
100
$xoopsTpl->assign('lid', $lid);
101
$xoopsTpl->assign('cid', $viewDownloads->getVar('cid'));
102
$xoopsTpl->assign('logourl', $logourl);
103
// pour les vignettes "new" et "mis Ă  jour"
104
$new = $utility->getStatusImage($viewDownloads->getVar('date'), $viewDownloads->getVar('status'));
105
$pop = $utility->getPopularImage($viewDownloads->getVar('hits'));
106
$xoopsTpl->assign('title', $viewDownloads->getVar('title'));
107
$xoopsTpl->assign('new', $new);
108
$xoopsTpl->assign('pop', $pop);
109
$xoopsTpl->assign('adminlink', $adminlink);
110
$xoopsTpl->assign('date', formatTimestamp($viewDownloads->getVar('date'), 's'));
111
$xoopsTpl->assign('author', \XoopsUser::getUnameFromId($viewDownloads->getVar('submitter')));
112
$xoopsTpl->assign('hits', sprintf(_MD_TDMDOWNLOADS_SINGLEFILE_NBTELECH, $viewDownloads->getVar('hits')));
113
$xoopsTpl->assign('rating', number_format((float)$viewDownloads->getVar('rating'), 1));
114
$xoopsTpl->assign('votes', sprintf(_MD_TDMDOWNLOADS_SINGLEFILE_VOTES, $viewDownloads->getVar('votes')));
115
$xoopsTpl->assign('nb_comments', sprintf(_MD_TDMDOWNLOADS_SINGLEFILE_COMMENTS, $viewDownloads->getVar('comments')));
116
$xoopsTpl->assign('show_bookmark', $helper->getConfig('show_bookmark'));
117
$xoopsTpl->assign('show_social', $helper->getConfig('show_social'));
118
//paypal
119
$paypal = false;
120
if (true === $helper->getConfig('use_paypal') && '' !== $viewDownloads->getVar('paypal')) {
121
    $paypal = '<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">
122
    <input type="hidden" name="cmd" value="_xclick">
123
    <input type="hidden" name="business" value="' . $viewDownloads->getVar('paypal') . '">
124
    <input type="hidden" name="item_name" value="' . sprintf(_MD_TDMDOWNLOADS_SINGLEFILE_PAYPAL, $viewDownloads->getVar('title')) . ' (' . \XoopsUser::getUnameFromId(!empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0) . ')">
125
    <input type="hidden" name="currency_code" value="' . $helper->getConfig('currency_paypal') . '">
126
    <input type="image" src="' . $helper->getConfig('image_paypal') . '" border="0" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!">
127
    </form>';
128
}
129
$xoopsTpl->assign('paypal', $paypal);
130
/**
131
 * @param $k
132
 * @return string
133
 */
134
function getXfieldKey($k)
135
{
136
    return \mb_strtolower(
137
        str_replace(
138
            ['Ü', 'ü', 'Ş', 'ş', 'I', 'ı', 'Ç', 'ç', 'Ğ', 'ğ', 'Ö', 'ö'],
139
            ['u', 'u', 's', 's', 'i', 'i', 'c', 'c', 'g', 'g', 'o', 'o'],
140
            $k
141
        )
142
    );
143
}
144
145
// pour les champs supplémentaires
146
$criteria = new \CriteriaCompo();
147
$criteria->setSort('weight ASC, title');
148
$criteria->setOrder('ASC');
149
$criteria->add(new \Criteria('status', 1));
150
/** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */
151
$downloads_field = $fieldHandler->getAll($criteria);
152
$nb_champ        = count($downloads_field);
153
$champ_sup       = '';
154
$champ_sup_vide  = 0;
155
$xfields         = [];
156
foreach (array_keys($downloads_field) as $i) {
157
    /** @var \XoopsModules\Tdmdownloads\Field[] $downloads_field */
158
    if (1 == $downloads_field[$i]->getVar('status_def')) {
159
        if (1 == $downloads_field[$i]->getVar('fid')) {
160
            //page d'accueil
161
            if ('' != $viewDownloads->getVar('homepage')) {
162
                $champ_sup = '&nbsp;' . _AM_TDMDOWNLOADS_FORMHOMEPAGE . ':&nbsp;<a href="' . $viewDownloads->getVar('homepage') . '">' . _MD_TDMDOWNLOADS_SINGLEFILE_ICI . '</a>';
163
                ++$champ_sup_vide;
164
                $xfields['homepage'] = $champ_sup;
165
            }
166
        }
167
        if (2 == $downloads_field[$i]->getVar('fid')) {
168
            //version
169
            if ('' != $viewDownloads->getVar('version')) {
170
                $champ_sup = '&nbsp;' . _AM_TDMDOWNLOADS_FORMVERSION . ':&nbsp;' . $viewDownloads->getVar('version');
171
                ++$champ_sup_vide;
172
                $xfields['version'] = $champ_sup;
173
            }
174
        }
175
        if (3 == $downloads_field[$i]->getVar('fid')) {
176
            //taille du fichier
177
            $size_value_arr = explode(' ', $viewDownloads->getVar('size'));
178
            if ('' != $size_value_arr[0]) {
179
                $champ_sup = '&nbsp;' . _AM_TDMDOWNLOADS_FORMSIZE . ':&nbsp;' . $utility::convertSizeToString($viewDownloads->getVar('size'));
180
                ++$champ_sup_vide;
181
                $xfields['size'] = $champ_sup;
182
            }
183
        }
184
        if (4 == $downloads_field[$i]->getVar('fid')) {
185
            //plateforme
186
            if ('' != $viewDownloads->getVar('platform')) {
187
                $champ_sup = '&nbsp;' . _AM_TDMDOWNLOADS_FORMPLATFORM . $viewDownloads->getVar('platform');
188
                ++$champ_sup_vide;
189
                $xfields['platform'] = $champ_sup;
190
            }
191
        }
192
    } else {
193
        $view_data = $fielddataHandler->get();
194
        $criteria  = new \CriteriaCompo();
195
        $criteria->add(new \Criteria('lid', \Xmf\Request::getInt('lid', 0, 'REQUEST')));
196
        $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

196
        $criteria->add(new \Criteria('fid', /** @scrutinizer ignore-type */ $downloads_field[$i]->getVar('fid')));
Loading history...
197
        $downloadsfielddata = $fielddataHandler->getAll($criteria);
198
        $contenu            = '';
199
        foreach (array_keys($downloadsfielddata) as $j) {
200
            /** @var \XoopsModules\Tdmdownloads\Fielddata[] $downloadsfielddata */
201
            $contenu = $downloadsfielddata[$j]->getVar('data', 'n');
202
        }
203
        if ('' != $contenu) {
204
            $champ_sup = '&nbsp;' . $downloads_field[$i]->getVar('title') . ':&nbsp;' . $contenu;
205
            ++$champ_sup_vide;
206
            $xfieldKey           = getXfieldKey($downloads_field[$i]->getVar('title'));
207
            $xfields[$xfieldKey] = $contenu;
208
        }
209
    }
210
    if ('' != $champ_sup) {
211
        $xoopsTpl->append('champ_sup', [
212
            'image' => $uploadurl_field . $downloads_field[$i]->getVar('img'),
213
            'data'  => $champ_sup,
214
        ]);
215
    }
216
    $champ_sup = '';
217
}
218
$xoopsTpl->assign('xfields', $xfields);
219
if ($nb_champ > 0 && $champ_sup_vide > 0) {
220
    $xoopsTpl->assign('sup_aff', true);
221
} else {
222
    $xoopsTpl->assign('sup_aff', false);
223
}
224
//permission
225
$xoopsTpl->assign('perm_vote', $perm_vote);
226
$xoopsTpl->assign('perm_modif', $perm_modif);
227
$categories = $utility->getItemIds('tdmdownloads_download', $moduleDirName);
228
$item       = $utility->getItemIds('tdmdownloads_download_item', $moduleDirName);
229
if (1 == $helper->getConfig('permission_download')) {
230
    if (!in_array($viewDownloads->getVar('cid'), $categories)) {
231
        $xoopsTpl->assign('perm_download', false);
232
    } else {
233
        $xoopsTpl->assign('perm_download', true);
234
    }
235
} else {
236
    if (!in_array($viewDownloads->getVar('lid'), $item)) {
237
        $xoopsTpl->assign('perm_download', false);
238
    } else {
239
        $xoopsTpl->assign('perm_download', true);
240
    }
241
}
242
// pour utiliser tellafriend.
243
if (1 == $helper->getConfig('usetellafriend') && is_dir('../tellafriend')) {
244
    $string  = sprintf(_MD_TDMDOWNLOADS_SINGLEFILE_INTFILEFOUND, $xoopsConfig['sitename'] . ':  ' . XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?lid=' . \Xmf\Request::getInt('lid', 0, 'REQUEST'));
245
    $subject = sprintf(_MD_TDMDOWNLOADS_SINGLEFILE_INTFILEFOUND, $xoopsConfig['sitename']);
246
    if (false !== mb_strpos($subject, '%')) {
247
        $subject = rawurldecode($subject);
248
    }
249
    if (false !== mb_stripos($string, '%3F')) {
250
        $string = rawurldecode($string);
251
    }
252
    if (preg_match('/(' . preg_quote(XOOPS_URL, '/') . '.*)$/i', $string, $matches)) {
253
        $targetUri = str_replace('&amp;', '&', $matches[1]);
254
    } else {
255
        $targetUri = XOOPS_URL . $_SERVER['REQUEST_URI'];
256
    }
257
    $tellafriendText = '<a target="_top" href="' . XOOPS_URL . '/modules/tellafriend/index.php?target_uri=' . rawurlencode($targetUri) . '&amp;subject=' . rawurlencode($subject) . '">' . _MD_TDMDOWNLOADS_SINGLEFILE_TELLAFRIEND . '</a>';
258
} else {
259
    $tellafriendText = '<a target="_top" href="mailto:?subject=' . rawurlencode(sprintf(_MD_TDMDOWNLOADS_SINGLEFILE_INTFILEFOUND, $xoopsConfig['sitename'])) . '&amp;body=' . rawurlencode(
260
            sprintf(_MD_TDMDOWNLOADS_SINGLEFILE_INTFILEFOUND, $xoopsConfig['sitename']) . ':  ' . XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?lid=' . \Xmf\Request::getInt('lid', 0, 'REQUEST')
261
        ) . '">' . _MD_TDMDOWNLOADS_SINGLEFILE_TELLAFRIEND . '</a>';
262
}
263
$xoopsTpl->assign('tellafriend_texte', $tellafriendText);
264
// référencement
265
// tags
266
if (1 == $helper->getConfig('usetag') && class_exists(Tag::class)) {
267
    require_once XOOPS_ROOT_PATH . '/modules/tag/include/tagbar.php';
268
    $xoopsTpl->assign('tags', true);
269
    $xoopsTpl->assign('tagbar', tagBar(\Xmf\Request::getInt('lid', 0, 'REQUEST'), 0));
270
} else {
271
    $xoopsTpl->assign('tags', false);
272
}
273
// titre de la page
274
$pagetitle = $viewDownloads->getVar('title') . ' - ';
275
$pagetitle .= $utility::getPathTreeUrl($mytree, $viewDownloads->getVar('cid'), $downloadscatArray, 'cat_title', $prefix = ' - ', false, 'DESC', true);
276
$xoopsTpl->assign('xoops_pagetitle', $pagetitle);
277
//version for title
278
$xoopsTpl->assign('version', $viewDownloads->getVar('version'));
279
//description
280
if (false === mb_strpos($description, '[pagebreak]')) {
281
    $descriptionShort = mb_substr($description, 0, 400);
282
} else {
283
    $descriptionShort = mb_substr($description, 0, mb_strpos($description, '[pagebreak]'));
284
}
285
$xoTheme->addMeta('meta', 'description', strip_tags($descriptionShort));
286
//keywords
287
$keywords = Metagen::generateKeywords($viewDownloads->getVar('description'), 10);
288
$xoTheme->addMeta('meta', 'keywords', implode(', ', $keywords));
289
/*$keywords = substr($keywords,0,-1);
290
$xoTheme->addMeta( 'meta', 'keywords', $keywords);*/
291
require XOOPS_ROOT_PATH . '/include/comment_view.php';
292
require XOOPS_ROOT_PATH . '/footer.php';
293