source: extensions/Force_HTTPS/admin.php @ 23128

Last change on this file since 23128 was 22560, checked in by bonhommedeneige, 8 years ago

Initial commit. Version 1.2.0

File size: 2.6 KB
Line 
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   :   04.05.2013
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/**
27Changelog :
28 1.1.0 (03.05.2013) : No change yet
29 1.0.0 (02.05.2013) : Initial version
30*/
31
32// Check whether we are indeed included by Piwigo.
33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
34
35// Setup plugin Language
36load_language('plugin.lang', FORCE_HTTPS_PATH);
37
38// Fetch the template.
39global $template, $conf, $lang;
40
41
42// Test URL
43$tpl_test_https_url = "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
44
45// Load parameter
46$tpl_use_https = $conf['fhp_use_https'] ? 'true' : 'false';
47$tpl_use_sts = $conf['fhp_use_sts'] ? 'true' : 'false';
48
49// Update conf if submitted in admin site
50if (isset($_POST['submit']) && !empty($_POST['fhp_use_https']))
51{
52        $query = "UPDATE ". CONFIG_TABLE ." SET value='". $_POST['fhp_use_https'] ."' WHERE param='fhp_use_https'";
53        pwg_query($query);
54
55        // keep the value in the admin form
56        $tpl_use_https = $_POST['fhp_use_https'];
57}
58
59// Update conf if submitted in admin site
60if (isset($_POST['submit']) && !empty($_POST['fhp_use_sts']))
61{
62        $query = "UPDATE ". CONFIG_TABLE ." SET value='". $_POST['fhp_use_sts'] ."' WHERE param='fhp_use_sts'";
63        pwg_query($query);
64
65        // keep the value in the admin form
66        $tpl_use_sts = $_POST['fhp_use_sts'];
67}
68
69// send value to template
70$template->assign(
71        array(
72                'TPL_USE_HTTPS'                 => $tpl_use_https,
73                'TPL_USE_STS'           => $tpl_use_sts,
74                'TPL_TEST_URL'          => $tpl_test_https_url
75        )
76);
77
78// Add our template to the global template
79$template->set_filenames(
80        array(
81                'plugin_admin_content' => dirname(__FILE__).'/admin.tpl'
82        ) 
83);
84
85// Assign the template contents to ADMIN_CONTENT
86$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
87?>
Note: See TracBrowser for help on using the repository browser.