@@ -1,25 +1,25 @@ |
||
| 1 | 1 | <?php |
| 2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
| 2 | + defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | 3 | |
| 4 | - /** |
|
| 5 | - * |
|
| 6 | - */ |
|
| 7 | - class Home extends Controller { |
|
| 4 | + /** |
|
| 5 | + * |
|
| 6 | + */ |
|
| 7 | + class Home extends Controller { |
|
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * the class constructor |
|
| 11 | - */ |
|
| 12 | - public function __construct() { |
|
| 13 | - parent::__construct(); |
|
| 14 | - } |
|
| 9 | + /** |
|
| 10 | + * the class constructor |
|
| 11 | + */ |
|
| 12 | + public function __construct() { |
|
| 13 | + parent::__construct(); |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * The default method |
|
| 18 | - * @return null |
|
| 19 | - */ |
|
| 20 | - public function index() { |
|
| 21 | - Loader::library('Assets'); |
|
| 22 | - Loader::library('Html'); |
|
| 23 | - $this->response->render('home'); |
|
| 24 | - } |
|
| 25 | - } |
|
| 16 | + /** |
|
| 17 | + * The default method |
|
| 18 | + * @return null |
|
| 19 | + */ |
|
| 20 | + public function index() { |
|
| 21 | + Loader::library('Assets'); |
|
| 22 | + Loader::library('Html'); |
|
| 23 | + $this->response->render('home'); |
|
| 24 | + } |
|
| 25 | + } |
|
@@ -1,94 +1,94 @@ |
||
| 1 | 1 | <?php |
| 2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | - /** |
|
| 4 | - * TNH Framework |
|
| 5 | - * |
|
| 6 | - * A simple PHP framework created using the concept of codeigniter with bootstrap twitter |
|
| 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 created using the concept of codeigniter with bootstrap twitter |
|
| 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 | - * This file contains the configuration of resources that you want to load automatically: |
|
| 29 | - * personal or system libraries, configuration files, models, |
|
| 30 | - * personal functions or systems that are used most often in your application |
|
| 31 | - * instead of loading them every time you want to use it. |
|
| 32 | - * Note: loading a lot of resources can decrease the performance of your application. |
|
| 33 | - */ |
|
| 27 | + /** |
|
| 28 | + * This file contains the configuration of resources that you want to load automatically: |
|
| 29 | + * personal or system libraries, configuration files, models, |
|
| 30 | + * personal functions or systems that are used most often in your application |
|
| 31 | + * instead of loading them every time you want to use it. |
|
| 32 | + * Note: loading a lot of resources can decrease the performance of your application. |
|
| 33 | + */ |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * If you have personal libraries or systems to load automatically, then list them in the following array. |
|
| 38 | - * For example : |
|
| 39 | - * |
|
| 40 | - * $autoload['libraries'] = array('library1', 'library1'); |
|
| 41 | - * |
|
| 42 | - * Note: Personal libraries have priority over system libraries, |
|
| 43 | - * ie the loading order is as follows: it looks in the folder of the personal libraries, |
|
| 44 | - * if it is found, it is loaded, if not , we search in the system libraries folder, |
|
| 45 | - * before returning an error in case it does not find it. |
|
| 46 | - */ |
|
| 47 | - $autoload['libraries'] = array(); |
|
| 36 | + /** |
|
| 37 | + * If you have personal libraries or systems to load automatically, then list them in the following array. |
|
| 38 | + * For example : |
|
| 39 | + * |
|
| 40 | + * $autoload['libraries'] = array('library1', 'library1'); |
|
| 41 | + * |
|
| 42 | + * Note: Personal libraries have priority over system libraries, |
|
| 43 | + * ie the loading order is as follows: it looks in the folder of the personal libraries, |
|
| 44 | + * if it is found, it is loaded, if not , we search in the system libraries folder, |
|
| 45 | + * before returning an error in case it does not find it. |
|
| 46 | + */ |
|
| 47 | + $autoload['libraries'] = array(); |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * If you have configuration files to load automatically, then list them in the following array. |
|
| 51 | - * For example : |
|
| 52 | - * |
|
| 53 | - * $autoload['config'] = array('config1', 'config2'); |
|
| 54 | - * |
|
| 55 | - * Note 1: the file name must have as prefix "config_" |
|
| 56 | - * for example "config_name_of_the_file_config.php" and contains as configuration variable the array $config, |
|
| 57 | - * otherwise the system can not find this configuration file. |
|
| 58 | - * For example : |
|
| 59 | - * |
|
| 60 | - * $config['key1'] = value1; |
|
| 61 | - * $config['key2'] = value2; |
|
| 62 | - * |
|
| 63 | - * Note 2: the files to be loaded must be in the folder defined by the constant "CONFIG_PATH" in "index.php". |
|
| 64 | - */ |
|
| 65 | - $autoload['config'] = array(); |
|
| 49 | + /** |
|
| 50 | + * If you have configuration files to load automatically, then list them in the following array. |
|
| 51 | + * For example : |
|
| 52 | + * |
|
| 53 | + * $autoload['config'] = array('config1', 'config2'); |
|
| 54 | + * |
|
| 55 | + * Note 1: the file name must have as prefix "config_" |
|
| 56 | + * for example "config_name_of_the_file_config.php" and contains as configuration variable the array $config, |
|
| 57 | + * otherwise the system can not find this configuration file. |
|
| 58 | + * For example : |
|
| 59 | + * |
|
| 60 | + * $config['key1'] = value1; |
|
| 61 | + * $config['key2'] = value2; |
|
| 62 | + * |
|
| 63 | + * Note 2: the files to be loaded must be in the folder defined by the constant "CONFIG_PATH" in "index.php". |
|
| 64 | + */ |
|
| 65 | + $autoload['config'] = array(); |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * If you have models to load automatically, then list them in the following table. |
|
| 69 | - * For example : |
|
| 70 | - * |
|
| 71 | - * $autoload['models'] = array('model1', 'model2'); |
|
| 72 | - */ |
|
| 73 | - $autoload['models'] = array(); |
|
| 67 | + /** |
|
| 68 | + * If you have models to load automatically, then list them in the following table. |
|
| 69 | + * For example : |
|
| 70 | + * |
|
| 71 | + * $autoload['models'] = array('model1', 'model2'); |
|
| 72 | + */ |
|
| 73 | + $autoload['models'] = array(); |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * If you have system or personal functions to load automatically, specify them in the following array. |
|
| 77 | - * For example : |
|
| 78 | - * |
|
| 79 | - * $autoload['functions'] = array('function1', 'function2'); |
|
| 80 | - * |
|
| 81 | - * Note: Personal functions have priority over system functions, |
|
| 82 | - * that is to say that the order of loading is the following : it looks in the directory of the personal functions, |
|
| 83 | - * if it is found, it is loaded, otherwise, it looks in the directory of the system functions, |
|
| 84 | - * before returning an error in case he does not find it. |
|
| 85 | - */ |
|
| 86 | - $autoload['functions'] = array(); |
|
| 75 | + /** |
|
| 76 | + * If you have system or personal functions to load automatically, specify them in the following array. |
|
| 77 | + * For example : |
|
| 78 | + * |
|
| 79 | + * $autoload['functions'] = array('function1', 'function2'); |
|
| 80 | + * |
|
| 81 | + * Note: Personal functions have priority over system functions, |
|
| 82 | + * that is to say that the order of loading is the following : it looks in the directory of the personal functions, |
|
| 83 | + * if it is found, it is loaded, otherwise, it looks in the directory of the system functions, |
|
| 84 | + * before returning an error in case he does not find it. |
|
| 85 | + */ |
|
| 86 | + $autoload['functions'] = array(); |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * If you have system or personal language to load automatically, specify them in the following array. |
|
| 90 | - * For example : |
|
| 91 | - * |
|
| 92 | - * $autoload['languages'] = array('lang1', 'lang2'); |
|
| 93 | - */ |
|
| 94 | - $autoload['languages'] = array(); |
|
| 88 | + /** |
|
| 89 | + * If you have system or personal language to load automatically, specify them in the following array. |
|
| 90 | + * For example : |
|
| 91 | + * |
|
| 92 | + * $autoload['languages'] = array('lang1', 'lang2'); |
|
| 93 | + */ |
|
| 94 | + $autoload['languages'] = array(); |
|
@@ -1,127 +1,127 @@ |
||
| 1 | 1 | <?php |
| 2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | - /** |
|
| 4 | - * TNH Framework |
|
| 5 | - * |
|
| 6 | - * A simple PHP framework created using the concept of codeigniter with bootstrap twitter |
|
| 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 created using the concept of codeigniter with bootstrap twitter |
|
| 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 | - * This file contains the connection information to your database, this file is read when you load the "Database" library. |
|
| 29 | - * You will find all its configuration parameters at your web hosting. |
|
| 30 | - */ |
|
| 27 | + /** |
|
| 28 | + * This file contains the connection information to your database, this file is read when you load the "Database" library. |
|
| 29 | + * You will find all its configuration parameters at your web hosting. |
|
| 30 | + */ |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * The type or driver of your database. |
|
| 34 | - * |
|
| 35 | - * Note: the "Database" library uses the PHP PDO extension to interact with your database, |
|
| 36 | - * so most of the PDO supported drivers namely: mysql, pgsql, sqlite, oracle are accepted. |
|
| 37 | - * For example : |
|
| 38 | - * |
|
| 39 | - * $db['driver'] = 'mysql'; // for MySQL Database |
|
| 40 | - * or |
|
| 41 | - * $db['driver'] = 'pgsql'; // for PostgreSQL Database |
|
| 42 | - * or |
|
| 43 | - * $db['driver'] = 'sqlite'; // for SQLite Database |
|
| 44 | - * or |
|
| 45 | - * $db['driver'] = 'oracle'; // for Oracle Database |
|
| 46 | - * |
|
| 47 | - */ |
|
| 48 | - $db['driver'] = 'mysql'; |
|
| 32 | + /** |
|
| 33 | + * The type or driver of your database. |
|
| 34 | + * |
|
| 35 | + * Note: the "Database" library uses the PHP PDO extension to interact with your database, |
|
| 36 | + * so most of the PDO supported drivers namely: mysql, pgsql, sqlite, oracle are accepted. |
|
| 37 | + * For example : |
|
| 38 | + * |
|
| 39 | + * $db['driver'] = 'mysql'; // for MySQL Database |
|
| 40 | + * or |
|
| 41 | + * $db['driver'] = 'pgsql'; // for PostgreSQL Database |
|
| 42 | + * or |
|
| 43 | + * $db['driver'] = 'sqlite'; // for SQLite Database |
|
| 44 | + * or |
|
| 45 | + * $db['driver'] = 'oracle'; // for Oracle Database |
|
| 46 | + * |
|
| 47 | + */ |
|
| 48 | + $db['driver'] = 'mysql'; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * The address of your database server |
|
| 52 | - * |
|
| 53 | - * It can be a domain name or IP address, for example: |
|
| 54 | - * $db['hostname'] = 'localhost'; |
|
| 55 | - * or |
|
| 56 | - * $db['hostname'] = 'mysql.host.com'; |
|
| 57 | - * or |
|
| 58 | - * $db['hostname'] = '187.15.14.17'; |
|
| 59 | - * * or if port is not a standart port |
|
| 60 | - * $db['hostname'] = 'mydb.server.com:6356'; |
|
| 61 | - */ |
|
| 62 | - $db['hostname'] = 'localhost'; |
|
| 50 | + /** |
|
| 51 | + * The address of your database server |
|
| 52 | + * |
|
| 53 | + * It can be a domain name or IP address, for example: |
|
| 54 | + * $db['hostname'] = 'localhost'; |
|
| 55 | + * or |
|
| 56 | + * $db['hostname'] = 'mysql.host.com'; |
|
| 57 | + * or |
|
| 58 | + * $db['hostname'] = '187.15.14.17'; |
|
| 59 | + * * or if port is not a standart port |
|
| 60 | + * $db['hostname'] = 'mydb.server.com:6356'; |
|
| 61 | + */ |
|
| 62 | + $db['hostname'] = 'localhost'; |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * The username of your database server |
|
| 66 | - * for example : |
|
| 67 | - * |
|
| 68 | - * $db['username'] = 'root'; |
|
| 69 | - * or |
|
| 70 | - * $db['username'] = 'myusername'; |
|
| 71 | - */ |
|
| 72 | - $db['username'] = 'root'; |
|
| 64 | + /** |
|
| 65 | + * The username of your database server |
|
| 66 | + * for example : |
|
| 67 | + * |
|
| 68 | + * $db['username'] = 'root'; |
|
| 69 | + * or |
|
| 70 | + * $db['username'] = 'myusername'; |
|
| 71 | + */ |
|
| 72 | + $db['username'] = 'root'; |
|
| 73 | 73 | |
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * The password of your database server. |
|
| 77 | - * |
|
| 78 | - * Note: Some configuration settings on some database management systems do not allow |
|
| 79 | - * connection with a user without password, so it is recommended to set a password for this user for a security measure. |
|
| 80 | - * for example : |
|
| 81 | - * |
|
| 82 | - * $db['password'] = ''; //for an empty password, this is the case most often, if you are in local, ie for the user "root". |
|
| 83 | - * or |
|
| 84 | - * $db['password'] = 'M@5CUR3P@$$W0rd'; |
|
| 85 | - */ |
|
| 86 | - $db['password'] = ''; |
|
| 75 | + /** |
|
| 76 | + * The password of your database server. |
|
| 77 | + * |
|
| 78 | + * Note: Some configuration settings on some database management systems do not allow |
|
| 79 | + * connection with a user without password, so it is recommended to set a password for this user for a security measure. |
|
| 80 | + * for example : |
|
| 81 | + * |
|
| 82 | + * $db['password'] = ''; //for an empty password, this is the case most often, if you are in local, ie for the user "root". |
|
| 83 | + * or |
|
| 84 | + * $db['password'] = 'M@5CUR3P@$$W0rd'; |
|
| 85 | + */ |
|
| 86 | + $db['password'] = ''; |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * The name of your database |
|
| 90 | - * |
|
| 91 | - * for example : |
|
| 92 | - * |
|
| 93 | - * $db['database'] = 'database_name'; |
|
| 94 | - */ |
|
| 95 | - $db['database'] = ''; |
|
| 88 | + /** |
|
| 89 | + * The name of your database |
|
| 90 | + * |
|
| 91 | + * for example : |
|
| 92 | + * |
|
| 93 | + * $db['database'] = 'database_name'; |
|
| 94 | + */ |
|
| 95 | + $db['database'] = ''; |
|
| 96 | 96 | |
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * The character set that will be used by the database server. |
|
| 100 | - * for example : |
|
| 101 | - * |
|
| 102 | - * $db['charset'] = 'utf8'; |
|
| 103 | - */ |
|
| 104 | - $db['charset'] = 'utf8'; |
|
| 98 | + /** |
|
| 99 | + * The character set that will be used by the database server. |
|
| 100 | + * for example : |
|
| 101 | + * |
|
| 102 | + * $db['charset'] = 'utf8'; |
|
| 103 | + */ |
|
| 104 | + $db['charset'] = 'utf8'; |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * In addition to the character set, a certain database management system allows you to |
|
| 108 | - * choose how the data will be classified (ORDER BY) by what is called a "COLLATE". |
|
| 109 | - * This makes it possible, for example, to answer the classic problem of case sensitivity. |
|
| 110 | - * for example : |
|
| 111 | - * $db['collation'] = 'utf8_general_ci'; |
|
| 112 | - */ |
|
| 113 | - $db['collation'] = 'utf8_general_ci'; |
|
| 106 | + /** |
|
| 107 | + * In addition to the character set, a certain database management system allows you to |
|
| 108 | + * choose how the data will be classified (ORDER BY) by what is called a "COLLATE". |
|
| 109 | + * This makes it possible, for example, to answer the classic problem of case sensitivity. |
|
| 110 | + * for example : |
|
| 111 | + * $db['collation'] = 'utf8_general_ci'; |
|
| 112 | + */ |
|
| 113 | + $db['collation'] = 'utf8_general_ci'; |
|
| 114 | 114 | |
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * If your tables in your database contain prefixes, this is the case most on some application, |
|
| 118 | - * to avoid the conflict of name of the tables between different database, |
|
| 119 | - * it is possible to define prefixes for the tables. |
|
| 120 | - * for example : |
|
| 121 | - * |
|
| 122 | - * $db['prefix'] = 'pf_'; |
|
| 123 | - * or |
|
| 124 | - * |
|
| 125 | - * $db['prefix'] = 'my_db_'; |
|
| 126 | - */ |
|
| 127 | - $db['prefix'] = ''; |
|
| 128 | 116 | \ No newline at end of file |
| 117 | + /** |
|
| 118 | + * If your tables in your database contain prefixes, this is the case most on some application, |
|
| 119 | + * to avoid the conflict of name of the tables between different database, |
|
| 120 | + * it is possible to define prefixes for the tables. |
|
| 121 | + * for example : |
|
| 122 | + * |
|
| 123 | + * $db['prefix'] = 'pf_'; |
|
| 124 | + * or |
|
| 125 | + * |
|
| 126 | + * $db['prefix'] = 'my_db_'; |
|
| 127 | + */ |
|
| 128 | + $db['prefix'] = ''; |
|
| 129 | 129 | \ No newline at end of file |
@@ -1,88 +1,88 @@ |
||
| 1 | 1 | <?php |
| 2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | - /** |
|
| 4 | - * TNH Framework |
|
| 5 | - * |
|
| 6 | - * A simple PHP framework created using the concept of codeigniter with bootstrap twitter |
|
| 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 created using the concept of codeigniter with bootstrap twitter |
|
| 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 | - * This file contains the configuration of your routes that is to say that links to your URLs. |
|
| 29 | - * The index of the $route array contains the url address to capture and the value contains |
|
| 30 | - * the name of the module, controller and the method to call. |
|
| 31 | - * For example : |
|
| 32 | - * |
|
| 33 | - * $route['/users/login'] = 'moduleUsers#UsersController@login_action'; |
|
| 34 | - * |
|
| 35 | - * it means, if the user type in the address bar an URL like http://yoursite.com/users/login, |
|
| 36 | - * that will call the module "moduleUsers", the controller "UsersController" and the method "login_action". |
|
| 37 | - * Note 1: it is recommended that each index in the $route array start with a slash "/" |
|
| 38 | - * otherwise on some system this will not work. |
|
| 39 | - * Note 2: to define the default controller route (homepage) of your application you use only the index "/" |
|
| 40 | - * for example the following route represents the homepage: |
|
| 41 | - * |
|
| 42 | - * $route['/'] = 'Home'; //only the controller or module name |
|
| 43 | - * |
|
| 44 | - * $route['/'] = 'Home@index'; //only the controller or module name with the method |
|
| 45 | - * |
|
| 46 | - * $route['/'] = 'module#Home@index'; //with module name, controller and method |
|
| 47 | - * |
|
| 48 | - * Note 3: If the method is not specified then the "index" method will be used as |
|
| 49 | - * default method. For example in the case of our homepage, this will be able to make: |
|
| 50 | - * |
|
| 51 | - * $route['/'] = 'Home'; |
|
| 52 | - * |
|
| 53 | - * Note 4: All methods called must have "public" visibility if you know the principle of |
|
| 54 | - * Object Oriented Programming, you know what visibility means (public, protected, private). |
|
| 55 | - * |
|
| 56 | - * In the index of your route, you can use the markers (:num), (:alpha), (:alnum) and (:any) which correspond |
|
| 57 | - * respectively to the regular expression [0-9], [a-zA-Z], [a-zA-Z0-9] and. *. |
|
| 58 | - * For example : |
|
| 59 | - * |
|
| 60 | - * - $route['/profile/(:num)'] = 'UsersController@profile'; => http://yoursite.com/profile/4 will be captured but |
|
| 61 | - * http://yoursite.com/profile/a will not captured. |
|
| 62 | - * |
|
| 63 | - * - $route['/profile/(:alpha)'] = 'UsersController@profile'; => http://yoursite.com/profile/a will be captured |
|
| 64 | - * but http://yoursite.com/profile/1457 will not captured. |
|
| 65 | - * |
|
| 66 | - * - $route['/profile/(:alnum)'] = 'UsersController@profile'; => http://yoursite.com/profile/4a, |
|
| 67 | - * http://yoursite.com/profile/7 will be captured but http://yoursite.com/profile/7-dangerous will not captured. |
|
| 68 | - * |
|
| 69 | - * - $route['/(:any)'] = 'ArticleController@read'; => http://yoursite.com/1-my-super-article, |
|
| 70 | - * http://yoursite.com/7, will be captured. |
|
| 71 | - * |
|
| 72 | - * Note 5: The order of definition of each route is important. |
|
| 73 | - * For example, the following definitions work: |
|
| 74 | - * |
|
| 75 | - * $route['/article/add'] = 'Article@add'; |
|
| 76 | - * $route['article/(:any)'] = 'Article@read'; |
|
| 77 | - * |
|
| 78 | - * however, the following definitions does not work as intended |
|
| 79 | - * |
|
| 80 | - * $route['article/(:any)'] = 'Article@read'; |
|
| 81 | - * $route['/article/add'] = 'Article@add'; |
|
| 82 | - * |
|
| 83 | - */ |
|
| 27 | + /** |
|
| 28 | + * This file contains the configuration of your routes that is to say that links to your URLs. |
|
| 29 | + * The index of the $route array contains the url address to capture and the value contains |
|
| 30 | + * the name of the module, controller and the method to call. |
|
| 31 | + * For example : |
|
| 32 | + * |
|
| 33 | + * $route['/users/login'] = 'moduleUsers#UsersController@login_action'; |
|
| 34 | + * |
|
| 35 | + * it means, if the user type in the address bar an URL like http://yoursite.com/users/login, |
|
| 36 | + * that will call the module "moduleUsers", the controller "UsersController" and the method "login_action". |
|
| 37 | + * Note 1: it is recommended that each index in the $route array start with a slash "/" |
|
| 38 | + * otherwise on some system this will not work. |
|
| 39 | + * Note 2: to define the default controller route (homepage) of your application you use only the index "/" |
|
| 40 | + * for example the following route represents the homepage: |
|
| 41 | + * |
|
| 42 | + * $route['/'] = 'Home'; //only the controller or module name |
|
| 43 | + * |
|
| 44 | + * $route['/'] = 'Home@index'; //only the controller or module name with the method |
|
| 45 | + * |
|
| 46 | + * $route['/'] = 'module#Home@index'; //with module name, controller and method |
|
| 47 | + * |
|
| 48 | + * Note 3: If the method is not specified then the "index" method will be used as |
|
| 49 | + * default method. For example in the case of our homepage, this will be able to make: |
|
| 50 | + * |
|
| 51 | + * $route['/'] = 'Home'; |
|
| 52 | + * |
|
| 53 | + * Note 4: All methods called must have "public" visibility if you know the principle of |
|
| 54 | + * Object Oriented Programming, you know what visibility means (public, protected, private). |
|
| 55 | + * |
|
| 56 | + * In the index of your route, you can use the markers (:num), (:alpha), (:alnum) and (:any) which correspond |
|
| 57 | + * respectively to the regular expression [0-9], [a-zA-Z], [a-zA-Z0-9] and. *. |
|
| 58 | + * For example : |
|
| 59 | + * |
|
| 60 | + * - $route['/profile/(:num)'] = 'UsersController@profile'; => http://yoursite.com/profile/4 will be captured but |
|
| 61 | + * http://yoursite.com/profile/a will not captured. |
|
| 62 | + * |
|
| 63 | + * - $route['/profile/(:alpha)'] = 'UsersController@profile'; => http://yoursite.com/profile/a will be captured |
|
| 64 | + * but http://yoursite.com/profile/1457 will not captured. |
|
| 65 | + * |
|
| 66 | + * - $route['/profile/(:alnum)'] = 'UsersController@profile'; => http://yoursite.com/profile/4a, |
|
| 67 | + * http://yoursite.com/profile/7 will be captured but http://yoursite.com/profile/7-dangerous will not captured. |
|
| 68 | + * |
|
| 69 | + * - $route['/(:any)'] = 'ArticleController@read'; => http://yoursite.com/1-my-super-article, |
|
| 70 | + * http://yoursite.com/7, will be captured. |
|
| 71 | + * |
|
| 72 | + * Note 5: The order of definition of each route is important. |
|
| 73 | + * For example, the following definitions work: |
|
| 74 | + * |
|
| 75 | + * $route['/article/add'] = 'Article@add'; |
|
| 76 | + * $route['article/(:any)'] = 'Article@read'; |
|
| 77 | + * |
|
| 78 | + * however, the following definitions does not work as intended |
|
| 79 | + * |
|
| 80 | + * $route['article/(:any)'] = 'Article@read'; |
|
| 81 | + * $route['/article/add'] = 'Article@add'; |
|
| 82 | + * |
|
| 83 | + */ |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * The default route like your home page |
|
| 87 | - */ |
|
| 88 | - $route['/'] = 'Home'; |
|
| 89 | 85 | \ No newline at end of file |
| 86 | + /** |
|
| 87 | + * The default route like your home page |
|
| 88 | + */ |
|
| 89 | + $route['/'] = 'Home'; |
|
| 90 | 90 | \ No newline at end of file |
@@ -1,90 +1,90 @@ |
||
| 1 | 1 | <?php |
| 2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
| 3 | - /** |
|
| 4 | - * TNH Framework |
|
| 5 | - * |
|
| 6 | - * A simple PHP framework created using the concept of codeigniter with bootstrap twitter |
|
| 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 created using the concept of codeigniter with bootstrap twitter |
|
| 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 | - * This file contains the pagination library configuration of your application |
|
| 29 | - */ |
|
| 27 | + /** |
|
| 28 | + * This file contains the pagination library configuration of your application |
|
| 29 | + */ |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Number of pagination digit |
|
| 33 | - */ |
|
| 34 | - $config['nb_link'] = 10; |
|
| 31 | + /** |
|
| 32 | + * Number of pagination digit |
|
| 33 | + */ |
|
| 34 | + $config['nb_link'] = 10; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * The pagination. |
|
| 38 | - * |
|
| 39 | - * Represents the number of data to display per page. |
|
| 40 | - * Note: this value must be strictly greater than zero (0) |
|
| 41 | - */ |
|
| 42 | - $config['pagination_per_page'] = 10; |
|
| 36 | + /** |
|
| 37 | + * The pagination. |
|
| 38 | + * |
|
| 39 | + * Represents the number of data to display per page. |
|
| 40 | + * Note: this value must be strictly greater than zero (0) |
|
| 41 | + */ |
|
| 42 | + $config['pagination_per_page'] = 10; |
|
| 43 | 43 | |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * The query string name used to fetch the current page |
|
| 47 | - */ |
|
| 48 | - $config['page_query_string_name'] = 'page'; |
|
| 45 | + /** |
|
| 46 | + * The query string name used to fetch the current page |
|
| 47 | + */ |
|
| 48 | + $config['page_query_string_name'] = 'page'; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * The opened and closed tag for active link |
|
| 52 | - */ |
|
| 53 | - $config['active_link_open'] = '<li class = "active"><a href = "#">'; |
|
| 54 | - $config['active_link_close'] = '</a></li>'; |
|
| 50 | + /** |
|
| 51 | + * The opened and closed tag for active link |
|
| 52 | + */ |
|
| 53 | + $config['active_link_open'] = '<li class = "active"><a href = "#">'; |
|
| 54 | + $config['active_link_close'] = '</a></li>'; |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * The opened and closed tag for previous link |
|
| 58 | - */ |
|
| 59 | - $config['previous_open'] = '<li>'; |
|
| 60 | - $config['previous_close'] = '</li>'; |
|
| 56 | + /** |
|
| 57 | + * The opened and closed tag for previous link |
|
| 58 | + */ |
|
| 59 | + $config['previous_open'] = '<li>'; |
|
| 60 | + $config['previous_close'] = '</li>'; |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * The opened and closed tag for next link |
|
| 64 | - */ |
|
| 65 | - $config['next_open'] = '<li>'; |
|
| 66 | - $config['next_close'] = '</li>'; |
|
| 62 | + /** |
|
| 63 | + * The opened and closed tag for next link |
|
| 64 | + */ |
|
| 65 | + $config['next_open'] = '<li>'; |
|
| 66 | + $config['next_close'] = '</li>'; |
|
| 67 | 67 | |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * The displayed text for previous and next link |
|
| 71 | - */ |
|
| 72 | - $config['previous_text'] = '««'; |
|
| 73 | - $config['next_text'] = '»»'; |
|
| 69 | + /** |
|
| 70 | + * The displayed text for previous and next link |
|
| 71 | + */ |
|
| 72 | + $config['previous_text'] = '««'; |
|
| 73 | + $config['next_text'] = '»»'; |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * The opened and closed tag for the pagination bloc |
|
| 77 | - */ |
|
| 78 | - $config['pagination_open'] = '<ul class = "pagination">'; |
|
| 79 | - $config['pagination_close'] = '</ul>'; |
|
| 75 | + /** |
|
| 76 | + * The opened and closed tag for the pagination bloc |
|
| 77 | + */ |
|
| 78 | + $config['pagination_open'] = '<ul class = "pagination">'; |
|
| 79 | + $config['pagination_close'] = '</ul>'; |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * The opened and closed tag for each link digit |
|
| 83 | - */ |
|
| 84 | - $config['digit_open'] = '<li>'; |
|
| 85 | - $config['digit_close'] = '</li>'; |
|
| 81 | + /** |
|
| 82 | + * The opened and closed tag for each link digit |
|
| 83 | + */ |
|
| 84 | + $config['digit_open'] = '<li>'; |
|
| 85 | + $config['digit_close'] = '</li>'; |
|
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * The HTML attributes to use in each link |
|
| 89 | - */ |
|
| 90 | - $config['attributes'] = array(); |
|
| 91 | 87 | \ No newline at end of file |
| 88 | + /** |
|
| 89 | + * The HTML attributes to use in each link |
|
| 90 | + */ |
|
| 91 | + $config['attributes'] = array(); |
|
| 92 | 92 | \ No newline at end of file |
@@ -1,63 +1,63 @@ |
||
| 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 | - * This class represent the event detail to dispatch to correspond listener |
|
| 29 | - */ |
|
| 30 | - class EventInfo{ |
|
| 27 | + /** |
|
| 28 | + * This class represent the event detail to dispatch to correspond listener |
|
| 29 | + */ |
|
| 30 | + class EventInfo{ |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * The event name |
|
| 34 | - * @var string |
|
| 35 | - */ |
|
| 36 | - public $name; |
|
| 32 | + /** |
|
| 33 | + * The event name |
|
| 34 | + * @var string |
|
| 35 | + */ |
|
| 36 | + public $name; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * The event data to send to the listeners |
|
| 40 | - * @var mixed |
|
| 41 | - */ |
|
| 42 | - public $payload; |
|
| 38 | + /** |
|
| 39 | + * The event data to send to the listeners |
|
| 40 | + * @var mixed |
|
| 41 | + */ |
|
| 42 | + public $payload; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * If the listeners need return the event after treatment or not, false means no need |
|
| 46 | - * return true need return the event. |
|
| 47 | - * @var boolean |
|
| 48 | - */ |
|
| 49 | - public $returnBack; |
|
| 44 | + /** |
|
| 45 | + * If the listeners need return the event after treatment or not, false means no need |
|
| 46 | + * return true need return the event. |
|
| 47 | + * @var boolean |
|
| 48 | + */ |
|
| 49 | + public $returnBack; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * This variable indicates if need stop the event propagation |
|
| 53 | - * @var boolean |
|
| 54 | - */ |
|
| 55 | - public $stop; |
|
| 51 | + /** |
|
| 52 | + * This variable indicates if need stop the event propagation |
|
| 53 | + * @var boolean |
|
| 54 | + */ |
|
| 55 | + public $stop; |
|
| 56 | 56 | |
| 57 | - public function __construct($name, $payload = array(), $returnBack = false, $stop = false){ |
|
| 58 | - $this->name = $name; |
|
| 59 | - $this->payload = $payload; |
|
| 60 | - $this->returnBack = $returnBack; |
|
| 61 | - $this->stop = $stop; |
|
| 62 | - } |
|
| 63 | - } |
|
| 57 | + public function __construct($name, $payload = array(), $returnBack = false, $stop = false){ |
|
| 58 | + $this->name = $name; |
|
| 59 | + $this->payload = $payload; |
|
| 60 | + $this->returnBack = $returnBack; |
|
| 61 | + $this->stop = $stop; |
|
| 62 | + } |
|
| 63 | + } |
|
@@ -1,43 +1,43 @@ discard block |
||
| 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 | - class DatabaseQueryResult{ |
|
| 27 | + class DatabaseQueryResult{ |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * The database query result |
|
| 31 | - * @var mixed |
|
| 32 | - */ |
|
| 33 | - private $result = null; |
|
| 29 | + /** |
|
| 30 | + * The database query result |
|
| 31 | + * @var mixed |
|
| 32 | + */ |
|
| 33 | + private $result = null; |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * The number of rows returned by the last query |
|
| 38 | - * @var int |
|
| 39 | - */ |
|
| 40 | - private $numRows = 0; |
|
| 36 | + /** |
|
| 37 | + * The number of rows returned by the last query |
|
| 38 | + * @var int |
|
| 39 | + */ |
|
| 40 | + private $numRows = 0; |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -51,24 +51,24 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Return the query result |
|
| 56 | - * |
|
| 57 | - * @return mixed |
|
| 58 | - */ |
|
| 54 | + /** |
|
| 55 | + * Return the query result |
|
| 56 | + * |
|
| 57 | + * @return mixed |
|
| 58 | + */ |
|
| 59 | 59 | public function getResult(){ |
| 60 | - return $this->result; |
|
| 60 | + return $this->result; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * Set the query result |
| 65 | 65 | * @param mixed $result the query result |
| 66 | 66 | * |
| 67 | - * @return object DatabaseQueryResult |
|
| 67 | + * @return object DatabaseQueryResult |
|
| 68 | 68 | */ |
| 69 | 69 | public function setResult($result){ |
| 70 | - $this->result = $result; |
|
| 71 | - return $this; |
|
| 70 | + $this->result = $result; |
|
| 71 | + return $this; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -77,18 +77,18 @@ discard block |
||
| 77 | 77 | * @return int |
| 78 | 78 | */ |
| 79 | 79 | public function getNumRows(){ |
| 80 | - return $this->numRows; |
|
| 80 | + return $this->numRows; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * Set the number of rows returned by the query |
| 85 | 85 | * @param int $numRows the number of rows returned |
| 86 | 86 | * |
| 87 | - * @return object DatabaseQueryResult |
|
| 87 | + * @return object DatabaseQueryResult |
|
| 88 | 88 | */ |
| 89 | 89 | public function setNumRows($numRows){ |
| 90 | - $this->numRows = $numRows; |
|
| 91 | - return $this; |
|
| 90 | + $this->numRows = $numRows; |
|
| 91 | + return $this; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | } |
@@ -1,168 +1,168 @@ |
||
| 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 | - */ |
|
| 26 | - class Session{ |
|
| 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 | + class Session{ |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * The session flash key to use |
|
| 30 | - * @const |
|
| 31 | - */ |
|
| 32 | - const SESSION_FLASH_KEY = 'session_flash'; |
|
| 28 | + /** |
|
| 29 | + * The session flash key to use |
|
| 30 | + * @const |
|
| 31 | + */ |
|
| 32 | + const SESSION_FLASH_KEY = 'session_flash'; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * The logger instance |
|
| 36 | - * @var Log |
|
| 37 | - */ |
|
| 38 | - private static $logger; |
|
| 34 | + /** |
|
| 35 | + * The logger instance |
|
| 36 | + * @var Log |
|
| 37 | + */ |
|
| 38 | + private static $logger; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Get the logger singleton instance |
|
| 42 | - * @return Log the logger instance |
|
| 43 | - */ |
|
| 44 | - private static function getLogger(){ |
|
| 45 | - if(self::$logger == null){ |
|
| 46 | - self::$logger[0] =& class_loader('Log', 'classes'); |
|
| 47 | - self::$logger[0]->setLogger('Library::Session'); |
|
| 48 | - } |
|
| 49 | - return self::$logger[0]; |
|
| 50 | - } |
|
| 40 | + /** |
|
| 41 | + * Get the logger singleton instance |
|
| 42 | + * @return Log the logger instance |
|
| 43 | + */ |
|
| 44 | + private static function getLogger(){ |
|
| 45 | + if(self::$logger == null){ |
|
| 46 | + self::$logger[0] =& class_loader('Log', 'classes'); |
|
| 47 | + self::$logger[0]->setLogger('Library::Session'); |
|
| 48 | + } |
|
| 49 | + return self::$logger[0]; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Get the session item value |
|
| 54 | - * @param string $item the session item name to get |
|
| 55 | - * @param mixed $default the default value to use if can not find the session item in the list |
|
| 56 | - * @return mixed the session value if exist or the default value |
|
| 57 | - */ |
|
| 58 | - public static function get($item, $default = null){ |
|
| 59 | - $logger = self::getLogger(); |
|
| 60 | - $logger->debug('Getting session data for item [' .$item. '] ...'); |
|
| 61 | - if(array_key_exists($item, $_SESSION)){ |
|
| 62 | - $logger->info('Found session data for item [' . $item . '] the vaue is : [' . stringfy_vars($_SESSION[$item]) . ']'); |
|
| 63 | - return $_SESSION[$item]; |
|
| 64 | - } |
|
| 65 | - $logger->warning('Cannot find session item [' . $item . '] using the default value ['. $default . ']'); |
|
| 66 | - return $default; |
|
| 67 | - } |
|
| 52 | + /** |
|
| 53 | + * Get the session item value |
|
| 54 | + * @param string $item the session item name to get |
|
| 55 | + * @param mixed $default the default value to use if can not find the session item in the list |
|
| 56 | + * @return mixed the session value if exist or the default value |
|
| 57 | + */ |
|
| 58 | + public static function get($item, $default = null){ |
|
| 59 | + $logger = self::getLogger(); |
|
| 60 | + $logger->debug('Getting session data for item [' .$item. '] ...'); |
|
| 61 | + if(array_key_exists($item, $_SESSION)){ |
|
| 62 | + $logger->info('Found session data for item [' . $item . '] the vaue is : [' . stringfy_vars($_SESSION[$item]) . ']'); |
|
| 63 | + return $_SESSION[$item]; |
|
| 64 | + } |
|
| 65 | + $logger->warning('Cannot find session item [' . $item . '] using the default value ['. $default . ']'); |
|
| 66 | + return $default; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Set the session item value |
|
| 71 | - * @param string $item the session item name to set |
|
| 72 | - * @param mixed $value the session item value |
|
| 73 | - */ |
|
| 74 | - public static function set($item, $value){ |
|
| 75 | - $logger = self::getLogger(); |
|
| 76 | - $logger->debug('Setting session data for item [' . $item . '], value [' . stringfy_vars($value) . ']'); |
|
| 77 | - $_SESSION[$item] = $value; |
|
| 78 | - } |
|
| 69 | + /** |
|
| 70 | + * Set the session item value |
|
| 71 | + * @param string $item the session item name to set |
|
| 72 | + * @param mixed $value the session item value |
|
| 73 | + */ |
|
| 74 | + public static function set($item, $value){ |
|
| 75 | + $logger = self::getLogger(); |
|
| 76 | + $logger->debug('Setting session data for item [' . $item . '], value [' . stringfy_vars($value) . ']'); |
|
| 77 | + $_SESSION[$item] = $value; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * Get the session flash item value |
|
| 82 | - * @param string $item the session flash item name to get |
|
| 83 | - * @param mixed $default the default value to use if can not find the session flash item in the list |
|
| 84 | - * @return mixed the session flash value if exist or the default value |
|
| 85 | - */ |
|
| 86 | - public static function getFlash($item, $default = null){ |
|
| 87 | - $logger = self::getLogger(); |
|
| 88 | - $key = self::SESSION_FLASH_KEY.'_'.$item; |
|
| 89 | - $return = array_key_exists($key, $_SESSION) ? |
|
| 90 | - ($_SESSION[$key]) : $default; |
|
| 91 | - if(array_key_exists($key, $_SESSION)){ |
|
| 92 | - unset($_SESSION[$key]); |
|
| 93 | - } |
|
| 94 | - else{ |
|
| 95 | - $logger->warning('Cannot find session flash item ['. $key .'] using the default value ['. $default .']'); |
|
| 96 | - } |
|
| 97 | - return $return; |
|
| 98 | - } |
|
| 80 | + /** |
|
| 81 | + * Get the session flash item value |
|
| 82 | + * @param string $item the session flash item name to get |
|
| 83 | + * @param mixed $default the default value to use if can not find the session flash item in the list |
|
| 84 | + * @return mixed the session flash value if exist or the default value |
|
| 85 | + */ |
|
| 86 | + public static function getFlash($item, $default = null){ |
|
| 87 | + $logger = self::getLogger(); |
|
| 88 | + $key = self::SESSION_FLASH_KEY.'_'.$item; |
|
| 89 | + $return = array_key_exists($key, $_SESSION) ? |
|
| 90 | + ($_SESSION[$key]) : $default; |
|
| 91 | + if(array_key_exists($key, $_SESSION)){ |
|
| 92 | + unset($_SESSION[$key]); |
|
| 93 | + } |
|
| 94 | + else{ |
|
| 95 | + $logger->warning('Cannot find session flash item ['. $key .'] using the default value ['. $default .']'); |
|
| 96 | + } |
|
| 97 | + return $return; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * Check whether the given session flash item exists |
|
| 102 | - * @param string $item the session flash item name |
|
| 103 | - * @return boolean |
|
| 104 | - */ |
|
| 105 | - public static function hasFlash($item){ |
|
| 106 | - $key = self::SESSION_FLASH_KEY.'_'.$item; |
|
| 107 | - return array_key_exists($key, $_SESSION); |
|
| 108 | - } |
|
| 100 | + /** |
|
| 101 | + * Check whether the given session flash item exists |
|
| 102 | + * @param string $item the session flash item name |
|
| 103 | + * @return boolean |
|
| 104 | + */ |
|
| 105 | + public static function hasFlash($item){ |
|
| 106 | + $key = self::SESSION_FLASH_KEY.'_'.$item; |
|
| 107 | + return array_key_exists($key, $_SESSION); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * Set the session flash item value |
|
| 112 | - * @param string $item the session flash item name to set |
|
| 113 | - * @param mixed $value the session flash item value |
|
| 114 | - */ |
|
| 115 | - public static function setFlash($item, $value){ |
|
| 116 | - $key = self::SESSION_FLASH_KEY.'_'.$item; |
|
| 117 | - $_SESSION[$key] = $value; |
|
| 118 | - } |
|
| 110 | + /** |
|
| 111 | + * Set the session flash item value |
|
| 112 | + * @param string $item the session flash item name to set |
|
| 113 | + * @param mixed $value the session flash item value |
|
| 114 | + */ |
|
| 115 | + public static function setFlash($item, $value){ |
|
| 116 | + $key = self::SESSION_FLASH_KEY.'_'.$item; |
|
| 117 | + $_SESSION[$key] = $value; |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * Clear the session item in the list |
|
| 122 | - * @param string $item the session item name to be deleted |
|
| 123 | - */ |
|
| 124 | - public static function clear($item){ |
|
| 125 | - $logger = self::getLogger(); |
|
| 126 | - if(array_key_exists($item, $_SESSION)){ |
|
| 127 | - $logger->info('Deleting of session for item ['.$item.' ]'); |
|
| 128 | - unset($_SESSION[$item]); |
|
| 129 | - } |
|
| 130 | - else{ |
|
| 131 | - $logger->warning('Session item ['.$item.'] to be deleted does not exists'); |
|
| 132 | - } |
|
| 133 | - } |
|
| 120 | + /** |
|
| 121 | + * Clear the session item in the list |
|
| 122 | + * @param string $item the session item name to be deleted |
|
| 123 | + */ |
|
| 124 | + public static function clear($item){ |
|
| 125 | + $logger = self::getLogger(); |
|
| 126 | + if(array_key_exists($item, $_SESSION)){ |
|
| 127 | + $logger->info('Deleting of session for item ['.$item.' ]'); |
|
| 128 | + unset($_SESSION[$item]); |
|
| 129 | + } |
|
| 130 | + else{ |
|
| 131 | + $logger->warning('Session item ['.$item.'] to be deleted does not exists'); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - /** |
|
| 136 | - * Clear the session flash item in the list |
|
| 137 | - * @param string $item the session flash item name to be deleted |
|
| 138 | - */ |
|
| 139 | - public static function clearFlash($item){ |
|
| 140 | - $logger = self::getLogger(); |
|
| 141 | - $key = self::SESSION_FLASH_KEY.'_'.$item; |
|
| 142 | - if(array_key_exists($key, $_SESSION)){ |
|
| 143 | - $logger->info('Delete session flash for item ['.$item.']'); |
|
| 144 | - unset($_SESSION[$item]); |
|
| 145 | - } |
|
| 146 | - else{ |
|
| 147 | - $logger->warning('Dession flash item ['.$item.'] to be deleted does not exists'); |
|
| 148 | - } |
|
| 149 | - } |
|
| 135 | + /** |
|
| 136 | + * Clear the session flash item in the list |
|
| 137 | + * @param string $item the session flash item name to be deleted |
|
| 138 | + */ |
|
| 139 | + public static function clearFlash($item){ |
|
| 140 | + $logger = self::getLogger(); |
|
| 141 | + $key = self::SESSION_FLASH_KEY.'_'.$item; |
|
| 142 | + if(array_key_exists($key, $_SESSION)){ |
|
| 143 | + $logger->info('Delete session flash for item ['.$item.']'); |
|
| 144 | + unset($_SESSION[$item]); |
|
| 145 | + } |
|
| 146 | + else{ |
|
| 147 | + $logger->warning('Dession flash item ['.$item.'] to be deleted does not exists'); |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - /** |
|
| 152 | - * Check whether the given session item exists |
|
| 153 | - * @param string $item the session item name |
|
| 154 | - * @return boolean |
|
| 155 | - */ |
|
| 156 | - public static function exists($item){ |
|
| 157 | - return array_key_exists($item, $_SESSION); |
|
| 158 | - } |
|
| 151 | + /** |
|
| 152 | + * Check whether the given session item exists |
|
| 153 | + * @param string $item the session item name |
|
| 154 | + * @return boolean |
|
| 155 | + */ |
|
| 156 | + public static function exists($item){ |
|
| 157 | + return array_key_exists($item, $_SESSION); |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | - /** |
|
| 161 | - * Destroy all session data values |
|
| 162 | - */ |
|
| 163 | - public static function clearAll(){ |
|
| 164 | - session_unset(); |
|
| 165 | - session_destroy(); |
|
| 166 | - } |
|
| 160 | + /** |
|
| 161 | + * Destroy all session data values |
|
| 162 | + */ |
|
| 163 | + public static function clearAll(){ |
|
| 164 | + session_unset(); |
|
| 165 | + session_destroy(); |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - } |
|
| 168 | + } |
|
@@ -1,330 +1,330 @@ discard block |
||
| 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 | - * check if the interface "SessionHandlerInterface" exists (normally in PHP 5.4 this already exists) |
|
| 29 | - */ |
|
| 30 | - if( !interface_exists('SessionHandlerInterface')){ |
|
| 31 | - show_error('"SessionHandlerInterface" interface does not exists or is disabled can not use it to handler database session.'); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - class DBSessionHandler implements SessionHandlerInterface{ |
|
| 27 | + /** |
|
| 28 | + * check if the interface "SessionHandlerInterface" exists (normally in PHP 5.4 this already exists) |
|
| 29 | + */ |
|
| 30 | + if( !interface_exists('SessionHandlerInterface')){ |
|
| 31 | + show_error('"SessionHandlerInterface" interface does not exists or is disabled can not use it to handler database session.'); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + class DBSessionHandler implements SessionHandlerInterface{ |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * The encryption method to use to encrypt session data in database |
|
| 38 | - * @const string |
|
| 39 | - */ |
|
| 40 | - const DB_SESSION_HASH_METHOD = 'AES-256-CBC'; |
|
| 36 | + /** |
|
| 37 | + * The encryption method to use to encrypt session data in database |
|
| 38 | + * @const string |
|
| 39 | + */ |
|
| 40 | + const DB_SESSION_HASH_METHOD = 'AES-256-CBC'; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Super global instance |
|
| 44 | - * @var object |
|
| 45 | - */ |
|
| 46 | - protected $OBJ = null; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Session secret to use |
|
| 50 | - * @var string |
|
| 51 | - */ |
|
| 52 | - private $sessionSecret = null; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * The initialisation vector to use for openssl |
|
| 56 | - * @var string |
|
| 57 | - */ |
|
| 58 | - private $iv = null; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * The model instance name to use after load model |
|
| 62 | - * @var object |
|
| 63 | - */ |
|
| 64 | - private $modelInstanceName = null; |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * The columns of the table to use to store session data |
|
| 68 | - * @var array |
|
| 69 | - */ |
|
| 70 | - private $sessionTableColumns = array(); |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * The instance of the Log |
|
| 74 | - * @var Log |
|
| 75 | - */ |
|
| 76 | - private $logger; |
|
| 77 | - |
|
| 78 | - /** |
|
| 42 | + /** |
|
| 43 | + * Super global instance |
|
| 44 | + * @var object |
|
| 45 | + */ |
|
| 46 | + protected $OBJ = null; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Session secret to use |
|
| 50 | + * @var string |
|
| 51 | + */ |
|
| 52 | + private $sessionSecret = null; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * The initialisation vector to use for openssl |
|
| 56 | + * @var string |
|
| 57 | + */ |
|
| 58 | + private $iv = null; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * The model instance name to use after load model |
|
| 62 | + * @var object |
|
| 63 | + */ |
|
| 64 | + private $modelInstanceName = null; |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * The columns of the table to use to store session data |
|
| 68 | + * @var array |
|
| 69 | + */ |
|
| 70 | + private $sessionTableColumns = array(); |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * The instance of the Log |
|
| 74 | + * @var Log |
|
| 75 | + */ |
|
| 76 | + private $logger; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | 79 | * Instance of the Loader class |
| 80 | 80 | * @var Loader |
| 81 | 81 | */ |
| 82 | 82 | protected $loader = null; |
| 83 | 83 | |
| 84 | - public function __construct(DBSessionHandlerModel $modelInstance = null, Log $logger = null, Loader $loader = null){ |
|
| 85 | - /** |
|
| 86 | - * instance of the Log class |
|
| 87 | - */ |
|
| 88 | - if(is_object($logger)){ |
|
| 89 | - $this->setLogger($logger); |
|
| 90 | - } |
|
| 91 | - else{ |
|
| 92 | - $this->logger =& class_loader('Log', 'classes'); |
|
| 93 | - $this->logger->setLogger('Library::DBSessionHandler'); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - if(is_object($loader)){ |
|
| 97 | - $this->setLoader($loader); |
|
| 98 | - } |
|
| 99 | - $this->OBJ = & get_instance(); |
|
| 84 | + public function __construct(DBSessionHandlerModel $modelInstance = null, Log $logger = null, Loader $loader = null){ |
|
| 85 | + /** |
|
| 86 | + * instance of the Log class |
|
| 87 | + */ |
|
| 88 | + if(is_object($logger)){ |
|
| 89 | + $this->setLogger($logger); |
|
| 90 | + } |
|
| 91 | + else{ |
|
| 92 | + $this->logger =& class_loader('Log', 'classes'); |
|
| 93 | + $this->logger->setLogger('Library::DBSessionHandler'); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + if(is_object($loader)){ |
|
| 97 | + $this->setLoader($loader); |
|
| 98 | + } |
|
| 99 | + $this->OBJ = & get_instance(); |
|
| 100 | 100 | |
| 101 | 101 | |
| 102 | - if(is_object($modelInstance)){ |
|
| 103 | - $this->setModelInstance($modelInstance); |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * Set the session secret used to encrypt the data in database |
|
| 109 | - * @param string $secret the base64 string secret |
|
| 110 | - */ |
|
| 111 | - public function setSessionSecret($secret){ |
|
| 112 | - $this->sessionSecret = $secret; |
|
| 113 | - return $this; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * Return the session secret |
|
| 118 | - * @return string |
|
| 119 | - */ |
|
| 120 | - public function getSessionSecret(){ |
|
| 121 | - return $this->sessionSecret; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * Set the initializer vector for openssl |
|
| 127 | - * @param string $key the session secret used |
|
| 128 | - */ |
|
| 129 | - public function setInitializerVector($key){ |
|
| 130 | - $iv_length = openssl_cipher_iv_length(self::DB_SESSION_HASH_METHOD); |
|
| 131 | - $key = base64_decode($key); |
|
| 132 | - $this->iv = substr(hash('sha256', $key), 0, $iv_length); |
|
| 133 | - return $this; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Return the initializer vector |
|
| 138 | - * @return string |
|
| 139 | - */ |
|
| 140 | - public function getInitializerVector(){ |
|
| 141 | - return $this->iv; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * Open the database session handler, here nothing to do just return true |
|
| 146 | - * @param string $savePath the session save path |
|
| 147 | - * @param string $sessionName the session name |
|
| 148 | - * @return boolean |
|
| 149 | - */ |
|
| 150 | - public function open($savePath, $sessionName){ |
|
| 151 | - $this->logger->debug('Opening database session handler for [' . $sessionName . ']'); |
|
| 152 | - //try to check if session secret is set before |
|
| 153 | - $secret = $this->getSessionSecret(); |
|
| 154 | - if(empty($secret)){ |
|
| 155 | - $secret = get_config('session_secret', null); |
|
| 156 | - $this->setSessionSecret($secret); |
|
| 157 | - } |
|
| 158 | - $this->logger->info('Session secret: ' . $secret); |
|
| 159 | - |
|
| 160 | - if(! $this->getModelInstance()){ |
|
| 161 | - $this->setModelInstanceFromConfig(); |
|
| 162 | - } |
|
| 163 | - $this->setInitializerVector($secret); |
|
| 164 | - |
|
| 165 | - //set session tables columns |
|
| 166 | - $this->sessionTableColumns = $this->getModelInstance()->getSessionTableColumns(); |
|
| 167 | - |
|
| 168 | - if(empty($this->sessionTableColumns)){ |
|
| 169 | - show_error('The session handler is "database" but the table columns not set'); |
|
| 170 | - } |
|
| 171 | - $this->logger->info('Database session, the model columns are listed below: ' . stringfy_vars($this->sessionTableColumns)); |
|
| 102 | + if(is_object($modelInstance)){ |
|
| 103 | + $this->setModelInstance($modelInstance); |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * Set the session secret used to encrypt the data in database |
|
| 109 | + * @param string $secret the base64 string secret |
|
| 110 | + */ |
|
| 111 | + public function setSessionSecret($secret){ |
|
| 112 | + $this->sessionSecret = $secret; |
|
| 113 | + return $this; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * Return the session secret |
|
| 118 | + * @return string |
|
| 119 | + */ |
|
| 120 | + public function getSessionSecret(){ |
|
| 121 | + return $this->sessionSecret; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * Set the initializer vector for openssl |
|
| 127 | + * @param string $key the session secret used |
|
| 128 | + */ |
|
| 129 | + public function setInitializerVector($key){ |
|
| 130 | + $iv_length = openssl_cipher_iv_length(self::DB_SESSION_HASH_METHOD); |
|
| 131 | + $key = base64_decode($key); |
|
| 132 | + $this->iv = substr(hash('sha256', $key), 0, $iv_length); |
|
| 133 | + return $this; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Return the initializer vector |
|
| 138 | + * @return string |
|
| 139 | + */ |
|
| 140 | + public function getInitializerVector(){ |
|
| 141 | + return $this->iv; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * Open the database session handler, here nothing to do just return true |
|
| 146 | + * @param string $savePath the session save path |
|
| 147 | + * @param string $sessionName the session name |
|
| 148 | + * @return boolean |
|
| 149 | + */ |
|
| 150 | + public function open($savePath, $sessionName){ |
|
| 151 | + $this->logger->debug('Opening database session handler for [' . $sessionName . ']'); |
|
| 152 | + //try to check if session secret is set before |
|
| 153 | + $secret = $this->getSessionSecret(); |
|
| 154 | + if(empty($secret)){ |
|
| 155 | + $secret = get_config('session_secret', null); |
|
| 156 | + $this->setSessionSecret($secret); |
|
| 157 | + } |
|
| 158 | + $this->logger->info('Session secret: ' . $secret); |
|
| 159 | + |
|
| 160 | + if(! $this->getModelInstance()){ |
|
| 161 | + $this->setModelInstanceFromConfig(); |
|
| 162 | + } |
|
| 163 | + $this->setInitializerVector($secret); |
|
| 164 | + |
|
| 165 | + //set session tables columns |
|
| 166 | + $this->sessionTableColumns = $this->getModelInstance()->getSessionTableColumns(); |
|
| 167 | + |
|
| 168 | + if(empty($this->sessionTableColumns)){ |
|
| 169 | + show_error('The session handler is "database" but the table columns not set'); |
|
| 170 | + } |
|
| 171 | + $this->logger->info('Database session, the model columns are listed below: ' . stringfy_vars($this->sessionTableColumns)); |
|
| 172 | 172 | |
| 173 | - //delete the expired session |
|
| 174 | - $timeActivity = get_config('session_inactivity_time', 100); |
|
| 175 | - $this->gc($timeActivity); |
|
| 173 | + //delete the expired session |
|
| 174 | + $timeActivity = get_config('session_inactivity_time', 100); |
|
| 175 | + $this->gc($timeActivity); |
|
| 176 | 176 | |
| 177 | - return true; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * Close the session |
|
| 182 | - * @return boolean |
|
| 183 | - */ |
|
| 184 | - public function close(){ |
|
| 185 | - $this->logger->debug('Closing database session handler'); |
|
| 186 | - return true; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * Get the session value for the given session id |
|
| 191 | - * @param string $sid the session id to use |
|
| 192 | - * @return string the session data in serialiaze format |
|
| 193 | - */ |
|
| 194 | - public function read($sid){ |
|
| 195 | - $this->logger->debug('Reading database session data for SID: ' . $sid); |
|
| 196 | - $instance = $this->getModelInstance(); |
|
| 197 | - $columns = $this->sessionTableColumns; |
|
| 198 | - if($this->getLoader()){ |
|
| 199 | - $this->getLoader()->functions('user_agent'); |
|
| 200 | - $this->getLoader()->library('Browser'); |
|
| 201 | - } |
|
| 202 | - else{ |
|
| 203 | - Loader::functions('user_agent'); |
|
| 204 | - Loader::library('Browser'); |
|
| 177 | + return true; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * Close the session |
|
| 182 | + * @return boolean |
|
| 183 | + */ |
|
| 184 | + public function close(){ |
|
| 185 | + $this->logger->debug('Closing database session handler'); |
|
| 186 | + return true; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * Get the session value for the given session id |
|
| 191 | + * @param string $sid the session id to use |
|
| 192 | + * @return string the session data in serialiaze format |
|
| 193 | + */ |
|
| 194 | + public function read($sid){ |
|
| 195 | + $this->logger->debug('Reading database session data for SID: ' . $sid); |
|
| 196 | + $instance = $this->getModelInstance(); |
|
| 197 | + $columns = $this->sessionTableColumns; |
|
| 198 | + if($this->getLoader()){ |
|
| 199 | + $this->getLoader()->functions('user_agent'); |
|
| 200 | + $this->getLoader()->library('Browser'); |
|
| 201 | + } |
|
| 202 | + else{ |
|
| 203 | + Loader::functions('user_agent'); |
|
| 204 | + Loader::library('Browser'); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - $ip = get_ip(); |
|
| 208 | - $host = @gethostbyaddr($ip) or null; |
|
| 209 | - $browser = $this->OBJ->browser->getPlatform().', '.$this->OBJ->browser->getBrowser().' '.$this->OBJ->browser->getVersion(); |
|
| 207 | + $ip = get_ip(); |
|
| 208 | + $host = @gethostbyaddr($ip) or null; |
|
| 209 | + $browser = $this->OBJ->browser->getPlatform().', '.$this->OBJ->browser->getBrowser().' '.$this->OBJ->browser->getVersion(); |
|
| 210 | 210 | |
| 211 | - $data = $instance->get_by(array($columns['sid'] => $sid, $columns['shost'] => $host, $columns['sbrowser'] => $browser)); |
|
| 212 | - if($data && isset($data->{$columns['sdata']})){ |
|
| 213 | - //checking inactivity |
|
| 214 | - $timeInactivity = time() - get_config('session_inactivity_time', 100); |
|
| 215 | - if($data->{$columns['stime']} < $timeInactivity){ |
|
| 216 | - $this->logger->info('Database session data for SID: ' . $sid . ' already expired, destroy it'); |
|
| 217 | - $this->destroy($sid); |
|
| 218 | - return null; |
|
| 219 | - } |
|
| 220 | - return $this->decode($data->{$columns['sdata']}); |
|
| 221 | - } |
|
| 222 | - $this->logger->info('Database session data for SID: ' . $sid . ' is not valid return false, may be the session ID is wrong'); |
|
| 223 | - return null; |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * Save the session data |
|
| 228 | - * @param string $sid the session ID |
|
| 229 | - * @param mixed $data the session data to save in serialize format |
|
| 230 | - * @return boolean |
|
| 231 | - */ |
|
| 232 | - public function write($sid, $data){ |
|
| 233 | - $this->logger->debug('Saving database session data for SID: ' . $sid . ', data: ' . stringfy_vars($data)); |
|
| 234 | - $instance = $this->getModelInstance(); |
|
| 235 | - $columns = $this->sessionTableColumns; |
|
| 236 | - |
|
| 237 | - if($this->getLoader()){ |
|
| 238 | - $this->getLoader()->functions('user_agent'); |
|
| 239 | - $this->getLoader()->library('Browser'); |
|
| 240 | - } |
|
| 241 | - else{ |
|
| 242 | - Loader::functions('user_agent'); |
|
| 243 | - Loader::library('Browser'); |
|
| 211 | + $data = $instance->get_by(array($columns['sid'] => $sid, $columns['shost'] => $host, $columns['sbrowser'] => $browser)); |
|
| 212 | + if($data && isset($data->{$columns['sdata']})){ |
|
| 213 | + //checking inactivity |
|
| 214 | + $timeInactivity = time() - get_config('session_inactivity_time', 100); |
|
| 215 | + if($data->{$columns['stime']} < $timeInactivity){ |
|
| 216 | + $this->logger->info('Database session data for SID: ' . $sid . ' already expired, destroy it'); |
|
| 217 | + $this->destroy($sid); |
|
| 218 | + return null; |
|
| 219 | + } |
|
| 220 | + return $this->decode($data->{$columns['sdata']}); |
|
| 221 | + } |
|
| 222 | + $this->logger->info('Database session data for SID: ' . $sid . ' is not valid return false, may be the session ID is wrong'); |
|
| 223 | + return null; |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * Save the session data |
|
| 228 | + * @param string $sid the session ID |
|
| 229 | + * @param mixed $data the session data to save in serialize format |
|
| 230 | + * @return boolean |
|
| 231 | + */ |
|
| 232 | + public function write($sid, $data){ |
|
| 233 | + $this->logger->debug('Saving database session data for SID: ' . $sid . ', data: ' . stringfy_vars($data)); |
|
| 234 | + $instance = $this->getModelInstance(); |
|
| 235 | + $columns = $this->sessionTableColumns; |
|
| 236 | + |
|
| 237 | + if($this->getLoader()){ |
|
| 238 | + $this->getLoader()->functions('user_agent'); |
|
| 239 | + $this->getLoader()->library('Browser'); |
|
| 240 | + } |
|
| 241 | + else{ |
|
| 242 | + Loader::functions('user_agent'); |
|
| 243 | + Loader::library('Browser'); |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + $ip = get_ip(); |
|
| 247 | + $keyValue = $instance->getKeyValue(); |
|
| 248 | + $host = @gethostbyaddr($ip) or null; |
|
| 249 | + $browser = $this->OBJ->browser->getPlatform().', '.$this->OBJ->browser->getBrowser().' '.$this->OBJ->browser->getVersion(); |
|
| 250 | + $data = $this->encode($data); |
|
| 251 | + $params = array( |
|
| 252 | + $columns['sid'] => $sid, |
|
| 253 | + $columns['sdata'] => $data, |
|
| 254 | + $columns['stime'] => time(), |
|
| 255 | + $columns['shost'] => $host, |
|
| 256 | + $columns['sbrowser'] => $browser, |
|
| 257 | + $columns['sip'] => $ip, |
|
| 258 | + $columns['skey'] => $keyValue |
|
| 259 | + ); |
|
| 260 | + $this->logger->info('Database session data to save are listed below :' . stringfy_vars($params)); |
|
| 261 | + $exists = $instance->get($sid); |
|
| 262 | + if($exists){ |
|
| 263 | + $this->logger->info('Session data for SID: ' . $sid . ' already exists, just update it'); |
|
| 264 | + //update |
|
| 265 | + unset($params[$columns['sid']]); |
|
| 266 | + $instance->update($sid, $params); |
|
| 244 | 267 | } |
| 268 | + else{ |
|
| 269 | + $this->logger->info('Session data for SID: ' . $sid . ' not yet exists, insert it now'); |
|
| 270 | + $instance->insert($params); |
|
| 271 | + } |
|
| 272 | + return true; |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + |
|
| 276 | + /** |
|
| 277 | + * Destroy the session data for the given session id |
|
| 278 | + * @param string $sid the session id value |
|
| 279 | + * @return boolean |
|
| 280 | + */ |
|
| 281 | + public function destroy($sid){ |
|
| 282 | + $this->logger->debug('Destroy of session data for SID: ' . $sid); |
|
| 283 | + $instance = $this->modelInstanceName; |
|
| 284 | + $instance->delete($sid); |
|
| 285 | + return true; |
|
| 286 | + } |
|
| 245 | 287 | |
| 246 | - $ip = get_ip(); |
|
| 247 | - $keyValue = $instance->getKeyValue(); |
|
| 248 | - $host = @gethostbyaddr($ip) or null; |
|
| 249 | - $browser = $this->OBJ->browser->getPlatform().', '.$this->OBJ->browser->getBrowser().' '.$this->OBJ->browser->getVersion(); |
|
| 250 | - $data = $this->encode($data); |
|
| 251 | - $params = array( |
|
| 252 | - $columns['sid'] => $sid, |
|
| 253 | - $columns['sdata'] => $data, |
|
| 254 | - $columns['stime'] => time(), |
|
| 255 | - $columns['shost'] => $host, |
|
| 256 | - $columns['sbrowser'] => $browser, |
|
| 257 | - $columns['sip'] => $ip, |
|
| 258 | - $columns['skey'] => $keyValue |
|
| 259 | - ); |
|
| 260 | - $this->logger->info('Database session data to save are listed below :' . stringfy_vars($params)); |
|
| 261 | - $exists = $instance->get($sid); |
|
| 262 | - if($exists){ |
|
| 263 | - $this->logger->info('Session data for SID: ' . $sid . ' already exists, just update it'); |
|
| 264 | - //update |
|
| 265 | - unset($params[$columns['sid']]); |
|
| 266 | - $instance->update($sid, $params); |
|
| 267 | - } |
|
| 268 | - else{ |
|
| 269 | - $this->logger->info('Session data for SID: ' . $sid . ' not yet exists, insert it now'); |
|
| 270 | - $instance->insert($params); |
|
| 271 | - } |
|
| 272 | - return true; |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - |
|
| 276 | - /** |
|
| 277 | - * Destroy the session data for the given session id |
|
| 278 | - * @param string $sid the session id value |
|
| 279 | - * @return boolean |
|
| 280 | - */ |
|
| 281 | - public function destroy($sid){ |
|
| 282 | - $this->logger->debug('Destroy of session data for SID: ' . $sid); |
|
| 283 | - $instance = $this->modelInstanceName; |
|
| 284 | - $instance->delete($sid); |
|
| 285 | - return true; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * Clean the expire session data to save espace |
|
| 290 | - * @param integer $maxLifetime the max lifetime |
|
| 291 | - * @return boolean |
|
| 292 | - */ |
|
| 293 | - public function gc($maxLifetime){ |
|
| 294 | - $instance = $this->modelInstanceName; |
|
| 295 | - $time = time() - $maxLifetime; |
|
| 296 | - $this->logger->debug('Garbage collector of expired session. maxLifetime [' . $maxLifetime . '] sec, expired time [' . $time . ']'); |
|
| 297 | - $instance->deleteByTime($time); |
|
| 298 | - return true; |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - /** |
|
| 302 | - * Encode the session data using the openssl |
|
| 303 | - * @param mixed $data the session data to encode |
|
| 304 | - * @return mixed the encoded session data |
|
| 305 | - */ |
|
| 306 | - public function encode($data){ |
|
| 307 | - $key = base64_decode($this->sessionSecret); |
|
| 308 | - $dataEncrypted = openssl_encrypt($data , self::DB_SESSION_HASH_METHOD, $key, OPENSSL_RAW_DATA, $this->getInitializerVector()); |
|
| 309 | - $output = base64_encode($dataEncrypted); |
|
| 310 | - return $output; |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - |
|
| 314 | - /** |
|
| 315 | - * Decode the session data using the openssl |
|
| 316 | - * @param mixed $data the data to decode |
|
| 317 | - * @return mixed the decoded data |
|
| 318 | - */ |
|
| 319 | - public function decode($data){ |
|
| 320 | - $key = base64_decode($this->sessionSecret); |
|
| 321 | - $data = base64_decode($data); |
|
| 322 | - $data = openssl_decrypt($data, self::DB_SESSION_HASH_METHOD, $key, OPENSSL_RAW_DATA, $this->getInitializerVector()); |
|
| 323 | - return $data; |
|
| 324 | - } |
|
| 288 | + /** |
|
| 289 | + * Clean the expire session data to save espace |
|
| 290 | + * @param integer $maxLifetime the max lifetime |
|
| 291 | + * @return boolean |
|
| 292 | + */ |
|
| 293 | + public function gc($maxLifetime){ |
|
| 294 | + $instance = $this->modelInstanceName; |
|
| 295 | + $time = time() - $maxLifetime; |
|
| 296 | + $this->logger->debug('Garbage collector of expired session. maxLifetime [' . $maxLifetime . '] sec, expired time [' . $time . ']'); |
|
| 297 | + $instance->deleteByTime($time); |
|
| 298 | + return true; |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + /** |
|
| 302 | + * Encode the session data using the openssl |
|
| 303 | + * @param mixed $data the session data to encode |
|
| 304 | + * @return mixed the encoded session data |
|
| 305 | + */ |
|
| 306 | + public function encode($data){ |
|
| 307 | + $key = base64_decode($this->sessionSecret); |
|
| 308 | + $dataEncrypted = openssl_encrypt($data , self::DB_SESSION_HASH_METHOD, $key, OPENSSL_RAW_DATA, $this->getInitializerVector()); |
|
| 309 | + $output = base64_encode($dataEncrypted); |
|
| 310 | + return $output; |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + |
|
| 314 | + /** |
|
| 315 | + * Decode the session data using the openssl |
|
| 316 | + * @param mixed $data the data to decode |
|
| 317 | + * @return mixed the decoded data |
|
| 318 | + */ |
|
| 319 | + public function decode($data){ |
|
| 320 | + $key = base64_decode($this->sessionSecret); |
|
| 321 | + $data = base64_decode($data); |
|
| 322 | + $data = openssl_decrypt($data, self::DB_SESSION_HASH_METHOD, $key, OPENSSL_RAW_DATA, $this->getInitializerVector()); |
|
| 323 | + return $data; |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | 326 | |
| 327 | - /** |
|
| 327 | + /** |
|
| 328 | 328 | * Return the loader instance |
| 329 | 329 | * @return object Loader the loader instance |
| 330 | 330 | */ |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | * set the loader instance for future use |
| 337 | 337 | * @param object Loader $loader the loader object |
| 338 | 338 | */ |
| 339 | - public function setLoader($loader){ |
|
| 339 | + public function setLoader($loader){ |
|
| 340 | 340 | $this->loader = $loader; |
| 341 | 341 | return $this; |
| 342 | 342 | } |
@@ -353,47 +353,47 @@ discard block |
||
| 353 | 353 | * set the model instance for future use |
| 354 | 354 | * @param DBSessionHandlerModel $modelInstance the model object |
| 355 | 355 | */ |
| 356 | - public function setModelInstance(DBSessionHandlerModel $modelInstance){ |
|
| 356 | + public function setModelInstance(DBSessionHandlerModel $modelInstance){ |
|
| 357 | 357 | $this->modelInstanceName = $modelInstance; |
| 358 | 358 | return $this; |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | /** |
| 362 | - * Return the Log instance |
|
| 363 | - * @return Log |
|
| 364 | - */ |
|
| 365 | - public function getLogger(){ |
|
| 366 | - return $this->logger; |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * Set the log instance |
|
| 371 | - * @param Log $logger the log object |
|
| 372 | - */ |
|
| 373 | - public function setLogger(Log $logger){ |
|
| 374 | - $this->logger = $logger; |
|
| 375 | - return $this; |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - /** |
|
| 379 | - * Set the model instance using the configuration for session |
|
| 380 | - */ |
|
| 381 | - private function setModelInstanceFromConfig(){ |
|
| 382 | - $modelName = get_config('session_save_path'); |
|
| 383 | - $this->logger->info('The database session model: ' . $modelName); |
|
| 384 | - if($this->getLoader()){ |
|
| 385 | - $this->getLoader()->model($modelName, 'dbsessionhandlerinstance'); |
|
| 386 | - } |
|
| 387 | - //@codeCoverageIgnoreStart |
|
| 388 | - else{ |
|
| 389 | - Loader::model($modelName, 'dbsessionhandlerinstance'); |
|
| 362 | + * Return the Log instance |
|
| 363 | + * @return Log |
|
| 364 | + */ |
|
| 365 | + public function getLogger(){ |
|
| 366 | + return $this->logger; |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * Set the log instance |
|
| 371 | + * @param Log $logger the log object |
|
| 372 | + */ |
|
| 373 | + public function setLogger(Log $logger){ |
|
| 374 | + $this->logger = $logger; |
|
| 375 | + return $this; |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + /** |
|
| 379 | + * Set the model instance using the configuration for session |
|
| 380 | + */ |
|
| 381 | + private function setModelInstanceFromConfig(){ |
|
| 382 | + $modelName = get_config('session_save_path'); |
|
| 383 | + $this->logger->info('The database session model: ' . $modelName); |
|
| 384 | + if($this->getLoader()){ |
|
| 385 | + $this->getLoader()->model($modelName, 'dbsessionhandlerinstance'); |
|
| 386 | + } |
|
| 387 | + //@codeCoverageIgnoreStart |
|
| 388 | + else{ |
|
| 389 | + Loader::model($modelName, 'dbsessionhandlerinstance'); |
|
| 390 | 390 | } |
| 391 | 391 | if(isset($this->OBJ->dbsessionhandlerinstance) && ! $this->OBJ->dbsessionhandlerinstance instanceof DBSessionHandlerModel){ |
| 392 | - show_error('To use database session handler, your class model "'.get_class($this->OBJ->dbsessionhandlerinstance).'" need extends "DBSessionHandlerModel"'); |
|
| 393 | - } |
|
| 394 | - //@codeCoverageIgnoreEnd |
|
| 392 | + show_error('To use database session handler, your class model "'.get_class($this->OBJ->dbsessionhandlerinstance).'" need extends "DBSessionHandlerModel"'); |
|
| 393 | + } |
|
| 394 | + //@codeCoverageIgnoreEnd |
|
| 395 | 395 | |
| 396 | - //set model instance |
|
| 397 | - $this->setModelInstance($this->OBJ->dbsessionhandlerinstance); |
|
| 398 | - } |
|
| 399 | - } |
|
| 396 | + //set model instance |
|
| 397 | + $this->setModelInstance($this->OBJ->dbsessionhandlerinstance); |
|
| 398 | + } |
|
| 399 | + } |
|