@@ -1,52 +1,52 @@ |
||
| 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 |
@@ -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 | + } |
|
@@ -1,81 +1,81 @@ |
||
| 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 constants.php |
|
| 29 | - * |
|
| 30 | - * This file contains the declaration of most of the constants used in the system, |
|
| 31 | - * for example: the version, the name of the framework, etc. |
|
| 32 | - * |
|
| 33 | - * @package core |
|
| 34 | - * @author Tony NGUEREZA |
|
| 35 | - * @copyright Copyright (c) 2017 |
|
| 36 | - * @license https://opensource.org/licenses/gpl-3.0.html GNU GPL License (GPL) |
|
| 37 | - * @link http://www.iacademy.cf |
|
| 38 | - * @version 1.0.0 |
|
| 39 | - * @filesource |
|
| 40 | - */ |
|
| 27 | + /** |
|
| 28 | + * @file constants.php |
|
| 29 | + * |
|
| 30 | + * This file contains the declaration of most of the constants used in the system, |
|
| 31 | + * for example: the version, the name of the framework, etc. |
|
| 32 | + * |
|
| 33 | + * @package core |
|
| 34 | + * @author Tony NGUEREZA |
|
| 35 | + * @copyright Copyright (c) 2017 |
|
| 36 | + * @license https://opensource.org/licenses/gpl-3.0.html GNU GPL License (GPL) |
|
| 37 | + * @link http://www.iacademy.cf |
|
| 38 | + * @version 1.0.0 |
|
| 39 | + * @filesource |
|
| 40 | + */ |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * The framework name |
|
| 44 | - */ |
|
| 45 | - define('TNH_NAME', 'TNH Framework'); |
|
| 42 | + /** |
|
| 43 | + * The framework name |
|
| 44 | + */ |
|
| 45 | + define('TNH_NAME', 'TNH Framework'); |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * The version of the framework in X.Y.Z format (Major, minor and bugs). |
|
| 49 | - * If there is the presence of the word "dev", it means that |
|
| 50 | - * it is a version under development. |
|
| 51 | - */ |
|
| 52 | - define('TNH_VERSION', '1.0.0-dev'); |
|
| 47 | + /** |
|
| 48 | + * The version of the framework in X.Y.Z format (Major, minor and bugs). |
|
| 49 | + * If there is the presence of the word "dev", it means that |
|
| 50 | + * it is a version under development. |
|
| 51 | + */ |
|
| 52 | + define('TNH_VERSION', '1.0.0-dev'); |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * The date of publication or release of the framework |
|
| 56 | - */ |
|
| 57 | - define('TNH_RELEASE_DATE', '2017/02/05'); |
|
| 54 | + /** |
|
| 55 | + * The date of publication or release of the framework |
|
| 56 | + */ |
|
| 57 | + define('TNH_RELEASE_DATE', '2017/02/05'); |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * The author of the framework, the person who developed the framework. |
|
| 61 | - */ |
|
| 62 | - define('TNH_AUTHOR', 'Tony NGUEREZA'); |
|
| 59 | + /** |
|
| 60 | + * The author of the framework, the person who developed the framework. |
|
| 61 | + */ |
|
| 62 | + define('TNH_AUTHOR', 'Tony NGUEREZA'); |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Email address of the author of the framework. |
|
| 66 | - */ |
|
| 67 | - define('TNH_AUTHOR_EMAIL', '[email protected]'); |
|
| 64 | + /** |
|
| 65 | + * Email address of the author of the framework. |
|
| 66 | + */ |
|
| 67 | + define('TNH_AUTHOR_EMAIL', '[email protected]'); |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * The minimum PHP version required to use the framework. |
|
| 71 | - * If the version of PHP installed is lower, then the application will not work. |
|
| 72 | - * Note: we use the PHP version_compare function to compare the required version with |
|
| 73 | - * the version installed on your system. |
|
| 74 | - */ |
|
| 75 | - define('TNH_REQUIRED_PHP_MIN_VERSION', '5.4'); |
|
| 69 | + /** |
|
| 70 | + * The minimum PHP version required to use the framework. |
|
| 71 | + * If the version of PHP installed is lower, then the application will not work. |
|
| 72 | + * Note: we use the PHP version_compare function to compare the required version with |
|
| 73 | + * the version installed on your system. |
|
| 74 | + */ |
|
| 75 | + define('TNH_REQUIRED_PHP_MIN_VERSION', '5.4'); |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * The maximum version of PHP required to use the framework. |
|
| 79 | - * If the version of PHP installed is higher than the required one, then the application will not work. |
|
| 80 | - */ |
|
| 81 | - define('TNH_REQUIRED_PHP_MAX_VERSION', '7.1'); |
|
| 82 | 77 | \ No newline at end of file |
| 78 | + /** |
|
| 79 | + * The maximum version of PHP required to use the framework. |
|
| 80 | + * If the version of PHP installed is higher than the required one, then the application will not work. |
|
| 81 | + */ |
|
| 82 | + define('TNH_REQUIRED_PHP_MAX_VERSION', '7.1'); |
|
| 83 | 83 | \ No newline at end of file |
@@ -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).'; |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | defined('ROOT_PATH') || exit('Access denied'); |
| 3 | - /** |
|
| 4 | - * File upload language messages (English) |
|
| 5 | - */ |
|
| 6 | - $lang['fu_upload_err_ini_size'] = 'The uploaded file exceeds the upload_max_filesize directive in php.ini.'; |
|
| 3 | + /** |
|
| 4 | + * File upload language messages (English) |
|
| 5 | + */ |
|
| 6 | + $lang['fu_upload_err_ini_size'] = 'The uploaded file exceeds the upload_max_filesize directive in php.ini.'; |
|
| 7 | 7 | $lang['fu_upload_err_form_size'] = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'; |
| 8 | 8 | $lang['fu_upload_err_partial'] = 'The uploaded file was only partially uploaded.'; |
| 9 | 9 | $lang['fu_upload_err_no_file'] = 'No file was choosed. Please select one.'; |
@@ -1,75 +1,75 @@ |
||
| 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 | 27 | |
| 28 | - /** |
|
| 29 | - * @file function_user_agent.php |
|
| 30 | - * |
|
| 31 | - * Contains most of the utility functions for agent, platform, mobile, browser, and other management. |
|
| 32 | - * |
|
| 33 | - * @package core |
|
| 34 | - * @author Tony NGUEREZA |
|
| 35 | - * @copyright Copyright (c) 2017 |
|
| 36 | - * @license https://opensource.org/licenses/gpl-3.0.html GNU GPL License (GPL) |
|
| 37 | - * @link http://www.iacademy.cf |
|
| 38 | - * @version 1.0.0 |
|
| 39 | - * @since 1.0.0 |
|
| 40 | - * @filesource |
|
| 41 | - */ |
|
| 28 | + /** |
|
| 29 | + * @file function_user_agent.php |
|
| 30 | + * |
|
| 31 | + * Contains most of the utility functions for agent, platform, mobile, browser, and other management. |
|
| 32 | + * |
|
| 33 | + * @package core |
|
| 34 | + * @author Tony NGUEREZA |
|
| 35 | + * @copyright Copyright (c) 2017 |
|
| 36 | + * @license https://opensource.org/licenses/gpl-3.0.html GNU GPL License (GPL) |
|
| 37 | + * @link http://www.iacademy.cf |
|
| 38 | + * @version 1.0.0 |
|
| 39 | + * @since 1.0.0 |
|
| 40 | + * @filesource |
|
| 41 | + */ |
|
| 42 | 42 | |
| 43 | 43 | |
| 44 | - if(! function_exists('get_ip')){ |
|
| 45 | - /** |
|
| 46 | - * Retrieves the user's IP address |
|
| 47 | - * |
|
| 48 | - * This function allows to retrieve the IP address of the client |
|
| 49 | - * even if it uses a proxy, the actual IP address is retrieved. |
|
| 50 | - * |
|
| 51 | - * @return string the IP address. |
|
| 52 | - */ |
|
| 53 | - function get_ip(){ |
|
| 54 | - $ip = '127.0.0.1'; |
|
| 55 | - $ipServerVars = array( |
|
| 56 | - 'REMOTE_ADDR', |
|
| 57 | - 'HTTP_CLIENT_IP', |
|
| 58 | - 'HTTP_X_FORWARDED_FOR', |
|
| 59 | - 'HTTP_X_FORWARDED', |
|
| 60 | - 'HTTP_FORWARDED_FOR', |
|
| 61 | - 'HTTP_FORWARDED' |
|
| 62 | - ); |
|
| 63 | - foreach ($ipServerVars as $var) { |
|
| 64 | - if(isset($_SERVER[$var])){ |
|
| 65 | - $ip = $_SERVER[$var]; |
|
| 66 | - break; |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - // Strip any secondary IP etc from the IP address |
|
| 70 | - if (strpos($ip, ',') > 0) { |
|
| 71 | - $ip = substr($ip, 0, strpos($ip, ',')); |
|
| 72 | - } |
|
| 73 | - return $ip; |
|
| 74 | - } |
|
| 75 | - } |
|
| 44 | + if(! function_exists('get_ip')){ |
|
| 45 | + /** |
|
| 46 | + * Retrieves the user's IP address |
|
| 47 | + * |
|
| 48 | + * This function allows to retrieve the IP address of the client |
|
| 49 | + * even if it uses a proxy, the actual IP address is retrieved. |
|
| 50 | + * |
|
| 51 | + * @return string the IP address. |
|
| 52 | + */ |
|
| 53 | + function get_ip(){ |
|
| 54 | + $ip = '127.0.0.1'; |
|
| 55 | + $ipServerVars = array( |
|
| 56 | + 'REMOTE_ADDR', |
|
| 57 | + 'HTTP_CLIENT_IP', |
|
| 58 | + 'HTTP_X_FORWARDED_FOR', |
|
| 59 | + 'HTTP_X_FORWARDED', |
|
| 60 | + 'HTTP_FORWARDED_FOR', |
|
| 61 | + 'HTTP_FORWARDED' |
|
| 62 | + ); |
|
| 63 | + foreach ($ipServerVars as $var) { |
|
| 64 | + if(isset($_SERVER[$var])){ |
|
| 65 | + $ip = $_SERVER[$var]; |
|
| 66 | + break; |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + // Strip any secondary IP etc from the IP address |
|
| 70 | + if (strpos($ip, ',') > 0) { |
|
| 71 | + $ip = substr($ip, 0, strpos($ip, ',')); |
|
| 72 | + } |
|
| 73 | + return $ip; |
|
| 74 | + } |
|
| 75 | + } |
|
@@ -1,149 +1,149 @@ |
||
| 1 | 1 | <?php |
| 2 | - defined('ROOT_PATH') or exit('Access denied'); |
|
| 3 | - /** |
|
| 4 | - * TNH Framework |
|
| 5 | - * |
|
| 6 | - * A simple PHP framework using HMVC architecture |
|
| 7 | - * |
|
| 8 | - * This content is released under the GNU GPL License (GPL) |
|
| 9 | - * |
|
| 10 | - * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | - * |
|
| 12 | - * This program is free software; you can redistribute it and/or |
|
| 13 | - * modify it under the terms of the GNU General Public License |
|
| 14 | - * as published by the Free Software Foundation; either version 3 |
|
| 15 | - * of the License, or (at your option) any later version. |
|
| 16 | - * |
|
| 17 | - * This program is distributed in the hope that it will be useful, |
|
| 18 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | - * GNU General Public License for more details. |
|
| 21 | - * |
|
| 22 | - * You should have received a copy of the GNU General Public License |
|
| 23 | - * along with this program; if not, write to the Free Software |
|
| 24 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | - */ |
|
| 2 | + defined('ROOT_PATH') or exit('Access denied'); |
|
| 3 | + /** |
|
| 4 | + * TNH Framework |
|
| 5 | + * |
|
| 6 | + * A simple PHP framework using HMVC architecture |
|
| 7 | + * |
|
| 8 | + * This content is released under the GNU GPL License (GPL) |
|
| 9 | + * |
|
| 10 | + * Copyright (C) 2017 Tony NGUEREZA |
|
| 11 | + * |
|
| 12 | + * This program is free software; you can redistribute it and/or |
|
| 13 | + * modify it under the terms of the GNU General Public License |
|
| 14 | + * as published by the Free Software Foundation; either version 3 |
|
| 15 | + * of the License, or (at your option) any later version. |
|
| 16 | + * |
|
| 17 | + * This program is distributed in the hope that it will be useful, |
|
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 20 | + * GNU General Public License for more details. |
|
| 21 | + * |
|
| 22 | + * You should have received a copy of the GNU General Public License |
|
| 23 | + * along with this program; if not, write to the Free Software |
|
| 24 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
| 25 | + */ |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | - class Url{ |
|
| 28 | + class Url{ |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Return the link using base_url config without front controller "index.php" |
|
| 32 | - * @param string $path the link path or full URL |
|
| 33 | - * @return string the full link URL |
|
| 34 | - */ |
|
| 35 | - public static function base_url($path = ''){ |
|
| 36 | - if(is_url($path)){ |
|
| 37 | - return $path; |
|
| 38 | - } |
|
| 39 | - return get_config('base_url') . $path; |
|
| 40 | - } |
|
| 30 | + /** |
|
| 31 | + * Return the link using base_url config without front controller "index.php" |
|
| 32 | + * @param string $path the link path or full URL |
|
| 33 | + * @return string the full link URL |
|
| 34 | + */ |
|
| 35 | + public static function base_url($path = ''){ |
|
| 36 | + if(is_url($path)){ |
|
| 37 | + return $path; |
|
| 38 | + } |
|
| 39 | + return get_config('base_url') . $path; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Return the link using base_url config with front controller "index.php" |
|
| 44 | - * @param string $path the link path or full URL |
|
| 45 | - * @return string the full link URL |
|
| 46 | - */ |
|
| 47 | - public static function site_url($path = ''){ |
|
| 48 | - if(is_url($path)){ |
|
| 49 | - return $path; |
|
| 50 | - } |
|
| 51 | - $path = rtrim($path, '/'); |
|
| 52 | - $baseUrl = get_config('base_url'); |
|
| 53 | - $frontController = get_config('front_controller'); |
|
| 54 | - $url = $baseUrl; |
|
| 55 | - if($frontController){ |
|
| 56 | - $url .= $frontController . '/'; |
|
| 57 | - } |
|
| 58 | - if(($suffix = get_config('url_suffix')) && $path){ |
|
| 59 | - if(strpos($path, '?') !== false){ |
|
| 60 | - $query = explode('?', $path); |
|
| 61 | - $query[0] = str_ireplace($suffix, '', $query[0]); |
|
| 62 | - $query[0] = rtrim($query[0], '/'); |
|
| 63 | - $query[0] .= $suffix; |
|
| 64 | - $path = implode('?', $query); |
|
| 65 | - } |
|
| 66 | - else{ |
|
| 67 | - $path .= $suffix; |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - return $url . $path; |
|
| 71 | - } |
|
| 42 | + /** |
|
| 43 | + * Return the link using base_url config with front controller "index.php" |
|
| 44 | + * @param string $path the link path or full URL |
|
| 45 | + * @return string the full link URL |
|
| 46 | + */ |
|
| 47 | + public static function site_url($path = ''){ |
|
| 48 | + if(is_url($path)){ |
|
| 49 | + return $path; |
|
| 50 | + } |
|
| 51 | + $path = rtrim($path, '/'); |
|
| 52 | + $baseUrl = get_config('base_url'); |
|
| 53 | + $frontController = get_config('front_controller'); |
|
| 54 | + $url = $baseUrl; |
|
| 55 | + if($frontController){ |
|
| 56 | + $url .= $frontController . '/'; |
|
| 57 | + } |
|
| 58 | + if(($suffix = get_config('url_suffix')) && $path){ |
|
| 59 | + if(strpos($path, '?') !== false){ |
|
| 60 | + $query = explode('?', $path); |
|
| 61 | + $query[0] = str_ireplace($suffix, '', $query[0]); |
|
| 62 | + $query[0] = rtrim($query[0], '/'); |
|
| 63 | + $query[0] .= $suffix; |
|
| 64 | + $path = implode('?', $query); |
|
| 65 | + } |
|
| 66 | + else{ |
|
| 67 | + $path .= $suffix; |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + return $url . $path; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Return the current site URL |
|
| 75 | - * @return string |
|
| 76 | - */ |
|
| 77 | - public static function current(){ |
|
| 78 | - $current = '/'; |
|
| 79 | - $requestUri = get_instance()->request->requestUri(); |
|
| 80 | - if($requestUri){ |
|
| 81 | - $current = $requestUri; |
|
| 82 | - } |
|
| 83 | - return static::domain() . $current; |
|
| 84 | - } |
|
| 73 | + /** |
|
| 74 | + * Return the current site URL |
|
| 75 | + * @return string |
|
| 76 | + */ |
|
| 77 | + public static function current(){ |
|
| 78 | + $current = '/'; |
|
| 79 | + $requestUri = get_instance()->request->requestUri(); |
|
| 80 | + if($requestUri){ |
|
| 81 | + $current = $requestUri; |
|
| 82 | + } |
|
| 83 | + return static::domain() . $current; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Generate a friendly text to use in link (slugs) |
|
| 88 | - * @param string $str the title or text to use to get the friendly text |
|
| 89 | - * @param string $separator the caracters separator |
|
| 90 | - * @param boolean $lowercase whether to set the final text to lowe case or not |
|
| 91 | - * @return string the friendly generated text |
|
| 92 | - */ |
|
| 93 | - public static function title($str = null, $separator = '-', $lowercase = true){ |
|
| 94 | - $str = trim($str); |
|
| 95 | - $from = array('ç','À','Á','Â','Ã','Ä','Å','à','á','â','ã','ä','å','Ò','Ó','Ô','Õ','Ö','Ø','ò','ó','ô','õ','ö','ø','È','É','Ê','Ë','è','é','ê','ë','Ç','ç','Ì','Í','Î','Ï','ì','í','î','ï','Ù','Ú','Û','Ü','ù','ú','û','ü','ÿ','Ñ','ñ'); |
|
| 96 | - $to = array('c','a','a','a','a','a','a','a','a','a','a','a','a','o','o','o','o','o','o','o','o','o','o','o','o','e','e','e','e','e','e','e','e','e','e','i','i','i','i','i','i','i','i','u','u','u','u','u','u','u','u','y','n','n'); |
|
| 97 | - $str = str_replace($from, $to, $str); |
|
| 98 | - $str = preg_replace('#([^a-z0-9]+)#i', $separator, $str); |
|
| 99 | - $str = str_replace('--', $separator, $str); |
|
| 100 | - //if after process we get something like one-two-three-, need truncate the last separator "-" |
|
| 101 | - if(substr($str, -1) == $separator){ |
|
| 102 | - $str = substr($str, 0, -1); |
|
| 103 | - } |
|
| 104 | - if($lowercase){ |
|
| 105 | - $str = strtolower($str); |
|
| 106 | - } |
|
| 107 | - return $str; |
|
| 108 | - } |
|
| 86 | + /** |
|
| 87 | + * Generate a friendly text to use in link (slugs) |
|
| 88 | + * @param string $str the title or text to use to get the friendly text |
|
| 89 | + * @param string $separator the caracters separator |
|
| 90 | + * @param boolean $lowercase whether to set the final text to lowe case or not |
|
| 91 | + * @return string the friendly generated text |
|
| 92 | + */ |
|
| 93 | + public static function title($str = null, $separator = '-', $lowercase = true){ |
|
| 94 | + $str = trim($str); |
|
| 95 | + $from = array('ç','À','Á','Â','Ã','Ä','Å','à','á','â','ã','ä','å','Ò','Ó','Ô','Õ','Ö','Ø','ò','ó','ô','õ','ö','ø','È','É','Ê','Ë','è','é','ê','ë','Ç','ç','Ì','Í','Î','Ï','ì','í','î','ï','Ù','Ú','Û','Ü','ù','ú','û','ü','ÿ','Ñ','ñ'); |
|
| 96 | + $to = array('c','a','a','a','a','a','a','a','a','a','a','a','a','o','o','o','o','o','o','o','o','o','o','o','o','e','e','e','e','e','e','e','e','e','e','i','i','i','i','i','i','i','i','u','u','u','u','u','u','u','u','y','n','n'); |
|
| 97 | + $str = str_replace($from, $to, $str); |
|
| 98 | + $str = preg_replace('#([^a-z0-9]+)#i', $separator, $str); |
|
| 99 | + $str = str_replace('--', $separator, $str); |
|
| 100 | + //if after process we get something like one-two-three-, need truncate the last separator "-" |
|
| 101 | + if(substr($str, -1) == $separator){ |
|
| 102 | + $str = substr($str, 0, -1); |
|
| 103 | + } |
|
| 104 | + if($lowercase){ |
|
| 105 | + $str = strtolower($str); |
|
| 106 | + } |
|
| 107 | + return $str; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * Get the current application domain with protocol |
|
| 112 | - * @return string the domain name |
|
| 113 | - */ |
|
| 114 | - public static function domain(){ |
|
| 115 | - $domain = 'localhost'; |
|
| 116 | - $port = get_instance()->request->server('SERVER_PORT'); |
|
| 117 | - $protocol = 'http'; |
|
| 118 | - if(is_https()){ |
|
| 119 | - $protocol = 'https'; |
|
| 120 | - } |
|
| 110 | + /** |
|
| 111 | + * Get the current application domain with protocol |
|
| 112 | + * @return string the domain name |
|
| 113 | + */ |
|
| 114 | + public static function domain(){ |
|
| 115 | + $domain = 'localhost'; |
|
| 116 | + $port = get_instance()->request->server('SERVER_PORT'); |
|
| 117 | + $protocol = 'http'; |
|
| 118 | + if(is_https()){ |
|
| 119 | + $protocol = 'https'; |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - $domainserverVars = array( |
|
| 123 | - 'HTTP_HOST', |
|
| 124 | - 'SERVER_NAME', |
|
| 125 | - 'SERVER_ADDR' |
|
| 126 | - ); |
|
| 122 | + $domainserverVars = array( |
|
| 123 | + 'HTTP_HOST', |
|
| 124 | + 'SERVER_NAME', |
|
| 125 | + 'SERVER_ADDR' |
|
| 126 | + ); |
|
| 127 | 127 | |
| 128 | - foreach ($domainserverVars as $var) { |
|
| 129 | - $value = get_instance()->request->server($var); |
|
| 130 | - if($value){ |
|
| 131 | - $domain = $value; |
|
| 132 | - break; |
|
| 133 | - } |
|
| 134 | - } |
|
| 128 | + foreach ($domainserverVars as $var) { |
|
| 129 | + $value = get_instance()->request->server($var); |
|
| 130 | + if($value){ |
|
| 131 | + $domain = $value; |
|
| 132 | + break; |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - if($port && ((is_https() && $port != 443) || (!is_https() && $port != 80))){ |
|
| 137 | - $domain .= ':'.$port; |
|
| 138 | - } |
|
| 139 | - return $protocol.'://'.$domain; |
|
| 140 | - } |
|
| 136 | + if($port && ((is_https() && $port != 443) || (!is_https() && $port != 80))){ |
|
| 137 | + $domain .= ':'.$port; |
|
| 138 | + } |
|
| 139 | + return $protocol.'://'.$domain; |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * Get the current request query string |
|
| 144 | - * @return string |
|
| 145 | - */ |
|
| 146 | - public static function queryString(){ |
|
| 147 | - return get_instance()->request->server('QUERY_STRING'); |
|
| 148 | - } |
|
| 149 | - } |
|
| 142 | + /** |
|
| 143 | + * Get the current request query string |
|
| 144 | + * @return string |
|
| 145 | + */ |
|
| 146 | + public static function queryString(){ |
|
| 147 | + return get_instance()->request->server('QUERY_STRING'); |
|
| 148 | + } |
|
| 149 | + } |
|
@@ -1669,34 +1669,34 @@ |
||
| 1669 | 1669 | protected function checkPlatform() |
| 1670 | 1670 | { |
| 1671 | 1671 | $platformMaps = array( |
| 1672 | - 'windows' => self::PLATFORM_WINDOWS, |
|
| 1673 | - 'iPad' => self::PLATFORM_IPAD, |
|
| 1674 | - 'iPod' => self::PLATFORM_IPOD, |
|
| 1675 | - 'iPhone' => self::PLATFORM_IPHONE, |
|
| 1676 | - 'mac' => self::PLATFORM_APPLE, |
|
| 1677 | - 'android' => self::PLATFORM_ANDROID, |
|
| 1678 | - 'Silk' => self::PLATFORM_FIRE_OS, |
|
| 1679 | - 'linux_smarttv' => self::PLATFORM_LINUX .'/'.self::PLATFORM_SMART_TV, |
|
| 1680 | - 'linux' => self::PLATFORM_LINUX, |
|
| 1681 | - 'Nokia' => self::PLATFORM_NOKIA, |
|
| 1682 | - 'BlackBerry' => self::PLATFORM_BLACKBERRY, |
|
| 1683 | - 'FreeBSD' => self::PLATFORM_FREEBSD, |
|
| 1684 | - 'OpenBSD' => self::PLATFORM_OPENBSD, |
|
| 1685 | - 'NetBSD' => self::PLATFORM_NETBSD, |
|
| 1686 | - 'OpenSolaris' => self::PLATFORM_OPENSOLARIS, |
|
| 1687 | - 'SunOS' => self::PLATFORM_SUNOS, |
|
| 1688 | - 'OS\/2' => self::PLATFORM_OS2, |
|
| 1689 | - 'BeOS' => self::PLATFORM_BEOS, |
|
| 1690 | - 'win' => self::PLATFORM_WINDOWS, |
|
| 1691 | - 'Playstation' => self::PLATFORM_PLAYSTATION, |
|
| 1692 | - 'Roku' => self::PLATFORM_ROKU, |
|
| 1693 | - 'iOS' => self::PLATFORM_IPHONE . '/' . self::PLATFORM_IPAD, |
|
| 1694 | - 'tvOS' => self::PLATFORM_APPLE_TV, |
|
| 1695 | - 'curl' => self::PLATFORM_TERMINAL, |
|
| 1696 | - 'CrOS' => self::PLATFORM_CHROME_OS, |
|
| 1697 | - 'okhttp' => self::PLATFORM_JAVA_ANDROID, |
|
| 1698 | - 'PostmanRuntime' => self::PLATFORM_POSTMAN, |
|
| 1699 | - 'Iframely' => self::PLATFORM_I_FRAME |
|
| 1672 | + 'windows' => self::PLATFORM_WINDOWS, |
|
| 1673 | + 'iPad' => self::PLATFORM_IPAD, |
|
| 1674 | + 'iPod' => self::PLATFORM_IPOD, |
|
| 1675 | + 'iPhone' => self::PLATFORM_IPHONE, |
|
| 1676 | + 'mac' => self::PLATFORM_APPLE, |
|
| 1677 | + 'android' => self::PLATFORM_ANDROID, |
|
| 1678 | + 'Silk' => self::PLATFORM_FIRE_OS, |
|
| 1679 | + 'linux_smarttv' => self::PLATFORM_LINUX .'/'.self::PLATFORM_SMART_TV, |
|
| 1680 | + 'linux' => self::PLATFORM_LINUX, |
|
| 1681 | + 'Nokia' => self::PLATFORM_NOKIA, |
|
| 1682 | + 'BlackBerry' => self::PLATFORM_BLACKBERRY, |
|
| 1683 | + 'FreeBSD' => self::PLATFORM_FREEBSD, |
|
| 1684 | + 'OpenBSD' => self::PLATFORM_OPENBSD, |
|
| 1685 | + 'NetBSD' => self::PLATFORM_NETBSD, |
|
| 1686 | + 'OpenSolaris' => self::PLATFORM_OPENSOLARIS, |
|
| 1687 | + 'SunOS' => self::PLATFORM_SUNOS, |
|
| 1688 | + 'OS\/2' => self::PLATFORM_OS2, |
|
| 1689 | + 'BeOS' => self::PLATFORM_BEOS, |
|
| 1690 | + 'win' => self::PLATFORM_WINDOWS, |
|
| 1691 | + 'Playstation' => self::PLATFORM_PLAYSTATION, |
|
| 1692 | + 'Roku' => self::PLATFORM_ROKU, |
|
| 1693 | + 'iOS' => self::PLATFORM_IPHONE . '/' . self::PLATFORM_IPAD, |
|
| 1694 | + 'tvOS' => self::PLATFORM_APPLE_TV, |
|
| 1695 | + 'curl' => self::PLATFORM_TERMINAL, |
|
| 1696 | + 'CrOS' => self::PLATFORM_CHROME_OS, |
|
| 1697 | + 'okhttp' => self::PLATFORM_JAVA_ANDROID, |
|
| 1698 | + 'PostmanRuntime' => self::PLATFORM_POSTMAN, |
|
| 1699 | + 'Iframely' => self::PLATFORM_I_FRAME |
|
| 1700 | 1700 | ); |
| 1701 | 1701 | |
| 1702 | 1702 | foreach ($platformMaps as $name => $value) { |