Passed
Push — 1.0.0-dev ( 93958a...e1c8ef )
by nguereza
02:26
created
core/classes/DBSessionHandler.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * check if the interface "SessionHandlerInterface" exists (normally in PHP 5.4 this already exists)
29 29
 	 */
30
-	if ( !interface_exists('SessionHandlerInterface')){
30
+	if (!interface_exists('SessionHandlerInterface')) {
31 31
 		show_error('"SessionHandlerInterface" interface does not exists or is disabled can not use it to handler database session.');
32 32
 	}
33 33
 
34
-	class DBSessionHandler extends BaseClass implements SessionHandlerInterface{
34
+	class DBSessionHandler extends BaseClass implements SessionHandlerInterface {
35 35
 		
36 36
 		/**
37 37
 		 * The encryption method to use to encrypt session data in database
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
          * Create new instance of Database session handler
80 80
          * @param object $modelInstance the model instance
81 81
          */
82
-		public function __construct(DBSessionHandlerModel $modelInstance = null){
82
+		public function __construct(DBSessionHandlerModel $modelInstance = null) {
83 83
 			parent::__construct();
84 84
 			
85 85
 	    	//Set Loader instance to use
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	       
88 88
 		    $this->OBJ = & get_instance();
89 89
 		    
90
-			if (is_object($modelInstance)){
90
+			if (is_object($modelInstance)) {
91 91
 				$this->setModelInstance($modelInstance);
92 92
 			}
93 93
 		}
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		 * Set the session secret used to encrypt the data in database 
97 97
 		 * @param string $secret the base64 string secret
98 98
 		 */
99
-		public function setSessionSecret($secret){
99
+		public function setSessionSecret($secret) {
100 100
 			$this->sessionSecret = $secret;
101 101
 			return $this;
102 102
 		}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		 * Return the session secret
106 106
 		 * @return string 
107 107
 		 */
108
-		public function getSessionSecret(){
108
+		public function getSessionSecret() {
109 109
 			return $this->sessionSecret;
110 110
 		}
111 111
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 		 * Set the initializer vector for openssl 
115 115
 		 * @param string $key the session secret used in base64 format
116 116
 		 */
117
-		public function setInitializerVector($key){
117
+		public function setInitializerVector($key) {
118 118
 			$ivLength = openssl_cipher_iv_length(self::DB_SESSION_HASH_METHOD);
119 119
 			$key = base64_decode($key);
120 120
 			$this->iv = substr(hash('sha256', $key), 0, $ivLength);
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 		 * Return the initializer vector
126 126
 		 * @return string 
127 127
 		 */
128
-		public function getInitializerVector(){
128
+		public function getInitializerVector() {
129 129
 			return $this->iv;
130 130
 		}
131 131
 
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
 		 * @param  string $sessionName the session name
136 136
 		 * @return boolean 
137 137
 		 */
138
-		public function open($savePath, $sessionName){
138
+		public function open($savePath, $sessionName) {
139 139
 			$this->logger->debug('Opening database session handler for [' . $sessionName . ']');
140 140
 			//try to check if session secret is set before
141 141
 			$secret = $this->getSessionSecret();
142
-			if (empty($secret)){
142
+			if (empty($secret)) {
143 143
 				$secret = get_config('session_secret', null);
144 144
 				$this->setSessionSecret($secret);
145 145
 			}
146 146
 			$this->logger->info('Session secret: ' . $secret);
147 147
 
148
-			if (! is_object($this->modelInstance)){
148
+			if (!is_object($this->modelInstance)) {
149 149
 				$this->setModelInstanceFromSessionConfig();
150 150
 			}
151 151
 			$this->setInitializerVector($secret);
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 			//set session tables columns
154 154
 			$this->sessionTableColumns = $this->modelInstance->getSessionTableColumns();
155 155
 
156
-			if (empty($this->sessionTableColumns)){
156
+			if (empty($this->sessionTableColumns)) {
157 157
 				show_error('The session handler is "database" but the table columns not set');
158 158
 			}
159 159
 			$this->logger->info('Database session, the model columns are listed below: ' . stringfy_vars($this->sessionTableColumns));
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		 * Close the session
170 170
 		 * @return boolean
171 171
 		 */
172
-		public function close(){
172
+		public function close() {
173 173
 			$this->logger->debug('Closing database session handler');
174 174
 			return true;
175 175
 		}
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 		 * @param  string $sid the session id to use
180 180
 		 * @return string      the session data in serialiaze format
181 181
 		 */
182
-		public function read($sid){
182
+		public function read($sid) {
183 183
 			$this->logger->debug('Reading database session data for SID: ' . $sid);
184 184
 			$instance = $this->getModelInstance();
185 185
 			$columns = $this->sessionTableColumns;
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
 			
189 189
 			$ip = get_ip();
190 190
 			$host = @gethostbyaddr($ip) or null;
191
-			$browser = $this->OBJ->browser->getPlatform().', '.$this->OBJ->browser->getBrowser().' '.$this->OBJ->browser->getVersion();
191
+			$browser = $this->OBJ->browser->getPlatform() . ', ' . $this->OBJ->browser->getBrowser() . ' ' . $this->OBJ->browser->getVersion();
192 192
 			
193 193
 			$data = $instance->get_by(array($columns['sid'] => $sid, $columns['shost'] => $host, $columns['sbrowser'] => $browser));
194
-			if ($data && isset($data->{$columns['sdata']})){
194
+			if ($data && isset($data->{$columns['sdata']})) {
195 195
 				//checking inactivity 
196 196
 				$timeInactivity = time() - get_config('session_inactivity_time', 100);
197
-				if ($data->{$columns['stime']} < $timeInactivity){
197
+				if ($data->{$columns['stime']} < $timeInactivity) {
198 198
 					$this->logger->info('Database session data for SID: ' . $sid . ' already expired, destroy it');
199 199
 					$this->destroy($sid);
200 200
 					return null;
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 		 * @param  mixed $data the session data to save in serialize format
212 212
 		 * @return boolean 
213 213
 		 */
214
-		public function write($sid, $data){
214
+		public function write($sid, $data) {
215 215
 			$this->logger->debug('Saving database session data for SID: ' . $sid . ', data: ' . stringfy_vars($data));
216 216
 			$instance = $this->getModelInstance();
217 217
 			$columns = $this->sessionTableColumns;
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 			$ip = get_ip();
223 223
 			$keyValue = $instance->getKeyValue();
224 224
 			$host = @gethostbyaddr($ip) or null;
225
-			$browser = $this->OBJ->browser->getPlatform().', '.$this->OBJ->browser->getBrowser().' '.$this->OBJ->browser->getVersion();
225
+			$browser = $this->OBJ->browser->getPlatform() . ', ' . $this->OBJ->browser->getBrowser() . ' ' . $this->OBJ->browser->getVersion();
226 226
 			$data = $this->encode($data);
227 227
 			$params = array(
228 228
 							$columns['sid'] => $sid,
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 						);
236 236
 			$this->logger->info('Database session data to save are listed below :' . stringfy_vars($params));
237 237
 			$exists = $instance->get($sid);
238
-			if ($exists){
238
+			if ($exists) {
239 239
 				$this->logger->info('Session data for SID: ' . $sid . ' already exists, just update it');
240 240
 				//update
241 241
 				unset($params[$columns['sid']]);
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 		 * @param  string $sid the session id value
252 252
 		 * @return boolean
253 253
 		 */
254
-		public function destroy($sid){
254
+		public function destroy($sid) {
255 255
 			$this->logger->debug('Destroy of session data for SID: ' . $sid);
256 256
 			$instance = $this->modelInstance;
257 257
 			$instance->delete($sid);
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 		 * @param  integer $maxLifetime the max lifetime
264 264
 		 * @return boolean
265 265
 		 */
266
-		public function gc($maxLifetime){
266
+		public function gc($maxLifetime) {
267 267
 			$instance = $this->modelInstance;
268 268
 			$time = time() - $maxLifetime;
269 269
 			$this->logger->debug('Garbage collector of expired session. maxLifetime [' . $maxLifetime . '] sec, expired time [' . $time . ']');
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
 		 * @param  mixed $data the session data to encode
277 277
 		 * @return mixed the encoded session data
278 278
 		 */
279
-		public function encode($data){
279
+		public function encode($data) {
280 280
 			$key = base64_decode($this->sessionSecret);
281
-			$dataEncrypted = openssl_encrypt($data , self::DB_SESSION_HASH_METHOD, $key, OPENSSL_RAW_DATA, $this->getInitializerVector());
281
+			$dataEncrypted = openssl_encrypt($data, self::DB_SESSION_HASH_METHOD, $key, OPENSSL_RAW_DATA, $this->getInitializerVector());
282 282
 			$output = base64_encode($dataEncrypted);
283 283
 			return $output;
284 284
 		}
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 		 * @param  mixed $data the data to decode
290 290
 		 * @return mixed       the decoded data
291 291
 		 */
292
-		public function decode($data){
292
+		public function decode($data) {
293 293
 			$key = base64_decode($this->sessionSecret);
294 294
 			$data = base64_decode($data);
295 295
 			$data = openssl_decrypt($data, self::DB_SESSION_HASH_METHOD, $key, OPENSSL_RAW_DATA, $this->getInitializerVector());
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
          * Return the loader instance
302 302
          * @return object Loader the loader instance
303 303
          */
304
-        public function getLoader(){
304
+        public function getLoader() {
305 305
             return $this->loader;
306 306
         }
307 307
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
          * set the loader instance for future use
310 310
          * @param object Loader $loader the loader object
311 311
          */
312
-         public function setLoader($loader){
312
+         public function setLoader($loader) {
313 313
             $this->loader = $loader;
314 314
             return $this;
315 315
         }
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
          * Return the model instance
319 319
          * @return object DBSessionHandlerModel the model instance
320 320
          */
321
-        public function getModelInstance(){
321
+        public function getModelInstance() {
322 322
             return $this->modelInstance;
323 323
         }
324 324
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
          * set the model instance for future use
327 327
          * @param DBSessionHandlerModel $modelInstance the model object
328 328
          */
329
-         public function setModelInstance(DBSessionHandlerModel $modelInstance){
329
+         public function setModelInstance(DBSessionHandlerModel $modelInstance) {
330 330
             $this->modelInstance = $modelInstance;
331 331
             return $this;
332 332
         }
@@ -334,13 +334,13 @@  discard block
 block discarded – undo
334 334
 	    /**
335 335
 	     * Set the model instance using the configuration for session
336 336
 	     */
337
-	    protected function setModelInstanceFromSessionConfig(){
337
+	    protected function setModelInstanceFromSessionConfig() {
338 338
 	    	$modelName = get_config('session_save_path');
339 339
 			$this->logger->info('The database session model: ' . $modelName);
340 340
 			$this->loader->model($modelName, 'dbsessionhandlerinstance'); 
341 341
 			//@codeCoverageIgnoreStart
342 342
             if (isset($this->OBJ->dbsessionhandlerinstance) 
343
-            	&& ! ($this->OBJ->dbsessionhandlerinstance instanceof DBSessionHandlerModel)
343
+            	&& !($this->OBJ->dbsessionhandlerinstance instanceof DBSessionHandlerModel)
344 344
             ) {
345 345
 				show_error('To use database session handler, your class model "' . get_class($this->OBJ->dbsessionhandlerinstance) . '" need extends "DBSessionHandlerModel"');
346 346
 			}  
Please login to merge, or discard this patch.
core/classes/Lang.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * For application languages management
29 29
 	 */
30
-	class Lang extends BaseClass{
30
+	class Lang extends BaseClass {
31 31
 		
32 32
 		/**
33 33
 		 * The supported available language for this application.
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		/**
62 62
 		 * Construct new Lang instance
63 63
 		 */
64
-		public function __construct(){
64
+		public function __construct() {
65 65
 			parent::__construct();
66 66
 
67 67
 			$this->default = get_config('default_language', 'en');
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 			
70 70
 			//add the supported languages ('key', 'display name')
71 71
 			$languages = get_config('languages', null);
72
-			if(! empty($languages)){
73
-				foreach($languages as $key => $displayName){
72
+			if (!empty($languages)) {
73
+				foreach ($languages as $key => $displayName) {
74 74
 					$this->addLang($key, $displayName);
75 75
 				}
76 76
 			}
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 
79 79
 			//if the language exists in cookie use it
80 80
 			$cfgKey = get_config('language_cookie_name');
81
-			$this->logger->debug('Getting current language from cookie [' .$cfgKey. ']');
81
+			$this->logger->debug('Getting current language from cookie [' . $cfgKey . ']');
82 82
 			$objCookie = & class_loader('Cookie');
83 83
 			$cookieLang = $objCookie->get($cfgKey);
84
-			if($cookieLang && $this->isValid($cookieLang)){
84
+			if ($cookieLang && $this->isValid($cookieLang)) {
85 85
 				$this->current = $cookieLang;
86
-				$this->logger->info('Language from cookie [' .$cfgKey. '] is valid so we will set the language using the cookie value [' .$cookieLang. ']');
86
+				$this->logger->info('Language from cookie [' . $cfgKey . '] is valid so we will set the language using the cookie value [' . $cookieLang . ']');
87 87
 			}
88
-			else{
89
-				$this->logger->info('Language from cookie [' .$cfgKey. '] is not set, use the default value [' .$this->getDefault(). ']');
88
+			else {
89
+				$this->logger->info('Language from cookie [' . $cfgKey . '] is not set, use the default value [' . $this->getDefault() . ']');
90 90
 				$this->current = $this->getDefault();
91 91
 			}
92 92
 		}
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		 *
97 97
 		 * @return array the language message list
98 98
 		 */
99
-		public function getAll(){
99
+		public function getAll() {
100 100
 			return $this->languages;
101 101
 		}
102 102
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 		 * @param string $key the language key to identify
107 107
 		 * @param string $value the language message value
108 108
 		 */
109
-		public function set($key, $value){
109
+		public function set($key, $value) {
110 110
 			$this->languages[$key] = $value;
111 111
 		}
112 112
 
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
 		 *
119 119
 		 * @return string the language message value
120 120
 		 */
121
-		public function get($key, $default = 'LANGUAGE_ERROR'){
122
-			if(isset($this->languages[$key])){
121
+		public function get($key, $default = 'LANGUAGE_ERROR') {
122
+			if (isset($this->languages[$key])) {
123 123
 				return $this->languages[$key];
124 124
 			}
125
-			$this->logger->warning('Language key  [' .$key. '] does not exist use the default value [' .$default. ']');
125
+			$this->logger->warning('Language key  [' . $key . '] does not exist use the default value [' . $default . ']');
126 126
 			return $default;
127 127
 		}
128 128
 
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
 		 *
134 134
 		 * @return boolean true if the language directory exists, false or not
135 135
 		 */
136
-		public function isValid($language){
136
+		public function isValid($language) {
137 137
 			$searchDir = array(CORE_LANG_PATH, APP_LANG_PATH);
138
-			foreach($searchDir as $dir){
139
-				if(file_exists($dir . $language) && is_dir($dir . $language)){
138
+			foreach ($searchDir as $dir) {
139
+				if (file_exists($dir . $language) && is_dir($dir . $language)) {
140 140
 					return true;
141 141
 				}
142 142
 			}
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		 *
149 149
 		 * @return string the default language
150 150
 		 */
151
-		public function getDefault(){
151
+		public function getDefault() {
152 152
 			return $this->default;
153 153
 		}
154 154
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		 *
158 158
 		 * @return string the current language
159 159
 		 */
160
-		public function getCurrent(){
160
+		public function getCurrent() {
161 161
 			return $this->current;
162 162
 		}
163 163
 
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
167 167
 		 * @param string $name the short language name like "en", "fr".
168 168
 		 * @param string $description the human readable description of this language
169 169
 		 */
170
-		public function addLang($name, $description){
171
-			if(isset($this->availables[$name])){
170
+		public function addLang($name, $description) {
171
+			if (isset($this->availables[$name])) {
172 172
 				return; //already added cost in performance
173 173
 			}
174
-			if($this->isValid($name)){
174
+			if ($this->isValid($name)) {
175 175
 				$this->availables[$name] = $description;
176 176
 			}
177
-			else{
177
+			else {
178 178
 				show_error('The language [' . $name . '] is not valid or does not exists.');
179 179
 			}
180 180
 		}
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		 *
185 185
 		 * @return array the list of the application language
186 186
 		 */
187
-		public function getSupported(){
187
+		public function getSupported() {
188 188
 			return $this->availables;
189 189
 		}
190 190
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 		 *
194 194
 		 * @param array $langs the languages array of the messages to be added
195 195
 		 */
196
-		public function addLangMessages(array $langs){
196
+		public function addLangMessages(array $langs) {
197 197
 			foreach ($langs as $key => $value) {
198 198
 				$this->set($key, $value);
199 199
 			}
Please login to merge, or discard this patch.
core/classes/Router.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26 26
 
27
-	class Router extends BaseClass{
27
+	class Router extends BaseClass {
28 28
 		/**
29 29
 		* @var array $pattern: The list of URIs to validate against
30 30
 		*/
@@ -90,13 +90,13 @@  discard block
 block discarded – undo
90 90
 		/**
91 91
 		 * Construct the new Router instance
92 92
 		 */
93
-		public function __construct(){
93
+		public function __construct() {
94 94
 			parent::__construct();
95 95
 			
96 96
 			//loading routes for module
97 97
 			$moduleRouteList = array();
98 98
 			$modulesRoutes = Module::getModulesRoutesConfig();
99
-			if($modulesRoutes && is_array($modulesRoutes)){
99
+			if ($modulesRoutes && is_array($modulesRoutes)) {
100 100
 				$moduleRouteList = $modulesRoutes;
101 101
 				unset($modulesRoutes);
102 102
 			}
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		 * Get the route patterns
112 112
 		 * @return array
113 113
 		 */
114
-		public function getPattern(){
114
+		public function getPattern() {
115 115
 			return $this->pattern;
116 116
 		}
117 117
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 		 * Get the route callbacks
120 120
 		 * @return array
121 121
 		 */
122
-		public function getCallback(){
122
+		public function getCallback() {
123 123
 			return $this->callback;
124 124
 		}
125 125
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		 * Get the module name
128 128
 		 * @return string
129 129
 		 */
130
-		public function getModule(){
130
+		public function getModule() {
131 131
 			return $this->module;
132 132
 		}
133 133
 		
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 		 * Get the controller name
136 136
 		 * @return string
137 137
 		 */
138
-		public function getController(){
138
+		public function getController() {
139 139
 			return $this->controller;
140 140
 		}
141 141
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		 * Get the controller file path
144 144
 		 * @return string
145 145
 		 */
146
-		public function getControllerPath(){
146
+		public function getControllerPath() {
147 147
 			return $this->controllerPath;
148 148
 		}
149 149
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 		 * Get the controller method
152 152
 		 * @return string
153 153
 		 */
154
-		public function getMethod(){
154
+		public function getMethod() {
155 155
 			return $this->method;
156 156
 		}
157 157
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		 * Get the request arguments
160 160
 		 * @return array
161 161
 		 */
162
-		public function getArgs(){
162
+		public function getArgs() {
163 163
 			return $this->args;
164 164
 		}
165 165
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 		 * Get the URL segments array
168 168
 		 * @return array
169 169
 		 */
170
-		public function getSegments(){
170
+		public function getSegments() {
171 171
 			return $this->segments;
172 172
 		}
173 173
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 		 * Get the route URI
176 176
 		 * @return string
177 177
 		 */
178
-		public function getRouteUri(){
178
+		public function getRouteUri() {
179 179
 			return $this->uri;
180 180
 		}
181 181
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		*/
190 190
 		public function add($uri, $callback) {
191 191
 			$uri = trim($uri, $this->uriTrim);
192
-			if(in_array($uri, $this->pattern)){
192
+			if (in_array($uri, $this->pattern)) {
193 193
 				$this->logger->warning('The route [' . $uri . '] already added, may be adding again can have route conflict');
194 194
 			}
195 195
 			$this->pattern[] = $uri;
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 		* @return object the current instance
206 206
 		*/
207 207
 		public function removeRoute($uri) {
208
-			$index  = array_search($uri, $this->pattern, true);
209
-			if($index !== false){
208
+			$index = array_search($uri, $this->pattern, true);
209
+			if ($index !== false) {
210 210
 				$this->logger->info('Remove route for uri [' . $uri . '] from the configuration');
211 211
 				unset($this->pattern[$index]);
212 212
 				unset($this->callback[$index]);
@@ -234,26 +234,26 @@  discard block
 block discarded – undo
234 234
 	     * @param string $uri the route URI, if is empty will determine automatically
235 235
 	     * @return object
236 236
 	     */
237
-	    public function setRouteUri($uri = ''){
237
+	    public function setRouteUri($uri = '') {
238 238
 	    	$routeUri = '';
239
-	    	if(! empty($uri)){
239
+	    	if (!empty($uri)) {
240 240
 	    		$routeUri = $uri;
241 241
 	    	}
242 242
 	    	//if the application is running in CLI mode use the first argument
243
-			else if(IS_CLI && isset($_SERVER['argv'][1])){
243
+			else if (IS_CLI && isset($_SERVER['argv'][1])) {
244 244
 				$routeUri = $_SERVER['argv'][1];
245 245
 			}
246
-			else if(isset($_SERVER['REQUEST_URI'])){
246
+			else if (isset($_SERVER['REQUEST_URI'])) {
247 247
 				$routeUri = $_SERVER['REQUEST_URI'];
248 248
 			}
249 249
 			$this->logger->debug('Check if URL suffix is enabled in the configuration');
250 250
 			//remove url suffix from the request URI
251 251
 			$suffix = get_config('url_suffix');
252 252
 			if ($suffix) {
253
-				$this->logger->info('URL suffix is enabled in the configuration, the value is [' . $suffix . ']' );
253
+				$this->logger->info('URL suffix is enabled in the configuration, the value is [' . $suffix . ']');
254 254
 				$routeUri = str_ireplace($suffix, '', $routeUri);
255 255
 			} 
256
-			if (strpos($routeUri, '?') !== false){
256
+			if (strpos($routeUri, '?') !== false) {
257 257
 				$routeUri = substr($routeUri, 0, strpos($routeUri, '?'));
258 258
 			}
259 259
 			$this->uri = trim($routeUri, $this->uriTrim);
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 		 * 
267 267
 		 * @return object
268 268
 		 */
269
-		public function setRouteSegments(array $segments = array()){
270
-			if(! empty($segments)){
269
+		public function setRouteSegments(array $segments = array()) {
270
+			if (!empty($segments)) {
271 271
 				$this->segments = $segments;
272 272
 			} else if (!empty($this->uri)) {
273 273
 				$this->segments = explode('/', $this->uri);
@@ -275,12 +275,12 @@  discard block
 block discarded – undo
275 275
 			$segment = $this->segments;
276 276
 			$baseUrl = get_config('base_url');
277 277
 			//check if the app is not in DOCUMENT_ROOT
278
-			if(isset($segment[0]) && stripos($baseUrl, $segment[0]) !== false){
278
+			if (isset($segment[0]) && stripos($baseUrl, $segment[0]) !== false) {
279 279
 				array_shift($segment);
280 280
 				$this->segments = $segment;
281 281
 			}
282 282
 			$this->logger->debug('Check if the request URI contains the front controller');
283
-			if(isset($segment[0]) && $segment[0] == SELF){
283
+			if (isset($segment[0]) && $segment[0] == SELF) {
284 284
 				$this->logger->info('The request URI contains the front controller');
285 285
 				array_shift($segment);
286 286
 				$this->segments = $segment;
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 			
301 301
 			//if can not determine the module/controller/method via the defined routes configuration we will use
302 302
 			//the URL like http://domain.com/module/controller/method/arg1/arg2
303
-			if(! $this->controller){
303
+			if (!$this->controller) {
304 304
 				$this->logger->info('Cannot determine the routing information using the predefined routes configuration, will use the request URI parameters');
305 305
 				//determine route parameters using the REQUEST_URI param
306 306
 				$this->determineRouteParamsFromRequestUri();
@@ -316,14 +316,14 @@  discard block
 block discarded – undo
316 316
 		 * Routing the request to the correspondant module/controller/method if exists
317 317
 		 * otherwise send 404 error.
318 318
 		 */
319
-	    public function processRequest(){
319
+	    public function processRequest() {
320 320
 	    	//Setting the route URI
321 321
 			$this->setRouteUri();
322 322
 
323 323
 			//setting route segments
324 324
 			$this->setRouteSegments();
325 325
 
326
-			$this->logger->info('The final Request URI is [' . implode('/', $this->segments) . ']' );
326
+			$this->logger->info('The final Request URI is [' . implode('/', $this->segments) . ']');
327 327
 
328 328
 	    	//determine the route parameters information
329 329
 	    	$this->determineRouteParamsInformation();
@@ -334,20 +334,20 @@  discard block
 block discarded – undo
334 334
 	    	$this->logger->info('The routing information are: module [' . $this->module . '], controller [' . $controller . '], method [' . $this->method . '], args [' . stringfy_vars($this->args) . ']');
335 335
 	    	$this->logger->debug('Loading controller [' . $controller . '], the file path is [' . $classFilePath . ']...');
336 336
 	    	
337
-			if(file_exists($classFilePath)){
337
+			if (file_exists($classFilePath)) {
338 338
 				require_once $classFilePath;
339
-				if(! class_exists($controller, false)){
339
+				if (!class_exists($controller, false)) {
340 340
 					$e404 = true;
341
-					$this->logger->warning('The controller file [' .$classFilePath. '] exists but does not contain the class [' . $controller . ']');
341
+					$this->logger->warning('The controller file [' . $classFilePath . '] exists but does not contain the class [' . $controller . ']');
342 342
 				}
343
-				else{
343
+				else {
344 344
 					$controllerInstance = new $controller();
345 345
 					$controllerMethod = $this->getMethod();
346
-					if(! method_exists($controllerInstance, $controllerMethod)){
346
+					if (!method_exists($controllerInstance, $controllerMethod)) {
347 347
 						$e404 = true;
348 348
 						$this->logger->warning('The controller [' . $controller . '] exist but does not contain the method [' . $controllerMethod . ']');
349 349
 					}
350
-					else{
350
+					else {
351 351
 						$this->logger->info('Routing data is set correctly now GO!');
352 352
 						call_user_func_array(array($controllerInstance, $controllerMethod), $this->args);
353 353
 						//render the final page to user
@@ -356,16 +356,16 @@  discard block
 block discarded – undo
356 356
 					}
357 357
 				}
358 358
 			}
359
-			else{
359
+			else {
360 360
 				$this->logger->info('The controller file path [' . $classFilePath . '] does not exist');
361 361
 				$e404 = true;
362 362
 			}
363
-			if($e404){
364
-				if(IS_CLI){
363
+			if ($e404) {
364
+				if (IS_CLI) {
365 365
 					set_http_status_header(404);
366 366
 					echo 'Error 404: page not found.';
367 367
 				} else {
368
-					$response =& class_loader('Response', 'classes');
368
+					$response = & class_loader('Response', 'classes');
369 369
 					$response->send404();
370 370
 				}
371 371
 			}
@@ -378,15 +378,15 @@  discard block
 block discarded – undo
378 378
 	    * @param boolean $useConfigFile whether to use route configuration file
379 379
 		* @return object
380 380
 	    */
381
-	    public function setRouteConfiguration(array $overwriteConfig = array(), $useConfigFile = true){
381
+	    public function setRouteConfiguration(array $overwriteConfig = array(), $useConfigFile = true) {
382 382
 	        $route = array();
383
-	        if ($useConfigFile && file_exists(CONFIG_PATH . 'routes.php')){
383
+	        if ($useConfigFile && file_exists(CONFIG_PATH . 'routes.php')) {
384 384
 	            require_once CONFIG_PATH . 'routes.php';
385 385
 	        }
386 386
 	        $route = array_merge($route, $overwriteConfig);
387 387
 	        $this->routes = $route;
388 388
 	        //if route is empty remove all configuration
389
-	        if(empty($route)){
389
+	        if (empty($route)) {
390 390
 	        	$this->removeAllRoute();
391 391
 	        }
392 392
 			return $this;
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 		 * Get the route configuration
397 397
 		 * @return array
398 398
 		 */
399
-		public function getRouteConfiguration(){
399
+		public function getRouteConfiguration() {
400 400
 			return $this->routes;
401 401
 		}
402 402
 
@@ -408,19 +408,19 @@  discard block
 block discarded – undo
408 408
 	     *
409 409
 	     * @return object the current instance
410 410
 	     */
411
-	    public function setControllerFilePath($path = null){
412
-	    	if($path !== null){
411
+	    public function setControllerFilePath($path = null) {
412
+	    	if ($path !== null) {
413 413
 	    		$this->controllerPath = $path;
414 414
 	    		return $this;
415 415
 	    	}
416 416
 	    	//did we set the controller, so set the controller path
417
-			if($this->controller && ! $this->controllerPath){
417
+			if ($this->controller && !$this->controllerPath) {
418 418
 				$this->logger->debug('Setting the file path for the controller [' . $this->controller . ']');
419 419
 				$controllerPath = APPS_CONTROLLER_PATH . ucfirst($this->controller) . '.php';
420 420
 				//if the controller is in module
421
-				if($this->module){
421
+				if ($this->module) {
422 422
 					$path = Module::findControllerFullPath(ucfirst($this->controller), $this->module);
423
-					if($path !== false){
423
+					if ($path !== false) {
424 424
 						$controllerPath = $path;
425 425
 					}
426 426
 				}
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 	     * Determine the route parameters from route configuration
434 434
 	     * @return void
435 435
 	     */
436
-	    protected function determineRouteParamsFromConfig(){
436
+	    protected function determineRouteParamsFromConfig() {
437 437
 	    	$uri = implode('/', $this->segments);
438 438
 	    	/*
439 439
 	   		* Generics routes patterns
@@ -458,20 +458,20 @@  discard block
 block discarded – undo
458 458
 					array_shift($args);
459 459
 					//check if this contains an module
460 460
 					$moduleControllerMethod = explode('#', $this->callback[$index]);
461
-					if(is_array($moduleControllerMethod) && count($moduleControllerMethod) >= 2){
461
+					if (is_array($moduleControllerMethod) && count($moduleControllerMethod) >= 2) {
462 462
 						$this->logger->info('The current request use the module [' . $moduleControllerMethod[0] . ']');
463 463
 						$this->module = $moduleControllerMethod[0];
464 464
 						$moduleControllerMethod = explode('@', $moduleControllerMethod[1]);
465 465
 					}
466
-					else{
466
+					else {
467 467
 						$this->logger->info('The current request does not use the module');
468 468
 						$moduleControllerMethod = explode('@', $this->callback[$index]);
469 469
 					}
470
-					if(is_array($moduleControllerMethod)){
471
-						if(isset($moduleControllerMethod[0])){
470
+					if (is_array($moduleControllerMethod)) {
471
+						if (isset($moduleControllerMethod[0])) {
472 472
 							$this->controller = $moduleControllerMethod[0];	
473 473
 						}
474
-						if(isset($moduleControllerMethod[1])){
474
+						if (isset($moduleControllerMethod[1])) {
475 475
 							$this->method = $moduleControllerMethod[1];
476 476
 						}
477 477
 						$this->args = $args;
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 			}
483 483
 
484 484
 			//first if the controller is not set and the module is set use the module name as the controller
485
-			if(! $this->controller && $this->module){
485
+			if (!$this->controller && $this->module) {
486 486
 				$this->logger->info(
487 487
 									'After loop in predefined routes configuration, 
488 488
 									the module name is set but the controller is not set, 
@@ -496,67 +496,67 @@  discard block
 block discarded – undo
496 496
 	     * Determine the route parameters using the server variable "REQUEST_URI"
497 497
 	     * @return void
498 498
 	     */
499
-	    protected function determineRouteParamsFromRequestUri(){
499
+	    protected function determineRouteParamsFromRequestUri() {
500 500
 	    	$segment = $this->segments;
501 501
 	    	$nbSegment = count($segment);
502 502
 			//if segment is null so means no need to perform
503
-			if($nbSegment > 0){
503
+			if ($nbSegment > 0) {
504 504
 				//get the module list
505 505
 				$modules = Module::getModuleList();
506 506
 				//first check if no module
507
-				if(empty($modules)){
507
+				if (empty($modules)) {
508 508
 					$this->logger->info('No module was loaded will skip the module checking');
509 509
 					//the application don't use module
510 510
 					//controller
511
-					if(isset($segment[0])){
511
+					if (isset($segment[0])) {
512 512
 						$this->controller = $segment[0];
513 513
 						array_shift($segment);
514 514
 					}
515 515
 					//method
516
-					if(isset($segment[0])){
516
+					if (isset($segment[0])) {
517 517
 						$this->method = $segment[0];
518 518
 						array_shift($segment);
519 519
 					}
520 520
 					//args
521 521
 					$this->args = $segment;
522 522
 				}
523
-				else{
523
+				else {
524 524
 					$this->logger->info('The application contains a loaded module will check if the current request is found in the module list');
525
-					if(in_array($segment[0], $modules)){
525
+					if (in_array($segment[0], $modules)) {
526 526
 						$this->logger->info('Found, the current request use the module [' . $segment[0] . ']');
527 527
 						$this->module = $segment[0];
528 528
 						array_shift($segment);
529 529
 						//check if the second arg is the controller from module
530
-						if(isset($segment[0])){
530
+						if (isset($segment[0])) {
531 531
 							$this->controller = $segment[0];
532 532
 							//check if the request use the same module name and controller
533 533
 							$path = Module::findControllerFullPath(ucfirst($this->controller), $this->module);
534
-							if(! $path){
534
+							if (!$path) {
535 535
 								$this->logger->info('The controller [' . $this->controller . '] not found in the module, may be will use the module [' . $this->module . '] as controller');
536 536
 								$this->controller = $this->module;
537 537
 							}
538
-							else{
538
+							else {
539 539
 								$this->controllerPath = $path;
540 540
 								array_shift($segment);
541 541
 							}
542 542
 						}
543 543
 						//check for method
544
-						if(isset($segment[0])){
544
+						if (isset($segment[0])) {
545 545
 							$this->method = $segment[0];
546 546
 							array_shift($segment);
547 547
 						}
548 548
 						//the remaining is for args
549 549
 						$this->args = $segment;
550 550
 					}
551
-					else{
551
+					else {
552 552
 						$this->logger->info('The current request information is not found in the module list');
553 553
 						//controller
554
-						if(isset($segment[0])){
554
+						if (isset($segment[0])) {
555 555
 							$this->controller = $segment[0];
556 556
 							array_shift($segment);
557 557
 						}
558 558
 						//method
559
-						if(isset($segment[0])){
559
+						if (isset($segment[0])) {
560 560
 							$this->method = $segment[0];
561 561
 							array_shift($segment);
562 562
 						}
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
 						$this->args = $segment;
565 565
 					}
566 566
 				}
567
-				if(! $this->controller && $this->module){
567
+				if (!$this->controller && $this->module) {
568 568
 					$this->logger->info('After using the request URI the module name is set but the controller is not set so we will use module as the controller');
569 569
 					$this->controller = $this->module;
570 570
 				}
@@ -576,9 +576,9 @@  discard block
 block discarded – undo
576 576
 	     *
577 577
 	     * @return object the current instance
578 578
 	     */
579
-	    protected function setRouteConfigurationInfos(){
579
+	    protected function setRouteConfigurationInfos() {
580 580
 	    	//adding route
581
-			foreach($this->routes as $pattern => $callback){
581
+			foreach ($this->routes as $pattern => $callback) {
582 582
 				$this->add($pattern, $callback);
583 583
 			}
584 584
 			return $this;
Please login to merge, or discard this patch.
core/classes/Session.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 * along with this program; if not, write to the Free Software
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26
-	class Session extends BaseStaticClass{
26
+	class Session extends BaseStaticClass {
27 27
 		
28 28
 		/**
29 29
 		 * The session flash key to use
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
 		 * @param  mixed $default the default value to use if can not find the session item in the list
38 38
 		 * @return mixed          the session value if exist or the default value
39 39
 		 */
40
-		public static function get($item, $default = null){
40
+		public static function get($item, $default = null) {
41 41
 			$logger = self::getLogger();
42
-			$logger->debug('Getting session data for item [' .$item. '] ...');
43
-			if(array_key_exists($item, $_SESSION)){
42
+			$logger->debug('Getting session data for item [' . $item . '] ...');
43
+			if (array_key_exists($item, $_SESSION)) {
44 44
 				$logger->info('Found session data for item [' . $item . '] the vaue is : [' . stringfy_vars($_SESSION[$item]) . ']');
45 45
 				return $_SESSION[$item];
46 46
 			}
47
-			$logger->warning('Cannot find session item [' . $item . '] using the default value ['. $default . ']');
47
+			$logger->warning('Cannot find session item [' . $item . '] using the default value [' . $default . ']');
48 48
 			return $default;
49 49
 		}
50 50
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		 * @param string $item  the session item name to set
54 54
 		 * @param mixed $value the session item value
55 55
 		 */
56
-		public static function set($item, $value){
56
+		public static function set($item, $value) {
57 57
 			$logger = self::getLogger();
58 58
 			$logger->debug('Setting session data for item [' . $item . '], value [' . stringfy_vars($value) . ']');
59 59
 			$_SESSION[$item] = $value;
@@ -65,16 +65,16 @@  discard block
 block discarded – undo
65 65
 		 * @param  mixed $default the default value to use if can not find the session flash item in the list
66 66
 		 * @return mixed          the session flash value if exist or the default value
67 67
 		 */
68
-		public static function getFlash($item, $default = null){
68
+		public static function getFlash($item, $default = null) {
69 69
 			$logger = self::getLogger();
70
-			$key = self::SESSION_FLASH_KEY.'_'.$item;
70
+			$key = self::SESSION_FLASH_KEY . '_' . $item;
71 71
 			$return = array_key_exists($key, $_SESSION) ?
72 72
 			($_SESSION[$key]) : $default;
73
-			if(array_key_exists($key, $_SESSION)){
73
+			if (array_key_exists($key, $_SESSION)) {
74 74
 				unset($_SESSION[$key]);
75 75
 			}
76
-			else{
77
-				$logger->warning('Cannot find session flash item ['. $key .'] using the default value ['. $default .']');
76
+			else {
77
+				$logger->warning('Cannot find session flash item [' . $key . '] using the default value [' . $default . ']');
78 78
 			}
79 79
 			return $return;
80 80
 		}
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 		 * @param  string  $item the session flash item name
85 85
 		 * @return boolean 
86 86
 		 */
87
-		public static function hasFlash($item){
88
-			$key = self::SESSION_FLASH_KEY.'_'.$item;
87
+		public static function hasFlash($item) {
88
+			$key = self::SESSION_FLASH_KEY . '_' . $item;
89 89
 			return array_key_exists($key, $_SESSION);
90 90
 		}
91 91
 
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 		 * @param string $item  the session flash item name to set
95 95
 		 * @param mixed $value the session flash item value
96 96
 		 */
97
-		public static function setFlash($item, $value){
98
-			$key = self::SESSION_FLASH_KEY.'_'.$item;
97
+		public static function setFlash($item, $value) {
98
+			$key = self::SESSION_FLASH_KEY . '_' . $item;
99 99
 			$_SESSION[$key] = $value;
100 100
 		}
101 101
 
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
 		 * Clear the session item in the list
104 104
 		 * @param  string $item the session item name to be deleted
105 105
 		 */
106
-		public static function clear($item){
106
+		public static function clear($item) {
107 107
 			$logger = self::getLogger();
108
-			if(array_key_exists($item, $_SESSION)){
109
-				$logger->info('Deleting of session for item ['.$item.' ]');
108
+			if (array_key_exists($item, $_SESSION)) {
109
+				$logger->info('Deleting of session for item [' . $item . ' ]');
110 110
 				unset($_SESSION[$item]);
111 111
 			}
112
-			else{
113
-				$logger->warning('Session item ['.$item.'] to be deleted does not exists');
112
+			else {
113
+				$logger->warning('Session item [' . $item . '] to be deleted does not exists');
114 114
 			}
115 115
 		}
116 116
 		
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
 		 * Clear the session flash item in the list
119 119
 		 * @param  string $item the session flash item name to be deleted
120 120
 		 */
121
-		public static function clearFlash($item){
121
+		public static function clearFlash($item) {
122 122
 			$logger = self::getLogger();
123
-			$key = self::SESSION_FLASH_KEY.'_'.$item;
124
-			if(array_key_exists($key, $_SESSION)){
125
-				$logger->info('Delete session flash for item ['.$item.']');
123
+			$key = self::SESSION_FLASH_KEY . '_' . $item;
124
+			if (array_key_exists($key, $_SESSION)) {
125
+				$logger->info('Delete session flash for item [' . $item . ']');
126 126
 				unset($_SESSION[$item]);
127 127
 			}
128
-			else{
129
-				$logger->warning('Dession flash item ['.$item.'] to be deleted does not exists');
128
+			else {
129
+				$logger->warning('Dession flash item [' . $item . '] to be deleted does not exists');
130 130
 			}
131 131
 		}
132 132
 
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
 		 * @param  string  $item the session item name
136 136
 		 * @return boolean 
137 137
 		 */
138
-		public static function exists($item){
138
+		public static function exists($item) {
139 139
 			return array_key_exists($item, $_SESSION);
140 140
 		}
141 141
 
142 142
 		/**
143 143
 		 * Destroy all session data values
144 144
 		 */
145
-		public static function clearAll(){
145
+		public static function clearAll() {
146 146
 			session_unset();
147 147
 			session_destroy();
148 148
 		}
Please login to merge, or discard this patch.
core/classes/cache/ApcCache.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -24,13 +24,13 @@  discard block
 block discarded – undo
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26 26
 	
27
-	class ApcCache extends BaseClass implements CacheInterface{
27
+	class ApcCache extends BaseClass implements CacheInterface {
28 28
 
29 29
 		
30 30
 		
31
-		public function __construct(){
31
+		public function __construct() {
32 32
 			parent::__construct();
33
-			if(! $this->isSupported()){
33
+			if (!$this->isSupported()) {
34 34
 				show_error('The cache for APC[u] driver is not available. Check if APC[u] extension is loaded and enabled.');
35 35
 			}
36 36
 		}
@@ -40,21 +40,21 @@  discard block
 block discarded – undo
40 40
 		 * @param  string $key the key to identify the cache data
41 41
 		 * @return mixed      the cache data if exists else return false
42 42
 		 */
43
-		public function get($key){
44
-			$this->logger->debug('Getting cache data for key ['. $key .']');
43
+		public function get($key) {
44
+			$this->logger->debug('Getting cache data for key [' . $key . ']');
45 45
 			$success = false;
46 46
 			$data = apc_fetch($key, $success);
47
-			if($success === false){
48
-				$this->logger->info('No cache found for the key ['. $key .'], return false');
47
+			if ($success === false) {
48
+				$this->logger->info('No cache found for the key [' . $key . '], return false');
49 49
 				return false;
50 50
 			}
51
-			else{
51
+			else {
52 52
 				$cacheInfo = $this->_getCacheInfo($key);
53 53
 				$expire = time();
54
-				if($cacheInfo){
54
+				if ($cacheInfo) {
55 55
 					$expire = $cacheInfo['creation_time'] + $cacheInfo['ttl'];
56 56
 				}
57
-				$this->logger->info('The cache not yet expire, now return the cache data for key ['. $key .'], the cache will expire at [' . date('Y-m-d H:i:s', $expire) . ']');
57
+				$this->logger->info('The cache not yet expire, now return the cache data for key [' . $key . '], the cache will expire at [' . date('Y-m-d H:i:s', $expire) . ']');
58 58
 				return $data;
59 59
 			}
60 60
 		}
@@ -67,16 +67,16 @@  discard block
 block discarded – undo
67 67
 		 * @param integer $ttl  the cache life time
68 68
 		 * @return boolean true if success otherwise will return false
69 69
 		 */
70
-		public function set($key, $data, $ttl = 0){
70
+		public function set($key, $data, $ttl = 0) {
71 71
 			$expire = time() + $ttl;
72
-			$this->logger->debug('Setting cache data for key ['. $key .'], time to live [' .$ttl. '], expire at [' . date('Y-m-d H:i:s', $expire) . ']');
72
+			$this->logger->debug('Setting cache data for key [' . $key . '], time to live [' . $ttl . '], expire at [' . date('Y-m-d H:i:s', $expire) . ']');
73 73
 			$result = apc_store($key, $data, $ttl);
74
-			if($result === false){
75
-		    	$this->logger->error('Can not write cache data for the key ['. $key .'], return false');
74
+			if ($result === false) {
75
+		    	$this->logger->error('Can not write cache data for the key [' . $key . '], return false');
76 76
 		    	return false;
77 77
 		    }
78
-		    else{
79
-		    	$this->logger->info('Cache data saved for the key ['. $key .']');
78
+		    else {
79
+		    	$this->logger->info('Cache data saved for the key [' . $key . ']');
80 80
 		    	return true;
81 81
 		    }
82 82
 		}
@@ -88,15 +88,15 @@  discard block
 block discarded – undo
88 88
 		 * @return boolean      true if the cache is deleted, false if can't delete 
89 89
 		 * the cache or the cache with the given key not exist
90 90
 		 */
91
-		public function delete($key){
92
-			$this->logger->debug('Deleting of cache data for key [' .$key. ']');
91
+		public function delete($key) {
92
+			$this->logger->debug('Deleting of cache data for key [' . $key . ']');
93 93
 			$cacheInfo = $this->_getCacheInfo($key);
94
-			if($cacheInfo === false){
94
+			if ($cacheInfo === false) {
95 95
 				$this->logger->info('This cache data does not exists skipping');
96 96
 				return false;
97 97
 			}
98
-			else{
99
-				$this->logger->info('Found cache data for the key [' .$key. '] remove it');
98
+			else {
99
+				$this->logger->info('Found cache data for the key [' . $key . '] remove it');
100 100
 	      		return apc_delete($key) === true;
101 101
 			}
102 102
 		}
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
 		 * 'expire' => expiration time of the cache (Unix timestamp),
110 110
 		 * 'ttl' => the time to live of the cache in second
111 111
 		 */
112
-		public function getInfo($key){
113
-			$this->logger->debug('Getting of cache info for key [' .$key. ']');
112
+		public function getInfo($key) {
113
+			$this->logger->debug('Getting of cache info for key [' . $key . ']');
114 114
 			$cacheInfos = $this->_getCacheInfo($key);
115
-			if($cacheInfos){
115
+			if ($cacheInfos) {
116 116
 				$data = array(
117 117
 							'mtime' => $cacheInfos['creation_time'],
118 118
 							'expire' => $cacheInfos['creation_time'] + $cacheInfos['ttl'],
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 							);
121 121
 				return $data;
122 122
 			}
123
-			else{
123
+			else {
124 124
 				$this->logger->info('This cache does not exists skipping');
125 125
 				return false;
126 126
 			}
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 		/**
131 131
 		 * Used to delete expired cache data
132 132
 		 */
133
-		public function deleteExpiredCache(){
133
+		public function deleteExpiredCache() {
134 134
 			//for APC[u] is done automatically
135 135
 			return true;
136 136
 		}
@@ -138,14 +138,14 @@  discard block
 block discarded – undo
138 138
 		/**
139 139
 		 * Remove all cache data
140 140
 		 */
141
-		public function clean(){
141
+		public function clean() {
142 142
 			$this->logger->debug('Deleting of all cache data');
143 143
 			$cacheInfos = apc_cache_info('user');
144
-			if(empty($cacheInfos['cache_list'])){
144
+			if (empty($cacheInfos['cache_list'])) {
145 145
 				$this->logger->info('No cache data were found skipping');
146 146
 				return false;
147 147
 			}
148
-			else{
148
+			else {
149 149
 				$this->logger->info('Found [' . count($cacheInfos) . '] cache data to remove');
150 150
 				return apc_clear_cache('user');
151 151
 			}
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		 *
158 158
 		 * @return bool
159 159
 		 */
160
-		public function isSupported(){
160
+		public function isSupported() {
161 161
 			return (extension_loaded('apc') || extension_loaded('apcu')) && ini_get('apc.enabled');
162 162
 		}
163 163
 		
@@ -167,12 +167,12 @@  discard block
 block discarded – undo
167 167
 		* @param string $key the cache key to get the cache information 
168 168
 		* @return boolean|array
169 169
 		*/
170
-		private function _getCacheInfo($key){
170
+		private function _getCacheInfo($key) {
171 171
 			$caches = apc_cache_info('user');
172
-			if(! empty($caches['cache_list'])){
172
+			if (!empty($caches['cache_list'])) {
173 173
 				$cacheLists = $caches['cache_list'];
174
-				foreach ($cacheLists as $c){
175
-					if(isset($c['info']) && $c['info'] === $key){
174
+				foreach ($cacheLists as $c) {
175
+					if (isset($c['info']) && $c['info'] === $key) {
176 176
 						return $c;
177 177
 					}
178 178
 				}
Please login to merge, or discard this patch.
core/classes/cache/FileCache.php 1 patch
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26 26
 
27
-	class FileCache extends BaseClass implements CacheInterface{
27
+	class FileCache extends BaseClass implements CacheInterface {
28 28
 		
29 29
 		/**
30 30
 		 * Whether to enable compression of the cache data file.
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
 		/**
36 36
 		 * Class constructor
37 37
 		 */
38
-		public function __construct(){
38
+		public function __construct() {
39 39
 			parent::__construct();
40
-			if(! $this->isSupported()){
40
+			if (!$this->isSupported()) {
41 41
 				show_error('The cache for file system is not available. Check the cache directory if is exists or is writable.');
42 42
 			}
43 43
 			
44 44
 			//if Zlib extension is not loaded set compressCacheData to false
45
-			if(! extension_loaded('zlib')){
45
+			if (!extension_loaded('zlib')) {
46 46
 				$this->logger->warning('The zlib extension is not loaded set cache compress data to FALSE');
47 47
 				$this->compressCacheData = false;
48 48
 			}
@@ -53,17 +53,17 @@  discard block
 block discarded – undo
53 53
 		 * @param  string $key the key to identify the cache data
54 54
 		 * @return mixed      the cache data if exists else return false
55 55
 		 */
56
-		public function get($key){
57
-			$this->logger->debug('Getting cache data for key ['. $key .']');
56
+		public function get($key) {
57
+			$this->logger->debug('Getting cache data for key [' . $key . ']');
58 58
 			$filePath = $this->getFilePath($key);
59
-			if(! file_exists($filePath)){
60
-				$this->logger->info('No cache file found for the key ['. $key .'], return false');
59
+			if (!file_exists($filePath)) {
60
+				$this->logger->info('No cache file found for the key [' . $key . '], return false');
61 61
 				return false;
62 62
 			}
63
-			$this->logger->info('The cache file [' .$filePath. '] for the key ['. $key .'] exists, check if the cache data is valid');
64
-			$handle = fopen($filePath,'r');
65
-			if(! is_resource($handle)){
66
-				$this->logger->error('Can not open the file cache [' .$filePath. '] for the key ['. $key .'], return false');
63
+			$this->logger->info('The cache file [' . $filePath . '] for the key [' . $key . '] exists, check if the cache data is valid');
64
+			$handle = fopen($filePath, 'r');
65
+			if (!is_resource($handle)) {
66
+				$this->logger->error('Can not open the file cache [' . $filePath . '] for the key [' . $key . '], return false');
67 67
 				return false;
68 68
 			}
69 69
 			// Getting a shared lock 
@@ -71,20 +71,20 @@  discard block
 block discarded – undo
71 71
 		    $data = file_get_contents($filePath);
72 72
       		fclose($handle);
73 73
       		$data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
74
-      		if (! $data) {
75
-      			$this->logger->error('Can not unserialize the cache data for the key ['. $key .'], return false');
74
+      		if (!$data) {
75
+      			$this->logger->error('Can not unserialize the cache data for the key [' . $key . '], return false');
76 76
 		         // If unserializing somehow didn't work out, we'll delete the file
77 77
 		         unlink($filePath);
78 78
 		         return false;
79 79
 	      	}
80 80
 	      	if (time() > $data['expire']) {
81
-	      		$this->logger->info('The cache data for the key ['. $key .'] already expired delete the cache file [' .$filePath. ']');
81
+	      		$this->logger->info('The cache data for the key [' . $key . '] already expired delete the cache file [' . $filePath . ']');
82 82
 		        // Unlinking when the file was expired
83 83
 		        unlink($filePath);
84 84
 		        return false;
85 85
 		     }
86
-		     else{
87
-		     	$this->logger->info('The cache not yet expire, now return the cache data for key ['. $key .'], the cache will expire at [' . date('Y-m-d H:i:s', $data['expire']) . ']');
86
+		     else {
87
+		     	$this->logger->info('The cache not yet expire, now return the cache data for key [' . $key . '], the cache will expire at [' . date('Y-m-d H:i:s', $data['expire']) . ']');
88 88
 		     	return $data['data'];
89 89
 		     }
90 90
 		}
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
 		 * @param integer $ttl  the cache life time
98 98
 		 * @return boolean true if success otherwise will return false
99 99
 		 */
100
-		public function set($key, $data, $ttl = 0){
100
+		public function set($key, $data, $ttl = 0) {
101 101
 			$expire = time() + $ttl;
102
-			$this->logger->debug('Setting cache data for key ['. $key .'], time to live [' .$ttl. '], expire at [' . date('Y-m-d H:i:s', $expire) . ']');
102
+			$this->logger->debug('Setting cache data for key [' . $key . '], time to live [' . $ttl . '], expire at [' . date('Y-m-d H:i:s', $expire) . ']');
103 103
 			$filePath = $this->getFilePath($key);
104
-			$handle = fopen($filePath,'w');
105
-			if(! is_resource($handle)){
106
-				$this->logger->error('Can not open the file cache [' .$filePath. '] for the key ['. $key .'], return false');
104
+			$handle = fopen($filePath, 'w');
105
+			if (!is_resource($handle)) {
106
+				$this->logger->error('Can not open the file cache [' . $filePath . '] for the key [' . $key . '], return false');
107 107
 				return false;
108 108
 			}
109 109
 			flock($handle, LOCK_EX); // exclusive lock, will get released when the file is closed
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
 									)
117 117
 								);		   
118 118
 		    $result = fwrite($handle, $this->compressCacheData ? gzdeflate($cacheData, 9) : $cacheData);
119
-		    if(! $result){
120
-		    	$this->logger->error('Can not write cache data into file [' .$filePath. '] for the key ['. $key .'], return false');
119
+		    if (!$result) {
120
+		    	$this->logger->error('Can not write cache data into file [' . $filePath . '] for the key [' . $key . '], return false');
121 121
 		    	fclose($handle);
122 122
 		    	return false;
123 123
 		    }
124
-		    else{
125
-		    	$this->logger->info('Cache data saved into file [' .$filePath. '] for the key ['. $key .']');
124
+		    else {
125
+		    	$this->logger->info('Cache data saved into file [' . $filePath . '] for the key [' . $key . ']');
126 126
 		    	fclose($handle);
127 127
 				chmod($filePath, 0640);
128 128
 				return true;
@@ -136,16 +136,16 @@  discard block
 block discarded – undo
136 136
 		 * @return boolean      true if the cache is delete, false if can't delete 
137 137
 		 * the cache or the cache with the given key not exist
138 138
 		 */
139
-		public function delete($key){
140
-			$this->logger->debug('Deleting of cache data for key [' .$key. ']');
139
+		public function delete($key) {
140
+			$this->logger->debug('Deleting of cache data for key [' . $key . ']');
141 141
 			$filePath = $this->getFilePath($key);
142
-			$this->logger->info('The file path for the key [' .$key. '] is [' .$filePath. ']');
143
-			if(! file_exists($filePath)){
142
+			$this->logger->info('The file path for the key [' . $key . '] is [' . $filePath . ']');
143
+			if (!file_exists($filePath)) {
144 144
 				$this->logger->info('This cache file does not exists skipping');
145 145
 				return false;
146 146
 			}
147
-			else{
148
-				$this->logger->info('Found cache file [' .$filePath. '] remove it');
147
+			else {
148
+				$this->logger->info('Found cache file [' . $filePath . '] remove it');
149 149
 	      		unlink($filePath);
150 150
 				return true;
151 151
 			}
@@ -159,23 +159,23 @@  discard block
 block discarded – undo
159 159
 		 * 'expire' => expiration time of the cache (Unix timestamp),
160 160
 		 * 'ttl' => the time to live of the cache in second
161 161
 		 */
162
-		public function getInfo($key){
163
-			$this->logger->debug('Getting of cache info for key [' .$key. ']');
162
+		public function getInfo($key) {
163
+			$this->logger->debug('Getting of cache info for key [' . $key . ']');
164 164
 			$filePath = $this->getFilePath($key);
165
-			$this->logger->info('The file path for the key [' .$key. '] is [' .$filePath. ']');
166
-			if(! file_exists($filePath)){
165
+			$this->logger->info('The file path for the key [' . $key . '] is [' . $filePath . ']');
166
+			if (!file_exists($filePath)) {
167 167
 				$this->logger->info('This cache file does not exists skipping');
168 168
 				return false;
169 169
 			}
170
-			$this->logger->info('Found cache file [' .$filePath. '] check the validity');
170
+			$this->logger->info('Found cache file [' . $filePath . '] check the validity');
171 171
       		$data = file_get_contents($filePath);
172 172
 			$data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
173
-			if(! $data){
173
+			if (!$data) {
174 174
 				$this->logger->warning('Can not unserialize the cache data for file [' . $filePath . ']');
175 175
 				return false;
176 176
 			}
177 177
 			$this->logger->info('This cache data is OK check for expire');
178
-			if(isset($data['expire']) && $data['expire'] > time()){
178
+			if (isset($data['expire']) && $data['expire'] > time()) {
179 179
 				$this->logger->info('This cache not yet expired return cache informations');
180 180
 				$info = array(
181 181
 					'mtime' => $data['mtime'],
@@ -192,26 +192,26 @@  discard block
 block discarded – undo
192 192
 		/**
193 193
 		 * Used to delete expired cache data
194 194
 		 */
195
-		public function deleteExpiredCache(){
195
+		public function deleteExpiredCache() {
196 196
 			$this->logger->debug('Deleting of expired cache files');
197 197
 			$list = glob(CACHE_PATH . '*.cache');
198
-			if(! $list){
198
+			if (!$list) {
199 199
 				$this->logger->info('No cache files were found skipping');
200 200
 			}
201
-			else{
201
+			else {
202 202
 				$this->logger->info('Found [' . count($list) . '] cache files to remove if expired');
203 203
 				foreach ($list as $file) {
204 204
 					$this->logger->debug('Processing the cache file [' . $file . ']');
205 205
 					$data = file_get_contents($file);
206 206
 		      		$data = @unserialize($this->compressCacheData ? gzinflate($data) : $data);
207
-		      		if(! $data){
207
+		      		if (!$data) {
208 208
 		      			$this->logger->warning('Can not unserialize the cache data for file [' . $file . ']');
209 209
 		      		}
210
-		      		else if(time() > $data['expire']){
210
+		      		else if (time() > $data['expire']) {
211 211
 		      			$this->logger->info('The cache data for file [' . $file . '] already expired remove it');
212 212
 		      			unlink($file);
213 213
 		      		}
214
-		      		else{
214
+		      		else {
215 215
 		      			$this->logger->info('The cache data for file [' . $file . '] not yet expired skip it');
216 216
 		      		}
217 217
 				}
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
 		/**
222 222
 		 * Remove all file from cache folder
223 223
 		 */
224
-		public function clean(){
224
+		public function clean() {
225 225
 			$this->logger->debug('Deleting of all cache files');
226 226
 			$list = glob(CACHE_PATH . '*.cache');
227
-			if(! $list){
227
+			if (!$list) {
228 228
 				$this->logger->info('No cache files were found skipping');
229 229
 			}
230
-			else{
230
+			else {
231 231
 				$this->logger->info('Found [' . count($list) . '] cache files to remove');
232 232
 				foreach ($list as $file) {
233 233
 					$this->logger->debug('Processing the cache file [' . $file . ']');
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	    /**
240 240
 	     * @return boolean
241 241
 	     */
242
-	    public function isCompressCacheData(){
242
+	    public function isCompressCacheData() {
243 243
 	        return $this->compressCacheData;
244 244
 	    }
245 245
 
@@ -248,14 +248,14 @@  discard block
 block discarded – undo
248 248
 	     *
249 249
 	     * @return object
250 250
 	     */
251
-	    public function setCompressCacheData($status = true){
251
+	    public function setCompressCacheData($status = true) {
252 252
 			//if Zlib extension is not loaded set compressCacheData to false
253
-			if($status === true && ! extension_loaded('zlib')){
253
+			if ($status === true && !extension_loaded('zlib')) {
254 254
 				
255 255
 				$this->logger->warning('The zlib extension is not loaded set cache compress data to FALSE');
256 256
 				$this->compressCacheData = false;
257 257
 			}
258
-			else{
258
+			else {
259 259
 				$this->compressCacheData = $status;
260 260
 			}
261 261
 			return $this;
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 		 *
267 267
 		 * @return bool
268 268
 		 */
269
-		public function isSupported(){
269
+		public function isSupported() {
270 270
 			return CACHE_PATH && is_dir(CACHE_PATH) && is_writable(CACHE_PATH);
271 271
 		}
272 272
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 		* @param string $key the cache item key
278 278
 		* @return string the full cache file path for this key
279 279
 		*/
280
-		private function getFilePath($key){
280
+		private function getFilePath($key) {
281 281
 			return CACHE_PATH . md5($key) . '.cache';
282 282
 		}
283 283
 	}
Please login to merge, or discard this patch.
core/classes/Controller.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26 26
 
27
-	class Controller extends BaseClass{
27
+	class Controller extends BaseClass {
28 28
 		
29 29
 		/**
30 30
 		 * The name of the module if this controller belong to an module
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 		/**
43 43
 		 * Class constructor
44 44
 		 */
45
-		public function __construct(){
45
+		public function __construct() {
46 46
 			parent::__construct();
47 47
 			
48 48
 			//instance of the super object
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 
51 51
 			//Load the resources loaded during the application bootstrap
52 52
 			$this->logger->debug('Adding the loaded classes to the super instance');
53
-			foreach (class_loaded() as $var => $class){
54
-				$this->$var =& class_loader($class);
53
+			foreach (class_loaded() as $var => $class) {
54
+				$this->$var = & class_loader($class);
55 55
 			}
56 56
 			
57 57
 			//set module using the router
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
 		/**
84 84
 		 * This method is used to set the module name
85 85
 		 */
86
-		protected function setModuleNameFromRouter(){
86
+		protected function setModuleNameFromRouter() {
87 87
 			//set the module using the router instance
88
-			if(isset($this->router) && $this->router->getModule()){
88
+			if (isset($this->router) && $this->router->getModule()) {
89 89
 				$this->moduleName = $this->router->getModule();
90 90
 			}
91 91
 		}
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 		 * Set the cache using the argument otherwise will use the configuration
95 95
 		 * @param CacheInterface $cache the implementation of CacheInterface if null will use the configured
96 96
 		 */
97
-		protected function setCacheFromParamOrConfig(CacheInterface $cache = null){
97
+		protected function setCacheFromParamOrConfig(CacheInterface $cache = null) {
98 98
 			$this->logger->debug('Setting the cache handler instance');
99 99
 			//set cache handler instance
100
-			if(get_config('cache_enable', false)){
101
-				if ($cache !== null){
100
+			if (get_config('cache_enable', false)) {
101
+				if ($cache !== null) {
102 102
 					$this->cache = $cache;
103
-				} else if (isset($this->{strtolower(get_config('cache_handler'))})){
103
+				} else if (isset($this->{strtolower(get_config('cache_handler'))})) {
104 104
 					$this->cache = $this->{strtolower(get_config('cache_handler'))};
105 105
 					unset($this->{strtolower(get_config('cache_handler'))});
106 106
 				} 
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
 		 * This method is used to load the required resources for framework to work
113 113
 		 * @return void 
114 114
 		 */
115
-		private function loadRequiredResources(){
115
+		private function loadRequiredResources() {
116 116
 			$this->logger->debug('Loading the required classes into super instance');
117
-			$this->eventdispatcher =& class_loader('EventDispatcher', 'classes');
118
-			$this->loader =& class_loader('Loader', 'classes');
119
-			$this->lang =& class_loader('Lang', 'classes');
120
-			$this->request =& class_loader('Request', 'classes');
117
+			$this->eventdispatcher = & class_loader('EventDispatcher', 'classes');
118
+			$this->loader = & class_loader('Loader', 'classes');
119
+			$this->lang = & class_loader('Lang', 'classes');
120
+			$this->request = & class_loader('Request', 'classes');
121 121
 			//dispatch the request instance created event
122 122
 			$this->eventdispatcher->dispatch('REQUEST_CREATED');
123
-			$this->response =& class_loader('Response', 'classes', 'classes');
123
+			$this->response = & class_loader('Response', 'classes', 'classes');
124 124
 		}
125 125
 
126 126
 	}
Please login to merge, or discard this patch.
core/classes/Security.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -24,13 +24,13 @@  discard block
 block discarded – undo
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26 26
 
27
-	class Security extends BaseStaticClass{
27
+	class Security extends BaseStaticClass {
28 28
 
29 29
 		/**
30 30
 		 * This method is used to generate the CSRF token
31 31
 		 * @return string the generated CSRF token
32 32
 		 */
33
-		public static function generateCSRF(){
33
+		public static function generateCSRF() {
34 34
 			$logger = self::getLogger();
35 35
 			$logger->debug('Generation of CSRF ...');
36 36
 			
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 			$expire = get_config('csrf_expire', 60);
39 39
 			$keyExpire = 'csrf_expire';
40 40
 			$currentTime = time();
41
-			if(Session::exists($key) && Session::exists($keyExpire) && Session::get($keyExpire) > $currentTime){
41
+			if (Session::exists($key) && Session::exists($keyExpire) && Session::get($keyExpire) > $currentTime) {
42 42
 				$logger->info('The CSRF token not yet expire just return it');
43 43
 				return Session::get($key);
44 44
 			}
45
-			else{
45
+			else {
46 46
 				$newTime = $currentTime + $expire;
47 47
 				$token = sha1(uniqid()) . sha1(uniqid());
48
-				$logger->info('The CSRF informations are listed below: key [' .$key. '], key expire [' .$keyExpire. '], expire time [' .$expire. '], token [' .$token. ']');
48
+				$logger->info('The CSRF informations are listed below: key [' . $key . '], key expire [' . $keyExpire . '], expire time [' . $expire . '], token [' . $token . ']');
49 49
 				Session::set($keyExpire, $newTime);
50 50
 				Session::set($key, $token);
51 51
 				return Session::get($key);
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		 * This method is used to check the CSRF if is valid, not yet expire, etc.
57 57
 		 * @return boolean true if valid, false if not valid
58 58
 		 */
59
-		public static function validateCSRF(){
59
+		public static function validateCSRF() {
60 60
 			$logger = self::getLogger();
61 61
 			$logger->debug('Validation of CSRF ...');
62 62
 				
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 			$expire = get_config('csrf_expire', 60);
65 65
 			$keyExpire = 'csrf_expire';
66 66
 			$currentTime = time();
67
-			$logger->info('The CSRF informations are listed below: key [' .$key. '], key expire [' .$keyExpire. '], expire time [' .$expire. ']');
68
-			if(! Session::exists($key) || Session::get($keyExpire) <= $currentTime){
67
+			$logger->info('The CSRF informations are listed below: key [' . $key . '], key expire [' . $keyExpire . '], expire time [' . $expire . ']');
68
+			if (!Session::exists($key) || Session::get($keyExpire) <= $currentTime) {
69 69
 				$logger->warning('The CSRF session data is not valide');
70 70
 				return false;
71 71
 			}
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
 			//super instance
75 75
 			$obj = & get_instance();
76 76
 			$token = $obj->request->query($key);
77
-			if(! $token || $token !== Session::get($key) || Session::get($keyExpire) <= $currentTime){
78
-				$logger->warning('The CSRF data [' .$token. '] is not valide may be attacker do his job');
77
+			if (!$token || $token !== Session::get($key) || Session::get($keyExpire) <= $currentTime) {
78
+				$logger->warning('The CSRF data [' . $token . '] is not valide may be attacker do his job');
79 79
 				return false;
80 80
 			}
81
-			$logger->info('The CSRF data [' .$token. '] is valide the form data is safe continue');
81
+			$logger->info('The CSRF data [' . $token . '] is valide the form data is safe continue');
82 82
 			//remove the token from session
83 83
 			Session::clear($key);
84 84
 			Session::clear($keyExpire);
@@ -88,24 +88,24 @@  discard block
 block discarded – undo
88 88
 		/**
89 89
 		 * This method is used to check the whitelist IP address access
90 90
 		 */
91
-		 public static function checkWhiteListIpAccess(){
91
+		 public static function checkWhiteListIpAccess() {
92 92
 			$logger = self::getLogger();
93 93
 			$logger->debug('Validation of the IP address access ...');
94 94
 			$logger->debug('Check if whitelist IP access is enabled in the configuration ...');
95 95
 			$isEnable = get_config('white_list_ip_enable', false);
96
-			if($isEnable){
96
+			if ($isEnable) {
97 97
 				$logger->info('Whitelist IP access is enabled in the configuration');
98 98
 				$list = get_config('white_list_ip_addresses', array());
99
-				if(! empty($list)){
99
+				if (!empty($list)) {
100 100
 					//Can't use Loader::functions() at this time because teh "Loader" library is loader after the security prossessing
101 101
 					require_once CORE_FUNCTIONS_PATH . 'function_user_agent.php';
102 102
 					$ip = get_ip();
103
-					if((count($list) == 1 && $list[0] == '*') || in_array($ip, $list)){
103
+					if ((count($list) == 1 && $list[0] == '*') || in_array($ip, $list)) {
104 104
 						$logger->info('IP address ' . $ip . ' allowed using the wildcard "*" or the full IP');
105 105
 						//wildcard to access all ip address
106 106
 						return;
107 107
 					}
108
-					else{
108
+					else {
109 109
 						// go through all whitelisted ips
110 110
 						foreach ($list as $ipaddr) {
111 111
 							// find the wild card * in whitelisted ip (f.e. find position in "127.0.*" or "127*")
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 					}
132 132
 				}
133 133
 			}
134
-			else{
134
+			else {
135 135
 				$logger->info('Whitelist IP access is not enabled in the configuration, ignore checking');
136 136
 			}
137 137
 		 }
Please login to merge, or discard this patch.
core/classes/BaseClass.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26 26
 
27
-	class BaseClass{
27
+	class BaseClass {
28 28
 		/**
29 29
 		 * The logger instance
30 30
 		 * @var object
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 		/**
35 35
 		 * Class constructor
36 36
 		 */
37
-		public function __construct(){
37
+		public function __construct() {
38 38
 			//Set Log instance to use
39 39
        		$this->setLoggerFromParamOrCreate(null);
40 40
 		}
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
 	     *
50 50
 	     * @return object this current instance
51 51
 	     */
52
-	    protected function setDependencyInstanceFromParamOrCreate($name, $instance = null, $loadClassName = null, $loadClassePath = 'classes'){
53
-	      if ($instance !== null){
52
+	    protected function setDependencyInstanceFromParamOrCreate($name, $instance = null, $loadClassName = null, $loadClassePath = 'classes') {
53
+	      if ($instance !== null) {
54 54
 	        $this->{$name} = $instance;
55 55
 	        return $this;
56 56
 	      }
57
-	      $this->{$name} =& class_loader($loadClassName, $loadClassePath);
57
+	      $this->{$name} = & class_loader($loadClassName, $loadClassePath);
58 58
 	      return $this;
59 59
 	    }
60 60
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	     * Return the Log instance
63 63
 	     * @return object
64 64
 	     */
65
-	    public function getLogger(){
65
+	    public function getLogger() {
66 66
 	      return $this->logger;
67 67
 	    }
68 68
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	     * @param object $logger the log object
72 72
 		 * @return object Database
73 73
 	     */
74
-	    public function setLogger($logger){
74
+	    public function setLogger($logger) {
75 75
 	      $this->logger = $logger;
76 76
 	      return $this;
77 77
 	    }
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
 	     *
83 83
 	     * @return object this current instance
84 84
 	     */
85
-	    protected function setLoggerFromParamOrCreate(Log $logger = null){
85
+	    protected function setLoggerFromParamOrCreate(Log $logger = null) {
86 86
 	      $this->setDependencyInstanceFromParamOrCreate('logger', $logger, 'Log', 'classes');
87
-	      if ($logger === null){
87
+	      if ($logger === null) {
88 88
 	        $this->logger->setLogger('Class::' . get_class($this));
89 89
 	      }
90 90
 	      return $this;
Please login to merge, or discard this patch.