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 | /** @var \XoopsModules\Smallworld\Helper $helper */ |
||
31 | require_once $helper->path('include/functions.php'); |
||
32 | $GLOBALS['xoopsLogger']->activated = false; |
||
33 | |||
34 | $friend = Request::getInt('friend', 0, 'POST'); |
||
35 | $check = new Smallworld\User(); |
||
36 | //$friendProfile = $check->checkIfProfile($friend); |
||
37 | /** @var \XoopsModules\Smallworld\SwUserHandler $swUserHandler */ |
||
38 | $swUserHandler = $helper->getHandler('SwUser'); |
||
39 | $friendProfile = $swUserHandler->checkIfProfile($friend); |
||
40 | |||
41 | if (Constants::PROFILE_HAS_BOTH > $friendProfile) { |
||
42 | $helper->redirect('index.php', 3, _SMALLWORLD_NOUSER_ERROR); |
||
43 | } |
||
44 | |||
45 | $swDB = new Smallworld\SwDatabase; |
||
46 | $mail = new Smallworld\Mail(); |
||
47 | $stat = Request::getInt('stat', 0, 'POST'); |
||
48 | $invitation = Request::getInt('invitation', 0, 'POST'); |
||
49 | $myUid = Request::getInt('myUid', 0, 'POST'); |
||
50 | $friendName = $swUserHandler->getName($friend); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
51 | $yourName = $swUserHandler->getName($myUid); |
||
0 ignored issues
–
show
![]() |
|||
52 | $USC = json_decode($swDB->getSettings($friend), true); |
||
53 | |||
54 | switch ($invitation) { |
||
55 | case 1: |
||
56 | $friendshipExists = $check->friendcheck($myUid, $friend); |
||
57 | if (0 == $friendshipExists[0]) { |
||
58 | $resultMsg = _SMALLWORLD_JSON_ADDFRIEND . $friendName . _SMALLWORLD_JSON_REQUEST_PENDING; |
||
59 | View Code Duplication | if (0 != $helper->getConfig('smallworldusemailnotis')) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
60 | if (1 == $USC['notify']) { |
||
61 | $mail->sendMails($friend, $friend, 'friendshipfollow', $link = null, []); |
||
62 | } |
||
63 | } |
||
64 | $swDB->toogleFriendInvite($friendshipExists, $friend, $myUid); |
||
0 ignored issues
–
show
$friendshipExists is of type array<integer,string|int...{"0":"string|integer"}> , but the function expects a integer .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
65 | echo json_encode(['error' => 'no', 'msg' => $resultMsg, 'msgChange' => _SMALLWORLD_JSON_CANCELFR_TEXT]); |
||
66 | } |
||
67 | |||
68 | if ($friendshipExists[0] > 0 and $friendshipExists[0] < 2) { |
||
69 | $resultMsg = _SMALLWORLD_JSON_CANCEL_ADDFRIEND . $friendName; |
||
70 | $swDB->toogleFriendInvite($friendshipExists, $friend, $myUid); |
||
0 ignored issues
–
show
$friendshipExists is of type array<integer,string|int...{"0":"string|integer"}> , but the function expects a integer .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
71 | echo json_encode(['error' => 'no', 'msg' => $resultMsg, 'msgChange' => _SMALLWORLD_JSON_ADDFR_TEXT]); |
||
72 | } |
||
73 | if (Constants::PROFILE_HAS_BOTH == $friendshipExists[0]) { |
||
74 | $resultMsg = _SMALLWORLD_JSON_DELETE_FRIEND_START . $friendName . _SMALLWORLD_JSON_DELETE_FRIEND_END; |
||
75 | $swDB->toogleFriendInvite($friendshipExists, $friend, $myUid); |
||
0 ignored issues
–
show
$friendshipExists is of type array<integer,string|int...{"0":"string|integer"}> , but the function expects a integer .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
76 | echo json_encode(['error' => 'no', 'msg' => $resultMsg, 'msgChange' => _SMALLWORLD_JSON_ADDFR_TEXT]); |
||
77 | } |
||
78 | break; |
||
79 | case 2: |
||
80 | // Used for followers |
||
81 | $following = $check->following_or($myUid, $friend); |
||
82 | |||
83 | View Code Duplication | if (0 == $following[0]) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
84 | $resultMsgFollow = _SMALLWORLD_JSON_FOLLOWINGFRIEND . $friendName . _SMALLWORLD_JSON_FOLLOWINGFRIEND_DESC; |
||
85 | $swDB->toogleFollow($following[0], $myUid, $friend); |
||
86 | echo json_encode(['error' => 'no', 'msg' => $resultMsgFollow, 'msgChange' => _SMALLWORLD_JSON_FLNO_TEXT]); |
||
87 | } |
||
88 | View Code Duplication | if (0 < $following[0]) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
89 | $resultMsgFollow = _SMALLWORLD_JSON_UNFOLLOWINGFRIEND . $friendName . _SMALLWORLD_JSON_UNFOLLOWINGFRIEND_DESC; |
||
90 | $swDB->toogleFollow($following[0], $myUid, $friend); |
||
91 | echo json_encode(['error' => 'no', 'msg' => $resultMsgFollow, 'msgChange' => _SMALLWORLD_JSON_FLYES_TEXT]); |
||
92 | } |
||
93 | break; |
||
94 | case 3: |
||
95 | // Used for accept/deny friendship requests |
||
96 | View Code Duplication | if ($stat > 0) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
97 | // Friendship is accepted (update status in mysql) |
||
98 | $swDB->setFriendshitStat(1, $myUid, $friend); |
||
0 ignored issues
–
show
The method
setFriendshitStat() does not exist on XoopsModules\Smallworld\SwDatabase . Did you maybe mean setFriendshipStat() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise. ![]() |
|||
99 | $acceptMsg = _SMALLWORLD_JSON_DELETE_FRIEND_START . $friendName . _SMALLWORLD_JSON_DELETE_FRIEND_END; |
||
100 | echo json_encode(['error' => 'no', 'msg' => $acceptMsg, 'msgChange' => _SMALLWORLD_JSON_REMOVEFR_TEXT]); |
||
101 | } |
||
102 | View Code Duplication | if ($stat < 0) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
103 | // friendship is denied (delete from mysql) |
||
104 | $swDB->setFriendshitStat(-1, $myUid, $friend); |
||
0 ignored issues
–
show
The method
setFriendshitStat() does not exist on XoopsModules\Smallworld\SwDatabase . Did you maybe mean setFriendshipStat() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise. ![]() |
|||
105 | $acceptMsg = _SMALLWORLD_JSON_ADDFRIEND . $friendName . _SMALLWORLD_JSON_REQUEST_PENDING; |
||
106 | echo json_encode(['error' => 'no', 'msg' => $acceptMsg, 'msgChange' => _SMALLWORLD_JSON_ADDFR_TEXT]); |
||
107 | } |
||
108 | break; |
||
109 | } |
||
110 |