Passed
Push — 1.0.0-dev ( 7e13dc...c7a39c )
by nguereza
06:11
created
tests/include/common.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -29,14 +29,14 @@  discard block
 block discarded – undo
29 29
 		//put the first letter of class to upper case 
30 30
 		$class = ucfirst($class);
31 31
 		static $classes = array();
32
-		if(isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log'){
32
+		if (isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log') {
33 33
 			return $classes[$class];
34 34
 		}
35 35
 		$found = false;
36 36
 		foreach (array(ROOT_PATH, CORE_PATH) as $path) {
37 37
 			$file = $path . $dir . '/' . $class . '.php';
38
-			if(file_exists($file)){
39
-				if(class_exists($class, false) === false){
38
+			if (file_exists($file)) {
39
+				if (class_exists($class, false) === false) {
40 40
 					require_once $file;
41 41
 				}
42 42
 				//already found
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 				break;
45 45
 			}
46 46
 		}
47
-		if(! $found){
47
+		if (!$found) {
48 48
 			//can't use show_error() at this time because some dependencies not yet loaded
49 49
 			set_http_status_header(503);
50 50
 			echo 'Cannot find the class [' . $class . ']';
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		/*
55 55
 		   TODO use the best method to get the Log instance
56 56
 		 */
57
-		if($class == 'Log'){
57
+		if ($class == 'Log') {
58 58
 			//can't use the instruction like "return new Log()" 
59 59
 			//because we need return the reference instance of the loaded class.
60 60
 			$log = new Log();
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 	function & class_loaded($class = null){
74 74
 		static $list = array();
75
-		if($class != null){
75
+		if ($class != null) {
76 76
 			$list[strtolower($class)] = $class;
77 77
 		}
78 78
 		return $list;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
 	function & load_configurations(array $overwrite_values = array()){
82 82
 		static $config;
83
-		if(empty($config)){
83
+		if (empty($config)) {
84 84
 			$file = CONFIG_PATH . 'config.php';
85 85
 			require_once $file;
86 86
 		
@@ -94,50 +94,50 @@  discard block
 block discarded – undo
94 94
 	/**
95 95
 	*  @test
96 96
 	*/
97
-	function get_config($key, $default = null){
97
+	function get_config($key, $default = null) {
98 98
 		static $cfg;
99
-		if(empty($cfg)){
99
+		if (empty($cfg)) {
100 100
 			$cfg[0] = & load_configurations();
101 101
 		}
102 102
 		return array_key_exists($key, $cfg[0]) ? $cfg[0][$key] : $default;
103 103
 	}
104 104
 
105
-	function save_to_log($level, $message, $logger = null){
105
+	function save_to_log($level, $message, $logger = null) {
106 106
 		return true;
107 107
 	}
108 108
 
109 109
 	
110
-	function set_http_status_header($code = 200, $text = null){
110
+	function set_http_status_header($code = 200, $text = null) {
111 111
 		return true;
112 112
 	}
113 113
 
114 114
 	
115
-	function show_error($msg, $title = 'error', $logging = true){
115
+	function show_error($msg, $title = 'error', $logging = true) {
116 116
 		//show only and continue to help track of some error occured
117
-		echo 'TNHFW Error: '.$msg . "\n";
117
+		echo 'TNHFW Error: ' . $msg . "\n";
118 118
 	}
119 119
 
120
-	function is_https(){
120
+	function is_https() {
121 121
 		return false;
122 122
 	}
123 123
 	
124 124
 	/**
125 125
 	*  @test
126 126
 	*/
127
-	function is_url($url){
127
+	function is_url($url) {
128 128
 		return preg_match('/^(http|https|ftp):\/\/(.*)/', $url);
129 129
 	}
130 130
 		
131
-	function php_exception_handler($ex){
132
-		throw new RuntimeException('PHP Exception : '.$ex->getMessage().' | '.$ex->getFile().' | '.$ex->getLine());
131
+	function php_exception_handler($ex) {
132
+		throw new RuntimeException('PHP Exception : ' . $ex->getMessage() . ' | ' . $ex->getFile() . ' | ' . $ex->getLine());
133 133
 	}
134 134
 	
135 135
 	
136
-	function php_error_handler($errno , $errstr, $errfile , $errline, array $errcontext = array()){
137
-		throw new RuntimeException('TNHFW Exception Error : '.$errstr.' | '.$errfile.' | '.$errline);
136
+	function php_error_handler($errno, $errstr, $errfile, $errline, array $errcontext = array()) {
137
+		throw new RuntimeException('TNHFW Exception Error : ' . $errstr . ' | ' . $errfile . ' | ' . $errline);
138 138
 	}
139 139
 
140
-	function php_shudown_handler(){
140
+	function php_shudown_handler() {
141 141
 		return true;
142 142
 	}
143 143
 
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
 	/**
146 146
 	*  @test
147 147
 	*/
148
-	function attributes_to_string(array $attributes){
148
+	function attributes_to_string(array $attributes) {
149 149
 		$str = ' ';
150 150
 		//we check that the array passed as an argument is not empty.
151
-		if(! empty($attributes)){
152
-			foreach($attributes as $key => $value){
151
+		if (!empty($attributes)) {
152
+			foreach ($attributes as $key => $value) {
153 153
 				$key = trim(htmlspecialchars($key));
154 154
 				$value = trim(htmlspecialchars($value));
155 155
 				/*
@@ -159,35 +159,35 @@  discard block
 block discarded – undo
159 159
 				* 	$attr = array('placeholder' => 'I am a "puple"')
160 160
 				* 	$str = attributes_to_string($attr); => placeholder = "I am a \"puple\""
161 161
 				 */
162
-				if($value && strpos('"', $value) !== false){
162
+				if ($value && strpos('"', $value) !== false) {
163 163
 					$value = addslashes($value);
164 164
 				}
165
-				$str .= $key.' = "'.$value.'" ';
165
+				$str .= $key . ' = "' . $value . '" ';
166 166
 			}
167 167
 		}
168 168
 		//remove the space after using rtrim()
169 169
 		return rtrim($str);
170 170
 	}
171 171
 
172
-	function stringfy_vars($var){
172
+	function stringfy_vars($var) {
173 173
 		return print_r($var, true);
174 174
 	}
175 175
 
176 176
 	/**
177 177
 	*  @test
178 178
 	*/
179
-	function clean_input($str){
180
-		if(is_array($str)){
179
+	function clean_input($str) {
180
+		if (is_array($str)) {
181 181
 			$str = array_map('clean_input', $str);
182 182
 		}
183
-		else if(is_object($str)){
183
+		else if (is_object($str)) {
184 184
 			$obj = $str;
185 185
 			foreach ($str as $var => $value) {
186 186
 				$obj->$var = clean_input($value);
187 187
 			}
188 188
 			$str = $obj;
189 189
 		}
190
-		else{
190
+		else {
191 191
 			$str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8');
192 192
 		}
193 193
 		return $str;
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
 	/**
197 197
 	*  @test
198 198
 	*/
199
-	function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*'){
199
+	function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*') {
200 200
 		//get the string length
201 201
 		$len = strlen($str);
202 202
 		//if str is empty
203
-		if($len <= 0){
203
+		if ($len <= 0) {
204 204
 			return str_repeat($hiddenChar, 6);
205 205
 		}
206 206
 		//if the length is less than startCount and endCount
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
 		//or startCount is negative or endCount is negative
209 209
 		//return the full string hidden
210 210
 		
211
-		if((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)){
211
+		if ((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)) {
212 212
 			return str_repeat($hiddenChar, $len);
213 213
 		}
214 214
 		//the start non hidden string
215 215
 		$startNonHiddenStr = substr($str, 0, $startCount);
216 216
 		//the end non hidden string
217 217
 		$endNonHiddenStr = null;
218
-		if($endCount > 0){
218
+		if ($endCount > 0) {
219 219
 			$endNonHiddenStr = substr($str, - $endCount);
220 220
 		}
221 221
 		//the hidden string
@@ -224,12 +224,12 @@  discard block
 block discarded – undo
224 224
 		return $startNonHiddenStr . $hiddenStr . $endNonHiddenStr;
225 225
 	}
226 226
 	
227
-	function set_session_config(){
227
+	function set_session_config() {
228 228
 		return true;
229 229
 	}
230 230
 	
231 231
 	function & get_instance(){
232
-		if(! Controller::get_instance()){
232
+		if (!Controller::get_instance()) {
233 233
 			$c = new Controller();
234 234
 		}
235 235
 		return Controller::get_instance();
Please login to merge, or discard this patch.
tests/tnhfw/classes/DBSessionHandlerTest.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 		
14 14
 		private static $config = null;
15 15
 		
16
-		public function __construct(){
16
+		public function __construct() {
17 17
 			$this->db = new Database(array(
18 18
 								'driver'    =>  'sqlite',
19 19
 								'database'  =>  TESTS_PATH . 'assets/db_tests.db',
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 		
51 51
 		
52
-		public function testUsingSessionConfiguration(){
52
+		public function testUsingSessionConfiguration() {
53 53
 			//using value in the configuration
54 54
 			static::$config->set('session_save_path', 'DBSessionModel');
55 55
 			static::$config->set('session_secret', $this->secret);
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 			$this->assertEquals($dbsh->decode($encoded), 'foo');
76 76
 		}
77 77
 		
78
-		public function testWhenDataIsExpired(){
78
+		public function testWhenDataIsExpired() {
79 79
 			$dbsh = new DBSessionHandler($this->model);
80 80
 			$dbsh->setSessionSecret($this->secret);
81 81
 			
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 			$this->assertNull($dbsh->read('foo'));
89 89
 		}
90 90
 		
91
-		public function testWhenDataAlreadyExistDoUpdate(){
91
+		public function testWhenDataAlreadyExistDoUpdate() {
92 92
 			$dbsh = new DBSessionHandler($this->model);
93 93
 			$dbsh->setSessionSecret($this->secret);
94 94
 			
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 			$this->assertEquals($dbsh->read('foo'), '445');	
102 102
 		}
103 103
 		
104
-		public function testUsingCustomModelInstance(){
104
+		public function testUsingCustomModelInstance() {
105 105
 			$dbsh = new DBSessionHandler($this->model);
106 106
 			$dbsh->setSessionSecret($this->secret);
107 107
 			
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 		}
130 130
 			
131 131
 			
132
-		public function testUsingCustomLogInstance(){
132
+		public function testUsingCustomLogInstance() {
133 133
 			$dbsh = new DBSessionHandler($this->model, new Log());
134 134
 			$dbsh->setSessionSecret($this->secret);
135 135
 			
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 			$this->assertEquals($dbsh->decode($encoded), 'foo');
157 157
 		}
158 158
 		
159
-		public function testUsingCustomLoaderInstance(){
159
+		public function testUsingCustomLoaderInstance() {
160 160
 			$dbsh = new DBSessionHandler($this->model, null, new Loader());
161 161
 			$dbsh->setSessionSecret($this->secret);
162 162
 			
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		}
185 185
 		
186 186
 		
187
-		public function testWhenModelInsanceIsNotSet(){
187
+		public function testWhenModelInsanceIsNotSet() {
188 188
 			$dbsh = new DBSessionHandler(null, null, new Loader());
189 189
 			$dbsh->setSessionSecret($this->secret);
190 190
 			
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 			$this->assertEquals($dbsh->decode($encoded), 'foo');
213 213
 		}
214 214
 		
215
-		public function testWhenModelTableColumnsIsNotSet(){
215
+		public function testWhenModelTableColumnsIsNotSet() {
216 216
 			//session table is empty
217 217
 			$this->model->setSessionTableColumns(array());
218 218
 			$dbsh = new DBSessionHandler($this->model);
Please login to merge, or discard this patch.
core/libraries/Cookie.php 1 patch
Spacing   +15 added lines, -15 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 Cookie{
27
+	class Cookie {
28 28
 		
29 29
 		/**
30 30
 		 * The logger instance
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 		 * The signleton of the logger
37 37
 		 * @return Object the Log 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::Cookie');
43 43
 			}
44 44
 			return self::$logger[0];
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 		 * @param  mixed $default the default value to use if can not find the cokkie item in the list
51 51
 		 * @return mixed          the cookie value if exist or the default value
52 52
 		 */
53
-		public static function get($item, $default = null){
53
+		public static function get($item, $default = null) {
54 54
 			$logger = self::getLogger();
55
-			if(array_key_exists($item, $_COOKIE)){
55
+			if (array_key_exists($item, $_COOKIE)) {
56 56
 				return $_COOKIE[$item];
57 57
 			}
58 58
 			$logger->warning('Cannot find cookie item [' . $item . '], using the default value [' . $default . ']');
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
 		 * @param boolean $secure   if this cookie will be available on secure connection or not
70 70
 		 * @param boolean $httponly if this cookie will be available under HTTP protocol.
71 71
 		 */
72
-		public static function set($name, $value = '', $expire = 0, $path = '/', $domain = '', $secure = false, $httponly = false){
73
-			if(headers_sent()){
72
+		public static function set($name, $value = '', $expire = 0, $path = '/', $domain = '', $secure = false, $httponly = false) {
73
+			if (headers_sent()) {
74 74
 				show_error('There exists a cookie that we wanted to create that we couldn\'t 
75 75
 						    because headers was already sent. Make sure to do this first 
76 76
 							before outputing anything.');
77 77
 			}
78 78
 			$timestamp = $expire;
79
-			if($expire){
79
+			if ($expire) {
80 80
 				$timestamp = time() + $expire;
81 81
 			}
82 82
 			setcookie($name, $value, $timestamp, $path, $domain, $secure, $httponly);
@@ -87,15 +87,15 @@  discard block
 block discarded – undo
87 87
 		 * @param  string $item the cookie item name to be cleared
88 88
 		 * @return boolean true if the item exists and is deleted successfully otherwise will return false.
89 89
 		 */
90
-		public static function delete($item){
90
+		public static function delete($item) {
91 91
 			$logger = self::getLogger();
92
-			if(array_key_exists($item, $_COOKIE)){
93
-				$logger->info('Delete cookie item ['.$item.']');
92
+			if (array_key_exists($item, $_COOKIE)) {
93
+				$logger->info('Delete cookie item [' . $item . ']');
94 94
 				unset($_COOKIE[$item]);
95 95
 				return true;
96 96
 			}
97
-			else{
98
-				$logger->warning('Cookie item ['.$item.'] to be deleted does not exists');
97
+			else {
98
+				$logger->warning('Cookie item [' . $item . '] to be deleted does not exists');
99 99
 				return false;
100 100
 			}
101 101
 		}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		 * @param  string $item the cookie item name
106 106
 		 * @return boolean       true if the cookie item is set, false or not
107 107
 		 */
108
-		public static function exists($item){
108
+		public static function exists($item) {
109 109
 			return array_key_exists($item, $_COOKIE);
110 110
 		}
111 111
 
Please login to merge, or discard this patch.
core/libraries/FormValidation.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
25 25
     */
26 26
 
27 27
 
28
-     class FormValidation{
28
+     class FormValidation {
29 29
 		 
30 30
         /**
31 31
          * The form validation status
32 32
          * @var boolean
33 33
          */
34
-        protected $_success  = false;
34
+        protected $_success = false;
35 35
 
36 36
         /**
37 37
          * The list of errors messages
@@ -40,31 +40,31 @@  discard block
 block discarded – undo
40 40
         protected $_errorsMessages = array();
41 41
         
42 42
         // Array of rule sets, fieldName => PIPE seperated ruleString
43
-        protected $_rules             = array();
43
+        protected $_rules = array();
44 44
         
45 45
         // Array of errors, niceName => Error Message
46
-        protected $_errors             = array();
46
+        protected $_errors = array();
47 47
         
48 48
         // Array of post Key => Nice name labels
49
-        protected $_labels          = array();
49
+        protected $_labels = array();
50 50
         
51 51
         /**
52 52
          * The errors delimiters
53 53
          * @var array
54 54
          */
55
-        protected $_allErrorsDelimiter   = array('<div class="error">', '</div>');
55
+        protected $_allErrorsDelimiter = array('<div class="error">', '</div>');
56 56
 
57 57
         /**
58 58
          * The each error delimiter
59 59
          * @var array
60 60
          */
61
-        protected $_eachErrorDelimiter   = array('<p class="error">', '</p>');
61
+        protected $_eachErrorDelimiter = array('<p class="error">', '</p>');
62 62
         
63 63
 		/**
64 64
          * Indicated if need force the validation to be failed
65 65
          * @var boolean
66 66
          */
67
-        protected $_forceFail            = false;
67
+        protected $_forceFail = false;
68 68
 
69 69
         /**
70 70
          * The list of the error messages overrides by the original
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
          * @return void
99 99
          */
100 100
         public function __construct() {
101
-            $this->logger =& class_loader('Log', 'classes');
101
+            $this->logger = & class_loader('Log', 'classes');
102 102
             $this->logger->setLogger('Library::FormValidation');
103 103
            
104 104
 		   //Load form validation language message
105 105
             Loader::lang('form_validation');
106 106
             $obj = & get_instance();
107
-            $this->_errorsMessages  = array(
107
+            $this->_errorsMessages = array(
108 108
                         'required'         => $obj->lang->get('fv_required'),
109 109
                         'min_length'       => $obj->lang->get('fv_min_length'),
110 110
                         'max_length'       => $obj->lang->get('fv_max_length'),
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
             $this->_success              = false;
142 142
             $this->_forceFail            = false;
143 143
             $this->data                  = array();
144
-			$this->enableCsrfCheck       = false;
144
+			$this->enableCsrfCheck = false;
145 145
         }
146 146
 
147 147
         /**
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		 *
151 151
          * @return FormValidation Current instance of object.
152 152
          */
153
-        public function setData(array $data){
153
+        public function setData(array $data) {
154 154
             $this->logger->debug('Setting the form validation data, the values are: ' . stringfy_vars($data));
155 155
             $this->data = $data;
156 156
 			return $this;
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
          * Get the form validation data
161 161
          * @return array the form validation data to be validated
162 162
          */
163
-        public function getData(){
163
+        public function getData() {
164 164
             return $this->data;
165 165
         }
166 166
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		*
170 170
 		* @return string the function name
171 171
 		*/
172
-        protected function _toCallCase($funcName, $prefix='_validate') {
172
+        protected function _toCallCase($funcName, $prefix = '_validate') {
173 173
             $funcName = strtolower($funcName);
174 174
             $finalFuncName = $prefix;
175 175
             foreach (explode('_', $funcName) as $funcNamePart) {
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
          * @return boolean Whether or not the form has been submitted or the data is available for validation.
194 194
          */
195 195
         public function canDoValidation() {
196
-            return get_instance()->request->method() === 'POST' || ! empty($this->data);
196
+            return get_instance()->request->method() === 'POST' || !empty($this->data);
197 197
         }
198 198
 
199 199
         /**
@@ -215,16 +215,16 @@  discard block
 block discarded – undo
215 215
          * afterwards.
216 216
          */
217 217
         protected function _run() {
218
-            if(get_instance()->request->method() == 'POST' || $this->enableCsrfCheck){
218
+            if (get_instance()->request->method() == 'POST' || $this->enableCsrfCheck) {
219 219
                 $this->logger->debug('Check if CSRF is enabled in configuration');
220 220
                 //first check for CSRF
221
-                if( get_config('csrf_enable', false) || $this->enableCsrfCheck){
221
+                if (get_config('csrf_enable', false) || $this->enableCsrfCheck) {
222 222
                      $this->logger->info('Check the CSRF value if is valid');
223
-                    if(! Security::validateCSRF()){
223
+                    if (!Security::validateCSRF()) {
224 224
                         show_error('Invalide data, Cross Site Request Forgery do his job, the data to validate is corrupted.');
225 225
                     }
226 226
                 }
227
-                else{
227
+                else {
228 228
                     $this->logger->info('CSRF is not enabled in configuration or not set manully, no need to check it');
229 229
                 }
230 230
             }
@@ -232,10 +232,10 @@  discard block
 block discarded – undo
232 232
             $this->_forceFail = false;
233 233
 
234 234
             foreach ($this->getData() as $inputName => $inputVal) {
235
-    			if(is_array($this->data[$inputName])){
235
+    			if (is_array($this->data[$inputName])) {
236 236
     				$this->data[$inputName] = array_map('trim', $this->data[$inputName]);
237 237
     			}
238
-    			else{
238
+    			else {
239 239
     				$this->data[$inputName] = trim($this->data[$inputName]);
240 240
     			}
241 241
 
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
         public function setRule($inputField, $inputLabel, $ruleSets) {
263 263
             $this->_rules[$inputField] = $ruleSets;
264 264
             $this->_labels[$inputField] = $inputLabel;
265
-            $this->logger->info('Set the field rule: name [' .$inputField. '], label [' .$inputLabel. '], rules [' .$ruleSets. ']');
265
+            $this->logger->info('Set the field rule: name [' . $inputField . '], label [' . $inputLabel . '], rules [' . $ruleSets . ']');
266 266
             return $this;
267 267
         }
268 268
 
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
             }
427 427
             $errorOutput .= $errorsEnd;
428 428
             echo ($echo) ? $errorOutput : '';
429
-            return (! $echo) ? $errorOutput : null;
429
+            return (!$echo) ? $errorOutput : null;
430 430
         }
431 431
 
432 432
         /**
@@ -451,25 +451,25 @@  discard block
 block discarded – undo
451 451
             /*
452 452
             //////////////// hack for regex rule that can contain "|"
453 453
             */
454
-            if(strpos($ruleString, 'regex') !== false){
454
+            if (strpos($ruleString, 'regex') !== false) {
455 455
                 $regexRule = array();
456 456
                 $rule = '#regex\[\/(.*)\/([a-zA-Z0-9]?)\]#';
457 457
                 preg_match($rule, $ruleString, $regexRule);
458 458
                 $ruleStringTemp = preg_replace($rule, '', $ruleString);
459
-                 if(isset($regexRule[0]) && !empty($regexRule[0])){
459
+                 if (isset($regexRule[0]) && !empty($regexRule[0])) {
460 460
                      $ruleSets[] = $regexRule[0];
461 461
                  }
462 462
                  $ruleStringRegex = explode('|', $ruleStringTemp);
463 463
                 foreach ($ruleStringRegex as $rule) {
464 464
                     $rule = trim($rule);
465
-                    if($rule){
465
+                    if ($rule) {
466 466
                         $ruleSets[] = $rule;
467 467
                     }
468 468
                 }
469 469
                  
470 470
             }
471 471
             /***********************************/
472
-            else{
472
+            else {
473 473
                 if (strpos($ruleString, '|') !== FALSE) {
474 474
                     $ruleSets = explode('|', $ruleString);
475 475
                 } else {
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
          * @return void
502 502
          */
503 503
         protected function _validateRule($inputName, $inputVal, $ruleName) {
504
-            $this->logger->debug('Rule validation of field [' .$inputName. '], value [' .$inputVal. '], rule [' .$ruleName. ']');
504
+            $this->logger->debug('Rule validation of field [' . $inputName . '], value [' . $inputVal . '], rule [' . $ruleName . ']');
505 505
             // Array to store args
506 506
             $ruleArgs = array();
507 507
 
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
                 $key = $i - 1;
546 546
                 $rulePhrase = str_replace('%' . $i, $replacements[$key], $rulePhrase);
547 547
             }
548
-            if (! array_key_exists($inputName, $this->_errors)) {
548
+            if (!array_key_exists($inputName, $this->_errors)) {
549 549
                 $this->_errors[$inputName] = $rulePhrase;
550 550
             }
551 551
         }
@@ -597,13 +597,13 @@  discard block
 block discarded – undo
597 597
          */
598 598
 		protected function _validateRequired($inputName, $ruleName, array $ruleArgs) {
599 599
             $inputVal = $this->post($inputName);
600
-            if(array_key_exists(1, $ruleArgs) && function_exists($ruleArgs[1])) {
600
+            if (array_key_exists(1, $ruleArgs) && function_exists($ruleArgs[1])) {
601 601
                 $callbackReturn = $this->_runEmptyCallback($ruleArgs[1]);
602 602
                 if ($inputVal == '' && $callbackReturn == true) {
603 603
                     $this->_setError($inputName, $ruleName, $this->_getLabel($inputName));
604 604
                 }
605 605
             } 
606
-			else if($inputVal == '') {
606
+			else if ($inputVal == '') {
607 607
 				$this->_setError($inputName, $ruleName, $this->_getLabel($inputName));
608 608
             }
609 609
         }
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
         protected function _validateCallback($inputName, $ruleName, array $ruleArgs) {
630 630
             if (function_exists($ruleArgs[1]) && !empty($this->data[$inputName])) {
631 631
 				$result = $this->_runCallback($this->data[$inputName], $ruleArgs[1]);
632
-				if(! $result){
632
+				if (!$result) {
633 633
 					$this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
634 634
 				}
635 635
             }
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
                         continue;
664 664
                     }
665 665
                 } 
666
-				else{
666
+				else {
667 667
                     if ($inputVal == $doNotEqual) {
668 668
                         $this->_setError($inputName, $ruleName . ',string', array($this->_getLabel($inputName), $doNotEqual));
669 669
                         continue;
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
          */
694 694
         protected function _validateValidEmail($inputName, $ruleName, array $ruleArgs) {
695 695
             $inputVal = $this->post($inputName);
696
-            if (! preg_match("/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i", $inputVal)) {
697
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
696
+            if (!preg_match("/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i", $inputVal)) {
697
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
698 698
                     return;
699 699
                 }
700 700
                 $this->_setError($inputName, $ruleName, $this->_getLabel($inputName));
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
         protected function _validateExactLength($inputName, $ruleName, array $ruleArgs) {
711 711
             $inputVal = $this->post($inputName);
712 712
             if (strlen($inputVal) != $ruleArgs[1]) { // $ruleArgs[0] is [length] $rulesArgs[1] is just length
713
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
713
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
714 714
                     return;
715 715
                 }
716 716
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
         protected function _validateMaxLength($inputName, $ruleName, array $ruleArgs) {
727 727
             $inputVal = $this->post($inputName);
728 728
             if (strlen($inputVal) > $ruleArgs[1]) { // $ruleArgs[0] is [length] $rulesArgs[1] is just length
729
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
729
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
730 730
                     return;
731 731
                 }
732 732
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
         protected function _validateMinLength($inputName, $ruleName, array $ruleArgs) {
743 743
             $inputVal = $this->post($inputName);
744 744
             if (strlen($inputVal) < $ruleArgs[1]) { // $ruleArgs[0] is [length] $rulesArgs[1] is just length
745
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
745
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
746 746
                     return;
747 747
                 }
748 748
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
     	protected function _validateLessThan($inputName, $ruleName, array $ruleArgs) {
759 759
             $inputVal = $this->post($inputName);
760 760
             if ($inputVal >= $ruleArgs[1]) { 
761
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
761
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
762 762
                     return;
763 763
                 }
764 764
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
     	protected function _validateGreaterThan($inputName, $ruleName, array $ruleArgs) {
775 775
             $inputVal = $this->post($inputName);
776 776
             if ($inputVal <= $ruleArgs[1]) {
777
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
777
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
778 778
                     return;
779 779
                 }
780 780
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
@@ -789,8 +789,8 @@  discard block
 block discarded – undo
789 789
          */
790 790
     	protected function _validateNumeric($inputName, $ruleName, array $ruleArgs) {
791 791
             $inputVal = $this->post($inputName);
792
-            if (! is_numeric($inputVal)) {
793
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
792
+            if (!is_numeric($inputVal)) {
793
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
794 794
                     return;
795 795
                 }
796 796
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 		protected function _validateExists($inputName, $ruleName, array $ruleArgs) {
807 807
             $inputVal = $this->post($inputName);
808 808
     		$obj = & get_instance();
809
-    		if(! isset($obj->database)){
809
+    		if (!isset($obj->database)) {
810 810
     			return;
811 811
     		}
812 812
     		list($table, $column) = explode('.', $ruleArgs[1]);
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
     			          ->get();
816 816
     		$nb = $obj->database->numRows();
817 817
             if ($nb == 0) {
818
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
818
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
819 819
                     return;
820 820
                 }
821 821
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
     	protected function _validateIsUnique($inputName, $ruleName, array $ruleArgs) {
832 832
             $inputVal = $this->post($inputName);
833 833
     		$obj = & get_instance();
834
-    		if(! isset($obj->database)){
834
+    		if (!isset($obj->database)) {
835 835
     			return;
836 836
     		}
837 837
     		list($table, $column) = explode('.', $ruleArgs[1]);
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
     			          ->get();
841 841
     		$nb = $obj->database->numRows();
842 842
             if ($nb != 0) {
843
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
843
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
844 844
                     return;
845 845
                 }
846 846
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
@@ -856,11 +856,11 @@  discard block
 block discarded – undo
856 856
     	protected function _validateIsUniqueUpdate($inputName, $ruleName, array $ruleArgs) {
857 857
             $inputVal = $this->post($inputName);
858 858
     		$obj = & get_instance();
859
-    		if(! isset($obj->database)){
859
+    		if (!isset($obj->database)) {
860 860
     			return;
861 861
     		}
862 862
     		$data = explode(',', $ruleArgs[1]);
863
-    		if(count($data) < 2){
863
+    		if (count($data) < 2) {
864 864
     			return;
865 865
     		}
866 866
     		list($table, $column) = explode('.', $data[0]);
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
                 		  ->get();
872 872
     		$nb = $obj->database->numRows();
873 873
             if ($nb != 0) {
874
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
874
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
875 875
                     return;
876 876
                 }
877 877
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
@@ -888,8 +888,8 @@  discard block
 block discarded – undo
888 888
             $inputVal = $this->post($inputName);
889 889
     		$list = explode(',', $ruleArgs[1]);
890 890
             $list = array_map('trim', $list);
891
-            if (! in_array($inputVal, $list)) {
892
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
891
+            if (!in_array($inputVal, $list)) {
892
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
893 893
                     return;
894 894
                 }
895 895
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
         protected function _validateRegex($inputName, $ruleName, array $ruleArgs) {
906 906
             $inputVal = $this->post($inputName);
907 907
     		$regex = $ruleArgs[1];
908
-            if (! preg_match($regex, $inputVal)) {
909
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
908
+            if (!preg_match($regex, $inputVal)) {
909
+                if (!$this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
910 910
                     return;
911 911
                 }
912 912
                 $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
Please login to merge, or discard this patch.
core/libraries/Assets.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 *  @since 1.0.0
39 39
 	 *  @filesource
40 40
 	 */
41
-	class Assets{
41
+	class Assets {
42 42
 		
43 43
 		/**
44 44
 		 * The logger instance
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
 		 * The signleton of the logger
51 51
 		 * @return Object the Log instance
52 52
 		 */
53
-		private static function getLogger(){
54
-			if(self::$logger == null){
53
+		private static function getLogger() {
54
+			if (self::$logger == null) {
55 55
 				//can't assign reference to static variable
56
-				self::$logger[0] =& class_loader('Log', 'classes');
56
+				self::$logger[0] = & class_loader('Log', 'classes');
57 57
 				self::$logger[0]->setLogger('Library::Assets');
58 58
 			}
59 59
 			return self::$logger[0];
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
 		 *  @param $asset the name of the assets file path with the extension.
73 73
 		 *  @return string|null the absolute path of the assets file, if it exists otherwise returns null if the file does not exist.
74 74
 		 */
75
-		public static function path($asset){
75
+		public static function path($asset) {
76 76
 			$logger = self::getLogger();	
77 77
 			$path = ASSETS_PATH . $asset;
78 78
 			
79 79
 			$logger->debug('Including the Assets file [' . $path . ']');
80 80
 			//Check if the file exists
81
-			if(file_exists($path)){
81
+			if (file_exists($path)) {
82 82
 				$logger->info('Assets file [' . $path . '] included successfully');
83 83
 				return Url::base_url($path);
84 84
 			}
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 		 *  @param $path the name of the css file without the extension.
99 99
 		 *  @return string|null the absolute path of the css file, if it exists otherwise returns null if the file does not exist.
100 100
 		 */
101
-		public static function css($path){
101
+		public static function css($path) {
102 102
 			$logger = self::getLogger();
103 103
 			/*
104 104
 			* if the file name contains the ".css" extension, replace it with 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 			
110 110
 			$logger->debug('Including the Assets file [' . $path . '] for CSS');
111 111
 			//Check if the file exists
112
-			if(file_exists($path)){
112
+			if (file_exists($path)) {
113 113
 				$logger->info('Assets file [' . $path . '] for CSS included successfully');
114 114
 				return Url::base_url($path);
115 115
 			}
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
 		 *  @param $path the name of the javascript file without the extension.
130 130
 		 *  @return string|null the absolute path of the javascript file, if it exists otherwise returns null if the file does not exist.
131 131
 		 */
132
-		public static function js($path){
132
+		public static function js($path) {
133 133
 			$logger = self::getLogger();
134 134
 			$path = str_ireplace('.js', '', $path);
135 135
 			$path = ASSETS_PATH . 'js/' . $path . '.js';
136 136
 			$logger->debug('Including the Assets file [' . $path . '] for javascript');
137
-			if(file_exists($path)){
137
+			if (file_exists($path)) {
138 138
 				$logger->info('Assets file [' . $path . '] for Javascript included successfully');
139 139
 				return Url::base_url($path);
140 140
 			}
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
 		 *  @param $path the name of the image file with the extension.
155 155
 		 *  @return string|null the absolute path of the image file, if it exists otherwise returns null if the file does not exist.
156 156
 		 */
157
-		public static function img($path){
157
+		public static function img($path) {
158 158
 			$logger = self::getLogger();
159 159
 			$path = ASSETS_PATH . 'images/' . $path;
160 160
 			$logger->debug('Including the Assets file [' . $path . '] for image');
161
-			if(file_exists($path)){
161
+			if (file_exists($path)) {
162 162
 				$logger->info('Assets file [' . $path . '] for image included successfully');
163 163
 				return Url::base_url($path);
164 164
 			}
Please login to merge, or discard this patch.
core/libraries/Benchmark.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * Class for Benchmark
29 29
 	 */
30
-	class Benchmark{
30
+	class Benchmark {
31 31
 		/**
32 32
 		 * The markers for excution time
33 33
 		 * @var array
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 		 * This method is used to mark one point for benchmark (execution time and memory usage)
45 45
 		 * @param  string $name the marker name
46 46
 		 */
47
-		public function mark($name){
47
+		public function mark($name) {
48 48
 			//Marker for execution time
49 49
 			$this->markersTime[$name] = microtime(true);
50 50
 			//Marker for memory usage
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
 		 * @param  integer $decimalCount   the number of decimal
59 59
 		 * @return string         the total execution time
60 60
 		 */
61
-		public function elapsedTime($startMarkerName = null, $endMarkerName = null, $decimalCount = 6){
62
-			if(! $startMarkerName || !isset($this->markersTime[$startMarkerName])){
61
+		public function elapsedTime($startMarkerName = null, $endMarkerName = null, $decimalCount = 6) {
62
+			if (!$startMarkerName || !isset($this->markersTime[$startMarkerName])) {
63 63
 				return 0;
64 64
 			}
65 65
 			
66
-			if(! isset($this->markersTime[$endMarkerName])){
66
+			if (!isset($this->markersTime[$endMarkerName])) {
67 67
 				$this->markersTime[$endMarkerName] = microtime(true);
68 68
 			}
69 69
 			return number_format($this->markersTime[$endMarkerName] - $this->markersTime[$startMarkerName], $decimalCount);
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
 		 * @param  integer $decimalCount   the number of decimal
77 77
 		 * @return string         the total memory usage
78 78
 		 */
79
-		public function memoryUsage($startMarkerName = null, $endMarkerName = null, $decimalCount = 6){
80
-			if(! $startMarkerName || !isset($this->markersMemory[$startMarkerName])){
79
+		public function memoryUsage($startMarkerName = null, $endMarkerName = null, $decimalCount = 6) {
80
+			if (!$startMarkerName || !isset($this->markersMemory[$startMarkerName])) {
81 81
 				return 0;
82 82
 			}
83 83
 			
84
-			if(! isset($this->markersMemory[$endMarkerName])){
84
+			if (!isset($this->markersMemory[$endMarkerName])) {
85 85
 				$this->markersMemory[$endMarkerName] = microtime(true);
86 86
 			}
87 87
 			return number_format($this->markersMemory[$endMarkerName] - $this->markersMemory[$startMarkerName], $decimalCount);
Please login to merge, or discard this patch.
core/libraries/Email.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		 */
87 87
 		public function __construct()
88 88
 		{
89
-			$this->logger =& class_loader('Log', 'classes');
89
+			$this->logger = & class_loader('Log', 'classes');
90 90
             $this->logger->setLogger('Library::Email');
91 91
 			$this->reset();
92 92
 		}
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
 		public function setTos(array $emails)
149 149
 		{
150 150
 			foreach ($emails as $name => $email) {
151
-				if(is_numeric($name)){
151
+				if (is_numeric($name)) {
152 152
 					$this->setTo($email);
153 153
 				}
154
-				else{
154
+				else {
155 155
 					$this->setTo($email, $name);
156 156
 				}
157 157
 			}
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 		 */
282 282
 		public function addAttachment($path, $filename = null, $data = null)
283 283
 		{
284
-			if(! file_exists($path)){
285
-				show_error('The file [' .$path. '] does not exists.');
284
+			if (!file_exists($path)) {
285
+				show_error('The file [' . $path . '] does not exists.');
286 286
 			}
287 287
 			$filename = empty($filename) ? basename($path) : $filename;
288 288
 			$filename = $this->encodeUtf8($this->filterOther((string) $filename));
@@ -304,13 +304,13 @@  discard block
 block discarded – undo
304 304
 		 */
305 305
 		public function getAttachmentData($path)
306 306
 		{
307
-			if(! file_exists($path)){
308
-				show_error('The file [' .$path. '] does not exists.');
307
+			if (!file_exists($path)) {
308
+				show_error('The file [' . $path . '] does not exists.');
309 309
 			}
310 310
 			$filesize = filesize($path);
311 311
 			$handle = fopen($path, "r");
312 312
 			$attachment = null;
313
-			if(is_resource($handle)){
313
+			if (is_resource($handle)) {
314 314
 				$attachment = fread($handle, $filesize);
315 315
 				fclose($handle);
316 316
 			}
Please login to merge, or discard this patch.
core/libraries/Upload.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     *    @package FileUpload
38 38
     *    @version 1.5
39 39
     */
40
-    class Upload{
40
+    class Upload {
41 41
 
42 42
         /**
43 43
         *   Version
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         *    @version    1.0
70 70
         *    @var        array
71 71
         */
72
-        private $file_array    = array();
72
+        private $file_array = array();
73 73
 
74 74
         /**
75 75
         *    If the file you are trying to upload already exists it will
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         *    @version    1.0
120 120
         *    @var        float
121 121
         */
122
-        private $max_file_size= 0.0;
122
+        private $max_file_size = 0.0;
123 123
 
124 124
         /**
125 125
         *    List of allowed mime types
@@ -217,12 +217,12 @@  discard block
 block discarded – undo
217 217
         *    @return    object
218 218
         *    @method    object    __construct
219 219
         */
220
-        public function __construct(){
221
-            $this->logger =& class_loader('Log', 'classes');
220
+        public function __construct() {
221
+            $this->logger = & class_loader('Log', 'classes');
222 222
             $this->logger->setLogger('Library::Upload');
223 223
 
224 224
             Loader::lang('file_upload');
225
-            $obj =& get_instance();
225
+            $obj = & get_instance();
226 226
 
227 227
             $this->error_messages = array(
228 228
                 'upload_err_ini_size' => $obj->lang->get('fu_upload_err_ini_size'),
@@ -239,15 +239,15 @@  discard block
 block discarded – undo
239 239
             );
240 240
 
241 241
             $this->file = array(
242
-                'status'                =>    false,    // True: success upload
243
-                'mime'                  =>    '',       // Empty string
244
-                'filename'              =>    '',       // Empty string
245
-                'original'              =>    '',       // Empty string
246
-                'size'                  =>    0,        // 0 Bytes
247
-                'sizeFormated'          =>    '0B',     // 0 Bytes
248
-                'destination'           =>    './',     // Default: ./
249
-                'allowed_mime_types'    =>    array(),  // Allowed mime types
250
-                'error'                 =>    null,        // File error
242
+                'status'                =>    false, // True: success upload
243
+                'mime'                  =>    '', // Empty string
244
+                'filename'              =>    '', // Empty string
245
+                'original'              =>    '', // Empty string
246
+                'size'                  =>    0, // 0 Bytes
247
+                'sizeFormated'          =>    '0B', // 0 Bytes
248
+                'destination'           =>    './', // Default: ./
249
+                'allowed_mime_types'    =>    array(), // Allowed mime types
250
+                'error'                 =>    null, // File error
251 251
             );
252 252
 
253 253
             // Change dir to current dir
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
             } elseif (isset($HTTP_POST_FILES) && is_array($HTTP_POST_FILES)) {
260 260
                 $this->file_array = $HTTP_POST_FILES;
261 261
             }
262
-            $this->logger->info('The upload file information are : ' .stringfy_vars($this->file_array));
262
+            $this->logger->info('The upload file information are : ' . stringfy_vars($this->file_array));
263 263
         }
264 264
         /**
265 265
         *    Set input.
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
         */
276 276
         public function setInput($input)
277 277
         {
278
-            if (!empty($input) && (is_string($input) || is_numeric($input) )) {
278
+            if (!empty($input) && (is_string($input) || is_numeric($input))) {
279 279
                 $this->input = $input;
280 280
             }
281 281
             return $this;
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
         */
312 312
         public function setAutoFilename()
313 313
         {
314
-            $this->filename = sha1(mt_rand(1, 9999).uniqid());
314
+            $this->filename = sha1(mt_rand(1, 9999) . uniqid());
315 315
             $this->filename .= time();
316 316
             return $this;
317 317
         }
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
                 $php_size = $this->sizeInBytes((int) ini_get('upload_max_filesize'));
333 333
                 // Calculate difference
334 334
                 if ($php_size < $file_size) {
335
-                    $this->logger->warning('The upload max file size you set [' .$file_size. '] is greather than the PHP configuration for upload max file size [' .$php_size. ']');
335
+                    $this->logger->warning('The upload max file size you set [' . $file_size . '] is greather than the PHP configuration for upload max file size [' . $php_size . ']');
336 336
                 }
337 337
                 $this->max_file_size = $file_size;
338 338
             }
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
         public function setAllowedMimeTypes(array $mimes)
351 351
         {
352 352
             if (count($mimes) > 0) {
353
-                array_map(array($this , 'setAllowMimeType'), $mimes);
353
+                array_map(array($this, 'setAllowMimeType'), $mimes);
354 354
             }
355 355
             return $this;
356 356
         }
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
         {
416 416
             if (!empty($name) && is_string($name)) {
417 417
                 if (array_key_exists($name, $this->mime_helping)) {
418
-                    return $this->setAllowedMimeTypes($this->mime_helping[ $name ]);
418
+                    return $this->setAllowedMimeTypes($this->mime_helping[$name]);
419 419
                 }
420 420
             }
421 421
             return $this;
@@ -434,8 +434,8 @@  discard block
 block discarded – undo
434 434
         */
435 435
         public function setUploadFunction($function)
436 436
         {
437
-            if (!empty($function) && (is_array($function) || is_string($function) )) {
438
-                if (is_callable( $function)) {
437
+            if (!empty($function) && (is_array($function) || is_string($function))) {
438
+                if (is_callable($function)) {
439 439
                     $this->upload_function = $function;
440 440
                 }
441 441
             }
@@ -488,8 +488,8 @@  discard block
 block discarded – undo
488 488
                             chdir($destination_directory);
489 489
                         }
490 490
                     }
491
-                    else{
492
-                        $this->logger->warning('Can not create the upload directory [' .$destination_directory. ']');
491
+                    else {
492
+                        $this->logger->warning('Can not create the upload directory [' . $destination_directory . ']');
493 493
                     }
494 494
                 }
495 495
             }
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
         public function isFilename($filename)
540 540
         {
541 541
             $filename = basename($filename);
542
-            return (!empty($filename) && (is_string( $filename) || is_numeric($filename)));
542
+            return (!empty($filename) && (is_string($filename) || is_numeric($filename)));
543 543
         }
544 544
         /**
545 545
         *    Validate mime type with allowed mime types,
@@ -581,11 +581,11 @@  discard block
 block discarded – undo
581 581
         */
582 582
         public function isDirpath($path)
583 583
         {
584
-            if (!empty( $path) && (is_string( $path) || is_numeric($path) )) {
584
+            if (!empty($path) && (is_string($path) || is_numeric($path))) {
585 585
                 if (DIRECTORY_SEPARATOR == '/') {
586
-                    return (preg_match( '/^[^*?"<>|:]*$/' , $path) == 1 );
586
+                    return (preg_match('/^[^*?"<>|:]*$/', $path) == 1);
587 587
                 } else {
588
-                    return (preg_match( "/^[^*?\"<>|:]*$/" , substr($path,2) ) == 1);
588
+                    return (preg_match("/^[^*?\"<>|:]*$/", substr($path, 2)) == 1);
589 589
                 }
590 590
             }
591 591
             return false;
@@ -613,10 +613,10 @@  discard block
 block discarded – undo
613 613
         */
614 614
         public function getInfo()
615 615
         {
616
-            return (object)$this->file;
616
+            return (object) $this->file;
617 617
         }
618 618
 
619
-        public function isUploaded(){
619
+        public function isUploaded() {
620 620
             return isset($this->file_array[$this->input])
621 621
             &&
622 622
             is_uploaded_file($this->file_array[$this->input]['tmp_name']);
@@ -629,9 +629,9 @@  discard block
 block discarded – undo
629 629
         *    @return    boolean
630 630
         *    @method    boolean    save
631 631
         */
632
-        public function save(){
632
+        public function save() {
633 633
             //check if file upload is  allowed in the configuration
634
-            if(! ini_get('file_uploads')){
634
+            if (!ini_get('file_uploads')) {
635 635
                 $this->setError($this->error_messages['file_uploads']);
636 636
                 return false;
637 637
             }
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
                     if (empty($this->filename)) {
642 642
                         $this->filename = $this->file_array[$this->input]['name'];
643 643
                     }
644
-                    else{
644
+                    else {
645 645
                         // Replace %s for extension in filename
646 646
                         // Before: /[\w\d]*(.[\d\w]+)$/i
647 647
                         // After: /^[\s[:alnum:]\-\_\.]*\.([\d\w]+)$/iu
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
                             '$1',
653 653
                             $this->file_array[$this->input]['name']
654 654
                         );
655
-                        $this->filename = $this->filename.'.'.$extension;
655
+                        $this->filename = $this->filename . '.' . $extension;
656 656
                     }
657 657
 
658 658
                     // set file info
@@ -665,10 +665,10 @@  discard block
 block discarded – undo
665 665
                     $this->file['filename']     = $this->filename;
666 666
                     $this->file['error']        = $this->file_array[$this->input]['error'];
667 667
 
668
-                    $this->logger->info('The upload file information to process is : ' .stringfy_vars($this->file));
668
+                    $this->logger->info('The upload file information to process is : ' . stringfy_vars($this->file));
669 669
 
670 670
                     //check for php upload error
671
-                    if(is_numeric($this->file['error']) && $this->file['error'] > 0){
671
+                    if (is_numeric($this->file['error']) && $this->file['error'] > 0) {
672 672
                         $this->setError($this->getPhpUploadErrorMessageByCode($this->file['error']));
673 673
                         return false;
674 674
                     }
@@ -697,8 +697,8 @@  discard block
 block discarded – undo
697 697
                     }
698 698
 
699 699
                     // Execute input callback
700
-                    if (!empty( $this->callbacks['input'])) {
701
-                        call_user_func($this->callbacks['input'], (object)$this->file);
700
+                    if (!empty($this->callbacks['input'])) {
701
+                        call_user_func($this->callbacks['input'], (object) $this->file);
702 702
                     }
703 703
                    
704 704
 
@@ -710,8 +710,8 @@  discard block
 block discarded – undo
710 710
                     );
711 711
 
712 712
                     // Execute output callback
713
-                    if (!empty( $this->callbacks['output'])) {
714
-                        call_user_func($this->callbacks['output'], (object)$this->file);
713
+                    if (!empty($this->callbacks['output'])) {
714
+                        call_user_func($this->callbacks['output'], (object) $this->file);
715 715
                     }
716 716
                     return $this->file['status'];
717 717
                 }
@@ -730,10 +730,10 @@  discard block
 block discarded – undo
730 730
         */
731 731
         public function sizeFormat($size, $precision = 2)
732 732
         {
733
-            if($size > 0){
733
+            if ($size > 0) {
734 734
                 $base       = log($size) / log(1024);
735 735
                 $suffixes   = array('B', 'K', 'M', 'G', 'T');
736
-                return round(pow(1024, $base - floor($base)), $precision) . ( isset($suffixes[floor($base)]) ? $suffixes[floor($base)] : '');
736
+                return round(pow(1024, $base - floor($base)), $precision) . (isset($suffixes[floor($base)]) ? $suffixes[floor($base)] : '');
737 737
             }
738 738
             return null;
739 739
         }
@@ -757,14 +757,14 @@  discard block
 block discarded – undo
757 757
             if (array_key_exists('unit', $matches)) {
758 758
                 $unit = strtoupper($matches['unit']);
759 759
             }
760
-            return (floatval($matches['size']) * pow(1024, $units[$unit]) ) ;
760
+            return (floatval($matches['size']) * pow(1024, $units[$unit]));
761 761
         }
762 762
 
763 763
         /**
764 764
          * Get the upload error message
765 765
          * @return string
766 766
          */
767
-        public function getError(){
767
+        public function getError() {
768 768
             return $this->error;
769 769
         }
770 770
 
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
          * Set the upload error message
773 773
          * @param string $message the upload error message to set
774 774
          */
775
-        public function setError($message){
775
+        public function setError($message) {
776 776
             $this->logger->info('The upload got error : ' . $message);
777 777
             $this->error = $message;
778 778
         }
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
          * @param  int $code the error code
783 783
          * @return string the error message
784 784
          */
785
-        private function getPhpUploadErrorMessageByCode($code){
785
+        private function getPhpUploadErrorMessageByCode($code) {
786 786
             $codeMessageMaps = array(
787 787
                 1 => $this->error_messages['upload_err_ini_size'],
788 788
                 2 => $this->error_messages['upload_err_form_size'],
Please login to merge, or discard this patch.
core/common.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
 		//put the first letter of class to upper case 
54 54
 		$class = ucfirst($class);
55 55
 		static $classes = array();
56
-		if(isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log'){
56
+		if (isset($classes[$class]) /*hack for duplicate log Logger name*/ && $class != 'Log') {
57 57
 			return $classes[$class];
58 58
 		}
59 59
 		$found = false;
60 60
 		foreach (array(ROOT_PATH, CORE_PATH) as $path) {
61 61
 			$file = $path . $dir . '/' . $class . '.php';
62
-			if(file_exists($file)){
63
-				if(class_exists($class, false) === false){
62
+			if (file_exists($file)) {
63
+				if (class_exists($class, false) === false) {
64 64
 					require_once $file;
65 65
 				}
66 66
 				//already found
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 				break;
69 69
 			}
70 70
 		}
71
-		if(! $found){
71
+		if (!$found) {
72 72
 			//can't use show_error() at this time because some dependencies not yet loaded
73 73
 			set_http_status_header(503);
74 74
 			echo 'Cannot find the class [' . $class . ']';
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		/*
79 79
 		   TODO use the best method to get the Log instance
80 80
 		 */
81
-		if($class == 'Log'){
81
+		if ($class == 'Log') {
82 82
 			//can't use the instruction like "return new Log()" 
83 83
 			//because we need return the reference instance of the loaded class.
84 84
 			$log = new Log();
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	function & class_loaded($class = null){
104 104
 		static $list = array();
105
-		if($class !== null){
105
+		if ($class !== null) {
106 106
 			$list[strtolower($class)] = $class;
107 107
 		}
108 108
 		return $list;
@@ -117,14 +117,14 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	function & load_configurations(array $overwrite_values = array()){
119 119
 		static $config;
120
-		if(empty($config)){
120
+		if (empty($config)) {
121 121
 			$file = CONFIG_PATH . 'config.php';
122 122
 			$found = false;
123
-			if(file_exists($file)){
123
+			if (file_exists($file)) {
124 124
 				require_once $file;
125 125
 				$found = true;
126 126
 			}
127
-			if(! $found){
127
+			if (!$found) {
128 128
 				set_http_status_header(503);
129 129
 				echo 'Unable to find the configuration file [' . $file . ']';
130 130
 				die();
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 	 * 
145 145
 	 * @return mixed          the config value
146 146
 	 */
147
-	function get_config($key, $default = null){
147
+	function get_config($key, $default = null) {
148 148
 		static $cfg;
149
-		if(empty($cfg)){
149
+		if (empty($cfg)) {
150 150
 			$cfg[0] = & load_configurations();
151 151
 		}
152 152
 		return array_key_exists($key, $cfg[0]) ? $cfg[0][$key] : $default;
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
 	 * 
161 161
 	 * @codeCoverageIgnore
162 162
 	 */
163
-	function save_to_log($level, $message, $logger = null){
164
-		$log =& class_loader('Log', 'classes');
165
-		if($logger){
163
+	function save_to_log($level, $message, $logger = null) {
164
+		$log = & class_loader('Log', 'classes');
165
+		if ($logger) {
166 166
 			$log->setLogger($logger);
167 167
 		}
168 168
 		$log->writeLog($message, $level);
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
 	 * 
176 176
 	 * @codeCoverageIgnore
177 177
 	 */
178
-	function set_http_status_header($code = 200, $text = null){
179
-		if(!is_numeric($code) || $code < 0 ){
178
+	function set_http_status_header($code = 200, $text = null) {
179
+		if (!is_numeric($code) || $code < 0) {
180 180
 			show_error('HTTP status code must be an integer');
181 181
 		}
182
-		if(empty($text)){
182
+		if (empty($text)) {
183 183
 			$code = abs($code);
184 184
 			$http_status = array(
185 185
 								100 => 'Continue',
@@ -228,18 +228,18 @@  discard block
 block discarded – undo
228 228
 								504 => 'Gateway Timeout',
229 229
 								505 => 'HTTP Version Not Supported',
230 230
 							);
231
-			if(isset($http_status[$code])){
231
+			if (isset($http_status[$code])) {
232 232
 				$text = $http_status[$code];
233 233
 			}
234
-			else{
234
+			else {
235 235
 				show_error('No HTTP status text found for your code please check it.');
236 236
 			}
237 237
 		}
238 238
 		
239
-		if(strpos(php_sapi_name(), 'cgi') === 0){
239
+		if (strpos(php_sapi_name(), 'cgi') === 0) {
240 240
 			header('Status: ' . $code . ' ' . $text, TRUE);
241 241
 		}
242
-		else{
242
+		else {
243 243
 			$proto = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
244 244
 			header($proto . ' ' . $code . ' ' . $text, TRUE, $code);
245 245
 		}
@@ -254,13 +254,13 @@  discard block
 block discarded – undo
254 254
 	 *  
255 255
 	 *  @codeCoverageIgnore
256 256
 	 */
257
-	function show_error($msg, $title = 'error', $logging = true){
257
+	function show_error($msg, $title = 'error', $logging = true) {
258 258
 		$title = strtoupper($title);
259 259
 		$data = array();
260 260
 		$data['error'] = $msg;
261 261
 		$data['title'] = $title;
262
-		if($logging){
263
-			save_to_log('error', '['.$title.'] '.strip_tags($msg), 'GLOBAL::ERROR');
262
+		if ($logging) {
263
+			save_to_log('error', '[' . $title . '] ' . strip_tags($msg), 'GLOBAL::ERROR');
264 264
 		}
265 265
 		$response = & class_loader('Response', 'classes');
266 266
 		$response->sendError($data);
@@ -274,18 +274,18 @@  discard block
 block discarded – undo
274 274
 	 *  
275 275
 	 *  @return boolean true if the web server uses the https protocol, false if not.
276 276
 	 */
277
-	function is_https(){
277
+	function is_https() {
278 278
 		/*
279 279
 		* some servers pass the "HTTPS" parameter in the server variable,
280 280
 		* if is the case, check if the value is "on", "true", "1".
281 281
 		*/
282
-		if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off'){
282
+		if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') {
283 283
 			return true;
284 284
 		}
285
-		else if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'){
285
+		else if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
286 286
 			return true;
287 287
 		}
288
-		else if(isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off'){
288
+		else if (isset($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') {
289 289
 			return true;
290 290
 		}
291 291
 		return false;
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 	 *  
301 301
 	 *  @return boolean true if is a valid URL address or false.
302 302
 	 */
303
-	function is_url($url){
303
+	function is_url($url) {
304 304
 		return preg_match('/^(http|https|ftp):\/\/(.*)/', $url) == 1;
305 305
 	}
306 306
 	
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
 	 *  @param string $controllerClass the controller class name to be loaded
311 311
 	 *  @codeCoverageIgnore
312 312
 	 */
313
-	function autoload_controller($controllerClass){
314
-		if(file_exists($path = APPS_CONTROLLER_PATH . $controllerClass . '.php')){
313
+	function autoload_controller($controllerClass) {
314
+		if (file_exists($path = APPS_CONTROLLER_PATH . $controllerClass . '.php')) {
315 315
 			require_once $path;
316 316
 		}
317 317
 	}
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
 	 *  
326 326
 	 *  @return boolean
327 327
 	 */
328
-	function php_exception_handler($ex){
329
-		if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))){
330
-			show_error('An exception is occured in file '. $ex->getFile() .' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception #' . $ex->getCode());
328
+	function php_exception_handler($ex) {
329
+		if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))) {
330
+			show_error('An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception #' . $ex->getCode());
331 331
 		}
332
-		else{
332
+		else {
333 333
 			save_to_log('error', 'An exception is occured in file ' . $ex->getFile() . ' at line ' . $ex->getLine() . ' raison : ' . $ex->getMessage(), 'PHP Exception');
334 334
 		}
335 335
 		return true;
@@ -347,16 +347,16 @@  discard block
 block discarded – undo
347 347
 	 *  
348 348
 	 *  @return boolean	
349 349
 	 */
350
-	function php_error_handler($errno , $errstr, $errfile , $errline, array $errcontext = array()){
350
+	function php_error_handler($errno, $errstr, $errfile, $errline, array $errcontext = array()) {
351 351
 		$isError = (((E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR | E_USER_ERROR) & $errno) === $errno);
352
-		if($isError){
352
+		if ($isError) {
353 353
 			set_http_status_header(500);
354 354
 		}
355
-		if (! (error_reporting() & $errno)) {
355
+		if (!(error_reporting() & $errno)) {
356 356
 			save_to_log('error', 'An error is occurred in the file ' . $errfile . ' at line ' . $errline . ' raison : ' . $errstr, 'PHP ERROR');
357 357
 			return;
358 358
 		}
359
-		if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))){
359
+		if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors'))) {
360 360
 			$errorType = 'error';
361 361
 			switch ($errno) {
362 362
 				case E_USER_ERROR:
@@ -372,9 +372,9 @@  discard block
 block discarded – undo
372 372
 					$errorType = 'error';
373 373
 					break;
374 374
 			}
375
-			show_error('An error is occurred in the file <b>' . $errfile . '</b> at line <b>' . $errline .'</b> raison : ' . $errstr, 'PHP ' . $errorType);
375
+			show_error('An error is occurred in the file <b>' . $errfile . '</b> at line <b>' . $errline . '</b> raison : ' . $errstr, 'PHP ' . $errorType);
376 376
 		}
377
-		if ($isError){
377
+		if ($isError) {
378 378
 			die();
379 379
 		}
380 380
 		return true;
@@ -384,10 +384,10 @@  discard block
 block discarded – undo
384 384
 	 * This function is used to run in shutdown situation of the script
385 385
 	 * @codeCoverageIgnore
386 386
 	 */
387
-	function php_shudown_handler(){
387
+	function php_shudown_handler() {
388 388
 		$lastError = error_get_last();
389 389
 		if (isset($lastError) &&
390
-			($lastError['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING))){
390
+			($lastError['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING))) {
391 391
 			php_error_handler($lastError['type'], $lastError['message'], $lastError['file'], $lastError['line']);
392 392
 		}
393 393
 	}
@@ -405,11 +405,11 @@  discard block
 block discarded – undo
405 405
 	 *   
406 406
 	 *  @return string string of the HTML attribute.
407 407
 	 */
408
-	function attributes_to_string(array $attributes){
408
+	function attributes_to_string(array $attributes) {
409 409
 		$str = ' ';
410 410
 		//we check that the array passed as an argument is not empty.
411
-		if(! empty($attributes)){
412
-			foreach($attributes as $key => $value){
411
+		if (!empty($attributes)) {
412
+			foreach ($attributes as $key => $value) {
413 413
 				$key = trim(htmlspecialchars($key));
414 414
 				$value = trim(htmlspecialchars($value));
415 415
 				/*
@@ -419,10 +419,10 @@  discard block
 block discarded – undo
419 419
 				* 	$attr = array('placeholder' => 'I am a "puple"')
420 420
 				* 	$str = attributes_to_string($attr); => placeholder = "I am a \"puple\""
421 421
 				 */
422
-				if($value && strpos('"', $value) !== false){
422
+				if ($value && strpos('"', $value) !== false) {
423 423
 					$value = addslashes($value);
424 424
 				}
425
-				$str .= $key.' = "'.$value.'" ';
425
+				$str .= $key . ' = "' . $value . '" ';
426 426
 			}
427 427
 		}
428 428
 		//remove the space after using rtrim()
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 	*
439 439
 	* @return string the stringfy value
440 440
 	*/
441
-	function stringfy_vars($var){
441
+	function stringfy_vars($var) {
442 442
 		return print_r($var, true);
443 443
 	}
444 444
 
@@ -449,18 +449,18 @@  discard block
 block discarded – undo
449 449
 	 * 
450 450
 	 * @return mixed   the sanitize value
451 451
 	 */
452
-	function clean_input($str){
453
-		if(is_array($str)){
452
+	function clean_input($str) {
453
+		if (is_array($str)) {
454 454
 			$str = array_map('clean_input', $str);
455 455
 		}
456
-		else if(is_object($str)){
456
+		else if (is_object($str)) {
457 457
 			$obj = $str;
458 458
 			foreach ($str as $var => $value) {
459 459
 				$obj->$var = clean_input($value);
460 460
 			}
461 461
 			$str = $obj;
462 462
 		}
463
-		else{
463
+		else {
464 464
 			$str = htmlspecialchars(strip_tags($str), ENT_QUOTES, 'UTF-8');
465 465
 		}
466 466
 		return $str;
@@ -478,11 +478,11 @@  discard block
 block discarded – undo
478 478
 	 * 
479 479
 	 * @return string the string with the hidden part.
480 480
 	 */
481
-	function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*'){
481
+	function string_hidden($str, $startCount = 0, $endCount = 0, $hiddenChar = '*') {
482 482
 		//get the string length
483 483
 		$len = strlen($str);
484 484
 		//if str is empty
485
-		if($len <= 0){
485
+		if ($len <= 0) {
486 486
 			return str_repeat($hiddenChar, 6);
487 487
 		}
488 488
 		//if the length is less than startCount and endCount
@@ -490,14 +490,14 @@  discard block
 block discarded – undo
490 490
 		//or startCount is negative or endCount is negative
491 491
 		//return the full string hidden
492 492
 		
493
-		if((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)){
493
+		if ((($startCount + $endCount) > $len) || ($startCount == 0 && $endCount == 0) || ($startCount < 0 || $endCount < 0)) {
494 494
 			return str_repeat($hiddenChar, $len);
495 495
 		}
496 496
 		//the start non hidden string
497 497
 		$startNonHiddenStr = substr($str, 0, $startCount);
498 498
 		//the end non hidden string
499 499
 		$endNonHiddenStr = null;
500
-		if($endCount > 0){
500
+		if ($endCount > 0) {
501 501
 			$endNonHiddenStr = substr($str, - $endCount);
502 502
 		}
503 503
 		//the hidden string
@@ -510,31 +510,31 @@  discard block
 block discarded – undo
510 510
 	 * This function is used to set the initial session config regarding the configuration
511 511
 	 * @codeCoverageIgnore
512 512
 	 */
513
-	function set_session_config(){
513
+	function set_session_config() {
514 514
 		//$_SESSION is not available on cli mode 
515
-		if(! IS_CLI){
516
-			$logger =& class_loader('Log', 'classes');
515
+		if (!IS_CLI) {
516
+			$logger = & class_loader('Log', 'classes');
517 517
 			$logger->setLogger('PHPSession');
518 518
 			//set session params
519 519
 			$sessionHandler = get_config('session_handler', 'files'); //the default is to store in the files
520 520
 			$sessionName = get_config('session_name');
521
-			if($sessionName){
521
+			if ($sessionName) {
522 522
 				session_name($sessionName);
523 523
 			}
524 524
 			$logger->info('Session handler: ' . $sessionHandler);
525 525
 			$logger->info('Session name: ' . $sessionName);
526 526
 
527
-			if($sessionHandler == 'files'){
527
+			if ($sessionHandler == 'files') {
528 528
 				$sessionSavePath = get_config('session_save_path');
529
-				if($sessionSavePath){
530
-					if(! is_dir($sessionSavePath)){
529
+				if ($sessionSavePath) {
530
+					if (!is_dir($sessionSavePath)) {
531 531
 						mkdir($sessionSavePath, 1773);
532 532
 					}
533 533
 					session_save_path($sessionSavePath);
534 534
 					$logger->info('Session save path: ' . $sessionSavePath);
535 535
 				}
536 536
 			}
537
-			else if($sessionHandler == 'database'){
537
+			else if ($sessionHandler == 'database') {
538 538
 				//load database session handle library
539 539
 				//Model
540 540
 				require_once CORE_CLASSES_MODEL_PATH . 'Model.php';
@@ -542,11 +542,11 @@  discard block
 block discarded – undo
542 542
 				//Database Session handler Model
543 543
 				require_once CORE_CLASSES_MODEL_PATH . 'DBSessionHandlerModel.php';
544 544
 
545
-				$DBS =& class_loader('DBSessionHandler', 'classes');
545
+				$DBS = & class_loader('DBSessionHandler', 'classes');
546 546
 				session_set_save_handler($DBS, true);
547 547
 				$logger->info('session save path: ' . get_config('session_save_path'));
548 548
 			}
549
-			else{
549
+			else {
550 550
 				show_error('Invalid session handler configuration');
551 551
 			}
552 552
 			$lifetime = get_config('session_cookie_lifetime', 0);
@@ -569,9 +569,9 @@  discard block
 block discarded – undo
569 569
 			$logger->info('Session lifetime: ' . $lifetime);
570 570
 			$logger->info('Session cookie path: ' . $path);
571 571
 			$logger->info('Session domain: ' . $domain);
572
-			$logger->info('Session is secure: ' . ($secure ? 'TRUE':'FALSE'));
572
+			$logger->info('Session is secure: ' . ($secure ? 'TRUE' : 'FALSE'));
573 573
 			
574
-			if((function_exists('session_status') && session_status() !== PHP_SESSION_ACTIVE) || !session_id()){
574
+			if ((function_exists('session_status') && session_status() !== PHP_SESSION_ACTIVE) || !session_id()) {
575 575
 				$logger->info('Session not yet start, start it now');
576 576
 				session_start();
577 577
 			}
Please login to merge, or discard this patch.