Passed
Push — 1.0.0-dev ( b68981...00dab9 )
by nguereza
05:23
created
core/functions/function_lang.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -1,52 +1,52 @@
 block discarded – undo
1 1
 <?php
2
-	defined('ROOT_PATH') || exit('Access denied');
3
-	/**
4
-	 * TNH Framework
5
-	 *
6
-	 * A simple PHP framework using HMVC architecture
7
-	 *
8
-	 * This content is released under the GNU GPL License (GPL)
9
-	 *
10
-	 * Copyright (C) 2017 Tony NGUEREZA
11
-	 *
12
-	 * This program is free software; you can redistribute it and/or
13
-	 * modify it under the terms of the GNU General Public License
14
-	 * as published by the Free Software Foundation; either version 3
15
-	 * of the License, or (at your option) any later version.
16
-	 *
17
-	 * This program is distributed in the hope that it will be useful,
18
-	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
-	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
-	 * GNU General Public License for more details.
21
-	 *
22
-	 * You should have received a copy of the GNU General Public License
23
-	 * along with this program; if not, write to the Free Software
24
-	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
-	*/
2
+    defined('ROOT_PATH') || exit('Access denied');
3
+    /**
4
+     * TNH Framework
5
+     *
6
+     * A simple PHP framework using HMVC architecture
7
+     *
8
+     * This content is released under the GNU GPL License (GPL)
9
+     *
10
+     * Copyright (C) 2017 Tony NGUEREZA
11
+     *
12
+     * This program is free software; you can redistribute it and/or
13
+     * modify it under the terms of the GNU General Public License
14
+     * as published by the Free Software Foundation; either version 3
15
+     * of the License, or (at your option) any later version.
16
+     *
17
+     * This program is distributed in the hope that it will be useful,
18
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+     * GNU General Public License for more details.
21
+     *
22
+     * You should have received a copy of the GNU General Public License
23
+     * along with this program; if not, write to the Free Software
24
+     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
+     */
26 26
 
27
-	if(! function_exists('__')){
28
-		/**
29
-		 * function for the shortcut to Lang::get()
30
-		 * @param  string $key the language key to retrieve
31
-		 * @param mixed $default the default value to return if can not find the value
32
-		 * for the given key
33
-		 * @return string  the language value
34
-		 */
35
-		function __($key, $default = 'LANGUAGE_ERROR'){
36
-			return get_instance()->lang->get($key, $default);
37
-		}
27
+    if(! function_exists('__')){
28
+        /**
29
+         * function for the shortcut to Lang::get()
30
+         * @param  string $key the language key to retrieve
31
+         * @param mixed $default the default value to return if can not find the value
32
+         * for the given key
33
+         * @return string  the language value
34
+         */
35
+        function __($key, $default = 'LANGUAGE_ERROR'){
36
+            return get_instance()->lang->get($key, $default);
37
+        }
38 38
 
39
-	}
39
+    }
40 40
 
41 41
 
42
-	if(! function_exists('get_languages')){
43
-		/**
44
-		 * function for the shortcut to Lang::getSupported()
45
-		 * 
46
-		 * @return array all the supported languages
47
-		 */
48
-		function get_languages(){
49
-			return get_instance()->lang->getSupported();
50
-		}
42
+    if(! function_exists('get_languages')){
43
+        /**
44
+         * function for the shortcut to Lang::getSupported()
45
+         * 
46
+         * @return array all the supported languages
47
+         */
48
+        function get_languages(){
49
+            return get_instance()->lang->getSupported();
50
+        }
51 51
 
52
-	}
53 52
\ No newline at end of file
53
+    }
54 54
\ No newline at end of file
Please login to merge, or discard this patch.
core/functions/function_string.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -1,74 +1,74 @@
 block discarded – undo
1 1
 <?php
2
-	defined('ROOT_PATH') || exit('Access denied');
3
-	/**
4
-	 * TNH Framework
5
-	 *
6
-	 * A simple PHP framework using HMVC architecture
7
-	 *
8
-	 * This content is released under the GNU GPL License (GPL)
9
-	 *
10
-	 * Copyright (C) 2017 Tony NGUEREZA
11
-	 *
12
-	 * This program is free software; you can redistribute it and/or
13
-	 * modify it under the terms of the GNU General Public License
14
-	 * as published by the Free Software Foundation; either version 3
15
-	 * of the License, or (at your option) any later version.
16
-	 *
17
-	 * This program is distributed in the hope that it will be useful,
18
-	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
-	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
-	 * GNU General Public License for more details.
21
-	 *
22
-	 * You should have received a copy of the GNU General Public License
23
-	 * along with this program; if not, write to the Free Software
24
-	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
-	*/
2
+    defined('ROOT_PATH') || exit('Access denied');
3
+    /**
4
+     * TNH Framework
5
+     *
6
+     * A simple PHP framework using HMVC architecture
7
+     *
8
+     * This content is released under the GNU GPL License (GPL)
9
+     *
10
+     * Copyright (C) 2017 Tony NGUEREZA
11
+     *
12
+     * This program is free software; you can redistribute it and/or
13
+     * modify it under the terms of the GNU General Public License
14
+     * as published by the Free Software Foundation; either version 3
15
+     * of the License, or (at your option) any later version.
16
+     *
17
+     * This program is distributed in the hope that it will be useful,
18
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+     * GNU General Public License for more details.
21
+     *
22
+     * You should have received a copy of the GNU General Public License
23
+     * along with this program; if not, write to the Free Software
24
+     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
+     */
26 26
 
27
-	/**
28
-	 *  @file function_string.php
29
-	 *
30
-	 *  This file contains the definition of the functions relating to the processing of strings characters.
31
-	 *
32
-	 *  @package	core
33
-	 *  @author	Tony NGUEREZA
34
-	 *  @copyright	Copyright (c) 2017
35
-	 *  @license	https://opensource.org/licenses/gpl-3.0.html GNU GPL License (GPL)
36
-	 *  @link	http://www.iacademy.cf
37
-	 *  @version 1.0.0
38
-	 *  @since 1.0.0
39
-	 *  @filesource
40
-	 */
27
+    /**
28
+     *  @file function_string.php
29
+     *
30
+     *  This file contains the definition of the functions relating to the processing of strings characters.
31
+     *
32
+     *  @package	core
33
+     *  @author	Tony NGUEREZA
34
+     *  @copyright	Copyright (c) 2017
35
+     *  @license	https://opensource.org/licenses/gpl-3.0.html GNU GPL License (GPL)
36
+     *  @link	http://www.iacademy.cf
37
+     *  @version 1.0.0
38
+     *  @since 1.0.0
39
+     *  @filesource
40
+     */
41 41
 
42
-	if(! function_exists('get_random_string')){
43
-		/**
44
-		 * Generate a random string
45
-		 * @param  string $type the type of generation. It can take the values: "alpha" for alphabetic characters,
46
-		 * "alnum" for alpha-numeric characters and "num" for numbers.
47
-		 * By default it is "alnum".
48
-		 * @param  integer $length the length of the string to generate. By default it is 10.
49
-		 * @param  boolean $lower if we return the generated string in lowercase (true). By default it's false.
50
-		 * @return string the generated string.
51
-		 */
52
-		function get_random_string($type = 'alnum', $length = 10, $lower = false){
53
-			$str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
54
-			switch($type){
55
-				case 'alpha':
56
-					$str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
57
-				break;
58
-				case 'alnum':
59
-					$str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
60
-				break;
61
-				case 'num':
62
-					$str = '1234567890';
63
-				break;
64
-			}
65
-			$random = null;
66
-			for($i = 0; $i < $length; $i++){
67
-				$random .= $str[mt_rand() % strlen($str)];
68
-			}
69
-			if($lower){
70
-				$random = strtolower($random);
71
-			}
72
-			return $random;
73
-		}
74
-	}
42
+    if(! function_exists('get_random_string')){
43
+        /**
44
+         * Generate a random string
45
+         * @param  string $type the type of generation. It can take the values: "alpha" for alphabetic characters,
46
+         * "alnum" for alpha-numeric characters and "num" for numbers.
47
+         * By default it is "alnum".
48
+         * @param  integer $length the length of the string to generate. By default it is 10.
49
+         * @param  boolean $lower if we return the generated string in lowercase (true). By default it's false.
50
+         * @return string the generated string.
51
+         */
52
+        function get_random_string($type = 'alnum', $length = 10, $lower = false){
53
+            $str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
54
+            switch($type){
55
+                case 'alpha':
56
+                    $str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
57
+                break;
58
+                case 'alnum':
59
+                    $str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
60
+                break;
61
+                case 'num':
62
+                    $str = '1234567890';
63
+                break;
64
+            }
65
+            $random = null;
66
+            for($i = 0; $i < $length; $i++){
67
+                $random .= $str[mt_rand() % strlen($str)];
68
+            }
69
+            if($lower){
70
+                $random = strtolower($random);
71
+            }
72
+            return $random;
73
+        }
74
+    }
Please login to merge, or discard this patch.
core/libraries/Email.php 1 patch
Indentation   +730 added lines, -730 removed lines patch added patch discarded remove patch
@@ -1,739 +1,739 @@
 block discarded – undo
1 1
 <?php
