Issues (621)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  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.
  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.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
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 (8 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
 * SmallWorld
14
 *
15
 * @copyright    The XOOPS Project (https://xoops.org)
16
 * @copyright    2011 Culex
17
 * @license      GNU GPL (http://www.gnu.org/licenses/gpl-2.0.html/)
18
 * @package      SmallWorld
19
 * @since        1.0
20
 * @author       Michael Albertsen (http://culex.dk) <[email protected]>
21
 */
22
23
use XoopsModules\Smallworld;
24
25
require_once XOOPS_ROOT_PATH . '/modules/smallworld/include/functions.php';
26
27
/**
28
 * Global search
29
 *
30
 * @param array  $queryarray
31
 * @param string $andor
32
 * @param int    $limit
33
 * @param int    $offset
34
 * @param int    $userid
35
 * @param string $sortby
36
 * @return array
37
 */
38
function smallworld_search($queryarray, $andor, $limit, $offset, $userid, $sortby = 'created DESC')
39
{
40
    $moduleDirName = basename(dirname(__DIR__));
0 ignored issues
show
$moduleDirName is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
41
42
    if (file_exists(XOOPS_ROOT_PATH . '/modules/smallworld/language/' . $GLOBALS['xoopsConfig']['language'] . '/main.php')) {
43
        require_once XOOPS_ROOT_PATH . '/modules/smallworld/language/' . $GLOBALS['xoopsConfig']['language'] . '/main.php';
44
    } else {
45
        require_once XOOPS_ROOT_PATH . '/modules/smallworld/language/english/main.php';
46
    }
47
48
    $moduleHandler = xoops_getHandler('module');
49
    $module        = $moduleHandler->getByDirname('smallworld');
50
    $modid         = $module->getVar('mid');
0 ignored issues
show
$modid is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
51
    $searchparam   = '';
0 ignored issues
show
$searchparam is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
52
    $highlight     = false;
53
54
    $gpermHandler = xoops_getHandler('groupperm');
0 ignored issues
show
$gpermHandler is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
55
    if ($GLOBALS['xoopsUser'] && ($GLOBALS['xoopsUser'] instanceof \XoopsUser)) {
0 ignored issues
show
The class XoopsUser does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
56
        $groups    = $GLOBALS['xoopsUser']->getGroups();
0 ignored issues
show
$groups is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
57
        $id        = $GLOBALS['xoopsUser']->getVar('uid');
58
        $wall      = new Smallworld\WallUpdates();
59
        $followers = smallworld_array_flatten($wall->getFollowers($id), 0);
60
    } else {
61
        $id        = 0;
62
        $groups    = XOOPS_GROUP_ANONYMOUS;
0 ignored issues
show
$groups is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
63
        $followers = [];
64
    }
65
66
    //@todo figure out why this if statement is here both conditions yield the same result
67
    if ($id > 0 && '' != $id) {
68
        $sql = 'SELECT M.msg_id, M.uid_fk, M.message, M.created, M.priv, U.username FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_messages') . ' M, ' . $GLOBALS['xoopsDB']->prefix('smallworld_user') . ' U WHERE M.uid_fk=U.userid';
69
    } else {
70
        $sql = 'SELECT M.msg_id, M.uid_fk, M.message, M.created, M.priv, U.username FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_messages') . ' M, ' . $GLOBALS['xoopsDB']->prefix('smallworld_user') . ' U WHERE M.uid_fk=U.userid';
71
    }
72
73
    if (0 != (int)$userid) {
74
        $sql .= ' AND M.uid_fk = ' . $userid . ' ';
75
    }
76
    //@todo this needs to be refactored to address when $queryarray has more than 1 element
77
    if (is_array($queryarray) && $count = count($queryarray)) {
78
        $sql .= " AND (M.message LIKE '%$queryarray[0]%' OR M.message LIKE '%$queryarray[0]%' OR U.username LIKE '%$queryarray[0]%'";
79
        $sql .= ') ';
80
        // keywords highlighting
81
        if ($highlight) {
82
            $searchparam = '&keywords=' . urlencode(trim(implode(' ', $queryarray)));
0 ignored issues
show
$searchparam is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
83
        }
84
    }
85
    $sql    .= 'ORDER BY created DESC';
86
    $result = $GLOBALS['xoopsDB']->query($sql, $limit, $offset);
87
    $ret    = [];
88
    $i      = 0;
89
    while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) {
90
        if (in_array($myrow['uid_fk'], $followers) || $myrow['uid_fk'] == $id) {
91
            $ret[$i]['image'] = 'assets/images/smallworld_icn.png';
92
            $ret[$i]['link']  = 'permalink.php?ownerid=' . $myrow['uid_fk'] . '&updid=' . $myrow['msg_id'];
93
            if (preg_match('/UPLIMAGE/', $myrow['message'])) {
94
                // @todo - figure this out, doesn't look right - title value is overwrittern so 'message' never gets displayed
95
                $ownmsg           = str_replace('UPLIMAGE ', '', $myrow['message']);
96
                $ret[$i]['title'] = $ownmsg;
97
                $ret[$i]['title'] = Smallworld\Helper::getInstance()->getHandler('SwUser')->getName($myrow['uid_fk']) . ' -> ' . _SMALLWORLD_GALLERY;
98
                //$ret[$i]['title'] = smallworld_getName($myrow['uid_fk']) . ' -> ' . _SMALLWORLD_GALLERY;
99
                $ret[$i]['title'] = str_replace(['&lt;', '&gt;'], ['<', '>'], $ret[$i]['title']);
100
            } else {
101
                $ret[$i]['title'] = smallworld_shortenText($myrow['message'], 60);
102
            }
103
            $ret[$i]['time'] = $myrow['created'];
104
            $ret[$i]['uid']  = $myrow['uid_fk'];
105
        } else {
106
            --$i;
107
        }
108
        ++$i;
109
    }
110
111
    return $ret;
112
}
113