Issues (411)

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
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * Wfdownloads module
14
 *
15
 * @copyright       XOOPS Project (https://xoops.org)
16
 * @license         GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
17
 * @package         wfdownload
18
 * @since           3.23
19
 * @author          Xoops Development Team
20
 */
21
22
use XoopsModules\Wfdownloads\{
23
    Common\LetterChoice,
24
    Category,
25
    Common,
26
    Helper,
27
    Utility,
28
    ObjectTree,
29
    DownloadHandler,
30
};
31
/** @var Helper $helper */
32
/** @var Utility $utility */
33
/** @var Category $categoryObj_a */
34
35
//$currentFile = pathinfo(__FILE__, PATHINFO_BASENAME);
36
//$currentFile = basename(__FILE__);
37
require_once __DIR__ . '/header.php';
38
39
$moduleDirName      = basename(__DIR__);
40
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
41
42
// Check directories
43
if (!is_dir($helper->getConfig('uploaddir'))) {
44
    redirect_header(XOOPS_URL, 4, _MD_WFDOWNLOADS_ERROR_UPLOADDIRNOTEXISTS);
45
}
46
if (!is_dir(XOOPS_ROOT_PATH . '/' . $helper->getConfig('mainimagedir'))) {
47
    redirect_header(XOOPS_URL, 4, _MD_WFDOWNLOADS_ERROR_MAINIMAGEDIRNOTEXISTS);
48
}
49
if (!is_dir(XOOPS_ROOT_PATH . '/' . $helper->getConfig('screenshots'))) {
50
    redirect_header(XOOPS_URL, 4, _MD_WFDOWNLOADS_ERROR_SCREENSHOTSDIRNOTEXISTS);
51
}
52
if (!is_dir(XOOPS_ROOT_PATH . '/' . $helper->getConfig('catimage'))) {
53
    redirect_header(XOOPS_URL, 4, _MD_WFDOWNLOADS_ERROR_CATIMAGEDIRNOTEXISTS);
54
}
55
56
$groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [0 => XOOPS_GROUP_ANONYMOUS];
57
58
// Check if submission is allowed
59
$isSubmissionAllowed = false;
60
if (is_object($GLOBALS['xoopsUser']) && (_WFDOWNLOADS_SUBMISSIONS_DOWNLOAD == $helper->getConfig('submissions') || _WFDOWNLOADS_SUBMISSIONS_BOTH == $helper->getConfig('submissions'))) {
61
    // if user is a registered user
62
    $groups = $GLOBALS['xoopsUser']->getGroups();
63
    if (count(array_intersect($helper->getConfig('submitarts'), $groups)) > 0) {
64
        $isSubmissionAllowed = true;
65
    }
66
} else {
67
    // if user is anonymous
68
    if (_WFDOWNLOADS_ANONPOST_DOWNLOAD == $helper->getConfig('anonpost') || _WFDOWNLOADS_ANONPOST_BOTH == $helper->getConfig('anonpost')) {
69
        $isSubmissionAllowed = true;
70
    }
71
}
72
73
// Get download/upload permissions
74
75
/** @var \XoopsGroupPermHandler $grouppermHandler */
76
$grouppermHandler = xoops_getHandler('groupperm');
77
78
$allowedDownCategoriesIds = $grouppermHandler->getItemIds('WFDownCatPerm', $groups, $helper->getModule()->mid());
79
$allowedUpCategoriesIds   = $grouppermHandler->getItemIds('WFUpCatPerm', $groups, $helper->getModule()->mid());
80
81
$GLOBALS['xoopsOption']['template_main'] = "{$helper->getDirname()}_index.tpl";
82
83
require_once XOOPS_ROOT_PATH . '/header.php';
84
85
$xoTheme->addScript(XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js');
86
$xoTheme->addScript(WFDOWNLOADS_URL . '/assets/js/magnific/jquery.magnific-popup.min.js');
0 ignored issues
show
The constant WFDOWNLOADS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
87
$xoTheme->addStylesheet(WFDOWNLOADS_URL . '/assets/js/magnific/magnific-popup.css');
88
$xoTheme->addStylesheet(WFDOWNLOADS_URL . '/assets/css/module.css');
89
90
$xoopsTpl->assign('wfdownloads_url', WFDOWNLOADS_URL . '/');
91
92
// Breadcrumb
93
$breadcrumb = new Common\Breadcrumb();
94
$breadcrumb->addLink($helper->getModule()->getVar('name'), WFDOWNLOADS_URL);
95
96
$xoopsTpl->assign('module_home', Utility::moduleHome(false)); // this definition is not removed for backward compatibility issues
97
$xoopsTpl->assign('wfdownloads_breadcrumb', $breadcrumb->render());
98
99
$categoryCriteria = new CriteriaCompo();
100
$categoryCriteria->setSort('weight ASC, title');
101
$categoryObjs = $helper->getHandler('Category')->getObjects($categoryCriteria);
102
unset($categoryCriteria);
103
104
$categoryObjsTree = new ObjectTree($categoryObjs, 'cid', 'pid');
105
106
// Generate content header
107
$sql                          = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_indexpage') . ' ';
108
$head_arr                     = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql));
109
$catarray['imageheader']      = Utility::headerImage();
110
$catarray['indexheaderalign'] = $head_arr['indexheaderalign'];
111
$catarray['indexfooteralign'] = $head_arr['indexfooteralign'];
112
$html                         = $head_arr['nohtml'] ? 1 : 0;
113
$smiley                       = $head_arr['nosmiley'] ? 1 : 0;
114
$xcodes                       = $head_arr['noxcodes'] ? 1 : 0;
115
$images                       = $head_arr['noimages'] ? 1 : 0;
116
$breaks                       = $head_arr['nobreak'] ? 1 : 0;
117
$catarray['indexheader']      = &$myts->displayTarea($head_arr['indexheader'], $html, $smiley, $xcodes, $images, $breaks);
118
$catarray['indexfooter']      = &$myts->displayTarea($head_arr['indexfooter'], $html, $smiley, $xcodes, $images, $breaks);
119
120
$showAlphabet = $helper->getConfig('showAlphabet');
121
if ($showAlphabet) {
122
    //$catarray['letters']          = Utility::lettersChoice();
123
124
    // Letter Choice Start ---------------------------------------
125
126
    $helper->loadLanguage('common');
127
    $xoopsTpl->assign('letterChoiceTitle', constant('CO_' . $moduleDirNameUpper . '_' . 'BROWSETOTOPIC'));
128
    $db             = XoopsDatabaseFactory::getDatabaseConnection();
129
    $objHandler     = new DownloadHandler($db);
130
    $choicebyletter = new LetterChoice($objHandler, null, null, range('a', 'z'), 'letter', 'viewcat.php');
131
    //$choicebyletter = new LetterChoice($objHandler, null, null, range('a', 'z'), 'init', XOOPSTUBE_URL . '/letter.php');
132
    //render the LetterChoice partial and story as part of the Category array
133
    //$catarray['letters']  = $choicebyletter->render($alphaCount, $howmanyother);
134
135
    $catarray['letters'] = $choicebyletter->render();
136
137
    //now assign it to the Smarty variable
138
    $xoopsTpl->assign('catarray', $catarray);
139
    // Letter Choice End ------------------------------------
140
}
141
$catarray['toolbar'] = Utility::toolbar();
142
$xoopsTpl->assign('catarray', $catarray);
143
144
// Begin Main page download info
145
$chcount = 0;
146
$countin = 0;
147
148
$listings = Utility::getTotalDownloads($allowedDownCategoriesIds);
149
150
// Get total amount of categories
151
$total_cat = count($allowedDownCategoriesIds);
152
// Get all main categories
153
$mainCategoryObjs = $categoryObjsTree->getFirstChild(0);
154
$count            = 0;
155
156
// Comparison functions for uasort()
157
/**
158
 * @param Category $categoryObj_a
159
 * @param Category $categoryObj_b
160
 *
161
 * @return int
162
 */