2
-	defined('ROOT_PATH') || exit('Access denied');
3
-	/**
4
-	 * Simple Mail
5
-	 *
6
-	 * A simple PHP wrapper class for sending email using the mail() method.
7
-	 *
8
-	 * PHP version > 5.2
9
-	 *
10
-	 * LICENSE: This source file is subject to the MIT license, which is
11
-	 * available through the world-wide-web at the following URI:
12
-	 * http://github.com/eoghanobrien/php-simple-mail/LICENCE.txt
13
-	 *
14
-	 * @category  SimpleMail
15
-	 * @package   SimpleMail
16
-	 * @author    Eoghan O'Brien <[email protected]>
17
-	 * @copyright 2009 - 2017 Eoghan O'Brien
18
-	 * @license   http://github.com/eoghanobrien/php-simple-mail/LICENCE.txt MIT
19
-	 * @version   1.7.1
20
-	 * @link      http://github.com/eoghanobrien/php-simple-mail
21
-	 */
22
-
23
-	/**
24
-	 * Simple Mail class.
25
-	 *
26
-	 * @category  SimpleMail
27
-	 * @package   SimpleMail
28
-	 * @author    Eoghan O'Brien <[email protected]>
29
-	 * @copyright 2009 - 2017 Eoghan O'Brien
30
-	 * @license   http://github.com/eoghanobrien/php-simple-mail/LICENCE.txt MIT
31
-	 * @version   1.7.1
32
-	 * @link      http://github.com/eoghanobrien/php-simple-mail
33
-	 */
34
-	class Email
35
-	{
36
-		/**
37
-		 * @var int $_wrap
38
-		 */
39
-		protected $_wrap = 78;
40
-
41
-		/**
42
-		 * @var array $_to
43
-		 */
44
-		protected $_to = array();
45
-
46
-		/**
47
-		 * @var string $_subject
48
-		 */
49
-		protected $_subject;
50
-
51
-		/**
52
-		 * @var string $_message
53
-		 */
54
-		protected $_message;
55
-
56
-		/**
57
-		 * @var array $_headers
58
-		 */
59
-		protected $_headers = array();
60
-
61
-		/**
62
-		 * @var string $_parameters
63
-		 */
64
-		protected $_params;
65
-
66
-		/**
67
-		 * @var array $_attachments
68
-		 */
69
-		protected $_attachments = array();
70
-
71
-		/**
72
-		 * @var string $_uid
73
-		 */
74
-		protected $_uid;
2
+    defined('ROOT_PATH') || exit('Access denied');
3
+    /**
4
+     * Simple Mail
5
+     *
6
+     * A simple PHP wrapper class for sending email using the mail() method.
7
+     *
8
+     * PHP version > 5.2
9
+     *
10
+     * LICENSE: This source file is subject to the MIT license, which is
11
+     * available through the world-wide-web at the following URI:
12
+     * http://github.com/eoghanobrien/php-simple-mail/LICENCE.txt
13
+     *
14
+     * @category  SimpleMail
15
+     * @package   SimpleMail
16
+     * @author    Eoghan O'Brien <[email protected]>
17
+     * @copyright 2009 - 2017 Eoghan O'Brien
18
+     * @license   http://github.com/eoghanobrien/php-simple-mail/LICENCE.txt MIT
19
+     * @version   1.7.1
20
+     * @link      http://github.com/eoghanobrien/php-simple-mail
21
+     */
22
+
23
+    /**
24
+     * Simple Mail class.
25
+     *
26
+     * @category  SimpleMail
27
+     * @package   SimpleMail
28
+     * @author    Eoghan O'Brien <[email protected]>
29
+     * @copyright 2009 - 2017 Eoghan O'Brien
30
+     * @license   http://github.com/eoghanobrien/php-simple-mail/LICENCE.txt MIT
31
+     * @version   1.7.1
32
+     * @link      http://github.com/eoghanobrien/php-simple-mail
33
+     */
34
+    class Email
35
+    {
36
+        /**
37
+         * @var int $_wrap
38
+         */
39
+        protected $_wrap = 78;
40
+
41
+        /**
42
+         * @var array $_to
43
+         */
44
+        protected $_to = array();
45
+
46
+        /**
47
+         * @var string $_subject
48
+         */
49
+        protected $_subject;
50
+
51
+        /**
52
+         * @var string $_message
53
+         */
54
+        protected $_message;
55
+
56
+        /**
57
+         * @var array $_headers
58
+         */
59
+        protected $_headers = array();
60
+
61
+        /**
62
+         * @var string $_parameters
63
+         */
64
+        protected $_params;
65
+
66
+        /**
67
+         * @var array $_attachments
68
+         */
69
+        protected $_attachments = array();
70
+
71
+        /**
72
+         * @var string $_uid
73
+         */
74
+        protected $_uid;
75 75
 		
76
-		/**
76
+        /**
77 77
          * The logger instance
78 78
          * @var Log
79 79
          */
80
-		private $logger;
80
+        private $logger;
81 81
 
82
-		/**
83
-		 * __construct
84
-		 *
85
-		 * Resets the class properties.
86
-		 */
87
-		public function __construct()
88
-		{
89
-			$this->logger =& class_loader('Log', 'classes');
82
+        /**
83
+         * __construct
84
+         *
85
+         * Resets the class properties.
86
+         */
87
+        public function __construct()
88
+        {
89
+            $this->logger =& class_loader('Log', 'classes');
90 90
             $this->logger->setLogger('Library::Email');
91
-			$this->reset();
92
-		}
93
-
94
-		/**
95
-		 * reset
96
-		 *
97
-		 * Resets all properties to initial state.
98
-		 *
99
-		 * @return self
100
-		 */
101
-		public function reset()
102
-		{
103
-			$this->_to = array();
104
-			$this->_headers = array();
105
-			$this->_subject = null;
106
-			$this->_message = null;
107
-			$this->_wrap = 78;
108
-			$this->_params = null;
109
-			$this->_attachments = array();
110
-			$this->_uid = $this->getUniqueId();
111
-			return $this;
112
-		}
91
+            $this->reset();
92
+        }
93
+
94
+        /**
95
+         * reset
96
+         *
97
+         * Resets all properties to initial state.
98
+         *
99
+         * @return self
100
+         */
101
+        public function reset()
102
+        {
103
+            $this->_to = array();
104
+            $this->_headers = array();
105
+            $this->_subject = null;
106
+            $this->_message = null;
107
+            $this->_wrap = 78;
108
+            $this->_params = null;
109
+            $this->_attachments = array();
110
+            $this->_uid = $this->getUniqueId();
111
+            return $this;
112
+        }
113 113
 		
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
-		 */
122
-		public function setFrom($email, $name = null)
123
-		{
124
-			$this->addMailHeader('From', (string) $email, (string) $name);
125
-			return $this;
126
-		}
127
-
128
-		/**
129
-		 * setTo
130
-		 *
131
-		 * @param string $email The email address to send to.
132
-		 * @param string $name  The name of the person to send to.
133
-		 *
134
-		 * @return self
135
-		 */
136
-		public function setTo($email, $name = null)
137
-		{
138
-			$this->_to[] = $this->formatHeader((string) $email, (string) $name);
139
-			return $this;
140
-		}
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
+             */
122
+        public function setFrom($email, $name = null)
123
+        {
124
+            $this->addMailHeader('From', (string) $email, (string) $name);
125
+            return $this;
126
+        }
127
+
128
+        /**
129
+         * setTo
130
+         *
131
+         * @param string $email The email address to send to.
132
+         * @param string $name  The name of the person to send to.
133
+         *
134
+         * @return self
135
+         */
136
+        public function setTo($email, $name = null)
137
+        {
138
+            $this->_to[] = $this->formatHeader((string) $email, (string) $name);
139
+            return $this;
140
+        }
141 141
 		
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
-		*/
148
-		public function setTos(array $emails)
149
-		{
150
-			foreach ($emails as $name => $email) {
151
-				if(is_numeric($name)){
152
-					$this->setTo($email);
153
-				}
154
-				else{
155
-					$this->setTo($email, $name);
156
-				}
157
-			}
158
-			return $this;
159
-		}
160
-
161
-
162
-		/**
163
-		 * getTo
164
-		 *
165
-		 * Return an array of formatted To addresses.
166
-		 *
167
-		 * @return array
168
-		 */
169
-		public function getTo()
170
-		{
171
-			return $this->_to;
172
-		}
173
-
174
-
175
-		/**
176
-		 * setCc
177
-		 *
178
-		 * @param array  $pairs  An array of name => email pairs.
179
-		 *
180
-		 * @return self
181
-		 */
182
-		public function setCc(array $pairs)
183
-		{
184
-			return $this->addMailHeaders('Cc', $pairs);
185
-		}
186
-
187
-		/**
188
-		 * setBcc
189
-		 *
190
-		 * @param array  $pairs  An array of name => email pairs.
191
-		 *
192
-		 * @return self
193
-		 */
194
-		public function setBcc(array $pairs)
195
-		{
196
-			return $this->addMailHeaders('Bcc', $pairs);
197
-		}
198
-
199
-		/**
200
-		 * setReplyTo
201
-		 *
202
-		 * @param string $email
203
-		 * @param string $name
204
-		 *
205
-		 * @return self
206
-		 */
207
-		public function setReplyTo($email, $name = null)
208
-		{
209
-			return $this->addMailHeader('Reply-To', $email, $name);
210
-		}
211
-
212
-		/**
213
-		 * setHtml
214
-		 *
215
-		 * @return self
216
-		 */
217
-		public function setHtml()
218
-		{
219
-			$this->addGenericHeader(
220
-				'Content-Type', 'text/html; charset="utf-8"'
221
-			);
222
-			return $this;
223
-		}
224
-
225
-		/**
226
-		 * setSubject
227
-		 *
228
-		 * @param string $subject The email subject
229
-		 *
230
-		 * @return self
231
-		 */
232
-		public function setSubject($subject)
233
-		{
234
-			$this->_subject = $this->encodeUtf8(
235
-				$this->filterOther((string) $subject)
236
-			);
237
-			return $this;
238
-		}
239
-
240
-		/**
241
-		 * getSubject function.
242
-		 *
243
-		 * @return string
244
-		 */
245
-		public function getSubject()
246
-		{
247
-			return $this->_subject;
248
-		}
249
-
250
-		/**
251
-		 * setMessage
252
-		 *
253
-		 * @param string $message The message to send.
254
-		 *
255
-		 * @return self
256
-		 */
257
-		public function setMessage($message)
258
-		{
259
-			$this->_message = str_replace("\n.", "\n..", (string) $message);
260
-			return $this;
261
-		}
262
-
263
-		/**
264
-		 * getMessage
265
-		 *
266
-		 * @return string
267
-		 */
268
-		public function getMessage()
269
-		{
270
-			return $this->_message;
271
-		}
272
-
273
-		/**
274
-		 * addAttachment
275
-		 *
276
-		 * @param string $path The file path to the attachment.
277
-		 * @param string $filename The filename of the attachment when emailed.
278
-		 * @param string $data
279
-		 * 
280
-		 * @return self
281
-		 */
282
-		public function addAttachment($path, $filename = null, $data = null)
283
-		{
284
-			if(! file_exists($path)){
285
-				show_error('The file [' .$path. '] does not exists.');
286
-			}
287
-			$filename = empty($filename) ? basename($path) : $filename;
288
-			$filename = $this->encodeUtf8($this->filterOther((string) $filename));
289
-			$data = empty($data) ? $this->getAttachmentData($path) : $data;
290
-			$this->_attachments[] = array(
291
-				'path' => $path,
292
-				'file' => $filename,
293
-				'data' => chunk_split(base64_encode($data))
294
-			);
295
-			return $this;
296
-		}
297
-
298
-		/**
299
-		 * getAttachmentData
300
-		 *
301
-		 * @param string $path The path to the attachment file.
302
-		 *
303
-		 * @return string
304
-		 */
305
-		public function getAttachmentData($path)
306
-		{
307
-			if(! file_exists($path)){
308
-				show_error('The file [' .$path. '] does not exists.');
309
-			}
310
-			$filesize = filesize($path);
311
-			$handle = fopen($path, "r");
312
-			$attachment = null;
313
-			if(is_resource($handle)){
314
-				$attachment = fread($handle, $filesize);
315
-				fclose($handle);
316
-			}
317
-			return $attachment;
318
-		}
319
-
320
-		/**
321
-		 * addMailHeader
322
-		 *
323
-		 * @param string $header The header to add.
324
-		 * @param string $email  The email to add.
325
-		 * @param string $name   The name to add.
326
-		 *
327
-		 * @return self
328
-		 */
329
-		public function addMailHeader($header, $email, $name = null)
330
-		{
331
-			$address = $this->formatHeader((string) $email, (string) $name);
332
-			$this->_headers[] = sprintf('%s: %s', (string) $header, $address);
333
-			return $this;
334
-		}
335
-
336
-		/**
337
-		 * addMailHeaders
338
-		 *
339
-		 * @param string $header The header to add.
340
-		 * @param array  $pairs  An array of name => email pairs.
341
-		 *
342
-		 * @return self
343
-		 */
344
-		public function addMailHeaders($header, array $pairs)
345
-		{
346
-			if (count($pairs) === 0) {
347
-				show_error('You must pass at least one name => email pair.');
348
-			}
349
-			$addresses = array();
350
-			foreach ($pairs as $name => $email) {
351
-				$name = is_numeric($name) ? null : $name;
352
-				$addresses[] = $this->formatHeader($email, $name);
353
-			}
354
-			$this->addGenericHeader($header, implode(',', $addresses));
355
-			return $this;
356
-		}
357
-
358
-		/**
359
-		 * addGenericHeader
360
-		 *
361
-		 * @param string $name The generic header to add.
362
-		 * @param mixed  $value  The value of the header.
363
-		 *
364
-		 * @return self
365
-		 */
366
-		public function addGenericHeader($name, $value)
367
-		{
368
-			$this->_headers[] = sprintf(
369
-				'%s: %s',
370
-				(string) $name,
371
-				(string) $value
372
-			);
373
-			return $this;
374
-		}
375
-
376
-		/**
377
-		 * getHeaders
378
-		 *
379
-		 * Return the headers registered so far as an array.
380
-		 *
381
-		 * @return array
382
-		 */
383
-		public function getHeaders()
384
-		{
385
-			return $this->_headers;
386
-		}
387
-
388
-		/**
389
-		 * setAdditionalParameters
390
-		 *
391
-		 * Such as "[email protected]
392
-		 *
393
-		 * @param string $additionalParameters The addition mail parameter.
394
-		 *
395
-		 * @return self
396
-		 */
397
-		public function setParameters($additionalParameters)
398
-		{
399
-			$this->_params = (string) $additionalParameters;
400
-			return $this;
401
-		}
402
-
403
-		/**
404
-		 * getAdditionalParameters
405
-		 *
406
-		 * @return string
407
-		 */
408
-		public function getParameters()
409
-		{
410
-			return $this->_params;
411
-		}
412
-
413
-		/**
414
-		 * setWrap
415
-		 *
416
-		 * @param int $wrap The number of characters at which the message will wrap.
417
-		 *
418
-		 * @return self
419
-		 */
420
-		public function setWrap($wrap = 78)
421
-		{
422
-			$wrap = (int) $wrap;
423
-			if ($wrap < 1) {
424
-				$wrap = 78;
425
-			}
426
-			$this->_wrap = $wrap;
427
-			return $this;
428
-		}
429
-
430
-		/**
431
-		 * getWrap
432
-		 *
433
-		 * @return int
434
-		 */
435
-		public function getWrap()
436
-		{
437
-			return $this->_wrap;
438
-		}
439
-
440
-		/**
441
-		 * hasAttachments
442
-		 * 
443
-		 * Checks if the email has any registered attachments.
444
-		 *
445
-		 * @return bool
446
-		 */
447
-		public function hasAttachments()
448
-		{
449
-			return !empty($this->_attachments);
450
-		}
451
-
452
-		/**
453
-		 * assembleAttachment
454
-		 *
455
-		 * @return string
456
-		 */
457
-		public function assembleAttachmentHeaders()
458
-		{
459
-			$head = array();
460
-			$head[] = "MIME-Version: 1.0";
461
-			$head[] = "Content-Type: multipart/mixed; boundary=\"{$this->_uid}\"";
462
-
463
-			return join(PHP_EOL, $head);
464
-		}
465
-
466
-		/**
467
-		 * assembleAttachmentBody
468
-		 *
469
-		 * @return string
470
-		 */
471
-		public function assembleAttachmentBody()
472
-		{
473
-			$body = array();
474
-			$body[] = "This is a multi-part message in MIME format.";
475
-			$body[] = "--{$this->_uid}";
476
-			$body[] = "Content-Type: text/html; charset=\"utf-8\"";
477
-			$body[] = "Content-Transfer-Encoding: quoted-printable";
478
-			$body[] = "";
479
-			$body[] = quoted_printable_encode($this->_message);
480
-			$body[] = "";
481
-			$body[] = "--{$this->_uid}";
482
-
483
-			foreach ($this->_attachments as $attachment) {
484
-				$body[] = $this->getAttachmentMimeTemplate($attachment);
485
-			}
486
-
487
-			return implode(PHP_EOL, $body) . '--';
488
-		}
489
-
490
-		/**
491
-		 * getAttachmentMimeTemplate
492
-		 *
493
-		 * @param array  $attachment An array containing 'file' and 'data' keys.
494
-		 *
495
-		 * @return string
496
-		 */
497
-		public function getAttachmentMimeTemplate($attachment)
498
-		{
499
-			$file = $attachment['file'];
500
-			$data = $attachment['data'];
501
-
502
-			$head = array();
503
-			$head[] = "Content-Type: application/octet-stream; name=\"{$file}\"";
504
-			$head[] = "Content-Transfer-Encoding: base64";
505
-			$head[] = "Content-Disposition: attachment; filename=\"{$file}\"";
506
-			$head[] = "";
507
-			$head[] = $data;
508
-			$head[] = "";
509
-			$head[] = "--{$this->_uid}";
510
-
511
-			return implode(PHP_EOL, $head);
512
-		}
513
-
514
-		/**
515
-		 * send the email
516
-		 *
517
-		 * @return boolean
518
-		 */
519
-		public function send()
520
-		{
521
-			$to = $this->getToForSend();
522
-			$headers = $this->getHeadersForSend();
523
-
524
-			if (empty($to)) {
525
-				show_error('Unable to send, no To address has been set.');
526
-			}
527
-
528
-			if ($this->hasAttachments()) {
529
-				$message  = $this->assembleAttachmentBody();
530
-				$headers .= PHP_EOL . $this->assembleAttachmentHeaders();
531
-			} else {
532
-				$message = $this->getWrapMessage();
533
-			}
534
-			$this->logger->info('Sending new mail, the information are listed below: destination: ' . $to . ', headers: ' . $headers . ', message: ' . $message);
535
-			return mail($to, $this->_subject, $message, $headers, $this->_params);
536
-		}
537
-
538
-		/**
539
-		 * debug
540
-		 *
541
-		 * @return string
542
-		 */
543
-		public function debug()
544
-		{
545
-			return '<pre>' . print_r($this, true) . '</pre>';
546
-		}
547
-
548
-		/**
549
-		 * magic __toString function
550
-		 *
551
-		 * @return string
552
-		 */
553
-		public function __toString()
554
-		{
555
-			return print_r($this, true);
556
-		}
557
-
558
-		/**
559
-		 * formatHeader
560
-		 *
561
-		 * Formats a display address for emails according to RFC2822 e.g.
562
-		 * Name <[email protected]>
563
-		 *
564
-		 * @param string $email The email address.
565
-		 * @param string $name  The display name.
566
-		 *
567
-		 * @return string
568
-		 */
569
-		public function formatHeader($email, $name = null)
570
-		{
571
-			$email = $this->filterEmail((string) $email);
572
-			if (empty($name)) {
573
-				return $email;
574
-			}
575
-			$name = $this->encodeUtf8($this->filterName((string) $name));
576
-			return sprintf('"%s" <%s>', $name, $email);
577
-		}
578
-
579
-		/**
580
-		 * encodeUtf8
581
-		 *
582
-		 * @param string $value The value to encode.
583
-		 *
584
-		 * @return string
585
-		 */
586
-		public function encodeUtf8($value)
587
-		{
588
-			$value = trim($value);
589
-			if (preg_match('/(\s)/', $value)) {
590
-				return $this->encodeUtf8Words($value);
591
-			}
592
-			return $this->encodeUtf8Word($value);
593
-		}
594
-
595
-		/**
596
-		 * encodeUtf8Word
597
-		 *
598
-		 * @param string $value The word to encode.
599
-		 *
600
-		 * @return string
601
-		 */
602
-		public function encodeUtf8Word($value)
603
-		{
604
-			return sprintf('=?UTF-8?B?%s?=', base64_encode($value));
605
-		}
606
-
607
-		/**
608
-		 * encodeUtf8Words
609
-		 *
610
-		 * @param string $value The words to encode.
611
-		 *
612
-		 * @return string
613
-		 */
614
-		public function encodeUtf8Words($value)
615
-		{
616
-			$words = explode(' ', $value);
617
-			$encoded = array();
618
-			foreach ($words as $word) {
619
-				$encoded[] = $this->encodeUtf8Word($word);
620
-			}
621
-			return join($this->encodeUtf8Word(' '), $encoded);
622
-		}
623
-
624
-		/**
625
-		 * filterEmail
626
-		 *
627
-		 * Removes any carriage return, line feed, tab, double quote, comma
628
-		 * and angle bracket characters before sanitizing the email address.
629
-		 *
630
-		 * @param string $email The email to filter.
631
-		 *
632
-		 * @return string
633
-		 */
634
-		public function filterEmail($email)
635
-		{
636
-			$rule = array(
637
-				"\r" => '',
638
-				"\n" => '',
639
-				"\t" => '',
640
-				'"'  => '',
641
-				','  => '',
642
-				'<'  => '',
643
-				'>'  => ''
644
-			);
645
-			$email = strtr($email, $rule);
646
-			$email = filter_var($email, FILTER_SANITIZE_EMAIL);
647
-			return $email;
648
-		}
649
-
650
-		/**
651
-		 * filterName
652
-		 *
653
-		 * Removes any carriage return, line feed or tab characters. Replaces
654
-		 * double quotes with single quotes and angle brackets with square
655
-		 * brackets, before sanitizing the string and stripping out html tags.
656
-		 *
657
-		 * @param string $name The name to filter.
658
-		 *
659
-		 * @return string
660
-		 */
661
-		public function filterName($name)
662
-		{
663
-			$rule = array(
664
-				"\r" => '',
665
-				"\n" => '',
666
-				"\t" => '',
667
-				'"'  => "'",
668
-				'<'  => '[',
669
-				'>'  => ']',
670
-			);
671
-			$filtered = filter_var(
672
-				$name,
673
-				FILTER_SANITIZE_STRING,
674
-				FILTER_FLAG_NO_ENCODE_QUOTES
675
-			);
676
-			return trim(strtr($filtered, $rule));
677
-		}
678
-
679
-		/**
680
-		 * filterOther
681
-		 *
682
-		 * Removes ASCII control characters including any carriage return, line
683
-		 * feed or tab characters.
684
-		 *
685
-		 * @param string $data The data to filter.
686
-		 *
687
-		 * @return string
688
-		 */
689
-		public function filterOther($data)
690
-		{
691
-			return filter_var($data, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW);
692
-		}
693
-
694
-		/**
695
-		 * getHeadersForSend
696
-		 *
697
-		 * @return string
698
-		 */
699
-		public function getHeadersForSend()
700
-		{
701
-			if (empty($this->_headers)) {
702
-				return '';
703
-			}
704
-			return join(PHP_EOL, $this->_headers);
705
-		}
706
-
707
-		/**
708
-		 * getToForSend
709
-		 *
710
-		 * @return string
711
-		 */
712
-		public function getToForSend()
713
-		{
714
-			if (empty($this->_to)) {
715
-				return '';
716
-			}
717
-			return join(', ', $this->_to);
718
-		}
719
-
720
-		/**
721
-		 * getUniqueId
722
-		 *
723
-		 * @return string
724
-		 */
725
-		public function getUniqueId()
726
-		{
727
-			return md5(uniqid(time()));
728
-		}
729
-
730
-		/**
731
-		 * getWrapMessage
732
-		 *
733
-		 * @return string
734
-		 */
735
-		public function getWrapMessage()
736
-		{
737
-			return wordwrap($this->_message, $this->_wrap);
738
-		}
739
-	}
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
+         */
148
+        public function setTos(array $emails)
149
+        {
150
+            foreach ($emails as $name => $email) {
151
+                if(is_numeric($name)){
152
+                    $this->setTo($email);
153
+                }
154
+                else{
155
+                    $this->setTo($email, $name);
156
+                }
157
+            }
158
+            return $this;
159
+        }
160
+
161
+
162
+        /**
163
+         * getTo
164
+         *
165
+         * Return an array of formatted To addresses.
166
+         *
167
+         * @return array
168
+         */
169
+        public function getTo()
170
+        {
171
+            return $this->_to;
172
+        }
173
+
174
+
175
+        /**
176
+         * setCc
177
+         *
178
+         * @param array  $pairs  An array of name => email pairs.
179
+         *
180
+         * @return self
181
+         */
182
+        public function setCc(array $pairs)
183
+        {
184
+            return $this->addMailHeaders('Cc', $pairs);
185
+        }
186
+
187
+        /**
188
+         * setBcc
189
+         *
190
+         * @param array  $pairs  An array of name => email pairs.
191
+         *
192
+         * @return self
193
+         */
194
+        public function setBcc(array $pairs)
195
+        {
196
+            return $this->addMailHeaders('Bcc', $pairs);
197
+        }
198
+
199
+        /**
200
+         * setReplyTo
201
+         *
202
+         * @param string $email
203
+         * @param string $name
204
+         *
205
+         * @return self
206
+         */
207
+        public function setReplyTo($email, $name = null)
208
+        {
209
+            return $this->addMailHeader('Reply-To', $email, $name);
210
+        }
211
+
212
+        /**
213
+         * setHtml
214
+         *
215
+         * @return self
216
+         */
217
+        public function setHtml()
218
+        {
219
+            $this->addGenericHeader(
220
+                'Content-Type', 'text/html; charset="utf-8"'
221
+            );
222
+            return $this;
223
+        }
224
+
225
+        /**
226
+         * setSubject
227
+         *
228
+         * @param string $subject The email subject
229
+         *
230
+         * @return self
231
+         */
232
+        public function setSubject($subject)
233
+        {
234
+            $this->_subject = $this->encodeUtf8(
235
+                $this->filterOther((string) $subject)
236
+            );
237
+            return $this;
238
+        }
239
+
240
+        /**
241
+         * getSubject function.
242
+         *
243
+         * @return string
244
+         */
245
+        public function getSubject()
246
+        {
247
+            return $this->_subject;
248
+        }
249
+
250
+        /**
251
+         * setMessage
252
+         *
253
+         * @param string $message The message to send.
254
+         *
255
+         * @return self
256
+         */
257
+        public function setMessage($message)
258
+        {
259
+            $this->_message = str_replace("\n.", "\n..", (string) $message);
260
+            return $this;
261
+        }
262
+
263
+        /**
264
+         * getMessage
265
+         *
266
+         * @return string
267
+         */
268
+        public function getMessage()
269
+        {
270
+            return $this->_message;
271
+        }
272
+
273
+        /**
274
+         * addAttachment
275
+         *
276
+         * @param string $path The file path to the attachment.
277
+         * @param string $filename The filename of the attachment when emailed.
278
+         * @param string $data
279
+         * 
280
+         * @return self
281
+         */
282
+        public function addAttachment($path, $filename = null, $data = null)
283
+        {
284
+            if(! file_exists($path)){
285
+                show_error('The file [' .$path. '] does not exists.');
286
+            }
287
+            $filename = empty($filename) ? basename($path) : $filename;
288
+            $filename = $this->encodeUtf8($this->filterOther((string) $filename));
289
+            $data = empty($data) ? $this->getAttachmentData($path) : $data;
290
+            $this->_attachments[] = array(
291
+                'path' => $path,
292
+                'file' => $filename,
293
+                'data' => chunk_split(base64_encode($data))
294
+            );
295
+            return $this;
296
+        }
297
+
298
+        /**
299
+         * getAttachmentData
300
+         *
301
+         * @param string $path The path to the attachment file.
302
+         *
303
+         * @return string
304
+         */
305
+        public function getAttachmentData($path)
306
+        {
307
+            if(! file_exists($path)){
308
+                show_error('The file [' .$path. '] does not exists.');
309
+            }
310
+            $filesize = filesize($path);
311
+            $handle = fopen($path, "r");
312
+            $attachment = null;
313
+            if(is_resource($handle)){
314
+                $attachment = fread($handle, $filesize);
315
+                fclose($handle);
316
+            }
317
+            return $attachment;
318
+        }
319
+
320
+        /**
321
+         * addMailHeader
322
+         *
323
+         * @param string $header The header to add.
324
+         * @param string $email  The email to add.
325
+         * @param string $name   The name to add.
326
+         *
327
+         * @return self
328
+         */
329
+        public function addMailHeader($header, $email, $name = null)
330
+        {
331
+            $address = $this->formatHeader((string) $email, (string) $name);
332
+            $this->_headers[] = sprintf('%s: %s', (string) $header, $address);
333
+            return $this;
334
+        }
335
+
336
+        /**
337
+         * addMailHeaders
338
+         *
339
+         * @param string $header The header to add.
340
+         * @param array  $pairs  An array of name => email pairs.
341
+         *
342
+         * @return self
343
+         */
344
+        public function addMailHeaders($header, array $pairs)
345
+        {
346
+            if (count($pairs) === 0) {
347
+                show_error('You must pass at least one name => email pair.');
348
+            }
349
+            $addresses = array();
350
+            foreach ($pairs as $name => $email) {
351
+                $name = is_numeric($name) ? null : $name;
352
+                $addresses[] = $this->formatHeader($email, $name);
353
+            }
354
+            $this->addGenericHeader($header, implode(',', $addresses));
355
+            return $this;
356
+        }
357
+
358
+        /**
359
+         * addGenericHeader
360
+         *
361
+         * @param string $name The generic header to add.
362
+         * @param mixed  $value  The value of the header.
363
+         *
364
+         * @return self
365
+         */
366
+        public function addGenericHeader($name, $value)
367
+        {
368
+            $this->_headers[] = sprintf(
369
+                '%s: %s',
370
+                (string) $name,
371
+                (string) $value
372
+            );
373
+            return $this;
374
+        }
375
+
376
+        /**
377
+         * getHeaders
378
+         *
379
+         * Return the headers registered so far as an array.
380
+         *
381
+         * @return array
382
+         */
383
+        public function getHeaders()
384
+        {
385
+            return $this->_headers;
386
+        }
387
+
388
+        /**
389
+         * setAdditionalParameters
390
+         *
391
+         * Such as "[email protected]
392
+         *
393
+         * @param string $additionalParameters The addition mail parameter.
394
+         *
395
+         * @return self
396
+         */
397
+        public function setParameters($additionalParameters)
398
+        {
399
+            $this->_params = (string) $additionalParameters;
400
+            return $this;
401
+        }
402
+
403
+        /**
404
+         * getAdditionalParameters
405
+         *
406
+         * @return string
407
+         */
408
+        public function getParameters()
409
+        {
410
+            return $this->_params;
411
+        }
412
+
413
+        /**
414
+         * setWrap
415
+         *
416
+         * @param int $wrap The number of characters at which the message will wrap.
417
+         *
418
+         * @return self
419
+         */
420
+        public function setWrap($wrap = 78)
421
+        {
422
+            $wrap = (int) $wrap;
423
+            if ($wrap < 1) {
424
+                $wrap = 78;
425
+            }
426
+            $this->_wrap = $wrap;
427
+            return $this;
428
+        }
429
+
430
+        /**
431
+         * getWrap
432
+         *
433
+         * @return int
434
+         */
435
+        public function getWrap()
436
+        {
437
+            return $this->_wrap;
438
+        }
439
+
440
+        /**
441
+         * hasAttachments
442
+         * 
443
+         * Checks if the email has any registered attachments.
444
+         *
445
+         * @return bool
446
+         */
447
+        public function hasAttachments()
448
+        {
449
+            return !empty($this->_attachments);
450
+        }
451
+
452
+        /**
453
+         * assembleAttachment
454
+         *
455
+         * @return string
456
+         */
457
+        public function assembleAttachmentHeaders()
458
+        {
459
+            $head = array();
460
+            $head[] = "MIME-Version: 1.0";
461
+            $head[] = "Content-Type: multipart/mixed; boundary=\"{$this->_uid}\"";
462
+
463
+            return join(PHP_EOL, $head);
464
+        }
465
+
466
+        /**
467
+         * assembleAttachmentBody
468
+         *
469
+         * @return string
470
+         */
471
+        public function assembleAttachmentBody()
472
+        {
473
+            $body = array();
474
+            $body[] = "This is a multi-part message in MIME format.";
475
+            $body[] = "--{$this->_uid}";
476
+            $body[] = "Content-Type: text/html; charset=\"utf-8\"";
477
+            $body[] = "Content-Transfer-Encoding: quoted-printable";
478
+            $body[] = "";
479
+            $body[] = quoted_printable_encode($this->_message);
480
+            $body[] = "";
481
+            $body[] = "--{$this->_uid}";
482
+
483
+            foreach ($this->_attachments as $attachment) {
484
+                $body[] = $this->getAttachmentMimeTemplate($attachment);
485
+            }
486
+
487
+            return implode(PHP_EOL, $body) . '--';
488
+        }
489
+
490
+        /**
491
+         * getAttachmentMimeTemplate
492
+         *
493
+         * @param array  $attachment An array containing 'file' and 'data' keys.
494
+         *
495
+         * @return string
496
+         */
497
+        public function getAttachmentMimeTemplate($attachment)
498
+        {
499
+            $file = $attachment['file'];
500
+            $data = $attachment['data'];
501
+
502
+            $head = array();
503
+            $head[] = "Content-Type: application/octet-stream; name=\"{$file}\"";
504
+            $head[] = "Content-Transfer-Encoding: base64";
505
+            $head[] = "Content-Disposition: attachment; filename=\"{$file}\"";
506
+            $head[] = "";
507
+            $head[] = $data;
508
+            $head[] = "";
509
+            $head[] = "--{$this->_uid}";
510
+
511
+            return implode(PHP_EOL, $head);
512
+        }
513
+
514
+        /**
515
+         * send the email
516
+         *
517
+         * @return boolean
518
+         */
519
+        public function send()
520
+        {
521
+            $to = $this->getToForSend();
522
+            $headers = $this->getHeadersForSend();
523
+
524
+            if (empty($to)) {
525
+                show_error('Unable to send, no To address has been set.');
526
+            }
527
+
528
+            if ($this->hasAttachments()) {
529
+                $message  = $this->assembleAttachmentBody();
530
+                $headers .= PHP_EOL . $this->assembleAttachmentHeaders();
531
+            } else {
532
+                $message = $this->getWrapMessage();
533
+            }
534
+            $this->logger->info('Sending new mail, the information are listed below: destination: ' . $to . ', headers: ' . $headers . ', message: ' . $message);
535
+            return mail($to, $this->_subject, $message, $headers, $this->_params);
536
+        }
537
+
538
+        /**
539
+         * debug
540
+         *
541
+         * @return string
542
+         */
543
+        public function debug()
544
+        {
545
+            return '<pre>' . print_r($this, true) . '</pre>';
546
+        }
547
+
548
+        /**
549
+         * magic __toString function
550
+         *
551
+         * @return string
552
+         */
553
+        public function __toString()
554
+        {
555
+            return print_r($this, true);
556
+        }
557
+
558
+        /**
559
+         * formatHeader
560
+         *
561
+         * Formats a display address for emails according to RFC2822 e.g.
562
+         * Name <[email protected]>
563
+         *
564
+         * @param string $email The email address.
565
+         * @param string $name  The display name.
566
+         *
567
+         * @return string
568
+         */
569
+        public function formatHeader($email, $name = null)
570
+        {
571
+            $email = $this->filterEmail((string) $email);
572
+            if (empty($name)) {
573
+                return $email;
574
+            }
575
+            $name = $this->encodeUtf8($this->filterName((string) $name));
576
+            return sprintf('"%s" <%s>', $name, $email);
577
+        }
578
+
579
+        /**
580
+         * encodeUtf8
581
+         *
582
+         * @param string $value The value to encode.
583
+         *
584
+         * @return string
585
+         */
586
+        public function encodeUtf8($value)
587
+        {
588
+            $value = trim($value);
589
+            if (preg_match('/(\s)/', $value)) {
590
+                return $this->encodeUtf8Words($value);
591
+            }
592
+            return $this->encodeUtf8Word($value);
593
+        }
594
+
595
+        /**
596
+         * encodeUtf8Word
597
+         *
598
+         * @param string $value The word to encode.
599
+         *
600
+         * @return string
601
+         */
602
+        public function encodeUtf8Word($value)
603
+        {
604
+            return sprintf('=?UTF-8?B?%s?=', base64_encode($value));
605
+        }
606
+
607
+        /**
608
+         * encodeUtf8Words
609
+         *
610
+         * @param string $value The words to encode.
611
+         *
612
+         * @return string
613
+         */
614
+        public function encodeUtf8Words($value)
615
+        {
616
+            $words = explode(' ', $value);
617
+            $encoded = array();
618
+            foreach ($words as $word) {
619
+                $encoded[] = $this->encodeUtf8Word($word);
620
+            }
621
+            return join($this->encodeUtf8Word(' '), $encoded);
622
+        }
623
+
624
+        /**
625
+         * filterEmail
626
+         *
627
+         * Removes any carriage return, line feed, tab, double quote, comma
628
+         * and angle bracket characters before sanitizing the email address.
629
+         *
630
+         * @param string $email The email to filter.
631
+         *
632
+         * @return string
633
+         */
634
+        public function filterEmail($email)
635
+        {
636
+            $rule = array(
637
+                "\r" => '',
638
+                "\n" => '',
639
+                "\t" => '',
640
+                '"'  => '',
641
+                ','  => '',
642
+                '<'  => '',
643
+                '>'  => ''
644
+            );
645
+            $email = strtr($email, $rule);
646
+            $email = filter_var($email, FILTER_SANITIZE_EMAIL);
647
+            return $email;
648
+        }
649
+
650
+        /**
651
+         * filterName
652
+         *
653
+         * Removes any carriage return, line feed or tab characters. Replaces
654
+         * double quotes with single quotes and angle brackets with square
655
+         * brackets, before sanitizing the string and stripping out html tags.
656
+         *
657
+         * @param string $name The name to filter.
658
+         *
659
+         * @return string
660
+         */
661
+        public function filterName($name)
662
+        {
663
+            $rule = array(
664
+                "\r" => '',
665
+                "\n" => '',
666
+                "\t" => '',
667
+                '"'  => "'",
668
+                '<'  => '[',
669
+                '>'  => ']',
670
+            );
671
+            $filtered = filter_var(
672
+                $name,
673
+                FILTER_SANITIZE_STRING,
674
+                FILTER_FLAG_NO_ENCODE_QUOTES
675
+            );
676
+            return trim(strtr($filtered, $rule));
677
+        }
678
+
679
+        /**
680
+         * filterOther
681
+         *
682
+         * Removes ASCII control characters including any carriage return, line
683
+         * feed or tab characters.
684
+         *
685
+         * @param string $data The data to filter.
686
+         *
687
+         * @return string
688
+         */
689
+        public function filterOther($data)
690
+        {
691
+            return filter_var($data, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW);
692
+        }
693
+
694
+        /**
695
+         * getHeadersForSend
696
+         *
697
+         * @return string
698
+         */
699
+        public function getHeadersForSend()
700
+        {
701
+            if (empty($this->_headers)) {
702
+                return '';
703
+            }
704
+            return join(PHP_EOL, $this->_headers);
705
+        }
706
+
707
+        /**
708
+         * getToForSend
709
+         *
710
+         * @return string
711
+         */
712
+        public function getToForSend()
713
+        {
714
+            if (empty($this->_to)) {
715
+                return '';
716
+            }
717
+            return join(', ', $this->_to);
718
+        }
719
+
720
+        /**
721
+         * getUniqueId
722
+         *
723
+         * @return string
724
+         */
725
+        public function getUniqueId()
726
+        {
727
+            return md5(uniqid(time()));
728
+        }
729
+
730
+        /**
731
+         * getWrapMessage
732
+         *
733
+         * @return string
734
+         */
735
+        public function getWrapMessage()
736
+        {
737
+            return wordwrap($this->_message, $this->_wrap);
738
+        }
739
+    }
Please login to merge, or discard this patch.
core/libraries/Cookie.php 1 patch
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -1,112 +1,112 @@
 block discarded – undo
