Ejemplo n.º 1
0
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title>ePub Viewer</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width">
        <meta name="apple-mobile-web-app-capable" content="yes">
    </head>

	<?php 
$dir = "../books/epub";
$keyword = $_GET["keyword"];
$filelist = getFileList($dir);
echo "FILE LIST : <br>";
$i = 1;
foreach ($filelist as $val) {
    $name = stringcut($val, $dir . "/", ".");
    echo "[{$i}] : {$name}<br>";
    $i++;
}
unset($val);
//return file list
function getFileList($dir)
{
    $files = scandir($dir);
    $files = array_filter($files, function ($file) {
        return !in_array($file, array('.', '..'));
    });
    $list = array();
    foreach ($files as $file) {
        $fullpath = rtrim($dir, '/') . '/' . $file;
        if (is_file($fullpath)) {
Ejemplo n.º 2
0
<?php

header("Content-Type: text/html; charset=UTF-8");
$dir = "../books";
$keyword = $_GET["keyword"];
$filelist = getFileList($dir);
foreach ($filelist as $val) {
    $name = stringcut($val, "books/", ".");
    $namelist[] = $name;
    if (strpos($name, $keyword) === false) {
        // any process
    } else {
        $resultlist[] = $name;
    }
}
unset($val);
//return file list
function getFileList($dir)
{
    $files = scandir($dir);
    $files = array_filter($files, function ($file) {
        return !in_array($file, array('.', '..'));
    });
    $list = array();
    foreach ($files as $file) {
        $fullpath = rtrim($dir, '/') . '/' . $file;
        if (is_file($fullpath)) {
            $list[] = $fullpath;
        }
        /*
                	if (is_dir($fullpath)) {