Exemple #1
0
function listDirectory($dir, $subdir = "")
{
    $files = array_diff(scandir($dir . '\\' . $subdir), array('..', '.'));
    foreach ($files as $file) {
        $file = utf8_encode($file);
        $fileType = pathinfo($file, PATHINFO_EXTENSION);
        if (is_dir($dir . '\\' . $subdir . '\\' . $file)) {
            listDirectory($dir, $subdir . '/' . $file);
        } else {
            $subtitle = false;
            if ($fileType != "mp4" && $fileType != "mkv") {
                continue;
            }
            if (strlen($subdir) == 0) {
                echo '<li><a href="play.php?video=' . $subdir . "/" . $file . '">' . $file . '</a></li>' . "\n";
            } else {
                $lastIndex = strrpos($file, ".");
                $movieName = substr($file, 0, $lastIndex);
                $subtitleName = $dir . '\\' . $subdir . '\\' . $movieName;
                $subtitleExtension = '.srt';
                if (file_exists($subtitleName . '.cht' . $subtitleExtension) || file_exists($subtitleName . '.eng' . $subtitleExtension) || file_exists($subtitleName . $subtitleExtension)) {
                    echo '<li><a href="play.php?video=' . $subdir . "/" . $file . '&subtitle=true">' . $file . '</a></li>' . "\n";
                } else {
                    echo '<li><a href="play.php?video=' . $subdir . "/" . $file . '">' . $file . '</a></li>' . "\n";
                }
            }
        }
    }
}
function copyDir($path, $newPath)
{
    $items = listDirectory($path);
    if (!is_dir($newPath)) {
        mkdir($newPath, octdec(DIRPERMISSIONS));
    }
    foreach ($items as $item) {
        if ($item == '.' || $item == '..') {
            continue;
        }
        $oldPath = RoxyFile::FixPath($path . '/' . $item);
        $tmpNewPath = RoxyFile::FixPath($newPath . '/' . $item);
        if (is_file($oldPath)) {
            copy($oldPath, $tmpNewPath);
        } elseif (is_dir($oldPath)) {
            copyDir($oldPath, $tmpNewPath);
        }
    }
}
function GetDirs($path, $type)
{
    $ret = $sort = array();
    $files = listDirectory(fixPath($path), 0);
    foreach ($files as $f) {
        $fullPath = $path . '/' . $f;
        if (!is_dir(fixPath($fullPath)) || $f == '.' || $f == '..') {
            continue;
        }
        $tmp = getFilesNumber(fixPath($fullPath), $type);
        $ret[$fullPath] = array('path' => $fullPath, 'files' => $tmp['files'], 'dirs' => $tmp['dirs']);
        $sort[$fullPath] = $f;
    }
    natcasesort($sort);
    foreach ($sort as $k => $v) {
        $tmp = $ret[$k];
        echo ',{"p":"' . mb_ereg_replace('"', '\\"', $tmp['path']) . '","f":"' . $tmp['files'] . '","d":"' . $tmp['dirs'] . '"}';
        GetDirs($tmp['path'], $type);
    }
}
Exemple #4
0
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

  Contact: Lyubomir Arsov, liubo (at) web-lobby.com
*/
include '../system.inc.php';
include 'functions.inc.php';
verifyAction('FILESLIST');
checkAccess('FILESLIST');
$path = empty($_GET['d']) ? getFilesPath() : $_GET['d'];
$type = empty($_GET['type']) ? '' : strtolower($_GET['type']);
if ($type != 'image' && $type != 'flash') {
    $type = '';
}
verifyPath($path);
$files = listDirectory(fixPath($path), 0);
natcasesort($files);
$str = '';
echo '[';
foreach ($files as $f) {
    $fullPath = $path . '/' . $f;
    if (!is_file(fixPath($fullPath)) || $type == 'image' && !RoxyFile::IsImage($f) || $type == 'flash' && !RoxyFile::IsFlash($f)) {
        continue;
    }
    $size = filesize(fixPath($fullPath));
    $time = filemtime(fixPath($fullPath));
    $tmp = @getimagesize(fixPath($fullPath));
    $w = 0;
    $h = 0;
    if ($tmp) {
        $w = $tmp[0];
function listDirectory($dir)
{
    $result = array();
    $root = scandir($dir);
    foreach ($root as $value) {
        if ($value === '.' || $value === '..') {
            continue;
        }
        if (is_file("{$dir}{$value}")) {
            $result[] = "{$dir}{$value}";
            continue;
        }
        if (is_dir("{$dir}{$value}")) {
            $result[] = "{$dir}{$value}/";
        }
        foreach (listDirectory("{$dir}{$value}/") as $value) {
            $result[] = $value;
        }
    }
    return $result;
}