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 | /** |
||
4 | * The admin controller |
||
5 | * |
||
6 | * @license http://opensource.org/licenses/MIT The MIT License (MIT) |
||
7 | * @author Omar El Gabry <[email protected]> |
||
8 | * |
||
9 | */ |
||
10 | |||
11 | class AdminController extends Controller { |
||
0 ignored issues
–
show
|
|||
12 | |||
13 | /** |
||
14 | * A method that will be triggered before calling action method. |
||
15 | * Any changes here will reflect then on Controller::triggerComponents() method |
||
16 | * |
||
17 | */ |
||
18 | public function beforeAction(){ |
||
19 | |||
20 | parent::beforeAction(); |
||
21 | |||
22 | $action = $this->request->param('action'); |
||
23 | $actions = ['getUsers', 'updateUserInfo', 'deleteUser']; |
||
24 | |||
25 | // define the action methods that needs to be triggered only through POST & Ajax request. |
||
26 | $this->Security->requireAjax($actions); |
||
0 ignored issues
–
show
The property
Security does not exist on object<AdminController> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
27 | $this->Security->requirePost($actions); |
||
0 ignored issues
–
show
The property
Security does not exist on object<AdminController> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
28 | |||
29 | // You need to explicitly define the form fields that you expect to be returned in POST request, |
||
30 | // if form field wasn't defined, this will detected as form tampering attempt. |
||
31 | switch($action){ |
||
32 | case "getUsers": |
||
33 | $this->Security->config("form", [ 'fields' => ['name', 'email', 'role', 'page']]); |
||
0 ignored issues
–
show
The property
Security does not exist on object<AdminController> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
34 | break; |
||
35 | case "updateUserInfo": |
||
36 | $this->Security->config("form", [ 'fields' => ['user_id', 'name', 'password', 'role']]); |
||
0 ignored issues
–
show
The property
Security does not exist on object<AdminController> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
37 | break; |
||
38 | case "deleteUser": |
||
39 | $this->Security->config("form", [ 'fields' => ['user_id']]); |
||
0 ignored issues
–
show
The property
Security does not exist on object<AdminController> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
40 | break; |
||
41 | case "updateBackup": |
||
42 | case "restoreBackup": |
||
43 | $this->Security->config("validateCsrfToken", true); |
||
0 ignored issues
–
show
The property
Security does not exist on object<AdminController> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
44 | break; |
||
45 | } |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * show all users |
||
50 | * |
||
51 | */ |
||
52 | public function users(){ |
||
53 | |||
54 | Config::setJsConfig('curPage', "users"); |
||
55 | $this->view->renderWithLayouts(Config::get('VIEWS_PATH') . "layout/default/", Config::get('ADMIN_VIEWS_PATH') . 'users/index.php'); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * get users by name, email & role |
||
60 | * |
||
61 | */ |
||
62 | public function getUsers(){ |
||
63 | |||
64 | $name = $this->request->data("name"); |
||
65 | $email = $this->request->data("email"); |
||
66 | $role = $this->request->data("role"); |
||
67 | $pageNum = $this->request->data("page"); |
||
68 | |||
69 | $usersData = $this->admin->getUsers($name, $email, $role, $pageNum); |
||
0 ignored issues
–
show
The property
admin does not exist on object<AdminController> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
70 | |||
71 | if(!$usersData){ |
||
72 | $this->view->renderErrors($this->admin->errors()); |
||
0 ignored issues
–
show
The property
admin does not exist on object<AdminController> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
73 | } else{ |
||
74 | |||
75 | $usersHTML = $this->view->render(Config::get('ADMIN_VIEWS_PATH') . 'users/users.php', array("users" => $usersData["users"])); |
||
76 | $paginationHTML = $this->view->render(Config::get('VIEWS_PATH') . 'pagination/default.php', array("pagination" => $usersData["pagination"])); |
||
77 | $this->view->renderJson(array("data" => ["users" => $usersHTML, "pagination" => $paginationHTML])); |
||
78 | } |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * view a user |
||
83 | * |
||
84 | * @param integer|string $userId |
||
85 | */ |
||
86 | public function viewUser($userId = 0){ |
||
87 | |||
88 | $userId = Encryption::decryptId($userId); |
||
89 | |||
90 | if(!$this->user->exists($userId)){ |
||
0 ignored issues
–
show
The property
user does not exist on object<AdminController> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
91 | return $this->error(404); |
||
92 | } |
||
93 | |||
94 | Config::setJsConfig('curPage', "users"); |
||
95 | Config::setJsConfig('userId', Encryption::encryptId($userId)); |
||
96 | |||
97 | $this->view->renderWithLayouts(Config::get('VIEWS_PATH') . "layout/default/", Config::get('ADMIN_VIEWS_PATH') . 'users/viewUser.php', array("userId" => $userId)); |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * update user profile info(name, password, role) |
||
102 | * |
||
103 | */ |
||
104 | public function updateUserInfo(){ |
||
105 | |||
106 | $userId = Encryption::decryptId($this->request->data("user_id")); |
||
107 | $name = $this->request->data("name"); |
||
108 | $password = $this->request->data("password"); |
||
109 | $role = $this->request->data("role"); |
||
110 | |||
111 | if(!$this->user->exists($userId)){ |
||
0 ignored issues
–
show
The property
user does not exist on object<AdminController> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
112 | return $this->error(404); |
||
113 | } |
||
114 | |||
115 | $result = $this->admin->updateUserInfo($userId, Session::getUserId(), $name, $password, $role); |
||
0 ignored issues
–
show
The property
admin does not exist on object<AdminController> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
116 | |||
117 | if(!$result){ |
||
118 | $this->view->renderErrors($this->admin->errors()); |
||
0 ignored issues
–
show
The property
admin does not exist on object<AdminController> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
119 | }else{ |
||
120 | $this->view->renderSuccess("Profile has been updated."); |
||
121 | } |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * delete a user |
||
126 | * |
||
127 | */ |
||
128 | View Code Duplication | public function deleteUser(){ |
|
0 ignored issues
–
show
This method seems to be duplicated in 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. ![]() |
|||
129 | |||
130 | $userId = Encryption::decryptIdWithDash($this->request->data("user_id")); |
||
131 | |||
132 | if(!$this->user->exists($userId)){ |
||
0 ignored issues
–
show
The property
user does not exist on object<AdminController> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
133 | return $this->error(404); |
||
134 | } |
||
135 | |||
136 | $this->admin->deleteUser(Session::getUserId(), $userId); |
||
0 ignored issues
–
show
The property
admin does not exist on object<AdminController> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
137 | $this->view->renderJson(array("success" => true)); |
||
138 | } |
||
139 | |||
140 | /** |
||
141 | * view backups if exist |
||
142 | * |
||
143 | */ |
||
144 | public function backups(){ |
||
145 | |||
146 | Config::setJsConfig('curPage', "backups"); |
||
147 | $this->view->renderWithLayouts(Config::get('VIEWS_PATH') . "layout/default/", Config::get('ADMIN_VIEWS_PATH') . 'backups.php'); |
||
148 | } |
||
149 | |||
150 | /** |
||
151 | * update backup |
||
152 | * |
||
153 | */ |
||
154 | public function updateBackup(){ |
||
155 | |||
156 | $this->admin->updateBackup(); |
||
0 ignored issues
–
show
The property
admin does not exist on object<AdminController> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
157 | |||
158 | Session::set('backup-success', "Backup has been updated"); |
||
159 | return $this->redirector->root("Admin/Backups"); |
||
160 | } |
||
161 | |||
162 | /** |
||
163 | * restore backup |
||
164 | * |
||
165 | */ |
||
166 | public function restoreBackup(){ |
||
167 | |||
168 | $result = $this->admin->restoreBackup(); |
||
0 ignored issues
–
show
The property
admin does not exist on object<AdminController> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
169 | |||
170 | if(!$result){ |
||
171 | Session::set('backup-errors', $this->admin->errors()); |
||
0 ignored issues
–
show
The property
admin does not exist on object<AdminController> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
172 | return $this->redirector->root("Admin/Backups"); |
||
173 | }else{ |
||
174 | Session::set('backup-success', "Backup has been restored successfully"); |
||
175 | return $this->redirector->root("Admin/Backups"); |
||
176 | } |
||
177 | } |
||
178 | |||
179 | /** |
||
180 | * Is user authorized for admin controller & requested action method? |
||
181 | * |
||
182 | * @return bool |
||
183 | */ |
||
184 | public function isAuthorized(){ |
||
185 | |||
186 | $role = Session::getUserRole(); |
||
187 | if(isset($role) && $role === "admin"){ |
||
188 | return true; |
||
189 | } |
||
190 | return false; |
||
191 | } |
||
192 | |||
193 | } |
||
194 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.