Пример #1
0
function _getFiles($rdi, $depth = 0, $dir)
{
    $out = array();
    if (!is_object($rdi)) {
        return $out;
    }
    for ($rdi->rewind(); $rdi->valid(); $rdi->next()) {
        if ($rdi->isDot()) {
            continue;
        }
        if ($rdi->isDir() || $rdi->isFile()) {
            $cur = $rdi->current();
            $cur = str_replace('\\', '/', $cur);
            $cur = str_replace($dir, '', $cur);
            if ($rdi->isDir()) {
                if ($depth == 0) {
                    $out[] = '<optgroup class="bg-gray400" label="' . $cur . '"></optgroup>';
                }
            }
            if ($rdi->isFile()) {
                $file_ext = strtolower(str_replace('.', '', strrchr($cur, '.')));
                if (in_array($file_ext, array('php', 'txt', 'css', 'less', 'js', 'html', 'htm', 'ini', 'sass', 'scss'))) {
                    if (is_writable($rdi->getPathname())) {
                        $out[] = $cur;
                    }
                }
            }
            if ($rdi->hasChildren()) {
                $out1 = _getFiles($rdi->getChildren(), 1 + $depth, $dir);
                $out = array_merge($out, $out1);
            }
        }
    }
    return $out;
}
Пример #2
0
if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}
require_once ENGINE_DIR . 'additions/auth-session.php';
if (!mso_auth('<p class="t-center mar20"><a href="?login" class="button">Login</a></p>')) {
    return;
}
?>
<div class="mar20">

<?php 
$directory = BASE_DIR . 'lpf-content/';
$directory = str_replace('\\', '/', $directory);
$r = new RecursiveDirectoryIterator($directory);
$files = _getFiles($r, 0, $directory);
$content_file = '';
$file_path = '';
$select = '<option value="" selected>-</option>';
foreach ($files as $file) {
    if (strpos($file, 'optgroup') === false) {
        $select .= '<option value="' . base64_encode($file) . '">' . $file . '</option>';
    } else {
        $select .= $file;
    }
}
?>

<p class="mar30-t">Select file <select id="select_file" class="w-auto"><?php 
echo $select;
?>