source: extensions/Force_HTTPS/maintain.inc.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      :   maintain.inc.php
4* Project   :   piwigo-force-https
5* Descr     :   Install / Uninstall method
6*
7* Created   :   02.05.2013
8* Updated   :   03.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.2.0 (05.05.2013) : No change
29 1.1.0 (04.05.2013) : Added HSTS security settings
30                      Modified default values at initialization (disabled by default)
31 1.0.0 (02.05.2013) : Initial version
32*/
33
34if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
35define('FORCE_HTTPS_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
36
37function plugin_install()
38{
39        $q = 'INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
40                VALUES ("fhp_use_https", "false", "https usage status tag used by the piwigo-force-https plugin");';
41        pwg_query( $q );
42       
43        $q = 'INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
44                VALUES ("fhp_use_sts", "false", "HTTP Strict Transport Security (HSTS) usage status tag used by the piwigo-force-https plugin");';
45        pwg_query( $q );
46       
47        $q = 'INSERT INTO '.CONFIG_TABLE.' (param,value,comment)
48                VALUES ("fhp_sts_maxage", "500", "max age duration (in seconds) used by the piwigo-force-https plugin");';
49        pwg_query( $q );
50}
51
52function plugin_uninstall()
53{
54        if (is_dir(PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'piwigo-force-https'))
55        {
56                deltree(PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'piwigo-force-https');
57        }
58        $q = 'DELETE FROM '.CONFIG_TABLE.' WHERE param LIKE "fhp_%" LIMIT 6;';
59        pwg_query( $q );
60}
61
62function plugin_activate()
63{
64        global $conf;
65
66        if (!isset($conf['fhp_use_https']))
67        {
68                plugin_install();
69        }
70}
71
72function deltree($path)
73{
74        if (is_dir($path))
75        {
76                $fh = opendir($path);
77                while ($file = readdir($fh))
78                {
79                        if ($file != '.' and $file != '..')
80                        {
81                                $pathfile = $path . '/' . $file;
82                                if (is_dir($pathfile))
83                                {
84                                        deltree($pathfile);
85                                }
86                                else
87                                {
88                                        @unlink($pathfile);
89                                }
90                        }
91                }
92                closedir($fh);
93                return @rmdir($path);
94        }
95}
96?>
Note: See TracBrowser for help on using the repository browser.