Test Failed
Push — 1.0.0-dev ( 659da7...aa6afc )
by nguereza
04:16
created
core/classes/Log.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 	 * You should have received a copy of the GNU General Public License
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 26
 
27 27
 	class Log{
28 28
 		
Please login to merge, or discard this patch.
core/classes/Controller.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 	 * You should have received a copy of the GNU General Public License
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 26
 
27 27
 	class Controller{
28 28
 		
Please login to merge, or discard this patch.
core/libraries/Benchmark.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 	 * You should have received a copy of the GNU General Public License
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 26
 
27 27
 	/**
28 28
 	 * Class for Benchmark
Please login to merge, or discard this patch.
core/libraries/PDF.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * You should have received a copy of the GNU General Public License
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 26
 
27 27
 	/**
28 28
 	 * PDF library to generate PDF document using the library DOMPDF
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 		 * Create PDF library instance
46 46
 		 */
47 47
 		public function __construct(){
48
-	        $this->logger =& class_loader('Log', 'classes');
49
-	        $this->logger->setLogger('Library::PDF');
48
+			$this->logger =& class_loader('Log', 'classes');
49
+			$this->logger->setLogger('Library::PDF');
50 50
 
51 51
 			require_once VENDOR_PATH.'dompdf/dompdf_config.inc.php';
52 52
 			$this->dompdf = new Dompdf();
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 		}
77 77
 		
78 78
 		/**
79
-		* Return the instance of Dompdf
80
-		*
81
-		* @return object the dompdf instance
82
-		*/
79
+		 * Return the instance of Dompdf
80
+		 *
81
+		 * @return object the dompdf instance
82
+		 */
83 83
 		public function getDompdf(){
84 84
 			return $this->dompdf;
85 85
 		}
Please login to merge, or discard this patch.
core/libraries/Email.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 		protected $_uid;
75 75
 		
76 76
 		/**
77
-         * The logger instance
78
-         * @var Log
79
-         */
77
+		 * The logger instance
78
+		 * @var Log
79
+		 */
80 80
 		private $logger;
81 81
 
82 82
 		/**
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		public function __construct()
88 88
 		{
89 89
 			$this->logger =& class_loader('Log', 'classes');
90
-            $this->logger->setLogger('Library::Email');
90
+			$this->logger->setLogger('Library::Email');
91 91
 			$this->reset();
92 92
 		}
93 93
 
@@ -112,13 +112,13 @@  discard block
 block discarded – undo
112 112
 		}
113 113
 		
114 114
 		 /**
115
-		 * setFrom
116
-		 *
117
-		 * @param string $email The email to send as from.
118
-		 * @param string $name  The name to send as from.
119
-		 *
120
-		 * @return self
121
-		 */
115
+		  * setFrom
116
+		  *
117
+		  * @param string $email The email to send as from.
118
+		  * @param string $name  The name to send as from.
119
+		  *
120
+		  * @return self
121
+		  */
122 122
 		public function setFrom($email, $name = null)
123 123
 		{
124 124
 			$this->addMailHeader('From', (string) $email, (string) $name);
@@ -140,11 +140,11 @@  discard block
 block discarded – undo
140 140
 		}
141 141
 		
142 142
 		/**
143
-		* Set destination using array
144
-		* @params array $emails the list of recipient. This is an associative array name => email
145
-		* @example array('John Doe' => '[email protected]')
146
-		* @return Object the current instance
147
-		*/
143
+		 * Set destination using array
144
+		 * @params array $emails the list of recipient. This is an associative array name => email
145
+		 * @example array('John Doe' => '[email protected]')
146
+		 * @return Object the current instance
147
+		 */
148 148
 		public function setTos(array $emails)
149 149
 		{
150 150
 			foreach ($emails as $name => $email) {
Please login to merge, or discard this patch.
core/libraries/Cookie.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 	 * You should have received a copy of the GNU General Public License
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 26
 
27 27
 	class Cookie{
28 28
 		
Please login to merge, or discard this patch.
core/libraries/Assets.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 	 * You should have received a copy of the GNU General Public License
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 26
 
27 27
 	/**
28 28
 	 *  @file Assets.php
Please login to merge, or discard this patch.
core/libraries/FormValidation.php 1 patch
Indentation   +877 added lines, -877 removed lines patch added patch discarded remove patch
@@ -1,918 +1,918 @@
 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
-     class FormValidation{
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
+	 class FormValidation{
29 29
 		 
30
-        /**
31
-         * The form validation status
32
-         * @var boolean
33
-         */
34
-        protected $_success  = false;
35
-
36
-        /**
37
-         * The list of errors messages
38
-         * @var array
39
-         */
40
-        protected $_errorsMessages = array();
30
+		/**
31
+		 * The form validation status
32
+		 * @var boolean
33
+		 */
34
+		protected $_success  = false;
35
+
36
+		/**
37
+		 * The list of errors messages
38
+		 * @var array
39
+		 */
40
+		protected $_errorsMessages = array();
41 41
         
42
-        // Array of rule sets, fieldName => PIPE seperated ruleString
43
-        protected $_rules             = array();
42
+		// Array of rule sets, fieldName => PIPE seperated ruleString
43
+		protected $_rules             = array();
44 44
         
45
-        // Array of errors, niceName => Error Message
46
-        protected $_errors             = array();
45
+		// Array of errors, niceName => Error Message
46
+		protected $_errors             = array();
47 47
         
48
-        // Array of post Key => Nice name labels
49
-        protected $_labels          = array();
48
+		// Array of post Key => Nice name labels
49
+		protected $_labels          = array();
50 50
         
51
-        /**
52
-         * The errors delimiters
53
-         * @var array
54
-         */
55
-        protected $_allErrorsDelimiter   = array('<div class="error">', '</div>');
56
-
57
-        /**
58
-         * The each error delimiter
59
-         * @var array
60
-         */
61
-        protected $_eachErrorDelimiter   = array('<p class="error">', '</p>');
51
+		/**
52
+		 * The errors delimiters
53
+		 * @var array
54
+		 */
55
+		protected $_allErrorsDelimiter   = array('<div class="error">', '</div>');
56
+
57
+		/**
58
+		 * The each error delimiter
59
+		 * @var array
60
+		 */
61
+		protected $_eachErrorDelimiter   = array('<p class="error">', '</p>');
62 62
         
63 63
 		/**
64
-         * Indicated if need force the validation to be failed
65
-         * @var boolean
66
-         */
67
-        protected $_forceFail            = false;
68
-
69
-        /**
70
-         * The list of the error messages overrides by the original
71
-         * @var array
72
-         */
73
-        protected $_errorPhraseOverrides = array();
74
-
75
-        /**
76
-         * The logger instance
77
-         * @var Log
78
-         */
79
-        private $logger;
80
-
81
-        /**
82
-         * The data to be validated, the default is to use $_POST
83
-         * @var array
84
-         */
85
-        private $data = array();
86
-
87
-        /**
88
-         * Whether to check the CSRF. This attribute is just a way to allow custom change of the 
64
+		 * Indicated if need force the validation to be failed
65
+		 * @var boolean
66
+		 */
67
+		protected $_forceFail            = false;
68
+
69
+		/**
70
+		 * The list of the error messages overrides by the original
71
+		 * @var array
72
+		 */
73
+		protected $_errorPhraseOverrides = array();
74
+
75
+		/**
76
+		 * The logger instance
77
+		 * @var Log
78
+		 */
79
+		private $logger;
80
+
81
+		/**
82
+		 * The data to be validated, the default is to use $_POST
83
+		 * @var array
84
+		 */
85
+		private $data = array();
86
+
87
+		/**
88
+		 * Whether to check the CSRF. This attribute is just a way to allow custom change of the 
89 89
 		 * CSRF global configuration
90 90
 		 *
91
-         * @var boolean
92
-         */
93
-        public $enableCsrfCheck = false;
94
-
95
-        /**
96
-         * Set all errors and rule sets empty, and sets success to false.
97
-         *
98
-         * @return void
99
-         */
100
-        public function __construct() {
101
-            $this->logger =& class_loader('Log', 'classes');
102
-            $this->logger->setLogger('Library::FormValidation');
91
+		 * @var boolean
92
+		 */
93
+		public $enableCsrfCheck = false;
94
+
95
+		/**
96
+		 * Set all errors and rule sets empty, and sets success to false.
97
+		 *
98
+		 * @return void
99
+		 */
100
+		public function __construct() {
101
+			$this->logger =& class_loader('Log', 'classes');
102
+			$this->logger->setLogger('Library::FormValidation');
103 103
            
104 104
 		   //Load form validation language message
105
-            Loader::lang('form_validation');
106
-            $obj = & get_instance();
107
-            $this->_errorsMessages  = array(
108
-                        'required'         => $obj->lang->get('fv_required'),
109
-                        'min_length'       => $obj->lang->get('fv_min_length'),
110
-                        'max_length'       => $obj->lang->get('fv_max_length'),
111
-                        'exact_length'     => $obj->lang->get('fv_exact_length'),
112
-                        'less_than'        => $obj->lang->get('fv_less_than'),
113
-                        'greater_than'     => $obj->lang->get('fv_greater_than'),
114
-                        'matches'          => $obj->lang->get('fv_matches'),
115
-                        'valid_email'      => $obj->lang->get('fv_valid_email'),
116
-                        'not_equal'        => array(
117
-                                                'post:key' => $obj->lang->get('fv_not_equal_post_key'),
118
-                                                'string'   => $obj->lang->get('fv_not_equal_string')
119
-                                            ),
120
-                        'depends'          => $obj->lang->get('fv_depends'),
121
-                        'is_unique'        => $obj->lang->get('fv_is_unique'),
122
-                        'is_unique_update' => $obj->lang->get('fv_is_unique_update'),
123
-                        'exists'           => $obj->lang->get('fv_exists'),
124
-                        'regex'            => $obj->lang->get('fv_regex'),
125
-                        'in_list'          => $obj->lang->get('fv_in_list'),
126
-                        'numeric'          => $obj->lang->get('fv_numeric'),
127
-                        'callback'         => $obj->lang->get('fv_callback'),
128
-                    );
129
-            $this->_resetValidation();
130
-            $this->setData($obj->request->post(null));
131
-        }
132
-
133
-        /**
134
-         * Reset the form validation instance
135
-         */
136
-        protected function _resetValidation() {
137
-            $this->_rules                = array();
138
-            $this->_labels               = array();
139
-            $this->_errorPhraseOverrides = array();
140
-            $this->_errors               = array();
141
-            $this->_success              = false;
142
-            $this->_forceFail            = false;
143
-            $this->data                  = array();
105
+			Loader::lang('form_validation');
106
+			$obj = & get_instance();
107
+			$this->_errorsMessages  = array(
108
+						'required'         => $obj->lang->get('fv_required'),
109
+						'min_length'       => $obj->lang->get('fv_min_length'),
110
+						'max_length'       => $obj->lang->get('fv_max_length'),
111
+						'exact_length'     => $obj->lang->get('fv_exact_length'),
112
+						'less_than'        => $obj->lang->get('fv_less_than'),
113
+						'greater_than'     => $obj->lang->get('fv_greater_than'),
114
+						'matches'          => $obj->lang->get('fv_matches'),
115
+						'valid_email'      => $obj->lang->get('fv_valid_email'),
116
+						'not_equal'        => array(
117
+												'post:key' => $obj->lang->get('fv_not_equal_post_key'),
118
+												'string'   => $obj->lang->get('fv_not_equal_string')
119
+											),
120
+						'depends'          => $obj->lang->get('fv_depends'),
121
+						'is_unique'        => $obj->lang->get('fv_is_unique'),
122
+						'is_unique_update' => $obj->lang->get('fv_is_unique_update'),
123
+						'exists'           => $obj->lang->get('fv_exists'),
124
+						'regex'            => $obj->lang->get('fv_regex'),
125
+						'in_list'          => $obj->lang->get('fv_in_list'),
126
+						'numeric'          => $obj->lang->get('fv_numeric'),
127
+						'callback'         => $obj->lang->get('fv_callback'),
128
+					);
129
+			$this->_resetValidation();
130
+			$this->setData($obj->request->post(null));
131
+		}
132
+
133
+		/**
134
+		 * Reset the form validation instance
135
+		 */
136
+		protected function _resetValidation() {
137
+			$this->_rules                = array();
138
+			$this->_labels               = array();
139
+			$this->_errorPhraseOverrides = array();
140
+			$this->_errors               = array();
141
+			$this->_success              = false;
142
+			$this->_forceFail            = false;
143
+			$this->data                  = array();
144 144
 			$this->enableCsrfCheck       = false;
145
-        }
145
+		}
146 146
 
147
-        /**
148
-         * Set the form validation data
149
-         * @param array $data the values to be validated
147
+		/**
148
+		 * Set the form validation data
149
+		 * @param array $data the values to be validated
150 150
 		 *
151
-         * @return FormValidation Current instance of object.
152
-         */
153
-        public function setData(array $data){
154
-            $this->logger->debug('Setting the form validation data, the values are: ' . stringfy_vars($data));
155
-            $this->data = $data;
151
+		 * @return FormValidation Current instance of object.
152
+		 */
153
+		public function setData(array $data){
154
+			$this->logger->debug('Setting the form validation data, the values are: ' . stringfy_vars($data));
155
+			$this->data = $data;
156 156
 			return $this;
157
-        }
158
-
159
-        /**
160
-         * Get the form validation data
161
-         * @return array the form validation data to be validated
162
-         */
163
-        public function getData(){
164
-            return $this->data;
165
-        }
166
-
167
-		/**
168
-		* Get the validation function name to validate a rule
169
-		*
170
-		* @return string the function name
171
-		*/
172
-        protected function _toCallCase($funcName, $prefix='_validate') {
173
-            $funcName = strtolower($funcName);
174
-            $finalFuncName = $prefix;
175
-            foreach (explode('_', $funcName) as $funcNamePart) {
176
-                $finalFuncName .= strtoupper($funcNamePart[0]) . substr($funcNamePart, 1);
177
-            }
178
-            return $finalFuncName;
179
-        }
180
-
181
-        /**
182
-         * Returns the boolean of the data status success. It goes by the simple
183
-         *
184
-         * @return boolean Whether or not the data validation has succeeded
185
-         */
186
-        public function isSuccess() {
187
-            return $this->_success;
188
-        }
189
-
190
-        /**
191
-         * Checks if the request method is POST or the Data to be validated is set
192
-         *
193
-         * @return boolean Whether or not the form has been submitted or the data is available for validation.
194
-         */
195
-        public function canDoValidation() {
196
-            return get_instance()->request->method() === 'POST' || ! empty($this->data);
197
-        }
198
-
199
-        /**
200
-         * Runs _run once POST data has been submitted or data is set manually.
201
-         *
202
-         * @return boolean
203
-         */
204
-        public function run() {
205
-            if ($this->canDoValidation()) {
206
-                $this->logger->info('The data to validate are listed below: ' . stringfy_vars($this->getData()));
207
-                $this->_run();
208
-            }
209
-            return $this->isSuccess();
210
-        }
211
-
212
-        /**
213
-         * Takes and trims each data, if it has any rules, we parse the rule string and run
214
-         * each rule against the data value. Sets _success to true if there are no errors
215
-         * afterwards.
216
-         */
217
-        protected function _run() {
218
-            if(get_instance()->request->method() == 'POST' || $this->enableCsrfCheck){
219
-                $this->logger->debug('Check if CSRF is enabled in configuration');
220
-                //first check for CSRF
221
-                if( get_config('csrf_enable', false) || $this->enableCsrfCheck){
222
-                     $this->logger->info('Check the CSRF value if is valid');
223
-                    if(! Security::validateCSRF()){
224
-                        show_error('Invalide data, Cross Site Request Forgery do his job, the data to validate is corrupted.');
225
-                    }
226
-                }
227
-                else{
228
-                    $this->logger->info('CSRF is not enabled in configuration or not set manully, no need to check it');
229
-                }
230
-            }
231
-            /////////////////////////////////////////////
232
-            $this->_forceFail = false;
233
-
234
-            foreach ($this->getData() as $inputName => $inputVal) {
235
-    			if(is_array($this->data[$inputName])){
236
-    				$this->data[$inputName] = array_map('trim', $this->data[$inputName]);
237
-    			}
238
-    			else{
239
-    				$this->data[$inputName] = trim($this->data[$inputName]);
240
-    			}
241
-
242
-                if (array_key_exists($inputName, $this->_rules)) {
243
-                    foreach ($this->_parseRuleString($this->_rules[$inputName]) as $eachRule) {
244
-                        $this->_validateRule($inputName, $this->data[$inputName], $eachRule);
245
-                    }
246
-                }
247
-            }
248
-
249
-            if (empty($this->_errors) && $this->_forceFail === false) {
250
-                $this->_success = true;
251
-            }
252
-        }
253
-
254
-        /**
255
-         * Adds a rule to a form data validation field.
256
-         *
257
-         * @param string $inputField Name of the field or the data key to add a rule to
258
-         * @param string $ruleSets PIPE seperated string of rules
259
-		 *
260
-         * @return FormValidation Current instance of object.
261
-         */
262
-        public function setRule($inputField, $inputLabel, $ruleSets) {
263
-            $this->_rules[$inputField] = $ruleSets;
264
-            $this->_labels[$inputField] = $inputLabel;
265
-            $this->logger->info('Set the field rule: name [' .$inputField. '], label [' .$inputLabel. '], rules [' .$ruleSets. ']');
266
-            return $this;
267
-        }
268
-
269
-        /**
270
-         * Takes an array of rules and uses setRule() to set them, accepts an array
271
-         * of rule names rather than a pipe-delimited string as well.
272
-         * @param array $ruleSets
157
+		}
158
+
159
+		/**
160
+		 * Get the form validation data
161
+		 * @return array the form validation data to be validated
162
+		 */
163
+		public function getData(){
164
+			return $this->data;
165
+		}
166
+
167
+		/**
168
+		 * Get the validation function name to validate a rule
169
+		 *
170
+		 * @return string the function name
171
+		 */
172
+		protected function _toCallCase($funcName, $prefix='_validate') {
173
+			$funcName = strtolower($funcName);
174
+			$finalFuncName = $prefix;
175
+			foreach (explode('_', $funcName) as $funcNamePart) {
176
+				$finalFuncName .= strtoupper($funcNamePart[0]) . substr($funcNamePart, 1);
177
+			}
178
+			return $finalFuncName;
179
+		}
180
+
181
+		/**
182
+		 * Returns the boolean of the data status success. It goes by the simple
183
+		 *
184
+		 * @return boolean Whether or not the data validation has succeeded
185
+		 */
186
+		public function isSuccess() {
187
+			return $this->_success;
188
+		}
189
+
190
+		/**
191
+		 * Checks if the request method is POST or the Data to be validated is set
192
+		 *
193
+		 * @return boolean Whether or not the form has been submitted or the data is available for validation.
194
+		 */
195
+		public function canDoValidation() {
196
+			return get_instance()->request->method() === 'POST' || ! empty($this->data);
197
+		}
198
+
199
+		/**
200
+		 * Runs _run once POST data has been submitted or data is set manually.
201
+		 *
202
+		 * @return boolean
203
+		 */
204
+		public function run() {
205
+			if ($this->canDoValidation()) {
206
+				$this->logger->info('The data to validate are listed below: ' . stringfy_vars($this->getData()));
207
+				$this->_run();
208
+			}
209
+			return $this->isSuccess();
210
+		}
211
+
212
+		/**
213
+		 * Takes and trims each data, if it has any rules, we parse the rule string and run
214
+		 * each rule against the data value. Sets _success to true if there are no errors
215
+		 * afterwards.
216
+		 */
217
+		protected function _run() {
218
+			if(get_instance()->request->method() == 'POST' || $this->enableCsrfCheck){
219
+				$this->logger->debug('Check if CSRF is enabled in configuration');
220
+				//first check for CSRF
221
+				if( get_config('csrf_enable', false) || $this->enableCsrfCheck){
222
+					 $this->logger->info('Check the CSRF value if is valid');
223
+					if(! Security::validateCSRF()){
224
+						show_error('Invalide data, Cross Site Request Forgery do his job, the data to validate is corrupted.');
225
+					}
226
+				}
227
+				else{
228
+					$this->logger->info('CSRF is not enabled in configuration or not set manully, no need to check it');
229
+				}
230
+			}
231
+			/////////////////////////////////////////////
232
+			$this->_forceFail = false;
233
+
234
+			foreach ($this->getData() as $inputName => $inputVal) {
235
+				if(is_array($this->data[$inputName])){
236
+					$this->data[$inputName] = array_map('trim', $this->data[$inputName]);
237
+				}
238
+				else{
239
+					$this->data[$inputName] = trim($this->data[$inputName]);
240
+				}
241
+
242
+				if (array_key_exists($inputName, $this->_rules)) {
243
+					foreach ($this->_parseRuleString($this->_rules[$inputName]) as $eachRule) {
244
+						$this->_validateRule($inputName, $this->data[$inputName], $eachRule);
245
+					}
246
+				}
247
+			}
248
+
249
+			if (empty($this->_errors) && $this->_forceFail === false) {
250
+				$this->_success = true;
251
+			}
252
+		}
253
+
254
+		/**
255
+		 * Adds a rule to a form data validation field.
256
+		 *
257
+		 * @param string $inputField Name of the field or the data key to add a rule to
258
+		 * @param string $ruleSets PIPE seperated string of rules
273 259
 		 *
274 260
 		 * @return FormValidation Current instance of object.
275
-         */
276
-        public function setRules(array $ruleSets) {
277
-            foreach ($ruleSets as $ruleSet) {
278
-                $pipeDelimitedRules = null;
279
-                if (is_array($ruleSet['rules'])) {
280
-                    $pipeDelimitedRules = implode('|', $ruleSet['rules']);
281
-                } else {
282
-                    $pipeDelimitedRules = $ruleSet['rules'];
283
-                }
284
-                $this->setRule($ruleSet['name'], $ruleSet['label'], $pipeDelimitedRules);
285
-            }
286
-            return $this;
287
-        }
288
-
289
-        /**
290
-         * This method creates the global errors delimiter, each argument occurs once, at the beginning, and
291
-         * end of the errors block respectively.
292
-         *
293
-         * @param string $start Before block of errors gets displayed, HTML allowed.
294
-         * @param string $end After the block of errors gets displayed, HTML allowed.
295
-         *
261
+		 */
262
+		public function setRule($inputField, $inputLabel, $ruleSets) {
263
+			$this->_rules[$inputField] = $ruleSets;
264
+			$this->_labels[$inputField] = $inputLabel;
265
+			$this->logger->info('Set the field rule: name [' .$inputField. '], label [' .$inputLabel. '], rules [' .$ruleSets. ']');
266
+			return $this;
267
+		}
268
+
269
+		/**
270
+		 * Takes an array of rules and uses setRule() to set them, accepts an array
271
+		 * of rule names rather than a pipe-delimited string as well.
272
+		 * @param array $ruleSets
273
+		 *
296 274
 		 * @return FormValidation Current instance of object.
297
-         */
298
-        public function setErrorsDelimiter($start, $end) {
299
-            $this->_allErrorsDelimiter[0] = $start;
300
-            $this->_allErrorsDelimiter[1] = $end;
301
-            return $this;
302
-        }
303
-
304
-        /**
305
-         * This is the individual error delimiter, each argument occurs once before and after
306
-         * each individual error listed.
307
-         *
308
-         * @param string $start Displayed before each error.
309
-         * @param string $end Displayed after each error.
310
-         * 
275
+		 */
276
+		public function setRules(array $ruleSets) {
277
+			foreach ($ruleSets as $ruleSet) {
278
+				$pipeDelimitedRules = null;
279
+				if (is_array($ruleSet['rules'])) {
280
+					$pipeDelimitedRules = implode('|', $ruleSet['rules']);
281
+				} else {
282
+					$pipeDelimitedRules = $ruleSet['rules'];
283
+				}
284
+				$this->setRule($ruleSet['name'], $ruleSet['label'], $pipeDelimitedRules);
285
+			}
286
+			return $this;
287
+		}
288
+
289
+		/**
290
+		 * This method creates the global errors delimiter, each argument occurs once, at the beginning, and
291
+		 * end of the errors block respectively.
292
+		 *
293
+		 * @param string $start Before block of errors gets displayed, HTML allowed.
294
+		 * @param string $end After the block of errors gets displayed, HTML allowed.
295
+		 *
311 296
 		 * @return FormValidation Current instance of object.
312
-         */
313
-        public function setErrorDelimiter($start, $end) {
314
-            $this->_eachErrorDelimiter[0] = $start;
315
-            $this->_eachErrorDelimiter[1] = $end;
316
-            return $this;
317
-        }
318
-
319
-		/**
320
-		* Get the each errors delimiters
321
-		*
322
-		* @return array
323
-		*/
324
-    	public function getErrorDelimiter() {
325
-            return $this->_eachErrorDelimiter;
326
-        }
327
-
328
-		/**
329
-		* Get the all errors delimiters
330
-		*
331
-		* @return array
332
-		*/
333
-    	public function getErrorsDelimiter() {
334
-            return $this->_allErrorsDelimiter;
335
-        }
336
-
337
-        /**
338
-         * This sets a custom error message that can override the default error phrase provided
339
-         * by FormValidation, it can be used in the format of setMessage('rule', 'error phrase')
340
-         * which will globally change the error phrase of that rule, or in the format of:
341
-         * setMessage('rule', 'fieldname', 'error phrase') - which will only change the error phrase for
342
-         * that rule, applied on that field.
343
-         *
344
-         * @return boolean True on success, false on failure.
345
-         */
346
-        public function setMessage() {
347
-            $numArgs = func_num_args();
348
-            switch ($numArgs) {
349
-                default:
350
-                    return false;
351
-                    break;
352
-                // A global rule error message
353
-                case 2:
354
-                    foreach ($this->post(null) as $key => $val) {
355
-                        $this->_errorPhraseOverrides[$key][func_get_arg(0)] = func_get_arg(1);
356
-                    }
357
-                    break;
358
-                // Field specific rule error message
359
-                case 3:
360
-                    $this->_errorPhraseOverrides[func_get_arg(1)][func_get_arg(0)] = func_get_arg(2);
361
-                    break;
362
-            }
363
-            return true;
364
-        }
365
-
366
-        /**
367
-         * Adds a custom error message in the errorSet array, that will
368
-         * forcibly display it.
369
-         *
370
-         * @param string $inputName The form input name or data key
371
-         * @param string $errorMessage Error to display
372
-		 *
373
-         * @return formValidation Current instance of the object
374
-         */
375
-        public function setCustomError($inputName, $errorMessage) {
376
-            $errorMessage = str_replace('%1', $this->_labels[$inputName], $errorMessage);
377
-            $this->_errors[$inputName] = $errorMessage;
378
-            return $this;
379
-        }
380
-
381
-        /**
382
-         * Allows for an accesor to any/all post values, if a value of null is passed as the key, it
383
-         * will recursively find all keys/values of the $_POST array or data array. It also automatically trims
384
-         * all values.
385
-         *
386
-         * @param string $key Key of $this->data to be found, pass null for all Key => Val pairs.
387
-         * @param boolean $trim Defaults to true, trims all $this->data values.
388
-         * @return string/array Array of post or data values if null is passed as key, string if only one key is desired.
389
-         */
390
-        public function post($key = null, $trim = true) {
391
-            $returnValue = null;
392
-            if (is_null($key)) {
393
-                $returnValue = array();
394
-                foreach ($this->getData()  as $key => $val) {
395
-                    $returnValue[$key] = $this->post($key, $trim);
396
-                }
397
-            } else {
398
-                $returnValue = (array_key_exists($key, $this->getData())) ? (($trim) ? trim($this->data[$key]) : $this->data[$key]) : false;
399
-            }
400
-            return $returnValue;
401
-        }
402
-
403
-        /**
404
-         * Gets all errors from errorSet and displays them, can be echo out from the
405
-         * function or just returned.
406
-         *
407
-         * @param boolean $limit number of error to display or return
408
-         * @param boolean $echo Whether or not the values are to be returned or displayed
409
-		 *
410
-         * @return string Errors formatted for output
411
-         */
412
-        public function displayErrors($limit = null, $echo = true) {
413
-            list($errorsStart, $errorsEnd) = $this->_allErrorsDelimiter;
414
-            list($errorStart, $errorEnd) = $this->_eachErrorDelimiter;
415
-            $errorOutput = $errorsStart;
416
-    		$i = 0;
417
-            if (!empty($this->_errors)) {
418
-                foreach ($this->_errors as $fieldName => $error) {
419
-        	    	if ($i === $limit) { 
420
-                        break; 
421
-                    }
422
-                    $errorOutput .= $errorStart;
423
-                    $errorOutput .= $error;
424
-                    $errorOutput .= $errorEnd;
425
-                    $i++;
426
-                }
427
-            }
428
-            $errorOutput .= $errorsEnd;
429
-            echo ($echo) ? $errorOutput : '';
430
-            return (! $echo) ? $errorOutput : null;
431
-        }
432
-
433
-        /**
434
-         * Returns raw array of errors in no format instead of displaying them
435
-         * formatted.
436
-         *
437
-         * @return array
438
-         */
439
-        public function returnErrors() {
440
-            return $this->_errors;
441
-        }
442
-
443
-        /**
444
-         * Breaks up a PIPE seperated string of rules, and puts them into an array.
445
-         *
446
-         * @param string $ruleString String to be parsed.
447
-		 *
448
-         * @return array Array of each value in original string.
449
-         */
450
-        protected function _parseRuleString($ruleString) {
451
-            $ruleSets = array();
452
-            /*
297
+		 */
298
+		public function setErrorsDelimiter($start, $end) {
299
+			$this->_allErrorsDelimiter[0] = $start;
300
+			$this->_allErrorsDelimiter[1] = $end;
301
+			return $this;
302
+		}
303
+
304
+		/**
305
+		 * This is the individual error delimiter, each argument occurs once before and after
306
+		 * each individual error listed.
307
+		 *
308
+		 * @param string $start Displayed before each error.
309
+		 * @param string $end Displayed after each error.
310
+		 * 
311
+		 * @return FormValidation Current instance of object.
312
+		 */
313
+		public function setErrorDelimiter($start, $end) {
314
+			$this->_eachErrorDelimiter[0] = $start;
315
+			$this->_eachErrorDelimiter[1] = $end;
316
+			return $this;
317
+		}
318
+
319
+		/**
320
+		 * Get the each errors delimiters
321
+		 *
322
+		 * @return array
323
+		 */
324
+		public function getErrorDelimiter() {
325
+			return $this->_eachErrorDelimiter;
326
+		}
327
+
328
+		/**
329
+		 * Get the all errors delimiters
330
+		 *
331
+		 * @return array
332
+		 */
333
+		public function getErrorsDelimiter() {
334
+			return $this->_allErrorsDelimiter;
335
+		}
336
+
337
+		/**
338
+		 * This sets a custom error message that can override the default error phrase provided
339
+		 * by FormValidation, it can be used in the format of setMessage('rule', 'error phrase')
340
+		 * which will globally change the error phrase of that rule, or in the format of:
341
+		 * setMessage('rule', 'fieldname', 'error phrase') - which will only change the error phrase for
342
+		 * that rule, applied on that field.
343
+		 *
344
+		 * @return boolean True on success, false on failure.
345
+		 */
346
+		public function setMessage() {
347
+			$numArgs = func_num_args();
348
+			switch ($numArgs) {
349
+				default:
350
+					return false;
351
+					break;
352
+				// A global rule error message
353
+				case 2:
354
+					foreach ($this->post(null) as $key => $val) {
355
+						$this->_errorPhraseOverrides[$key][func_get_arg(0)] = func_get_arg(1);
356
+					}
357
+					break;
358
+				// Field specific rule error message
359
+				case 3:
360
+					$this->_errorPhraseOverrides[func_get_arg(1)][func_get_arg(0)] = func_get_arg(2);
361
+					break;
362
+			}
363
+			return true;
364
+		}
365
+
366
+		/**
367
+		 * Adds a custom error message in the errorSet array, that will
368
+		 * forcibly display it.
369
+		 *
370
+		 * @param string $inputName The form input name or data key
371
+		 * @param string $errorMessage Error to display
372
+		 *
373
+		 * @return formValidation Current instance of the object
374
+		 */
375
+		public function setCustomError($inputName, $errorMessage) {
376
+			$errorMessage = str_replace('%1', $this->_labels[$inputName], $errorMessage);
377
+			$this->_errors[$inputName] = $errorMessage;
378
+			return $this;
379
+		}
380
+
381
+		/**
382
+		 * Allows for an accesor to any/all post values, if a value of null is passed as the key, it
383
+		 * will recursively find all keys/values of the $_POST array or data array. It also automatically trims
384
+		 * all values.
385
+		 *
386
+		 * @param string $key Key of $this->data to be found, pass null for all Key => Val pairs.
387
+		 * @param boolean $trim Defaults to true, trims all $this->data values.
388
+		 * @return string/array Array of post or data values if null is passed as key, string if only one key is desired.
389
+		 */
390
+		public function post($key = null, $trim = true) {
391
+			$returnValue = null;
392
+			if (is_null($key)) {
393
+				$returnValue = array();
394
+				foreach ($this->getData()  as $key => $val) {
395
+					$returnValue[$key] = $this->post($key, $trim);
396
+				}
397
+			} else {
398
+				$returnValue = (array_key_exists($key, $this->getData())) ? (($trim) ? trim($this->data[$key]) : $this->data[$key]) : false;
399
+			}
400
+			return $returnValue;
401
+		}
402
+
403
+		/**
404
+		 * Gets all errors from errorSet and displays them, can be echo out from the
405
+		 * function or just returned.
406
+		 *
407
+		 * @param boolean $limit number of error to display or return
408
+		 * @param boolean $echo Whether or not the values are to be returned or displayed
409
+		 *
410
+		 * @return string Errors formatted for output
411
+		 */
412
+		public function displayErrors($limit = null, $echo = true) {
413
+			list($errorsStart, $errorsEnd) = $this->_allErrorsDelimiter;
414
+			list($errorStart, $errorEnd) = $this->_eachErrorDelimiter;
415
+			$errorOutput = $errorsStart;
416
+			$i = 0;
417
+			if (!empty($this->_errors)) {
418
+				foreach ($this->_errors as $fieldName => $error) {
419
+					if ($i === $limit) { 
420
+						break; 
421
+					}
422
+					$errorOutput .= $errorStart;
423
+					$errorOutput .= $error;
424
+					$errorOutput .= $errorEnd;
425
+					$i++;
426
+				}
427
+			}
428
+			$errorOutput .= $errorsEnd;
429
+			echo ($echo) ? $errorOutput : '';
430
+			return (! $echo) ? $errorOutput : null;
431
+		}
432
+
433
+		/**
434
+		 * Returns raw array of errors in no format instead of displaying them
435
+		 * formatted.
436
+		 *
437
+		 * @return array
438
+		 */
439
+		public function returnErrors() {
440
+			return $this->_errors;
441
+		}
442
+
443
+		/**
444
+		 * Breaks up a PIPE seperated string of rules, and puts them into an array.
445
+		 *
446
+		 * @param string $ruleString String to be parsed.
447
+		 *
448
+		 * @return array Array of each value in original string.
449
+		 */
450
+		protected function _parseRuleString($ruleString) {
451
+			$ruleSets = array();
452
+			/*
453 453
             //////////////// hack for regex rule that can contain "|"
454 454
             */
455
-            if(strpos($ruleString, 'regex') !== false){
456
-                $regexRule = array();
457
-                $rule = '#regex\[\/(.*)\/([a-zA-Z0-9]?)\]#';
458
-                preg_match($rule, $ruleString, $regexRule);
459
-                $ruleStringTemp = preg_replace($rule, '', $ruleString);
460
-                 if(isset($regexRule[0]) && !empty($regexRule[0])){
461
-                     $ruleSets[] = $regexRule[0];
462
-                 }
463
-                 $ruleStringRegex = explode('|', $ruleStringTemp);
464
-                 if(is_array($ruleStringRegex)){
465
-                    foreach ($ruleStringRegex as $rule) {
466
-                        $rule = trim($rule);
467
-                        if($rule){
468
-                            $ruleSets[] = $rule;
469
-                        }
470
-                    }
471
-                 }
472
-            }
473
-            /***********************************/
474
-            else{
475
-                if (strpos($ruleString, '|') !== FALSE) {
476
-                    $ruleSets = explode('|', $ruleString);
477
-                } else {
478
-                    $ruleSets[] = $ruleString;
479
-                }
480
-             }
481
-            return $ruleSets;
482
-        }
483
-
484
-        /**
485
-         * Returns whether or not a field obtains the rule "required".
486
-         *
487
-         * @param string $fieldName Field to check if required.
488
-		 *
489
-         * @return boolean Whether or not the field is required.
490
-         */
491
-        protected function _fieldIsRequired($fieldName) {
492
-            $rules = $this->_parseRuleString($this->_rules[$fieldName]);
493
-            return (in_array('required', $rules));
494
-        }
495
-
496
-        /**
497
-         * Takes a data input name, it's value, and the rule it's being validated against (ex: max_length[16])
498
-         * and adds an error to the errorSet if it fails validation of the rule.
499
-         *
500
-         * @param string $inputName Name or key of the validation data
501
-         * @param string $inputVal Value of the validation data
502
-         * @param string $ruleName Rule to be validated against, including args (exact_length[5])
503
-         * @return void
504
-         */
505
-        protected function _validateRule($inputName, $inputVal, $ruleName) {
506
-            $this->logger->debug('Rule validation of field [' .$inputName. '], value [' .$inputVal. '], rule [' .$ruleName. ']');
507
-            // Array to store args
508
-            $ruleArgs = array();
509
-
510
-            // Get the rule arguments, realRule is just the base rule name
511
-            // Like min_length instead of min_length[3]
512
-            $realRule = preg_match('/\[(.*)\]/', $ruleName, $ruleArgs);
513
-            $ruleName = preg_replace('/\[(.*)\]/', '', $ruleName);
455
+			if(strpos($ruleString, 'regex') !== false){
456
+				$regexRule = array();
457
+				$rule = '#regex\[\/(.*)\/([a-zA-Z0-9]?)\]#';
458
+				preg_match($rule, $ruleString, $regexRule);
459
+				$ruleStringTemp = preg_replace($rule, '', $ruleString);
460
+				 if(isset($regexRule[0]) && !empty($regexRule[0])){
461
+					 $ruleSets[] = $regexRule[0];
462
+				 }
463
+				 $ruleStringRegex = explode('|', $ruleStringTemp);
464
+				 if(is_array($ruleStringRegex)){
465
+					foreach ($ruleStringRegex as $rule) {
466
+						$rule = trim($rule);
467
+						if($rule){
468
+							$ruleSets[] = $rule;
469
+						}
470
+					}
471
+				 }
472
+			}
473
+			/***********************************/
474
+			else{
475
+				if (strpos($ruleString, '|') !== FALSE) {
476
+					$ruleSets = explode('|', $ruleString);
477
+				} else {
478
+					$ruleSets[] = $ruleString;
479
+				}
480
+			 }
481
+			return $ruleSets;
482
+		}
483
+
484
+		/**
485
+		 * Returns whether or not a field obtains the rule "required".
486
+		 *
487
+		 * @param string $fieldName Field to check if required.
488
+		 *
489
+		 * @return boolean Whether or not the field is required.
490
+		 */
491
+		protected function _fieldIsRequired($fieldName) {
492
+			$rules = $this->_parseRuleString($this->_rules[$fieldName]);
493
+			return (in_array('required', $rules));
494
+		}
495
+
496
+		/**
497
+		 * Takes a data input name, it's value, and the rule it's being validated against (ex: max_length[16])
498
+		 * and adds an error to the errorSet if it fails validation of the rule.
499
+		 *
500
+		 * @param string $inputName Name or key of the validation data
501
+		 * @param string $inputVal Value of the validation data
502
+		 * @param string $ruleName Rule to be validated against, including args (exact_length[5])
503
+		 * @return void
504
+		 */
505
+		protected function _validateRule($inputName, $inputVal, $ruleName) {
506
+			$this->logger->debug('Rule validation of field [' .$inputName. '], value [' .$inputVal. '], rule [' .$ruleName. ']');
507
+			// Array to store args
508
+			$ruleArgs = array();
509
+
510
+			// Get the rule arguments, realRule is just the base rule name
511
+			// Like min_length instead of min_length[3]
512
+			$realRule = preg_match('/\[(.*)\]/', $ruleName, $ruleArgs);
513
+			$ruleName = preg_replace('/\[(.*)\]/', '', $ruleName);
514 514
             
515
-            if (method_exists($this, $this->_toCallCase($ruleName))) {
516
-                $methodToCall = $this->_toCallCase($ruleName);
517
-                @call_user_func(array($this, $methodToCall), $inputName, $ruleName, $ruleArgs);
518
-            }
519
-
520
-            return;
521
-        }
522
-
523
-		/**
524
-		* Set error for the given field or key
525
-		*
526
-		* @param string $inputName the input or key name
527
-		* @param string $ruleName the rule name
528
-		* @param array $replacements
529
-		*/
530
-        protected function _setError($inputName, $ruleName, $replacements = array()) {
531
-            $rulePhraseKeyParts = explode(',', $ruleName);
532
-            foreach ($rulePhraseKeyParts as $rulePhraseKeyPart) {
533
-                if (array_key_exists($rulePhraseKeyPart, $this->_errorsMessages)) {
534
-                    $rulePhrase = $this->_errorsMessages[$rulePhraseKeyPart];
535
-                } else {
536
-                    $rulePhrase = $rulePhrase[$rulePhraseKeyPart];
537
-                }
538
-            }
539
-            // Any overrides?
540
-            if (array_key_exists($inputName, $this->_errorPhraseOverrides) && array_key_exists($ruleName, $this->_errorPhraseOverrides[$inputName])) {
541
-                $rulePhrase = $this->_errorPhraseOverrides[$inputName][$ruleName];
542
-            }
543
-            // Type cast to array in case it's a string
544
-            $replacements = (array) $replacements;
515
+			if (method_exists($this, $this->_toCallCase($ruleName))) {
516
+				$methodToCall = $this->_toCallCase($ruleName);
517
+				@call_user_func(array($this, $methodToCall), $inputName, $ruleName, $ruleArgs);
518
+			}
519
+
520
+			return;
521
+		}
522
+
523
+		/**
524
+		 * Set error for the given field or key
525
+		 *
526
+		 * @param string $inputName the input or key name
527
+		 * @param string $ruleName the rule name
528
+		 * @param array $replacements
529
+		 */
530
+		protected function _setError($inputName, $ruleName, $replacements = array()) {
531
+			$rulePhraseKeyParts = explode(',', $ruleName);
532
+			foreach ($rulePhraseKeyParts as $rulePhraseKeyPart) {
533
+				if (array_key_exists($rulePhraseKeyPart, $this->_errorsMessages)) {
534
+					$rulePhrase = $this->_errorsMessages[$rulePhraseKeyPart];
535
+				} else {
536
+					$rulePhrase = $rulePhrase[$rulePhraseKeyPart];
537
+				}
538
+			}
539
+			// Any overrides?
540
+			if (array_key_exists($inputName, $this->_errorPhraseOverrides) && array_key_exists($ruleName, $this->_errorPhraseOverrides[$inputName])) {
541
+				$rulePhrase = $this->_errorPhraseOverrides[$inputName][$ruleName];
542
+			}
543
+			// Type cast to array in case it's a string
544
+			$replacements = (array) $replacements;
545 545
 			$replacementCount = count($replacements);
546
-            for ($i = 1; $i <= $replacementCount; $i++) {
547
-                $key = $i - 1;
548
-                $rulePhrase = str_replace('%' . $i, $replacements[$key], $rulePhrase);
549
-            }
550
-            if (! array_key_exists($inputName, $this->_errors)) {
551
-                $this->_errors[$inputName] = $rulePhrase;
552
-            }
553
-        }
554
-
555
-        /**
556
-         * Used to run a callback for the callback rule, as well as pass in a default
557
-         * argument of the post value. For example the username field having a rule:
558
-         * callback[userExists] will eval userExists(data[username]) - Note the use
559
-         * of eval over call_user_func is in case the function is not user defined.
560
-         *
561
-         * @param type $inputArg
562
-         * @param string $callbackFunc
563
-		 *
564
-         * @return anything
565
-         */
566
-        protected function _runCallback($inputArg, $callbackFunc) {
546
+			for ($i = 1; $i <= $replacementCount; $i++) {
547
+				$key = $i - 1;
548
+				$rulePhrase = str_replace('%' . $i, $replacements[$key], $rulePhrase);
549
+			}
550
+			if (! array_key_exists($inputName, $this->_errors)) {
551
+				$this->_errors[$inputName] = $rulePhrase;
552
+			}
553
+		}
554
+
555
+		/**
556
+		 * Used to run a callback for the callback rule, as well as pass in a default
557
+		 * argument of the post value. For example the username field having a rule:
558
+		 * callback[userExists] will eval userExists(data[username]) - Note the use
559
+		 * of eval over call_user_func is in case the function is not user defined.
560
+		 *
561
+		 * @param type $inputArg
562
+		 * @param string $callbackFunc
563
+		 *
564
+		 * @return anything
565
+		 */
566
+		protected function _runCallback($inputArg, $callbackFunc) {
567 567
 			return eval('return ' . $callbackFunc . '("' . $inputArg . '");');
568
-        }
569
-
570
-        /**
571
-         * Used for applying a rule only if the empty callback evaluates to true,
572
-         * for example required[funcName] - This runs funcName without passing any
573
-         * arguments.
574
-         *
575
-         * @param string $callbackFunc
576
-		 *
577
-         * @return anything
578
-         */
579
-        protected function _runEmptyCallback($callbackFunc) {
580
-            return eval('return ' . $callbackFunc . '();');
581
-        }
582
-
583
-        /**
584
-         * Gets a specific label of a specific field input name.
585
-         *
586
-         * @param string $inputName
587
-		 *
588
-         * @return string
589
-         */
590
-        protected function _getLabel($inputName) {
591
-            return (array_key_exists($inputName, $this->_labels)) ? $this->_labels[$inputName] : $inputName;
592
-        }
568
+		}
569
+
570
+		/**
571
+		 * Used for applying a rule only if the empty callback evaluates to true,
572
+		 * for example required[funcName] - This runs funcName without passing any
573
+		 * arguments.
574
+		 *
575
+		 * @param string $callbackFunc
576
+		 *
577
+		 * @return anything
578
+		 */
579
+		protected function _runEmptyCallback($callbackFunc) {
580
+			return eval('return ' . $callbackFunc . '();');
581
+		}
582
+
583
+		/**
584
+		 * Gets a specific label of a specific field input name.
585
+		 *
586
+		 * @param string $inputName
587
+		 *
588
+		 * @return string
589
+		 */
590
+		protected function _getLabel($inputName) {
591
+			return (array_key_exists($inputName, $this->_labels)) ? $this->_labels[$inputName] : $inputName;
592
+		}
593 593
 		
594
-        /**
595
-         * Peform validation for the rule "required"
596
-         * @param  string $inputName the form field or data key name used
597
-         * @param  string $ruleName  the rule name for this validation ("required")
598
-         * @param  array  $ruleArgs  the rules argument
599
-         */
594
+		/**
595
+		 * Peform validation for the rule "required"
596
+		 * @param  string $inputName the form field or data key name used
597
+		 * @param  string $ruleName  the rule name for this validation ("required")
598
+		 * @param  array  $ruleArgs  the rules argument
599
+		 */
600 600
 		protected function _validateRequired($inputName, $ruleName, array $ruleArgs) {
601
-            $inputVal = $this->post($inputName);
602
-            if(array_key_exists(1, $ruleArgs) && function_exists($ruleArgs[1])) {
603
-                $callbackReturn = $this->_runEmptyCallback($ruleArgs[1]);
604
-                if ($inputVal == '' && $callbackReturn == true) {
605
-                    $this->_setError($inputName, $ruleName, $this->_getLabel($inputName));
606
-                }
607
-            } 
601
+			$inputVal = $this->post($inputName);
602
+			if(array_key_exists(1, $ruleArgs) && function_exists($ruleArgs[1])) {
603
+				$callbackReturn = $this->_runEmptyCallback($ruleArgs[1]);
604
+				if ($inputVal == '' && $callbackReturn == true) {
605
+					$this->_setError($inputName, $ruleName, $this->_getLabel($inputName));
606
+				}
607
+			} 
608 608
 			else if($inputVal == '') {
609 609
 				$this->_setError($inputName, $ruleName, $this->_getLabel($inputName));
610
-            }
611
-        }
612
-
613
-        /**
614
-         * Perform validation for the honey pot so means for the validation to be failed
615
-         * @param  string $inputName the form field or data key name used
616
-         * @param  string $ruleName  the rule name for this validation
617
-         * @param  array  $ruleArgs  the rules argument
618
-         */
619
-        protected function _validateHoneypot($inputName, $ruleName, array $ruleArgs) {
620
-            if ($this->data[$inputName] != '') {
621
-                $this->_forceFail = true;
622
-            }
623
-        }
624
-
625
-        /**
626
-         * Peform validation for the rule "callback"
627
-         * @param  string $inputName the form field or data key name used
628
-         * @param  string $ruleName  the rule name for this validation ("callback")
629
-         * @param  array  $ruleArgs  the rules argument
630
-         */
631
-        protected function _validateCallback($inputName, $ruleName, array $ruleArgs) {
632
-            if (function_exists($ruleArgs[1]) && !empty($this->data[$inputName])) {
610
+			}
611
+		}
612
+
613
+		/**
614
+		 * Perform validation for the honey pot so means for the validation to be failed
615
+		 * @param  string $inputName the form field or data key name used
616
+		 * @param  string $ruleName  the rule name for this validation
617
+		 * @param  array  $ruleArgs  the rules argument
618
+		 */
619
+		protected function _validateHoneypot($inputName, $ruleName, array $ruleArgs) {
620
+			if ($this->data[$inputName] != '') {
621
+				$this->_forceFail = true;
622
+			}
623
+		}
624
+
625
+		/**
626
+		 * Peform validation for the rule "callback"
627
+		 * @param  string $inputName the form field or data key name used
628
+		 * @param  string $ruleName  the rule name for this validation ("callback")
629
+		 * @param  array  $ruleArgs  the rules argument
630
+		 */
631
+		protected function _validateCallback($inputName, $ruleName, array $ruleArgs) {
632
+			if (function_exists($ruleArgs[1]) && !empty($this->data[$inputName])) {
633 633
 				$result = $this->_runCallback($this->data[$inputName], $ruleArgs[1]);
634 634
 				if(! $result){
635 635
 					$this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
636 636
 				}
637
-            }
638
-        }
639
-
640
-        /**
641
-         * Peform validation for the rule "depends"
642
-         * @param  string $inputName the form field or data key name used
643
-         * @param  string $ruleName  the rule name for this validation ("depends")
644
-         * @param  array  $ruleArgs  the rules argument
645
-         */
646
-        protected function _validateDepends($inputName, $ruleName, array $ruleArgs) {
647
-            if (array_key_exists($ruleArgs[1], $this->_errors)) {
648
-                $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
649
-            }
650
-        }
651
-
652
-        /**
653
-         * Peform validation for the rule "not_equal"
654
-         * @param  string $inputName the form field or data key name used
655
-         * @param  string $ruleName  the rule name for this validation ("not_equal")
656
-         * @param  array  $ruleArgs  the rules argument
657
-         */
658
-        protected function _validateNotEqual($inputName, $ruleName, array $ruleArgs) {
659
-            $canNotEqual = explode(',', $ruleArgs[1]);
660
-            foreach ($canNotEqual as $doNotEqual) {
661
-                $inputVal = $this->post($inputName);
662
-                if (preg_match('/post:(.*)/', $doNotEqual)) {
663
-                    if ($inputVal == $this->data[str_replace('post:', '', $doNotEqual)]) {
664
-                        $this->_setError($inputName, $ruleName . ',post:key', array($this->_getLabel($inputName), $this->_getLabel(str_replace('post:', '', $doNotEqual))));
665
-                        continue;
666
-                    }
667
-                } 
637
+			}
638
+		}
639
+
640
+		/**
641
+		 * Peform validation for the rule "depends"
642
+		 * @param  string $inputName the form field or data key name used
643
+		 * @param  string $ruleName  the rule name for this validation ("depends")
644
+		 * @param  array  $ruleArgs  the rules argument
645
+		 */
646
+		protected function _validateDepends($inputName, $ruleName, array $ruleArgs) {
647
+			if (array_key_exists($ruleArgs[1], $this->_errors)) {
648
+				$this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
649
+			}
650
+		}
651
+
652
+		/**
653
+		 * Peform validation for the rule "not_equal"
654
+		 * @param  string $inputName the form field or data key name used
655
+		 * @param  string $ruleName  the rule name for this validation ("not_equal")
656
+		 * @param  array  $ruleArgs  the rules argument
657
+		 */
658
+		protected function _validateNotEqual($inputName, $ruleName, array $ruleArgs) {
659
+			$canNotEqual = explode(',', $ruleArgs[1]);
660
+			foreach ($canNotEqual as $doNotEqual) {
661
+				$inputVal = $this->post($inputName);
662
+				if (preg_match('/post:(.*)/', $doNotEqual)) {
663
+					if ($inputVal == $this->data[str_replace('post:', '', $doNotEqual)]) {
664
+						$this->_setError($inputName, $ruleName . ',post:key', array($this->_getLabel($inputName), $this->_getLabel(str_replace('post:', '', $doNotEqual))));
665
+						continue;
666
+					}
667
+				} 
668 668
 				else{
669
-                    if ($inputVal == $doNotEqual) {
670
-                        $this->_setError($inputName, $ruleName . ',string', array($this->_getLabel($inputName), $doNotEqual));
671
-                        continue;
672
-                    }
673
-                }
674
-            }
675
-        }
676
-
677
-        /**
678
-         * Peform validation for the rule "matches"
679
-         * @param  string $inputName the form field or data key name used
680
-         * @param  string $ruleName  the rule name for this validation ("matches")
681
-         * @param  array  $ruleArgs  the rules argument
682
-         */
683
-        protected function _validateMatches($inputName, $ruleName, array $ruleArgs) {
684
-            $inputVal = $this->post($inputName);
685
-            if ($inputVal != $this->data[$ruleArgs[1]]) {
686
-                $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
687
-            }
688
-        }
689
-
690
-        /**
691
-         * Peform validation for the rule "valid_email"
692
-         * @param  string $inputName the form field or data key name used
693
-         * @param  string $ruleName  the rule name for this validation ("valid_email")
694
-         * @param  array  $ruleArgs  the rules argument
695
-         */
696
-        protected function _validateValidEmail($inputName, $ruleName, array $ruleArgs) {
697
-            $inputVal = $this->post($inputName);
698
-            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)) {
699
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
700
-                    return;
701
-                }
702
-                $this->_setError($inputName, $ruleName, $this->_getLabel($inputName));
703
-            }
704
-        }
705
-
706
-        /**
707
-         * Peform validation for the rule "exact_length"
708
-         * @param  string $inputName the form field or data key name used
709
-         * @param  string $ruleName  the rule name for this validation ("exact_length")
710
-         * @param  array  $ruleArgs  the rules argument
711
-         */
712
-        protected function _validateExactLength($inputName, $ruleName, array $ruleArgs) {
713
-            $inputVal = $this->post($inputName);
714
-            if (strlen($inputVal) != $ruleArgs[1]) { // $ruleArgs[0] is [length] $rulesArgs[1] is just length
715
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
716
-                    return;
717
-                }
718
-                $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
719
-            }
720
-        }
721
-
722
-        /**
723
-         * Peform validation for the rule "max_length"
724
-         * @param  string $inputName the form field or data key name used
725
-         * @param  string $ruleName  the rule name for this validation ("max_length")
726
-         * @param  array  $ruleArgs  the rules argument
727
-         */
728
-        protected function _validateMaxLength($inputName, $ruleName, array $ruleArgs) {
729
-            $inputVal = $this->post($inputName);
730
-            if (strlen($inputVal) > $ruleArgs[1]) { // $ruleArgs[0] is [length] $rulesArgs[1] is just length
731
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
732
-                    return;
733
-                }
734
-                $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
735
-            }
736
-        }
737
-
738
-        /**
739
-         * Peform validation for the rule "min_length"
740
-         * @param  string $inputName the form field or data key name used
741
-         * @param  string $ruleName  the rule name for this validation ("min_length")
742
-         * @param  array  $ruleArgs  the rules argument
743
-         */
744
-        protected function _validateMinLength($inputName, $ruleName, array $ruleArgs) {
745
-            $inputVal = $this->post($inputName);
746
-            if (strlen($inputVal) < $ruleArgs[1]) { // $ruleArgs[0] is [length] $rulesArgs[1] is just length
747
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
748
-                    return;
749
-                }
750
-                $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
751
-            }
752
-        }
669
+					if ($inputVal == $doNotEqual) {
670
+						$this->_setError($inputName, $ruleName . ',string', array($this->_getLabel($inputName), $doNotEqual));
671
+						continue;
672
+					}
673
+				}
674
+			}
675
+		}
676
+
677
+		/**
678
+		 * Peform validation for the rule "matches"
679
+		 * @param  string $inputName the form field or data key name used
680
+		 * @param  string $ruleName  the rule name for this validation ("matches")
681
+		 * @param  array  $ruleArgs  the rules argument
682
+		 */
683
+		protected function _validateMatches($inputName, $ruleName, array $ruleArgs) {
684
+			$inputVal = $this->post($inputName);
685
+			if ($inputVal != $this->data[$ruleArgs[1]]) {
686
+				$this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
687
+			}
688
+		}
689
+
690
+		/**
691
+		 * Peform validation for the rule "valid_email"
692
+		 * @param  string $inputName the form field or data key name used
693
+		 * @param  string $ruleName  the rule name for this validation ("valid_email")
694
+		 * @param  array  $ruleArgs  the rules argument
695
+		 */
696
+		protected function _validateValidEmail($inputName, $ruleName, array $ruleArgs) {
697
+			$inputVal = $this->post($inputName);
698
+			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)) {
699
+				if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
700
+					return;
701
+				}
702
+				$this->_setError($inputName, $ruleName, $this->_getLabel($inputName));
703
+			}
704
+		}
705
+
706
+		/**
707
+		 * Peform validation for the rule "exact_length"
708
+		 * @param  string $inputName the form field or data key name used
709
+		 * @param  string $ruleName  the rule name for this validation ("exact_length")
710
+		 * @param  array  $ruleArgs  the rules argument
711
+		 */
712
+		protected function _validateExactLength($inputName, $ruleName, array $ruleArgs) {
713
+			$inputVal = $this->post($inputName);
714
+			if (strlen($inputVal) != $ruleArgs[1]) { // $ruleArgs[0] is [length] $rulesArgs[1] is just length
715
+				if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
716
+					return;
717
+				}
718
+				$this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
719
+			}
720
+		}
721
+
722
+		/**
723
+		 * Peform validation for the rule "max_length"
724
+		 * @param  string $inputName the form field or data key name used
725
+		 * @param  string $ruleName  the rule name for this validation ("max_length")
726
+		 * @param  array  $ruleArgs  the rules argument
727
+		 */
728
+		protected function _validateMaxLength($inputName, $ruleName, array $ruleArgs) {
729
+			$inputVal = $this->post($inputName);
730
+			if (strlen($inputVal) > $ruleArgs[1]) { // $ruleArgs[0] is [length] $rulesArgs[1] is just length
731
+				if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
732
+					return;
733
+				}
734
+				$this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
735
+			}
736
+		}
737
+
738
+		/**
739
+		 * Peform validation for the rule "min_length"
740
+		 * @param  string $inputName the form field or data key name used
741
+		 * @param  string $ruleName  the rule name for this validation ("min_length")
742
+		 * @param  array  $ruleArgs  the rules argument
743
+		 */
744
+		protected function _validateMinLength($inputName, $ruleName, array $ruleArgs) {
745
+			$inputVal = $this->post($inputName);
746
+			if (strlen($inputVal) < $ruleArgs[1]) { // $ruleArgs[0] is [length] $rulesArgs[1] is just length
747
+				if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
748
+					return;
749
+				}
750
+				$this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
751
+			}
752
+		}
753 753
     	
