Exemple #1
0
function get_dir_tree($dir, $root = true)
{
    static $tree;
    static $base_dir_length;
    if ($root) {
        $tree = array();
        $base_dir_length = strlen($dir) + 1;
    }
    if (is_file($dir)) {
        $tree[substr($dir, $base_dir_length)] = filemtime($dir);
    } elseif (is_dir($dir) && ($di = dir($dir))) {
        if (!$root) {
            $tree[substr($dir, $base_dir_length)] = false;
        }
        while (($file = $di->read()) !== false) {
            if ($file != "." && $file != "..") {
                get_dir_tree("{$dir}/{$file}", false);
            }
        }
        $di->close();
    }
    if ($root) {
        return $tree;
    }
}
Exemple #2
0
function get_dir_tree(&$tree, $path)
{
    $basedir = dirname($_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF']);
    $basedir = preg_replace("/\\//", "\\/", $basedir . "/images");
    if ($dh = opendir($path)) {
        while (($file = readdir($dh)) !== false) {
            $file_array[] = $file;
        }
    } else {
        return;
    }
    natcasesort($file_array);
    foreach ($file_array as $file) {
        if ($file[0] != "." && filetype($path . $file) == "dir") {
            $file_str = preg_replace("/^{$basedir}/i", "", $path . $file);
            array_push($tree, $file_str . "/");
            get_dir_tree($tree, $path . $file . "/");
        }
    }
}
<?php

header("Content-Type: application/json; charset=utf-8");
// [ToDo]
// * バリデート(個人利用想定なので優先度低)
require_once 'settings.php';
require_once 'functions.php';
require_once 'sqlite.php';
$dir = get_dir_tree();
cache_clean();
// 漫画 ID
$id = $_GET["id"];
$id = intval(str_replace('comic_', '', $id));
if ($id < 1) {
    $id = 1;
}
// 現在のページ
$page = intval($_GET["page"]);
if ($page < 1) {
    $page = 1;
}
$zip_path = COMIC_DIR . "/" . $dir[$id - 1];
$manga_title = get_filename_without_ext($zip_path);
// cache ディレクトリに ZIP 内のファイルを展開
if (!cached($id)) {
    caching($id, $zip_path, $image_ext);
}
// 表示するページのパスを返却
$response = '{"title":"' . get_title($id) . '", "pages":"' . get_pages($id) . '", "files":[';
$load_images = $page + PRELOAD + 2;
for ($i = $page; $i <= $load_images; $i++) {
<?php

require_once 'settings.php';
require_once 'template.php';
require_once 'functions.php';
$tree = get_dir_tree();
start_html();
?>

  <article id="viewer">
    <section id="full_page">
      <div id="page_1" class="right_page"></div>
      <div id="page_2" class="left_page"></div>
      <div class="clear"></div>
    </section>

    <section id="half_page">
      <div class="controllers">
        <div class="next next_control left_control"></div>
        <div class="previous previous_control right_control"></div>
      </div>
      <div id="half_page_image"></div>
      <div class="clear"></div>
    </section>
  </article>

  <nav id="menu">
    <a class="controller next next_control left_control">1 ページ進む</a>
    <a class="controller previous previous_control right_control">1 ページ戻る</a>
    <div class="move_page_wrapper">
      <input type="range" name="slider" id="slider_controller" value="1" min="1" max="1" />
function get_dir_tree($directory, $level = 2)
{
    static $_dirs = array();
    $dir = dir($directory);
    while ($file = $dir->read()) {
        if ($file != '.' && $file != '..') {
            //需要排除的
            if (is_dir("{$directory}/{$file}")) {
                $_dirs[] = "{$directory}/{$file}";
                if ($level) {
                    get_dir_tree("{$directory}/{$file}", $level - 1);
                }
            }
        }
    }
    $dir->close();
    return $_dirs;
}