Passed
Push — 1.0.0-dev ( 7e13dc...c7a39c )
by nguereza
06:11
created
core/classes/Session.php 1 patch
Spacing   +31 added lines, -31 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{
26
+	class Session {
27 27
 		
28 28
 		/**
29 29
 		 * The session flash key to use
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 		 * Get the logger singleton instance
42 42
 		 * @return Log the logger instance
43 43
 		 */
44
-		private static function getLogger(){
45
-			if(self::$logger == null){
46
-				self::$logger[0] =& class_loader('Log', 'classes');
44
+		private static function getLogger() {
45
+			if (self::$logger == null) {
46
+				self::$logger[0] = & class_loader('Log', 'classes');
47 47
 				self::$logger[0]->setLogger('Library::Session');
48 48
 			}
49 49
 			return self::$logger[0];
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
 		 * @param  mixed $default the default value to use if can not find the session item in the list
56 56
 		 * @return mixed          the session value if exist or the default value
57 57
 		 */
58
-		public static function get($item, $default = null){
58
+		public static function get($item, $default = null) {
59 59
 			$logger = self::getLogger();
60
-			$logger->debug('Getting session data for item [' .$item. '] ...');
61
-			if(array_key_exists($item, $_SESSION)){
60
+			$logger->debug('Getting session data for item [' . $item . '] ...');
61
+			if (array_key_exists($item, $_SESSION)) {
62 62
 				$logger->info('Found session data for item [' . $item . '] the vaue is : [' . stringfy_vars($_SESSION[$item]) . ']');
63 63
 				return $_SESSION[$item];
64 64
 			}
65
-			$logger->warning('Cannot find session item [' . $item . '] using the default value ['. $default . ']');
65
+			$logger->warning('Cannot find session item [' . $item . '] using the default value [' . $default . ']');
66 66
 			return $default;
67 67
 		}
68 68
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		 * @param string $item  the session item name to set
72 72
 		 * @param mixed $value the session item value
73 73
 		 */
74
-		public static function set($item, $value){
74
+		public static function set($item, $value) {
75 75
 			$logger = self::getLogger();
76 76
 			$logger->debug('Setting session data for item [' . $item . '], value [' . stringfy_vars($value) . ']');
77 77
 			$_SESSION[$item] = $value;
@@ -83,16 +83,16 @@  discard block
 block discarded – undo
83 83
 		 * @param  mixed $default the default value to use if can not find the session flash item in the list
84 84
 		 * @return mixed          the session flash value if exist or the default value
85 85
 		 */
86
-		public static function getFlash($item, $default = null){
86
+		public static function getFlash($item, $default = null) {
87 87
 			$logger = self::getLogger();
88
-			$key = self::SESSION_FLASH_KEY.'_'.$item;
88
+			$key = self::SESSION_FLASH_KEY . '_' . $item;
89 89
 			$return = array_key_exists($key, $_SESSION) ?
90 90
 			($_SESSION[$key]) : $default;
91
-			if(array_key_exists($key, $_SESSION)){
91
+			if (array_key_exists($key, $_SESSION)) {
92 92
 				unset($_SESSION[$key]);
93 93
 			}
94
-			else{
95
-				$logger->warning('Cannot find session flash item ['. $key .'] using the default value ['. $default .']');
94
+			else {
95
+				$logger->warning('Cannot find session flash item [' . $key . '] using the default value [' . $default . ']');
96 96
 			}
97 97
 			return $return;
98 98
 		}
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 		 * @param  string  $item the session flash item name
103 103
 		 * @return boolean 
104 104
 		 */
105
-		public static function hasFlash($item){
106
-			$key = self::SESSION_FLASH_KEY.'_'.$item;
105
+		public static function hasFlash($item) {
106
+			$key = self::SESSION_FLASH_KEY . '_' . $item;
107 107
 			return array_key_exists($key, $_SESSION);
108 108
 		}
109 109
 
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 		 * @param string $item  the session flash item name to set
113 113
 		 * @param mixed $value the session flash item value
114 114
 		 */
115
-		public static function setFlash($item, $value){
116
-			$key = self::SESSION_FLASH_KEY.'_'.$item;
115
+		public static function setFlash($item, $value) {
116
+			$key = self::SESSION_FLASH_KEY . '_' . $item;
117 117
 			$_SESSION[$key] = $value;
118 118
 		}
119 119
 
@@ -121,14 +121,14 @@  discard block
 block discarded – undo
121 121
 		 * Clear the session item in the list
122 122
 		 * @param  string $item the session item name to be deleted
123 123
 		 */
124
-		public static function clear($item){
124
+		public static function clear($item) {
125 125
 			$logger = self::getLogger();
126
-			if(array_key_exists($item, $_SESSION)){
127
-				$logger->info('Deleting of session for item ['.$item.' ]');
126
+			if (array_key_exists($item, $_SESSION)) {
127
+				$logger->info('Deleting of session for item [' . $item . ' ]');
128 128
 				unset($_SESSION[$item]);
129 129
 			}
130
-			else{
131
-				$logger->warning('Session item ['.$item.'] to be deleted does not exists');
130
+			else {
131
+				$logger->warning('Session item [' . $item . '] to be deleted does not exists');
132 132
 			}
133 133
 		}
134 134
 		
@@ -136,15 +136,15 @@  discard block
 block discarded – undo
136 136
 		 * Clear the session flash item in the list
137 137
 		 * @param  string $item the session flash item name to be deleted
138 138
 		 */
139
-		public static function clearFlash($item){
139
+		public static function clearFlash($item) {
140 140
 			$logger = self::getLogger();
141
-			$key = self::SESSION_FLASH_KEY.'_'.$item;
142
-			if(array_key_exists($key, $_SESSION)){
143
-				$logger->info('Delete session flash for item ['.$item.']');
141
+			$key = self::SESSION_FLASH_KEY . '_' . $item;
142
+			if (array_key_exists($key, $_SESSION)) {
143
+				$logger->info('Delete session flash for item [' . $item . ']');
144 144
 				unset($_SESSION[$item]);
145 145
 			}
146
-			else{
147
-				$logger->warning('Dession flash item ['.$item.'] to be deleted does not exists');
146
+			else {
147
+				$logger->warning('Dession flash item [' . $item . '] to be deleted does not exists');
148 148
 			}
149 149
 		}
150 150
 
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
 		 * @param  string  $item the session item name
154 154
 		 * @return boolean 
155 155
 		 */
156
-		public static function exists($item){
156
+		public static function exists($item) {
157 157
 			return array_key_exists($item, $_SESSION);
158 158
 		}
159 159
 
160 160
 		/**
161 161
 		 * Destroy all session data values
162 162
 		 */
163
-		public static function clearAll(){
163
+		public static function clearAll() {
164 164
 			session_unset();
165 165
 			session_destroy();
166 166
 		}
Please login to merge, or discard this patch.
core/classes/Module.php 2 patches
Spacing   +83 added lines, -83 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 Module{
27
+	class Module {
28 28
 		
29 29
 		/**
30 30
 		 * list of loaded module
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 		 * The signleton of the logger
43 43
 		 * @return Object the Log instance
44 44
 		 */
45
-		private static function getLogger(){
46
-			if(self::$logger == null){
47
-				self::$logger[0] =& class_loader('Log', 'classes');
45
+		private static function getLogger() {
46
+			if (self::$logger == null) {
47
+				self::$logger[0] = & class_loader('Log', 'classes');
48 48
 				self::$logger[0]->setLogger('Library::Module');
49 49
 			}
50 50
 			return self::$logger[0];
@@ -53,25 +53,25 @@  discard block
 block discarded – undo
53 53
 		/**
54 54
 		 * Initialise the module list by scanning the directory MODULE_PATH
55 55
 		 */
56
-		public function init(){
56
+		public function init() {
57 57
 			$logger = self::getLogger();
58 58
 			$logger->debug('Check if the application contains the modules ...');
59 59
 			$moduleDir = opendir(MODULE_PATH);
60
-			while(($module = readdir($moduleDir)) !== false){
61
-				if($module != '.' && $module != '..'  && preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)){
60
+			while (($module = readdir($moduleDir)) !== false) {
61
+				if ($module != '.' && $module != '..' && preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)) {
62 62
 					self::$list[] = $module;
63 63
 				}
64
-				else{
65
-					$logger->info('Skipping [' .$module. '], may be this is not a directory or does not exists or is invalid name');
64
+				else {
65
+					$logger->info('Skipping [' . $module . '], may be this is not a directory or does not exists or is invalid name');
66 66
 				}
67 67
 			}
68 68
 			closedir($moduleDir);
69 69
 			ksort(self::$list);
70 70
 			
71
-			if(self::hasModule()){
71
+			if (self::hasModule()) {
72 72
 				$logger->info('The application contains the module below [' . implode(', ', self::getModuleList()) . ']');
73 73
 			}
74
-			else{
74
+			else {
75 75
 				$logger->info('The application contains no module skipping');
76 76
 			}
77 77
 		}
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 		 * Get the list of the custom autoload configuration from module if exists
81 81
 		 * @return array|boolean the autoload configurations list or false if no module contains the autoload configuration values
82 82
 		 */
83
-		public static function getModulesAutoloadConfig(){
83
+		public static function getModulesAutoloadConfig() {
84 84
 			$logger = self::getLogger();
85
-			if(! self::hasModule()){
85
+			if (!self::hasModule()) {
86 86
 				$logger->info('No module was loaded skipping.');
87 87
 				return false;
88 88
 			}
@@ -95,27 +95,27 @@  discard block
 block discarded – undo
95 95
 			
96 96
 			foreach (self::$list as $module) {
97 97
 				$file = MODULE_PATH . $module . DS . 'config' . DS . 'autoload.php';
98
-				if(file_exists($file)){
98
+				if (file_exists($file)) {
99 99
 					require_once $file;
100
-					if(! empty($autoload) && is_array($autoload)){
100
+					if (!empty($autoload) && is_array($autoload)) {
101 101
 						//libraries autoload
102
-						if(! empty($autoload['libraries']) && is_array($autoload['libraries'])){
102
+						if (!empty($autoload['libraries']) && is_array($autoload['libraries'])) {
103 103
 							$autoloads['libraries'] = array_merge($autoloads['libraries'], $autoload['libraries']);
104 104
 						}
105 105
 						//config autoload
106
-						if(! empty($autoload['config']) && is_array($autoload['config'])){
106
+						if (!empty($autoload['config']) && is_array($autoload['config'])) {
107 107
 							$autoloads['config'] = array_merge($autoloads['config'], $autoload['config']);
108 108
 						}
109 109
 						//models autoload
110
-						if(! empty($autoload['models']) && is_array($autoload['models'])){
110
+						if (!empty($autoload['models']) && is_array($autoload['models'])) {
111 111
 							$autoloads['models'] = array_merge($autoloads['models'], $autoload['models']);
112 112
 						}
113 113
 						//functions autoload
114
-						if(! empty($autoload['functions']) && is_array($autoload['functions'])){
114
+						if (!empty($autoload['functions']) && is_array($autoload['functions'])) {
115 115
 							$autoloads['functions'] = array_merge($autoloads['functions'], $autoload['functions']);
116 116
 						}
117 117
 						//languages autoload
118
-						if(! empty($autoload['languages']) && is_array($autoload['languages'])){
118
+						if (!empty($autoload['languages']) && is_array($autoload['languages'])) {
119 119
 							$autoloads['languages'] = array_merge($autoloads['languages'], $autoload['languages']);
120 120
 						}
121 121
 						unset($autoload);
@@ -129,23 +129,23 @@  discard block
 block discarded – undo
129 129
 		 * Get the list of the custom routes configuration from module if exists
130 130
 		 * @return array|boolean the routes list or false if no module contains the routes configuration
131 131
 		 */
132
-		public static function getModulesRoutes(){
132
+		public static function getModulesRoutes() {
133 133
 			$logger = self::getLogger();
134
-			if(! self::hasModule()){
134
+			if (!self::hasModule()) {
135 135
 				$logger->info('No module was loaded skipping.');
136 136
 				return false;
137 137
 			}
138 138
 			$routes = array();
139 139
 			foreach (self::$list as $module) {
140 140
 				$file = MODULE_PATH . $module . DS . 'config' . DS . 'routes.php';
141
-				if(file_exists($file)){
141
+				if (file_exists($file)) {
142 142
 					require_once $file;
143
-					if(! empty($route) && is_array($route)){
143
+					if (!empty($route) && is_array($route)) {
144 144
 						$routes = array_merge($routes, $route);
145 145
 						unset($route);
146 146
 					}
147
-					else{
148
-						show_error('No routing configuration found in [' .$file. '] for module [' . $module . ']');
147
+					else {
148
+						show_error('No routing configuration found in [' . $file . '] for module [' . $module . ']');
149 149
 					}
150 150
 				}
151 151
 			}
@@ -159,23 +159,23 @@  discard block
 block discarded – undo
159 159
 		 * @param  string $module  the module name
160 160
 		 * @return boolean|string  false or null if no module have this controller, path the full path of the controller
161 161
 		 */
162
-		public static function findControllerFullPath($class, $module = null){
162
+		public static function findControllerFullPath($class, $module = null) {
163 163
 			$logger = self::getLogger();
164
-			if(! self::hasModule()){
164
+			if (!self::hasModule()) {
165 165
 				$logger->info('No module was loaded skiping.');
166 166
 				return false;
167 167
 			}
168 168
 			$class = str_ireplace('.php', '', $class);
169 169
 			$class = ucfirst($class);
170
-			$classFile = $class.'.php';
171
-			$logger->debug('Checking the controller [' . $class . '] in module [' .$module. '] ...');
170
+			$classFile = $class . '.php';
171
+			$logger->debug('Checking the controller [' . $class . '] in module [' . $module . '] ...');
172 172
 			$filePath = MODULE_PATH . $module . DS . 'controllers' . DS . $classFile;
173
-			if(file_exists($filePath)){
174
-				$logger->info('Found controller [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
173
+			if (file_exists($filePath)) {
174
+				$logger->info('Found controller [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']');
175 175
 				return $filePath;
176 176
 			}
177
-			else{
178
-				$logger->info('Controller [' . $class . '] does not exist in the module [' .$module. ']');
177
+			else {
178
+				$logger->info('Controller [' . $class . '] does not exist in the module [' . $module . ']');
179 179
 				return false;
180 180
 			}
181 181
 		}
@@ -186,23 +186,23 @@  discard block
 block discarded – undo
186 186
 		 * @param string $module the module name
187 187
 		 * @return boolean|string  false or null if no module have this model, return the full path of this model
188 188
 		 */
189
-		public static function findModelFullPath($class, $module = null){
189
+		public static function findModelFullPath($class, $module = null) {
190 190
 			$logger = self::getLogger();
191
-			if(! self::hasModule()){
191
+			if (!self::hasModule()) {
192 192
 				$logger->info('No module was loaded skiping.');
193 193
 				return false;
194 194
 			}
195 195
 			$class = str_ireplace('.php', '', $class);
196 196
 			$class = ucfirst($class);
197
-			$classFile = $class.'.php';
198
-			$logger->debug('Checking model [' . $class . '] in module [' .$module. '] ...');
197
+			$classFile = $class . '.php';
198
+			$logger->debug('Checking model [' . $class . '] in module [' . $module . '] ...');
199 199
 			$filePath = MODULE_PATH . $module . DS . 'models' . DS . $classFile;
200
-			if(file_exists($filePath)){
201
-				$logger->info('Found model [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
200
+			if (file_exists($filePath)) {
201
+				$logger->info('Found model [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']');
202 202
 				return $filePath;
203 203
 			}
204
-			else{
205
-				$logger->info('Model [' . $class . '] does not exist in the module [' .$module. ']');
204
+			else {
205
+				$logger->info('Model [' . $class . '] does not exist in the module [' . $module . ']');
206 206
 				return false;
207 207
 			}
208 208
 		}
@@ -213,22 +213,22 @@  discard block
 block discarded – undo
213 213
 		 * @param string $module the module name
214 214
 		 * @return boolean|string  false or null if no module have this configuration,  return the full path of this configuration
215 215
 		 */
216
-		public static function findConfigFullPath($configuration, $module = null){
216
+		public static function findConfigFullPath($configuration, $module = null) {
217 217
 			$logger = self::getLogger();
218
-			if(! self::hasModule()){
218
+			if (!self::hasModule()) {
219 219
 				$logger->info('No module was loaded skiping.');
220 220
 				return false;
221 221
 			}
222 222
 			$configuration = str_ireplace('.php', '', $configuration);
223
-			$file = $configuration.'.php';
224
-			$logger->debug('Checking configuration [' . $configuration . '] in module [' .$module. '] ...');
223
+			$file = $configuration . '.php';
224
+			$logger->debug('Checking configuration [' . $configuration . '] in module [' . $module . '] ...');
225 225
 			$filePath = MODULE_PATH . $module . DS . 'config' . DS . $file;
226
-			if(file_exists($filePath)){
227
-				$logger->info('Found configuration [' . $configuration . '] in module [' .$module. '], the file path is [' .$filePath. ']');
226
+			if (file_exists($filePath)) {
227
+				$logger->info('Found configuration [' . $configuration . '] in module [' . $module . '], the file path is [' . $filePath . ']');
228 228
 				return $filePath;
229 229
 			}
230
-			else{
231
-				$logger->info('Configuration [' . $configuration . '] does not exist in the module [' .$module. ']');
230
+			else {
231
+				$logger->info('Configuration [' . $configuration . '] does not exist in the module [' . $module . ']');
232 232
 				return false;
233 233
 			}
234 234
 		}
@@ -239,23 +239,23 @@  discard block
 block discarded – undo
239 239
 		 * @param string $module the module name
240 240
 		 * @return boolean|string  false or null if no module have this helper,  return the full path of this helper
241 241
 		 */
242
-		public static function findFunctionFullPath($helper, $module = null){
242
+		public static function findFunctionFullPath($helper, $module = null) {
243 243
 			$logger = self::getLogger();
244
-			if(! self::hasModule()){
244
+			if (!self::hasModule()) {
245 245
 				$logger->info('No module was loaded skiping.');
246 246
 				return false;
247 247
 			}
248 248
 			$helper = str_ireplace('.php', '', $helper);
249 249
 			$helper = str_ireplace('function_', '', $helper);
250
-			$file = 'function_'.$helper.'.php';
251
-			$logger->debug('Checking helper [' . $helper . '] in module [' .$module. '] ...');
250
+			$file = 'function_' . $helper . '.php';
251
+			$logger->debug('Checking helper [' . $helper . '] in module [' . $module . '] ...');
252 252
 			$filePath = MODULE_PATH . $module . DS . 'functions' . DS . $file;
253
-			if(file_exists($filePath)){
254
-				$logger->info('Found helper [' . $helper . '] in module [' .$module. '], the file path is [' .$filePath. ']');
253
+			if (file_exists($filePath)) {
254
+				$logger->info('Found helper [' . $helper . '] in module [' . $module . '], the file path is [' . $filePath . ']');
255 255
 				return $filePath;
256 256
 			}
257
-			else{
258
-				$logger->info('Helper [' . $helper . '] does not exist in the module [' .$module. ']');
257
+			else {
258
+				$logger->info('Helper [' . $helper . '] does not exist in the module [' . $module . ']');
259 259
 				return false;
260 260
 			}
261 261
 		}
@@ -267,22 +267,22 @@  discard block
 block discarded – undo
267 267
 		 * @param string $module the module name
268 268
 		 * @return boolean|string  false or null if no module have this library,  return the full path of this library
269 269
 		 */
270
-		public static function findLibraryFullPath($class, $module = null){
270
+		public static function findLibraryFullPath($class, $module = null) {
271 271
 			$logger = self::getLogger();
272
-			if(! self::hasModule()){
272
+			if (!self::hasModule()) {
273 273
 				$logger->info('No module was loaded skiping.');
274 274
 				return false;
275 275
 			}
276 276
 			$class = str_ireplace('.php', '', $class);
277
-			$file = $class.'.php';
278
-			$logger->debug('Checking library [' . $class . '] in module [' .$module. '] ...');
277
+			$file = $class . '.php';
278
+			$logger->debug('Checking library [' . $class . '] in module [' . $module . '] ...');
279 279
 			$filePath = MODULE_PATH . $module . DS . 'libraries' . DS . $file;
280
-			if(file_exists($filePath)){
281
-				$logger->info('Found library [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
280
+			if (file_exists($filePath)) {
281
+				$logger->info('Found library [' . $class . '] in module [' . $module . '], the file path is [' . $filePath . ']');
282 282
 				return $filePath;
283 283
 			}
284
-			else{
285
-				$logger->info('Library [' . $class . '] does not exist in the module [' .$module. ']');
284
+			else {
285
+				$logger->info('Library [' . $class . '] does not exist in the module [' . $module . ']');
286 286
 				return false;
287 287
 			}
288 288
 		}
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
 		 * @param string $module the module name to check
295 295
 		 * @return boolean|string  false or null if no module have this view, path the full path of the view
296 296
 		 */
297
-		public static function findViewFullPath($view, $module = null){
297
+		public static function findViewFullPath($view, $module = null) {
298 298
 			$logger = self::getLogger();
299
-			if(! self::hasModule()){
299
+			if (!self::hasModule()) {
300 300
 				$logger->info('No module was loaded skiping.');
301 301
 				return false;
302 302
 			}
@@ -304,14 +304,14 @@  discard block
 block discarded – undo
304 304
 			$view = trim($view, '/\\');
305 305
 			$view = str_ireplace('/', DS, $view);
306 306
 			$viewFile = $view . '.php';
307
-			$logger->debug('Checking view [' . $view . '] in module [' .$module. '] ...');
307
+			$logger->debug('Checking view [' . $view . '] in module [' . $module . '] ...');
308 308
 			$filePath = MODULE_PATH . $module . DS . 'views' . DS . $viewFile;
309
-			if(file_exists($filePath)){
310
-				$logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$filePath. ']');
309
+			if (file_exists($filePath)) {
310
+				$logger->info('Found view [' . $view . '] in module [' . $module . '], the file path is [' . $filePath . ']');
311 311
 				return $filePath;
312 312
 			}
313
-			else{
314
-				$logger->info('View [' . $view . '] does not exist in the module [' .$module. ']');
313
+			else {
314
+				$logger->info('View [' . $view . '] does not exist in the module [' . $module . ']');
315 315
 				return false;
316 316
 			}
317 317
 		}
@@ -323,23 +323,23 @@  discard block
 block discarded – undo
323 323
 		 * @param string $appLang the application language like 'en', 'fr'
324 324
 		 * @return boolean|string  false or null if no module have this language,  return the full path of this language
325 325
 		 */
326
-		public static function findLanguageFullPath($language, $module = null, $appLang){
326
+		public static function findLanguageFullPath($language, $module = null, $appLang) {
327 327
 			$logger = self::getLogger();
328
-			if(! self::hasModule()){
328
+			if (!self::hasModule()) {
329 329
 				$logger->info('No module was loaded skiping.');
330 330
 				return false;
331 331
 			}
332 332
 			$language = str_ireplace('.php', '', $language);
333 333
 			$language = str_ireplace('lang_', '', $language);
334
-			$file = 'lang_'.$language.'.php';
335
-			$logger->debug('Checking language [' . $language . '] in module [' .$module. '] ...');
334
+			$file = 'lang_' . $language . '.php';
335
+			$logger->debug('Checking language [' . $language . '] in module [' . $module . '] ...');
336 336
 			$filePath = MODULE_PATH . $module . DS . 'lang' . DS . $appLang . DS . $file;
337
-			if(file_exists($filePath)){
338
-				$logger->info('Found language [' . $language . '] in module [' .$module. '], the file path is [' .$filePath. ']');
337
+			if (file_exists($filePath)) {
338
+				$logger->info('Found language [' . $language . '] in module [' . $module . '], the file path is [' . $filePath . ']');
339 339
 				return $filePath;
340 340
 			}
341
-			else{
342
-				$logger->info('Language [' . $language . '] does not exist in the module [' .$module. ']');
341
+			else {
342
+				$logger->info('Language [' . $language . '] does not exist in the module [' . $module . ']');
343 343
 				return false;
344 344
 			}
345 345
 		}
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 		 * Get the list of module loaded
349 349
 		 * @return array the module list
350 350
 		 */
351
-		public static function getModuleList(){
351
+		public static function getModuleList() {
352 352
 			return self::$list;
353 353
 		}
354 354
 
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 		 * Check if the application has an module
357 357
 		 * @return boolean
358 358
 		 */
359
-		public static function hasModule(){
359
+		public static function hasModule() {
360 360
 			return !empty(self::$list);
361 361
 		}
362 362
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -20 removed lines patch added patch discarded remove patch
@@ -60,8 +60,7 @@  discard block
 block discarded – undo
60 60
 			while(($module = readdir($moduleDir)) !== false){
61 61
 				if($module != '.' && $module != '..'  && preg_match('/^([a-z0-9-_]+)$/i', $module) && is_dir(MODULE_PATH . $module)){
62 62
 					self::$list[] = $module;
63
-				}
64
-				else{
63
+				} else{
65 64
 					$logger->info('Skipping [' .$module. '], may be this is not a directory or does not exists or is invalid name');
66 65
 				}
67 66
 			}
@@ -70,8 +69,7 @@  discard block
 block discarded – undo
70 69
 			
71 70
 			if(self::hasModule()){
72 71
 				$logger->info('The application contains the module below [' . implode(', ', self::getModuleList()) . ']');
73
-			}
74
-			else{
72
+			} else{
75 73
 				$logger->info('The application contains no module skipping');
76 74
 			}
77 75
 		}
@@ -143,8 +141,7 @@  discard block
 block discarded – undo
143 141
 					if(! empty($route) && is_array($route)){
144 142
 						$routes = array_merge($routes, $route);
145 143
 						unset($route);
146
-					}
147
-					else{
144
+					} else{
148 145
 						show_error('No routing configuration found in [' .$file. '] for module [' . $module . ']');
149 146
 					}
150 147
 				}
@@ -173,8 +170,7 @@  discard block
 block discarded – undo
173 170
 			if(file_exists($filePath)){
174 171
 				$logger->info('Found controller [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
175 172
 				return $filePath;
176
-			}
177
-			else{
173
+			} else{
178 174
 				$logger->info('Controller [' . $class . '] does not exist in the module [' .$module. ']');
179 175
 				return false;
180 176
 			}
@@ -200,8 +196,7 @@  discard block
 block discarded – undo
200 196
 			if(file_exists($filePath)){
201 197
 				$logger->info('Found model [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
202 198
 				return $filePath;
203
-			}
204
-			else{
199
+			} else{
205 200
 				$logger->info('Model [' . $class . '] does not exist in the module [' .$module. ']');
206 201
 				return false;
207 202
 			}
@@ -226,8 +221,7 @@  discard block
 block discarded – undo
226 221
 			if(file_exists($filePath)){
227 222
 				$logger->info('Found configuration [' . $configuration . '] in module [' .$module. '], the file path is [' .$filePath. ']');
228 223
 				return $filePath;
229
-			}
230
-			else{
224
+			} else{
231 225
 				$logger->info('Configuration [' . $configuration . '] does not exist in the module [' .$module. ']');
232 226
 				return false;
233 227
 			}
@@ -253,8 +247,7 @@  discard block
 block discarded – undo
253 247
 			if(file_exists($filePath)){
254 248
 				$logger->info('Found helper [' . $helper . '] in module [' .$module. '], the file path is [' .$filePath. ']');
255 249
 				return $filePath;
256
-			}
257
-			else{
250
+			} else{
258 251
 				$logger->info('Helper [' . $helper . '] does not exist in the module [' .$module. ']');
259 252
 				return false;
260 253
 			}
@@ -280,8 +273,7 @@  discard block
 block discarded – undo
280 273
 			if(file_exists($filePath)){
281 274
 				$logger->info('Found library [' . $class . '] in module [' .$module. '], the file path is [' .$filePath. ']');
282 275
 				return $filePath;
283
-			}
284
-			else{
276
+			} else{
285 277
 				$logger->info('Library [' . $class . '] does not exist in the module [' .$module. ']');
286 278
 				return false;
287 279
 			}
@@ -309,8 +301,7 @@  discard block
 block discarded – undo
309 301
 			if(file_exists($filePath)){
310 302
 				$logger->info('Found view [' . $view . '] in module [' .$module. '], the file path is [' .$filePath. ']');
311 303
 				return $filePath;
312
-			}
313
-			else{
304
+			} else{
314 305
 				$logger->info('View [' . $view . '] does not exist in the module [' .$module. ']');
315 306
 				return false;
316 307
 			}
@@ -337,8 +328,7 @@  discard block
 block discarded – undo
337 328
 			if(file_exists($filePath)){
338 329
 				$logger->info('Found language [' . $language . '] in module [' .$module. '], the file path is [' .$filePath. ']');
339 330
 				return $filePath;
340
-			}
341
-			else{
331
+			} else{
342 332
 				$logger->info('Language [' . $language . '] does not exist in the module [' .$module. ']');
343 333
 				return false;
344 334
 			}
Please login to merge, or discard this patch.
core/classes/Request.php 1 patch
Spacing   +27 added lines, -27 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 Request{
27
+	class Request {
28 28
 		
29 29
 		/**
30 30
 		 * The value for the super global $_GET
@@ -90,21 +90,21 @@  discard block
 block discarded – undo
90 90
 		/**
91 91
 		 * Construct new request instance
92 92
 		 */
93
-		public function __construct(){
93
+		public function __construct() {
94 94
 			$this->get = $_GET;
95 95
 			$this->post = $_POST;
96 96
 			$this->server = $_SERVER;
97 97
 			$this->query = $_REQUEST;
98 98
 			$this->cookie = $_COOKIE;
99 99
 			$this->file = $_FILES;
100
-			$this->session =& class_loader('Session', 'classes');
100
+			$this->session = & class_loader('Session', 'classes');
101 101
 			$this->method = $this->server('REQUEST_METHOD');
102 102
 			$this->requestUri = $this->server('REQUEST_URI');
103 103
 			$this->header = array();
104
-			if(function_exists('apache_request_headers')){
104
+			if (function_exists('apache_request_headers')) {
105 105
 				$this->header = apache_request_headers();
106 106
 			}
107
-			else if(function_exists('getallheaders')){
107
+			else if (function_exists('getallheaders')) {
108 108
 				$this->header = getallheaders();
109 109
 			}
110 110
 		}
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		 * Get the request method
114 114
 		 * @return string
115 115
 		 */
116
-		public function method(){
116
+		public function method() {
117 117
 			return $this->method;
118 118
 		}
119 119
 		
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 		 * Get the request URI
122 122
 		 * @return string
123 123
 		 */
124
-		public function requestUri(){
124
+		public function requestUri() {
125 125
 			return $this->requestUri;
126 126
 		}
127 127
 
@@ -131,13 +131,13 @@  discard block
 block discarded – undo
131 131
 		 * @param  boolean $xss if need apply some XSS attack rule on the value
132 132
 		 * @return array|mixed       the item value if the key exists or all array if the key does not exists or is empty
133 133
 		 */
134
-		public function query($key = null, $xss = true){
135
-			if(empty($key)){
134
+		public function query($key = null, $xss = true) {
135
+			if (empty($key)) {
136 136
 				//return all
137 137
 				return $xss ? clean_input($this->query) : $this->query;
138 138
 			}
139 139
 			$query = array_key_exists($key, $this->query) ? $this->query[$key] : null;
140
-			if($xss){
140
+			if ($xss) {
141 141
 				$query = clean_input($query);
142 142
 			}
143 143
 			return $query;
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
 		 * @param  boolean $xss if need apply some XSS attack rule on the value
150 150
 		 * @return array|mixed       the item value if the key exists or all array if the key does not exists or is empty
151 151
 		 */
152
-		public function get($key = null, $xss = true){
153
-			if(empty($key)){
152
+		public function get($key = null, $xss = true) {
153
+			if (empty($key)) {
154 154
 				//return all
155 155
 				return $xss ? clean_input($this->get) : $this->get;
156 156
 			}
157 157
 			$get = array_key_exists($key, $this->get) ? $this->get[$key] : null;
158
-			if($xss){
158
+			if ($xss) {
159 159
 				$get = clean_input($get);
160 160
 			}
161 161
 			return $get;
@@ -167,13 +167,13 @@  discard block
 block discarded – undo
167 167
 		 * @param  boolean $xss if need apply some XSS attack rule on the value
168 168
 		 * @return array|mixed       the item value if the key exists or all array if the key does not exists or is empty
169 169
 		 */
170
-		public function post($key = null, $xss = true){
171
-			if(empty($key)){
170
+		public function post($key = null, $xss = true) {
171
+			if (empty($key)) {
172 172
 				//return all
173 173
 				return $xss ? clean_input($this->post) : $this->post;
174 174
 			}
175 175
 			$post = array_key_exists($key, $this->post) ? $this->post[$key] : null;
176
-			if($xss){
176
+			if ($xss) {
177 177
 				$post = clean_input($post);
178 178
 			}
179 179
 			return $post;
@@ -185,13 +185,13 @@  discard block
 block discarded – undo
185 185
 		 * @param  boolean $xss if need apply some XSS attack rule on the value
186 186
 		 * @return array|mixed       the item value if the key exists or all array if the key does not exists or is empty
187 187
 		 */
188
-		public function server($key = null, $xss = true){
189
-			if(empty($key)){
188
+		public function server($key = null, $xss = true) {
189
+			if (empty($key)) {
190 190
 				//return all
191 191
 				return $xss ? clean_input($this->server) : $this->server;
192 192
 			}
193 193
 			$server = array_key_exists($key, $this->server) ? $this->server[$key] : null;
194
-			if($xss){
194
+			if ($xss) {
195 195
 				$server = clean_input($server);
196 196
 			}
197 197
 			return $server;
@@ -203,13 +203,13 @@  discard block
 block discarded – undo
203 203
 		 * @param  boolean $xss if need apply some XSS attack rule on the value
204 204
 		 * @return array|mixed       the item value if the key exists or all array if the key does not exists or is empty
205 205
 		 */
206
-		public function cookie($key = null, $xss = true){
207
-			if(empty($key)){
206
+		public function cookie($key = null, $xss = true) {
207
+			if (empty($key)) {
208 208
 				//return all
209 209
 				return $xss ? clean_input($this->cookie) : $this->cookie;
210 210
 			}
211 211
 			$cookie = array_key_exists($key, $this->cookie) ? $this->cookie[$key] : null;
212
-			if($xss){
212
+			if ($xss) {
213 213
 				$cookie = clean_input($cookie);
214 214
 			}
215 215
 			return $cookie;
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		 * @param  string  $key the item key to be fetched
221 221
 		 * @return array|mixed       the item value if the key exists or all array if the key does not exists or is empty
222 222
 		 */
223
-		public function file($key){
223
+		public function file($key) {
224 224
 			$file = array_key_exists($key, $this->file) ? $this->file[$key] : null;
225 225
 			return $file;
226 226
 		}
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
 		 * @param  boolean $xss if need apply some XSS attack rule on the value
232 232
 		 * @return array|mixed       the item value if the key exists or null if the key does not exists
233 233
 		 */
234
-		public function session($key, $xss = true){
234
+		public function session($key, $xss = true) {
235 235
 			$session = $this->session->get($key);
236
-			if($xss){
236
+			if ($xss) {
237 237
 				$session = clean_input($session);
238 238
 			}
239 239
 			return $session;
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
 		 * @param  boolean $xss if need apply some XSS attack rule on the value
246 246
 		 * @return mixed       the item value if the key exists or null if the key does not exists
247 247
 		 */
248
-		public function header($key, $xss = true){
248
+		public function header($key, $xss = true) {
249 249
 			$header = array_key_exists($key, $this->header) ? $this->header[$key] : null;
250
-			if($xss){
250
+			if ($xss) {
251 251
 				$header = clean_input($header);
252 252
 			}
253 253
 			return $header;
Please login to merge, or discard this patch.
core/classes/Security.php 1 patch
Spacing   +22 added lines, -22 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 Security{
27
+	class Security {
28 28
 		
29 29
 		/**
30 30
 		 * The logger instance
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 		 * Get the logger singleton instance
37 37
 		 * @return Log the logger instance
38 38
 		 */
39
-		private static function getLogger(){
40
-			if(self::$logger == null){
41
-				self::$logger[0] =& class_loader('Log', 'classes');
39
+		private static function getLogger() {
40
+			if (self::$logger == null) {
41
+				self::$logger[0] = & class_loader('Log', 'classes');
42 42
 				self::$logger[0]->setLogger('Library::Security');
43 43
 			}
44 44
 			return self::$logger[0];
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 		 * This method is used to generate the CSRF token
50 50
 		 * @return string the generated CSRF token
51 51
 		 */
52
-		public static function generateCSRF(){
52
+		public static function generateCSRF() {
53 53
 			$logger = self::getLogger();
54 54
 			$logger->debug('Generation of CSRF ...');
55 55
 			
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
 			$expire = get_config('csrf_expire', 60);
58 58
 			$keyExpire = 'csrf_expire';
59 59
 			$currentTime = time();
60
-			if(Session::exists($key) && Session::exists($keyExpire) && Session::get($keyExpire) > $currentTime){
60
+			if (Session::exists($key) && Session::exists($keyExpire) && Session::get($keyExpire) > $currentTime) {
61 61
 				$logger->info('The CSRF token not yet expire just return it');
62 62
 				return Session::get($key);
63 63
 			}
64
-			else{
64
+			else {
65 65
 				$newTime = $currentTime + $expire;
66 66
 				$token = sha1(uniqid()) . sha1(uniqid());
67
-				$logger->info('The CSRF informations are listed below: key [' .$key. '], key expire [' .$keyExpire. '], expire time [' .$expire. '], token [' .$token. ']');
67
+				$logger->info('The CSRF informations are listed below: key [' . $key . '], key expire [' . $keyExpire . '], expire time [' . $expire . '], token [' . $token . ']');
68 68
 				Session::set($keyExpire, $newTime);
69 69
 				Session::set($key, $token);
70 70
 				return Session::get($key);
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 		 * This method is used to check the CSRF if is valid, not yet expire, etc.
76 76
 		 * @return boolean true if valid, false if not valid
77 77
 		 */
78
-		public static function validateCSRF(){
78
+		public static function validateCSRF() {
79 79
 			$logger = self::getLogger();
80 80
 			$logger->debug('Validation of CSRF ...');
81 81
 				
@@ -83,23 +83,23 @@  discard block
 block discarded – undo
83 83
 			$expire = get_config('csrf_expire', 60);
84 84
 			$keyExpire = 'csrf_expire';
85 85
 			$currentTime = time();
86
-			$logger->info('The CSRF informations are listed below: key [' .$key. '], key expire [' .$keyExpire. '], expire time [' .$expire. ']');
87
-			if(! Session::exists($key) || Session::get($keyExpire) <= $currentTime){
86
+			$logger->info('The CSRF informations are listed below: key [' . $key . '], key expire [' . $keyExpire . '], expire time [' . $expire . ']');
87
+			if (!Session::exists($key) || Session::get($keyExpire) <= $currentTime) {
88 88
 				$logger->warning('The CSRF session data is not valide');
89 89
 				return false;
90 90
 			}
91
-			else{
91
+			else {
92 92
 				//perform form data
93 93
 				//need use request->query() for best retrieve
94 94
 				//super instance
95 95
 				$obj = & get_instance();
96 96
 				$token = $obj->request->query($key);
97
-				if(! $token || $token !== Session::get($key) || Session::get($keyExpire) <= $currentTime){
98
-					$logger->warning('The CSRF data [' .$token. '] is not valide may be attacker do his job');
97
+				if (!$token || $token !== Session::get($key) || Session::get($keyExpire) <= $currentTime) {
98
+					$logger->warning('The CSRF data [' . $token . '] is not valide may be attacker do his job');
99 99
 					return false;
100 100
 				}
101
-				else{
102
-					$logger->info('The CSRF data [' .$token. '] is valide the form data is safe continue');
101
+				else {
102
+					$logger->info('The CSRF data [' . $token . '] is valide the form data is safe continue');
103 103
 					//remove the token from session
104 104
 					Session::clear($key);
105 105
 					Session::clear($keyExpire);
@@ -111,24 +111,24 @@  discard block
 block discarded – undo
111 111
 		/**
112 112
 		 * This method is used to check the whitelist IP address access
113 113
 		 */
114
-		 public static function checkWhiteListIpAccess(){
114
+		 public static function checkWhiteListIpAccess() {
115 115
 			$logger = self::getLogger();
116 116
 			$logger->debug('Validation of the IP address access ...');
117 117
 			$logger->debug('Check if whitelist IP access is enabled in the configuration ...');
118 118
 			$isEnable = get_config('white_list_ip_enable', false);
119
-			if($isEnable){
119
+			if ($isEnable) {
120 120
 				$logger->info('Whitelist IP access is enabled in the configuration');
121 121
 				$list = get_config('white_list_ip_addresses', array());
122
-				if(! empty($list)){
122
+				if (!empty($list)) {
123 123
 					//Can't use Loader::functions() at this time because teh "Loader" library is loader after the security prossessing
124 124
 					require_once CORE_FUNCTIONS_PATH . 'function_user_agent.php';
125 125
 					$ip = get_ip();
126
-					if((count($list) == 1 && $list[0] == '*') || in_array($ip, $list)){
126
+					if ((count($list) == 1 && $list[0] == '*') || in_array($ip, $list)) {
127 127
 						$logger->info('IP address ' . $ip . ' allowed using the wildcard "*" or the full IP');
128 128
 						//wildcard to access all ip address
129 129
 						return;
130 130
 					}
131
-					else{
131
+					else {
132 132
 						// go through all whitelisted ips
133 133
 						foreach ($list as $ipaddr) {
134 134
 							// find the wild card * in whitelisted ip (f.e. find position in "127.0.*" or "127*")
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 					}
155 155
 				}
156 156
 			}
157
-			else{
157
+			else {
158 158
 				$logger->info('Whitelist IP access is not enabled in the configuration, ignore checking');
159 159
 			}
160 160
 		 }
Please login to merge, or discard this patch.