florinp /
phpbb-messenger
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 | namespace florinp\messenger\ucp; |
||
| 4 | |||
| 5 | class ucp_friends_module |
||
| 6 | { |
||
| 7 | |||
| 8 | public $u_action; |
||
| 9 | |||
| 10 | public function main($id, $mode) |
||
|
0 ignored issues
–
show
|
|||
| 11 | { |
||
| 12 | |||
| 13 | global $phpbb_container, $request, $user; |
||
|
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
Loading history...
|
|||
| 14 | |||
| 15 | $friends_controller = $phpbb_container->get('florinp.messenger.friends.controller'); |
||
| 16 | $friends_controller->set_page_url($this->u_action); |
||
| 17 | |||
| 18 | $this->tpl_name = 'friends'; |
||
|
0 ignored issues
–
show
The property
tpl_name does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
Loading history...
|
|||
| 19 | |||
| 20 | switch ($mode) |
||
| 21 | { |
||
| 22 | case 'friends': |
||
|
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. Loading history...
|
|||
| 23 | |||
| 24 | $action = $request->variable('action', ''); |
||
| 25 | switch ($action) |
||
| 26 | { |
||
| 27 | View Code Duplication | case 'add_friend': |
|
|
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. Loading history...
|
|||
| 28 | $user_id = $request->variable('user_id', 0); |
||
| 29 | if ($user_id > 0) |
||
| 30 | { |
||
| 31 | if (confirm_box(true)) |
||
| 32 | { |
||
| 33 | $user_id = $request->variable('user_id', 0); |
||
| 34 | $redirect_url = $request->variable('redirect_url', ''); |
||
| 35 | if ($friends_controller->send_request($user_id)) |
||
| 36 | { |
||
| 37 | redirect($redirect_url); |
||
| 38 | } |
||
| 39 | } else |
||
| 40 | { |
||
| 41 | $user_id = $request->variable('user_id', 0); |
||
| 42 | $redirect_url = $request->server('HTTP_REFERER'); |
||
| 43 | confirm_box(false, $user->lang('CONFIRM_ADD_FRIEND'), build_hidden_fields(array( |
||
| 44 | 'user_id' => $user_id, |
||
| 45 | 'redirect_url' => $redirect_url, |
||
| 46 | ))); |
||
| 47 | } |
||
| 48 | } |
||
| 49 | break; |
||
| 50 | View Code Duplication | case 'remove_friend': |
|
|
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. Loading history...
|
|||
| 51 | $user_id = $request->variable('user_id', 0); |
||
| 52 | if ($user_id > 0) |
||
| 53 | { |
||
| 54 | if (confirm_box(true)) |
||
| 55 | { |
||
| 56 | $user_id = $request->variable('user_id', 0); |
||
| 57 | $redirect_url = $request->variable('redirect_url', ''); |
||
| 58 | if ($friends_controller->remove_friend($user_id)) |
||
| 59 | { |
||
| 60 | redirect($redirect_url); |
||
| 61 | } |
||
| 62 | } else |
||
| 63 | { |
||
| 64 | $user_id = $request->variable('user_id', 0); |
||
| 65 | $redirect_url = $request->server('HTTP_REFERER'); |
||
| 66 | confirm_box(false, $user->lang('CONFIRM_REMOVE_FRIEND'), build_hidden_fields(array( |
||
| 67 | 'user_id' => $user_id, |
||
| 68 | 'redirect_url' => $redirect_url, |
||
| 69 | ))); |
||
| 70 | } |
||
| 71 | } |
||
| 72 | break; |
||
| 73 | default: |
||
| 74 | if ($request->is_set_post('action')) |
||
| 75 | { |
||
| 76 | $action = $request->variable('action', ''); |
||
| 77 | switch ($action) |
||
| 78 | { |
||
| 79 | case 'remove': |
||
| 80 | if (confirm_box(true)) |
||
| 81 | { |
||
| 82 | $user_id = $request->variable('user_id', array(0)); |
||
| 83 | $redirect_url = $request->variable('redirect_url', ''); |
||
| 84 | if ($friends_controller->remove_friend($user_id)) |
||
| 85 | { |
||
| 86 | redirect($redirect_url); |
||
| 87 | } |
||
| 88 | } else |
||
| 89 | { |
||
| 90 | $user_id = $request->variable('user_id', array(0)); |
||
| 91 | $redirect_url = $request->server('HTTP_REFERER'); |
||
| 92 | confirm_box(false, $user->lang('CONFIRM_REMOVE_FRIEND'), build_hidden_fields(array( |
||
| 93 | 'user_id' => $user_id, |
||
| 94 | 'redirect_url' => $redirect_url, |
||
| 95 | ))); |
||
| 96 | } |
||
| 97 | break; |
||
| 98 | } |
||
| 99 | } |
||
| 100 | $friends_controller->friends_list(); |
||
| 101 | $this->tpl_name = 'friends'; |
||
| 102 | break; |
||
| 103 | } |
||
| 104 | break; |
||
| 105 | |||
| 106 | case 'requests': |
||
|
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. Loading history...
|
|||
| 107 | |||
| 108 | if ($request->is_set_post('action')) |
||
| 109 | { |
||
| 110 | $action = $request->variable('action', ''); |
||
| 111 | |||
| 112 | switch ($action) |
||
| 113 | { |
||
| 114 | case 'delete': |
||
|
0 ignored issues
–
show
The case body in a switch statement must start on the line following the statement.
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement. switch ($expr) {
case "A":
doSomething(); //right
break;
case "B":
doSomethingElse(); //wrong
break;
} To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. Loading history...
|
|||
| 115 | |||
| 116 | if (confirm_box(true)) |
||
| 117 | { |
||
| 118 | $requests_id = $request->variable('requests_id', array(0)); |
||
| 119 | $friends_controller->delete_request($requests_id); |
||
| 120 | } else |
||
| 121 | { |
||
| 122 | $requests_id = $request->variable('requests_id', array(0)); |
||
| 123 | confirm_box(false, $user->lang('CONFIRM_REMOVE_REQUESTS'), build_hidden_fields(array( |
||
| 124 | 'requests_id' => $requests_id, |
||
| 125 | 'action' => $action, |
||
| 126 | 'mode' => $mode |
||
| 127 | ))); |
||
| 128 | } |
||
| 129 | |||
| 130 | break; |
||
| 131 | case 'approve': |
||
| 132 | $requests_id = $request->variable('requests_id', array(0)); |
||
| 133 | $friends_controller->approve_request($requests_id); |
||
| 134 | break; |
||
| 135 | } |
||
| 136 | } |
||
| 137 | |||
| 138 | $action = $request->variable('action', ''); |
||
| 139 | switch ($action) |
||
| 140 | { |
||
| 141 | case 'cancel_request': |
||
| 142 | if (confirm_box(true)) |
||
| 143 | { |
||
| 144 | $request_id = $request->variable('request_id', 0); |
||
| 145 | $redirect_url = $request->variable('redirect_url', ''); |
||
| 146 | if ($friends_controller->delete_request($request_id)) |
||
| 147 | { |
||
| 148 | redirect($redirect_url); |
||
| 149 | } |
||
| 150 | } else |
||
| 151 | { |
||
| 152 | $request_id = $request->variable('request_id', 0); |
||
| 153 | $redirect_url = $request->server('HTTP_REFERER'); |
||
| 154 | confirm_box(false, $user->lang('CONFIRM_REMOVE_REQUESTS'), build_hidden_fields(array( |
||
| 155 | 'request_id' => $request_id, |
||
| 156 | 'action' => $action, |
||
| 157 | 'mode' => $mode, |
||
| 158 | 'redirect_url' => $redirect_url, |
||
| 159 | ))); |
||
| 160 | } |
||
| 161 | break; |
||
| 162 | } |
||
| 163 | |||
| 164 | $friends_controller->requests(); |
||
| 165 | $this->tpl_name = 'ucp_friends_requests'; |
||
| 166 | break; |
||
| 167 | |||
| 168 | } |
||
| 169 | |||
| 170 | } |
||
| 171 | |||
| 172 | } |
||
| 173 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.