Issues (380)

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.

include/search.inc.php (1 issue)

1
<?php
2
/**
3
 * NewBB 5.0x,  the forum module for XOOPS project
4
 *
5
 * @copyright      XOOPS Project (https://xoops.org)
6
 * @license        GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
7
 * @author         Taiwen Jiang (phppp or D.J.) <[email protected]>, irmtfan <[email protected]>
8
 * @since          4.3
9
 * @package        module::newbb
10
 */
11
12
use XoopsModules\Newbb;
13
14
// completely rewrite by irmtfan - remove hardcode database access, solve order issues, add post_text & topic_id, add highlight and reduce queries
15
16
require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.ini.php');
17
18
/**
19
 * @param                $queryarray
20
 * @param                $andor
21
 * @param                $limit
22
 * @param                $offset
23
 * @param                $userid
24
 * @param int            $forums
25
 * @param int|string     $sortby
26
 * @param string         $searchin
27
 * @param \CriteriaCompo $criteriaExtra
28
 * @return array
29
 */
30
function newbb_search(
31
    $queryarray,
32
    $andor,
33
    $limit,
34
    $offset,
35
    $userid,
36
    $forums = 0,
37
    $sortby = 0,
38
    $searchin = 'both',
39
    \CriteriaCompo $criteriaExtra = null
40
) {
41
    global $myts, $xoopsDB;
42
    // irmtfan - in XOOPSCORE/search.php $GLOBALS['xoopsModuleConfig'] is not set
43
    if (!isset($GLOBALS['xoopsModuleConfig'])) {
44
        $GLOBALS['xoopsModuleConfig'] = newbbLoadConfig();
45
    }
46
    // irmtfan - in XOOPSCORE/search.php $xoopsModule is not set
47
    if (!is_object($GLOBALS['xoopsModule']) && is_object($GLOBALS['module'])
48
        && 'newbb' === $GLOBALS['module']->getVar('dirname')) {
49
        $GLOBALS['xoopsModule'] = $GLOBALS['module'];
50
    }
51
    /** @var Newbb\ForumHandler $forumHandler */
52
    $forumHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Forum');
53
    $validForums  = $forumHandler->getIdsByValues($forums); // can we use view permission? $forumHandler->getIdsByValues($forums, "view")
54
55
    $criteriaPost = new \CriteriaCompo();
56
    $criteriaPost->add(new \Criteria('p.approved', 1), 'AND'); // only active posts
57
58
    $forum_list = []; // get forum lists just for forum names
59
    if (count($validForums) > 0) {
60
        $criteriaPermissions = new \CriteriaCompo();
61
        $criteriaPermissions->add(new \Criteria('p.forum_id', '(' . implode(',', $validForums) . ')', 'IN'), 'AND');
62
        $forum_list = $forumHandler->getAll(new \Criteria('forum_id', '(' . implode(', ', $validForums) . ')', 'IN'), 'forum_name', false);
63
    }
64
65
    if (is_numeric($userid) && 0 !== $userid) {
66
        $criteriaUser = new \CriteriaCompo();
67
        $criteriaUser->add(new \Criteria('p.uid', $userid), 'OR');
68
    } elseif ($userid && is_array($userid)) {
69
        $userid       = array_map('\intval', $userid);
70
        $criteriaUser = new \CriteriaCompo();
71
        $criteriaUser->add(new \Criteria('p.uid', '(' . implode(',', $userid) . ')', 'IN'), 'OR');
72
    }
73
74
    $count = 0;
75
    if (is_array($queryarray)) {
76
        $count = count($queryarray);
77
    }
78
    $highlightKey = '';
79
    if ($count > 0) {
80
        $criteriaKeywords = new \CriteriaCompo();
81
        foreach ($queryarray as $queryTerm) {
82
            $termCriteria  = new \CriteriaCompo();
83
            $queryTermLike = '%' . $xoopsDB->escape($queryTerm) . '%';
84
            if ('title' === $searchin || 'both' === $searchin) {
85
                $termCriteria->add(new \Criteria('p.subject', $queryTermLike, 'LIKE'), 'OR');
86
            }
87
            if ('text' === $searchin || 'both' === $searchin) {
88
                $termCriteria->add(new \Criteria('t.post_text', $queryTermLike, 'LIKE'), 'OR');
89
            }
90
            $criteriaKeywords->add($termCriteria, $andor);
91
        }
92
        // add highlight keywords to post links
93
        $highlightKey = '&amp;keywords=' . implode(' ', $queryarray);
94
        $highlightKey = str_replace(' ', '+', $highlightKey);
95
    }
96
    $criteria = new \CriteriaCompo();
97
    $criteria->add($criteriaPost, 'AND');
98
    if (null !== $criteriaPermissions) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $criteriaPermissions does not seem to be defined for all execution paths leading up to this point.
Loading history...
99
        $criteria->add($criteriaPermissions, 'AND');
100
    }
101
    if (isset($criteriaUser)) {
102
        $criteria->add($criteriaUser, 'AND');
103
    }
104
    if (isset($criteriaKeywords)) {
105
        $criteria->add($criteriaKeywords, 'AND');
106
    }
107
    if (isset($criteriaExtra)) {
108
        $criteria->add($criteriaExtra, 'AND');
109
    }
110
    //$criteria->setLimit($limit); // no need for this
111
    //$criteria->setStart($offset); // no need for this
112
113
    if (empty($sortby)) {
114
        $sortby = 'p.post_time';
115
    }
116
    $criteria->setSort($sortby);
117
    $order = 'ASC';
118
    if ('p.post_time' === $sortby) {
119
        $order = 'DESC';
120
    }
121
    $criteria->setOrder($order);
122
123
    /** @var Newbb\PostHandler $postHandler */
124
    $postHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Post');
125
    $posts       = $postHandler->getPostsByLimit($criteria, $limit, $offset);
126
127
    $ret = [];
128
    $i   = 0;
129
    foreach (array_keys($posts) as $id) {
130
        /** @var Newbb\Post $post */
131
        $post                  = $posts[$id];
132
        $post_data             = $post->getPostBody();
133
        $ret[$i]['topic_id']   = $post->getVar('topic_id');
134
        $ret[$i]['link']       = XOOPS_URL . '/modules/newbb/viewtopic.php?post_id=' . $post->getVar('post_id') . $highlightKey; // add highlight key
135
        $ret[$i]['title']      = $post_data['subject'];
136
        $ret[$i]['time']       = $post_data['date'];
137
        $ret[$i]['forum_name'] = $myts->htmlSpecialChars($forum_list[$post->getVar('forum_id')]['forum_name']);
138
        $ret[$i]['forum_link'] = XOOPS_URL . '/modules/newbb/viewforum.php?forum=' . $post->getVar('forum_id');
139
        $ret[$i]['post_text']  = $post_data['text'];
140
        $ret[$i]['uid']        = $post->getVar('uid');
141
        $ret[$i]['poster']     = $post->getVar('uid') ? '<a href="' . XOOPS_URL . '/userinfo.php?uid=' . $ret[$i]['uid'] . '">' . $post_data['author'] . '</a>' : $post_data['author'];
142
        ++$i;
143
    }
144
145
    return $ret;
146
}
147