Esempio n. 1
0
 public function getAbsPath($absHref = null)
 {
     if ($absHref === null) {
         return $this->absPath;
     }
     $absHref = substr($absHref, strlen($this->rootAbsHref));
     return H5ai::normalize_path($this->rootAbsPath . "/" . rawurldecode($absHref));
 }
Esempio n. 2
0
 private function add_hrefs($hrefs)
 {
     foreach ($hrefs as $href) {
         $d = H5ai::normalize_path(dirname($href), true);
         $n = basename($href);
         $code = $this->h5ai->getHttpCode($d);
         if ($code == 401) {
             $this->sc401 = true;
         }
         if ($code == "h5ai" && !$this->h5ai->is_ignored($n)) {
             $realFile = $this->h5ai->getAbsPath($href);
             $archivedFile = preg_replace("!^" . H5ai::normalize_path($this->h5ai->getRootAbsPath(), true) . "!", "", $realFile);
             if (is_dir($realFile)) {
                 $this->add_dir($realFile, $archivedFile);
             } else {
                 $this->add_file($realFile, $archivedFile);
             }
         }
     }
 }
Esempio n. 3
0
 private function __construct($h5ai, $absPath, $absHref)
 {
     $this->h5ai = $h5ai;
     $this->absPath = H5ai::normalize_path($absPath);
     $this->isFolder = is_dir($this->absPath);
     $this->absHref = H5ai::normalize_path($absHref, $this->isFolder);
     $this->date = filemtime($this->absPath);
     if ($this->isFolder) {
         $this->size = null;
         $options = $h5ai->getOptions();
         if ($options["foldersize"]["enabled"]) {
             $cmd = str_replace("[DIR]", $this->absPath, Entry::$FOLDER_SIZE_CMD);
             $this->size = intval(preg_replace("/\\s.*\$/", "", `{$cmd}`), 10);
         }
     } else {
         $this->size = filesize($this->absPath);
     }
     $this->parent = null;
     if ($this->absHref !== "/") {
         $this->parent = Entry::get($this->h5ai, H5ai::normalize_path(dirname($this->absPath)), H5ai::normalize_path(dirname($this->absHref), true));
     }
     $this->isContentFetched = false;
     Entry::$cache[$this->absHref] = $this;
 }
Esempio n. 4
0
        exit;
    }
}
function checkKeys($keys)
{
    $values = array();
    foreach ($keys as $key) {
        fail(1, "parameter '{$key}' is missing", !array_key_exists($key, $_REQUEST));
        $values[] = $_REQUEST[$key];
    }
    return $values;
}
list($action) = checkKeys(array("action"));
require_once "config.php";
require_once "inc/H5ai.php";
$h5ai = new H5ai();
$options = $h5ai->getOptions();
if ($action === "httpcodes") {
    list($hrefs) = checkKeys(array("hrefs"));
    function getHttpCodes($h5ai, $hrefs)
    {
        $codes = array();
        foreach ($hrefs as $href) {
            $href = trim($href);
            if (strlen($href) > 0) {
                $codes[$href] = $h5ai->getHttpCode($href);
            }
        }
        return $codes;
    }
    $hrefs = preg_split("/;/", $hrefs);
Esempio n. 5
0
    if (!file_exists($h5ai_php)) {
        function find_h5ai($path, $h5ai)
        {
            if (file_exists($path . $h5ai)) {
                return $path . $h5ai;
            }
            $parent = str_replace("\\", "/", dirname($path));
            if ($parent !== $path) {
                return find_h5ai($parent, $h5ai);
            }
            error_log("h5ai not found: " . __FILE__);
        }
        $h5ai_php = find_h5ai(str_replace("\\", "/", dirname(__FILE__)), "/_h5ai/php/inc/H5ai.php");
    }
    require_once $h5ai_php;
    $h5ai = new H5ai(__FILE__);
    echo $h5ai->getGenericJson();
}
?>
	</div>
	<div id="data-php-no-js-fallback" class="hideOnJs">
		<?php 
if (stripos($_SERVER["REQUEST_METHOD"], "HEAD") === false) {
    echo $h5ai->getNoJsFallback();
}
?>
	</div>
	<script src="/_h5ai/config.js"></script>
	<script src="/_h5ai/js/scripts.js"></script>
</body>
</html>
Esempio n. 6
0
	</div>
	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
	<script>window.jQuery || document.write('<script src="/_h5ai/js/jquery-1.7.2.min.js"><\/script>')</script>
	<script src="/_h5ai/config.js"></script>
	<script src="/_h5ai/js/scripts.js"></script>
	<div id="data-generic-json" class="hidden">
		<?php 
if (stripos($_SERVER["REQUEST_METHOD"], "HEAD") === false) {
    $h5ai_php = str_replace("\\", "/", dirname(__FILE__)) . "/inc/H5ai.php";
    if (!file_exists($h5ai_php)) {
        function find_h5ai($path, $h5ai)
        {
            if (file_exists($path . $h5ai)) {
                return $path . $h5ai;
            }
            $parent = str_replace("\\", "/", dirname($path));
            if ($parent !== $path) {
                return find_h5ai($parent, $h5ai);
            }
            error_log("h5ai not found: " . __FILE__);
        }
        $h5ai_php = find_h5ai(str_replace("\\", "/", dirname(__FILE__)), "/_h5ai/php/inc/H5ai.php");
    }
    require_once $h5ai_php;
    $h5ai = new H5ai(__FILE__);
    echo $h5ai->getGenericJson();
}
?>
	</div>
</body>
</html>
Esempio n. 7
0
File: api.php Progetto: nvdnkpr/h5ai
<?php

require_once str_replace("\\", "/", dirname(__FILE__)) . "/inc/H5ai.php";
$h5ai = new H5ai(__FILE__);
$options = $h5ai->getOptions();
function json_exit($obj)
{
    $obj["code"] = 0;
    echo json_encode($obj);
    exit;
}
function json_fail($code, $msg = "", $cond = true)
{
    if ($cond) {
        echo json_encode(array("code" => $code, "msg" => $msg));
        exit;
    }
}
function check_keys($keys)
{
    $values = array();
    foreach ($keys as $key) {
        json_fail(101, "parameter '{$key}' is missing", !array_key_exists($key, $_REQUEST));
        $values[] = $_REQUEST[$key];
    }
    return $values;
}
list($action) = check_keys(array("action"));
if ($action === "getthumbsrc") {
    if (!$options["thumbnails"]["enabled"]) {
        json_fail(1, "thumbnails disabled");