Exemple #1
0
function tree($dir = '.', $files = true)
{
    if (!isset($dossiers[0]) || $dossiers[0] != $dir) {
        $dossiers[0] = $dir;
    }
    if (!is_dir($dir) && $files) {
        return array($dir);
    } elseif (!is_dir($dir) && !$files) {
        return array();
    }
    $list = _glob(addslash_if_needed($dir));
    foreach ($list as $dossier) {
        $dossiers = array_merge($dossiers, tree($dossier, $files));
    }
    return $dossiers;
}
Exemple #2
0
// Configuration
$upload_path_size = strlen($_SESSION['upload_root_path'] . $_SESSION['upload_user_path']);
if (empty($_SESSION['mode'])) {
    $mode = 'view';
} else {
    $mode = $_SESSION['mode'];
}
if (empty($_SESSION['filter'])) {
    $mask = '*';
} else {
    $mask = '*' . $_SESSION['filter'] . '*';
}
if (empty($_SESSION['current_path'])) {
    $liste = _glob($_SESSION['upload_root_path'] . $_SESSION['upload_user_path'], $mask);
} else {
    $liste = _glob($_SESSION['upload_root_path'] . $_SESSION['upload_user_path'] . addslash_if_needed($_SESSION['current_path']), $mask);
}
if ($mode == 'move') {
    # Prépare folder tree
    $select_folder = '<select name="destination" class="folder_list button"><option value="">' . e('Choose a folder', false) . '</option>';
    $folders_list = tree($_SESSION['upload_root_path'] . $_SESSION['upload_user_path'], false);
    $folders_list[0] .= '/';
    foreach ($folders_list as $folder) {
        $folder = substr($folder, $upload_path_size);
        $select_folder .= '<option value="' . $folder . '">' . $folder . '</option>';
    }
    $select_folder .= '</select>';
    # Add move dialogbox to the page
    $array = array('#LIST_FILES_SELECT' => $select_folder, '#TOKEN' => returnToken());
    echo template('move_lightbox', $array);
}
Exemple #3
0
if (!isset($shared_folders)) {
    $shared_folders = '';
}
if (!isset($back_link)) {
    $back_link = '';
}
$upload_path_size = strlen($_SESSION['upload_root_path'] . $_SESSION['upload_user_path']);
if (empty($_SESSION['mode'])) {
    $mode = 'view';
} else {
    $mode = $_SESSION['mode'];
}
if (empty($_SESSION['current_path'])) {
    $path_list = $_SESSION['upload_root_path'] . $_SESSION['upload_user_path'];
} else {
    $path_list = $_SESSION['upload_root_path'] . $_SESSION['upload_user_path'] . addslash_if_needed($_SESSION['current_path']);
}
# Building current tree and prepare pagination
if (empty($_SESSION['filter'])) {
    $liste = tree($path_list, null, false, false, $tree);
} else {
    $liste = tree($path_list, null, false, false, $tree);
}
$total_files = count($liste);
$from = 0;
$max_pages = ceil($total_files / $_SESSION['max_files_per_page']);
if (!empty($_GET['from'])) {
    $from = $_GET['from'];
}
$liste = array_slice($liste, $from * $_SESSION['max_files_per_page'], $_SESSION['max_files_per_page']);
$remain = $total_files - ($from + 1) * $_SESSION['max_files_per_page'];
Exemple #4
0
if (!empty($_POST['file']) && !empty($_POST['destination'])) {
    $file = $_POST['file'];
    if ($file == '/') {
        $file = '';
    }
    $destination = $_POST['destination'];
    if ($destination == '/') {
        $destination = '';
    }
    if (check_path($file) && check_path($destination)) {
        if (is_file($_SESSION['upload_path'] . $file) || is_dir($_SESSION['upload_path'] . $file)) {
            $file = stripslashes($file);
            $destination = addslash_if_needed($destination) . basename($file);
            # if file/folder exists in destination folder, change name
            if (is_file($_SESSION['upload_path'] . $destination) || is_dir($_SESSION['upload_path'] . $destination)) {
                $destination = addslash_if_needed($destination) . rename_item(basename($file));
            }
            # move file
            rename($_SESSION['upload_path'] . $file, $_SESSION['upload_path'] . $destination);
            if (!is_dir(dirname('thumbs/' . $destination))) {
                mkdir(dirname('thumbs/' . $destination), 0744, true);
            }
            rename(get_thumbs_name($file), get_thumbs_name($destination));
            # change path in id
            $id = file2id($file);
            $ids = unstore();
            $ids[$id] = $destination;
            store();
        }
    }
    header('location:admin.php');
Exemple #5
0
function tree($folder = null, $user = false, $folders_only = false, $recursive = false, $tree = null)
{
    global $current_tree, $ids;
    if (!empty($current_tree) && !$folders_only && !$recursive) {
        return $current_tree;
    }
    $dir = array();
    if (!$user) {
        $user = $_SESSION['login'];
    }
    if (!$tree) {
        $tree = regen_tree($user);
    }
    if (!empty($current_tree) && $folders_only) {
        $tree = only_folders($current_tree);
    } elseif ($folders_only) {
        $tree = only_folders($tree);
    }
    if (empty($folder)) {
        $folder = $_SESSION['upload_root_path'] . $_SESSION['upload_user_path'] . $_SESSION['current_path'];
    }
    if (!empty($tree)) {
        foreach ($tree as $id => $path) {
            if ($recursive) {
                $p = addslash_if_needed($path);
                $f = addslash_if_needed($folder);
                $match = strpos($p, $f) === 0;
            } else {
                $match = addslash_if_needed(dirname($path)) === addslash_if_needed($folder);
            }
            if (!empty($_SESSION['filter'])) {
                $match = $match && strpos(_basename($path), $_SESSION['filter']) !== false;
            }
            if ($match === true) {
                $dir[$id] = $path;
            }
        }
    } else {
        $dir = array();
    }
    unset($_SESSION['filter']);
    return $dir;
}
Exemple #6
0
if (empty($_SESSION['aspect'])) {
    $_SESSION['aspect'] = $default_aspect;
}
// variable en session pour changer le thème
if (empty($_SESSION['theme'])) {
    $_SESSION['theme'] = $default_theme;
}
if (empty($_SESSION['mode'])) {
    $_SESSION['mode'] = $default_mode;
}
// dossiers pour stocker les fichiers envoyés
if (empty($_SESSION['api_rss_key']) && !empty($_SESSION['login'])) {
    $_SESSION['api_rss_key'] = hash_user($_SESSION['login']);
}
if (empty($_SESSION['upload_root_path'])) {
    $_SESSION['upload_root_path'] = addslash_if_needed($default_path);
}
if (empty($_SESSION['upload_user_path']) && !empty($_SESSION['login'])) {
    $_SESSION['upload_user_path'] = $_SESSION['login'] . '/';
}
if (!is_dir($_SESSION['upload_root_path'])) {
    mkdir($_SESSION['upload_root_path'], 0744, true);
}
if (!empty($_SESSION['upload_user_path']) && !is_dir($_SESSION['upload_root_path'] . $_SESSION['upload_user_path'])) {
    mkdir($_SESSION['upload_root_path'] . $_SESSION['upload_user_path'], 0744, true);
}
// dossier des miniatures
if (!is_dir('thumbs/')) {
    mkdir('thumbs/');
}
if (!is_file('thumbs/.htaccess')) {