diff --git a/README.md b/README.md index 2f9352ea..bc23087e 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ h5ai is provided under the terms of the [MIT License](http://github.com/lrsjng/h * updates es translation * custom headers/footers are now optional and disabled by default * fixes problems with folder recognition in the JS version +* fixes include problems in PHP version +* fixes path problems on servers running on Windows in PHP version ### v0.17 - *2011-11-28* diff --git a/src/_h5ai/config.js b/src/_h5ai/config.js index d0b7035e..ba29658f 100644 --- a/src/_h5ai/config.js +++ b/src/_h5ai/config.js @@ -106,6 +106,7 @@ var H5AI_CONFIG = { * Show thumbnails for image files. */ "showThumbs": true, + "thumbTypes": ["bmp", "gif", "ico", "image", "jpg", "png", "tiff"], /* * Requires PHP on the server. diff --git a/src/_h5ai/config.php b/src/_h5ai/config.php index f901fa31..8096a5b2 100644 --- a/src/_h5ai/config.php +++ b/src/_h5ai/config.php @@ -12,9 +12,8 @@ $H5AI_CONFIG = array(); /* * This configuration assumes that h5ai is installed * in the webroot directory of the Apache server. - * Assumed to end with a slash. */ -$H5AI_CONFIG["ROOT_ABS_PATH"] = dirname(dirname(str_replace('\\', '/', __FILE__))); +$H5AI_CONFIG["ROOT_ABS_PATH"] = safe_dirname(safe_dirname(__FILE__)); /* * Files/folders that should not be listed. Specified diff --git a/src/_h5ai/php/inc/Crumb.php b/src/_h5ai/php/inc/Crumb.php index 9d10ab00..76ac81b8 100644 --- a/src/_h5ai/php/inc/Crumb.php +++ b/src/_h5ai/php/inc/Crumb.php @@ -11,7 +11,7 @@ class Crumb { $this->parts = array(); $href = $h5ai->getAbsHref(); - while ($href !== "/" && $href !== "//") { + while ($href !== "/") { $this->parts[] = $href; $href = safe_dirname($href, true); } diff --git a/src/_h5ai/php/inc/Extended.php b/src/_h5ai/php/inc/Extended.php index f2b8ee7c..e8a47878 100644 --- a/src/_h5ai/php/inc/Extended.php +++ b/src/_h5ai/php/inc/Extended.php @@ -5,7 +5,7 @@ require_h5ai("/php/inc/Thumbnail.php"); class Entry { - private $h5ai, $label, $absPath, $absHref, $date, $isFolder, $type, $size, $thumbTypes; + private $h5ai, $label, $absPath, $absHref, $date, $isFolder, $type, $size; public function __construct($h5ai, $absPath, $absHref, $type = null, $label = null) { @@ -25,8 +25,6 @@ class Entry { $this->type = $type !== null ? $type : $this->h5ai->getType($this->absPath); $this->size = filesize($this->absPath); } - - $this->thumbTypes = array("bmp", "gif", "ico", "image", "jpg", "png", "tiff"); } @@ -59,7 +57,7 @@ class Entry { } } } - if ($this->h5ai->showThumbs() && in_array($this->type, $this->thumbTypes)) { + if ($this->h5ai->showThumbs() && in_array($this->type, $this->h5ai->getThumbTypes())) { $imgClass = " class='thumb' "; $thumbnail = new Thumbnail($this->h5ai, $this->absHref, "square", 16, 16); $thumbnail->create(); @@ -138,7 +136,7 @@ class Extended { } - public function generateHeaders() { + private function generateHeaders() { $html = "\t
  • \n"; $html .= "\t\t\n"; diff --git a/src/_h5ai/php/inc/H5ai.php b/src/_h5ai/php/inc/H5ai.php index 98e88965..6d25807c 100644 --- a/src/_h5ai/php/inc/H5ai.php +++ b/src/_h5ai/php/inc/H5ai.php @@ -126,24 +126,27 @@ class H5ai { } + public function normalizePath($path, $endWithSlash) { + + return preg_match("#^(\w:)?/$#", $path) ? $path : (preg_replace('#/$#', '', $path) . ($endWithSlash ? "/" : "")); + } + + public function getAbsHref($absPath = null, $endWithSlash = true) { if ($absPath === null) { return $this->absHref; } - $absPath=substr($absPath, strlen($this->rootAbsPath)); + $absPath = substr($absPath, strlen($this->rootAbsPath)); $parts = explode("/", $absPath); $encodedParts = array(); foreach ($parts as $part) { $encodedParts[] = rawurlencode($part); } - $endodedAbsHref = implode("/", $encodedParts); - $endodedAbsHref = $this->rootAbsHref . $endodedAbsHref; - - return $this->normalizePath($endodedAbsHref, $endWithSlash); + return $this->normalizePath($this->rootAbsHref . implode("/", $encodedParts), $endWithSlash); } @@ -153,7 +156,7 @@ class H5ai { return $this->absPath; } - $absHref=substr($absHref, strlen($this->rootAbsHref)); + $absHref = substr($absHref, strlen($this->rootAbsHref)); return $this->normalizePath($this->rootAbsPath . "/" . rawurldecode($absHref), false); } @@ -165,6 +168,12 @@ class H5ai { } + public function getThumbTypes() { + + return $this->options["thumbTypes"]; + } + + public function getTitle() { $title = $this->domain . rawurldecode($this->absHref); @@ -233,12 +242,6 @@ class H5ai { } - public function normalizePath($path, $endWithSlash) { - - return $path === "/" ? "/" : (preg_replace('#/$#', '', $path) . ($endWithSlash ? "/" : "")); - } - - public function startsWith($sequence, $start) { return strcasecmp(substr($sequence, 0, strlen($start)), $start) === 0; diff --git a/src/_h5ai/php/inc/Image.php b/src/_h5ai/php/inc/Image.php index 198d04b3..ae71db64 100644 --- a/src/_h5ai/php/inc/Image.php +++ b/src/_h5ai/php/inc/Image.php @@ -78,7 +78,7 @@ class Image { public function releaseDest() { if (!is_null($this->dest)) { - imagedestroy($this->dest); + @imagedestroy($this->dest); $this->dest = null; } } @@ -87,7 +87,7 @@ class Image { public function releaseSource() { if (!is_null($this->source)) { - imagedestroy($this->source); + @imagedestroy($this->source); $this->sourceFile = null; $this->source = null; $this->width = null;