This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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 | * @package \XoopsModules\Smallworld |
||
16 | * @license GNU GPL (https://www.gnu.org/licenses/gpl-2.0.html/) |
||
17 | * @copyright The XOOPS Project (https://xoops.org) |
||
18 | * @copyright 2011 Culex |
||
19 | * @author Michael Albertsen (http://culex.dk) <[email protected]> |
||
20 | * @link https://github.com/XoopsModules25x/smallworld |
||
21 | * @since 1.0 |
||
22 | */ |
||
23 | |||
24 | use Xmf\Request; |
||
25 | use XoopsModules\Smallworld; |
||
26 | use XoopsModules\Smallworld\Constants; |
||
27 | |||
28 | require_once __DIR__ . '/header.php'; |
||
29 | |||
30 | require_once XOOPS_ROOT_PATH . '/class/template.php'; |
||
31 | |||
32 | /** @var \XoopsModules\Smallworld\Helper $helper */ |
||
33 | require_once $helper->path('include/functions.php'); |
||
34 | require_once $helper->path('include/arrays.php'); |
||
35 | |||
36 | $set = smallworld_checkPrivateOrPublic(); |
||
37 | $pub = smallworld_checkUserPubPostPerm(); |
||
38 | $hm = smallworld_GetModuleOption('msgtoshow'); |
||
39 | |||
40 | $last = $GLOBALS['xoopsDB']->escape($_POST['last']); |
||
41 | $page = $GLOBALS['xoopsDB']->escape($_POST['page']); |
||
42 | |||
43 | $GLOBALS['xoopsLogger']->activated = false; |
||
44 | /* error_reporting(E_ALL); */ |
||
45 | |||
46 | //$GLOBALS['xoopsTpl'] = new \XoopsTpl(); |
||
47 | //$check = new Smallworld\User(); |
||
48 | $id = Constants::DEFAULT_UID; |
||
49 | $username = ''; |
||
50 | $profile = Constants::PROFILE_NONE; |
||
51 | $isAdmin = $helper->isUserAdmin(); |
||
52 | $tplAdmin= $isAdmin ? 'YES' : 'NO'; |
||
53 | |||
54 | /**@var \XoopsModules\Smallworld\SwUserHandler $swUserHandler */ |
||
55 | $swUserHandler = $helper->getHandler('SwUser'); |
||
56 | |||
57 | if ($GLOBALS['xoopsUser'] && ($GLOBALS['xoopsUser'] instanceof \XoopsUser)) { |
||
0 ignored issues
–
show
|
|||
58 | $id = $GLOBALS['xoopsUser']->uid(); |
||
59 | $username = $GLOBALS['xoopsUser']->uname(); |
||
60 | //$profile = $check->checkIfProfile($id); |
||
61 | $profile = $swUserHandler->checkIfProfile($id); |
||
62 | if ($isAdmin) { |
||
63 | $pub = $swUserHandler->allUsers(); |
||
64 | /* |
||
65 | $check = new Smallworld\User(); |
||
66 | $pub = $check->allUsers(); |
||
67 | */ |
||
68 | } |
||
69 | } |
||
70 | |||
71 | $userid = Request::getInt('userid', $id, 'POST'); |
||
72 | if (Constants::DEFAULT_UID < $userid && $userid !== $id) { |
||
73 | $xUser = new \XoopsUser($userid); |
||
74 | if ($xUser && ($xUser 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 dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() |
|||
75 | $id = $userid; |
||
76 | $username = $xUser->uname(); |
||
77 | //$profile = $check->checkIfProfile($id); |
||
78 | $profile = $swUserHandler->checkIfProfile($id); |
||
79 | } |
||
80 | } |
||
81 | |||
82 | if (Constants::DEFAULT_UID >= $id || ('publicindex' === $page) && (Constants::HAS_ACCESS == $set['access'])) { |
||
83 | $wall = new Smallworld\PublicWallUpdates(); |
||
84 | } else { |
||
85 | $wall = new Smallworld\WallUpdates(); |
||
86 | } |
||
87 | |||
88 | if (Constants::DEFAULT_UID >= $id && Constants::HAS_ACCESS == $set['access']) { |
||
89 | $followers = $pub; |
||
90 | } elseif ($id > 0 && Constants::HAS_ACCESS == $set['access'] && 'publicindex' === $page) { |
||
91 | //$pub = $check->allUsers(); |
||
92 | $followers = $pub; |
||
93 | } else { |
||
94 | $followers = smallworld_array_flatten($wall->getFollowers($id), 0); |
||
0 ignored issues
–
show
The method
getFollowers does only exist in XoopsModules\Smallworld\WallUpdates , but not in XoopsModules\Smallworld\PublicWallUpdates .
It seems like the method you are trying to call exists only in some of the possible types. Let’s take a look at an example: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
![]() |
|||
95 | } |
||
96 | |||
97 | $last = Request::getString('last', 'a', 'POST'); |
||
98 | switch ($page) { |
||
99 | case ('index'): |
||
100 | $updatesArray = (Constants::DEFAULT_UID < $id) ? $wall->Updates($last, $id, $followers) : $wall->Updates($last, $followers); |
||
0 ignored issues
–
show
The call to
PublicWallUpdates::Updates() has too many arguments starting with $followers .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() It seems like
$followers can also be of type string ; however, XoopsModules\Smallworld\...cWallUpdates::Updates() does only seem to accept array , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() |
|||
101 | break; |
||
102 | case ('profile'): |
||
103 | $updatesArray = (Constants::DEFAULT_UID < $id) ? $wall->Updates($last, $userid, $userid) : $wall->Updates($last, $userid); |
||
0 ignored issues
–
show
The call to
PublicWallUpdates::Updates() has too many arguments starting with $userid .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
104 | break; |
||
105 | case ('publicindex'): |
||
106 | $updatesArray = $wall->Updates($last, $followers); |
||
0 ignored issues
–
show
It seems like
$followers can also be of type string ; however, XoopsModules\Smallworld\...cWallUpdates::Updates() does only seem to accept array , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() |
|||
107 | break; |
||
108 | } |
||
109 | |||
110 | $wall->parsePubArray($updatesArray, $id); |
||
111 | |||
112 | $GLOBALS['xoopsTpl']->assign([ |
||
113 | 'sCountResp' => count($updatesArray), |
||
114 | 'msgtoshow' => $hm, |
||
115 | 'myusername' => $username, |
||
116 | 'pagename' => $page, |
||
117 | 'isadminuser' => $tplAdmin |
||
118 | ]); |
||
119 | |||
120 | $tplFileName = (Constants::DEFAULT_UID < $id) ? $helper->path('templates/getmore.tpl') : $helper->path('templates/getmorepublic.tpl'); |
||
121 | $GLOBALS['xoopsTpl']->display($tplFileName); |
||
122 | |||
123 |
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 thecomposer.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
orrequire-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 you have not tested against this specific condition, such errors might go unnoticed.