Пример #1
0
<?php

require_h5ai("/config.php");
require_h5ai("/php/inc/Cache.php");
class H5ai
{
    private static $VIEWMODES = array("details", "icons");
    private $h5aiAbsPath, $rootAbsPath, $ignore, $ignoreRE, $config, $options, $types, $langs, $cache, $rootAbsHref, $h5aiAbsHref, $domain, $absHref, $absPath, $view;
    public function __construct()
    {
        $this->h5aiAbsPath = H5AI_ABS_PATH;
        global $H5AI_CONFIG;
        $this->rootAbsPath = $H5AI_CONFIG["ROOT_ABS_PATH"];
        $this->ignore = $H5AI_CONFIG["IGNORE"];
        $this->ignoreRE = $H5AI_CONFIG["IGNORE_PATTERNS"];
        $this->config = $this->loadConfig($this->h5aiAbsPath . "/config.js");
        $this->options = $this->config["options"];
        $this->types = $this->config["types"];
        $this->langs = $this->config["langs"];
        $this->cache = new Cache($this->h5aiAbsPath . "/cache");
        $this->rootAbsHref = $this->options["rootAbsHref"];
        $this->h5aiAbsHref = $this->options["h5aiAbsHref"];
        $this->domain = getenv("HTTP_HOST");
        $this->absHref = $this->normalizePath(preg_replace('/\\?.*/', '', getenv("REQUEST_URI")), true);
        $this->absPath = $this->getAbsPath($this->absHref);
        $this->view = $this->options["viewmodes"][0];
        if (!in_array($this->view, H5ai::$VIEWMODES)) {
            $this->view = H5ai::$VIEWMODES[0];
        }
    }
    private function loadConfig($file)
Пример #2
0
<?php

require_h5ai("/php/inc/Thumbnail.php");
class Entry
{
    private $h5ai, $label, $absPath, $absHref, $date, $isFolder, $type, $size;
    public function __construct($h5ai, $absPath, $absHref, $type = null, $label = null)
    {
        $this->h5ai = $h5ai;
        $this->label = $label !== null ? $label : $this->h5ai->getLabel($absHref);
        $this->absPath = $this->h5ai->normalizePath($absPath, false);
        $this->isFolder = is_dir($this->absPath);
        $this->absHref = $this->h5ai->normalizePath($absHref, $this->isFolder);
        $this->date = filemtime($this->absPath);
        if ($this->isFolder) {
            $this->type = $type !== null ? $type : "folder";
            $this->size = "";
        } else {
            $this->type = $type !== null ? $type : $this->h5ai->getType($this->absPath);
            $this->size = filesize($this->absPath);
        }
    }
    public function isFolder()
    {
        return $this->isFolder;
    }
    public function toHtml()
    {
        $classes = "entry " . ($this->isFolder ? "folder " : "file ") . $this->type;
        $imgClass = "";
        $img = $this->type;
Пример #3
0
<?php

function safe_dirname($path, $endWithSlash = false)
{
    $path = str_replace("\\", "/", dirname($path));
    return preg_match("#^(\\w:)?/\$#", $path) ? $path : preg_replace('#/$#', '', $path) . ($endWithSlash ? "/" : "");
}
define("H5AI_ABS_PATH", safe_dirname(safe_dirname(__FILE__)));
function require_h5ai($lib)
{
    require_once H5AI_ABS_PATH . $lib;
}
require_h5ai("/php/inc/H5ai.php");
require_h5ai("/php/inc/Crumb.php");
require_h5ai("/php/inc/Customize.php");
require_h5ai("/php/inc/Extended.php");
require_h5ai("/php/inc/Tree.php");
$h5ai = new H5ai();
$crumb = new Crumb($h5ai);
$customize = new Customize($h5ai);
$extended = new Extended($h5ai);
$tree = new Tree($h5ai);
Пример #4
0
<?php

require_h5ai("/php/inc/Image.php");
class Thumbnail
{
    private $srcAbsHref, $srcAbsPath, $width, $height, $name, $href, $path;
    public static function isUsable()
    {
        return Image::isUsable();
    }
    public function __construct($h5ai, $absHref, $mode, $width, $height)
    {
        $this->h5ai = $h5ai;
        $this->srcAbsHref = $absHref;
        $this->srcAbsPath = $this->h5ai->getRootAbsPath() . urldecode($absHref);
        $this->width = $width;
        $this->height = $height;
        $this->mode = $mode;
        $this->name = sha1("{$this->srcAbsPath}-{$this->width}-{$this->height}-{$this->mode}");
        $this->href = $this->h5ai->getH5aiAbsHref() . "cache/thumb-" . $this->name . ".jpg";
        $this->path = $this->h5ai->getRootAbsPath() . $this->href;
        $this->liveHref = $this->h5ai->api() . "?action=thumb&href=" . $this->srcAbsHref . "&width=" . $this->width . "&height=" . $this->height . "&mode=" . $this->mode;
    }
    public function create($force = 0)
    {
        if ($force === 2 || $force === 1 && !file_exists($this->path) || file_exists($this->path) && filemtime($this->srcAbsPath) >= filemtime($this->path)) {
            $image = new Image();
            $image->setSource($this->srcAbsPath);
            $image->thumb($this->mode, $this->width, $this->height);
            $image->saveDest($this->path);
        }
Пример #5
0
         $image->showDest();
     }
 } else {
     if ($action === "tree") {
         list($href) = checkKeys(array("href"));
         require_h5ai("/php/inc/Tree.php");
         $absHref = trim($href);
         $absPath = $h5ai->getAbsPath($absHref);
         $tree = new TreeEntry($h5ai, $absPath, $absHref);
         $tree->loadContent();
         echo $tree->contentToHtml();
     } else {
         if ($action === "zip") {
             fail(0, "zipped download is disabled", !$options["zippedDownload"]);
             list($hrefs) = checkKeys(array("hrefs"));
             require_h5ai("/php/inc/ZipIt.php");
             $zipit = new ZipIt($h5ai);
             $hrefs = explode(":", trim($hrefs));
             $zipFile = $zipit->zip($hrefs);
             if (is_string($zipFile)) {
                 $response = array('status' => 'ok', 'id' => basename($zipFile), 'size' => filesize($zipFile));
             } else {
                 $response = array('status' => 'failed', 'code' => $zipFile);
             }
             echo json_encode($response);
         } else {
             if ($action === "getzip") {
                 list($id) = checkKeys(array("id"));
                 fail(1, "zipped file not found: " . $id, !preg_match("/^h5ai-zip-/", $id));
                 $zipFile = str_replace("\\", "/", sys_get_temp_dir()) . "/" . $id;
                 fail(2, "zipped file not found: " . $id, !file_exists($zipFile));