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 | * Kernel - a registry |
||
4 | * |
||
5 | * @package Intraface |
||
6 | * @author Sune Jensen <[email protected]> |
||
7 | * @author Lars Olesen <[email protected]> |
||
8 | * @since 0.1.0 |
||
9 | * @version @package-version@ |
||
10 | */ |
||
11 | class Intraface_Kernel implements Intraface_Identity |
||
12 | { |
||
13 | private $db; |
||
14 | public $intranet; |
||
15 | public $user; |
||
16 | private $_session; |
||
17 | public $session_id; |
||
18 | /* |
||
0 ignored issues
–
show
|
|||
19 | public $modules = array(); |
||
20 | public $shared; |
||
21 | private $primary_module_name; |
||
22 | */ |
||
23 | public $translation; |
||
24 | private $observers = array(); |
||
0 ignored issues
–
show
|
|||
25 | private $modulehandler; |
||
26 | public $setting; |
||
27 | |||
28 | /** |
||
29 | * Constructor |
||
30 | * |
||
31 | * @param string $session Session string |
||
32 | * |
||
33 | * @return void |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Adding a
@return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.
Adding a Please refer to the PHP core documentation on constructors. ![]() |
|||
34 | */ |
||
35 | 30 | function __construct($session = null) |
|
36 | { |
||
37 | 30 | if ($session == null) { |
|
0 ignored issues
–
show
|
|||
38 | 30 | $this->_session = md5(uniqid(rand(), true)); |
|
39 | 30 | } else { |
|
40 | $this->_session = $session; |
||
41 | } |
||
42 | 30 | $this->db = MDB2:: singleton(DB_DSN); |
|
43 | 30 | if (PEAR::isError($this->db)) { |
|
44 | throw new Exception($this->db->getMessage() . $this->db->getUserInfo()); |
||
45 | } |
||
46 | 30 | } |
|
47 | |||
48 | /** |
||
49 | * returns an unique user id for this login |
||
50 | * |
||
51 | * @todo: session_id is not the correct name, as this is not always session id. |
||
52 | */ |
||
53 | 3 | function getSessionId() |
|
54 | { |
||
55 | 3 | return $this->_session; |
|
56 | } |
||
57 | |||
58 | 89 | function getModuleHandler() |
|
59 | { |
||
60 | 89 | if (!empty($this->modulehandler)) { |
|
61 | 63 | return $this->modulehandler; |
|
62 | } |
||
63 | 89 | return ($this->modulehandler = new Intraface_ModuleHandler($this->intranet, $this->user)); |
|
0 ignored issues
–
show
$this->intranet is of type object<Intraface_Intrane...ect<FakeDebtorIntranet> , but the function expects a string .
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);
![]() $this->user is of type object<Intraface_User>|o...|object<FakeDebtorUser> , but the function expects a string .
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);
![]() |
|||
64 | } |
||
65 | |||
66 | /** |
||
67 | * Sets primary module for a page |
||
68 | * |
||
69 | * @param string $module_name Name on module |
||
70 | * |
||
71 | * @return Module object |
||
72 | */ |
||
73 | 27 | function module($module_name) |
|
74 | { |
||
75 | 27 | return $this->getModuleHandler()->setPrimaryModule($module_name); |
|
76 | } |
||
77 | |||
78 | /** |
||
79 | * Returns the primary module |
||
80 | * |
||
81 | * Used for instance in Page to give the correct submenu. |
||
82 | * |
||
83 | * @return module object or false |
||
84 | */ |
||
85 | 1 | function getPrimaryModule() |
|
86 | { |
||
87 | 1 | return $this->getModuleHandler()->getPrimaryModule(); |
|
88 | } |
||
89 | |||
90 | /** |
||
91 | * Gets a module |
||
92 | * |
||
93 | * @param string $name of the module |
||
94 | * |
||
95 | * @return module object or false |
||
96 | */ |
||
97 | 1 | function getModule($name) |
|
98 | { |
||
99 | 1 | return $this->getModuleHandler()->getModule($name); |
|
100 | } |
||
101 | |||
102 | /** |
||
103 | * Gets a list of modules - is used on frontpage and under rights |
||
104 | * |
||
105 | * @param string $order_by which index |
||
106 | * |
||
107 | * @return array with modules |
||
108 | */ |
||
109 | 1 | function getModules($order_by = 'frontpage_index') |
|
110 | { |
||
111 | 1 | return $this->getModuleHandler()->getModules($this->db, $order_by); |
|
112 | } |
||
113 | |||
114 | /** |
||
115 | * Use another module besides the primary |
||
116 | * |
||
117 | * @param string $module_name Navn p� det modullet der skal loades |
||
118 | * @param boolean $ignore_user_access Ved true, tjekker den ikke om brugeren har adgang, men kun om intranettet har. Benyttes bla. til n�r der skal tr�kkes vare fra lageret fra gennem faktura. |
||
119 | * |
||
120 | * @return object or false Hvis man har adgang returnere den et object, ellers returnere den 0; |
||
121 | */ |
||
122 | 63 | function useModule($module_name, $ignore_user_access = false) |
|
0 ignored issues
–
show
|
|||
123 | { |
||
124 | 63 | return $this->getModuleHandler()->useModule($module_name, $ignore_user_access = false); |
|
125 | } |
||
126 | |||
127 | /** |
||
128 | * Public: Giv adgang til et shared |
||
129 | * |
||
130 | * @param string $shared_name Navn p� det shared der skal loades |
||
131 | * |
||
132 | * @return object or 0 Hvis man har adgang returnere den et object, ellers returnere den 0; |
||
133 | */ |
||
134 | 20 | function useShared($shared_name) |
|
135 | { |
||
136 | 20 | return $this->getModuleHandler()->useShared($shared_name); |
|
137 | } |
||
138 | |||
139 | /** |
||
140 | * Returns translation object and sets page_id |
||
141 | * Could be moved when there is no more calls to the method. |
||
142 | * |
||
143 | * @param string $page_id Which specific translation object is needed |
||
144 | * |
||
145 | * @return Translation object |
||
146 | */ |
||
147 | function getTranslation($page_id = 'common') |
||
148 | { |
||
149 | if (is_object($this->translation)) { |
||
150 | if (!empty($page_id)) { |
||
151 | $this->translation->setPageID($page_id); |
||
152 | } |
||
153 | return $this->translation; |
||
154 | } |
||
155 | |||
156 | if (isset($this->translation)) { |
||
157 | $this->translation->setPageID($page_id); |
||
158 | } |
||
159 | |||
160 | return $this->translation; |
||
161 | } |
||
162 | |||
163 | /** |
||
164 | * Function to make a random key - e.g. for passwords |
||
165 | * This functions don't return any characters whick can be mistaken. |
||
166 | * Won't return 0 (zero) or o (as in Ole) or 1 (one) or l (lars), because they can be mistaken on print. |
||
167 | * |
||
168 | * @param $count (integer) how many characters to return? |
||
169 | * |
||
170 | * @return random key (string) only letters |
||
171 | */ |
||
172 | 1 | function randomKey($length = 1) |
|
173 | { |
||
174 | 1 | $random = new Ilib_RandomKeyGenerator(); |
|
175 | 1 | return $random->generate($length); |
|
176 | } |
||
177 | |||
178 | function getIntranet() |
||
179 | { |
||
180 | return $this->intranet; |
||
181 | } |
||
182 | |||
183 | function getSetting() |
||
184 | { |
||
185 | // Very important to store setting, as getSetting is called many times in some scripts |
||
186 | if (empty($this->setting)) { |
||
187 | if (is_object($this->user)) { |
||
188 | $user_id = $this->user->getId(); |
||
189 | } else { |
||
190 | $user_id = 0; |
||
191 | } |
||
192 | $this->setting = new Intraface_Setting($this->intranet->getId(), $user_id); |
||
0 ignored issues
–
show
The method
getId does only exist in FakeDebtorIntranet and Intraface_Intranet , but not in FakeKernelIntranet and F...nelIntranetWithNoAccess .
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
![]() |
|||
193 | } |
||
194 | |||
195 | return $this->setting; |
||
196 | } |
||
197 | |||
198 | function getId() |
||
199 | { |
||
200 | return $this->user->getId(); |
||
0 ignored issues
–
show
The method
getId does only exist in Intraface_User , but not in FakeDebtorUser and FakeK...nelIntranetWithNoAccess .
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
![]() |
|||
201 | } |
||
202 | |||
203 | function getActiveIntranetId() |
||
204 | { |
||
205 | return $this->user->getActiveIntranetId(); |
||
0 ignored issues
–
show
The method
getActiveIntranetId does only exist in Intraface_User , but not in FakeDebtorUser and FakeK...nelIntranetWithNoAccess .
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
![]() |
|||
206 | } |
||
207 | } |
||
208 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.