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.

singlefile.php (3 issues)

Labels
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 Xmf\Request;
23
use XoopsModules\Wfdownloads\{
24
    Common,
25
    Helper,
26
    Utility,
27
    ObjectTree
28
};
29
/** @var Helper $helper */
30
/** @var Utility $utility */
31
32
$currentFile = basename(__FILE__);
33
require_once __DIR__ . '/header.php';
34
35
/** @var \XoopsGroupPermHandler $grouppermHandler */
36
$grouppermHandler = xoops_getHandler('groupperm');
37
38
$lid         = Request::getInt('lid', 0);
39
$downloadObj = $helper->getHandler('Download')->get($lid);
40
if (null === $downloadObj) {
41
    redirect_header('index.php', 3, _CO_WFDOWNLOADS_ERROR_NODOWNLOAD);
42
}
43
$cid         = Request::getInt('cid', $downloadObj->getVar('cid'));
44
$categoryObj = $helper->getHandler('Category')->get($cid);
45
if (null === $categoryObj) {
46
    redirect_header('index.php', 3, _CO_WFDOWNLOADS_ERROR_NOCATEGORY);
47
}
48
49
// Check permissions
50
$userGroups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [0 => XOOPS_GROUP_ANONYMOUS];
51
if (!$grouppermHandler->checkRight('WFDownCatPerm', $cid, $userGroups, $helper->getModule()->mid())) {
52
    if (in_array(XOOPS_GROUP_ANONYMOUS, $userGroups)) {
53
        redirect_header(XOOPS_URL . '/user.php', 3, _MD_WFDOWNLOADS_NEEDLOGINVIEW);
54
    } else {
55
        redirect_header('index.php', 3, _NOPERM);
56
    }
57
}
58
59
// Get download
60
if ($downloadObj->isNew()) {
61
    redirect_header('index.php', 1, _MD_WFDOWNLOADS_NODOWNLOAD);
62
}
63
64
// If Download not published, expired or taken offline - redirect
65
if (0 == $downloadObj->getVar('published') || $downloadObj->getVar('published') > time()
66
    || true === $downloadObj->getVar('offline')
67
    || (0 != $downloadObj->getVar('expired')
68
        && $downloadObj->getVar('expired') < time())
69
    || _WFDOWNLOADS_STATUS_WAITING == $downloadObj->getVar('status')) {
70
    redirect_header('index.php', 3, _MD_WFDOWNLOADS_NODOWNLOAD);
71
}
72
73
// Load Template
74
$GLOBALS['xoopsOption']['template_main'] = "{$helper->getModule()->dirname()}_singlefile.tpl";
75
require_once XOOPS_ROOT_PATH . '/header.php';
76
77
$xoTheme->addScript(XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js');
78
$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...
79
$xoTheme->addStylesheet(WFDOWNLOADS_URL . '/assets/js/magnific/magnific-popup.css');
80
$xoTheme->addStylesheet(WFDOWNLOADS_URL . '/assets/css/module.css');
81
82
$xoopsTpl->assign('wfdownloads_url', WFDOWNLOADS_URL . '/');
83
84
85
//assign title of the download to Page title
86
if ($helper->getConfig('shortTitles')) {
87
    $xoopsTpl->assign('xoops_pagetitle', $downloadObj->getVar('title'));
88
} else {
89
    $xoopsTpl->assign('xoops_pagetitle', $downloadObj->getVar('title') . ' | ' . $helper->getModule()->name());
90
}
91
92
93
// Making the category image and title available in the template
94
if (('' != $categoryObj->getVar('imgurl'))
95
    && is_file(XOOPS_ROOT_PATH . '/' . $helper->getConfig('catimage') . '/' . $categoryObj->getVar('imgurl'))) {
96
    if ($helper->getConfig('usethumbs') && function_exists('gd_info')) {
97
        $imgurl = Utility::createThumb(
98
            $categoryObj->getVar('imgurl'),
99
            $helper->getConfig('catimage'),
100
            'thumbs',
101
            $helper->getConfig('cat_imgwidth'),
102
            $helper->getConfig('cat_imgheight'),
103
            $helper->getConfig('imagequality'),
104
            $helper->getConfig('updatethumbs'),
105
            $helper->getConfig('keepaspect')
106
        );
107
    } else {
108
        $imgurl = XOOPS_URL . '/' . $helper->getConfig('catimage') . '/' . $categoryObj->getVar('imgurl');
109
    }
110
} else {
111
    $imgurl = XOOPS_URL . '/' . $helper->getConfig('catimage') . '/blank.png';
112
}
113
$xoopsTpl->assign('category_title', $categoryObj->getVar('title'));
114
$xoopsTpl->assign('category_image', $imgurl);
115
116
// Retreiving the top parent category
117
$categoriesTopParentByCid = $helper->getHandler('Category')->getAllSubcatsTopParentCid();
118
$topCategoryObj           = $helper->getHandler('Category')->get($categoriesTopParentByCid[$cid]);
119
120
$xoopsTpl->assign('topcategory_title', $topCategoryObj->getVar('title'));
121
$xoopsTpl->assign('topcategory_image', $topCategoryObj->getVar('imgurl'));
122
$xoopsTpl->assign('topcategory_cid', $topCategoryObj->getVar('cid'));
123
124
// Formulize module support (2006/03/06, 2006/03/08) jpc - start
125
$formulize_idreq = $downloadObj->getVar('formulize_idreq');
126
if (Utility::checkModule('formulize') && $formulize_idreq) {
127
    $xoopsTpl->assign('custom_form', true);
128
    require_once XOOPS_ROOT_PATH . '/modules/formulize/include/extract.php';
129
    // get the form id and id_req of the user's entry
130
    $formulizeModule = $moduleHandler->getByDirname('formulize');
131
    $formulizeConfig = $configHandler->getConfigsByCat(0, $formulizeModule->mid());
132
133
    $formulize_fid = $categoryObj->getVar('formulize_fid');
134
135
    if ($formulize_fid) {
136
        // get Formulize form description
137
        $sql                 = 'SELECT desc_form';
138
        $sql                 .= " FROM {$GLOBALS['xoopsDB']->prefix('formulize_id')}";
139
        $sql                 .= " WHERE id_form = '{$formulize_fid}'";
140
        $formulize_formQuery = $GLOBALS['xoopsDB']->query($sql);
141
        if (false !== ($formulize_form_array = $GLOBALS['xoopsDB']->fetchArray($formulize_formQuery))) {
142
            $desc_form = $formulize_form_array['desc_form'];
143
144
            // query the form for its data
145
            $data = getData('', $formulize_fid, $formulize_idreq); // is a Formulize function
0 ignored issues
show
The function getData was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

145
            $data = /** @scrutinizer ignore-call */ getData('', $formulize_fid, $formulize_idreq); // is a Formulize function
Loading history...
146
            // include only elements that are visible to the user's groups in the DB query below
147
            $userGroups = $GLOBALS['xoopsUser'] ? $GLOBALS['xoopsUser']->getGroups() : [0 => XOOPS_GROUP_ANONYMOUS];
148
            $start      = 1;
149
            foreach ($userGroups as $thisgroup) {
150
                if ($start) {
151
                    $userGroups_query = "ele_display LIKE '%,{$thisgroup},%'";
152
                    $start            = 0;
153
                } else {
154
                    $userGroups_query .= " OR ele_display LIKE '%,{$thisgroup},%'";
155
                }
156
            }
157
            // collect the element id numbers for use in a DB query, and apply the groups filter to each
158
            $start = 1;
159
            foreach ($data[0][$desc_form][$formulize_idreq] as $ele_id => $values) {
160
                if ($start) {
161
                    $ele_id_query = "(ele_id='{$ele_id}' AND (ele_display=1 OR ({$userGroups_query})))";
162
                    $start        = 0;
163
                } else {
164
                    $ele_id_query .= " OR (ele_id='{$ele_id}' AND (ele_display=1 OR ({$userGroups_query})))";
165
                }
166
            }
167
            // get the captions for the elements that are visible to the user's groups
168
            $sql          = 'SELECT ele_caption, ele_id, ele_display';
169
            $sql          .= " FROM {$GLOBALS['xoopsDB']->prefix('formulize')}";
170
            $sql          .= " WHERE ({$ele_id_query}) AND ele_type <> 'ib' AND ele_type <> 'sep' AND ele_type <> 'areamodif'";
171
            $sql          .= ' ORDER BY ele_order';
172
            $captionQuery = $GLOBALS['xoopsDB']->query($sql);
173
            // collect the captions and their values into an array for passing to the template
174
            $formulize_fields = [];
175
            $i                = 0;
176
            while (false !== ($caption_array = $GLOBALS['xoopsDB']->fetchArray($captionQuery))) {
177
                $formulize_fields[$i]['caption'] = $caption_array['ele_caption'];
178
                if (count($data[0][$desc_form][$formulize_idreq][$caption_array['ele_id']]) > 1) {
179
                    $formulize_fields[$i]['values'][] = implode(', ', $data[0][$desc_form][$formulize_idreq][$caption_array['ele_id']]);
180
                } else {
181
                    $formulize_fields[$i]['values'][] = $data[0][$desc_form][$formulize_idreq][$caption_array['ele_id']][0];
182
                }
183
                ++$i;
184
            }
185
            $xoopsTpl->assign('formulize_download', $formulize_fields); // this definition is not removed for backward compatibility issues
186
            $xoopsTpl->assign('custom_fields', $formulize_fields);
187
        }
188
    }
189
} else {
190
    $xoopsTpl->assign('custom_form', false);
191
}
192
// Formulize module support (2006/03/06, 2006/03/08) jpc - end
193
194
$use_mirrors = $helper->getConfig('enable_mirrors');
195
$add_mirror  = false;
196
if (!is_object($GLOBALS['xoopsUser']) && true === $use_mirrors
197
    && (_WFDOWNLOADS_ANONPOST_MIRROR == $helper->getConfig('anonpost')
198
        || _WFDOWNLOADS_ANONPOST_BOTH == $helper->getConfig('anonpost'))
199
    && (_WFDOWNLOADS_SUBMISSIONS_MIRROR == $helper->getConfig('submissions')
200
        || _WFDOWNLOADS_SUBMISSIONS_BOTH == $helper->getConfig('submissions'))) {
201
    $add_mirror = true;
202
} elseif (is_object($GLOBALS['xoopsUser']) && true === $use_mirrors
203
          && (_WFDOWNLOADS_SUBMISSIONS_MIRROR == $helper->getConfig('submissions')
204
              || _WFDOWNLOADS_SUBMISSIONS_BOTH == $helper->getConfig('submissions')
205
              || Utility::userIsAdmin())) {
206
    $add_mirror = true;
207
}
208
209
// Get download information
210
$downloadInfo = $downloadObj->getDownloadInfo();
211
$xoopsTpl->assign('categoryPath', $downloadInfo['path'] . ' > ' . $downloadInfo['title']); // this definition is not removed for backward compatibility issues
212
$xoopsTpl->assign('lang_dltimes', sprintf(_MD_WFDOWNLOADS_DLTIMES, $downloadInfo['hits']));
213
$xoopsTpl->assign('lang_subdate', $downloadInfo['is_updated']);
214
$xoopsTpl->assign('file_url', $downloadInfo['file_url']); // this definition is not removed for backward compatibility issues
215
$xoopsTpl->append('file', $downloadInfo);
216
$xoopsTpl->assign('show_screenshot', false);
217
218
if (1 == $helper->getConfig('screenshot')) {
219
    $xoopsTpl->assign('shots_dir', $helper->getConfig('screenshots'));
220
    $xoopsTpl->assign('shotwidth', $helper->getConfig('shotwidth'));
221
    $xoopsTpl->assign('shotheight', $helper->getConfig('shotheight'));
222
    $xoopsTpl->assign('show_screenshot', true);
223
}
224
225
// Breadcrumb
226
require_once XOOPS_ROOT_PATH . '/class/tree.php';
227
$categoryObjsTree = new ObjectTree($helper->getHandler('Category')->getObjects(), 'cid', 'pid');
0 ignored issues
show
$helper->getHandler('Category')->getObjects() cannot be passed to XoopsModules\Wfdownloads\ObjectTree::__construct() as the parameter $objectArr expects a reference. ( Ignorable by Annotation )

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

227
$categoryObjsTree = new ObjectTree(/** @scrutinizer ignore-type */ $helper->getHandler('Category')->getObjects(), 'cid', 'pid');
Loading history...
228
$breadcrumb       = new Common\Breadcrumb();
229
$breadcrumb->addLink($helper->getModule()->getVar('name'), WFDOWNLOADS_URL);
230
foreach (array_reverse($categoryObjsTree->getAllParent($cid)) as $parentCategory) {
231
    $breadcrumb->addLink($parentCategory->getVar('title'), 'viewcat.php?cid=' . $parentCategory->getVar('cid'));
232
}
233
$breadcrumb->addLink($categoryObj->getVar('title'), 'viewcat.php?cid=' . $categoryObj->getVar('cid'));
234
$breadcrumb->addLink($downloadInfo['title'], '');
235
$xoopsTpl->assign('wfdownloads_breadcrumb', $breadcrumb->render());
236
237
// Show other author downloads
238
$downloadByUserCriteria = new CriteriaCompo(new Criteria('submitter', $downloadObj->getVar('submitter')));
239
$downloadByUserCriteria->add(new Criteria('lid', $lid, '!='));
240
$downloadByUserCriteria->setLimit(20);
241
$downloadByUserCriteria->setSort('published');
242
$downloadByUserCriteria->setOrder('DESC');
243
$downloadByUserObjs = $helper->getHandler('Download')->getActiveDownloads($downloadByUserCriteria);
244
foreach ($downloadByUserObjs as $downloadByUserObj) {
245
    $downloadByUser['title']     = $downloadByUserObj->getVar('title');
246
    $downloadByUser['lid']       = (int)$downloadByUserObj->getVar('lid');
247
    $downloadByUser['cid']       = (int)$downloadByUserObj->getVar('cid');
248
    $downloadByUser['published'] = formatTimestamp($downloadByUserObj->getVar('published'), $helper->getConfig('dateformat'));
249
    $xoopsTpl->append('down_uid', $downloadByUser); // this definition is not removed for backward compatibility issues
250
    $xoopsTpl->append('downloads_by_user', $downloadByUser);
251
}
252
253
$cid = (int)$downloadObj->getVar('cid');
254
$lid = (int)$downloadObj->getVar('lid');
255
256
// User reviews
257
$criteria = new CriteriaCompo(new Criteria('lid', $lid));
258
$criteria->add(new Criteria('submit', 1));
259
$reviewCount = $helper->getHandler('Review')->getCount($criteria);
260
if ($reviewCount > 0) {
261
    $user_reviews = "op=list&amp;cid={$cid}&amp;lid={$lid}\">" . _MD_WFDOWNLOADS_USERREVIEWS;
262
} else {
263
    $user_reviews = "cid={$cid}&amp;lid={$lid}\">" . _MD_WFDOWNLOADS_NOUSERREVIEWS;
264
}
265
$xoopsTpl->assign('lang_user_reviews', $GLOBALS['xoopsConfig']['sitename'] . ' ' . _MD_WFDOWNLOADS_USERREVIEWSTITLE);
266
$xoopsTpl->assign('lang_UserReviews', sprintf($user_reviews, $downloadObj->getVar('title')));
267
$xoopsTpl->assign('review_amount', $reviewCount);
268
269
// User mirrors
270
$downloadInfo['add_mirror'] = $add_mirror;
271
$criteria                   = new CriteriaCompo(new Criteria('lid', $lid));
272
$criteria->add(new Criteria('submit', 1));
273
$mirrorCount = $helper->getHandler('Mirror')->getCount($criteria);
274
if ($mirrorCount > 0) {
275
    $user_mirrors = "op=list&amp;cid={$cid}&amp;lid={$lid}\">" . _MD_WFDOWNLOADS_USERMIRRORS;
276
} else {
277
    $user_mirrors = "cid={$cid}&amp;lid={$lid}\">" . _MD_WFDOWNLOADS_NOUSERMIRRORS;
278
}
279
$xoopsTpl->assign('lang_user_mirrors', $GLOBALS['xoopsConfig']['sitename'] . ' ' . _MD_WFDOWNLOADS_USERMIRRORSTITLE);
280
$xoopsTpl->assign('lang_UserMirrors', sprintf($user_mirrors, $downloadObj->getVar('title')));
281
$xoopsTpl->assign('mirror_amount', $mirrorCount);
282
283
$xoopsTpl->assign('use_mirrors', $helper->getConfig('enable_mirrors'));
284
$xoopsTpl->assign('use_ratings', $helper->getConfig('enable_ratings'));
285
$xoopsTpl->assign('use_reviews', $helper->getConfig('enable_reviews'));
286
$xoopsTpl->assign('use_brokenreports', $helper->getConfig('enable_brokenreports'));
287
$xoopsTpl->assign('use_rss', $helper->getConfig('enablerss'));
288
289
// Copyright
290
if (1 === $helper->getConfig('copyright')) {
291
    $xoopsTpl->assign('lang_copyright', $downloadObj->getVar('title') . ' &copy; ' . _MD_WFDOWNLOADS_COPYRIGHT . ' ' . formatTimestamp(time(), 'Y'));
292
}
293
$xoopsTpl->assign('down', $downloadInfo); // this definition is not removed for backward compatibility issues
294
$xoopsTpl->assign('download', $downloadInfo);
295
296
require_once XOOPS_ROOT_PATH . '/include/comment_view.php';
297
298
$xoopsTpl->assign('com_rule', $helper->getConfig('com_rule'));
299
$xoopsTpl->assign('module_home', Utility::moduleHome(true));
300
require_once __DIR__ . '/footer.php';
301
302
?>
303
<script type="text/javascript">
304
305
    $('.magnific_zoom').magnificPopup({
306
        type: 'image',
307
        image: {
308
            cursor: 'mfp-zoom-out-cur',
309
            titleSrc: "title",
310
            verticalFit: true,
311
            tError: 'The image could not be loaded.' // Error message
312
        },
313
        gallery: {
314
            enabled: true
315
        },
316
        iframe: {
317
            patterns: {
318
                youtube: {
319
                    index: 'youtube.com/',
320
                    id: 'v=',
321
                    src: '//www.youtube.com/embed/%id%?autoplay=1'
322
                }, vimeo: {
323
                    index: 'vimeo.com/',
324
                    id: '/',
325
                    src: '//player.vimeo.com/video/%id%?autoplay=1'
326
                }, gmaps: {
327
                    index: '//maps.google.',
328
                    src: '%id%&output=embed'
329
                }
330
            }
331
        },
332
        preloader: true,
333
        showCloseBtn: true,
334
        closeBtnInside: false,
335
        closeOnContentClick: true,
336
        closeOnBgClick: true,
337
        enableEscapeKey: true,
338
        modal: false,
339
        alignTop: false,
340
        mainClass: 'mfp-img-mobile mfp-fade',
341
        zoom: {
342
            enabled: true,
343
            duration: 300,
344
            easing: 'ease-in-out'
345
        },
346
        removalDelay: 200
347
    });
348
</script>
349