From a12a0ce3c524c4edabcbb0e872fbc84fc3bad498 Mon Sep 17 00:00:00 2001 From: Vincent Zanotti Date: Sun, 21 Dec 2008 15:13:17 +0100 Subject: [PATCH] Adds support for disallowed URIs in plat/al's configuration, which are translated into the robots.txt file. Signed-off-by: Vincent Zanotti --- modules/core.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/modules/core.php b/modules/core.php index fa54116..fd8518f 100644 --- a/modules/core.php +++ b/modules/core.php @@ -84,14 +84,25 @@ class CoreModule extends PLModule function handler_robotstxt(&$page) { global $globals; - if (!$globals->core->restricted_platal) { - return PL_NOT_FOUND; + + $disallowed_uris = array(); + if ($globals->core->restricted_platal) { + $disallowed_uris[] = '/'; + } else if (!empty($globals->core->robotstxt_disallowed_uris)) { + $disallowed_uris = preg_split('/[\s,]+/', + $globals->core->robotstxt_disallowed_uris, + -1, PREG_SPLIT_NO_EMPTY); } - header('Content-Type: text/plain'); - echo "User-agent: *\n"; - echo "Disallow: /\n"; - exit; + if (count($disallowed_uris) > 0) { + header('Content-Type: text/plain'); + echo "User-agent: *\n"; + foreach ($disallowed_uris as $uri) { + echo "Disallow: $uri\n"; + } + exit; + } + return PL_NOT_FOUND; } function handler_purge_cache(&$page) -- 2.1.4