From c6a937448894ca7c53eb35419f657958ac15508b Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Sat, 6 Oct 2012 15:10:04 +0200 Subject: [PATCH] Removes folderstatus extension. --- src/_h5ai/client/js/inc/ext/folderstatus.js | 10 ----- src/_h5ai/conf/config.json | 20 +-------- src/_h5ai/server/php/inc/App.php | 48 --------------------- src/_h5ai/server/php/inc/init.php | 4 +- 4 files changed, 3 insertions(+), 79 deletions(-) delete mode 100644 src/_h5ai/client/js/inc/ext/folderstatus.js diff --git a/src/_h5ai/client/js/inc/ext/folderstatus.js b/src/_h5ai/client/js/inc/ext/folderstatus.js deleted file mode 100644 index 09823801..00000000 --- a/src/_h5ai/client/js/inc/ext/folderstatus.js +++ /dev/null @@ -1,10 +0,0 @@ - -modulejs.define('ext/folderstatus', ['_', 'core/settings'], function (_, allsettings) { - - var settings = _.extend({ - enabled: false, - folders: {} - }, allsettings.folderstatus); - - return settings.enabled ? settings.folders : {}; -}); diff --git a/src/_h5ai/conf/config.json b/src/_h5ai/conf/config.json index 2afb5d93..f2cfeb41 100644 --- a/src/_h5ai/conf/config.json +++ b/src/_h5ai/conf/config.json @@ -130,21 +130,6 @@ options, types and langs "enabled": true }, - /* [all] - Associative array of folders and their HTTP status codes to - avoid HEAD requests to that folders. The key (folder) must start - and end with a slash (/). - For example - "/some/folder/": 200 - will always return HTTP status 200 (OK), which will be interpreted - as a non auto indexed folder, that means a folder containing an - appropriate default index file. - */ - "folderstatus": { - "enabled": true, - "folders": {} - }, - /* [all] Adds Google Analytics asynchronous tracking code. @@ -313,10 +298,7 @@ options, types and langs /* [all] Show a folder tree. - Note that this tree might have side effects as it sends HEAD requests - to the folders, and therefore will invoke index.php scripts. Use - "folderstatus" above to avoid such requests. - It might also affect performance significantly. + Note that this might affect performance significantly. Slide tree bar into viewport if there is enough space. */ diff --git a/src/_h5ai/server/php/inc/App.php b/src/_h5ai/server/php/inc/App.php index dea8cb22..1d31a7e7 100644 --- a/src/_h5ai/server/php/inc/App.php +++ b/src/_h5ai/server/php/inc/App.php @@ -152,20 +152,6 @@ class H5ai { return null; } - if ($this->options["folderstatus"]["enabled"]) { - $folders = $this->options["folderstatus"]["folders"]; - if (array_key_exists($absHref, $folders)) { - return $folders[$absHref]; - } - } - - // return $this->fetchHttpCode($absHref); - return $this->guessHttpCode($absHref); - } - - - public function guessHttpCode($absHref) { - $absPath = $this->getAbsPath($absHref); foreach ($this->index_files as $if) { @@ -181,40 +167,6 @@ class H5ai { } - public function fetchHttpCode($absHref) { - - $host = getenv("HTTP_HOST"); - $port = getenv("SERVER_PORT"); - $msg = "HEAD $absHref HTTP/1.1\r\nHost: $host\r\nConnection: Close\r\n"; - if (isset($_SERVER['PHP_AUTH_USER'])) { - $msg .= "Authorization: Basic " . base64_encode($_SERVER['PHP_AUTH_USER'] . ":" . $_SERVER['PHP_AUTH_PW']) . "\r\n"; - } - $msg .= "\r\n"; - - $errno = ""; - $errstr = ""; - $socket = fsockopen($host, $port, $errno, $errstr, 30); - if($socket === 0) { - return null; - } - - fwrite($socket, $msg); - $content = fgets($socket); - $code = intval(trim(substr($content, 9, 4))); - if ($code === 200) { - while ($content !== false && stripos($content, "Content-Type") === false) { - $content = fgets($socket); - } - if (stripos($content, H5ai::$H5AI_CONTENT_TYPE) !== false) { - $code = "h5ai"; - } - } - fclose($socket); - - return $code; - } - - private function fileExists($file) { return is_string($file) && file_exists($file); diff --git a/src/_h5ai/server/php/inc/init.php b/src/_h5ai/server/php/inc/init.php index 146326d1..9b11d170 100644 --- a/src/_h5ai/server/php/inc/init.php +++ b/src/_h5ai/server/php/inc/init.php @@ -14,10 +14,10 @@ function normalized_require_once($lib) { require_once(APP_ABS_PATH . $lib); } -normalized_require_once("/conf/config.php"); +normalized_require_once("/server/php/inc/util.php"); normalized_require_once("/server/php/inc/App.php"); normalized_require_once("/server/php/inc/Entry.php"); -normalized_require_once("/server/php/inc/util.php"); +normalized_require_once("/conf/config.php"); $APP = new H5ai(APP_ABS_PATH, APP_ABS_HREF);