示例#1
0
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++) {
    $response .= '"' . get_filepath($id, $i) . '"';
    if ($i == $load_images) {
        $response .= ']}';
    } else {
        $response .= ',';
    }
}
function dir_tree_callback($path)
{
    $length = mb_strlen(COMIC_DIR . "/");
    $path = trim(mb_substr($path, $length));
    $title = get_filename_without_ext($path);
    query("INSERT INTO comics (title, zip_path) values ('" . $title . "', '" . $path . "')");
}