Esempio n. 1
0
//Check Whether User Can Manage Downloads
if (!current_user_can('manage_downloads')) {
    wp_die('Access Denied');
}
//init the variables for safe reasons.
$root = '';
$dir = '';
$root = hacklogdm_admin::get_opt('download_path');
$dir = urldecode(hacklogdm_admin::post('dir'));
if (file_exists($root . $dir)) {
    $files = scandir($root . $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 (hacklogdm_admin::is_normal_file($root . $dir, $file) && is_dir($root . $dir . $file)) {
                echo "<li class=\"directory collapsed\"><a href=\"#\" rel=\"" . htmlspecialchars($dir . $file) . "/\">" . htmlspecialchars($file) . "</a></li>";
            }
        }
        // All files
        foreach ($files as $file) {
            if (hacklogdm_admin::is_normal_file($root . $dir, $file) && !is_dir($root . $dir . $file)) {
                $ext = preg_replace('/^.*\\./', '', $file);
                echo "<li class=\"file ext_{$ext}\"><a href=\"#\" rel=\"" . htmlspecialchars($dir . $file) . "\">" . htmlspecialchars($file) . "</a></li>";
            }
        }
        echo "</ul>";
    }
}