From 0889eb332c7b3159065db1a14494d9c18976849b Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Sat, 8 Jul 2006 14:31:59 +0000 Subject: [PATCH] remove clear cache. remove index.php (test.php will replace next commit) git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@389 839d8a87-29fc-0310-9880-83ba4fa771e5 --- classes/Platal.php | 5 ++--- hooks/tmp.inc.php | 2 +- htdocs/.htaccess | 4 +--- htdocs/clear_all_cache.php | 31 ------------------------------- htdocs/index.php | 27 --------------------------- modules/core.php | 20 ++++++++++++++++++++ 6 files changed, 24 insertions(+), 65 deletions(-) delete mode 100644 htdocs/clear_all_cache.php delete mode 100644 htdocs/index.php diff --git a/classes/Platal.php b/classes/Platal.php index d87b9f7..eb536b4 100644 --- a/classes/Platal.php +++ b/classes/Platal.php @@ -92,9 +92,8 @@ class Platal new_skinned_page('index.tpl', AUTH_PUBLIC); if (empty($this->path)) { - $page->run(); - } - + $this->__mods['core']->handler_index($page); + } else switch ($this->call_hook($page)) { case PL_FORBIDDEN: $this->__mods['core']->handler_403($page); diff --git a/hooks/tmp.inc.php b/hooks/tmp.inc.php index 9d44d0d..7763a86 100644 --- a/hooks/tmp.inc.php +++ b/hooks/tmp.inc.php @@ -41,7 +41,7 @@ function tmp_menu() $globals->menu->addPrivateEntry(XOM_ADMIN, 00, 'Marketing', 'marketing'); $globals->menu->addPrivateEntry(XOM_ADMIN, 10, 'Administration', 'admin/'); - $globals->menu->addPrivateEntry(XOM_ADMIN, 20, 'Clear cache', 'clear_all_cache.php'); + $globals->menu->addPrivateEntry(XOM_ADMIN, 20, 'Clear cache', 'purge_cache'); $globals->menu->addPrivateEntry(XOM_ADMIN, 30, 'Trackers', 'http://trackers.polytechnique.org'); $globals->menu->addPrivateEntry(XOM_ADMIN, 40, 'Support', 'http://support.polytechnique.org'); diff --git a/htdocs/.htaccess b/htdocs/.htaccess index 4c8f34b..73d78b6 100644 --- a/htdocs/.htaccess +++ b/htdocs/.htaccess @@ -1,5 +1,3 @@ -DirectoryIndex test.php index.php - Options +FollowSymLinks RewriteEngine on @@ -12,4 +10,4 @@ RewriteRule ^([A-Z].*) wiki.php?n=$1 [L,QSA] # Rewrite URLs of the form 'index.php?q=x': RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d -RewriteRule ^(.*)$ test.php?p=$1 [L,QSA] +RewriteRule ^(.*)$ index.php?p=$1 [L,QSA] diff --git a/htdocs/clear_all_cache.php b/htdocs/clear_all_cache.php deleted file mode 100644 index 187fad8..0000000 --- a/htdocs/clear_all_cache.php +++ /dev/null @@ -1,31 +0,0 @@ -clear_compiled_tpl(); -wiki_clear_all_cache(); - -redirect(empty($_SERVER['HTTP_REFERER']) ? 'index.php' : $_SERVER['HTTP_REFERER']); - -?> diff --git a/htdocs/index.php b/htdocs/index.php deleted file mode 100644 index 90b0807..0000000 --- a/htdocs/index.php +++ /dev/null @@ -1,27 +0,0 @@ -run(); -?> diff --git a/modules/core.php b/modules/core.php index 618c0e5..a18d20c 100644 --- a/modules/core.php +++ b/modules/core.php @@ -27,9 +27,19 @@ class CoreModule extends PLModule '403' => $this->make_hook('403', AUTH_PUBLIC), '404' => $this->make_hook('404', AUTH_PUBLIC), 'exit' => $this->make_hook('exit', AUTH_PUBLIC), + 'purge_cache' => $this->make_hook('purge_cache', AUTH_COOKIE, 'admin') ); } + function handler_index(&$page) + { + if (logged()) { + redirect("login.php"); + } + + return PL_OK; + } + function handler_exit(&$page, $level = null) { if (Session::has('suid')) { @@ -88,6 +98,16 @@ class CoreModule extends PLModule $page->changeTpl('404.tpl'); return PL_OK; } + + function handler_purge_cache(&$page) + { + require_once 'wiki.inc.php'; + + $page->clear_compiled_tpl(); + wiki_clear_all_cache(); + + redirect(empty($_SERVER['HTTP_REFERER']) ? './' : $_SERVER['HTTP_REFERER']); + } } ?> -- 2.1.4