163
function categoriesCompareCid(Category $categoryObj_a, Category $categoryObj_b)
164
{
165
    if ($categoryObj_a->getVar('cid') == $categoryObj_b->getVar('cid')) {
166
        return 0;
167
    }
168
169
    return ($categoryObj_a->getVar('cid') < $categoryObj_b->getVar('cid')) ? -1 : 1;
170
}
171
172
/**
173
 * @param Category $categoryObj_a
174
 * @param Category $categoryObj_b
175
 *
176
 * @return int
177
 */
178
function categoriesCompareTitle(Category $categoryObj_a, Category $categoryObj_b)
179
{
180
    if ($categoryObj_a->getVar('title') == $categoryObj_b->getVar('title')) {
181
        return 0;
182
    }
183
184
    return ($categoryObj_a->getVar('title') < $categoryObj_b->getVar('title')) ? -1 : 1;
185
}
186
187
/**
188
 * @param Category $categoryObj_a
189
 * @param Category $categoryObj_b
190
 *
191
 * @return int
192
 */
193
function categoriesCompareWeight(Category $categoryObj_a, Category $categoryObj_b)
194
{
195
    if ($categoryObj_a->getVar('weight') == $categoryObj_b->getVar('weight')) {
196
        return 0;
197
    }
198
199
    return ($categoryObj_a->getVar('weight') < $categoryObj_b->getVar('weight')) ? -1 : 1;
200
}
201
202
// Foreach main category
203
foreach (array_keys($mainCategoryObjs) as $i) {
204
    if (in_array($mainCategoryObjs[$i]->getVar('cid'), $allowedDownCategoriesIds)) {
205
        // Get this category image
206
        // Get this category subcategories
207
        $allSubcategoryObjs = $categoryObjsTree->getAllChild($mainCategoryObjs[$i]->getVar('cid'));
208
209
        // Sort subcategories by: cid or title or weight
210
        switch ($helper->getConfig('subcatssortby')) {
211
            case 'cid':
212
                uasort($allSubcategoryObjs, 'categoriesCompareCid');
213
                break;
214
            case 'title':
215
                uasort($allSubcategoryObjs, 'categoriesCompareTitle');
216
                break;
217
            case 'weight':
218
            default:
219
                uasort($allSubcategoryObjs, 'categoriesCompareWeight');
220
                break;
221
        }
222
223
        // Get this category indicator image
224
        $publishdate = $listings['published'][$mainCategoryObjs[$i]->getVar('cid')] ?? 0;
225
        if (count($allSubcategoryObjs) > 0) {
226
            // Foreach subcategory
227
            foreach (array_keys($allSubcategoryObjs) as $k) {
228
                if (in_array($allSubcategoryObjs[$k]->getVar('cid'), $allowedDownCategoriesIds)) {
229
                    $publishdate = (isset($listings['published'][$allSubcategoryObjs[$k]->getVar('cid')])
230
                                    && $listings['published'][$allSubcategoryObjs[$k]->getVar('cid')] > $publishdate) ? $listings['published'][$allSubcategoryObjs[$k]->getVar('cid')] : $publishdate;
231
                }
232
            }
233
        }
234
        $isNewImage = Utility::isNewImage($publishdate);
235
        if (('' !== $mainCategoryObjs[$i]->getVar('imgurl')) && is_file(XOOPS_ROOT_PATH . '/' . $helper->getConfig('catimage') . '/' . $mainCategoryObjs[$i]->getVar('imgurl'))) {
236
            if ($helper->getConfig('usethumbs') && function_exists('gd_info')) {
237
                $imageURL = Utility::createThumb(
238
                    $mainCategoryObjs[$i]->getVar('imgurl'),
239
                    $helper->getConfig('catimage'),
240
                    'thumbs',
241
                    $helper->getConfig('cat_imgwidth'),
242
                    $helper->getConfig('cat_imgheight'),
243
                    $helper->getConfig('imagequality'),
244
                    $helper->getConfig('updatethumbs'),
245
                    $helper->getConfig('keepaspect')
246
                );
247
            } else {
248
                $imageURL = XOOPS_URL . '/' . $helper->getConfig('catimage') . '/' . $mainCategoryObjs[$i]->getVar('imgurl');
249
            }
250
        } else {
251
            $imageURL = $isNewImage['image'];
252
        }
253
254
        // Get this category subcategories id and title
255
        $subcategories = [];
256
        ++$count;
257
        $download_count = $listings['count'][$mainCategoryObjs[$i]->getVar('cid')] ?? 0;
258
        // modified July 5 2006 by Freeform Solutions (jwe)
259
        // make download count recursive, to include all sub categories that the user has permission to view
260
        //$allSubcategoryObjs = $categoryObjsTree->getAllChild($mainCategoryObjs[$i]->getVar('cid'));
261
        if (count($allSubcategoryObjs) > 0) {
262
            foreach (array_keys($allSubcategoryObjs) as $k) {
263
                if (in_array($allSubcategoryObjs[$k]->getVar('cid'), $allowedDownCategoriesIds)) {
264
                    $download_count += $listings['count'][$allSubcategoryObjs[$k]->getVar('cid')] ?? 0;
265
                    if (1 == $helper->getConfig('subcats') && $allSubcategoryObjs[$k]->getVar('pid') == $mainCategoryObjs[$i]->getVar('cid')) {
266
                        // if we are collecting subcat info for displaying, and this subcat is a first level child...
267
                        $subcategories[] = [
268
                            'id'               => $allSubcategoryObjs[$k]->getVar('cid'), // this definition is not removed for backward compatibility issues
269
                            'cid'              => $allSubcategoryObjs[$k]->getVar('cid'),
270
                            'allowed_download' => in_array($allSubcategoryObjs[$k]->getVar('cid'), $allowedDownCategoriesIds),
271
                            'allowed_upload'   => $isSubmissionAllowed && in_array($allSubcategoryObjs[$k]->getVar('cid'), $allowedUpCategoriesIds),
272
                            'title'            => $allSubcategoryObjs[$k]->getVar('title'),
273
                        ];
274
                    }
275
                }
276
            }
277
        }
278
279
        if (true !== $helper->getConfig('subcats')) {
280
            unset($subcategories);
281
            $xoopsTpl->append(
282
                'categories',
283
                [
284
                    'image'            => $imageURL, // this definition is not removed for backward compatibility issues
285
                    'image_URL'        => $imageURL,
286
                    'days'             => $isNewImage['days'],
287
                    'id'               => (int)$mainCategoryObjs[$i]->getVar('cid'), // this definition is not removed for backward compatibility issues
288
                    'cid'              => (int)$mainCategoryObjs[$i]->getVar('cid'),
289
                    'allowed_download' => in_array($mainCategoryObjs[$i]->getVar('cid'), $allowedDownCategoriesIds),
290
                    'allowed_upload'   => $isSubmissionAllowed && in_array($mainCategoryObjs[$i]->getVar('cid'), $allowedUpCategoriesIds),
291
                    'title'            => $mainCategoryObjs[$i]->getVar('title'),
292
                    'summary'          => $mainCategoryObjs[$i]->getVar('summary'),
293
                    'totaldownloads'   => $download_count, // this definition is not removed for backward compatibility issues
294
                    'downloads_count'  => $download_count,
295
                    'count'            => $count,
296
                    'alttext'          => $isNewImage['alttext'],
297
                ]
298
            );
299
        } else {
300
            $xoopsTpl->append(
301
                'categories',
302
                [
303
                    'image'            => $imageURL, // this definition is not removed for backward compatibility issues
304
                    'image_URL'        => $imageURL,
305
                    'days'             => $isNewImage['days'],
306
                    'id'               => (int)$mainCategoryObjs[$i]->getVar('cid'), // this definition is not removed for backward compatibility issues
307
                    'cid'              => (int)$mainCategoryObjs[$i]->getVar('cid'),
308
                    'allowed_download' => in_array($mainCategoryObjs[$i]->getVar('cid'), $allowedDownCategoriesIds),
309
                    'allowed_upload'   => $isSubmissionAllowed && in_array($mainCategoryObjs[$i]->getVar('cid'), $allowedUpCategoriesIds),
310
                    'title'            => $mainCategoryObjs[$i]->getVar('title'),
311
                    'summary'          => $mainCategoryObjs[$i]->getVar('summary'),
312
                    'subcategories'    => $subcategories,
313
                    'totaldownloads'   => $download_count, // this definition is not removed for backward compatibility issues
314
                    'downloads_count'  => $download_count,
315
                    'count'            => $count,
316
                    'alttext'          => $isNewImage['alttext'],
317
                ]
318
            );
319
        }
320
    }
321
}
322
$lang_ThereAre = 1 != $count ? _MD_WFDOWNLOADS_THEREARE : _MD_WFDOWNLOADS_THEREIS;
323
324
$xoopsTpl->assign('lang_thereare', sprintf($lang_ThereAre, $count, array_sum($listings['count'])));
325
326
if (true === $helper->getConfig('enablerss')) {
327
    $rsslink_URL = WFDOWNLOADS_URL . '/rss.php';
328
    $xoopsTpl->assign('full_rssfeed_URL', $rsslink_URL);
329
    $rsslink = "<a href='" . $rsslink_URL . "' title='" . _MD_WFDOWNLOADS_LEGENDTEXTRSS . "'>";
330
    $rsslink .= "<img src='" . WFDOWNLOADS_URL . "/assets/images/icon/rss.gif' border='0' alt='" . _MD_WFDOWNLOADS_LEGENDTEXTRSS . "' title='" . _MD_WFDOWNLOADS_LEGENDTEXTRSS . "'>";
331
    $rsslink .= '</a>';
332
    $xoopsTpl->assign('full_rssfeed_link', $rsslink); // this definition is not removed for backward compatibility issues
333
}
334
335
require_once __DIR__ . '/footer.php';
336