Passed
Push — 1.0.0-dev ( 4efac2...b68981 )
by nguereza
02:49
created
classes/views/home.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -8,13 +8,13 @@  discard block
 block discarded – undo
8 8
     <meta name="description" content="A simple PHP framework using HMVC architecture">
9 9
     <meta name="author" content="Tony NGUEREZA">
10 10
     <title>TNH Framework</title>
11
-    <link href="<?php echo Assets::css('bootstrap.min');?>" rel="stylesheet" type = "text/css" >
12
-	<link href="<?php echo Assets::css('font-awesome.min');?>" rel="stylesheet" type = "text/css" >
13
-    <link href="<?php echo Assets::css('responsive');?>" rel="stylesheet" type = "text/css" >
14
-	<link rel="icon" href="<?php echo Assets::img('favicon.ico');?>">
11
+    <link href="<?php echo Assets::css('bootstrap.min'); ?>" rel="stylesheet" type = "text/css" >
12
+	<link href="<?php echo Assets::css('font-awesome.min'); ?>" rel="stylesheet" type = "text/css" >
13
+    <link href="<?php echo Assets::css('responsive'); ?>" rel="stylesheet" type = "text/css" >
14
+	<link rel="icon" href="<?php echo Assets::img('favicon.ico'); ?>">
15 15
 	<!--[if lt IE 9]>
16
-	<script src="<?php echo Assets::js('html5shiv');?>"></script>
17
-	<script src="<?php echo Assets::js('respond.min');?>"></script>
16
+	<script src="<?php echo Assets::js('html5shiv'); ?>"></script>
17
+	<script src="<?php echo Assets::js('respond.min'); ?>"></script>
18 18
     <![endif]-->
19 19
 	<style type = "text/css">
20 20
 		
@@ -28,15 +28,15 @@  discard block
 block discarded – undo
28 28
 			<div class = "col-md-offset-2 col-md-8 col-md-offset-2">
29 29
 				<div class = "panel panel-primary">
30 30
 					<div class = "panel-heading">
31
-						<h2>Welcome on <?php echo TNH_NAME;?> v<?php echo TNH_VERSION;?></h2>
31
+						<h2>Welcome on <?php echo TNH_NAME; ?> v<?php echo TNH_VERSION; ?></h2>
32 32
 					</div>
33 33
 					<div class = "panel-body">
34
-						<img src = "<?php echo Assets::img('logo.png');?>" class = "img-responsive" style = "float:left;" />
34
+						<img src = "<?php echo Assets::img('logo.png'); ?>" class = "img-responsive" style = "float:left;" />
35 35
 						<h3>
36 36
 							A simple PHP framework using HMVC architecture
37 37
 						</h3>
38 38
 						<br />
39
-						<p><?php echo Html::a('https://github.com/tnhfw/tnh-fw', 'Framework on Github', array('class' => 'btn btn-default', 'target' => '_blank'));?></p>
39
+						<p><?php echo Html::a('https://github.com/tnhfw/tnh-fw', 'Framework on Github', array('class' => 'btn btn-default', 'target' => '_blank')); ?></p>
40 40
 					</div>
41 41
 				</div>
42 42
 				<div class = "panel panel-primary">
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 						<h2>Server information</h2>
45 45
 					</div>
46 46
 					<div class = "panel-body">
47
-						<h4>Running on : <b><?php echo php_uname();?></b></h4>
48
-						<h4>PHP server SAPI : <b><?php echo php_sapi_name();?></b></h4>
49
-						<h4>PHP Version : <b><?php echo phpversion();?></b></h4>
50
-						<h4>PHP Loaded extensions : (<?php echo count(get_loaded_extensions());?> extensions)</h4>
47
+						<h4>Running on : <b><?php echo php_uname(); ?></b></h4>
48
+						<h4>PHP server SAPI : <b><?php echo php_sapi_name(); ?></b></h4>
49
+						<h4>PHP Version : <b><?php echo phpversion(); ?></b></h4>
50
+						<h4>PHP Loaded extensions : (<?php echo count(get_loaded_extensions()); ?> extensions)</h4>
51 51
 							<table class = "table table-striped table-condensed table-bordered table-responsive">
52 52
 								<tr>
53 53
 									<th>Name</th>
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 								</tr>
56 56
 								<?php foreach (get_loaded_extensions() as $e):?>
57 57
 									<tr>
58
-										<td><?php echo $e;?></td>
59
-										<td><?php echo phpversion($e);?></td>
58
+										<td><?php echo $e; ?></td>
59
+										<td><?php echo phpversion($e); ?></td>
60 60
 									</tr>
61
-								<?php endforeach;?>
61
+								<?php endforeach; ?>
62 62
 							</table>
63 63
 					</div>
64 64
 				</div>
@@ -67,30 +67,30 @@  discard block
 block discarded – undo
67 67
 						<h2>Framework information</h2>
68 68
 					</div>
69 69
 					<div class = "panel-body">
70
-						<h4>Version : <b><?php echo TNH_VERSION;?></b></h4>
71
-						<h4>Required PHP version : <b>PHP >= <?php echo TNH_REQUIRED_PHP_MIN_VERSION;?>, PHP <= <?php echo TNH_REQUIRED_PHP_MAX_VERSION;?></b></h4>
72
-						<h4>Build date : <b><?php echo TNH_RELEASE_DATE;?></b></h4>
73
-						<h4>Author : <b><?php echo TNH_AUTHOR;?></b></h4>
74
-						<h4>Author E-mail : <b><?php echo TNH_AUTHOR_EMAIL;?></b></h4>
75
-						<h4>Loaded files : (<?php echo count(get_included_files());?> files)</h4>
70
+						<h4>Version : <b><?php echo TNH_VERSION; ?></b></h4>
71
+						<h4>Required PHP version : <b>PHP >= <?php echo TNH_REQUIRED_PHP_MIN_VERSION; ?>, PHP <= <?php echo TNH_REQUIRED_PHP_MAX_VERSION; ?></b></h4>
72
+						<h4>Build date : <b><?php echo TNH_RELEASE_DATE; ?></b></h4>
73
+						<h4>Author : <b><?php echo TNH_AUTHOR; ?></b></h4>
74
+						<h4>Author E-mail : <b><?php echo TNH_AUTHOR_EMAIL; ?></b></h4>
75
+						<h4>Loaded files : (<?php echo count(get_included_files()); ?> files)</h4>
76 76
 							<table class = "table table-striped table-condensed table-bordered table-responsive">
77 77
 								<tr>
78 78
 									<th>Path</th>
79 79
 									<th>File</th>
80 80
 								</tr>
81
-								<?php foreach(get_included_files() as $file):?>
81
+								<?php foreach (get_included_files() as $file):?>
82 82
 									<tr>
83
-										<td><?php echo $file;?></td>
84
-										<td><?php echo basename($file);?></td>
83
+										<td><?php echo $file; ?></td>
84
+										<td><?php echo basename($file); ?></td>
85 85
 									</tr>
86
-								<?php endforeach;?>
86
+								<?php endforeach; ?>
87 87
 							</table>
88 88
 					</div>
89 89
 				</div>
90 90
 			</div>
91 91
 		</div>
92 92
 	</div>
93
-	<script src="<?php echo Assets::js('jquery');?>"></script>
94
-	<script src="<?php echo Assets::js('bootstrap.min');?>"></script>
93
+	<script src="<?php echo Assets::js('jquery'); ?>"></script>
94
+	<script src="<?php echo Assets::js('bootstrap.min'); ?>"></script>
95 95
 	</body>
96 96
 </html>
Please login to merge, or discard this patch.
index.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -243,7 +243,7 @@
 block discarded – undo
243 243
 			if (version_compare(PHP_VERSION, '5.3', '>=')) {
244 244
 				error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
245 245
 			}
