ADDED src/config.dist.php Index: src/config.dist.php ================================================================== --- src/config.dist.php +++ src/config.dist.php @@ -0,0 +1,53 @@ +get('frequence_sauvegardes') && $config->get('nombre_sauvegardes')) +{ + $s = new Sauvegarde; + $s->auto(); +} Index: src/include/class.plugin.php ================================================================== --- src/include/class.plugin.php +++ src/include/class.plugin.php @@ -53,11 +53,11 @@ * Renvoie le chemin absolu vers l'archive du plugin * @return string Chemin PHAR vers l'archive */ public function path() { - return 'phar://' . PLUGINS_PATH . '/' . $this->id . '.phar'; + return 'phar://' . PLUGINS_ROOT . '/' . $this->id . '.phar'; } /** * Renvoie une entrée de la configuration ou la configuration complète * @param string $key Clé à rechercher, ou NULL si on désire toutes les entrées de la @@ -200,11 +200,11 @@ if (file_exists($this->path() . '/uninstall.php')) { include $this->path() . '/uninstall.php'; } - unlink(PLUGINS_PATH . '/' . $this->id . '.phar'); + unlink(PLUGINS_ROOT . '/' . $this->id . '.phar'); $db = DB::getInstance(); return $db->simpleExec('DELETE FROM plugins WHERE id = ?;', $this->id); } @@ -268,11 +268,11 @@ static public function listDownloaded() { $installed = self::listInstalled(); $list = []; - $dir = dir(PLUGINS_PATH); + $dir = dir(PLUGINS_ROOT); while ($file = $dir->read()) { if (substr($file, 0, 1) == '.') continue; @@ -281,11 +281,11 @@ continue; if (array_key_exists($match[1], $installed)) continue; - $list[$match[1]] = parse_ini_file('phar://' . PLUGINS_PATH . '/' . $match[1] . '.phar/garradin_plugin.ini', false); + $list[$match[1]] = parse_ini_file('phar://' . PLUGINS_ROOT . '/' . $match[1] . '.phar/garradin_plugin.ini', false); } $dir->close(); return $list; @@ -346,11 +346,11 @@ $list = self::fetchOfficialList(); if (!array_key_exists($id, $list)) return null; - $hash = sha1_file(PLUGINS_PATH . '/' . $id . '.phar'); + $hash = sha1_file(PLUGINS_ROOT . '/' . $id . '.phar'); return ($hash === $list[$id]['hash']); } /** @@ -379,11 +379,11 @@ if (!array_key_exists($id, $list)) { throw new \LogicException($id . ' n\'est pas un plugin officiel (absent de la liste)'); } - if (file_exists(PLUGINS_PATH . '/' . $id . '.phar')) + if (file_exists(PLUGINS_ROOT . '/' . $id . '.phar')) { throw new UserException('Le plugin '.$id.' existe déjà.'); } $url = parse_url(PLUGINS_URL); @@ -401,20 +401,20 @@ ]; $context = stream_context_create($context_options); try { - copy($list[$id]['phar'], PLUGINS_PATH . '/' . $id . '.phar', $context); + copy($list[$id]['phar'], PLUGINS_ROOT . '/' . $id . '.phar', $context); } catch (\Exception $e) { throw new UserException('Le téléchargement du plugin '.$id.' a échoué : ' . $e->getMessage()); } if (!self::checkHash($id)) { - unlink(PLUGINS_PATH . '/' . $id . '.phar'); + unlink(PLUGINS_ROOT . '/' . $id . '.phar'); throw new \RuntimeException('L\'archive du plugin '.$id.' est corrompue (le hash SHA1 ne correspond pas).'); } self::install($id, true); @@ -427,21 +427,21 @@ * @param boolean $official TRUE si le plugin est officiel * @return boolean TRUE si tout a fonctionné */ static public function install($id, $official = false) { - if (!file_exists('phar://' . PLUGINS_PATH . '/' . $id . '.phar')) + if (!file_exists('phar://' . PLUGINS_ROOT . '/' . $id . '.phar')) { throw new \RuntimeException('Le plugin ' . $id . ' ne semble pas exister et ne peut donc être installé.'); } - if (!file_exists('phar://' . PLUGINS_PATH . '/' . $id . '.phar/garradin_plugin.ini')) + if (!file_exists('phar://' . PLUGINS_ROOT . '/' . $id . '.phar/garradin_plugin.ini')) { throw new UserException('L\'archive '.$id.'.phar n\'est pas une extension Garradin : fichier garradin_plugin.ini manquant.'); } - $infos = parse_ini_file('phar://' . PLUGINS_PATH . '/' . $id . '.phar/garradin_plugin.ini', false); + $infos = parse_ini_file('phar://' . PLUGINS_ROOT . '/' . $id . '.phar/garradin_plugin.ini', false); $required = ['nom', 'description', 'auteur', 'url', 'version', 'menu', 'config']; foreach ($required as $key) { @@ -449,32 +449,32 @@ { throw new \RuntimeException('Le fichier garradin_plugin.ini ne contient pas d\'entrée "'.$key.'".'); } } - if (!empty($infos['menu']) && !file_exists('phar://' . PLUGINS_PATH . '/' . $id . '.phar/www/admin/index.php')) + if (!empty($infos['menu']) && !file_exists('phar://' . PLUGINS_ROOT . '/' . $id . '.phar/www/admin/index.php')) { throw new \RuntimeException('Le plugin '.$id.' ne comporte pas de fichier www/admin/index.php alors qu\'il demande à figurer au menu.'); } $config = ''; if ((bool)$infos['config']) { - if (!file_exists('phar://' . PLUGINS_PATH . '/' . $id . '.phar/config.json')) + if (!file_exists('phar://' . PLUGINS_ROOT . '/' . $id . '.phar/config.json')) { throw new \RuntimeException('L\'archive '.$id.'.phar ne comporte pas de fichier config.json alors que le plugin nécessite le stockage d\'une configuration.'); } - if (!file_exists('phar://' . PLUGINS_PATH . '/' . $id . '.phar/www/admin/config.php')) + if (!file_exists('phar://' . PLUGINS_ROOT . '/' . $id . '.phar/www/admin/config.php')) { throw new \RuntimeException('L\'archive '.$id.'.phar ne comporte pas de fichier www/admin/config.php alors que le plugin nécessite le stockage d\'une configuration.'); } - $config = json_encode(file_get_contents('phar://' . PLUGINS_PATH . '/' . $id . '.phar/config.json')); + $config = json_encode(file_get_contents('phar://' . PLUGINS_ROOT . '/' . $id . '.phar/config.json')); } $db = DB::getInstance(); $db->simpleInsert('plugins', [ 'id' => $id, @@ -486,13 +486,13 @@ 'version' => $infos['version'], 'menu' => (int)(bool)$infos['menu'], 'config' => $config, ]); - if (file_exists('phar://' . PLUGINS_PATH . '/' . $id . '.phar/install.php')) + if (file_exists('phar://' . PLUGINS_ROOT . '/' . $id . '.phar/install.php')) { - include 'phar://' . PLUGINS_PATH . '/' . $id . '.phar/install.php'; + include 'phar://' . PLUGINS_ROOT . '/' . $id . '.phar/install.php'; } return true; } Index: src/include/init.php ================================================================== --- src/include/init.php +++ src/include/init.php @@ -88,20 +88,26 @@ ? $_SERVER['HTTP_HOST'] : (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost'); define('Garradin\WWW_URL', 'http' . (!empty($_SERVER['HTTPS']) ? 's' : '') . '://' . $host . WWW_URI); } -if (!defined('Garradin\PLUGINS_PATH')) +if (!defined('Garradin\PLUGINS_ROOT')) { - define('Garradin\PLUGINS_PATH', DATA_ROOT . '/plugins'); + define('Garradin\PLUGINS_ROOT', DATA_ROOT . '/plugins'); } // Affichage des erreurs par défaut if (!defined('Garradin\SHOW_ERRORS')) { define('Garradin\SHOW_ERRORS', true); } + +// Utilisation de cron pour les tâches automatiques +if (!defined('Garradin\USE_CRON')) +{ + define('Garradin\USE_CRON', false); +} define('Garradin\WEBSITE', 'http://garradin.eu/'); define('Garradin\PLUGINS_URL', 'https://garradin.eu/plugins/list.json'); // PHP devrait être assez intelligent pour chopper la TZ système mais nan @@ -209,10 +215,14 @@
Une erreur s\'est produite à l\'exécution de Garradin. Pour rapporter ce bug merci d\'inclure le message suivant :