Fixing PHP path and request issues.

This commit is contained in:
Lars Jung 2013-07-14 01:18:59 +02:00
parent bfba6c084c
commit 19eea2b316
2 changed files with 15 additions and 17 deletions

View File

@ -27,9 +27,6 @@ class App {
$this->abs_path = $this->get_abs_path($this->abs_href);
$this->options = load_commented_json($this->app_abs_path . "/conf/options.json");
$this->is_https = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] === 443);
$this->prot_host = 'http' . ($this->is_https ? 's' : '') . '://' . getenv('HTTP_HOST');
}
@ -138,29 +135,30 @@ class App {
public function get_http_code($abs_href) {
if (!is_dir($this->get_abs_path($abs_href))) {
$abs_path = $this->get_abs_path($abs_href);
if (!is_dir($abs_path)) {
return 500;
}
$abs_path = $this->get_abs_path($abs_href);
foreach ($this->options["view"]["indexFiles"] as $if) {
if (file_exists($abs_path . "/" . $if)) {
return 200;
}
}
$rc = 200;
ob_start();
try {
$res = json_decode(file_get_contents($this->prot_host . $abs_href . '?version'));
if ($res->version === '{{pkg.version}}' && $res->href === $this->app_abs_href) {
$rc = App::$MAGIC_SEQUENCE;
$p = $abs_path;
while ($p !== $this->root_abs_path) {
if (@is_dir($p . "/_h5ai/server")) {
return 200;
}
} catch (Exception $e) {}
ob_end_clean();
return $rc;
$pp = normalize_path(dirname($p));
if ($pp === $p) {
return 200;
}
$p = $pp;
}
return App::$MAGIC_SEQUENCE;
}

View File

@ -88,7 +88,7 @@ class Item {
public function get_parent(&$cache) {
$parent_abs_path = normalize_path(dirname($this->abs_path));
if (starts_with($parent_abs_path, $this->app->get_root_abs_path())) {
if ($parent_abs_path !== $this->abs_path && starts_with($parent_abs_path, $this->app->get_root_abs_path())) {
return Item::get($this->app, $parent_abs_path, $cache);
}
return null;