246
-			else{
246
+			else {
247 247
 				error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
248 248
 			}
249 249
 		break;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -242,8 +242,7 @@
 block discarded – undo
242 242
 			ini_set('display_errors', 0);
243 243
 			if (version_compare(PHP_VERSION, '5.3', '>=')) {
244 244
 				error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
245
-			}
246
-			else{
245
+			} else{
247 246
 				error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
248 247
 			}
249 248
 		break;
Please login to merge, or discard this patch.
Indentation   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -1,260 +1,260 @@
 block discarded – undo
1 1
 <?php
2
-	/**
3
-	 * TNH Framework
4
-	 *
5
-	 * A simple PHP framework using HMVC architecture
6
-	 *
7
-	 * This content is released under the GNU GPL License (GPL)
8
-	 *
9
-	 * Copyright (C) 2017 Tony NGUEREZA
10
-	 *
11
-	 * This program is free software; you can redistribute it and/or
12
-	 * modify it under the terms of the GNU General Public License
13
-	 * as published by the Free Software Foundation; either version 3
14
-	 * of the License, or (at your option) any later version.
15
-	 *
16
-	 * This program is distributed in the hope that it will be useful,
17
-	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
-	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
-	 * GNU General Public License for more details.
20
-	 *
21
-	 * You should have received a copy of the GNU General Public License
22
-	 * along with this program; if not, write to the Free Software
23
-	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24
-	*/
2
+    /**
3
+     * TNH Framework
4
+     *
5
+     * A simple PHP framework using HMVC architecture
6
+     *
7
+     * This content is released under the GNU GPL License (GPL)
8
+     *
9
+     * Copyright (C) 2017 Tony NGUEREZA
10
+     *
11
+     * This program is free software; you can redistribute it and/or
12
+     * modify it under the terms of the GNU General Public License
13
+     * as published by the Free Software Foundation; either version 3
14
+     * of the License, or (at your option) any later version.
15
+     *
16
+     * This program is distributed in the hope that it will be useful,
17
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
+     * GNU General Public License for more details.
20
+     *
21
+     * You should have received a copy of the GNU General Public License
22
+     * along with this program; if not, write to the Free Software
23
+     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24
+     */
25 25
 
26
-	/**
27
-	* the directory separator, under windows it is \ and unix, linux /
28
-	*/
29
-	define('DS', DIRECTORY_SEPARATOR);
26
+    /**
27
+     * the directory separator, under windows it is \ and unix, linux /
28
+     */
29
+    define('DS', DIRECTORY_SEPARATOR);
30 30
 
31
-	/**
32
-	* The root directory of the application.
33
-	*
34
-	* you can place this directory outside of your web directory, for example "/home/your_app", etc.
35
-	*/
36
-	define('ROOT_PATH', dirname(realpath(__FILE__)) . DS);
31
+    /**
32
+     * The root directory of the application.
33
+     *
34
+     * you can place this directory outside of your web directory, for example "/home/your_app", etc.
35
+     */
36
+    define('ROOT_PATH', dirname(realpath(__FILE__)) . DS);
37 37
 
38
-	/**
39
-	* The path to the directory.
40
-	*
41
-	* That contains your static files (javascript, css, images, etc.)
42
-	* Note: the path must be relative to the file index.php (the front-end controller).
43
-	*/
44
-	define('ASSETS_PATH', 'assets/');
38
+    /**
39
+     * The path to the directory.
40
+     *
41
+     * That contains your static files (javascript, css, images, etc.)
42
+     * Note: the path must be relative to the file index.php (the front-end controller).
43
+     */
44
+    define('ASSETS_PATH', 'assets/');
45 45
 
46
-	/**
47
-	* The path to the directory of your cache files.
48
-	*
49
-	* This feature is available currently for database and views.
50
-	*/
51
-	define('CACHE_PATH', ROOT_PATH . 'cache' . DS);
46
+    /**
47
+     * The path to the directory of your cache files.
48
+     *
49
+     * This feature is available currently for database and views.
50
+     */
51
+    define('CACHE_PATH', ROOT_PATH . 'cache' . DS);
52 52
 
53
-	/**
54
-	* The path to the application directory. 
55
-	*
56
-	* It contains your most often used files that is to say which contains your files of the application, 
57
-	* in MVC architecture (controllers, models, views).
58
-	*/
59
-	define('APPS_PATH', ROOT_PATH . 'classes' . DS);
53
+    /**
54
+     * The path to the application directory. 
55
+     *
56
+     * It contains your most often used files that is to say which contains your files of the application, 
57
+     * in MVC architecture (controllers, models, views).
58
+     */
59
+    define('APPS_PATH', ROOT_PATH . 'classes' . DS);
60 60
 
61
-	/**
62
-	* The path to the controller directory of your application.
63
-	*
64
-	* If you already know the MVC architecture you know what a controller means; 
65
-	* it is he who makes the business logic of your application in general.
66
-	*/
67
-	define('APPS_CONTROLLER_PATH', APPS_PATH . 'controllers' . DS);
61
+    /**
62
+     * The path to the controller directory of your application.
63
+     *
64
+     * If you already know the MVC architecture you know what a controller means; 
65
+     * it is he who makes the business logic of your application in general.
66
+     */
67
+    define('APPS_CONTROLLER_PATH', APPS_PATH . 'controllers' . DS);
68 68
 
69
-	/**
70
-	* The path to the directory of your model classes of your application. 
71
-	*
72
-	* If you already know the MVC architecture you know what a model means; 
73
-	* it's the one who interacts with the database, in one word persistent data from your application.
74
-	*/
75
-	define('APPS_MODEL_PATH', APPS_PATH . 'models' . DS);
69
+    /**
70
+     * The path to the directory of your model classes of your application. 
71
+     *
72
+     * If you already know the MVC architecture you know what a model means; 
73
+     * it's the one who interacts with the database, in one word persistent data from your application.
74
+     */
75
+    define('APPS_MODEL_PATH', APPS_PATH . 'models' . DS);
76 76
 
77
-	/**
78
-	* The path to the directory of your views.
79
-	*
80
-	* If you already know the MVC architecture you know what a view means, 
81
-	* a view is just a user interface (html page, form, etc.) that is to say 
82
-	* everything displayed in the browser interface, etc.
83
-	*/
84
-	define('APPS_VIEWS_PATH', APPS_PATH . 'views' . DS);
77
+    /**
78
+     * The path to the directory of your views.
79
+     *
80
+     * If you already know the MVC architecture you know what a view means, 
81
+     * a view is just a user interface (html page, form, etc.) that is to say 
82
+     * everything displayed in the browser interface, etc.
83
+     */
84
+    define('APPS_VIEWS_PATH', APPS_PATH . 'views' . DS);
85 85
 
86
-	/**
87
-	* The path to the configuration directory.
88
-	*
89
-	* That contains most of the configuration files for your 
90
-	* application (database, class loading file, functions, etc.)
91
-	*/
92
-	define('CONFIG_PATH', ROOT_PATH . 'config' . DS);
86
+    /**
87
+     * The path to the configuration directory.
88
+     *
89
+     * That contains most of the configuration files for your 
90
+     * application (database, class loading file, functions, etc.)
91
+     */
92
+    define('CONFIG_PATH', ROOT_PATH . 'config' . DS);
93 93
 
94
-	/** 
95
-	* The core directory
96
-	*
97
-	* It is recommended to put this folder out of the web directory of your server and 
98
-	* you should not change its content because in case of update you could lose the modified files.
99
-	*/
100
-	define('CORE_PATH', ROOT_PATH . 'core' . DS);
94
+    /** 
95
+     * The core directory
96
+     *
97
+     * It is recommended to put this folder out of the web directory of your server and 
98
+     * you should not change its content because in case of update you could lose the modified files.
99
+     */
100
+    define('CORE_PATH', ROOT_PATH . 'core' . DS);
101 101
 	
102
-	/**
103
-	* The path to the directory of core classes that used by the system.
104
-	*
105
-	* It contains PHP classes that are used by the framework internally.
106
-	*/
107
-	define('CORE_CLASSES_PATH', CORE_PATH . 'classes' . DS);
102
+    /**
103
+     * The path to the directory of core classes that used by the system.
104
+     *
105
+     * It contains PHP classes that are used by the framework internally.
106
+     */
107
+    define('CORE_CLASSES_PATH', CORE_PATH . 'classes' . DS);
108 108
 	
109
-	/**
110
-	* The path to the directory of core classes for the cache used by the system.
111
-	*
112
-	* It contains PHP classes for the cache drivers.
113
-	*/
114
-	define('CORE_CLASSES_CACHE_PATH', CORE_CLASSES_PATH . 'cache' . DS);
109
+    /**
110
+     * The path to the directory of core classes for the cache used by the system.
111
+     *
112
+     * It contains PHP classes for the cache drivers.
113
+     */
114
+    define('CORE_CLASSES_CACHE_PATH', CORE_CLASSES_PATH . 'cache' . DS);
115 115
 	
116
-	/**
117
-	* The path to the directory of core classes for the model used by the system.
118
-	*
119
-	* It contains PHP classes for the models.
120
-	*/
121
-	define('CORE_CLASSES_MODEL_PATH', CORE_CLASSES_PATH . 'model' . DS);
116
+    /**
117
+     * The path to the directory of core classes for the model used by the system.
118
+     *
119
+     * It contains PHP classes for the models.
120
+     */
121
+    define('CORE_CLASSES_MODEL_PATH', CORE_CLASSES_PATH . 'model' . DS);
122 122
 
123
-	/**
124
-	* The path to the directory of functions or helper systems.
125
-	*
126
-	* It contains PHP functions that perform a particular task: character string processing, URL, etc.
127
-	*/
128
-	define('CORE_FUNCTIONS_PATH', CORE_PATH . 'functions' . DS);
123
+    /**
124
+     * The path to the directory of functions or helper systems.
125
+     *
126
+     * It contains PHP functions that perform a particular task: character string processing, URL, etc.
127
+     */
128
+    define('CORE_FUNCTIONS_PATH', CORE_PATH . 'functions' . DS);
129 129
 
130
-	/**
131
-	* The path to the core directory of languages files. 
132
-	*
133
-	*/
134
-	define('CORE_LANG_PATH', CORE_PATH . 'lang' . DS);
130
+    /**
131
+     * The path to the core directory of languages files. 
132
+     *
133
+     */
134
+    define('CORE_LANG_PATH', CORE_PATH . 'lang' . DS);
135 135
 
136
-	/**
137
-	* The path to the system library directory.
138
-	*
139
-	* Which contains the libraries most often used in your web application, as for the 
140
-	* core directory it is advisable to put it out of the root directory of your application.
141
-	*/
142
-	define('CORE_LIBRARY_PATH', CORE_PATH . 'libraries' . DS);
136
+    /**
137
+     * The path to the system library directory.
138
+     *
139
+     * Which contains the libraries most often used in your web application, as for the 
140
+     * core directory it is advisable to put it out of the root directory of your application.
141
+     */
142
+    define('CORE_LIBRARY_PATH', CORE_PATH . 'libraries' . DS);
143 143
 
144
-	/**
145
-	* The path to the system view directory.
146
-	*
147
-	* That contains the views used for the system, such as error messages, and so on.
148
-	*/
149
-	define('CORE_VIEWS_PATH', CORE_PATH . 'views' . DS);
144
+    /**
145
+     * The path to the system view directory.
146
+     *
147
+     * That contains the views used for the system, such as error messages, and so on.
148
+     */
149
+    define('CORE_VIEWS_PATH', CORE_PATH . 'views' . DS);
150 150
 	
151
-	/**
152
-	* The path to the directory of your PHP personal functions or helper.
153
-	*
154
-	* It contains your PHP functions that perform a particular task: utilities, etc.
155
-	* Note: Do not put your personal functions or helpers in the system functions directory, 
156
-	* because if you update the system you may lose them.
157
-	*/
158
-	define('FUNCTIONS_PATH', ROOT_PATH . 'functions' . DS);
151
+    /**
152
+     * The path to the directory of your PHP personal functions or helper.
153
+     *
154
+     * It contains your PHP functions that perform a particular task: utilities, etc.
155
+     * Note: Do not put your personal functions or helpers in the system functions directory, 
156
+     * because if you update the system you may lose them.
157
+     */
158
+    define('FUNCTIONS_PATH', ROOT_PATH . 'functions' . DS);
159 159
 
160
-	/**
161
-	* The path to the app directory of personal language. 
162
-	*
163
-	* This feature is not yet available. 
164
-	* You can help us do this if you are nice or wish to see the developed framework.
165
-	*/
166
-	define('APP_LANG_PATH', ROOT_PATH . 'lang' . DS);
160
+    /**
161
+     * The path to the app directory of personal language. 
162
+     *
163
+     * This feature is not yet available. 
164
+     * You can help us do this if you are nice or wish to see the developed framework.
165
+     */
166
+    define('APP_LANG_PATH', ROOT_PATH . 'lang' . DS);
167 167
 
168
-	/**
169
-	* The path to the directory of your personal libraries
170
-	*
171
-	* It contains your PHP classes, package, etc.
172
-	* Note: you should not put your personal libraries in the system library directory, 
173
-	* because it is recalled in case of updating the system you might have surprises.
174
-	*/
175
-	define('LIBRARY_PATH', ROOT_PATH . 'libraries' . DS);
168
+    /**
169
+     * The path to the directory of your personal libraries
170
+     *
171
+     * It contains your PHP classes, package, etc.
172
+     * Note: you should not put your personal libraries in the system library directory, 
173
+     * because it is recalled in case of updating the system you might have surprises.
174
+     */
175
+    define('LIBRARY_PATH', ROOT_PATH . 'libraries' . DS);
176 176
 
177
-	/**
178
-	* The path to the directory that contains the log files.
179
-	*
180
-	* Note: This directory must be available in writing and if possible must have as owner the user who launches your web server, 
181
-	* under unix or linux most often with the apache web server it is "www-data" or "httpd" even "nobody" for more
182
-	* details see the documentation of your web server.
183
-	* Example for Unix or linux with apache web server:
184
-	* # chmod -R 700 /path/to/your/logs/directory/
185
-	* # chown -R www-data:www-data /path/to/your/logs/directory/
186
-	*/
187
-	define('LOGS_PATH', ROOT_PATH . 'logs' . DS);
177
+    /**
178
+     * The path to the directory that contains the log files.
179
+     *
180
+     * Note: This directory must be available in writing and if possible must have as owner the user who launches your web server, 
181
+     * under unix or linux most often with the apache web server it is "www-data" or "httpd" even "nobody" for more
182
+     * details see the documentation of your web server.
183
+     * Example for Unix or linux with apache web server:
184
+     * # chmod -R 700 /path/to/your/logs/directory/
185
+     * # chown -R www-data:www-data /path/to/your/logs/directory/
186
+     */
187
+    define('LOGS_PATH', ROOT_PATH . 'logs' . DS);
188 188
 
189
-	/**
190
-	* The path to the modules directory. 
191
-	*
192
-	* It contains your modules used files (config, controllers, libraries, etc.) that is to say which contains your files of the modules, 
193
-	* in HMVC architecture (hierichical, controllers, models, views).
194
-	*/
195
-	define('MODULE_PATH', ROOT_PATH . 'modules' . DS);
189
+    /**
190
+     * The path to the modules directory. 
191
+     *
192
+     * It contains your modules used files (config, controllers, libraries, etc.) that is to say which contains your files of the modules, 
193
+     * in HMVC architecture (hierichical, controllers, models, views).
194
+     */
195
+    define('MODULE_PATH', ROOT_PATH . 'modules' . DS);
196 196
 
197
-	/**
198
-	* The path to the directory of sources external to your application.
199
-	*
200
-	* If you have already used "composer" you know what that means.
201
-	*/
202
-	define('VENDOR_PATH', ROOT_PATH . 'vendor' . DS);
197
+    /**
198
+     * The path to the directory of sources external to your application.
199
+     *
200
+     * If you have already used "composer" you know what that means.
201
+     */
202
+    define('VENDOR_PATH', ROOT_PATH . 'vendor' . DS);
203 203
 
204
-	/**
205
-	* The front controller of your application.
206
-	*
207
-	* "index.php" it is through this file that all the requests come, there is a possibility to hidden it in the url of 
208
-	* your application by using the rewrite module URL of your web server .
209
-	* For example, under apache web server, there is a configuration example file that is located at the root 
210
-	* of your framework folder : "htaccess.txt" rename it to ".htaccess".
211
-	*/
212
-	define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
204
+    /**
205
+     * The front controller of your application.
206
+     *
207
+     * "index.php" it is through this file that all the requests come, there is a possibility to hidden it in the url of 
208
+     * your application by using the rewrite module URL of your web server .
209
+     * For example, under apache web server, there is a configuration example file that is located at the root 
210
+     * of your framework folder : "htaccess.txt" rename it to ".htaccess".
211
+     */
212
+    define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
213 213
 	
214
-	/**
215
-	 * Check if user run the application under CLI
216
-	 */
217
-	define('IS_CLI', stripos('cli', php_sapi_name()) !== false);
214
+    /**
215
+     * Check if user run the application under CLI
216
+     */
217
+    define('IS_CLI', stripos('cli', php_sapi_name()) !== false);
218 218
 
219
-	/**
220
-	* The environment of your application (production, test, development). 
221
-	*
222
-	* if your application is still in development you use the value "development" 
223
-	* so you will have the display of the error messages, etc. 
224
-	* Once you finish the development of your application that is to put it online 
225
-	* you change this value to "production" or "testing", in this case there will be deactivation of error messages, 
226
-	* the loading of the system, will be fast.
227
-	*/
228
-	define('ENVIRONMENT', 'development');
219
+    /**
220
+     * The environment of your application (production, test, development). 
221
+     *
222
+     * if your application is still in development you use the value "development" 
223
+     * so you will have the display of the error messages, etc. 
224
+     * Once you finish the development of your application that is to put it online 
225
+     * you change this value to "production" or "testing", in this case there will be deactivation of error messages, 
226
+     * the loading of the system, will be fast.
227
+     */
228
+    define('ENVIRONMENT', 'development');
229 229
 
230
-	/* ---------------------------------------------------------------------------------- */
231
-	///////////////////////////////////////////////////////////////////////////////////////
232
-	/******************** DO NOT CHANGE THE LINES BELOW *********************************/
233
-	/////////////////////////////////////////////////////////////////////////////////////
230
+    /* ---------------------------------------------------------------------------------- */
231
+    ///////////////////////////////////////////////////////////////////////////////////////
232
+    /******************** DO NOT CHANGE THE LINES BELOW *********************************/
233
+    /////////////////////////////////////////////////////////////////////////////////////
234 234
 
235
-	switch (ENVIRONMENT) {
236
-		case 'development':
237
-			error_reporting(-1);
238
-			ini_set('display_errors', 1);
239
-		break;
240
-		case 'testing':
241
-		case 'production':
242
-			ini_set('display_errors', 0);
243
-			if (version_compare(PHP_VERSION, '5.3', '>=')) {
244
-				error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
245
-			}
246
-			else{
247
-				error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
248
-			}
249
-		break;
250
-		default:
251
-			header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
252
-			echo 'The application environment is not set correctly.';
253
-			exit(1);
254
-	}
235
+    switch (ENVIRONMENT) {
236
+        case 'development':
237
+            error_reporting(-1);
238
+            ini_set('display_errors', 1);
239
+        break;
240
+        case 'testing':
241
+        case 'production':
242
+            ini_set('display_errors', 0);
243
+            if (version_compare(PHP_VERSION, '5.3', '>=')) {
244
+                error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
245
+            }
246
+            else{
247
+                error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
248
+            }
249
+        break;
250
+        default:
251
+            header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
252
+            echo 'The application environment is not set correctly.';
253
+            exit(1);
254
+    }
255 255
 	
256
-	/**
257
-	* let's go.
258
-	* Everything is OK now we launch our application.
259
-	*/
260
-	require_once CORE_PATH . 'bootstrap.php';
261 256
\ No newline at end of file
257
+    /**
258
+     * let's go.
259
+     * Everything is OK now we launch our application.
260
+     */
261
+    require_once CORE_PATH . 'bootstrap.php';
262 262
\ No newline at end of file
Please login to merge, or discard this patch.
core/bootstrap.php 3 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -78,8 +78,7 @@  discard block
 block discarded – undo
78 78
 	*/
79 79
 	if (version_compare(phpversion(), TNH_REQUIRED_PHP_MIN_VERSION, '<')){
80 80
 		show_error('Your PHP Version [' . phpversion() . '] is less than [' . TNH_REQUIRED_PHP_MIN_VERSION . '], please install a new version or update your PHP to the latest.', 'PHP Error environment');	
81
-	}
82
-	else if(version_compare(phpversion(), TNH_REQUIRED_PHP_MAX_VERSION, '>')){
81
+	} else if(version_compare(phpversion(), TNH_REQUIRED_PHP_MAX_VERSION, '>')){
83 82
 		show_error('Your PHP Version [' . phpversion() . '] is greather than [' . TNH_REQUIRED_PHP_MAX_VERSION . '] please install a PHP version that is compatible.', 'PHP Error environment');	
84 83
 	}
85 84
 	$LOGGER->info('PHP version [' . phpversion() . '] is OK [REQUIRED MINIMUM: ' . TNH_REQUIRED_PHP_MIN_VERSION . ', REQUIRED MAXIMUM: ' . TNH_REQUIRED_PHP_MAX_VERSION . '], application can work without any issue');
@@ -104,8 +103,7 @@  discard block
 block discarded – undo
104 103
 	if(file_exists(VENDOR_PATH . 'autoload.php')){
105 104
 		$LOGGER->info('The composer autoload file exists include it');
106 105
 		require_once VENDOR_PATH . 'autoload.php';
107
-	}
108
-	else{
106
+	} else{
109 107
 		$LOGGER->info('The composer autoload file does not exist skipping');
110 108
 	}
111 109
 	
@@ -176,8 +174,7 @@  discard block
 block discarded – undo
176 174
 		//first check if the cache handler is the system driver
177 175
 		if(file_exists(CORE_CLASSES_CACHE_PATH . $cacheHandler . '.php')){
178 176
 			$CACHE =& class_loader($cacheHandler, 'classes/cache');
179
-		}
180
-		else{
177
+		} else{
181 178
 			//it's not a system driver use user library
182 179
 			$CACHE =& class_loader($cacheHandler);
183 180
 		}
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	
43 43
 	//if the application is running in CLI mode $_SESSION global variable is not available
44
-	if(IS_CLI){
44
+	if (IS_CLI) {
45 45
 		$_SESSION = array();
46 46
 	}
47 47
 		
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 	/**
61 61
 	 * The Benchmark class
62 62
 	 */
63
-	$BENCHMARK =& class_loader('Benchmark');
63
+	$BENCHMARK = & class_loader('Benchmark');
64 64
 	
65 65
 	$BENCHMARK->mark('APP_EXECUTION_START');
66 66
 	
67 67
 	/**
68 68
     * instance of the Log class
69 69
     */
70
-    $LOGGER =& class_loader('Log', 'classes');
70
+    $LOGGER = & class_loader('Log', 'classes');
71 71
 
72 72
     $LOGGER->setLogger('ApplicationBootstrap');
73 73
 
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 	/**
77 77
 	* Verification of the PHP environment: minimum and maximum version
78 78
 	*/
79
-	if (version_compare(phpversion(), TNH_REQUIRED_PHP_MIN_VERSION, '<')){
79
+	if (version_compare(phpversion(), TNH_REQUIRED_PHP_MIN_VERSION, '<')) {
80 80
 		show_error('Your PHP Version [' . phpversion() . '] is less than [' . TNH_REQUIRED_PHP_MIN_VERSION . '], please install a new version or update your PHP to the latest.', 'PHP Error environment');	
81 81
 	}
82
-	else if(version_compare(phpversion(), TNH_REQUIRED_PHP_MAX_VERSION, '>')){
82
+	else if (version_compare(phpversion(), TNH_REQUIRED_PHP_MAX_VERSION, '>')) {
83 83
 		show_error('Your PHP Version [' . phpversion() . '] is greather than [' . TNH_REQUIRED_PHP_MAX_VERSION . '] please install a PHP version that is compatible.', 'PHP Error environment');	
84 84
 	}
85 85
 	$LOGGER->info('PHP version [' . phpversion() . '] is OK [REQUIRED MINIMUM: ' . TNH_REQUIRED_PHP_MIN_VERSION . ', REQUIRED MAXIMUM: ' . TNH_REQUIRED_PHP_MAX_VERSION . '], application can work without any issue');
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	
102 102
 	//if user have some composer packages
103 103
 	$LOGGER->debug('Check for composer autoload');
104
-	if(file_exists(VENDOR_PATH . 'autoload.php')){
104
+	if (file_exists(VENDOR_PATH . 'autoload.php')) {
105 105
 		$LOGGER->info('The composer autoload file exists include it');
106 106
 		require_once VENDOR_PATH . 'autoload.php';
107 107
 	}
108
-	else{
108
+	else {
109 109
 		$LOGGER->info('The composer autoload file does not exist skipping');
110 110
 	}
111 111
 	
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	* Load configurations and using the 
122 122
 	* static method "init()" to initialize the Config class .
123 123
 	*/
124
-	$CONFIG =& class_loader('Config', 'classes');	
124
+	$CONFIG = & class_loader('Config', 'classes');	
125 125
 	$CONFIG->init();
126 126
 	$BENCHMARK->mark('CONFIG_INIT_END');
127 127
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	* Load modules and using the 
131 131
 	* static method "init()" to initialize the Module class.
132 132
 	*/
133
-	$MODULE =& class_loader('Module', 'classes');
133
+	$MODULE = & class_loader('Module', 'classes');
134 134
 	$MODULE->init();
135 135
 	$BENCHMARK->mark('MODULE_INIT_END');
136 136
 
@@ -149,34 +149,34 @@  discard block
 block discarded – undo
149 149
 	/**
150 150
 	* Loading Security class
151 151
 	*/
152
-	$SECURITY =& class_loader('Security', 'classes');
152
+	$SECURITY = & class_loader('Security', 'classes');
153 153
 	$SECURITY->checkWhiteListIpAccess();
154 154
 	
155 155
 	/**
156 156
 	* Loading Url class
157 157
 	*/
158
-	$URL =& class_loader('Url', 'classes');
158
+	$URL = & class_loader('Url', 'classes');
159 159
 	
160
-	if(get_config('cache_enable', false)){
160
+	if (get_config('cache_enable', false)) {
161 161
 		/**
162 162
 		 * Load Cache interface file
163 163
 		 */
164 164
 		require_once CORE_CLASSES_CACHE_PATH . 'CacheInterface.php';
165 165
 		$cacheHandler = get_config('cache_handler');
166
-		if(! $cacheHandler){
166
+		if (!$cacheHandler) {
167 167
 			show_error('The cache feature is enabled in the configuration but the cache handler class is not set.');
168 168
 		}
169 169
 		$CACHE = null;
170 170
 		//first check if the cache handler is the system driver
171
-		if(file_exists(CORE_CLASSES_CACHE_PATH . $cacheHandler . '.php')){
172
-			$CACHE =& class_loader($cacheHandler, 'classes/cache');
171
+		if (file_exists(CORE_CLASSES_CACHE_PATH . $cacheHandler . '.php')) {
172
+			$CACHE = & class_loader($cacheHandler, 'classes/cache');
173 173
 		}
174
-		else{
174
+		else {
175 175
 			//it's not a system driver use user library
176
-			$CACHE =& class_loader($cacheHandler);
176
+			$CACHE = & class_loader($cacheHandler);
177 177
 		}
178 178
 		//check if the page already cached
179
-		if(! empty($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'get'){
179
+		if (!empty($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'get') {
180 180
 			$RESPONSE = & class_loader('Response', 'classes');
181 181
 			$RESPONSE->renderFinalPageFromCache($CACHE);
182 182
 		}
Please login to merge, or discard this patch.
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -1,195 +1,195 @@
 block discarded – undo
1 1
 <?php
2
-	defined('ROOT_PATH') || exit('Access denied');
3
-	/**
4
-	 * TNH Framework
5
-	 *
6
-	 * A simple PHP framework using HMVC architecture
7
-	 *
8
-	 * This content is released under the GNU GPL License (GPL)
9
-	 *
10
-	 * Copyright (C) 2017 Tony NGUEREZA
11
-	 *
12
-	 * This program is free software; you can redistribute it and/or
13
-	 * modify it under the terms of the GNU General Public License
14
-	 * as published by the Free Software Foundation; either version 3
15
-	 * of the License, or (at your option) any later version.
16
-	 *
17
-	 * This program is distributed in the hope that it will be useful,
18
-	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
-	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
-	 * GNU General Public License for more details.
21
-	 *
22
-	 * You should have received a copy of the GNU General Public License
23
-	 * along with this program; if not, write to the Free Software
24
-	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
-	*/
2
+    defined('ROOT_PATH') || exit('Access denied');
3
+    /**
4
+     * TNH Framework
5
+     *
6
+     * A simple PHP framework using HMVC architecture
7
+     *
8
+     * This content is released under the GNU GPL License (GPL)
9
+     *
10
+     * Copyright (C) 2017 Tony NGUEREZA
11
+     *
12
+     * This program is free software; you can redistribute it and/or
13
+     * modify it under the terms of the GNU General Public License
14
+     * as published by the Free Software Foundation; either version 3
15
+     * of the License, or (at your option) any later version.
16
+     *
17
+     * This program is distributed in the hope that it will be useful,
18
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+     * GNU General Public License for more details.
21
+     *
22
+     * You should have received a copy of the GNU General Public License
23
+     * along with this program; if not, write to the Free Software
24
+     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
+     */
26 26
 
27
-	/**
28
-	 *  @file bootstrap.php
29
-	 *  
30
-	 *  Contains the loading process: loading of constants, common functions, libraries 
31
-	 *  configurations, etc
32
-	 *  verification of the environment and the routing of the request.
33
-	 *  
34
-	 *  @package	core	
35
-	 *  @author	Tony NGUEREZA
36
-	 *  @copyright	Copyright (c) 2017
37
-	 *  @license	https://opensource.org/licenses/gpl-3.0.html GNU GPL License (GPL)
38
-	 *  @link	http://www.iacademy.cf
39
-	 *  @version 1.0.0
40
-	 *  @filesource
41
-	 */
27
+    /**
28
+     *  @file bootstrap.php
29
+     *  
30
+     *  Contains the loading process: loading of constants, common functions, libraries 
31
+     *  configurations, etc
32
+     *  verification of the environment and the routing of the request.
33
+     *  
34
+     *  @package	core	
35
+     *  @author	Tony NGUEREZA
36
+     *  @copyright	Copyright (c) 2017
37
+     *  @license	https://opensource.org/licenses/gpl-3.0.html GNU GPL License (GPL)
38
+     *  @link	http://www.iacademy.cf
39
+     *  @version 1.0.0
40
+     *  @filesource
41
+     */
42 42
 	
43
-	//if the application is running in CLI mode $_SESSION global variable is not available
44
-	if(IS_CLI){
45
-		$_SESSION = array();
46
-	}
43
+    //if the application is running in CLI mode $_SESSION global variable is not available
44
+    if(IS_CLI){
45
+        $_SESSION = array();
46
+    }
47 47
 		
48
-	/**
49
-	*  inclusion of global constants of the environment that contain : name of the framework,
50
-	*  version, release date, version of PHP required, etc.
51
-	*/
52
-	require_once CORE_PATH . 'constants.php';	
48
+    /**
49
+     *  inclusion of global constants of the environment that contain : name of the framework,
50
+     *  version, release date, version of PHP required, etc.
51
+     */
52
+    require_once CORE_PATH . 'constants.php';	
53 53
 	
54
-	/**
55
-	 *  include file containing commons functions used in the framework such: show_error, 
56
-	 *  php_exception_handler, php_error_handler, get_instance, etc.
57
-	 */
58
-	require_once CORE_PATH . 'common.php';
54
+    /**
55
+     *  include file containing commons functions used in the framework such: show_error, 
56
+     *  php_exception_handler, php_error_handler, get_instance, etc.
57
+     */
58
+    require_once CORE_PATH . 'common.php';
59 59
 
60
-	/**
61
-	 * The Benchmark class
62
-	 */
63
-	$BENCHMARK =& class_loader('Benchmark');
60
+    /**
61
+     * The Benchmark class
62
+     */
63
+    $BENCHMARK =& class_loader('Benchmark');
64 64
 	
65
-	$BENCHMARK->mark('APP_EXECUTION_START');
65
+    $BENCHMARK->mark('APP_EXECUTION_START');
66 66
 	
67
-	/**
68
-    * instance of the Log class
69
-    */
67
+    /**
68
+     * instance of the Log class
69
+     */
70 70
     $LOGGER =& class_loader('Log', 'classes');
71 71
 
72 72
     $LOGGER->setLogger('ApplicationBootstrap');
73 73
 
74 74
     $LOGGER->debug('Checking PHP version ...');	
75 75
 	
76
-	/**
77
-	* Verification of the PHP environment: minimum and maximum version
78
-	*/
79
-	if (version_compare(phpversion(), TNH_REQUIRED_PHP_MIN_VERSION, '<')){
80
-		show_error('Your PHP Version [' . phpversion() . '] is less than [' . TNH_REQUIRED_PHP_MIN_VERSION . '], please install a new version or update your PHP to the latest.', 'PHP Error environment');	
81
-	}
82
-	else if(version_compare(phpversion(), TNH_REQUIRED_PHP_MAX_VERSION, '>')){
83
-		show_error('Your PHP Version [' . phpversion() . '] is greather than [' . TNH_REQUIRED_PHP_MAX_VERSION . '] please install a PHP version that is compatible.', 'PHP Error environment');	
84
-	}
85
-	$LOGGER->info('PHP version [' . phpversion() . '] is OK [REQUIRED MINIMUM: ' . TNH_REQUIRED_PHP_MIN_VERSION . ', REQUIRED MAXIMUM: ' . TNH_REQUIRED_PHP_MAX_VERSION . '], application can work without any issue');
76
+    /**
77
+     * Verification of the PHP environment: minimum and maximum version
78
+     */
79
+    if (version_compare(phpversion(), TNH_REQUIRED_PHP_MIN_VERSION, '<')){
80
+        show_error('Your PHP Version [' . phpversion() . '] is less than [' . TNH_REQUIRED_PHP_MIN_VERSION . '], please install a new version or update your PHP to the latest.', 'PHP Error environment');	
81
+    }
82
+    else if(version_compare(phpversion(), TNH_REQUIRED_PHP_MAX_VERSION, '>')){
83
+        show_error('Your PHP Version [' . phpversion() . '] is greather than [' . TNH_REQUIRED_PHP_MAX_VERSION . '] please install a PHP version that is compatible.', 'PHP Error environment');	
84
+    }
85
+    $LOGGER->info('PHP version [' . phpversion() . '] is OK [REQUIRED MINIMUM: ' . TNH_REQUIRED_PHP_MIN_VERSION . ', REQUIRED MAXIMUM: ' . TNH_REQUIRED_PHP_MAX_VERSION . '], application can work without any issue');
86 86
 
87
-	/**
88
-	* Setting of the PHP error message handling function
89
-	*/
90
-	set_error_handler('php_error_handler');
87
+    /**
88
+     * Setting of the PHP error message handling function
89
+     */
90
+    set_error_handler('php_error_handler');
91 91
 
92
-	/**
93
-	* Setting of the PHP error exception handling function
94
-	*/
95
-	set_exception_handler('php_exception_handler');
92
+    /**
93
+     * Setting of the PHP error exception handling function
94
+     */
95
+    set_exception_handler('php_exception_handler');
96 96
 
97
-	/**
98
-	 * Setting of the PHP shutdown handling function
99
-	 */
100
-	register_shutdown_function('php_shudown_handler');
97
+    /**
98
+     * Setting of the PHP shutdown handling function
99
+     */
100
+    register_shutdown_function('php_shudown_handler');
101 101
 	
102
-	//if user have some composer packages
103
-	$LOGGER->debug('Check for composer autoload');
104
-	if(file_exists(VENDOR_PATH . 'autoload.php')){
105
-		$LOGGER->info('The composer autoload file exists include it');
106
-		require_once VENDOR_PATH . 'autoload.php';
107
-	}
108
-	else{
109
-		$LOGGER->info('The composer autoload file does not exist skipping');
110
-	}
102
+    //if user have some composer packages
103
+    $LOGGER->debug('Check for composer autoload');
104
+    if(file_exists(VENDOR_PATH . 'autoload.php')){
105
+        $LOGGER->info('The composer autoload file exists include it');
106
+        require_once VENDOR_PATH . 'autoload.php';
107
+    }
108
+    else{
109
+        $LOGGER->info('The composer autoload file does not exist skipping');
110
+    }
111 111
 	
112
-	$LOGGER->debug('Begin to load the required resources');
112
+    $LOGGER->debug('Begin to load the required resources');
113 113
 
114
-	/**
115
-	 * Load the EventInfo class file
116
-	 */
117
-	require_once CORE_CLASSES_PATH . 'EventInfo.php';
114
+    /**
115
+     * Load the EventInfo class file
116
+     */
117
+    require_once CORE_CLASSES_PATH . 'EventInfo.php';
118 118
 
119 119
 
120
-	$BENCHMARK->mark('CONFIG_INIT_START');
121
-	/**
122
-	* Load configurations and using the 
123
-	* static method "init()" to initialize the Config class .
124
-	*/
125
-	$CONFIG =& class_loader('Config', 'classes');	
126
-	$CONFIG->init();
127
-	$BENCHMARK->mark('CONFIG_INIT_END');
120
+    $BENCHMARK->mark('CONFIG_INIT_START');
121
+    /**
122
+     * Load configurations and using the 
123
+     * static method "init()" to initialize the Config class .
124
+     */
125
+    $CONFIG =& class_loader('Config', 'classes');	
126
+    $CONFIG->init();
127
+    $BENCHMARK->mark('CONFIG_INIT_END');
128 128
 
129
-	$BENCHMARK->mark('MODULE_INIT_START');
130
-	/**
131
-	* Load modules and using the 
132
-	* static method "init()" to initialize the Module class.
133
-	*/
134
-	$MODULE =& class_loader('Module', 'classes');
135
-	$MODULE->init();
136
-	$BENCHMARK->mark('MODULE_INIT_END');
129
+    $BENCHMARK->mark('MODULE_INIT_START');
130
+    /**
131
+     * Load modules and using the 
132
+     * static method "init()" to initialize the Module class.
133
+     */
134
+    $MODULE =& class_loader('Module', 'classes');
135
+    $MODULE->init();
136
+    $BENCHMARK->mark('MODULE_INIT_END');
137 137
 
138
-	$LOGGER->debug('Loading Base Controller ...');
139
-	/**
140
-	 * Include of the file containing the Base Controller class 
141
-	 */
142
-	require_once CORE_CLASSES_PATH . 'Controller.php';
143
-	$LOGGER->info('Base Controller loaded successfully');
138
+    $LOGGER->debug('Loading Base Controller ...');
139
+    /**
140
+     * Include of the file containing the Base Controller class 
141
+     */
142
+    require_once CORE_CLASSES_PATH . 'Controller.php';
143
+    $LOGGER->info('Base Controller loaded successfully');
144 144
 
145
-	/**
146
-	* Register controllers autoload function
147
-	*/
148
-	 spl_autoload_register('autoload_controller');
145
+    /**
146
+     * Register controllers autoload function
147
+     */
148
+        spl_autoload_register('autoload_controller');
149 149
 
150
-	/**
151
-	* Loading Security class
152
-	*/
153
-	$SECURITY =& class_loader('Security', 'classes');
154
-	$SECURITY->checkWhiteListIpAccess();
150
+    /**
151
+     * Loading Security class
152
+     */
153
+    $SECURITY =& class_loader('Security', 'classes');
154
+    $SECURITY->checkWhiteListIpAccess();
155 155
 	
156
-	/**
157
-	* Loading Url class
158
-	*/
159
-	$URL =& class_loader('Url', 'classes');
156
+    /**
157
+     * Loading Url class
158
+     */
159
+    $URL =& class_loader('Url', 'classes');
160 160
 	
161
-	if(get_config('cache_enable', false)){
162
-		/**
163
-		 * Load Cache interface file
164
-		 */
165
-		require_once CORE_CLASSES_CACHE_PATH . 'CacheInterface.php';
166
-		$cacheHandler = get_config('cache_handler');
167
-		if(! $cacheHandler){
168
-			show_error('The cache feature is enabled in the configuration but the cache handler class is not set.');
169
-		}
170
-		$CACHE = null;
171
-		//first check if the cache handler is the system driver
172
-		if(file_exists(CORE_CLASSES_CACHE_PATH . $cacheHandler . '.php')){
173
-			$CACHE =& class_loader($cacheHandler, 'classes/cache');
174
-		}
175
-		else{
176
-			//it's not a system driver use user library
177
-			$CACHE =& class_loader($cacheHandler);
178
-		}
179
-		//check if the page already cached
180
-		if(! empty($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'get'){
181
-			$RESPONSE = & class_loader('Response', 'classes');
182
-			$RESPONSE->renderFinalPageFromCache($CACHE);
183
-		}
184
-	}
161
+    if(get_config('cache_enable', false)){
162
+        /**
163
+         * Load Cache interface file
164
+         */
165
+        require_once CORE_CLASSES_CACHE_PATH . 'CacheInterface.php';
166
+        $cacheHandler = get_config('cache_handler');
167
+        if(! $cacheHandler){
168
+            show_error('The cache feature is enabled in the configuration but the cache handler class is not set.');
169
+        }
170
+        $CACHE = null;
171
+        //first check if the cache handler is the system driver
172
+        if(file_exists(CORE_CLASSES_CACHE_PATH . $cacheHandler . '.php')){
173
+            $CACHE =& class_loader($cacheHandler, 'classes/cache');
174
+        }
175
+        else{
176
+            //it's not a system driver use user library
177
+            $CACHE =& class_loader($cacheHandler);
178
+        }
179
+        //check if the page already cached
180
+        if(! empty($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'get'){
181
+            $RESPONSE = & class_loader('Response', 'classes');
182
+            $RESPONSE->renderFinalPageFromCache($CACHE);
183
+        }
184
+    }
185 185
 	
186
-	//load model class
187
-	require_once CORE_CLASSES_MODEL_PATH . 'Model.php';
186
+    //load model class
187
+    require_once CORE_CLASSES_MODEL_PATH . 'Model.php';
188 188
 	
189
-	$LOGGER->info('Everything is OK load Router library and dispatch the request to the corresponding controller');
190
-	/**
191
-	* Routing
192
-	* instantiation of the "Router" class and user request routing processing.
193
-	*/
194
-	$ROUTER = & class_loader('Router', 'classes');
195
-	$ROUTER->run();
189
+    $LOGGER->info('Everything is OK load Router library and dispatch the request to the corresponding controller');
190
+    /**
191
+     * Routing
192
+     * instantiation of the "Router" class and user request routing processing.
193
+     */
194
+    $ROUTER = & class_loader('Router', 'classes');
195
+    $ROUTER->run();
Please login to merge, or discard this patch.
core/classes/cache/CacheInterface.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 25
 	*/
26 26
 	
27
-	interface CacheInterface{
27
+	interface CacheInterface {
28 28
 
29 29
 		/**
30 30
 		 * This is used to get the cache data using the key
Please login to merge, or discard this patch.
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -1,84 +1,84 @@
 block discarded – undo
1 1
 <?php
2
-	defined('ROOT_PATH') or exit('Access denied');
3
-	/**
4
-	 * TNH Framework
5
-	 *
6
-	 * A simple PHP framework using HMVC architecture
7
-	 *
8
-	 * This content is released under the GNU GPL License (GPL)
9
-	 *
10
-	 * Copyright (C) 2017 Tony NGUEREZA
11
-	 *
12
-	 * This program is free software; you can redistribute it and/or
13
-	 * modify it under the terms of the GNU General Public License
14
-	 * as published by the Free Software Foundation; either version 3
15
-	 * of the License, or (at your option) any later version.
16
-	 *
17
-	 * This program is distributed in the hope that it will be useful,
18
-	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
-	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
-	 * GNU General Public License for more details.
21
-	 *
22
-	 * You should have received a copy of the GNU General Public License
23
-	 * along with this program; if not, write to the Free Software
24
-	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
-	*/
2
+    defined('ROOT_PATH') or exit('Access denied');
3
+    /**
4
+     * TNH Framework
5
+     *
6
+     * A simple PHP framework using HMVC architecture
7
+     *
8
+     * This content is released under the GNU GPL License (GPL)
9
+     *
10
+     * Copyright (C) 2017 Tony NGUEREZA
11
+     *
12
+     * This program is free software; you can redistribute it and/or
13
+     * modify it under the terms of the GNU General Public License
14
+     * as published by the Free Software Foundation; either version 3
15
+     * of the License, or (at your option) any later version.
16
+     *
17
+     * This program is distributed in the hope that it will be useful,
18
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+     * GNU General Public License for more details.
21
+     *
22
+     * You should have received a copy of the GNU General Public License
23
+     * along with this program; if not, write to the Free Software
24
+     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
+     */
26 26
 	
27
-	interface CacheInterface{
27
+    interface CacheInterface{
28 28
 
29
-		/**
30
-		 * This is used to get the cache data using the key
31
-		 * @param  string $key the key to identify the cache data
32
-		 * @return mixed      the cache data if exists else return false
33
-		 */
34
-		public function get($key);
29
+        /**
30
+         * This is used to get the cache data using the key
31
+         * @param  string $key the key to identify the cache data
32
+         * @return mixed      the cache data if exists else return false
33
+         */
34
+        public function get($key);
35 35
 
36 36
 
37
-		/**
38
-		 * Save data to the cache
39
-		 * @param string  $key  the key to identify this cache data
40
-		 * @param mixed  $data the cache data to be saved
41
-		 * @param integer $ttl  the cache life time
42
-		 * @return boolean true if success otherwise will return false
43
-		 */
44
-		public function set($key, $data, $ttl = 0);
37
+        /**
38
+         * Save data to the cache
39
+         * @param string  $key  the key to identify this cache data
40
+         * @param mixed  $data the cache data to be saved
41
+         * @param integer $ttl  the cache life time
42
+         * @return boolean true if success otherwise will return false
43
+         */
44
+        public function set($key, $data, $ttl = 0);
45 45
 
46 46
 
47
-		/**
48
-		 * Delete the cache data for given key
49
-		 * @param  string $key the key for cache to be deleted
50
-		 * @return boolean      true if the cache is deleted, false if can't delete 
51
-		 * the cache or the cache with the given key not exist
52
-		 */
53
-		public function delete($key);
47
+        /**
48
+         * Delete the cache data for given key
49
+         * @param  string $key the key for cache to be deleted
50
+         * @return boolean      true if the cache is deleted, false if can't delete 
51
+         * the cache or the cache with the given key not exist
52
+         */
53
+        public function delete($key);
54 54
 		
55 55
 		
56
-		/**
57
-		 * Get the cache information for given key
58
-		 * @param  string $key the key for cache to get the information for
59
-		 * @return boolean|array    the cache information. The associative array and must contains the following information:
60
-		 * 'mtime' => creation time of the cache (Unix timestamp),
61
-		 * 'expire' => expiration time of the cache (Unix timestamp),
62
-		 * 'ttl' => the time to live of the cache in second
63
-		 */
64
-		public function getInfo($key);
56
+        /**
57
+         * Get the cache information for given key
58
+         * @param  string $key the key for cache to get the information for
59
+         * @return boolean|array    the cache information. The associative array and must contains the following information:
60
+         * 'mtime' => creation time of the cache (Unix timestamp),
61
+         * 'expire' => expiration time of the cache (Unix timestamp),
62
+         * 'ttl' => the time to live of the cache in second
63
+         */
64
+        public function getInfo($key);
65 65
 
66 66
 
67
-		/**
68
-		 * Used to delete expired cache data
69
-		 */
70
-		public function deleteExpiredCache();
67
+        /**
68
+         * Used to delete expired cache data
69
+         */
70
+        public function deleteExpiredCache();
71 71
 
72
-		/**
73
-		 * Remove all cache data
74
-		 */
75
-		public function clean();
72
+        /**
73
+         * Remove all cache data
74
+         */
75
+        public function clean();
76 76
 		
77 77
 		
78
-		/**
79
-		 * Check whether the cache feature for the handle is supported
80
-		 *
81
-		 * @return bool
82
-		 */
83
-		public function isSupported();
84
-	}
78
+        /**
79
+         * Check whether the cache feature for the handle is supported
80
+         *
81
+         * @return bool
82
+         */
83
+        public function isSupported();
84
+    }
Please login to merge, or discard this patch.
core/classes/Url.php 3 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -25,15 +25,15 @@  discard block
 block discarded – undo
25 25
 	*/
26 26
 
27 27
 
28
-	class Url{
28
+	class Url {
29 29
 
30 30
 		/**
31 31
 		 * Return the link using base_url config without front controller "index.php"
32 32
 		 * @param  string $path the link path or full URL
33 33
 		 * @return string the full link URL
34 34
 		 */
35
-		public static function base_url($path = ''){
36
-			if(is_url($path)){
35
+		public static function base_url($path = '') {
36
+			if (is_url($path)) {
37 37
 				return $path;
38 38
 			}
39 39
 			return get_config('base_url') . $path;
@@ -44,26 +44,26 @@  discard block
 block discarded – undo
44 44
 		 * @param  string $path the link path or full URL
45 45
 		 * @return string the full link URL
46 46
 		 */
47
-		public static function site_url($path = ''){
48
-			if(is_url($path)){
47
+		public static function site_url($path = '') {
48
+			if (is_url($path)) {
49 49
 				return $path;
50 50
 			}
51 51
 			$path = rtrim($path, '/');
52 52
 			$baseUrl = get_config('base_url');
53 53
 			$frontController = get_config('front_controller');
54 54
 			$url = $baseUrl;
55
-			if($frontController){
55
+			if ($frontController) {
56 56
 				$url .= $frontController . '/';
57 57
 			}
58
-			if(($suffix = get_config('url_suffix')) && $path){
59
-				if(strpos($path, '?') !== false){
58
+			if (($suffix = get_config('url_suffix')) && $path) {
59
+				if (strpos($path, '?') !== false) {
60 60
 					$query = explode('?', $path);
61 61
 					$query[0] = str_ireplace($suffix, '', $query[0]);
62 62
 					$query[0] = rtrim($query[0], '/');
63 63
 					$query[0] .= $suffix;
64 64
 					$path = implode('?', $query);
65 65
 				}
66
-				else{
66
+				else {
67 67
 					$path .= $suffix;
68 68
 				}
69 69
 			}
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
 		 * Return the current site URL
75 75
 		 * @return string
76 76
 		 */
77
-		public static function current(){
77
+		public static function current() {
78 78
 			$current = '/';
79 79
 			$requestUri = get_instance()->request->requestUri();
80
-			if($requestUri){
80
+			if ($requestUri) {
81 81
 				$current = $requestUri;
82 82
 			}
83 83
 			return static::domain() . $current;
@@ -90,18 +90,18 @@  discard block
 block discarded – undo
90 90
 		 * @param  boolean $lowercase whether to set the final text to lowe case or not
91 91
 		 * @return string the friendly generated text
92 92
 		 */
93
-		public static function title($str = null, $separator = '-', $lowercase = true){
93
+		public static function title($str = null, $separator = '-', $lowercase = true) {
94 94
 			$str = trim($str);
95
-			$from = array('ç','À','Á','Â','Ã','Ä','Å','à','á','â','ã','ä','å','Ò','Ó','Ô','Õ','Ö','Ø','ò','ó','ô','õ','ö','ø','È','É','Ê','Ë','è','é','ê','ë','Ç','ç','Ì','Í','Î','Ï','ì','í','î','ï','Ù','Ú','Û','Ü','ù','ú','û','ü','ÿ','Ñ','ñ');
96
-			$to = array('c','a','a','a','a','a','a','a','a','a','a','a','a','o','o','o','o','o','o','o','o','o','o','o','o','e','e','e','e','e','e','e','e','e','e','i','i','i','i','i','i','i','i','u','u','u','u','u','u','u','u','y','n','n');
95
+			$from = array('ç', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'à', 'á', 'â', 'ã', 'ä', 'å', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'È', 'É', 'Ê', 'Ë', 'è', 'é', 'ê', 'ë', 'Ç', 'ç', 'Ì', 'Í', 'Î', 'Ï', 'ì', 'í', 'î', 'ï', 'Ù', 'Ú', 'Û', 'Ü', 'ù', 'ú', 'û', 'ü', 'ÿ', 'Ñ', 'ñ');
96
+			$to = array('c', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'i', 'i', 'i', 'i', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'y', 'n', 'n');
97 97
 			$str = str_replace($from, $to, $str);
98 98
 			$str = preg_replace('#([^a-z0-9]+)#i', $separator, $str);
99 99
 			$str = str_replace('--', $separator, $str);
100 100
 			//if after process we get something like one-two-three-, need truncate the last separator "-"
101
-			if(substr($str, -1) == $separator){
101
+			if (substr($str, -1) == $separator) {
102 102
 				$str = substr($str, 0, -1);
103 103
 			}
104
-			if($lowercase){
104
+			if ($lowercase) {
105 105
 				$str = strtolower($str);
106 106
 			}
107 107
 			return $str;
@@ -111,36 +111,36 @@  discard block
 block discarded – undo
111 111
 		 * Get the current application domain with protocol
112 112
 		 * @return string the domain name
113 113
 		 */
114
-		public static function domain(){
114
+		public static function domain() {
115 115
 			$obj = & get_instance();
116 116
 			$domain = 'localhost';
117 117
 			$port = $obj->request->server('SERVER_PORT');
118 118
 			$protocol = is_https() ? 'https' : 'http';
119 119
 			
120
-			if($obj->request->server('HTTP_HOST')){
120
+			if ($obj->request->server('HTTP_HOST')) {
121 121
 				$domain = $obj->request->server('HTTP_HOST');
122 122
 			}
123
-			else if($obj->request->server('SERVER_NAME')){
123
+			else if ($obj->request->server('SERVER_NAME')) {
124 124
 				$domain = $obj->request->server('SERVER_NAME');
125 125
 			}
126
-			else if($obj->request->server('SERVER_ADDR')){
126
+			else if ($obj->request->server('SERVER_ADDR')) {
127 127
 				$domain = $obj->request->server('SERVER_ADDR');
128 128
 			}
129
-			if($port && (is_https() && $port != 443 || !is_https() && $port != 80)){
129
+			if ($port && (is_https() && $port != 443 || !is_https() && $port != 80)) {
130 130
 				//some server use SSL but the port doesn't equal 443 sometime is 80 if is the case put the port at this end
131 131
 				//of the domain like https://my.domain.com:787
132
-				if(is_https() && $port != 80){
133
-					$domain .= ':'.$port;
132
+				if (is_https() && $port != 80) {
133
+					$domain .= ':' . $port;
134 134
 				}
135 135
 			}
136
-			return $protocol.'://'.$domain;
136
+			return $protocol . '://' . $domain;
137 137
 		}
138 138
 
139 139
 		/**
140 140
 		 * Get the current request query string
141 141
 		 * @return string
142 142
 		 */
143
-		public static function queryString(){
143
+		public static function queryString() {
144 144
 			return get_instance()->request->server('QUERY_STRING');
145 145
 		}
146 146
 	}
147 147
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -62,8 +62,7 @@  discard block
 block discarded – undo
62 62
 					$query[0] = rtrim($query[0], '/');
63 63
 					$query[0] .= $suffix;
64 64
 					$path = implode('?', $query);
65
-				}
66
-				else{
65
+				} else{
67 66
 					$path .= $suffix;
68 67
 				}
69 68
 			}
@@ -119,11 +118,9 @@  discard block
 block discarded – undo
119 118
 			
120 119
 			if($obj->request->server('HTTP_HOST')){
121 120
 				$domain = $obj->request->server('HTTP_HOST');
122
-			}
123
-			else if($obj->request->server('SERVER_NAME')){
121
+			} else if($obj->request->server('SERVER_NAME')){
124 122
 				$domain = $obj->request->server('SERVER_NAME');
125
-			}
126
-			else if($obj->request->server('SERVER_ADDR')){
123
+			} else if($obj->request->server('SERVER_ADDR')){
127 124
 				$domain = $obj->request->server('SERVER_ADDR');
128 125
 			}
129 126
 			if($port && (is_https() && $port != 443 || !is_https() && $port != 80)){
Please login to merge, or discard this patch.
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -1,146 +1,146 @@
 block discarded – undo
1 1
 <?php
2
-	defined('ROOT_PATH') or exit('Access denied');
3
-	/**
4
-	 * TNH Framework
5
-	 *
6
-	 * A simple PHP framework using HMVC architecture
7
-	 *
8
-	 * This content is released under the GNU GPL License (GPL)
9
-	 *
10
-	 * Copyright (C) 2017 Tony NGUEREZA
11
-	 *
12
-	 * This program is free software; you can redistribute it and/or
13
-	 * modify it under the terms of the GNU General Public License
14
-	 * as published by the Free Software Foundation; either version 3
15
-	 * of the License, or (at your option) any later version.
16
-	 *
17
-	 * This program is distributed in the hope that it will be useful,
18
-	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
-	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
-	 * GNU General Public License for more details.
21
-	 *
22
-	 * You should have received a copy of the GNU General Public License
23
-	 * along with this program; if not, write to the Free Software
24
-	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
-	*/
2
+    defined('ROOT_PATH') or exit('Access denied');
3
+    /**
4
+     * TNH Framework
5
+     *
6
+     * A simple PHP framework using HMVC architecture
7
+     *
8
+     * This content is released under the GNU GPL License (GPL)
9
+     *
10
+     * Copyright (C) 2017 Tony NGUEREZA
11
+     *
12
+     * This program is free software; you can redistribute it and/or
13
+     * modify it under the terms of the GNU General Public License
14
+     * as published by the Free Software Foundation; either version 3
15
+     * of the License, or (at your option) any later version.
16
+     *
17
+     * This program is distributed in the hope that it will be useful,
18
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+     * GNU General Public License for more details.
21
+     *
22
+     * You should have received a copy of the GNU General Public License
23
+     * along with this program; if not, write to the Free Software
24
+     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
+     */
26 26
 
27 27
 
28
-	class Url{
28
+    class Url{
29 29
 
30
-		/**
31
-		 * Return the link using base_url config without front controller "index.php"
32
-		 * @param  string $path the link path or full URL
33
-		 * @return string the full link URL
34
-		 */
35
-		public static function base_url($path = ''){
36
-			if(is_url($path)){
37
-				return $path;
38
-			}
39
-			return get_config('base_url') . $path;
40
-		}
30
+        /**
31
+         * Return the link using base_url config without front controller "index.php"
32
+         * @param  string $path the link path or full URL
33
+         * @return string the full link URL
34
+         */
35
+        public static function base_url($path = ''){
36
+            if(is_url($path)){
37
+                return $path;
38
+            }
39
+            return get_config('base_url') . $path;
40
+        }
41 41
 
42
-		/**
43
-		 * Return the link using base_url config with front controller "index.php"
44
-		 * @param  string $path the link path or full URL
45
-		 * @return string the full link URL
46
-		 */
47
-		public static function site_url($path = ''){
48
-			if(is_url($path)){
49
-				return $path;
50
-			}
51
-			$path = rtrim($path, '/');
52
-			$baseUrl = get_config('base_url');
53
-			$frontController = get_config('front_controller');
54
-			$url = $baseUrl;
55
-			if($frontController){
56
-				$url .= $frontController . '/';
57
-			}
58
-			if(($suffix = get_config('url_suffix')) && $path){
59
-				if(strpos($path, '?') !== false){
60
-					$query = explode('?', $path);
61
-					$query[0] = str_ireplace($suffix, '', $query[0]);
62
-					$query[0] = rtrim($query[0], '/');
63
-					$query[0] .= $suffix;
64
-					$path = implode('?', $query);
65
-				}
66
-				else{
67
-					$path .= $suffix;
68
-				}
69
-			}
70
-			return $url . $path;
71
-		}
42
+        /**
43
+         * Return the link using base_url config with front controller "index.php"
44
+         * @param  string $path the link path or full URL
45
+         * @return string the full link URL
46
+         */
47
+        public static function site_url($path = ''){
48
+            if(is_url($path)){
49
+                return $path;
50
+            }
51
+            $path = rtrim($path, '/');
52
+            $baseUrl = get_config('base_url');
53
+            $frontController = get_config('front_controller');
54
+            $url = $baseUrl;
55
+            if($frontController){
56
+                $url .= $frontController . '/';
57
+            }
58
+            if(($suffix = get_config('url_suffix')) && $path){
59
+                if(strpos($path, '?') !== false){
60
+                    $query = explode('?', $path);
61
+                    $query[0] = str_ireplace($suffix, '', $query[0]);
62
+                    $query[0] = rtrim($query[0], '/');
63
+                    $query[0] .= $suffix;
64
+                    $path = implode('?', $query);
65
+                }
66
+                else{
67
+                    $path .= $suffix;
68
+                }
69
+            }
70
+            return $url . $path;
71
+        }
72 72
 
73
-		/**
74
-		 * Return the current site URL
75
-		 * @return string
76
-		 */
77
-		public static function current(){
78
-			$current = '/';
79
-			$requestUri = get_instance()->request->requestUri();
80
-			if($requestUri){
81
-				$current = $requestUri;
82
-			}
83
-			return static::domain() . $current;
84
-		}
73
+        /**
74
+         * Return the current site URL
75
+         * @return string
76
+         */
77
+        public static function current(){
78
+            $current = '/';
79
+            $requestUri = get_instance()->request->requestUri();
80
+            if($requestUri){
81
+                $current = $requestUri;
82
+            }
83
+            return static::domain() . $current;
84
+        }
85 85
 
86
-		/**
87
-		 * Generate a friendly  text to use in link (slugs)
88
-		 * @param  string  $str       the title or text to use to get the friendly text
89
-		 * @param  string  $separator the caracters separator
90
-		 * @param  boolean $lowercase whether to set the final text to lowe case or not
91
-		 * @return string the friendly generated text
92
-		 */
93
-		public static function title($str = null, $separator = '-', $lowercase = true){
94
-			$str = trim($str);
95
-			$from = array('ç','À','Á','Â','Ã','Ä','Å','à','á','â','ã','ä','å','Ò','Ó','Ô','Õ','Ö','Ø','ò','ó','ô','õ','ö','ø','È','É','Ê','Ë','è','é','ê','ë','Ç','ç','Ì','Í','Î','Ï','ì','í','î','ï','Ù','Ú','Û','Ü','ù','ú','û','ü','ÿ','Ñ','ñ');
96
-			$to = array('c','a','a','a','a','a','a','a','a','a','a','a','a','o','o','o','o','o','o','o','o','o','o','o','o','e','e','e','e','e','e','e','e','e','e','i','i','i','i','i','i','i','i','u','u','u','u','u','u','u','u','y','n','n');
97
-			$str = str_replace($from, $to, $str);
98
-			$str = preg_replace('#([^a-z0-9]+)#i', $separator, $str);
99
-			$str = str_replace('--', $separator, $str);
100
-			//if after process we get something like one-two-three-, need truncate the last separator "-"
101
-			if(substr($str, -1) == $separator){
102
-				$str = substr($str, 0, -1);
103
-			}
104
-			if($lowercase){
105
-				$str = strtolower($str);
106
-			}
107
-			return $str;
108
-		}
86
+        /**
87
+         * Generate a friendly  text to use in link (slugs)
88
+         * @param  string  $str       the title or text to use to get the friendly text
89
+         * @param  string  $separator the caracters separator
90
+         * @param  boolean $lowercase whether to set the final text to lowe case or not
91
+         * @return string the friendly generated text
92
+         */
93
+        public static function title($str = null, $separator = '-', $lowercase = true){
94
+            $str = trim($str);
95
+            $from = array('ç','À','Á','Â','Ã','Ä','Å','à','á','â','ã','ä','å','Ò','Ó','Ô','Õ','Ö','Ø','ò','ó','ô','õ','ö','ø','È','É','Ê','Ë','è','é','ê','ë','Ç','ç','Ì','Í','Î','Ï','ì','í','î','ï','Ù','Ú','Û','Ü','ù','ú','û','ü','ÿ','Ñ','ñ');
96
+            $to = array('c','a','a','a','a','a','a','a','a','a','a','a','a','o','o','o','o','o','o','o','o','o','o','o','o','e','e','e','e','e','e','e','e','e','e','i','i','i','i','i','i','i','i','u','u','u','u','u','u','u','u','y','n','n');
97
+            $str = str_replace($from, $to, $str);
98
+            $str = preg_replace('#([^a-z0-9]+)#i', $separator, $str);
99
+            $str = str_replace('--', $separator, $str);
100
+            //if after process we get something like one-two-three-, need truncate the last separator "-"
101
+            if(substr($str, -1) == $separator){
102
+                $str = substr($str, 0, -1);
103
+            }
104
+            if($lowercase){
105
+                $str = strtolower($str);
106
+            }
107
+            return $str;
108
+        }
109 109
 
110
-		/**
111
-		 * Get the current application domain with protocol
112
-		 * @return string the domain name
113
-		 */
114
-		public static function domain(){
115
-			$obj = & get_instance();
116
-			$domain = 'localhost';
117
-			$port = $obj->request->server('SERVER_PORT');
118
-			$protocol = is_https() ? 'https' : 'http';
110
+        /**
111
+         * Get the current application domain with protocol
112
+         * @return string the domain name
113
+         */
114
+        public static function domain(){
115
+            $obj = & get_instance();
116
+            $domain = 'localhost';
117
+            $port = $obj->request->server('SERVER_PORT');
118
+            $protocol = is_https() ? 'https' : 'http';
119 119
 			
120
-			if($obj->request->server('HTTP_HOST')){
121
-				$domain = $obj->request->server('HTTP_HOST');
122
-			}
123
-			else if($obj->request->server('SERVER_NAME')){
124
-				$domain = $obj->request->server('SERVER_NAME');
125
-			}
126
-			else if($obj->request->server('SERVER_ADDR')){
127
-				$domain = $obj->request->server('SERVER_ADDR');
128
-			}
129
-			if($port && (is_https() && $port != 443 || !is_https() && $port != 80)){
130
-				//some server use SSL but the port doesn't equal 443 sometime is 80 if is the case put the port at this end
131
-				//of the domain like https://my.domain.com:787
132
-				if(is_https() && $port != 80){
133
-					$domain .= ':'.$port;
134
-				}
135
-			}
136
-			return $protocol.'://'.$domain;
137
-		}
120
+            if($obj->request->server('HTTP_HOST')){
121
+                $domain = $obj->request->server('HTTP_HOST');
122
+            }
123
+            else if($obj->request->server('SERVER_NAME')){
124
+                $domain = $obj->request->server('SERVER_NAME');
125
+            }
126
+            else if($obj->request->server('SERVER_ADDR')){
127
+                $domain = $obj->request->server('SERVER_ADDR');
128
+            }
129
+            if($port && (is_https() && $port != 443 || !is_https() && $port != 80)){
130
+                //some server use SSL but the port doesn't equal 443 sometime is 80 if is the case put the port at this end
131
+                //of the domain like https://my.domain.com:787
132
+                if(is_https() && $port != 80){
133
+                    $domain .= ':'.$port;
134
+                }
135
+            }
136
+            return $protocol.'://'.$domain;
137
+        }
138 138
 
139
-		/**
140
-		 * Get the current request query string
141
-		 * @return string
142
-		 */
143
-		public static function queryString(){
144
-			return get_instance()->request->server('QUERY_STRING');
145
-		}
146
-	}
147 139
\ No newline at end of file
140
+        /**
141
+         * Get the current request query string
142
+         * @return string
143
+         */
144
+        public static function queryString(){
145
+            return get_instance()->request->server('QUERY_STRING');
146
+        }
147
+    }
148 148
\ No newline at end of file
Please login to merge, or discard this patch.
core/classes/Session.php 3 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -90,8 +90,7 @@  discard block
 block discarded – undo
90 90
 			($_SESSION[$key]) : $default;
91 91
 			if(array_key_exists($key, $_SESSION)){
92 92
 				unset($_SESSION[$key]);
93
-			}
94
-			else{
93
+			} else{
95 94
 				$logger->warning('Cannot find session flash item ['. $key .'] using the default value ['. $default .']');
96 95
 			}
97 96
 			return $return;
@@ -126,8 +125,7 @@  discard block
 block discarded – undo
126 125
 			if(array_key_exists($item, $_SESSION)){
127 126
 				$logger->info('Deleting of session for item ['.$item.' ]');
128 127
 				unset($_SESSION[$item]);
129
-			}
130
-			else{
128
+			} else{
131 129
 				$logger->warning('Session item ['.$item.'] to be deleted does not exists');
132 130
 			}
133 131
 		}
@@ -142,8 +140,7 @@  discard block
 block discarded – undo
142 140
 			if(array_key_exists($key, $_SESSION)){
143 141
 				$logger->info('Delete session flash for item ['.$item.']');
144 142
 				unset($_SESSION[$item]);
145
-			}
146
-			else{
143
+			} else{
147 144
 				$logger->warning('Dession flash item ['.$item.'] to be deleted does not exists');
148 145
 			}
149 146
 		}
Please login to merge, or discard this 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.
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -1,168 +1,168 @@
 block discarded – undo
1 1
 <?php
2
-	defined('ROOT_PATH') or exit('Access denied');
3
-	/**
4
-	 * TNH Framework
5
-	 *
6
-	 * A simple PHP framework using HMVC architecture
7
-	 *
8
-	 * This content is released under the GNU GPL License (GPL)
9
-	 *
10
-	 * Copyright (C) 2017 Tony NGUEREZA
11
-	 *
12
-	 * This program is free software; you can redistribute it and/or
13
-	 * modify it under the terms of the GNU General Public License
14
-	 * as published by the Free Software Foundation; either version 3
15
-	 * of the License, or (at your option) any later version.
16
-	 *
17
-	 * This program is distributed in the hope that it will be useful,
18
-	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
-	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
-	 * GNU General Public License for more details.
21
-	 *
22
-	 * You should have received a copy of the GNU General Public License
23
-	 * along with this program; if not, write to the Free Software
24
-	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
-	*/
26
-	class Session{
2
+    defined('ROOT_PATH') or exit('Access denied');
3
+    /**
4
+     * TNH Framework
5
+     *
6
+     * A simple PHP framework using HMVC architecture
7
+     *
8
+     * This content is released under the GNU GPL License (GPL)
9
+     *
10
+     * Copyright (C) 2017 Tony NGUEREZA
11
+     *
12
+     * This program is free software; you can redistribute it and/or
13
+     * modify it under the terms of the GNU General Public License
14
+     * as published by the Free Software Foundation; either version 3
15
+     * of the License, or (at your option) any later version.
16
+     *
17
+     * This program is distributed in the hope that it will be useful,
18
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+     * GNU General Public License for more details.
21
+     *
22
+     * You should have received a copy of the GNU General Public License
23
+     * along with this program; if not, write to the Free Software
24
+     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
+     */
26
+    class Session{
27 27
 		
28
-		/**
29
-		 * The session flash key to use
30
-		 * @const
31
-		 */
32
-		const SESSION_FLASH_KEY = 'session_flash';
28
+        /**
29
+         * The session flash key to use
30
+         * @const
31
+         */
32
+        const SESSION_FLASH_KEY = 'session_flash';
33 33
 
34
-		/**
35
-		 * The logger instance
36
-		 * @var Log
37
-		 */
38
-		private static $logger;
34
+        /**
35
+         * The logger instance
36
+         * @var Log
37
+         */
38
+        private static $logger;
39 39
 
40
-		/**
41
-		 * Get the logger singleton instance
42
-		 * @return Log the logger instance
43
-		 */
44
-		private static function getLogger(){
45
-			if(self::$logger == null){
46
-				self::$logger[0] =& class_loader('Log', 'classes');
47
-				self::$logger[0]->setLogger('Library::Session');
48
-			}
49
-			return self::$logger[0];
50
-		}
40
+        /**
41
+         * Get the logger singleton instance
42
+         * @return Log the logger instance
43
+         */
44
+        private static function getLogger(){
45
+            if(self::$logger == null){
46
+                self::$logger[0] =& class_loader('Log', 'classes');
47
+                self::$logger[0]->setLogger('Library::Session');
48
+            }
49
+            return self::$logger[0];
50
+        }
51 51
 
52
-		/**
53
-		 * Get the session item value
54
-		 * @param  string $item    the session item name to get
55
-		 * @param  mixed $default the default value to use if can not find the session item in the list
56
-		 * @return mixed          the session value if exist or the default value
57
-		 */
58
-		public static function get($item, $default = null){
59
-			$logger = self::getLogger();
60
-			$logger->debug('Getting session data for item [' .$item. '] ...');
61
-			if(array_key_exists($item, $_SESSION)){
62
-				$logger->info('Found session data for item [' . $item . '] the vaue is : [' . stringfy_vars($_SESSION[$item]) . ']');
63
-				return $_SESSION[$item];
64
-			}
65
-			$logger->warning('Cannot find session item [' . $item . '] using the default value ['. $default . ']');
66
-			return $default;
67
-		}
52
+        /**
53
+         * Get the session item value
54
+         * @param  string $item    the session item name to get
55
+         * @param  mixed $default the default value to use if can not find the session item in the list
56
+         * @return mixed          the session value if exist or the default value
57
+         */
58
+        public static function get($item, $default = null){
59
+            $logger = self::getLogger();
60
+            $logger->debug('Getting session data for item [' .$item. '] ...');
61
+            if(array_key_exists($item, $_SESSION)){
62
+                $logger->info('Found session data for item [' . $item . '] the vaue is : [' . stringfy_vars($_SESSION[$item]) . ']');
63
+                return $_SESSION[$item];
64
+            }
65
+            $logger->warning('Cannot find session item [' . $item . '] using the default value ['. $default . ']');
66
+            return $default;
67
+        }
68 68
 
69
-		/**
70
-		 * Set the session item value
71
-		 * @param string $item  the session item name to set
72
-		 * @param mixed $value the session item value
73
-		 */
74
-		public static function set($item, $value){
75
-			$logger = self::getLogger();
76
-			$logger->debug('Setting session data for item [' . $item . '], value [' . stringfy_vars($value) . ']');
77
-			$_SESSION[$item] = $value;
78
-		}
69
+        /**
70
+         * Set the session item value
71
+         * @param string $item  the session item name to set
72
+         * @param mixed $value the session item value
73
+         */
74
+        public static function set($item, $value){
75
+            $logger = self::getLogger();
76
+            $logger->debug('Setting session data for item [' . $item . '], value [' . stringfy_vars($value) . ']');
77
+            $_SESSION[$item] = $value;
78
+        }
79 79
 
80
-		/**
81
-		 * Get the session flash item value
82
-		 * @param  string $item    the session flash item name to get
83
-		 * @param  mixed $default the default value to use if can not find the session flash item in the list
84
-		 * @return mixed          the session flash value if exist or the default value
85
-		 */
86
-		public static function getFlash($item, $default = null){
87
-			$logger = self::getLogger();
88
-			$key = self::SESSION_FLASH_KEY.'_'.$item;
89
-			$return = array_key_exists($key, $_SESSION) ?
90
-			($_SESSION[$key]) : $default;
91
-			if(array_key_exists($key, $_SESSION)){
92
-				unset($_SESSION[$key]);
93
-			}
94
-			else{
95
-				$logger->warning('Cannot find session flash item ['. $key .'] using the default value ['. $default .']');
96
-			}
97
-			return $return;
98
-		}
80
+        /**
81
+         * Get the session flash item value
82
+         * @param  string $item    the session flash item name to get
83
+         * @param  mixed $default the default value to use if can not find the session flash item in the list
84
+         * @return mixed          the session flash value if exist or the default value
85
+         */
86
+        public static function getFlash($item, $default = null){
87
+            $logger = self::getLogger();
88
+            $key = self::SESSION_FLASH_KEY.'_'.$item;
89
+            $return = array_key_exists($key, $_SESSION) ?
90
+            ($_SESSION[$key]) : $default;
91
+            if(array_key_exists($key, $_SESSION)){
92
+                unset($_SESSION[$key]);
93
+            }
94
+            else{
95
+                $logger->warning('Cannot find session flash item ['. $key .'] using the default value ['. $default .']');
96
+            }
97
+            return $return;
98
+        }
99 99
 
100
-		/**
101
-		 * Check whether the given session flash item exists
102
-		 * @param  string  $item the session flash item name
103
-		 * @return boolean 
104
-		 */
105
-		public static function hasFlash($item){
106
-			$key = self::SESSION_FLASH_KEY.'_'.$item;
107
-			return array_key_exists($key, $_SESSION);
108
-		}
100
+        /**
101
+         * Check whether the given session flash item exists
102
+         * @param  string  $item the session flash item name
103
+         * @return boolean 
104
+         */
105
+        public static function hasFlash($item){
106
+            $key = self::SESSION_FLASH_KEY.'_'.$item;
107
+            return array_key_exists($key, $_SESSION);
108
+        }
109 109
 
110
-		/**
111
-		 * Set the session flash item value
112
-		 * @param string $item  the session flash item name to set
113
-		 * @param mixed $value the session flash item value
114
-		 */
115
-		public static function setFlash($item, $value){
116
-			$key = self::SESSION_FLASH_KEY.'_'.$item;
117
-			$_SESSION[$key] = $value;
118
-		}
110
+        /**
111
+         * Set the session flash item value
112
+         * @param string $item  the session flash item name to set
113
+         * @param mixed $value the session flash item value
114
+         */
115
+        public static function setFlash($item, $value){
116
+            $key = self::SESSION_FLASH_KEY.'_'.$item;
117
+            $_SESSION[$key] = $value;
118
+        }
119 119
 
120
-		/**
121
-		 * Clear the session item in the list
122
-		 * @param  string $item the session item name to be deleted
123
-		 */
124
-		public static function clear($item){
125
-			$logger = self::getLogger();
126
-			if(array_key_exists($item, $_SESSION)){
127
-				$logger->info('Deleting of session for item ['.$item.' ]');
128
-				unset($_SESSION[$item]);
129
-			}
130
-			else{
131
-				$logger->warning('Session item ['.$item.'] to be deleted does not exists');
132
-			}
133
-		}
120
+        /**
121
+         * Clear the session item in the list
122
+         * @param  string $item the session item name to be deleted
123
+         */
124
+        public static function clear($item){
125
+            $logger = self::getLogger();
126
+            if(array_key_exists($item, $_SESSION)){
127
+                $logger->info('Deleting of session for item ['.$item.' ]');
128
+                unset($_SESSION[$item]);
129
+            }
130
+            else{
131
+                $logger->warning('Session item ['.$item.'] to be deleted does not exists');
132
+            }
133
+        }
134 134
 		
135
-		/**
136
-		 * Clear the session flash item in the list
137
-		 * @param  string $item the session flash item name to be deleted
138
-		 */
139
-		public static function clearFlash($item){
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.']');
144
-				unset($_SESSION[$item]);
145
-			}
146
-			else{
147
-				$logger->warning('Dession flash item ['.$item.'] to be deleted does not exists');
148
-			}
149
-		}
135
+        /**
136
+         * Clear the session flash item in the list
137
+         * @param  string $item the session flash item name to be deleted
138
+         */
139
+        public static function clearFlash($item){
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.']');
144
+                unset($_SESSION[$item]);
145
+            }
146
+            else{
147
+                $logger->warning('Dession flash item ['.$item.'] to be deleted does not exists');
148
+            }
149
+        }
150 150
 
151
-		/**
152
-		 * Check whether the given session item exists
153
-		 * @param  string  $item the session item name
154
-		 * @return boolean 
155
-		 */
156
-		public static function exists($item){
157
-			return array_key_exists($item, $_SESSION);
158
-		}
151
+        /**
152
+         * Check whether the given session item exists
153
+         * @param  string  $item the session item name
154
+         * @return boolean 
155
+         */
156
+        public static function exists($item){
157
+            return array_key_exists($item, $_SESSION);
158
+        }
159 159
 
160
-		/**
161
-		 * Destroy all session data values
162
-		 */
163
-		public static function clearAll(){
164
-			session_unset();
165
-			session_destroy();
166
-		}
160
+        /**
161
+         * Destroy all session data values
162
+         */
163
+        public static function clearAll(){
164
+            session_unset();
165
+            session_destroy();
166
+        }
167 167
 
168
-	}
168
+    }
Please login to merge, or discard this patch.
core/classes/Lang.php 3 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -82,8 +82,7 @@  discard block
 block discarded – undo
82 82
 			if($cookieLang && $this->isValid($cookieLang)){
83 83
 				$this->current = $cookieLang;
84 84
 				$this->logger->info('Language from cookie [' .$cfgKey. '] is valid so we will set the language using the cookie value [' .$cookieLang. ']');
85
-			}
86
-			else{
85
+			} else{
87 86
 				$this->logger->info('Language from cookie [' .$cfgKey. '] is not set, use the default value [' .$this->getDefault(). ']');
88 87
 				$this->current = $this->getDefault();
89 88
 			}
@@ -171,8 +170,7 @@  discard block
 block discarded – undo
171 170
 			}
172 171
 			if($this->isValid($name)){
173 172
 				$this->availables[$name] = $description;
174
-			}
175
-			else{
173
+			} else{
176 174
 				show_error('The language [' . $name . '] is not valid or does not exists.');
177 175
 			}
178 176
 		}
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 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{
30
+	class Lang {
31 31
 		
32 32
 		/**
33 33
 		 * The supported available language for this application.
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 		/**
68 68
 		 * Construct new Lang instance
69 69
 		 */
70
-		public function __construct(){
71
-	        $this->logger =& class_loader('Log', 'classes');
70
+		public function __construct() {
71
+	        $this->logger = & class_loader('Log', 'classes');
72 72
 	        $this->logger->setLogger('Library::Lang');
73 73
 
74 74
 			$this->default = get_config('default_language', 'en');
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 			
77 77
 			//add the supported languages ('key', 'display name')
78 78
 			$languages = get_config('languages', null);
79
-			if(! empty($languages)){
80
-				foreach($languages as $key => $displayName){
79
+			if (!empty($languages)) {
80
+				foreach ($languages as $key => $displayName) {
81 81
 					$this->addLang($key, $displayName);
82 82
 				}
83 83
 			}
@@ -85,15 +85,15 @@  discard block
 block discarded – undo
85 85
 
86 86
 			//if the language exists in cookie use it
87 87
 			$cfgKey = get_config('language_cookie_name');
88
-			$this->logger->debug('Getting current language from cookie [' .$cfgKey. ']');
88
+			$this->logger->debug('Getting current language from cookie [' . $cfgKey . ']');
89 89
 			$objCookie = & class_loader('Cookie');
90 90
 			$cookieLang = $objCookie->get($cfgKey);
91
-			if($cookieLang && $this->isValid($cookieLang)){
91
+			if ($cookieLang && $this->isValid($cookieLang)) {
92 92
 				$this->current = $cookieLang;
93
-				$this->logger->info('Language from cookie [' .$cfgKey. '] is valid so we will set the language using the cookie value [' .$cookieLang. ']');
93
+				$this->logger->info('Language from cookie [' . $cfgKey . '] is valid so we will set the language using the cookie value [' . $cookieLang . ']');
94 94
 			}
95
-			else{
96
-				$this->logger->info('Language from cookie [' .$cfgKey. '] is not set, use the default value [' .$this->getDefault(). ']');
95
+			else {
96
+				$this->logger->info('Language from cookie [' . $cfgKey . '] is not set, use the default value [' . $this->getDefault() . ']');
97 97
 				$this->current = $this->getDefault();
98 98
 			}
99 99
 		}
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		 *
104 104
 		 * @return array the language message list
105 105
 		 */
106
-		public function getAll(){
106
+		public function getAll() {
107 107
 			return $this->languages;
108 108
 		}
109 109
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		 * @param string $key the language key to identify
114 114
 		 * @param string $value the language message value
115 115
 		 */
116
-		public function set($key, $value){
116
+		public function set($key, $value) {
117 117
 			$this->languages[$key] = $value;
118 118
 		}
119 119
 
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
 		 *
126 126
 		 * @return string the language message value
127 127
 		 */
128
-		public function get($key, $default = 'LANGUAGE_ERROR'){
129
-			if(isset($this->languages[$key])){
128
+		public function get($key, $default = 'LANGUAGE_ERROR') {
129
+			if (isset($this->languages[$key])) {
130 130
 				return $this->languages[$key];
131 131
 			}
132
-			$this->logger->warning('Language key  [' .$key. '] does not exist use the default value [' .$default. ']');
132
+			$this->logger->warning('Language key  [' . $key . '] does not exist use the default value [' . $default . ']');
133 133
 			return $default;
134 134
 		}
135 135
 
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
 		 *
141 141
 		 * @return boolean true if the language directory exists, false or not
142 142
 		 */
143
-		public function isValid($language){
143
+		public function isValid($language) {
144 144
 			$searchDir = array(CORE_LANG_PATH, APP_LANG_PATH);
145
-			foreach($searchDir as $dir){
146
-				if(file_exists($dir . $language) && is_dir($dir . $language)){
145
+			foreach ($searchDir as $dir) {
146
+				if (file_exists($dir . $language) && is_dir($dir . $language)) {
147 147
 					return true;
148 148
 				}
149 149
 			}
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 		 *
156 156
 		 * @return string the default language
157 157
 		 */
158
-		public function getDefault(){
158
+		public function getDefault() {
159 159
 			return $this->default;
160 160
 		}
161 161
 
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 		 *
165 165
 		 * @return string the current language
166 166
 		 */
167
-		public function getCurrent(){
167
+		public function getCurrent() {
168 168
 			return $this->current;
169 169
 		}
170 170
 
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 		 * @param string $name the short language name like "en", "fr".
175 175
 		 * @param string $description the human readable description of this language
176 176
 		 */
177
-		public function addLang($name, $description){
178
-			if(isset($this->availables[$name])){
177
+		public function addLang($name, $description) {
178
+			if (isset($this->availables[$name])) {
179 179
 				return; //already added cost in performance
180 180
 			}
181
-			if($this->isValid($name)){
181
+			if ($this->isValid($name)) {
182 182
 				$this->availables[$name] = $description;
183 183
 			}
184
-			else{
184
+			else {
185 185
 				show_error('The language [' . $name . '] is not valid or does not exists.');
186 186
 			}
187 187
 		}
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 		 *
192 192
 		 * @return array the list of the application language
193 193
 		 */
194
-		public function getSupported(){
194
+		public function getSupported() {
195 195
 			return $this->availables;
196 196
 		}
197 197
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 		 *
201 201
 		 * @param array $langs the languages array of the messages to be added
202 202
 		 */
203
-		public function addLangMessages(array $langs){
203
+		public function addLangMessages(array $langs) {
204 204
 			foreach ($langs as $key => $value) {
205 205
 				$this->set($key, $value);
206 206
 			}
Please login to merge, or discard this patch.
Indentation   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -1,208 +1,208 @@
 block discarded – undo
1 1
 <?php
2
-	defined('ROOT_PATH') || exit('Access denied');
3
-	/**
4
-	 * TNH Framework
5
-	 *
6
-	 * A simple PHP framework using HMVC architecture
7
-	 *
8
-	 * This content is released under the GNU GPL License (GPL)
9
-	 *
10
-	 * Copyright (C) 2017 Tony NGUEREZA
11
-	 *
12
-	 * This program is free software; you can redistribute it and/or
13
-	 * modify it under the terms of the GNU General Public License
14
-	 * as published by the Free Software Foundation; either version 3
15
-	 * of the License, or (at your option) any later version.
16
-	 *
17
-	 * This program is distributed in the hope that it will be useful,
18
-	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
-	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
-	 * GNU General Public License for more details.
21
-	 *
22
-	 * You should have received a copy of the GNU General Public License
23
-	 * along with this program; if not, write to the Free Software
24
-	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
-	*/
26
-
27
-	/**
28
-	 * For application languages management
29
-	 */
30
-	class Lang{
2
+    defined('ROOT_PATH') || exit('Access denied');
3
+    /**
4
+     * TNH Framework
5
+     *
6
+     * A simple PHP framework using HMVC architecture
7
+     *
8
+     * This content is released under the GNU GPL License (GPL)
9
+     *
10
+     * Copyright (C) 2017 Tony NGUEREZA
11
+     *
12
+     * This program is free software; you can redistribute it and/or
13
+     * modify it under the terms of the GNU General Public License
14
+     * as published by the Free Software Foundation; either version 3
15
+     * of the License, or (at your option) any later version.
16
+     *
17
+     * This program is distributed in the hope that it will be useful,
18
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+     * GNU General Public License for more details.
21
+     *
22
+     * You should have received a copy of the GNU General Public License
23
+     * along with this program; if not, write to the Free Software
24
+     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
+     */
26
+
27
+    /**
28
+     * For application languages management
29
+     */
30
+    class Lang{
31 31
 		
32
-		/**
33
-		 * The supported available language for this application.
34
-		 * @example "en" => "english" 
35
-		 * @see Lang::addLang()
36
-		 * @var array
37
-		 */
38
-		protected $availables = array();
39
-
40
-		/**
41
-		 * The all messages language
42
-		 * @var array
43
-		 */
44
-		protected $languages = array();
45
-
46
-		/**
47
-		 * The default language to use if can not
48
-		 *  determine the client language
49
-		 *  
50
-		 * @example $default = 'en'
51
-		 * @var string
52
-		 */
53
-		protected $default = null;
54
-
55
-		/**
56
-		 * The current client language
57
-		 * @var string
58
-		 */
59
-		protected $current = null;
60
-
61
-		/**
62
-		 * The logger instance
63
-		 * @var Log
64
-		 */
65
-		private $logger;
66
-
67
-		/**
68
-		 * Construct new Lang instance
69
-		 */
70
-		public function __construct(){
71
-	        $this->logger =& class_loader('Log', 'classes');
72
-	        $this->logger->setLogger('Library::Lang');
73
-
74
-			$this->default = get_config('default_language', 'en');
75
-			$this->logger->debug('Setting the supported languages');
32
+        /**
33
+         * The supported available language for this application.
34
+         * @example "en" => "english" 
35
+         * @see Lang::addLang()
36
+         * @var array
37
+         */
38
+        protected $availables = array();
39
+
40
+        /**
41
+         * The all messages language
42
+         * @var array
43
+         */
44
+        protected $languages = array();
45
+
46
+        /**
47
+         * The default language to use if can not
48
+         *  determine the client language
49
+         *  
50
+         * @example $default = 'en'
51
+         * @var string
52
+         */
53
+        protected $default = null;
54
+
55
+        /**
56
+         * The current client language
57
+         * @var string
58
+         */
59
+        protected $current = null;
60
+
61
+        /**
62
+         * The logger instance
63
+         * @var Log
64
+         */
65
+        private $logger;
66
+
67
+        /**
68
+         * Construct new Lang instance
69
+         */
70
+        public function __construct(){
71
+            $this->logger =& class_loader('Log', 'classes');
72
+            $this->logger->setLogger('Library::Lang');
73
+
74
+            $this->default = get_config('default_language', 'en');
75
+            $this->logger->debug('Setting the supported languages');
76 76
 			
77
-			//add the supported languages ('key', 'display name')
78
-			$languages = get_config('languages', null);
79
-			if(! empty($languages)){
80
-				foreach($languages as $key => $displayName){
81
-					$this->addLang($key, $displayName);
82
-				}
83
-			}
84
-			unset($languages);
85
-
86
-			//if the language exists in cookie use it
87
-			$cfgKey = get_config('language_cookie_name');
88
-			$this->logger->debug('Getting current language from cookie [' .$cfgKey. ']');
89
-			$objCookie = & class_loader('Cookie');
90
-			$cookieLang = $objCookie->get($cfgKey);
91
-			if($cookieLang && $this->isValid($cookieLang)){
92
-				$this->current = $cookieLang;
93
-				$this->logger->info('Language from cookie [' .$cfgKey. '] is valid so we will set the language using the cookie value [' .$cookieLang. ']');
94
-			}
95
-			else{
96
-				$this->logger->info('Language from cookie [' .$cfgKey. '] is not set, use the default value [' .$this->getDefault(). ']');
97
-				$this->current = $this->getDefault();
98
-			}
99
-		}
100
-
101
-		/**
102
-		 * Get the all languages messages
103
-		 *
104
-		 * @return array the language message list
105
-		 */
106
-		public function getAll(){
107
-			return $this->languages;
108
-		}
109
-
110
-		/**
111
-		 * Set the language message
112
-		 *
113
-		 * @param string $key the language key to identify
114
-		 * @param string $value the language message value
115
-		 */
116
-		public function set($key, $value){
117
-			$this->languages[$key] = $value;
118
-		}
119
-
120
-		/**
121
-		 * Get the language message for the given key. If can't find return the default value
122
-		 *
123
-		 * @param  string $key the message language key
124
-		 * @param  string $default the default value to return if can not found the language message key
125
-		 *
126
-		 * @return string the language message value
127
-		 */
128
-		public function get($key, $default = 'LANGUAGE_ERROR'){
129
-			if(isset($this->languages[$key])){
130
-				return $this->languages[$key];
131
-			}
132
-			$this->logger->warning('Language key  [' .$key. '] does not exist use the default value [' .$default. ']');
133
-			return $default;
134
-		}
135
-
136
-		/**
137
-		 * Check whether the language file for given name exists
138
-		 *
139
-		 * @param  string  $language the language name like "fr", "en", etc.
140
-		 *
141
-		 * @return boolean true if the language directory exists, false or not
142
-		 */
143
-		public function isValid($language){
144
-			$searchDir = array(CORE_LANG_PATH, APP_LANG_PATH);
145
-			foreach($searchDir as $dir){
146
-				if(file_exists($dir . $language) && is_dir($dir . $language)){
147
-					return true;
148
-				}
149
-			}
150
-			return false;
151
-		}
152
-
153
-		/**
154
-		 * Get the default language value like "en" , "fr", etc.
155
-		 *
156
-		 * @return string the default language
157
-		 */
158
-		public function getDefault(){
159
-			return $this->default;
160
-		}
161
-
162
-		/**
163
-		 * Get the current language defined by cookie or the default value
164
-		 *
165
-		 * @return string the current language
166
-		 */
167
-		public function getCurrent(){
168
-			return $this->current;
169
-		}
170
-
171
-		/**
172
-		 * Add new supported or available language
173
-		 *
174
-		 * @param string $name the short language name like "en", "fr".
175
-		 * @param string $description the human readable description of this language
176
-		 */
177
-		public function addLang($name, $description){
178
-			if(isset($this->availables[$name])){
179
-				return; //already added cost in performance
180
-			}
181
-			if($this->isValid($name)){
182
-				$this->availables[$name] = $description;
183
-			}
184
-			else{
185
-				show_error('The language [' . $name . '] is not valid or does not exists.');
186
-			}
187
-		}
188
-
189
-		/**
190
-		 * Get the list of the application supported language
191
-		 *
192
-		 * @return array the list of the application language
193
-		 */
194
-		public function getSupported(){
195
-			return $this->availables;
196
-		}
197
-
198
-		/**
199
-		 * Add new language messages
200
-		 *
201
-		 * @param array $langs the languages array of the messages to be added
202
-		 */
203
-		public function addLangMessages(array $langs){
204
-			foreach ($langs as $key => $value) {
205
-				$this->set($key, $value);
206
-			}
207
-		}
208
-	}
77
+            //add the supported languages ('key', 'display name')
78
+            $languages = get_config('languages', null);
79
+            if(! empty($languages)){
80
+                foreach($languages as $key => $displayName){
81
+                    $this->addLang($key, $displayName);
82
+                }
83
+            }
84
+            unset($languages);
85
+
86
+            //if the language exists in cookie use it
87
+            $cfgKey = get_config('language_cookie_name');
88
+            $this->logger->debug('Getting current language from cookie [' .$cfgKey. ']');
89
+            $objCookie = & class_loader('Cookie');
90
+            $cookieLang = $objCookie->get($cfgKey);
91
+            if($cookieLang && $this->isValid($cookieLang)){
92
+                $this->current = $cookieLang;
93
+                $this->logger->info('Language from cookie [' .$cfgKey. '] is valid so we will set the language using the cookie value [' .$cookieLang. ']');
94
+            }
95
+            else{
96
+                $this->logger->info('Language from cookie [' .$cfgKey. '] is not set, use the default value [' .$this->getDefault(). ']');
97
+                $this->current = $this->getDefault();
98
+            }
99
+        }
100
+
101
+        /**
102
+         * Get the all languages messages
103
+         *
104
+         * @return array the language message list
105
+         */
106
+        public function getAll(){
107
+            return $this->languages;
108
+        }
109
+
110
+        /**
111
+         * Set the language message
112
+         *
113
+         * @param string $key the language key to identify
114
+         * @param string $value the language message value
115
+         */
116
+        public function set($key, $value){
117
+            $this->languages[$key] = $value;
118
+        }
119
+
120
+        /**
121
+         * Get the language message for the given key. If can't find return the default value
122
+         *
123
+         * @param  string $key the message language key
124
+         * @param  string $default the default value to return if can not found the language message key
125
+         *
126
+         * @return string the language message value
127
+         */
128
+        public function get($key, $default = 'LANGUAGE_ERROR'){
129
+            if(isset($this->languages[$key])){
130
+                return $this->languages[$key];
131
+            }
132
+            $this->logger->warning('Language key  [' .$key. '] does not exist use the default value [' .$default. ']');
133
+            return $default;
134
+        }
135
+
136
+        /**
137
+         * Check whether the language file for given name exists
138
+         *
139
+         * @param  string  $language the language name like "fr", "en", etc.
140
+         *
141
+         * @return boolean true if the language directory exists, false or not
142
+         */
143
+        public function isValid($language){
144
+            $searchDir = array(CORE_LANG_PATH, APP_LANG_PATH);
145
+            foreach($searchDir as $dir){
146
+                if(file_exists($dir . $language) && is_dir($dir . $language)){
147
+                    return true;
148
+                }
149
+            }
150
+            return false;
151
+        }
152
+
153
+        /**
154
+         * Get the default language value like "en" , "fr", etc.
155
+         *
156
+         * @return string the default language
157
+         */
158
+        public function getDefault(){
159
+            return $this->default;
160
+        }
161
+
162
+        /**
163
+         * Get the current language defined by cookie or the default value
164
+         *
165
+         * @return string the current language
166
+         */
167
+        public function getCurrent(){
168
+            return $this->current;
169
+        }
170
+
171
+        /**
172
+         * Add new supported or available language
173
+         *
174
+         * @param string $name the short language name like "en", "fr".
175
+         * @param string $description the human readable description of this language
176
+         */
177
+        public function addLang($name, $description){
178
+            if(isset($this->availables[$name])){
179
+                return; //already added cost in performance
180
+            }
181
+            if($this->isValid($name)){
182
+                $this->availables[$name] = $description;
183
+            }
184
+            else{
185
+                show_error('The language [' . $name . '] is not valid or does not exists.');
186
+            }
187
+        }
188
+
189
+        /**
190
+         * Get the list of the application supported language
191
+         *
192
+         * @return array the list of the application language
193
+         */
194
+        public function getSupported(){
195
+            return $this->availables;
196
+        }
197
+
198
+        /**
199
+         * Add new language messages
200
+         *
201
+         * @param array $langs the languages array of the messages to be added
202
+         */
203
+        public function addLangMessages(array $langs){
204
+            foreach ($langs as $key => $value) {
205
+                $this->set($key, $value);
206
+            }
207
+        }
208
+    }
Please login to merge, or discard this patch.
core/classes/Security.php 3 patches
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -60,8 +60,7 @@  discard block
 block discarded – undo
60 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
-			}
64
-			else{
63
+			} else{
65 64
 				$newTime = $currentTime + $expire;
66 65
 				$token = sha1(uniqid()) . sha1(uniqid());
67 66
 				$logger->info('The CSRF informations are listed below: key [' .$key. '], key expire [' .$keyExpire. '], expire time [' .$expire. '], token [' .$token. ']');
@@ -87,8 +86,7 @@  discard block
 block discarded – undo
87 86
 			if(! Session::exists($key) || Session::get($keyExpire) <= $currentTime){
88 87
 				$logger->warning('The CSRF session data is not valide');
89 88
 				return false;
90
-			}
91
-			else{
89
+			} else{
92 90
 				//perform form data
93 91
 				//need use request->query() for best retrieve
94 92
 				//super instance
@@ -97,8 +95,7 @@  discard block
 block discarded – undo
97 95
 				if(! $token || $token !== Session::get($key) || Session::get($keyExpire) <= $currentTime){
98 96
 					$logger->warning('The CSRF data [' .$token. '] is not valide may be attacker do his job');
99 97
 					return false;
100
-				}
101
-				else{
98
+				} else{
102 99
 					$logger->info('The CSRF data [' .$token. '] is valide the form data is safe continue');
103 100
 					//remove the token from session
104 101
 					Session::clear($key);
@@ -127,8 +124,7 @@  discard block
 block discarded – undo
127 124
 						$logger->info('IP address ' . $ip . ' allowed using the wildcard "*" or the full IP');
128 125
 						//wildcard to access all ip address
129 126
 						return;
130
-					}
131
-					else{
127
+					} else{
132 128
 						// go through all whitelisted ips
133 129
 						foreach ($list as $ipaddr) {
134 130
 							// find the wild card * in whitelisted ip (f.e. find position in "127.0.*" or "127*")
@@ -153,8 +149,7 @@  discard block
 block discarded – undo
153 149
 						show_error('Access to this application is not allowed');
154 150
 					}
155 151
 				}
156
-			}
157
-			else{
152
+			} else{
158 153
 				$logger->info('Whitelist IP access is not enabled in the configuration, ignore checking');
159 154
 			}
160 155
 		 }
Please login to merge, or discard this 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.
Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -1,161 +1,161 @@
 block discarded – undo
1 1
 <?php
2
-	defined('ROOT_PATH') or exit('Access denied');
3
-	/**
4
-	 * TNH Framework
5
-	 *
6
-	 * A simple PHP framework using HMVC architecture
7
-	 *
8
-	 * This content is released under the GNU GPL License (GPL)
9
-	 *
10
-	 * Copyright (C) 2017 Tony NGUEREZA
11
-	 *
12
-	 * This program is free software; you can redistribute it and/or
13
-	 * modify it under the terms of the GNU General Public License
14
-	 * as published by the Free Software Foundation; either version 3
15
-	 * of the License, or (at your option) any later version.
16
-	 *
17
-	 * This program is distributed in the hope that it will be useful,
18
-	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
-	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
-	 * GNU General Public License for more details.
21
-	 *
22
-	 * You should have received a copy of the GNU General Public License
23
-	 * along with this program; if not, write to the Free Software
24
-	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
-	*/
2
+    defined('ROOT_PATH') or exit('Access denied');
3
+    /**
4
+     * TNH Framework
5
+     *
6
+     * A simple PHP framework using HMVC architecture
7
+     *
8
+     * This content is released under the GNU GPL License (GPL)
9
+     *
10
+     * Copyright (C) 2017 Tony NGUEREZA
11
+     *
12
+     * This program is free software; you can redistribute it and/or
13
+     * modify it under the terms of the GNU General Public License
14
+     * as published by the Free Software Foundation; either version 3
15
+     * of the License, or (at your option) any later version.
16
+     *
17
+     * This program is distributed in the hope that it will be useful,
18
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+     * GNU General Public License for more details.
21
+     *
22
+     * You should have received a copy of the GNU General Public License
23
+     * along with this program; if not, write to the Free Software
24
+     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
+     */
26 26
 
27
-	class Security{
27
+    class Security{
28 28
 		
29
-		/**
30
-		 * The logger instance
31
-		 * @var Log
32
-		 */
33
-		private static $logger;
29
+        /**
30
+         * The logger instance
31
+         * @var Log
32
+         */
33
+        private static $logger;
34 34
 
35
-		/**
36
-		 * Get the logger singleton instance
37
-		 * @return Log the logger instance
38
-		 */
39
-		private static function getLogger(){
40
-			if(self::$logger == null){
41
-				self::$logger[0] =& class_loader('Log', 'classes');
42
-				self::$logger[0]->setLogger('Library::Security');
43
-			}
44
-			return self::$logger[0];
45
-		}
35
+        /**
36
+         * Get the logger singleton instance
37
+         * @return Log the logger instance
38
+         */
39
+        private static function getLogger(){
40
+            if(self::$logger == null){
41
+                self::$logger[0] =& class_loader('Log', 'classes');
42
+                self::$logger[0]->setLogger('Library::Security');
43
+            }
44
+            return self::$logger[0];
45
+        }
46 46
 
47 47
 
48
-		/**
49
-		 * This method is used to generate the CSRF token
50
-		 * @return string the generated CSRF token
51
-		 */
52
-		public static function generateCSRF(){
53
-			$logger = self::getLogger();
54
-			$logger->debug('Generation of CSRF ...');
48
+        /**
49
+         * This method is used to generate the CSRF token
50
+         * @return string the generated CSRF token
51
+         */
52
+        public static function generateCSRF(){
53
+            $logger = self::getLogger();
54
+            $logger->debug('Generation of CSRF ...');
55 55
 			
56
-			$key = get_config('csrf_key', 'csrf_key');
57
-			$expire = get_config('csrf_expire', 60);
58
-			$keyExpire = 'csrf_expire';
59
-			$currentTime = time();
60
-			if(Session::exists($key) && Session::exists($keyExpire) && Session::get($keyExpire) > $currentTime){
61
-				$logger->info('The CSRF token not yet expire just return it');
62
-				return Session::get($key);
63
-			}
64
-			else{
65
-				$newTime = $currentTime + $expire;
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. ']');
68
-				Session::set($keyExpire, $newTime);
69
-				Session::set($key, $token);
70
-				return Session::get($key);
71
-			}
72
-		}
56
+            $key = get_config('csrf_key', 'csrf_key');
57
+            $expire = get_config('csrf_expire', 60);
58
+            $keyExpire = 'csrf_expire';
59
+            $currentTime = time();
60
+            if(Session::exists($key) && Session::exists($keyExpire) && Session::get($keyExpire) > $currentTime){
61
+                $logger->info('The CSRF token not yet expire just return it');
62
+                return Session::get($key);
63
+            }
64
+            else{
65
+                $newTime = $currentTime + $expire;
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. ']');
68
+                Session::set($keyExpire, $newTime);
69
+                Session::set($key, $token);
70
+                return Session::get($key);
71
+            }
72
+        }
73 73
 
74
-		/**
75
-		 * This method is used to check the CSRF if is valid, not yet expire, etc.
76
-		 * @return boolean true if valid, false if not valid
77
-		 */
78
-		public static function validateCSRF(){
79
-			$logger = self::getLogger();
80
-			$logger->debug('Validation of CSRF ...');
74
+        /**
75
+         * This method is used to check the CSRF if is valid, not yet expire, etc.
76
+         * @return boolean true if valid, false if not valid
77
+         */
78
+        public static function validateCSRF(){
79
+            $logger = self::getLogger();
80
+            $logger->debug('Validation of CSRF ...');
81 81
 				
82
-			$key = get_config('csrf_key', 'csrf_key');
83
-			$expire = get_config('csrf_expire', 60);
84
-			$keyExpire = 'csrf_expire';
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){
88
-				$logger->warning('The CSRF session data is not valide');
89
-				return false;
90
-			}
91
-			else{
92
-				//perform form data
93
-				//need use request->query() for best retrieve
94
-				//super instance
95
-				$obj = & get_instance();
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');
99
-					return false;
100
-				}
101
-				else{
102
-					$logger->info('The CSRF data [' .$token. '] is valide the form data is safe continue');
103
-					//remove the token from session
104
-					Session::clear($key);
105
-					Session::clear($keyExpire);
106
-					return true;
107
-				}
108
-			}
109
-		}
82
+            $key = get_config('csrf_key', 'csrf_key');
83
+            $expire = get_config('csrf_expire', 60);
84
+            $keyExpire = 'csrf_expire';
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){
88
+                $logger->warning('The CSRF session data is not valide');
89
+                return false;
90
+            }
91
+            else{
92
+                //perform form data
93
+                //need use request->query() for best retrieve
94
+                //super instance
95
+                $obj = & get_instance();
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');
99
+                    return false;
100
+                }
101
+                else{
102
+                    $logger->info('The CSRF data [' .$token. '] is valide the form data is safe continue');
103
+                    //remove the token from session
104
+                    Session::clear($key);
105
+                    Session::clear($keyExpire);
106
+                    return true;
107
+                }
108
+            }
109
+        }
110 110
 		
111
-		/**
112
-		 * This method is used to check the whitelist IP address access
113
-		 */
114
-		 public static function checkWhiteListIpAccess(){
115
-			$logger = self::getLogger();
116
-			$logger->debug('Validation of the IP address access ...');
117
-			$logger->debug('Check if whitelist IP access is enabled in the configuration ...');
118
-			$isEnable = get_config('white_list_ip_enable', false);
119
-			if($isEnable){
120
-				$logger->info('Whitelist IP access is enabled in the configuration');
121
-				$list = get_config('white_list_ip_addresses', array());
122
-				if(! empty($list)){
123
-					//Can't use Loader::functions() at this time because teh "Loader" library is loader after the security prossessing
124
-					require_once CORE_FUNCTIONS_PATH . 'function_user_agent.php';
125
-					$ip = get_ip();
126
-					if((count($list) == 1 && $list[0] == '*') || in_array($ip, $list)){
127
-						$logger->info('IP address ' . $ip . ' allowed using the wildcard "*" or the full IP');
128
-						//wildcard to access all ip address
129
-						return;
130
-					}
131
-					else{
132
-						// go through all whitelisted ips
133
-						foreach ($list as $ipaddr) {
134
-							// find the wild card * in whitelisted ip (f.e. find position in "127.0.*" or "127*")
135
-							$wildcardPosition = strpos($ipaddr, '*');
136
-							if ($wildcardPosition === false) {
137
-								// no wild card in whitelisted ip --continue searching
138
-								continue;
139
-							}
140
-							// cut ip at the position where we got the wild card on the whitelisted ip
141
-							// and add the wold card to get the same pattern
142
-							if (substr($ip, 0, $wildcardPosition) . '*' === $ipaddr) {
143
-								// f.e. we got
144
-								//  ip "127.0.0.1"
145
-								//  whitelisted ip "127.0.*"
146
-								// then we compared "127.0.*" with "127.0.*"
147
-								// return success
148
-								$logger->info('IP address ' . $ip . ' allowed using the wildcard like "x.x.x.*"');
149
-								return;
150
-							}
151
-						}
152
-						$logger->warning('IP address ' . $ip . ' is not allowed to access to this application');
153
-						show_error('Access to this application is not allowed');
154
-					}
155
-				}
156
-			}
157
-			else{
158
-				$logger->info('Whitelist IP access is not enabled in the configuration, ignore checking');
159
-			}
160
-		 }
161
-	}
111
+        /**
112
+         * This method is used to check the whitelist IP address access
113
+         */
114
+            public static function checkWhiteListIpAccess(){
115
+            $logger = self::getLogger();
116
+            $logger->debug('Validation of the IP address access ...');
117
+            $logger->debug('Check if whitelist IP access is enabled in the configuration ...');
118
+            $isEnable = get_config('white_list_ip_enable', false);
119
+            if($isEnable){
120
+                $logger->info('Whitelist IP access is enabled in the configuration');
121
+                $list = get_config('white_list_ip_addresses', array());
122
+                if(! empty($list)){
123
+                    //Can't use Loader::functions() at this time because teh "Loader" library is loader after the security prossessing
124
+                    require_once CORE_FUNCTIONS_PATH . 'function_user_agent.php';
125
+                    $ip = get_ip();
126
+                    if((count($list) == 1 && $list[0] == '*') || in_array($ip, $list)){
127
+                        $logger->info('IP address ' . $ip . ' allowed using the wildcard "*" or the full IP');
128
+                        //wildcard to access all ip address
129
+                        return;
130
+                    }
131
+                    else{
132
+                        // go through all whitelisted ips
133
+                        foreach ($list as $ipaddr) {
134
+                            // find the wild card * in whitelisted ip (f.e. find position in "127.0.*" or "127*")
135
+                            $wildcardPosition = strpos($ipaddr, '*');
136
+                            if ($wildcardPosition === false) {
137
+                                // no wild card in whitelisted ip --continue searching
138
+                                continue;
139
+                            }
140
+                            // cut ip at the position where we got the wild card on the whitelisted ip
141
+                            // and add the wold card to get the same pattern
142
+                            if (substr($ip, 0, $wildcardPosition) . '*' === $ipaddr) {
143
+                                // f.e. we got
144
+                                //  ip "127.0.0.1"
145
+                                //  whitelisted ip "127.0.*"
146
+                                // then we compared "127.0.*" with "127.0.*"
147
+                                // return success
148
+                                $logger->info('IP address ' . $ip . ' allowed using the wildcard like "x.x.x.*"');
149
+                                return;
150
+                            }
151
+                        }
152
+                        $logger->warning('IP address ' . $ip . ' is not allowed to access to this application');
153
+                        show_error('Access to this application is not allowed');
154
+                    }
155
+                }
156
+            }
157
+            else{
158
+                $logger->info('Whitelist IP access is not enabled in the configuration, ignore checking');
159
+            }
160
+            }
161
+    }
Please login to merge, or discard this patch.
core/classes/Request.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -103,8 +103,7 @@
 block discarded – undo
103 103
 			$this->header = array();
104 104
 			if(function_exists('apache_request_headers')){
105 105
 				$this->header = apache_request_headers();
106
-			}
107
-			else if(function_exists('getallheaders')){
106
+			} else if(function_exists('getallheaders')){
108 107
 				$this->header = getallheaders();
109 108
 			}
110 109
 		}
Please login to merge, or discard this 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.
Indentation   +231 added lines, -231 removed lines patch added patch discarded remove patch
@@ -1,256 +1,256 @@
 block discarded – undo
1 1
 <?php
2
-	defined('ROOT_PATH') or exit('Access denied');
3
-	/**
4
-	 * TNH Framework
5
-	 *
6
-	 * A simple PHP framework using HMVC architecture
7
-	 *
8
-	 * This content is released under the GNU GPL License (GPL)
9
-	 *
10
-	 * Copyright (C) 2017 Tony NGUEREZA
11
-	 *
12
-	 * This program is free software; you can redistribute it and/or
13
-	 * modify it under the terms of the GNU General Public License
14
-	 * as published by the Free Software Foundation; either version 3
15
-	 * of the License, or (at your option) any later version.
16
-	 *
17
-	 * This program is distributed in the hope that it will be useful,
18
-	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
-	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
-	 * GNU General Public License for more details.
21
-	 *
22
-	 * You should have received a copy of the GNU General Public License
23
-	 * along with this program; if not, write to the Free Software
24
-	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
-	*/
2
+    defined('ROOT_PATH') or exit('Access denied');
3
+    /**
4
+     * TNH Framework
5
+     *
6
+     * A simple PHP framework using HMVC architecture
7
+     *
8
+     * This content is released under the GNU GPL License (GPL)
9
+     *
10
+     * Copyright (C) 2017 Tony NGUEREZA
11
+     *
12
+     * This program is free software; you can redistribute it and/or
13
+     * modify it under the terms of the GNU General Public License
14
+     * as published by the Free Software Foundation; either version 3
15
+     * of the License, or (at your option) any later version.
16
+     *
17
+     * This program is distributed in the hope that it will be useful,
18
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+     * GNU General Public License for more details.
21
+     *
22
+     * You should have received a copy of the GNU General Public License
23
+     * along with this program; if not, write to the Free Software
24
+     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
+     */
26 26
 
27
-	class Request{
27
+    class Request{
28 28
 		
29
-		/**
30
-		 * The value for the super global $_GET
31
-		 * @var array
32
-		 */
33
-		public $get = null;
29
+        /**
30
+         * The value for the super global $_GET
31
+         * @var array
32
+         */
33
+        public $get = null;
34 34
 
35
-		/**
36
-		 * The value for the super global $_POST
37
-		 * @var array
38
-		 */
39
-		public $post = null;
35
+        /**
36
+         * The value for the super global $_POST
37
+         * @var array
38
+         */
39
+        public $post = null;
40 40
 
41
-		/**
42
-		 * The value for the super global $_SERVER
43
-		 * @var array
44
-		 */
45
-		public $server = null;
41
+        /**
42
+         * The value for the super global $_SERVER
43
+         * @var array
44
+         */
45
+        public $server = null;
46 46
 
47
-		/**
48
-		 * The value for the super global $_COOKIE
49
-		 * @var array
50
-		 */
51
-		public $cookie = null;
47
+        /**
48
+         * The value for the super global $_COOKIE
49
+         * @var array
50
+         */
51
+        public $cookie = null;
52 52
 
53
-		/**
54
-		 * The value for the super global $_FILES
55
-		 * @var array
56
-		 */
57
-		public $file = null;
53
+        /**
54
+         * The value for the super global $_FILES
55
+         * @var array
56
+         */
57
+        public $file = null;
58 58
 
59
-		/**
60
-		 * The value for the super global $_REQUEST
61
-		 * @var array
62
-		 */
63
-		public $query = null;
59
+        /**
60
+         * The value for the super global $_REQUEST
61
+         * @var array
62
+         */
63
+        public $query = null;
64 64
 		
65
-		/**
66
-		 * The session instance
67
-		 * @var Session
68
-		 */
69
-		public $session = null;
65
+        /**
66
+         * The session instance
67
+         * @var Session
68
+         */
69
+        public $session = null;
70 70
 		
71
-		/**
72
-		 * The request headers
73
-		 * @var array
74
-		 */
75
-		public $header = null;
71
+        /**
72
+         * The request headers
73
+         * @var array
74
+         */
75
+        public $header = null;
76 76
 
77
-		/**
78
-		 * The current request method 'GET', 'POST', 'PUT', etc.
79
-		 * @var null
80
-		 */
81
-		private $method = null;
77
+        /**
78
+         * The current request method 'GET', 'POST', 'PUT', etc.
79
+         * @var null
80
+         */
81
+        private $method = null;
82 82
 
83
-		/**
84
-		 * The current request URI
85
-		 * @var string
86
-		 */
87
-		private $requestUri = null;
83
+        /**
84
+         * The current request URI
85
+         * @var string
86
+         */
87
+        private $requestUri = null;
88 88
 		
89 89
 		
90
-		/**
91
-		 * Construct new request instance
92
-		 */
93
-		public function __construct(){
94
-			$this->get = $_GET;
95
-			$this->post = $_POST;
96
-			$this->server = $_SERVER;
97
-			$this->query = $_REQUEST;
98
-			$this->cookie = $_COOKIE;
99
-			$this->file = $_FILES;
100
-			$this->session =& class_loader('Session', 'classes');
101
-			$this->method = $this->server('REQUEST_METHOD');
102
-			$this->requestUri = $this->server('REQUEST_URI');
103
-			$this->header = array();
104
-			if(function_exists('apache_request_headers')){
105
-				$this->header = apache_request_headers();
106
-			}
107
-			else if(function_exists('getallheaders')){
108
-				$this->header = getallheaders();
109
-			}
110
-		}
90
+        /**
91
+         * Construct new request instance
92
+         */
93
+        public function __construct(){
94
+            $this->get = $_GET;
95
+            $this->post = $_POST;
96
+            $this->server = $_SERVER;
97
+            $this->query = $_REQUEST;
98
+            $this->cookie = $_COOKIE;
99
+            $this->file = $_FILES;
100
+            $this->session =& class_loader('Session', 'classes');
101
+            $this->method = $this->server('REQUEST_METHOD');
102
+            $this->requestUri = $this->server('REQUEST_URI');
103
+            $this->header = array();
104
+            if(function_exists('apache_request_headers')){
105
+                $this->header = apache_request_headers();
106
+            }
107
+            else if(function_exists('getallheaders')){
108
+                $this->header = getallheaders();
109
+            }
110
+        }
111 111
 
112
-		/**
113
-		 * Get the request method
114
-		 * @return string
115
-		 */
116
-		public function method(){
117
-			return $this->method;
118
-		}
112
+        /**
113
+         * Get the request method
114
+         * @return string
115
+         */
116
+        public function method(){
117
+            return $this->method;
118
+        }
119 119
 		
120
-		/**
121
-		 * Get the request URI
122
-		 * @return string
123
-		 */
124
-		public function requestUri(){
125
-			return $this->requestUri;
126
-		}
120
+        /**
121
+         * Get the request URI
122
+         * @return string
123
+         */
124
+        public function requestUri(){
125
+            return $this->requestUri;
126
+        }
127 127
 
128
-		/**
129
-		 * Get the value from $_REQUEST for given key. if the key is empty will return the all values
130
-		 * @param  string  $key the item key to be fetched
131
-		 * @param  boolean $xss if need apply some XSS attack rule on the value
132
-		 * @return array|mixed       the item value if the key exists or all array if the key does not exists or is empty
133
-		 */
134
-		public function query($key = null, $xss = true){
135
-			if(empty($key)){
136
-				//return all
137
-				return $xss ? clean_input($this->query) : $this->query;
138
-			}
139
-			$query = array_key_exists($key, $this->query) ? $this->query[$key] : null;
140
-			if($xss){
141
-				$query = clean_input($query);
142
-			}
143
-			return $query;
144
-		}
128
+        /**
129
+         * Get the value from $_REQUEST for given key. if the key is empty will return the all values
130
+         * @param  string  $key the item key to be fetched
131
+         * @param  boolean $xss if need apply some XSS attack rule on the value
132
+         * @return array|mixed       the item value if the key exists or all array if the key does not exists or is empty
133
+         */
134
+        public function query($key = null, $xss = true){
135
+            if(empty($key)){
136
+                //return all
137
+                return $xss ? clean_input($this->query) : $this->query;
138
+            }
139
+            $query = array_key_exists($key, $this->query) ? $this->query[$key] : null;
140
+            if($xss){
141
+                $query = clean_input($query);
142
+            }
143
+            return $query;
144
+        }
145 145
 		
146
-		/**
147
-		 * Get the value from $_GET for given key. if the key is empty will return the all values
148
-		 * @param  string  $key the item key to be fetched
149
-		 * @param  boolean $xss if need apply some XSS attack rule on the value
150
-		 * @return array|mixed       the item value if the key exists or all array if the key does not exists or is empty
151
-		 */
152
-		public function get($key = null, $xss = true){
153
-			if(empty($key)){
154
-				//return all
155
-				return $xss ? clean_input($this->get) : $this->get;
156
-			}
157
-			$get = array_key_exists($key, $this->get) ? $this->get[$key] : null;
158
-			if($xss){
159
-				$get = clean_input($get);
160
-			}
161
-			return $get;
162
-		}
146
+        /**
147
+         * Get the value from $_GET for given key. if the key is empty will return the all values
148
+         * @param  string  $key the item key to be fetched
149
+         * @param  boolean $xss if need apply some XSS attack rule on the value
150
+         * @return array|mixed       the item value if the key exists or all array if the key does not exists or is empty
151
+         */
152
+        public function get($key = null, $xss = true){
153
+            if(empty($key)){
154
+                //return all
155
+                return $xss ? clean_input($this->get) : $this->get;
156
+            }
157
+            $get = array_key_exists($key, $this->get) ? $this->get[$key] : null;
158
+            if($xss){
159
+                $get = clean_input($get);
160
+            }
161
+            return $get;
162
+        }
163 163
 		
164
-		/**
165
-		 * Get the value from $_POST for given key. if the key is empty will return the all values
166
-		 * @param  string  $key the item key to be fetched
167
-		 * @param  boolean $xss if need apply some XSS attack rule on the value
168
-		 * @return array|mixed       the item value if the key exists or all array if the key does not exists or is empty
169
-		 */
170
-		public function post($key = null, $xss = true){
171
-			if(empty($key)){
172
-				//return all
173
-				return $xss ? clean_input($this->post) : $this->post;
174
-			}
175
-			$post = array_key_exists($key, $this->post) ? $this->post[$key] : null;
176
-			if($xss){
177
-				$post = clean_input($post);
178
-			}
179
-			return $post;
180
-		}
164
+        /**
165
+         * Get the value from $_POST for given key. if the key is empty will return the all values
166
+         * @param  string  $key the item key to be fetched
167
+         * @param  boolean $xss if need apply some XSS attack rule on the value
168
+         * @return array|mixed       the item value if the key exists or all array if the key does not exists or is empty
169
+         */
170
+        public function post($key = null, $xss = true){
171
+            if(empty($key)){
172
+                //return all
173
+                return $xss ? clean_input($this->post) : $this->post;
174
+            }
175
+            $post = array_key_exists($key, $this->post) ? $this->post[$key] : null;
176
+            if($xss){
177
+                $post = clean_input($post);
178
+            }
179
+            return $post;
180
+        }
181 181
 		
182
-		/**
183
-		 * Get the value from $_SERVER for given key. if the key is empty will return the all values
184
-		 * @param  string  $key the item key to be fetched
185
-		 * @param  boolean $xss if need apply some XSS attack rule on the value
186
-		 * @return array|mixed       the item value if the key exists or all array if the key does not exists or is empty
187
-		 */
188
-		public function server($key = null, $xss = true){
189
-			if(empty($key)){
190
-				//return all
191
-				return $xss ? clean_input($this->server) : $this->server;
192
-			}
193
-			$server = array_key_exists($key, $this->server) ? $this->server[$key] : null;
194
-			if($xss){
195
-				$server = clean_input($server);
196
-			}
197
-			return $server;
198
-		}
182
+        /**
183
+         * Get the value from $_SERVER for given key. if the key is empty will return the all values
184
+         * @param  string  $key the item key to be fetched
185
+         * @param  boolean $xss if need apply some XSS attack rule on the value
186
+         * @return array|mixed       the item value if the key exists or all array if the key does not exists or is empty
187
+         */
188
+        public function server($key = null, $xss = true){
189
+            if(empty($key)){
190
+                //return all
191
+                return $xss ? clean_input($this->server) : $this->server;
192
+            }
193
+            $server = array_key_exists($key, $this->server) ? $this->server[$key] : null;
194
+            if($xss){
195
+                $server = clean_input($server);
196
+            }
197
+            return $server;
198
+        }
199 199
 		
200
-		/**
201
-		 * Get the value from $_COOKIE for given key. if the key is empty will return the all values
202
-		 * @param  string  $key the item key to be fetched
203
-		 * @param  boolean $xss if need apply some XSS attack rule on the value
204
-		 * @return array|mixed       the item value if the key exists or all array if the key does not exists or is empty
205
-		 */
206
-		public function cookie($key = null, $xss = true){
207
-			if(empty($key)){
208
-				//return all
209
-				return $xss ? clean_input($this->cookie) : $this->cookie;
210
-			}
211
-			$cookie = array_key_exists($key, $this->cookie) ? $this->cookie[$key] : null;
212
-			if($xss){
213
-				$cookie = clean_input($cookie);
214
-			}
215
-			return $cookie;
216
-		}
200
+        /**
201
+         * Get the value from $_COOKIE for given key. if the key is empty will return the all values
202
+         * @param  string  $key the item key to be fetched
203
+         * @param  boolean $xss if need apply some XSS attack rule on the value
204
+         * @return array|mixed       the item value if the key exists or all array if the key does not exists or is empty
205
+         */
206
+        public function cookie($key = null, $xss = true){
207
+            if(empty($key)){
208
+                //return all
209
+                return $xss ? clean_input($this->cookie) : $this->cookie;
210
+            }
211
+            $cookie = array_key_exists($key, $this->cookie) ? $this->cookie[$key] : null;
212
+            if($xss){
213
+                $cookie = clean_input($cookie);
214
+            }
215
+            return $cookie;
216
+        }
217 217
 		
218
-		/**
219
-		 * Get the value from $_FILES for given key. if the key is empty will return the all values
220
-		 * @param  string  $key the item key to be fetched
221
-		 * @return array|mixed       the item value if the key exists or all array if the key does not exists or is empty
222
-		 */
223
-		public function file($key){
224
-			$file = array_key_exists($key, $this->file) ? $this->file[$key] : null;
225
-			return $file;
226
-		}
218
+        /**
219
+         * Get the value from $_FILES for given key. if the key is empty will return the all values
220
+         * @param  string  $key the item key to be fetched
221
+         * @return array|mixed       the item value if the key exists or all array if the key does not exists or is empty
222
+         */
223
+        public function file($key){
224
+            $file = array_key_exists($key, $this->file) ? $this->file[$key] : null;
225
+            return $file;
226
+        }
227 227
 		
228
-		/**
229
-		 * Get the value from $_SESSION for given key. if the key is empty will return the all values
230
-		 * @param  string  $key the item key to be fetched
231
-		 * @param  boolean $xss if need apply some XSS attack rule on the value
232
-		 * @return array|mixed       the item value if the key exists or null if the key does not exists
233
-		 */
234
-		public function session($key, $xss = true){
235
-			$session = $this->session->get($key);
236
-			if($xss){
237
-				$session = clean_input($session);
238
-			}
239
-			return $session;
240
-		}
228
+        /**
229
+         * Get the value from $_SESSION for given key. if the key is empty will return the all values
230
+         * @param  string  $key the item key to be fetched
231
+         * @param  boolean $xss if need apply some XSS attack rule on the value
232
+         * @return array|mixed       the item value if the key exists or null if the key does not exists
233
+         */
234
+        public function session($key, $xss = true){
235
+            $session = $this->session->get($key);
236
+            if($xss){
237
+                $session = clean_input($session);
238
+            }
239
+            return $session;
240
+        }
241 241
 
242
-		/**
243
-		 * Get the value from header array for given key.
244
-		 * @param  string  $key the item key to be fetched
245
-		 * @param  boolean $xss if need apply some XSS attack rule on the value
246
-		 * @return mixed       the item value if the key exists or null if the key does not exists
247
-		 */
248
-		public function header($key, $xss = true){
249
-			$header = array_key_exists($key, $this->header) ? $this->header[$key] : null;
250
-			if($xss){
251
-				$header = clean_input($header);
252
-			}
253
-			return $header;
254
-		}
242
+        /**
243
+         * Get the value from header array for given key.
244
+         * @param  string  $key the item key to be fetched
245
+         * @param  boolean $xss if need apply some XSS attack rule on the value
246
+         * @return mixed       the item value if the key exists or null if the key does not exists
247
+         */
248
+        public function header($key, $xss = true){
249
+            $header = array_key_exists($key, $this->header) ? $this->header[$key] : null;
250
+            if($xss){
251
+                $header = clean_input($header);
252
+            }
253
+            return $header;
254
+        }
255 255
 		
256
-	}
256
+    }
Please login to merge, or discard this patch.