754
-        /**
755
-         * Peform validation for the rule "less_than"
756
-         * @param  string $inputName the form field or data key name used
757
-         * @param  string $ruleName  the rule name for this validation ("less_than")
758
-         * @param  array  $ruleArgs  the rules argument
759
-         */
760
-    	protected function _validateLessThan($inputName, $ruleName, array $ruleArgs) {
761
-            $inputVal = $this->post($inputName);
762
-            if ($inputVal >= $ruleArgs[1]) { 
763
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
764
-                    return;
765
-                }
766
-                $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
767
-            }
768
-        }
754
+		/**
755
+		 * Peform validation for the rule "less_than"
756
+		 * @param  string $inputName the form field or data key name used
757
+		 * @param  string $ruleName  the rule name for this validation ("less_than")
758
+		 * @param  array  $ruleArgs  the rules argument
759
+		 */
760
+		protected function _validateLessThan($inputName, $ruleName, array $ruleArgs) {
761
+			$inputVal = $this->post($inputName);
762
+			if ($inputVal >= $ruleArgs[1]) { 
763
+				if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
764
+					return;
765
+				}
766
+				$this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
767
+			}
768
+		}
769 769
     	
770
-        /**
771
-         * Peform validation for the rule "greater_than"
772
-         * @param  string $inputName the form field or data key name used
773
-         * @param  string $ruleName  the rule name for this validation ("greater_than")
774
-         * @param  array  $ruleArgs  the rules argument
775
-         */
776
-    	protected function _validateGreaterThan($inputName, $ruleName, array $ruleArgs) {
777
-            $inputVal = $this->post($inputName);
778
-            if ($inputVal <= $ruleArgs[1]) {
779
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
780
-                    return;
781
-                }
782
-                $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
783
-            }
784
-        }
770
+		/**
771
+		 * Peform validation for the rule "greater_than"
772
+		 * @param  string $inputName the form field or data key name used
773
+		 * @param  string $ruleName  the rule name for this validation ("greater_than")
774
+		 * @param  array  $ruleArgs  the rules argument
775
+		 */
776
+		protected function _validateGreaterThan($inputName, $ruleName, array $ruleArgs) {
777
+			$inputVal = $this->post($inputName);
778
+			if ($inputVal <= $ruleArgs[1]) {
779
+				if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
780
+					return;
781
+				}
782
+				$this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
783
+			}
784
+		}
785 785
     	