1 1
 <?php
2
-	defined('ROOT_PATH') || exit('Access denied');
3
-	/**
4
-	 * TNH Framework
5
-	 *
6
-	 * A simple PHP framework using HMVC architecture
7
-	 *
8
-	 * This content is released under the GNU GPL License (GPL)
9
-	 *
10
-	 * Copyright (C) 2017 Tony NGUEREZA
11
-	 *
12
-	 * This program is free software; you can redistribute it and/or
13
-	 * modify it under the terms of the GNU General Public License
14
-	 * as published by the Free Software Foundation; either version 3
15
-	 * of the License, or (at your option) any later version.
16
-	 *
17
-	 * This program is distributed in the hope that it will be useful,
18
-	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
-	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
-	 * GNU General Public License for more details.
21
-	 *
22
-	 * You should have received a copy of the GNU General Public License
23
-	 * along with this program; if not, write to the Free Software
24
-	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
-	*/
2
+    defined('ROOT_PATH') || exit('Access denied');
3
+    /**
4
+     * TNH Framework
5
+     *
6
+     * A simple PHP framework using HMVC architecture
7
+     *
8
+     * This content is released under the GNU GPL License (GPL)
9
+     *
10
+     * Copyright (C) 2017 Tony NGUEREZA
11
+     *
12
+     * This program is free software; you can redistribute it and/or
13
+     * modify it under the terms of the GNU General Public License
14
+     * as published by the Free Software Foundation; either version 3
15
+     * of the License, or (at your option) any later version.
16
+     *
17
+     * This program is distributed in the hope that it will be useful,
18
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+     * GNU General Public License for more details.
21
+     *
22
+     * You should have received a copy of the GNU General Public License
23
+     * along with this program; if not, write to the Free Software
24
+     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
+     */
26 26
 
