Exemplo n.º 1
0
include PHPFOX_DIR . 'include' . PHPFOX_DS . 'init.inc.php';
$file_list = new FileList();
$_POST['dir'] = urldecode($_POST['dir']);
$root = '';
if (file_exists($root . $_POST['dir'])) {
    $files = scandir($root . $_POST['dir']);
    natcasesort($files);
    if (count($files) > 2) {
        /* The 2 accounts for . and .. */
        echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">";
        // All dirs
        foreach ($files as $file) {
            if (file_exists($root . $_POST['dir'] . $file) && $file != '.' && $file != '..' && is_dir($root . $_POST['dir'] . $file)) {
                $full_path = htmlentities($root . $_POST['dir'] . $file) . "/";
                $file = htmlentities($file);
                $class = $file_list->is_checked_file($full_path) ? 'checked' : '';
                // var_dump($full_path);
                echo "<li class=\"directory collapsed\">\n                                            <a href=\"#\" rel=\"" . htmlentities($_POST['dir'] . $file) . "/\">" . htmlentities($file) . "</a>\n                                            <a href='#' rel='{$full_path}' class='checkbox directory {$class}'></a>\n                                      </li>";
            }
        }
        // All files
        foreach ($files as $file) {
            if (file_exists($root . $_POST['dir'] . $file) && $file != '.' && $file != '..' && !is_dir($root . $_POST['dir'] . $file)) {
                $ext = preg_replace('/^.*\\./', '', $file);
                $full_path = htmlentities($root . $_POST['dir'] . $file);
                $file = htmlentities($file);
                $class = $file_list->is_checked_file($full_path) ? 'checked' : '';
                // var_dump($full_path);
                echo "<li class=\"file ext_{$ext}\">\n                                            <a href=\"#\" rel=\"" . htmlentities($_POST['dir'] . $file) . "\">" . htmlentities($file) . "</a>\n                                            <a href='#' rel='{$full_path}' class='checkbox {$class}'></a> \n                                         </li>";
            }
        }