示例#1
0
文件: ZipIt.php 项目: ryochin/h5ai
 public function zip($hrefs)
 {
     $zipFile = tempnam(sys_get_temp_dir(), "h5ai-zip-");
     $zip = new ZipArchive();
     if (!$zip->open($zipFile, ZIPARCHIVE::CREATE)) {
         return null;
     }
     $zip->addEmptyDir("/");
     foreach ($hrefs as $href) {
         $d = safe_dirname($href, true);
         $n = basename($href);
         $code = $this->h5ai->getHttpCode($d);
         if ($code == 401) {
             return $code;
         }
         if ($code == "h5ai" && !$this->h5ai->ignoreThisFile($n)) {
             $localFile = $this->h5ai->getAbsPath($href);
             $file = preg_replace("!^" . $this->h5ai->getRootAbsPath() . "!", "", $localFile);
             if (is_dir($localFile)) {
                 $rcode = $this->zipDir($zip, $localFile, $file);
                 if ($rcode == 401) {
                     return $rcode;
                 }
             } else {
                 $this->zipFile($zip, $localFile, $file);
             }
         }
     }
     $zip->close();
     return filesize($zipFile) ? $zipFile : null;
 }
示例#2
0
文件: Crumb.php 项目: ryochin/h5ai
 public function __construct($h5ai)
 {
     $this->h5ai = $h5ai;
     $this->parts = array();
     $href = $h5ai->getAbsHref();
     while ($href !== "/") {
         $this->parts[] = $href;
         $href = safe_dirname($href, true);
     }
     $this->parts[] = "/";
     $this->parts = array_reverse($this->parts);
 }
示例#3
0
文件: Extended.php 项目: ryochin/h5ai
 private function loadContent()
 {
     if ($this->h5ai->getAbsHref() !== "/") {
         $options = $this->h5ai->getOptions();
         $parentPath = safe_dirname($this->h5ai->getAbsPath());
         $parentHref = safe_dirname($this->h5ai->getAbsHref(), true);
         $label = $options["setParentFolderLabels"] === true ? $this->h5ai->getLabel($parentHref) : "<span class='l10n-parentDirectory'>Parent Directory</span>";
         $this->parent = new Entry($this->h5ai, $parentPath, $parentHref, "folder-parent", $label);
     }
     $this->content = array();
     $files = $this->h5ai->readDir($this->h5ai->getAbsPath());
     foreach ($files as $file) {
         $absPath = $this->h5ai->getAbsPath() . "/" . $file;
         $absHref = $this->h5ai->getAbsHref() . rawurlencode($file);
         $this->content[$absPath] = new Entry($this->h5ai, $absPath, $absHref);
     }
 }
示例#4
0
<?php

define('APP_BASE_PATH', safe_dirname());
define('APP_FUNCTIONS_PATH', APP_BASE_PATH . '/functions');
define('BASE_URL', 'http://simpleqa.dev/');
define('DB_HOST', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_NAME', 'simpleqa');
function safe_dirname()
{
    $dirname = dirname(dirname(__FILE__));
    return $dirname == '/' ? '' : $dirname;
}
示例#5
0
文件: Tree.php 项目: ryochin/h5ai
 public function getRoot()
 {
     if ($this->absHref === "/") {
         return $this;
     }
     $tree = new TreeEntry($this->h5ai, safe_dirname($this->absPath), safe_dirname($this->absHref, true));
     $tree->loadContent();
     $tree->content[$this->absPath] = $this;
     return $tree->getRoot();
 }
示例#6
0
文件: main.php 项目: ryochin/h5ai
<?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);
示例#7
0
文件: config.php 项目: ryochin/h5ai
<?php

/*
 * h5ai %BUILD_VERSION%
 *
 * PHP Configuration
 * filesystem paths and file ignore rules
 */
global $H5AI_CONFIG;
$H5AI_CONFIG = array("ROOT_ABS_PATH" => safe_dirname(safe_dirname(__FILE__)), "IGNORE" => array(), "IGNORE_PATTERNS" => array("/^\\./", "/^_h5ai/"));