1 | <?php |
---|
2 | /*********************************************** |
---|
3 | * File : admin.php |
---|
4 | * Project : piwigo-force-https |
---|
5 | * Descr : Generate the admin panel |
---|
6 | * |
---|
7 | * Created : 02.05.2013 |
---|
8 | * Updated : 05.03.2014 |
---|
9 | * Author: bonhommedeneige |
---|
10 | * |
---|
11 | * This program is free software: you can redistribute it and/or modify |
---|
12 | * it under the terms of the GNU General Public License as published by |
---|
13 | * the Free Software Foundation, either version 3 of the License, or |
---|
14 | * (at your option) any later version. |
---|
15 | * |
---|
16 | * This program is distributed in the hope that it will be useful, |
---|
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
19 | * GNU General Public License for more details. |
---|
20 | * |
---|
21 | * You should have received a copy of the GNU General Public License |
---|
22 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
23 | * |
---|
24 | ************************************************/ |
---|
25 | |
---|
26 | /** |
---|
27 | Changelog : |
---|
28 | 1.3.0 (05.03.2014) : Upgrade for Piwigo 2.6 compatibility |
---|
29 | 1.1.0 (03.05.2013) : No change yet |
---|
30 | 1.0.0 (02.05.2013) : Initial version |
---|
31 | */ |
---|
32 | |
---|
33 | // Check whether we are indeed included by Piwigo. |
---|
34 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
35 | |
---|
36 | // Setup plugin Language |
---|
37 | load_language('plugin.lang', FORCE_HTTPS_PATH); |
---|
38 | |
---|
39 | // Fetch the template. |
---|
40 | global $template, $conf, $lang; |
---|
41 | |
---|
42 | |
---|
43 | // Test URL |
---|
44 | $tpl_test_https_url = "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
---|
45 | |
---|
46 | // Load parameter |
---|
47 | $tpl_use_https = $conf['fhp_use_https'] ? 'true' : 'false'; |
---|
48 | $tpl_use_sts = $conf['fhp_use_sts'] ? 'true' : 'false'; |
---|
49 | |
---|
50 | // Update conf if submitted in admin site |
---|
51 | if (isset($_POST['submit']) && !empty($_POST['fhp_use_https'])) |
---|
52 | { |
---|
53 | $query = "UPDATE ". CONFIG_TABLE ." SET value='". $_POST['fhp_use_https'] ."' WHERE param='fhp_use_https'"; |
---|
54 | pwg_query($query); |
---|
55 | |
---|
56 | // keep the value in the admin form |
---|
57 | $tpl_use_https = $_POST['fhp_use_https']; |
---|
58 | } |
---|
59 | |
---|
60 | // Update conf if submitted in admin site |
---|
61 | if (isset($_POST['submit']) && !empty($_POST['fhp_use_sts'])) |
---|
62 | { |
---|
63 | $query = "UPDATE ". CONFIG_TABLE ." SET value='". $_POST['fhp_use_sts'] ."' WHERE param='fhp_use_sts'"; |
---|
64 | pwg_query($query); |
---|
65 | |
---|
66 | // keep the value in the admin form |
---|
67 | $tpl_use_sts = $_POST['fhp_use_sts']; |
---|
68 | } |
---|
69 | |
---|
70 | // send value to template |
---|
71 | $template->assign( |
---|
72 | array( |
---|
73 | 'TPL_USE_HTTPS' => $tpl_use_https, |
---|
74 | 'TPL_USE_STS' => $tpl_use_sts, |
---|
75 | 'TPL_TEST_URL' => $tpl_test_https_url |
---|
76 | ) |
---|
77 | ); |
---|
78 | |
---|
79 | // Add our template to the global template |
---|
80 | $template->set_filenames( |
---|
81 | array( |
---|
82 | 'plugin_admin_content' => dirname(__FILE__).'/admin.tpl' |
---|
83 | ) |
---|
84 | ); |
---|
85 | |
---|
86 | // Assign the template contents to ADMIN_CONTENT |
---|
87 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
88 | ?> |
---|