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.

blocks/tdmdownloads_top.php (3 issues)

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
 * @param $options
16
 * @return array
17
 * @author      Gregory Mage (Aka Mage)
18
 * @copyright   Gregory Mage (Aka Mage)
19
 * @license     GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
20
 */
21
22
use XoopsModules\Tdmdownloads\Helper;
23
24
/**
25
 * @param $options
26
 * @return array
27
 */
28
function b_tdmdownloads_top_show($options)
29
{
30
    require dirname(__DIR__) . '/include/common.php';
31
    /** @var \XoopsModuleHandler $moduleHandler */
32
    $moduleHandler = xoops_getHandler('module');
33
    // get the name of the file's directory to get the "owner" of the block, i.e. its module, and not the "user", where it is currently
34
    //$mydir          = basename(dirname(__DIR__));
35
    $moduleDirName = basename(dirname(__DIR__));
36
    $mymodule      = $moduleHandler->getByDirname($moduleDirName);
37
    //appel de la class
38
    /** @var \XoopsModules\Tdmdownloads\DownloadsHandler $downloadsHandler */
39
    $downloadsHandler   = Helper::getInstance()->getHandler('Downloads');
40
    $block              = [];
41
    $type_block         = $options[0];
42
    $nb_entree          = $options[1];
43
    $lenght_title       = (int)$options[2];
44
    $use_logo           = $options[3];
45
    $use_description    = $options[4];
46
    $show_information   = $options[5];
47
    $logo_float         = $options[6];
48
    $logo_width         = $options[7];
49
    $length_description = (int)$options[8];
50
    $blockstyle         = $options[9];
51
    array_shift($options);
52
    array_shift($options);
53
    array_shift($options);
54
    array_shift($options);
55
    array_shift($options);
56
    array_shift($options);
57
    array_shift($options);
58
    array_shift($options);
59
    array_shift($options);
60
    array_shift($options);
61
    // Add styles
62
    global $xoTheme;
63
    $db = null;
0 ignored issues
show
The assignment to $db is dead and can be removed.
Loading history...
64
    /** @var \xos_opal_Theme $xoTheme */
65
    $xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $moduleDirName . '/assets/css/blocks.css', null);
66
    $utility = new \XoopsModules\Tdmdownloads\Utility();
67
    /** @var \XoopsModules\Tdmdownloads\Helper $helper */
68
    $helper->loadLanguage('main');
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $helper seems to be never defined.
Loading history...
69
    $categories = $utility->getItemIds('tdmdownloads_view', $moduleDirName);
70
    $criteria   = new \CriteriaCompo();
71
    $criteria->add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN'));
72
    if (is_array($options) && !empty($options) && !0 == $options[0] && 1 === count($options)) {
73
        $criteria->add(new \Criteria('cid', '(' . implode(',', $options) . ')', 'IN'));
74
    }
75
    $criteria->add(new \Criteria('status', 0, '!='));
76
    switch ($type_block) {    // pour le bloc: dernier fichier
77
        case 'date':
78
            $criteria->setSort('date');
79
            $criteria->setOrder('DESC');
80
            break;
81
        // pour le bloc: plus téléchargé
82
        case 'hits':
83
            $criteria->setSort('hits');
84
            $criteria->setOrder('DESC');
85
            break;
86
        // pour le bloc: mieux noté
87
        case 'rating':
88
            $criteria->setSort('rating');
89
            $criteria->setOrder('DESC');
90
            break;
91
        // pour le bloc: aléatoire
92
        case 'random':
93
            $criteria->setSort('RAND()');
94
            break;
95
    }
96
    $criteria->setLimit($nb_entree);
97
    $downloadsArray = $downloadsHandler->getAll($criteria);
