Beispiel #1
0
     }
 } else {
     $icone_visu = '';
 }
 #adding edit icon if needed
 if (is_file($fichier) && _mime_content_type($fichier) == 'text/plain' && $extension != 'js' && $extension != 'php' && $extension != 'sphp') {
     $icone_edit = '<a class="edit" href="index.php?p=editor&overwrite=true&file=' . $id . '&token=' . TOKEN . '" title="' . e('Edit this file', false) . '"><span class="icon-edit" ></span></a>';
 } else {
     $icone_edit = '';
 }
 # create item for file or folder
 $fichier_short = substr($fichier, $upload_path_size);
 if (is_dir($fichier)) {
     # Item is a folder
     $current_tree = tree($fichier, null, false, false, $tree);
     if (only_type($current_tree, '.jpg .jpeg .gif .png') || only_type($current_tree, '.mp3 .ogg') || only_type($fichier, '.jpg .jpeg .gif .png') || only_type($fichier, '.mp3 .ogg')) {
         $icone_visu = '<a class="visu" href="index.php?f=' . $id . '" title="' . e('View this share', false) . '"><span class="icon-eye"></span></a>';
     }
     if ($allow_folder_size_stat) {
         $taille = folder_size($fichier);
     } else {
         $taille = '';
     }
     # no share folder button if there's only one user
     if ($mode == 'links' && count($auto_restrict['users']) > 1) {
         $icone_share = '<a class="usershare" title="' . e('Share this folder with another user', false) . '" href="#usershare" data-id="' . $id . '" data-name="' . $fichier_short . '"><span class="icon-users"></span></a>';
     } else {
         $icone_share = '';
     }
     $array = array('#CLASS' => $class, '#ID' => $id, '#FICHIER' => $fichier_short, '#TOKEN' => TOKEN, '#SIZE' => $taille, '#NAME' => $nom, '#USERSHAREBUTTON' => $icone_share, '#TITLE' => $title, '#ICONE_VISU' => $icone_visu, '#SLASHEDNAME' => addslashes($nom), '#SLASHEDFICHIER' => addslashes($fichier_short));
     $folderlist .= template($mode . '_folder_' . $layout, $array);
Beispiel #2
0
function draw_tree($tree = null)
{
    if (!$tree) {
        return false;
    }
    $first = array_keys($tree);
    $second = $first[1];
    $first = $first[0];
    $image_only = only_type($tree, '.jpg .jpeg .gif .png');
    $sound_only = only_type($tree, '.mp3 .ogg');
    if (!$image_only && !$sound_only) {
        # file list tree
        echo '<section class="tree">';
        $tree = array_map(function ($i) {
            return $i . '/';
        }, $tree);
        natcasesort($tree);
        echo '<h1>' . _basename(rtrim($tree[$first], '/\\')) . '</h1>';
        unset($tree[$first]);
        if (empty($tree)) {
            return false;
        }
        $previous_branch = explode('/', $tree[$second]);
        $previous_level = $current_level = count($previous_branch);
        foreach ($tree as $id => $branch) {
            if (!is_dir($branch)) {
                $branch = rtrim($branch, '/\\');
            }
            $current_branch = explode('/', $branch);
            $current_level = count($current_branch);
            if (is_dir($branch) && $previous_level == $current_level) {
                echo '</ul>';
            }
            if ($current_level < $previous_level) {
                $nb = count_back($previous_branch, $current_branch);
                echo str_repeat('</ul>', $nb);
            }
            if (is_dir($branch)) {
                echo '<li class="folder"><span class="icon-folder-1"></span> ' . _basename(rtrim($branch, '/\\')) . '</li>';
                echo '<ul class="folder_content">';
            } elseif (is_file($branch)) {
                $extension = strtolower(pathinfo($branch, PATHINFO_EXTENSION));
                echo '<li><a href="index.php?f=' . $id . '"><span class="icon-file ' . $extension . '"><em>' . $extension . '</em></span> ' . _basename($branch) . '</a></li>';
            }
            $previous_level = $current_level;
            $previous_branch = $current_branch;
        }
        echo '</ul>';
        echo '</section>';
    } elseif ($image_only) {
        # image gallery
        if (!function_exists('auto_thumb')) {
            include 'core/auto_thumb.php';
        }
        global $gallery_thumbs_width;
        $title = explode('/', $tree[$first]);
        $title = $title[count($title) - 1];
        unset($tree[$first]);
        echo '<link rel="stylesheet" type="text/css" href="' . THEME_PATH . '/css/gallery.css">';
        echo '<section><ul class="gallery"><h1>' . $title . '</h1>';
        foreach ($tree as $id => $image) {
            if (is_file($image)) {
                $link = 'index.php?f=' . $id;
                $file = _basename($image);
                $filesize = sizeconvert(filesize($image));
                $ext = strtolower(pathinfo($image, PATHINFO_EXTENSION));
                if ($ext != 'mp4') {
                    $size = getimagesize($image);
                    $size = $size[0] . 'x' . $size[1];
                    auto_thumb($image, $width = $gallery_thumbs_width, $height = $gallery_thumbs_width, $add_to_thumb_filename = '_THUMBGALLERY_', $crop_image = true);
                    echo '<a class="image" data-type="img" data-group="gallery" href="' . $link . '" ><img class="b-lazy" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="' . $link . '&gthumbs" alt="' . $file . '"/><span class="info"><em>' . $file . '</em> ' . $size . ' ' . $filesize . '</span></a>';
                } else {
                    $size = sizeconvert(filesize($image));
                    echo '<a class="image video" data-type="" data-group="gallery" href="' . $link . '" ><img class="blank b-lazy" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="  data-src="' . THEME_PATH . 'img/video.png"/><span class="info"><em>' . $file . '</em>' . $size . '</span></a>';
                }
            }
        }
        echo '</ul></section>';
        echo '
			<script src="core/js/blazy.js"></script>
		    <script>
		        ;(function() {
		            // Initialize
		            var bLazy = new Blazy();
		        })();
		    </script>';
    } elseif ($sound_only) {
        # music player
        $title = explode('/', $tree[$first]);
        $title = $title[count($title) - 1];
        unset($tree[$first]);
        echo '<section class="music_player"><h1>' . $title . '</h1>';
        echo '<table><tr>';
        echo '<td><audio preload autoplay></audio></td>';
        echo '<td id="volume">';
        $mult = 3;
        for ($vol = 1; $vol < 11; $vol++) {
            if ($vol < 10) {
                echo '<span class="volume" data-volume="0.' . $vol . '" style="background-position:center ' . (30 - $vol * $mult) . 'px">&nbsp;</span>';
            } else {
                echo '<span class="volume active"data-volume="1"  style="background-position:center ' . (30 - $vol * $mult) . 'px">&nbsp;</span>';
            }
        }
        echo '</td></tr></table>';
        foreach ($tree as $id => $sound) {
            if (is_file($image)) {
                $link = 'index.php?f=' . $id;
                $file = _basename($sound);
                $ext = strtolower(pathinfo($sound, PATHINFO_EXTENSION));
                $size = sizeconvert(filesize($sound));
                echo '<a class="sound" onclick="play(this);" href="#" data-src="' . $link . '" ><em>' . $file . '</em> ' . $size . '</a>';
            }
        }
        echo '</section>';
        echo '
				<script src="core/js/audio.js"></script>
				<script src="core/js/playlist.js"></script>';
    }
}