786
-        /**
787
-         * Peform validation for the rule "numeric"
788
-         * @param  string $inputName the form field or data key name used
789
-         * @param  string $ruleName  the rule name for this validation ("numeric")
790
-         * @param  array  $ruleArgs  the rules argument
791
-         */
792
-    	protected function _validateNumeric($inputName, $ruleName, array $ruleArgs) {
793
-            $inputVal = $this->post($inputName);
794
-            if (! is_numeric($inputVal)) {
795
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
796
-                    return;
797
-                }
798
-                $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
799
-            }
800
-        }
786
+		/**
787
+		 * Peform validation for the rule "numeric"
788
+		 * @param  string $inputName the form field or data key name used
789
+		 * @param  string $ruleName  the rule name for this validation ("numeric")
790
+		 * @param  array  $ruleArgs  the rules argument
791
+		 */
792
+		protected function _validateNumeric($inputName, $ruleName, array $ruleArgs) {
793
+			$inputVal = $this->post($inputName);
794
+			if (! is_numeric($inputVal)) {
795
+				if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
796
+					return;
797
+				}
798
+				$this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
799
+			}
800
+		}
801 801
 		
802
-        /**
803
-         * Peform validation for the rule "exists"
804
-         * @param  string $inputName the form field or data key name used
805
-         * @param  string $ruleName  the rule name for this validation ("exists")
806
-         * @param  array  $ruleArgs  the rules argument
807
-         */
802
+		/**
803
+		 * Peform validation for the rule "exists"
804
+		 * @param  string $inputName the form field or data key name used
805
+		 * @param  string $ruleName  the rule name for this validation ("exists")
806
+		 * @param  array  $ruleArgs  the rules argument
807
+		 */
808 808
 		protected function _validateExists($inputName, $ruleName, array $ruleArgs) {
809
-            $inputVal = $this->post($inputName);
810
-    		$obj = & get_instance();
811
-    		if(! isset($obj->database)){
812
-    			return;
813
-    		}
814
-    		list($table, $column) = explode('.', $ruleArgs[1]);
815
-    		$obj->database->from($table)
816
-    			          ->where($column, $inputVal)
817
-    			          ->get();
818
-    		$nb = $obj->database->numRows();
819
-            if ($nb == 0) {
820
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
821
-                    return;
822
-                }
823
-                $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
824
-            }
825
-        }
826
-
827
-        /**
828
-         * Peform validation for the rule "is_unique"
829
-         * @param  string $inputName the form field or data key name used
830
-         * @param  string $ruleName  the rule name for this validation ("is_unique")
831
-         * @param  array  $ruleArgs  the rules argument
832
-         */
833
-    	protected function _validateIsUnique($inputName, $ruleName, array $ruleArgs) {
834
-            $inputVal = $this->post($inputName);
835
-    		$obj = & get_instance();
836
-    		if(! isset($obj->database)){
837
-    			return;
838
-    		}
839
-    		list($table, $column) = explode('.', $ruleArgs[1]);
840
-    		$obj->database->from($table)
841
-    			          ->where($column, $inputVal)
842
-    			          ->get();
843
-    		$nb = $obj->database->numRows();
844
-            if ($nb != 0) {
845
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
846
-                    return;
847
-                }
848
-                $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
849
-            }
850
-        }
809
+			$inputVal = $this->post($inputName);
810
+			$obj = & get_instance();
811
+			if(! isset($obj->database)){
812
+				return;
813
+			}
814
+			list($table, $column) = explode('.', $ruleArgs[1]);
815
+			$obj->database->from($table)
816
+						  ->where($column, $inputVal)
817
+						  ->get();
818
+			$nb = $obj->database->numRows();
819
+			if ($nb == 0) {
820
+				if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
821
+					return;
822
+				}
823
+				$this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
824
+			}
825
+		}
826
+
827
+		/**
828
+		 * Peform validation for the rule "is_unique"
829
+		 * @param  string $inputName the form field or data key name used
830
+		 * @param  string $ruleName  the rule name for this validation ("is_unique")
831
+		 * @param  array  $ruleArgs  the rules argument
832
+		 */
833
+		protected function _validateIsUnique($inputName, $ruleName, array $ruleArgs) {
834
+			$inputVal = $this->post($inputName);
835
+			$obj = & get_instance();
836
+			if(! isset($obj->database)){
837
+				return;
838
+			}
839
+			list($table, $column) = explode('.', $ruleArgs[1]);
840
+			$obj->database->from($table)
841
+						  ->where($column, $inputVal)
842
+						  ->get();
843
+			$nb = $obj->database->numRows();
844
+			if ($nb != 0) {
845
+				if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
846
+					return;
847
+				}
848
+				$this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
849
+			}
850
+		}
851 851
     	
