@@ -1,65 +1,65 @@ |
||
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 |
@@ -1,89 +1,89 @@ |
||
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 | + } |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | $this->_forceFail = false; |
246 | 246 | |
247 | 247 | foreach ($this->getData() as $inputName => $inputVal) { |
248 | - if(is_array($this->data[$inputName])){ |
|
249 | - $this->data[$inputName] = array_map('trim', $this->data[$inputName]); |
|
250 | - } else{ |
|
251 | - $this->data[$inputName] = trim($this->data[$inputName]); |
|
252 | - } |
|
248 | + if(is_array($this->data[$inputName])){ |
|
249 | + $this->data[$inputName] = array_map('trim', $this->data[$inputName]); |
|
250 | + } else{ |
|
251 | + $this->data[$inputName] = trim($this->data[$inputName]); |
|
252 | + } |
|
253 | 253 | |
254 | 254 | if (array_key_exists($inputName, $this->_rules)) { |
255 | 255 | foreach ($this->_parseRuleString($this->_rules[$inputName]) as $eachRule) { |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | $this->_setError($inputName, $ruleName, $this->_getLabel($inputName)); |
614 | 614 | } |
615 | 615 | } else if($inputVal == '') { |
616 | - $this->_setError($inputName, $ruleName, $this->_getLabel($inputName)); |
|
616 | + $this->_setError($inputName, $ruleName, $this->_getLabel($inputName)); |
|
617 | 617 | } |
618 | 618 | } |
619 | 619 |
@@ -1,79 +1,79 @@ |
||
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 extends BaseClass { |
|
27 | + /** |
|
28 | + * PDF library to generate PDF document using the library DOMPDF |
|
29 | + */ |
|
30 | + class PDF extends BaseClass { |
|
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 | - * Create PDF library instance |
|
40 | - */ |
|
41 | - public function __construct() { |
|
42 | - parent::__construct(); |
|
38 | + /** |
|
39 | + * Create PDF library instance |
|
40 | + */ |
|
41 | + public function __construct() { |
|
42 | + parent::__construct(); |
|
43 | 43 | |
44 | - require_once VENDOR_PATH . 'dompdf/dompdf_config.inc.php'; |
|
45 | - $this->dompdf = new Dompdf(); |
|
46 | - } |
|
44 | + require_once VENDOR_PATH . 'dompdf/dompdf_config.inc.php'; |
|
45 | + $this->dompdf = new Dompdf(); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Generate PDF document |
|
50 | - * @param string $html the HTML content to use for generation |
|
51 | - * @param string $filename the generated PDF document filename |
|
52 | - * @param boolean $stream if need send the generated PDF to browser for download |
|
53 | - * @param string $paper the PDF document paper type like 'A4', 'A5', 'letter', etc. |
|
54 | - * @param string $orientation the PDF document orientation like 'portrait', 'landscape' |
|
55 | - * @return string|void if $stream is true send PDF document to browser for download, else return the generated PDF |
|
56 | - * content like to join in Email attachment of for other purpose use. |
|
57 | - */ |
|
58 | - public function generate($html, $filename = 'output.pdf', $stream = true, $paper = 'A4', $orientation = 'portrait'){ |
|
59 | - $this->logger->info('Generating of PDF document: filename [' .$filename. '], stream [' .($stream ? 'TRUE':'FALSE'). '], paper [' .$paper. '], orientation [' .$orientation. ']'); |
|
60 | - $this->dompdf->load_html($html); |
|
61 | - $this->dompdf->set_paper($paper, $orientation); |
|
62 | - $this->dompdf->render(); |
|
63 | - if($stream){ |
|
64 | - $this->dompdf->stream($filename); |
|
65 | - } else{ |
|
66 | - return $this->dompdf->output(); |
|
67 | - } |
|
68 | - } |
|
48 | + /** |
|
49 | + * Generate PDF document |
|
50 | + * @param string $html the HTML content to use for generation |
|
51 | + * @param string $filename the generated PDF document filename |
|
52 | + * @param boolean $stream if need send the generated PDF to browser for download |
|
53 | + * @param string $paper the PDF document paper type like 'A4', 'A5', 'letter', etc. |
|
54 | + * @param string $orientation the PDF document orientation like 'portrait', 'landscape' |
|
55 | + * @return string|void if $stream is true send PDF document to browser for download, else return the generated PDF |
|
56 | + * content like to join in Email attachment of for other purpose use. |
|
57 | + */ |
|
58 | + public function generate($html, $filename = 'output.pdf', $stream = true, $paper = 'A4', $orientation = 'portrait'){ |
|
59 | + $this->logger->info('Generating of PDF document: filename [' .$filename. '], stream [' .($stream ? 'TRUE':'FALSE'). '], paper [' .$paper. '], orientation [' .$orientation. ']'); |
|
60 | + $this->dompdf->load_html($html); |
|
61 | + $this->dompdf->set_paper($paper, $orientation); |
|
62 | + $this->dompdf->render(); |
|
63 | + if($stream){ |
|
64 | + $this->dompdf->stream($filename); |
|
65 | + } else{ |
|
66 | + return $this->dompdf->output(); |
|
67 | + } |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Return the instance of Dompdf |
|
72 | - * |
|
73 | - * @return object the dompdf instance |
|
74 | - */ |
|
75 | - public function getDompdf() { |
|
76 | - return $this->dompdf; |
|
77 | - } |
|
70 | + /** |
|
71 | + * Return the instance of Dompdf |
|
72 | + * |
|
73 | + * @return object the dompdf instance |
|
74 | + */ |
|
75 | + public function getDompdf() { |
|
76 | + return $this->dompdf; |
|
77 | + } |
|
78 | 78 | |
79 | - } |
|
79 | + } |
@@ -1,204 +1,204 @@ |
||
1 | 1 | <?php |
2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
3 | - /** |
|
4 | - * TNH Framework |
|
5 | - * |
|
6 | - * A simple PHP framework using HMVC architecture |
|
7 | - * |
|
8 | - * This content is released under the GNU GPL License (GPL) |
|
9 | - * |
|
10 | - * Copyright (C) 2017 Tony NGUEREZA |
|
11 | - * |
|
12 | - * This program is free software; you can redistribute it and/or |
|
13 | - * modify it under the terms of the GNU General Public License |
|
14 | - * as published by the Free Software Foundation; either version 3 |
|
15 | - * of the License, or (at your option) any later version. |
|
16 | - * |
|
17 | - * This program is distributed in the hope that it will be useful, |
|
18 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 | - * GNU General Public License for more details. |
|
21 | - * |
|
22 | - * You should have received a copy of the GNU General Public License |
|
23 | - * along with this program; if not, write to the Free Software |
|
24 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
25 | - */ |
|
26 | - |
|
27 | - /** |
|
28 | - * @file bootstrap.php |
|
29 | - * |
|
30 | - * Contains the loading process: loading of constants, common functions, libraries |
|
31 | - * configurations, etc |
|
32 | - * verification of the environment and the routing of the request. |
|
33 | - * |
|
34 | - * @package core |
|
35 | - * @author Tony NGUEREZA |
|
36 | - * @copyright Copyright (c) 2017 |
|
37 | - * @license https://opensource.org/licenses/gpl-3.0.html GNU GPL License (GPL) |
|
38 | - * @link http://www.iacademy.cf |
|
39 | - * @version 1.0.0 |
|
40 | - * @filesource |
|
41 | - */ |
|
2 | + defined('ROOT_PATH') || exit('Access denied'); |
|
3 | + /** |
|
4 | + * TNH Framework |
|
5 | + * |
|
6 | + * A simple PHP framework using HMVC architecture |
|
7 | + * |
|
8 | + * This content is released under the GNU GPL License (GPL) |
|
9 | + * |
|
10 | + * Copyright (C) 2017 Tony NGUEREZA |
|
11 | + * |
|
12 | + * This program is free software; you can redistribute it and/or |
|
13 | + * modify it under the terms of the GNU General Public License |
|
14 | + * as published by the Free Software Foundation; either version 3 |
|
15 | + * of the License, or (at your option) any later version. |
|
16 | + * |
|
17 | + * This program is distributed in the hope that it will be useful, |
|
18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 | + * GNU General Public License for more details. |
|
21 | + * |
|
22 | + * You should have received a copy of the GNU General Public License |
|
23 | + * along with this program; if not, write to the Free Software |
|
24 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
25 | + */ |
|
26 | + |
|
27 | + /** |
|
28 | + * @file bootstrap.php |
|
29 | + * |
|
30 | + * Contains the loading process: loading of constants, common functions, libraries |
|
31 | + * configurations, etc |
|
32 | + * verification of the environment and the routing of the request. |
|
33 | + * |
|
34 | + * @package core |
|
35 | + * @author Tony NGUEREZA |
|
36 | + * @copyright Copyright (c) 2017 |
|
37 | + * @license https://opensource.org/licenses/gpl-3.0.html GNU GPL License (GPL) |
|
38 | + * @link http://www.iacademy.cf |
|
39 | + * @version 1.0.0 |
|
40 | + * @filesource |
|
41 | + */ |
|
42 | 42 | |
43 | - //if the application is running in CLI mode $_SESSION global variable is not available |
|
44 | - if (IS_CLI) { |
|
45 | - $_SESSION = array(); |
|
46 | - } |
|
43 | + //if the application is running in CLI mode $_SESSION global variable is not available |
|
44 | + if (IS_CLI) { |
|
45 | + $_SESSION = array(); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * inclusion of global constants of the environment that contain : name of the framework, |
|
50 | - * version, release date, version of PHP required, etc. |
|
51 | - */ |
|
52 | - require_once CORE_PATH . 'constants.php'; |
|
48 | + /** |
|
49 | + * inclusion of global constants of the environment that contain : name of the framework, |
|
50 | + * version, release date, version of PHP required, etc. |
|
51 | + */ |
|
52 | + require_once CORE_PATH . 'constants.php'; |
|
53 | 53 | |
54 | - /** |
|
55 | - * include file containing commons functions used in the framework such: show_error, |
|
56 | - * php_exception_handler, php_error_handler, get_instance, etc. |
|
57 | - */ |
|
58 | - require_once CORE_PATH . 'common.php'; |
|
59 | - |
|
60 | - /** |
|
61 | - * Include of the file containing the BaseClass |
|
62 | - */ |
|
63 | - require_once CORE_CLASSES_PATH . 'BaseClass.php'; |
|
64 | - |
|
65 | - /** |
|
66 | - * Include of the file containing the BaseClass |
|
67 | - */ |
|
68 | - require_once CORE_CLASSES_PATH . 'BaseStaticClass.php'; |
|
69 | - |
|
70 | - /** |
|
71 | - * The Benchmark class |
|
72 | - */ |
|
73 | - $BENCHMARK = & class_loader('Benchmark'); |
|
54 | + /** |
|
55 | + * include file containing commons functions used in the framework such: show_error, |
|
56 | + * php_exception_handler, php_error_handler, get_instance, etc. |
|
57 | + */ |
|
58 | + require_once CORE_PATH . 'common.php'; |
|
59 | + |
|
60 | + /** |
|
61 | + * Include of the file containing the BaseClass |
|
62 | + */ |
|
63 | + require_once CORE_CLASSES_PATH . 'BaseClass.php'; |
|
64 | + |
|
65 | + /** |
|
66 | + * Include of the file containing the BaseClass |
|
67 | + */ |
|
68 | + require_once CORE_CLASSES_PATH . 'BaseStaticClass.php'; |
|
69 | + |
|
70 | + /** |
|
71 | + * The Benchmark class |
|
72 | + */ |
|
73 | + $BENCHMARK = & class_loader('Benchmark'); |
|
74 | 74 | |
75 | - $BENCHMARK->mark('APP_EXECUTION_START'); |
|
75 | + $BENCHMARK->mark('APP_EXECUTION_START'); |
|
76 | 76 | |
77 | - /** |
|
78 | - * instance of the Log class |
|
79 | - */ |
|
77 | + /** |
|
78 | + * instance of the Log class |
|
79 | + */ |
|
80 | 80 | $LOGGER = & class_loader('Log', 'classes'); |
81 | 81 | |
82 | 82 | $LOGGER->setLogger('ApplicationBootstrap'); |
83 | 83 | |
84 | 84 | $LOGGER->debug('Checking PHP version ...'); |
85 | 85 | |
86 | - /** |
|
87 | - * Verification of the PHP environment: minimum and maximum version |
|
88 | - */ |
|
89 | - if (version_compare(phpversion(), TNH_REQUIRED_PHP_MIN_VERSION, '<')){ |
|
90 | - show_error('Your PHP Version [' . phpversion() . '] is less than [' . TNH_REQUIRED_PHP_MIN_VERSION . '], please install a new version or update your PHP to the latest.', 'PHP Error environment'); |
|
91 | - } else if(version_compare(phpversion(), TNH_REQUIRED_PHP_MAX_VERSION, '>')){ |
|
92 | - show_error('Your PHP Version [' . phpversion() . '] is greather than [' . TNH_REQUIRED_PHP_MAX_VERSION . '] please install a PHP version that is compatible.', 'PHP Error environment'); |
|
93 | - } |
|
94 | - $LOGGER->info('PHP version [' . phpversion() . '] is OK [REQUIRED MINIMUM: ' . TNH_REQUIRED_PHP_MIN_VERSION . ', REQUIRED MAXIMUM: ' . TNH_REQUIRED_PHP_MAX_VERSION . '], application can work without any issue'); |
|
95 | - |
|
96 | - /** |
|
97 | - * Setting of the PHP error message handling function |
|
98 | - */ |
|
99 | - set_error_handler('php_error_handler'); |
|
100 | - |
|
101 | - /** |
|
102 | - * Setting of the PHP error exception handling function |
|
103 | - */ |
|
104 | - set_exception_handler('php_exception_handler'); |
|
105 | - |
|
106 | - /** |
|
107 | - * Setting of the PHP shutdown handling function |
|
108 | - */ |
|
109 | - register_shutdown_function('php_shudown_handler'); |
|
86 | + /** |
|
87 | + * Verification of the PHP environment: minimum and maximum version |
|
88 | + */ |
|
89 | + if (version_compare(phpversion(), TNH_REQUIRED_PHP_MIN_VERSION, '<')){ |
|
90 | + show_error('Your PHP Version [' . phpversion() . '] is less than [' . TNH_REQUIRED_PHP_MIN_VERSION . '], please install a new version or update your PHP to the latest.', 'PHP Error environment'); |
|
91 | + } else if(version_compare(phpversion(), TNH_REQUIRED_PHP_MAX_VERSION, '>')){ |
|
92 | + show_error('Your PHP Version [' . phpversion() . '] is greather than [' . TNH_REQUIRED_PHP_MAX_VERSION . '] please install a PHP version that is compatible.', 'PHP Error environment'); |
|
93 | + } |
|
94 | + $LOGGER->info('PHP version [' . phpversion() . '] is OK [REQUIRED MINIMUM: ' . TNH_REQUIRED_PHP_MIN_VERSION . ', REQUIRED MAXIMUM: ' . TNH_REQUIRED_PHP_MAX_VERSION . '], application can work without any issue'); |
|
95 | + |
|
96 | + /** |
|
97 | + * Setting of the PHP error message handling function |
|
98 | + */ |
|
99 | + set_error_handler('php_error_handler'); |
|
100 | + |
|
101 | + /** |
|
102 | + * Setting of the PHP error exception handling function |
|
103 | + */ |
|
104 | + set_exception_handler('php_exception_handler'); |
|
105 | + |
|
106 | + /** |
|
107 | + * Setting of the PHP shutdown handling function |
|
108 | + */ |
|
109 | + register_shutdown_function('php_shudown_handler'); |
|
110 | 110 | |
111 | - //if user have some composer packages |
|
112 | - $LOGGER->debug('Check for composer autoload'); |
|
113 | - if(file_exists(VENDOR_PATH . 'autoload.php')){ |
|
114 | - $LOGGER->info('The composer autoload file exists include it'); |
|
115 | - require_once VENDOR_PATH . 'autoload.php'; |
|
116 | - } else{ |
|
117 | - $LOGGER->info('The composer autoload file does not exist skipping'); |
|
118 | - } |
|
111 | + //if user have some composer packages |
|
112 | + $LOGGER->debug('Check for composer autoload'); |
|
113 | + if(file_exists(VENDOR_PATH . 'autoload.php')){ |
|
114 | + $LOGGER->info('The composer autoload file exists include it'); |
|
115 | + require_once VENDOR_PATH . 'autoload.php'; |
|
116 | + } else{ |
|
117 | + $LOGGER->info('The composer autoload file does not exist skipping'); |
|
118 | + } |
|
119 | 119 | |
120 | - $LOGGER->debug('Begin to load the required resources'); |
|
121 | - |
|
122 | - /** |
|
123 | - * Load the EventInfo class file |
|
124 | - */ |
|
125 | - require_once CORE_CLASSES_PATH . 'EventInfo.php'; |
|
126 | - |
|
127 | - |
|
128 | - $BENCHMARK->mark('CONFIG_INIT_START'); |
|
129 | - /** |
|
130 | - * Load configurations and using the |
|
131 | - * static method "init()" to initialize the Config class . |
|
132 | - */ |
|
133 | - $CONFIG = & class_loader('Config', 'classes'); |
|
134 | - $CONFIG->init(); |
|
135 | - $BENCHMARK->mark('CONFIG_INIT_END'); |
|
136 | - |
|
137 | - $BENCHMARK->mark('MODULE_INIT_START'); |
|
138 | - /** |
|
139 | - * Load modules and using the |
|
140 | - * static method "init()" to initialize the Module class. |
|
141 | - */ |
|
142 | - $MODULE = & class_loader('Module', 'classes'); |
|
143 | - $MODULE->init(); |
|
144 | - $BENCHMARK->mark('MODULE_INIT_END'); |
|
145 | - |
|
146 | - $LOGGER->debug('Loading Base Controller ...'); |
|
147 | - /** |
|
148 | - * Include of the file containing the Base Controller class |
|
149 | - */ |
|
150 | - require_once CORE_CLASSES_PATH . 'Controller.php'; |
|
151 | - $LOGGER->info('Base Controller loaded successfully'); |
|
152 | - |
|
153 | - /** |
|
154 | - * Register controllers autoload function |
|
155 | - */ |
|
156 | - spl_autoload_register('autoload_controller'); |
|
157 | - |
|
158 | - /** |
|
159 | - * Loading Security class |
|
160 | - */ |
|
161 | - $SECURITY =& class_loader('Security', 'classes'); |
|
162 | - $SECURITY->checkWhiteListIpAccess(); |
|
120 | + $LOGGER->debug('Begin to load the required resources'); |
|
121 | + |
|
122 | + /** |
|
123 | + * Load the EventInfo class file |
|
124 | + */ |
|
125 | + require_once CORE_CLASSES_PATH . 'EventInfo.php'; |
|
126 | + |
|
127 | + |
|
128 | + $BENCHMARK->mark('CONFIG_INIT_START'); |
|
129 | + /** |
|
130 | + * Load configurations and using the |
|
131 | + * static method "init()" to initialize the Config class . |
|
132 | + */ |
|
133 | + $CONFIG = & class_loader('Config', 'classes'); |
|
134 | + $CONFIG->init(); |
|
135 | + $BENCHMARK->mark('CONFIG_INIT_END'); |
|
136 | + |
|
137 | + $BENCHMARK->mark('MODULE_INIT_START'); |
|
138 | + /** |
|
139 | + * Load modules and using the |
|
140 | + * static method "init()" to initialize the Module class. |
|
141 | + */ |
|
142 | + $MODULE = & class_loader('Module', 'classes'); |
|
143 | + $MODULE->init(); |
|
144 | + $BENCHMARK->mark('MODULE_INIT_END'); |
|
145 | + |
|
146 | + $LOGGER->debug('Loading Base Controller ...'); |
|
147 | + /** |
|
148 | + * Include of the file containing the Base Controller class |
|
149 | + */ |
|
150 | + require_once CORE_CLASSES_PATH . 'Controller.php'; |
|
151 | + $LOGGER->info('Base Controller loaded successfully'); |
|
152 | + |
|
153 | + /** |
|
154 | + * Register controllers autoload function |
|
155 | + */ |
|
156 | + spl_autoload_register('autoload_controller'); |
|
157 | + |
|
158 | + /** |
|
159 | + * Loading Security class |
|
160 | + */ |
|
161 | + $SECURITY =& class_loader('Security', 'classes'); |
|
162 | + $SECURITY->checkWhiteListIpAccess(); |
|
163 | 163 | |
164 | - /** |
|
165 | - * Loading Url class |
|
166 | - */ |
|
167 | - $URL =& class_loader('Url', 'classes'); |
|
164 | + /** |
|
165 | + * Loading Url class |
|
166 | + */ |
|
167 | + $URL =& class_loader('Url', 'classes'); |
|
168 | 168 | |
169 | - if(get_config('cache_enable', false)){ |
|
170 | - /** |
|
171 | - * Load Cache interface file |
|
172 | - */ |
|
173 | - require_once CORE_CLASSES_CACHE_PATH . 'CacheInterface.php'; |
|
174 | - $cacheHandler = get_config('cache_handler'); |
|
175 | - if(! $cacheHandler){ |
|
176 | - show_error('The cache feature is enabled in the configuration but the cache handler class is not set.'); |
|
177 | - } |
|
178 | - $CACHE = null; |
|
179 | - //first check if the cache handler is the system driver |
|
180 | - if(file_exists(CORE_CLASSES_CACHE_PATH . $cacheHandler . '.php')){ |
|
181 | - $CACHE =& class_loader($cacheHandler, 'classes/cache'); |
|
182 | - } else{ |
|
183 | - //it's not a system driver use user library |
|
184 | - $CACHE =& class_loader($cacheHandler); |
|
185 | - } |
|
186 | - //check if the page already cached |
|
187 | - if(! empty($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'get'){ |
|
188 | - $RESPONSE = & class_loader('Response', 'classes'); |
|
189 | - if ($RESPONSE->renderFinalPageFromCache($CACHE)){ |
|
190 | - return; |
|
191 | - } |
|
192 | - } |
|
193 | - } |
|
169 | + if(get_config('cache_enable', false)){ |
|
170 | + /** |
|
171 | + * Load Cache interface file |
|
172 | + */ |
|
173 | + require_once CORE_CLASSES_CACHE_PATH . 'CacheInterface.php'; |
|
174 | + $cacheHandler = get_config('cache_handler'); |
|
175 | + if(! $cacheHandler){ |
|
176 | + show_error('The cache feature is enabled in the configuration but the cache handler class is not set.'); |
|
177 | + } |
|
178 | + $CACHE = null; |
|
179 | + //first check if the cache handler is the system driver |
|
180 | + if(file_exists(CORE_CLASSES_CACHE_PATH . $cacheHandler . '.php')){ |
|
181 | + $CACHE =& class_loader($cacheHandler, 'classes/cache'); |
|
182 | + } else{ |
|
183 | + //it's not a system driver use user library |
|
184 | + $CACHE =& class_loader($cacheHandler); |
|
185 | + } |
|
186 | + //check if the page already cached |
|
187 | + if(! empty($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'get'){ |
|
188 | + $RESPONSE = & class_loader('Response', 'classes'); |
|
189 | + if ($RESPONSE->renderFinalPageFromCache($CACHE)){ |
|
190 | + return; |
|
191 | + } |
|
192 | + } |
|
193 | + } |
|
194 | 194 | |
195 | - //load model class |
|
196 | - require_once CORE_CLASSES_MODEL_PATH . 'Model.php'; |
|
195 | + //load model class |
|
196 | + require_once CORE_CLASSES_MODEL_PATH . 'Model.php'; |
|
197 | 197 | |
198 | - $LOGGER->info('Everything is OK load Router library and dispatch the request to the corresponding controller'); |
|
199 | - /** |
|
200 | - * Routing |
|
201 | - * instantiation of the "Router" class and request processing. |
|
202 | - */ |
|
203 | - $ROUTER = & class_loader('Router', 'classes'); |
|
204 | - $ROUTER->processRequest(); |
|
198 | + $LOGGER->info('Everything is OK load Router library and dispatch the request to the corresponding controller'); |
|
199 | + /** |
|
200 | + * Routing |
|
201 | + * instantiation of the "Router" class and request processing. |
|
202 | + */ |
|
203 | + $ROUTER = & class_loader('Router', 'classes'); |
|
204 | + $ROUTER->processRequest(); |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | defined('ROOT_PATH') || exit('Access denied'); |
3 | - /** |
|
4 | - * Form validation language message (English) |
|
5 | - */ |
|
6 | - $lang['fv_required'] = 'Field %1 is required.'; |
|
3 | + /** |
|
4 | + * Form validation language message (English) |
|
5 | + */ |
|
6 | + $lang['fv_required'] = 'Field %1 is required.'; |
|
7 | 7 | $lang['fv_min_length'] = 'Field %1 must contain at least %2 characters.'; |
8 | 8 | $lang['fv_max_length'] = 'Field %1 must contain at most %2 characters.'; |
9 | 9 | $lang['fv_exact_length'] = 'Field %1 must contain exactly %2 characters.'; |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | $lang['fv_not_equal_post_key'] = 'Field %1 must not be the same as field %2.'; |
15 | 15 | $lang['fv_not_equal_string'] = 'Field %1 must not contain the value %2.'; |
16 | 16 | $lang['fv_depends'] = 'Field %1 depends on field %2 which is not valid.'; |
17 | - $lang['fv_is_unique'] = 'The value of field %1 already exists.'; |
|
18 | - $lang['fv_is_unique_update'] = 'The value of field %1 already exists for another record.'; |
|
17 | + $lang['fv_is_unique'] = 'The value of field %1 already exists.'; |
|
18 | + $lang['fv_is_unique_update'] = 'The value of field %1 already exists for another record.'; |
|
19 | 19 | $lang['fv_exists'] = 'The value of the field %1 does not exist.'; |
20 | 20 | $lang['fv_regex'] = 'The value of the field %1 does not use the correct format.'; |
21 | 21 | $lang['fv_in_list'] = 'The value of field %1 must be one of the list (%2).'; |