27
-	class Cookie{
27
+    class Cookie{
28 28
 		
29
-		/**
30
-		 * The logger instance
31
-		 * @var Log
32
-		 */
33
-		private static $logger;
29
+        /**
30
+         * The logger instance
31
+         * @var Log
32
+         */
33
+        private static $logger;
34 34
 
35
-		/**
36
-		 * The signleton of the logger
37
-		 * @return Object the Log instance
38
-		 */
39
-		private static function getLogger(){
40
-			if(self::$logger == null){
41
-				self::$logger[0] =& class_loader('Log', 'classes');
42
-				self::$logger[0]->setLogger('Library::Cookie');
43
-			}
44
-			return self::$logger[0];
45
-		}
35
+        /**
36
+         * The signleton of the logger
37
+         * @return Object the Log instance
38
+         */
39
+        private static function getLogger(){
40
+            if(self::$logger == null){
41
+                self::$logger[0] =& class_loader('Log', 'classes');
42
+                self::$logger[0]->setLogger('Library::Cookie');
43
+            }
44
+            return self::$logger[0];
45
+        }
46 46
 
47
-		/**
48
-		 * Get the cookie item value
49
-		 * @param  string $item    the cookie item name to get
50
-		 * @param  mixed $default the default value to use if can not find the cokkie item in the list
51
-		 * @return mixed          the cookie value if exist or the default value
52
-		 */
53
-		public static function get($item, $default = null){
54
-			$logger = self::getLogger();
55
-			if(array_key_exists($item, $_COOKIE)){
56
-				return $_COOKIE[$item];
57
-			}
58
-			$logger->warning('Cannot find cookie item [' . $item . '], using the default value [' . $default . ']');
59
-			return $default;
60
-		}
47
+        /**
48
+         * Get the cookie item value
49
+         * @param  string $item    the cookie item name to get
50
+         * @param  mixed $default the default value to use if can not find the cokkie item in the list
51
+         * @return mixed          the cookie value if exist or the default value
52
+         */
53
+        public static function get($item, $default = null){
54
+            $logger = self::getLogger();
55
+            if(array_key_exists($item, $_COOKIE)){
56
+                return $_COOKIE[$item];
57
+            }
58
+            $logger->warning('Cannot find cookie item [' . $item . '], using the default value [' . $default . ']');
59
+            return $default;
60
+        }
61 61
 
62
-		/**
63
-		 * Set the cookie item value
64
-		 * @param string  $name     the cookie item name
65
-		 * @param string  $value    the cookie value to set
66
-		 * @param integer $expire   the time to live for this cookie
67
-		 * @param string  $path     the path that the cookie will be available
68
-		 * @param string  $domain   the domain that the cookie will be available
69
-		 * @param boolean $secure   if this cookie will be available on secure connection or not
70
-		 * @param boolean $httponly if this cookie will be available under HTTP protocol.
71
-		 */
72
-		public static function set($name, $value = '', $expire = 0, $path = '/', $domain = '', $secure = false, $httponly = false){
73
-			if(headers_sent()){
74
-				show_error('There exists a cookie that we wanted to create that we couldn\'t 
62
+        /**
63
+         * Set the cookie item value
64
+         * @param string  $name     the cookie item name
65
+         * @param string  $value    the cookie value to set
66
+         * @param integer $expire   the time to live for this cookie
67
+         * @param string  $path     the path that the cookie will be available
68
+         * @param string  $domain   the domain that the cookie will be available
69
+         * @param boolean $secure   if this cookie will be available on secure connection or not
70
+         * @param boolean $httponly if this cookie will be available under HTTP protocol.
71
+         */
72
+        public static function set($name, $value = '', $expire = 0, $path = '/', $domain = '', $secure = false, $httponly = false){
73
+            if(headers_sent()){
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
-			}
78
-			$timestamp = $expire;
79
-			if($expire){
80
-				$timestamp = time() + $expire;
81
-			}
82
-			setcookie($name, $value, $timestamp, $path, $domain, $secure, $httponly);
83
-		}
77
+            }
78
+            $timestamp = $expire;
79
+            if($expire){
80
+                $timestamp = time() + $expire;
81
+            }
82
+            setcookie($name, $value, $timestamp, $path, $domain, $secure, $httponly);
83
+        }
84 84
 
85
-		/**
86
-		 * Delete the cookie item in the list
87
-		 * @param  string $item the cookie item name to be cleared
88
-		 * @return boolean true if the item exists and is deleted successfully otherwise will return false.
89
-		 */
90
-		public static function delete($item){
91
-			$logger = self::getLogger();
92
-			if(array_key_exists($item, $_COOKIE)){
93
-				$logger->info('Delete cookie item ['.$item.']');
94
-				unset($_COOKIE[$item]);
95
-				return true;
96
-			}
97
-			else{
98
-				$logger->warning('Cookie item ['.$item.'] to be deleted does not exists');
99
-				return false;
100
-			}
101
-		}
85
+        /**
86
+         * Delete the cookie item in the list
87
+         * @param  string $item the cookie item name to be cleared
88
+         * @return boolean true if the item exists and is deleted successfully otherwise will return false.
89
+         */
90
+        public static function delete($item){
91
+            $logger = self::getLogger();
92
+            if(array_key_exists($item, $_COOKIE)){
93
+                $logger->info('Delete cookie item ['.$item.']');
94
+                unset($_COOKIE[$item]);
95
+                return true;
96
+            }
97
+            else{
98
+                $logger->warning('Cookie item ['.$item.'] to be deleted does not exists');
99
+                return false;
100
+            }
101
+        }
102 102
 
103
-		/**
104
-		 * Check if the given cookie item exists
105
-		 * @param  string $item the cookie item name
106
-		 * @return boolean       true if the cookie item is set, false or not
107
-		 */
108
-		public static function exists($item){
109
-			return array_key_exists($item, $_COOKIE);
110
-		}
103
+        /**
104
+         * Check if the given cookie item exists
105
+         * @param  string $item the cookie item name
106
+         * @return boolean       true if the cookie item is set, false or not
107
+         */
108
+        public static function exists($item){
109
+            return array_key_exists($item, $_COOKIE);
110
+        }
111 111
 
112
-	}
112
+    }
Please login to merge, or discard this patch.
core/libraries/StringHash.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -1,65 +1,65 @@
 block discarded – undo
1 1
 <?php 
2
-	defined('ROOT_PATH') || exit('Access denied');
3
-	/**
4
-	 * TNH Framework
5
-	 *
6
-	 * A simple PHP framework using HMVC architecture
7
-	 *
8
-	 * This content is released under the GNU GPL License (GPL)
9
-	 *
10
-	 * Copyright (C) 2017 Tony NGUEREZA
11
-	 *
12
-	 * This program is free software; you can redistribute it and/or
13
-	 * modify it under the terms of the GNU General Public License
14
-	 * as published by the Free Software Foundation; either version 3
15
-	 * of the License, or (at your option) any later version.
16
-	 *
17
-	 * This program is distributed in the hope that it will be useful,
18
-	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
-	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
-	 * GNU General Public License for more details.
21
-	 *
22
-	 * You should have received a copy of the GNU General Public License
23
-	 * along with this program; if not, write to the Free Software
24
-	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
-	*/
2
+    defined('ROOT_PATH') || exit('Access denied');
3
+    /**
4
+     * TNH Framework
5
+     *
6
+     * A simple PHP framework using HMVC architecture
7
+     *
8
+     * This content is released under the GNU GPL License (GPL)
9
+     *
10
+     * Copyright (C) 2017 Tony NGUEREZA
11
+     *
12
+     * This program is free software; you can redistribute it and/or
13
+     * modify it under the terms of the GNU General Public License
14
+     * as published by the Free Software Foundation; either version 3
15
+     * of the License, or (at your option) any later version.
16
+     *
17
+     * This program is distributed in the hope that it will be useful,
18
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+     * GNU General Public License for more details.
21
+     *
22
+     * You should have received a copy of the GNU General Public License
23
+     * along with this program; if not, write to the Free Software
24
+     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
+     */
26 26
 
27
-	class StringHash{
27
+    class StringHash{
28 28
 		 
29
-		 //blowfish
30
-		private static $algo = '$2a';
29
+            //blowfish
30
+        private static $algo = '$2a';
31 31
 		
32
-		//cost parameter
33
-		private static $cost = '$10';
32
+        //cost parameter
33
+        private static $cost = '$10';
34 34
 
35
-		/**
36
-		 * Get the unique salt for the string hash
37
-		 * @return string the unique generated salt
38
-		 */
39
-		private static function uniqueSalt() {
40
-			return substr(sha1(mt_rand()), 0, 22);
41
-		}
35
+        /**
36
+         * Get the unique salt for the string hash
37
+         * @return string the unique generated salt
38
+         */
39
+        private static function uniqueSalt() {
40
+            return substr(sha1(mt_rand()), 0, 22);
41
+        }
42 42
 
43
-		/**
44
-		 * Hash the given string
45
-		 * @param  string $value the plain string text to be hashed
46
-		 * @return string           the hashed string
47
-		 */
48
-		public static function hash($value) {
49
-			return crypt($value, self::$algo .
50
-					self::$cost .
51
-					'$' . self::uniqueSalt());
52
-		}
43
+        /**
44
+         * Hash the given string
45
+         * @param  string $value the plain string text to be hashed
46
+         * @return string           the hashed string
47
+         */
48
+        public static function hash($value) {
49
+            return crypt($value, self::$algo .
50
+                    self::$cost .
51
+                    '$' . self::uniqueSalt());
52
+        }
53 53
 
54
-		/**
55
-		 * Check if the hash and plain string is valid
56
-		 * @param  string $hash     the hashed string
57
-		 * @param  string $plain the plain text
58
-		 * @return boolean  true if is valid or false if not
59
-		 */
60
-		public static function check($hash, $plain) {
61
-			$full_salt = substr($hash, 0, 29);
62
-			$new_hash = crypt($plain, $full_salt);
63
-			return ($hash === $new_hash);
64
-		}	
65
-	}
66 54
\ No newline at end of file
55
+        /**
56
+         * Check if the hash and plain string is valid
57
+         * @param  string $hash     the hashed string
58
+         * @param  string $plain the plain text
59
+         * @return boolean  true if is valid or false if not
60
+         */
61
+        public static function check($hash, $plain) {
62
+            $full_salt = substr($hash, 0, 29);
63
+            $new_hash = crypt($plain, $full_salt);
64
+            return ($hash === $new_hash);
65
+        }	
66
+    }
67 67
\ No newline at end of file
Please login to merge, or discard this patch.
core/libraries/Benchmark.php 1 patch
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -1,89 +1,89 @@
 block discarded – undo
1 1
 <?php
2
-	defined('ROOT_PATH') or exit('Access denied');
3
-	/**
4
-	 * TNH Framework
5
-	 *
6
-	 * A simple PHP framework using HMVC architecture
7
-	 *
8
-	 * This content is released under the GNU GPL License (GPL)
9
-	 *
10
-	 * Copyright (C) 2017 Tony NGUEREZA
11
-	 *
12
-	 * This program is free software; you can redistribute it and/or
13
-	 * modify it under the terms of the GNU General Public License
14
-	 * as published by the Free Software Foundation; either version 3
15
-	 * of the License, or (at your option) any later version.
16
-	 *
17
-	 * This program is distributed in the hope that it will be useful,
18
-	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
-	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
-	 * GNU General Public License for more details.
21
-	 *
22
-	 * You should have received a copy of the GNU General Public License
23
-	 * along with this program; if not, write to the Free Software
24
-	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
-	*/
2
+    defined('ROOT_PATH') or exit('Access denied');
3
+    /**
4
+     * TNH Framework
5
+     *
6
+     * A simple PHP framework using HMVC architecture
7
+     *
8
+     * This content is released under the GNU GPL License (GPL)
9
+     *
10
+     * Copyright (C) 2017 Tony NGUEREZA
11
+     *
12
+     * This program is free software; you can redistribute it and/or
13
+     * modify it under the terms of the GNU General Public License
14
+     * as published by the Free Software Foundation; either version 3
15
+     * of the License, or (at your option) any later version.
16
+     *
17
+     * This program is distributed in the hope that it will be useful,
18
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+     * GNU General Public License for more details.
21
+     *
22
+     * You should have received a copy of the GNU General Public License
23
+     * along with this program; if not, write to the Free Software
24
+     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
+     */
26 26
 
27
-	/**
28
-	 * Class for Benchmark
29
-	 */
30
-	class Benchmark{
31
-		/**
32
-		 * The markers for excution time
33
-		 * @var array
34
-		 */
35
-		private $markersTime = array();
27
+    /**
28
+     * Class for Benchmark
29
+     */
30
+    class Benchmark{
31
+        /**
32
+         * The markers for excution time
33
+         * @var array
34
+         */
35
+        private $markersTime = array();
36 36
 		
37
-		/**
38
-		 * The markers for memory usage
39
-		 * @var array
40
-		 */
41
-		private $markersMemory = array();
37
+        /**
38
+         * The markers for memory usage
39
+         * @var array
40
+         */
41
+        private $markersMemory = array();
42 42
 		
43
-		/**
44
-		 * This method is used to mark one point for benchmark (execution time and memory usage)
45
-		 * @param  string $name the marker name
46
-		 */
47
-		public function mark($name){
48
-			//Marker for execution time
49
-			$this->markersTime[$name] = microtime(true);
50
-			//Marker for memory usage
51
-			$this->markersMemory[$name] = memory_get_usage(true);
52
-		}
43
+        /**
44
+         * This method is used to mark one point for benchmark (execution time and memory usage)
45
+         * @param  string $name the marker name
46
+         */
47
+        public function mark($name){
48
+            //Marker for execution time
49
+            $this->markersTime[$name] = microtime(true);
50
+            //Marker for memory usage
51
+            $this->markersMemory[$name] = memory_get_usage(true);
52
+        }
53 53
 		
54
-		/**
55
-		 * This method is used to get the total excution time in second between two markers
56
-		 * @param  string  $startMarkerName the marker for start point
57
-		 * @param  string  $endMarkerName   the marker for end point
58
-		 * @param  integer $decimalCount   the number of decimal
59
-		 * @return string         the total execution time
60
-		 */
61
-		public function elapsedTime($startMarkerName = null, $endMarkerName = null, $decimalCount = 6){
62
-			if(! $startMarkerName || !isset($this->markersTime[$startMarkerName])){
63
-				return 0;
64
-			}
54
+        /**
55
+         * This method is used to get the total excution time in second between two markers
56
+         * @param  string  $startMarkerName the marker for start point
57
+         * @param  string  $endMarkerName   the marker for end point
58
+         * @param  integer $decimalCount   the number of decimal
59
+         * @return string         the total execution time
60
+         */
61
+        public function elapsedTime($startMarkerName = null, $endMarkerName = null, $decimalCount = 6){
62
+            if(! $startMarkerName || !isset($this->markersTime[$startMarkerName])){
63
+                return 0;
64
+            }
65 65
 			
66
-			if(! isset($this->markersTime[$endMarkerName])){
67
-				$this->markersTime[$endMarkerName] = microtime(true);
68
-			}
69
-			return number_format($this->markersTime[$endMarkerName] - $this->markersTime[$startMarkerName], $decimalCount);
70
-		}
66
+            if(! isset($this->markersTime[$endMarkerName])){
67
+                $this->markersTime[$endMarkerName] = microtime(true);
68
+            }
69
+            return number_format($this->markersTime[$endMarkerName] - $this->markersTime[$startMarkerName], $decimalCount);
70
+        }
71 71
 		
72
-		/**
73
-		 * This method is used to get the total memory usage in byte between two markers
74
-		 * @param  string  $startMarkerName the marker for start point
75
-		 * @param  string  $endMarkerName   the marker for end point
76
-		 * @param  integer $decimalCount   the number of decimal
77
-		 * @return string         the total memory usage
78
-		 */
79
-		public function memoryUsage($startMarkerName = null, $endMarkerName = null, $decimalCount = 6){
80
-			if(! $startMarkerName || !isset($this->markersMemory[$startMarkerName])){
81
-				return 0;
82
-			}
72
+        /**
73
+         * This method is used to get the total memory usage in byte between two markers
74
+         * @param  string  $startMarkerName the marker for start point
75
+         * @param  string  $endMarkerName   the marker for end point
76
+         * @param  integer $decimalCount   the number of decimal
77
+         * @return string         the total memory usage
78
+         */
79
+        public function memoryUsage($startMarkerName = null, $endMarkerName = null, $decimalCount = 6){
80
+            if(! $startMarkerName || !isset($this->markersMemory[$startMarkerName])){
81
+                return 0;
82
+            }
83 83
 			
84
-			if(! isset($this->markersMemory[$endMarkerName])){
85
-				$this->markersMemory[$endMarkerName] = microtime(true);
86
-			}
87
-			return number_format($this->markersMemory[$endMarkerName] - $this->markersMemory[$startMarkerName], $decimalCount);
88
-		}
89
-	}
84
+            if(! isset($this->markersMemory[$endMarkerName])){
85
+                $this->markersMemory[$endMarkerName] = microtime(true);
86
+            }
87
+            return number_format($this->markersMemory[$endMarkerName] - $this->markersMemory[$startMarkerName], $decimalCount);
88
+        }
89
+    }
Please login to merge, or discard this patch.
core/libraries/Pagination.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,32 +1,32 @@  discard block
 block discarded – undo
1 1
 <?php
2 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
-	*/
3
+    /**
4
+     * TNH Framework
5
+     *
6
+     * A simple PHP framework using HMVC architecture
7
+     *
8
+     * This content is released under the GNU GPL License (GPL)
9
+     *
10
+     * Copyright (C) 2017 Tony NGUEREZA
11
+     *
12
+     * This program is free software; you can redistribute it and/or
13
+     * modify it under the terms of the GNU General Public License
14
+     * as published by the Free Software Foundation; either version 3
15
+     * of the License, or (at your option) any later version.
16
+     *
17
+     * This program is distributed in the hope that it will be useful,
18
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+     * GNU General Public License for more details.
21
+     *
22
+     * You should have received a copy of the GNU General Public License
23
+     * along with this program; if not, write to the Free Software
24
+     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
+     */
26 26
 
27 27
     class Pagination{
28 28
         
29
-		/**
29
+        /**
30 30
          * The list of loaded config
31 31
          * @var array
32 32
          */
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
                 if(empty($config) || ! is_array($config)){
44 44
                     show_error('No configuration found in ' . CONFIG_PATH . 'config_pagination.php');
45 45
                 }
46
-				else{
47
-					if(! empty($overwriteConfig)){
48
-						$config = array_merge($config, $overwriteConfig);
49
-					}
50
-					$this->config = $config;
46
+                else{
47
+                    if(! empty($overwriteConfig)){
48
+                        $config = array_merge($config, $overwriteConfig);
49
+                    }
50
+                    $this->config = $config;
51 51
                     //put it gobally
52
-					Config::setAll($config);
53
-					unset($config);
54
-				}
52
+                    Config::setAll($config);
53
+                    unset($config);
54
+                }
55 55
             }
56 56
             else{
57 57
                 show_error('Unable to find the pagination configuration file');
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         public function getLink($totalRows, $currentPageNumber){
81 81
             $pageQueryName = $this->config['page_query_string_name'];
82 82
             $numberOfLink = $this->config['nb_link'];
83
-			$numberOfRowPerPage = $this->config['pagination_per_page'];
83
+            $numberOfRowPerPage = $this->config['pagination_per_page'];
84 84
             $queryString = Url::queryString();
85 85
             $currentUrl = Url::current();
86 86
             if($queryString == ''){
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
             $navbar = '';
107 107
             $numberOfPage = ceil($totalRows / $numberOfRowPerPage);
108 108
             $currentPageNumber = (int) $currentPageNumber;
109
-			if($currentPageNumber <= 0){
110
-				$currentPageNumber = 1;
111
-			}
109
+            if($currentPageNumber <= 0){
110
+                $currentPageNumber = 1;
111
+            }
112 112
             if($numberOfPage <= 1 || $numberOfLink <= 0 || $numberOfRowPerPage <= 0 || !is_numeric($numberOfLink) || !is_numeric($numberOfRowPerPage)
113 113
             ){
114 114
                 return $navbar;
Please login to merge, or discard this patch.
core/libraries/FormValidation.php 1 patch
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@  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
-     class FormValidation{
28
+        class FormValidation{
29 29
 		 
30 30
         /**
31 31
          * The form validation status
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
          */
61 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
          */
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 
87 87
         /**
88 88
          * Whether to check the CSRF. This attribute is just a way to allow custom change of the 
89
-		 * CSRF global configuration
90
-		 *
89
+         * CSRF global configuration
90
+         *
91 91
          * @var boolean
92 92
          */
93 93
         public $enableCsrfCheck = false;
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             $this->logger =& class_loader('Log', 'classes');
102 102
             $this->logger->setLogger('Library::FormValidation');
103 103
            
104
-		   //Load form validation language message
104
+            //Load form validation language message
105 105
             Loader::lang('form_validation');
106 106
             $obj = & get_instance();
107 107
             $this->_errorsMessages  = array(
@@ -141,19 +141,19 @@  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
         /**
148 148
          * Set the form validation data
149 149
          * @param array $data the values to be validated
150
-		 *
150
+         *
151 151
          * @return FormValidation Current instance of object.
152 152
          */
153 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
-			return $this;
156
+            return $this;
157 157
         }
158 158
 
159 159
         /**
@@ -164,11 +164,11 @@  discard block
 block discarded – undo
164 164
             return $this->data;
165 165
         }
166 166
 
167
-		/**
168
-		* Get the validation function name to validate a rule
169
-		*
170
-		* @return string the function name
171
-		*/
167
+        /**
168
+         * Get the validation function name to validate a rule
169
+         *
170
+         * @return string the function name
171
+         */
172 172
         protected function _toCallCase($funcName, $prefix='_validate') {
173 173
             $funcName = strtolower($funcName);
174 174
             $finalFuncName = $prefix;
@@ -238,12 +238,12 @@  discard block
 block discarded – undo
238 238
             $this->_forceFail = false;
239 239
 
240 240
             foreach ($this->getData() as $inputName => $inputVal) {
241
-    			if(is_array($this->data[$inputName])){
242
-    				$this->data[$inputName] = array_map('trim', $this->data[$inputName]);
243
-    			}
244
-    			else{
245
-    				$this->data[$inputName] = trim($this->data[$inputName]);
246
-    			}
241
+                if(is_array($this->data[$inputName])){
242
+                    $this->data[$inputName] = array_map('trim', $this->data[$inputName]);
243
+                }
244
+                else{
245
+                    $this->data[$inputName] = trim($this->data[$inputName]);
246
+                }
247 247
 
248 248
                 if (array_key_exists($inputName, $this->_rules)) {
249 249
                     foreach ($this->_parseRuleString($this->_rules[$inputName]) as $eachRule) {
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
          *
263 263
          * @param string $inputField Name of the field or the data key to add a rule to
264 264
          * @param string $ruleSets PIPE seperated string of rules
265
-		 *
265
+         *
266 266
          * @return FormValidation Current instance of object.
267 267
          */
268 268
         public function setRule($inputField, $inputLabel, $ruleSets) {
@@ -276,8 +276,8 @@  discard block
 block discarded – undo
276 276
          * Takes an array of rules and uses setRule() to set them, accepts an array
277 277
          * of rule names rather than a pipe-delimited string as well.
278 278
          * @param array $ruleSets
279
-		 *
280
-		 * @return FormValidation Current instance of object.
279
+         *
280
+         * @return FormValidation Current instance of object.
281 281
          */
282 282
         public function setRules(array $ruleSets) {
283 283
             foreach ($ruleSets as $ruleSet) {
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
          * @param string $start Before block of errors gets displayed, HTML allowed.
300 300
          * @param string $end After the block of errors gets displayed, HTML allowed.
301 301
          *
302
-		 * @return FormValidation Current instance of object.
302
+         * @return FormValidation Current instance of object.
303 303
          */
304 304
         public function setErrorsDelimiter($start, $end) {
305 305
             $this->_allErrorsDelimiter[0] = $start;
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
          * @param string $start Displayed before each error.
315 315
          * @param string $end Displayed after each error.
316 316
          * 
317
-		 * @return FormValidation Current instance of object.
317
+         * @return FormValidation Current instance of object.
318 318
          */
319 319
         public function setErrorDelimiter($start, $end) {
320 320
             $this->_eachErrorDelimiter[0] = $start;
@@ -322,21 +322,21 @@  discard block
 block discarded – undo
322 322
             return $this;
323 323
         }
324 324
 
325
-		/**
326
-		* Get the each errors delimiters
327
-		*
328
-		* @return array
329
-		*/
330
-    	public function getErrorDelimiter() {
325
+        /**
326
+         * Get the each errors delimiters
327
+         *
328
+         * @return array
329
+         */
330
+        public function getErrorDelimiter() {
331 331
             return $this->_eachErrorDelimiter;
332 332
         }
333 333
 
334
-		/**
335
-		* Get the all errors delimiters
336
-		*
337
-		* @return array
338
-		*/
339
-    	public function getErrorsDelimiter() {
334
+        /**
335
+         * Get the all errors delimiters
336
+         *
337
+         * @return array
338
+         */
339
+        public function getErrorsDelimiter() {
340 340
             return $this->_allErrorsDelimiter;
341 341
         }
342 342
 
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
          *
375 375
          * @param string $inputName The form input name or data key
376 376
          * @param string $errorMessage Error to display
377
-		 *
377
+         *
378 378
          * @return formValidation Current instance of the object
379 379
          */
380 380
         public function setCustomError($inputName, $errorMessage) {
@@ -411,17 +411,17 @@  discard block
 block discarded – undo
411 411
          *
412 412
          * @param boolean $limit number of error to display or return
413 413
          * @param boolean $echo Whether or not the values are to be returned or displayed
414
-		 *
414
+         *
415 415
          * @return string Errors formatted for output
416 416
          */
417 417
         public function displayErrors($limit = null, $echo = true) {
418 418
             list($errorsStart, $errorsEnd) = $this->_allErrorsDelimiter;
419 419
             list($errorStart, $errorEnd) = $this->_eachErrorDelimiter;
420 420
             $errorOutput = $errorsStart;
421
-    		$i = 0;
421
+            $i = 0;
422 422
             if (!empty($this->_errors)) {
423 423
                 foreach ($this->_errors as $fieldName => $error) {
424
-        	    	if ($i === $limit) { 
424
+                    if ($i === $limit) { 
425 425
                         break; 
426 426
                     }
427 427
                     $errorOutput .= $errorStart;
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
          * Breaks up a PIPE seperated string of rules, and puts them into an array.
450 450
          *
451 451
          * @param string $ruleString String to be parsed.
452
-		 *
452
+         *
453 453
          * @return array Array of each value in original string.
454 454
          */
455 455
         protected function _parseRuleString($ruleString) {
@@ -462,10 +462,10 @@  discard block
 block discarded – undo
462 462
                 $rule = '#regex\[\/(.*)\/([a-zA-Z0-9]?)\]#';
463 463
                 preg_match($rule, $ruleString, $regexRule);
464 464
                 $ruleStringTemp = preg_replace($rule, '', $ruleString);
465
-                 if(!empty($regexRule[0])){
466
-                     $ruleSets[] = $regexRule[0];
467
-                 }
468
-                 $ruleStringRegex = explode('|', $ruleStringTemp);
465
+                    if(!empty($regexRule[0])){
466
+                        $ruleSets[] = $regexRule[0];
467
+                    }
468
+                    $ruleStringRegex = explode('|', $ruleStringTemp);
469 469
                 foreach ($ruleStringRegex as $rule) {
470 470
                     $rule = trim($rule);
471 471
                     if($rule){
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
                 } else {
482 482
                     $ruleSets[] = $ruleString;
483 483
                 }
484
-             }
484
+                }
485 485
             return $ruleSets;
486 486
         }
487 487
 
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
          * Returns whether or not a field obtains the rule "required".
490 490
          *
491 491
          * @param string $fieldName Field to check if required.
492
-		 *
492
+         *
493 493
          * @return boolean Whether or not the field is required.
494 494
          */
495 495
         protected function _fieldIsRequired($fieldName) {
@@ -524,13 +524,13 @@  discard block
 block discarded – undo
524 524
             return;
525 525
         }
526 526
 
527
-		/**
528
-		* Set error for the given field or key
529
-		*
530
-		* @param string $inputName the input or key name
531
-		* @param string $ruleName the rule name
532
-		* @param array|string $replacements
533
-		*/
527
+        /**
528
+         * Set error for the given field or key
529
+         *
530
+         * @param string $inputName the input or key name
531
+         * @param string $ruleName the rule name
532
+         * @param array|string $replacements
533
+         */
534 534
         protected function _setError($inputName, $ruleName, $replacements = array()) {
535 535
             $rulePhraseKeyParts = explode(',', $ruleName);
536 536
             $rulePhrase = null;
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
             }
548 548
             // Type cast to array in case it's a string
549 549
             $replacements = (array) $replacements;
550
-			$replacementCount = count($replacements);
550
+            $replacementCount = count($replacements);
551 551
             for ($i = 1; $i <= $replacementCount; $i++) {
552 552
                 $key = $i - 1;
553 553
                 $rulePhrase = str_replace('%' . $i, $replacements[$key], $rulePhrase);
@@ -565,11 +565,11 @@  discard block
 block discarded – undo
565 565
          *
566 566
          * @param type $inputArg
567 567
          * @param string $callbackFunc
568
-		 *
568
+         *
569 569
          * @return mixed
570 570
          */
571 571
         protected function _runCallback($inputArg, $callbackFunc) {
572
-			return eval('return ' . $callbackFunc . '("' . $inputArg . '");');
572
+            return eval('return ' . $callbackFunc . '("' . $inputArg . '");');
573 573
         }
574 574
 
575 575
         /**
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
          * arguments.
579 579
          *
580 580
          * @param string $callbackFunc
581
-		 *
581
+         *
582 582
          * @return mixed
583 583
          */
584 584
         protected function _runEmptyCallback($callbackFunc) {
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
          * Gets a specific label of a specific field input name.
590 590
          *
591 591
          * @param string $inputName
592
-		 *
592
+         *
593 593
          * @return string
594 594
          */
595 595
         protected function _getLabel($inputName) {
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
          * @param  string $ruleName  the rule name for this validation ("required")
603 603
          * @param  array  $ruleArgs  the rules argument
604 604
          */
605
-		protected function _validateRequired($inputName, $ruleName, array $ruleArgs) {
605
+        protected function _validateRequired($inputName, $ruleName, array $ruleArgs) {
606 606
             $inputVal = $this->post($inputName);
607 607
             if(array_key_exists(1, $ruleArgs) && function_exists($ruleArgs[1])) {
608 608
                 $callbackReturn = $this->_runEmptyCallback($ruleArgs[1]);
@@ -610,8 +610,8 @@  discard block
 block discarded – undo
610 610
                     $this->_setError($inputName, $ruleName, $this->_getLabel($inputName));
611 611
                 }
612 612
             } 
613
-			else if($inputVal == '') {
614
-				$this->_setError($inputName, $ruleName, $this->_getLabel($inputName));
613
+            else if($inputVal == '') {
614
+                $this->_setError($inputName, $ruleName, $this->_getLabel($inputName));
615 615
             }
616 616
         }
617 617
 
@@ -635,10 +635,10 @@  discard block
 block discarded – undo
635 635
          */
636 636
         protected function _validateCallback($inputName, $ruleName, array $ruleArgs) {
637 637
             if (function_exists($ruleArgs[1]) && !empty($this->data[$inputName])) {
638
-				$result = $this->_runCallback($this->data[$inputName], $ruleArgs[1]);
639
-				if(! $result){
640
-					$this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
641
-				}
638
+                $result = $this->_runCallback($this->data[$inputName], $ruleArgs[1]);
639
+                if(! $result){
640
+                    $this->_setError($inputName, $ruleName, array($this->_getLabel($inputName)));
641
+                }
642 642
             }
643 643
         }
644 644
 
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
                         continue;
671 671
                     }
672 672
                 } 
673
-				else{
673
+                else{
674 674
                     if ($inputVal == $doNotEqual) {
675 675
                         $this->_setError($inputName, $ruleName . ',string', array($this->_getLabel($inputName), $doNotEqual));
676 676
                         continue;
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
          * @param  string $ruleName  the rule name for this validation ("less_than")
763 763
          * @param  array  $ruleArgs  the rules argument
764 764
          */
765
-    	protected function _validateLessThan($inputName, $ruleName, array $ruleArgs) {
765
+        protected function _validateLessThan($inputName, $ruleName, array $ruleArgs) {
766 766
             $inputVal = $this->post($inputName);
767 767
             if ($inputVal >= $ruleArgs[1]) { 
768 768
                 if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
          * @param  string $ruleName  the rule name for this validation ("greater_than")
779 779
          * @param  array  $ruleArgs  the rules argument
780 780
          */
781
-    	protected function _validateGreaterThan($inputName, $ruleName, array $ruleArgs) {
781
+        protected function _validateGreaterThan($inputName, $ruleName, array $ruleArgs) {
782 782
             $inputVal = $this->post($inputName);
783 783
             if ($inputVal <= $ruleArgs[1]) {
784 784
                 if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
          * @param  string $ruleName  the rule name for this validation ("numeric")
795 795
          * @param  array  $ruleArgs  the rules argument
796 796
          */
797
-    	protected function _validateNumeric($inputName, $ruleName, array $ruleArgs) {
797
+        protected function _validateNumeric($inputName, $ruleName, array $ruleArgs) {
798 798
             $inputVal = $this->post($inputName);
799 799
             if (! is_numeric($inputVal)) {
800 800
                 if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
@@ -810,17 +810,17 @@  discard block
 block discarded – undo
810 810
          * @param  string $ruleName  the rule name for this validation ("exists")
811 811
          * @param  array  $ruleArgs  the rules argument
812 812
          */
813
-		protected function _validateExists($inputName, $ruleName, array $ruleArgs) {
813
+        protected function _validateExists($inputName, $ruleName, array $ruleArgs) {
814 814
             $inputVal = $this->post($inputName);
815
-    		$obj = & get_instance();
816
-    		if(! isset($obj->database)){
817
-    			return;
818
-    		}
819
-    		list($table, $column) = explode('.', $ruleArgs[1]);
820
-    		$obj->database->from($table)
821
-    			          ->where($column, $inputVal)
822
-    			          ->get();
823
-    		$nb = $obj->database->numRows();
815
+            $obj = & get_instance();
816
+            if(! isset($obj->database)){
817
+                return;
818
+            }
819
+            list($table, $column) = explode('.', $ruleArgs[1]);
820
+            $obj->database->from($table)
821
+                            ->where($column, $inputVal)
822
+                            ->get();
823
+            $nb = $obj->database->numRows();
824 824
             if ($nb == 0) {
825 825
                 if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
826 826
                     return;
@@ -835,17 +835,17 @@  discard block
 block discarded – undo
835 835
          * @param  string $ruleName  the rule name for this validation ("is_unique")
836 836
          * @param  array  $ruleArgs  the rules argument
837 837
          */
838
-    	protected function _validateIsUnique($inputName, $ruleName, array $ruleArgs) {
838
+        protected function _validateIsUnique($inputName, $ruleName, array $ruleArgs) {
839 839
             $inputVal = $this->post($inputName);
840
-    		$obj = & get_instance();
841
-    		if(! isset($obj->database)){
842
-    			return;
843
-    		}
844
-    		list($table, $column) = explode('.', $ruleArgs[1]);
845
-    		$obj->database->from($table)
846
-    			          ->where($column, $inputVal)
847
-    			          ->get();
848
-    		$nb = $obj->database->numRows();
840
+            $obj = & get_instance();
841
+            if(! isset($obj->database)){
842
+                return;
843
+            }
844
+            list($table, $column) = explode('.', $ruleArgs[1]);
845
+            $obj->database->from($table)
846
+                            ->where($column, $inputVal)
847
+                            ->get();
848
+            $nb = $obj->database->numRows();
849 849
             if ($nb != 0) {
850 850
                 if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
851 851
                     return;
@@ -860,23 +860,23 @@  discard block
 block discarded – undo
860 860
          * @param  string $ruleName  the rule name for this validation ("is_unique_update")
861 861
          * @param  array  $ruleArgs  the rules argument
862 862
          */
863
-    	protected function _validateIsUniqueUpdate($inputName, $ruleName, array $ruleArgs) {
863
+        protected function _validateIsUniqueUpdate($inputName, $ruleName, array $ruleArgs) {
864 864
             $inputVal = $this->post($inputName);
865
-    		$obj = & get_instance();
866
-    		if(! isset($obj->database)){
867
-    			return;
868
-    		}
869
-    		$data = explode(',', $ruleArgs[1]);
870
-    		if(count($data) < 2){
871
-    			return;
872
-    		}
873
-    		list($table, $column) = explode('.', $data[0]);
874
-    		list($field, $val) = explode('=', $data[1]);
875
-    		$obj->database->from($table)
876
-    			          ->where($column, $inputVal)
877
-                		  ->where($field, '!=', trim($val))
878
-                		  ->get();
879
-    		$nb = $obj->database->numRows();
865
+            $obj = & get_instance();
866
+            if(! isset($obj->database)){
867
+                return;
868
+            }
869
+            $data = explode(',', $ruleArgs[1]);
870
+            if(count($data) < 2){
871
+                return;
872
+            }
873
+            list($table, $column) = explode('.', $data[0]);
874
+            list($field, $val) = explode('=', $data[1]);
875
+            $obj->database->from($table)
876
+                            ->where($column, $inputVal)
877
+                            ->where($field, '!=', trim($val))
878
+                            ->get();
879
+            $nb = $obj->database->numRows();
880 880
             if ($nb != 0) {
881 881
                 if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
882 882
                     return;
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
          */
894 894
         protected function _validateInList($inputName, $ruleName, array $ruleArgs) {
895 895
             $inputVal = $this->post($inputName);
896
-    		$list = explode(',', $ruleArgs[1]);
896
+            $list = explode(',', $ruleArgs[1]);
897 897
             $list = array_map('trim', $list);
898 898
             if (! in_array($inputVal, $list)) {
899 899
                 if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
          */
912 912
         protected function _validateRegex($inputName, $ruleName, array $ruleArgs) {
913 913
             $inputVal = $this->post($inputName);
914
-    		$regex = $ruleArgs[1];
914
+            $regex = $ruleArgs[1];
915 915
             if (! preg_match($regex, $inputVal)) {
916 916
                 if (! $this->_fieldIsRequired($inputName) && empty($this->data[$inputName])) {
917 917
                     return;
Please login to merge, or discard this patch.
core/libraries/PDF.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -1,87 +1,87 @@
 block discarded – undo
1 1
 <?php
2
-	defined('ROOT_PATH') or exit('Access denied');
3
-	/**
4
-	 * TNH Framework
5
-	 *
6
-	 * A simple PHP framework using HMVC architecture
7
-	 *
8
-	 * This content is released under the GNU GPL License (GPL)
9
-	 *
10
-	 * Copyright (C) 2017 Tony NGUEREZA
11
-	 *
12
-	 * This program is free software; you can redistribute it and/or
13
-	 * modify it under the terms of the GNU General Public License
14
-	 * as published by the Free Software Foundation; either version 3
15
-	 * of the License, or (at your option) any later version.
16
-	 *
17
-	 * This program is distributed in the hope that it will be useful,
18
-	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
-	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
-	 * GNU General Public License for more details.
21
-	 *
22
-	 * You should have received a copy of the GNU General Public License
23
-	 * along with this program; if not, write to the Free Software
24
-	 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
-	*/
2
+    defined('ROOT_PATH') or exit('Access denied');
3
+    /**
4
+     * TNH Framework
5
+     *
6
+     * A simple PHP framework using HMVC architecture
7
+     *
8
+     * This content is released under the GNU GPL License (GPL)
9
+     *
10
+     * Copyright (C) 2017 Tony NGUEREZA
11
+     *
12
+     * This program is free software; you can redistribute it and/or
13
+     * modify it under the terms of the GNU General Public License
14
+     * as published by the Free Software Foundation; either version 3
15
+     * of the License, or (at your option) any later version.
16
+     *
17
+     * This program is distributed in the hope that it will be useful,
18
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+     * GNU General Public License for more details.
21
+     *
22
+     * You should have received a copy of the GNU General Public License
23
+     * along with this program; if not, write to the Free Software
24
+     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
+     */
26 26
 
27
-	/**
28
-	 * PDF library to generate PDF document using the library DOMPDF
29
-	 */
30
-	class PDF{
27
+    /**
28
+     * PDF library to generate PDF document using the library DOMPDF
29
+     */
30
+    class PDF{
31 31
 		
32
-		/**
33
-		 * The dompdf instance
34
-		 * @var Dompdf
35
-		 */
36
-		private $dompdf = null;
32
+        /**
33
+         * The dompdf instance
34
+         * @var Dompdf
35
+         */
36
+        private $dompdf = null;
37 37
 
38
-		/**
39
-		 * The logger instance
40
-		 * @var Log
41
-		 */
42
-		private $logger;
38
+        /**
39
+         * The logger instance
40
+         * @var Log
41
+         */
42
+        private $logger;
43 43
 		
44
-		/**
45
-		 * Create PDF library instance
46
-		 */
47
-		public function __construct(){
48
-	        $this->logger =& class_loader('Log', 'classes');
49
-	        $this->logger->setLogger('Library::PDF');
44
+        /**
45
+         * Create PDF library instance
46
+         */
47
+        public function __construct(){
48
+            $this->logger =& class_loader('Log', 'classes');
49
+            $this->logger->setLogger('Library::PDF');
50 50
 
51
-			require_once VENDOR_PATH.'dompdf/dompdf_config.inc.php';
52
-			$this->dompdf = new Dompdf();
53
-		}
51
+            require_once VENDOR_PATH.'dompdf/dompdf_config.inc.php';
52
+            $this->dompdf = new Dompdf();
53
+        }
54 54
 
55
-		/**
56
-		 * Generate PDF document
57
-		 * @param  string  $html        the HTML content to use for generation
58
-		 * @param  string  $filename    the generated PDF document filename
59
-		 * @param  boolean $stream      if need send the generated PDF to browser for download
60
-		 * @param  string  $paper       the PDF document paper type like 'A4', 'A5', 'letter', etc.
61
-		 * @param  string  $orientation the PDF document orientation like 'portrait', 'landscape'
62
-		 * @return string|void               if $stream is true send PDF document to browser for download, else return the generated PDF
63
-		 * content like to join in Email attachment of for other purpose use.
64
-		 */
65
-		public function generate($html, $filename = 'output.pdf', $stream = true, $paper = 'A4', $orientation = 'portrait'){
66
-			$this->logger->info('Generating of PDF document: filename [' .$filename. '], stream [' .($stream ? 'TRUE':'FALSE'). '], paper [' .$paper. '], orientation [' .$orientation. ']');
67
-			$this->dompdf->load_html($html);
68
-			$this->dompdf->set_paper($paper, $orientation);
69
-			$this->dompdf->render();
70
-			if($stream){
71
-				$this->dompdf->stream($filename);
72
-			}
73
-			else{
74
-				return $this->dompdf->output();
75
-			}
76
-		}
55
+        /**
56
+         * Generate PDF document
57
+         * @param  string  $html        the HTML content to use for generation
58
+         * @param  string  $filename    the generated PDF document filename
59
+         * @param  boolean $stream      if need send the generated PDF to browser for download
60
+         * @param  string  $paper       the PDF document paper type like 'A4', 'A5', 'letter', etc.
61
+         * @param  string  $orientation the PDF document orientation like 'portrait', 'landscape'
62
+         * @return string|void               if $stream is true send PDF document to browser for download, else return the generated PDF
63
+         * content like to join in Email attachment of for other purpose use.
64
+         */
65
+        public function generate($html, $filename = 'output.pdf', $stream = true, $paper = 'A4', $orientation = 'portrait'){
66
+            $this->logger->info('Generating of PDF document: filename [' .$filename. '], stream [' .($stream ? 'TRUE':'FALSE'). '], paper [' .$paper. '], orientation [' .$orientation. ']');
67
+            $this->dompdf->load_html($html);
68
+            $this->dompdf->set_paper($paper, $orientation);
69
+            $this->dompdf->render();
70
+            if($stream){
71
+                $this->dompdf->stream($filename);
72
+            }
73
+            else{
74
+                return $this->dompdf->output();
75
+            }
76
+        }
77 77
 		
78
-		/**
79
-		* Return the instance of Dompdf
80
-		*
81
-		* @return object the dompdf instance
82
-		*/
83
-		public function getDompdf(){
84
-			return $this->dompdf;
85
-		}
78
+        /**
79
+         * Return the instance of Dompdf
80
+         *
81
+         * @return object the dompdf instance
82
+         */
83
+        public function getDompdf(){
84
+            return $this->dompdf;
85
+        }
86 86
 		
87
-	}
87
+    }
Please login to merge, or discard this patch.