852
-        /**
853
-         * Peform validation for the rule "is_unique_update"
854
-         * @param  string $inputName the form field or data key name used
855
-         * @param  string $ruleName  the rule name for this validation ("is_unique_update")
856
-         * @param  array  $ruleArgs  the rules argument
857
-         */
858
-    	protected function _validateIsUniqueUpdate($inputName, $ruleName, array $ruleArgs) {
859
-            $inputVal = $this->post($inputName);
860
-    		$obj = & get_instance();
861
-    		if(! isset($obj->database)){
862
-    			return;
863
-    		}
864
-    		$data = explode(',', $ruleArgs[1]);
865
-    		if(count($data) < 2){
866
-    			return;
867
-    		}
868
-    		list($table, $column) = explode('.', $data[0]);
869
-    		list($field, $val) = explode('=', $data[1]);
870
-    		$obj->database->from($table)
871
-    			          ->where($column, $inputVal)
872
-                		  ->where($field, '!=', trim($val))
873
-                		  ->get();
874
-    		$nb = $obj->database->numRows();
875
-            if ($nb != 0) {
876
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
877
-                    return;
878
-                }
879
-                $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
880
-            }
881
-        }
882
-
883
-        /**
884
-         * Peform validation for the rule "in_list"
885
-         * @param  string $inputName the form field or data key name used
886
-         * @param  string $ruleName  the rule name for this validation ("in_list")
887
-         * @param  array  $ruleArgs  the rules argument
888
-         */
889
-        protected function _validateInList($inputName, $ruleName, array $ruleArgs) {
890
-            $inputVal = $this->post($inputName);
891
-    		$list = explode(',', $ruleArgs[1]);
892
-            $list = array_map('trim', $list);
893
-            if (! in_array($inputVal, $list)) {
894
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
895
-                    return;
896
-                }
897
-                $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
898
-            }
899
-        }
900
-
901
-        /**
902
-         * Peform validation for the rule "regex"
903
-         * @param  string $inputName the form field or data key name used
904
-         * @param  string $ruleName  the rule name for this validation ("regex")
905
-         * @param  array  $ruleArgs  the rules argument
906
-         */
907
-        protected function _validateRegex($inputName, $ruleName, array $ruleArgs) {
908
-            $inputVal = $this->post($inputName);
909
-    		$regex = $ruleArgs[1];
910
-            if (! preg_match($regex, $inputVal)) {
911
-                if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
912
-                    return;
913
-                }
914
-                $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
915
-            }
916
-        }
852
+		/**
853
+		 * Peform validation for the rule "is_unique_update"
854
+		 * @param  string $inputName the form field or data key name used
855
+		 * @param  string $ruleName  the rule name for this validation ("is_unique_update")
856
+		 * @param  array  $ruleArgs  the rules argument
857
+		 */
858
+		protected function _validateIsUniqueUpdate($inputName, $ruleName, array $ruleArgs) {
859
+			$inputVal = $this->post($inputName);
860
+			$obj = & get_instance();
861
+			if(! isset($obj->database)){
862
+				return;
863
+			}
864
+			$data = explode(',', $ruleArgs[1]);
865
+			if(count($data) < 2){
866
+				return;
867
+			}
868
+			list($table, $column) = explode('.', $data[0]);
869
+			list($field, $val) = explode('=', $data[1]);
870
+			$obj->database->from($table)
871
+						  ->where($column, $inputVal)
872
+						  ->where($field, '!=', trim($val))
873
+						  ->get();
874
+			$nb = $obj->database->numRows();
875
+			if ($nb != 0) {
876
+				if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
877
+					return;
878
+				}
879
+				$this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
880
+			}
881
+		}
882
+
883
+		/**
884
+		 * Peform validation for the rule "in_list"
885
+		 * @param  string $inputName the form field or data key name used
886
+		 * @param  string $ruleName  the rule name for this validation ("in_list")
887
+		 * @param  array  $ruleArgs  the rules argument
888
+		 */
889
+		protected function _validateInList($inputName, $ruleName, array $ruleArgs) {
890
+			$inputVal = $this->post($inputName);
891
+			$list = explode(',', $ruleArgs[1]);
892
+			$list = array_map('trim', $list);
893
+			if (! in_array($inputVal, $list)) {
894
+				if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
895
+					return;
896
+				}
897
+				$this->_setError($inputName, $ruleName, array($this->_getLabel($inputName), $this->_getLabel($ruleArgs[1])));
898
+			}
899
+		}
900
+
901
+		/**
902
+		 * Peform validation for the rule "regex"
903
+		 * @param  string $inputName the form field or data key name used
904
+		 * @param  string $ruleName  the rule name for this validation ("regex")
905
+		 * @param  array  $ruleArgs  the rules argument
906
+		 */
907
+		protected function _validateRegex($inputName, $ruleName, array $ruleArgs) {
908
+			$inputVal = $this->post($inputName);
909
+			$regex = $ruleArgs[1];
910
+			if (! preg_match($regex, $inputVal)) {
911
+				if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
912
+					return;
913
+				}
914
+				$this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
915
+			}
916
+		}
917 917
         
918
-    }
918
+	}
Please login to merge, or discard this patch.
core/libraries/StringHash.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 	 * You should have received a copy of the GNU General Public License
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 26
 
27 27
 	class StringHash{
28 28
 		 
Please login to merge, or discard this patch.