98
    foreach (array_keys($downloadsArray) as $i) {
99
        /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloadsArray */
100
        $block[$i]['lid'] = $downloadsArray[$i]->getVar('lid');
101
        $titleFinal       = $downloadsArray[$i]->getVar('title');
102
        if ($lenght_title > 0) {
103
            $titleFinal = mb_strlen($titleFinal) > $lenght_title ? mb_substr($titleFinal, 0, $lenght_title) . '...' : $titleFinal;
104
        }
105
        $block[$i]['title'] = $titleFinal;
106
        $descriptionFinal   = '';
107
        if (true == $use_description) {
108
            $description = $downloadsArray[$i]->getVar('description');
109
            //permet d'afficher uniquement la description courte
110
            if ($length_description > 0) {
111
                if (false === mb_strpos($description, '[pagebreak]')) {
112
                    $descriptionFinal = mb_substr($description, 0, $length_description);
113
                    if (mb_strlen($description) > mb_strlen($descriptionFinal)) {
114
                        $descriptionFinal .= ' ...';
115
                    }
116
                } else {
117
                    $descriptionFinal = mb_substr($description, 0, mb_strpos($description, '[pagebreak]')) . ' ...';
118
                }
119
            } else {
120
                $descriptionFinal = $description;
121
            }
122
        }
123
        $block[$i]['description'] = $descriptionFinal;
124
        $logourl                  = '';
125
        if (true == $use_logo) {
126
            if ('blank.gif' === $downloadsArray[$i]->getVar('logourl') || '' === $downloadsArray[$i]->getVar('logourl')) {
127
                $logourl = '';
128
            } else {
129
                $logourl = XOOPS_URL . '/uploads/' . $moduleDirName . '/images/shots/' . $downloadsArray[$i]->getVar('logourl');
130
            }
131
        }
132
        $block[$i]['logourl']       = $logourl;
133
        $block[$i]['logourl_class'] = $logo_float;
134
        $block[$i]['logourl_width'] = $logo_width;
135
        $block[$i]['hits']          = $downloadsArray[$i]->getVar('hits');
136
        $block[$i]['rating']        = number_format((float)$downloadsArray[$i]->getVar('rating'), 1);
137
        $block[$i]['date']          = formatTimestamp($downloadsArray[$i]->getVar('date'), 's');
138
        $block[$i]['submitter']     = \XoopsUser::getUnameFromId($downloadsArray[$i]->getVar('submitter'));
139
        $block[$i]['inforation']    = $show_information;
140
        $block[$i]['blockstyle']    = $blockstyle;
141
    }
142
    $GLOBALS['xoopsTpl']->assign('tdmblockstyle', $blockstyle);
143
    /** @var \XoopsGroupPermHandler $grouppermHandler */
144
    $grouppermHandler = xoops_getHandler('groupperm');
145
    $groups           = XOOPS_GROUP_ANONYMOUS;
146
    if (is_object($GLOBALS['xoopsUser'])) {
147
        $groups = $GLOBALS['xoopsUser']->getGroups();
148
    }
149
    $perm_submit = $grouppermHandler->checkRight('tdmdownloads_ac', 4, $groups, $mymodule->getVar('mid')) ? true : false;
150
    $perm_modif  = $grouppermHandler->checkRight('tdmdownloads_ac', 8, $groups, $mymodule->getVar('mid')) ? true : false;
151
    $GLOBALS['xoopsTpl']->assign('perm_submit', $perm_submit);
152
    $GLOBALS['xoopsTpl']->assign('perm_modif', $perm_modif);
153
    return $block;
154
}
155
156
/**
157
 * @param $options
158
 *
159
 * @return string
160
 */
