Pour info voici le contenu du fichier et des scripts pour l'affichage.
<?php
/*=====================================================================================================================================
Ce fichier fait partie de "Yexplorer", un explorateur en php par Yoann Lemain.
Yexplorer est sous la license Creative Commons "Paternité - Pas d'Utilisation Commerciale - Partage des Conditions Initiales ŕ l'Identique 2.0 France".
Pour plus de détails, voir : http://creativecommons.org/licenses/by-nc-sa/2.0/fr/.
This file is part of "Yexplorer", a php explorer by Yoaan Lemain.
Yexplorer is under the "Attribution-NonCommercial-ShareAlike 2.0 France" Creative Commons license.
For further details see : http://creativecommons.org/licenses/by-nc-sa/2.0/fr/deed.en_US .
v 1.11
===================================================================================================================================*/
function listing(&$tree, $directory, $treepath, $filespath, $refresh){
if( $refresh || !isset($tree) ){
$tree = array();
getTree($tree, $directory);
}
if( !empty($tree) ) {
$opendirs = array();
$temp $tok strtok($treepath,'/');
while($tok !== false){
$opendirs[] = $temp;
$tok = strtok('/');
$temp = $temp.'/'.$tok;
}
printTree($filespath, $tree, $opendirs, $directory );
}
}
function getTree(&$tree, $root, $dir=null){
if(false !($dir_handle @opendir($root.'/'.$dir))) {
while(false !($subdir readdir($dir_handle))){
if( $subdir !='.' && $subdir !='..' && is_dir($root.'/'.$dir.'/'.$subdir) ) {
if($dir){
$tree[$dir.'/'.$subdir] = $dir;
getTree($tree, $root, $dir.'/'.$subdir);
}else{
$tree[$subdir] = $dir;
getTree($tree, $root, $subdir);
}
}
}
closedir($dir_handle);
}
else
echo 'Unable to open "'.htmlentities($dir).'"';
}
function printTree($filespath, &$tree, $opendirs, $root, $dir=null ){
$subdirs = array_keys($tree, $dir);
sort($subdirs);
foreach($subdirs as $subdir){
if($opendirs)
$open = in_array($subdir, $opendirs);
else
$open=false;
if($open) {
$link=$tree[$subdir];
if($link)
$link='?treepath='.$link;
}
else
$link='?treepath='.$subdir;
if($filespath)
if($link)
$link.='&filespath='.$filespath;
else
$link = '?filespath='.$filespath;
if( in_array($subdir, $tree) ){
echo '
';
echo '[index.php'.$link.' ';
if($open){
echo ']';
}
else {
echo '';
}
}
else
echo '
';
echo '[index.php?treepath='.$subdir.'&filespath='.$subdir.' ';
echo ' ';
$dirname = substr(strrchr($subdir, '/'), 1);
if(!$dirname)
$dirname = $subdir;
echo ' '.$dirname;
echo ']';
if($open){
echo '
';
printTree($filespath, $tree, $opendirs, $root, $subdir);
echo '
';
}
echo '
';
}
}
#=========================================================================================
function printFiles($root, $dir=''){
global $docs_dir;
if(false !($dir_handle @opendir($root.'/'.$dir))) {
if($dir)
$dir.='/';
$filenames = array();
while(false !($filename readdir($dir_handle))){
if( $filename[0] !='.' && is_file($root.'/'.$dir.$filename) ) {
$filenames[]=$filename;
}
}
closedir($dir_handle);
if(isset($filenames)){
sort($filenames);
foreach($filenames as $filename){
$ext = substr($filename, strrpos($filename, '.')+1);
$url = $docs_dir.'/'.$dir.$filename;
if (strlen($filename)>20)
$resized_filename = substr($filename, 0, 17).'...';
else
$resized_filename = $filename;
// Affichage
echo '['.$url.' ';
echo $resized_filename;
if( $ext=='png' || $ext=='jpg' || $ext=='bmp' || $ext=='gif' )
{
$urlforimage = getThumb($url);
$img_size = getimagesize($urlforimage);
echo '';
}
else
echo '';
echo ']';
}
}
}
else
echo 'Unable to open "'.htmlentities($dir).'"';
}
function getThumb($src_url){
$dst_url = 'temp/'.md5($src_url).'.png';
if(!file_exists($dst_url))
{
$size = getimagesize($src_url);
if ($size[0]>$size[1])
$coef = $size[0]/100;
else $coef = $size[1]/100;
if ($coef>1) {
$dest_x = (int)($size[0]/$coef);
$dest_y = (int)($size[1]/$coef);
switch ($size[2])
{
case 1:
$src_img = imagecreatefromgif($src_url);
break;
case 2:
$src_img = imagecreatefromjpeg($src_url);
break;
case 3:
$src_img = imagecreatefrompng($src_url);
break;
case 6:
$src_img = imagecreatefromwbmp($src_url);
break;
}
$dst_img = imageCreatetruecolor($dest_x,$dest_y);
imagealphablending ( $dst_img , false );
imagesavealpha ( $dst_img , true );
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0,$dest_x, $dest_y, $size[0], $size[1]);
imagepng($dst_img, $dst_url);
imagedestroy($src_img);
imagedestroy($dst_img);
}
else
$dst_url = $src_url;
}
return $dst_url;
}
?>