. * ************************************************/ /** Changelog : 1.4.0 (02.01.2015) : New maintenance class (compatibility with Piwigo 2.7.x) */ if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); if (!defined('FORCE_HTTPS_PATH')) define('FORCE_HTTPS_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); class Force_HTTPS_maintain extends PluginMaintain { /** * * @param unknown $plugin_version * @param unknown $errors */ function install($plugin_version, &$errors=array()) { $q = 'INSERT INTO '.CONFIG_TABLE.' (param,value,comment) VALUES ("fhp_use_https", "false", "https usage status tag used by the piwigo-force-https plugin");'; pwg_query( $q ); $q = 'INSERT INTO '.CONFIG_TABLE.' (param,value,comment) VALUES ("fhp_use_sts", "false", "HTTP Strict Transport Security (HSTS) usage status tag used by the piwigo-force-https plugin");'; pwg_query( $q ); $q = 'INSERT INTO '.CONFIG_TABLE.' (param,value,comment) VALUES ("fhp_sts_maxage", "500", "max age duration (in seconds) used by the piwigo-force-https plugin");'; pwg_query( $q ); } /** * */ function uninstall() { if (is_dir(PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'piwigo-force-https')) { $this->force_https_deltree(PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'piwigo-force-https'); } $q = 'DELETE FROM '.CONFIG_TABLE.' WHERE param LIKE "fhp_%" LIMIT 6;'; pwg_query( $q ); } /** * */ function deactivate() { } /** * * @param unknown $plugin_version * @param unknown $errors */ function activate($plugin_version, &$errors=array()) { global $conf; if (!isset($conf['fhp_use_https'])) { plugin_install(); $this->install($plugin_version); } } /** * * @param unknown $plugin_version * @param unknown $errors */ function update($old_version, $new_version, &$errors=array()) { } /** * * @param unknown $path */ private function force_https_deltree($path) { if (is_dir($path)) { $fh = opendir($path); while ($file = readdir($fh)) { if ($file != '.' and $file != '..') { $pathfile = $path . '/' . $file; if (is_dir($pathfile)) { force_https_deltree($pathfile); } else { @unlink($pathfile); } } } closedir($fh); return @rmdir($path); } } } ?>