161
function b_tdmdownloads_top_edit($options)
162
{
163
    //appel de la class
164
    $moduleDirName   = basename(dirname(__DIR__));
0 ignored issues
show
The assignment to $moduleDirName is dead and can be removed.
Loading history...
165
    $categoryHandler = Helper::getInstance()->getHandler('Category');
166
    $criteria        = new \CriteriaCompo();
167
    $criteria->setSort('cat_weight ASC, cat_title');
168
    $criteria->setOrder('ASC');
169
    $downloadscatArray = $categoryHandler->getAll($criteria);
170
    $form              = _MB_TDMDOWNLOADS_DISP . "&nbsp;\n";
171
    $form              .= '<input type="hidden" name="options[0]" value="' . $options[0] . "\">\n";
172
    $form              .= '<input name="options[1]" size="5" maxlength="255" value="' . $options[1] . '" type="text">&nbsp;' . _MB_TDMDOWNLOADS_FILES . "<br>\n";
173
    $form              .= _MB_TDMDOWNLOADS_CHARS . ' (<small>' . _MB_TDMDOWNLOADS_CHARSDSC . '</small>): <input name="options[2]" size="5" maxlength="255" value="' . $options[2] . "\" type=\"text\"><br>\n";
174
    if (false == $options[3]) {
175
        $checked_yes = '';
176
        $checked_no  = 'checked';
177
    } else {
178
        $checked_yes = 'checked';
179
        $checked_no  = '';
180
    }
181
    $form .= _MB_TDMDOWNLOADS_LOGO . ' : <input name="options[3]" value="1" type="radio" ' . $checked_yes . '>' . _YES . "&nbsp;\n";
182
    $form .= '<input name="options[3]" value="0" type="radio" ' . $checked_no . '>' . _NO . "<br>\n";
183
    if (false == $options[4]) {
184
        $checked_yes = '';
185
        $checked_no  = 'checked';
186
    } else {
187
        $checked_yes = 'checked';
188
        $checked_no  = '';
189
    }
190
    $form .= _MB_TDMDOWNLOADS_DESCRIPTION . ' : <input name="options[4]" value="1" type="radio" ' . $checked_yes . '>' . _YES . "&nbsp;\n";
191
    $form .= '<input name="options[4]" value="0" type="radio" ' . $checked_no . '>' . _NO . "<br>\n";
192
    if (false == $options[5]) {
193
        $checked_yes = '';
194
        $checked_no  = 'checked';
195
    } else {
196
        $checked_yes = 'checked';
197
        $checked_no  = '';
198
    }
199
    $form        .= _MB_TDMDOWNLOADS_INFORMATIONS . ' : <input name="options[5]" value="1" type="radio" ' . $checked_yes . '>' . _YES . "&nbsp;\n";
200
    $form        .= '<input name="options[5]" value="0" type="radio" ' . $checked_no . '>' . _NO . "<br><br>\n";
201
    $floatSelect = new \XoopsFormSelect('', 'options[6]', $options[6]);
202
    $floatSelect->addOption('left', _MB_TDMDOWNLOADS_FLOAT_LEFT);
203
    $floatSelect->addOption('right', _MB_TDMDOWNLOADS_FLOAT_RIGHT);
204
    $form        .= _MB_TDMDOWNLOADS_FLOAT . $floatSelect->render() . '<br>';
205
    $form        .= _MB_TDMDOWNLOADS_WIDTH . ' (<small>' . _MB_TDMDOWNLOADS_WIDTHDSC . '</small>): <input name="options[7]" size="5" maxlength="255" value="' . $options[7] . "\" type=\"text\"><br>\n";
206
    $form        .= _MB_TDMDOWNLOADS_DESCRIPTIONDSC . ': <input name="options[8]" size="5" maxlength="255" value="' . $options[8] . "\" type=\"text\"><br>\n";
207
    $styleSelect = new \XoopsFormSelect('', 'options[9]', $options[9]);
208
    $styleSelect->addOption('default', 'default');
209
    $styleSelect->addOption('simple1', 'simple1');
210
    $styleSelect->addOption('simple2', 'simple2');
211
    $styleSelect->addOption('simple3', 'simple3');
212
    $styleSelect->addOption('simple4', 'simple4');
213
    $form .= _MB_TDMDOWNLOADS_BLOCKSTYLE . ': ' . $styleSelect->render() . '<br>';
214
    array_shift($options);
215
    array_shift($options);
216
    array_shift($options);
217
    array_shift($options);
218
    array_shift($options);
219
    array_shift($options);
220
    array_shift($options);
221
    array_shift($options);
222
    array_shift($options);
223
    $form .= _MB_TDMDOWNLOADS_CATTODISPLAY . "<br><select name=\"options[]\" multiple=\"multiple\" size=\"5\">\n";
224
    $form .= '<option value="0" ' . (!in_array(0, $options, false) ? '' : 'selected="selected"') . '>' . _MB_TDMDOWNLOADS_ALLCAT . "</option>\n";
225
    foreach (array_keys($downloadscatArray) as $i) {
226
        /** @var \XoopsModules\Tdmdownloads\Category[] $downloadscatArray */
227
        $form .= '<option value="' . $downloadscatArray[$i]->getVar('cat_cid') . '" ' . (!in_array($downloadscatArray[$i]->getVar('cat_cid'), $options, false) ? '' : 'selected') . '>' . $downloadscatArray[$i]->getVar('cat_title') . "</option>\n";
228
    }
229
    $form .= "</select>\n";
230
    return $form;
231
}
232