Ho creato velocemente questo esempio http://rockyildog.altervista.org/es/
digito il nome della directory chiamate in questo caso 1 o 2 o 3 poi per listare il contenuto devo inserire il file in ogni singola directory , io invece vorrei un solo file dove gli dico quali directory deve listarmi automaticamente senza bisogno di copiare il file in ogni cartella
grazie
Codice PHP:
<?
$host
=$_SERVER['HTTP_HOST'];
/*
Directory Listing Script - Version 2
====================================

*/
$startdir '.';
$showthumbnails false
$showdirs true;
$forcedownloads false;
$hide = array(
                
'dlf',
                
'public_html',                
                
'index.php',
                
'Thumbs',
                
'.htaccess',
                
'.htpasswd'
            
);
$displayindex false;
$allowuploads false;
$overwrite false;

$indexfiles = array (
                
'index.html',
                
'index.htm',
                
'default.htm',
                
'default.html'
            
);
            
$filetypes = array (
                
'png' => 'jpg.gif',
                
'jpeg' => 'jpg.gif',
                
'bmp' => 'jpg.gif',
                
'jpg' => 'jpg.gif'
                
'gif' => 'gif.gif',
                
'zip' => 'archive.png',
                
'rar' => 'archive.png',
                
'exe' => 'exe.gif',
                
'setup' => 'setup.gif',
                
'txt' => 'text.png',
                
'htm' => 'html.gif',
                
'html' => 'html.gif',
                
'php' => 'php.gif',                
                
'fla' => 'fla.gif',
                
'swf' => 'swf.gif',
                
'xls' => 'xls.gif',
                
'doc' => 'doc.gif',
                
'sig' => 'sig.gif',
                
'fh10' => 'fh10.gif',
                
'pdf' => 'pdf.gif',
                
'psd' => 'psd.gif',
                
'rm' => 'real.gif',
                
'mpg' => 'video.gif',
                
'mpeg' => 'video.gif',
                
'mov' => 'video2.gif',
                
'avi' => 'video.gif',
                
'eps' => 'eps.gif',
                
'gz' => 'archive.png',
                
'asc' => 'sig.gif',
            );
            
error_reporting(0);
if(!
function_exists('imagecreatetruecolor')) $showthumbnails false;
$leadon $startdir;
if(
$leadon=='.'$leadon '';
if((
substr($leadon, -11)!='/') && $leadon!=''$leadon $leadon '/';
$startdir $leadon;

if(
$_GET['dir']) {
    
//check this is okay.
    
    
if(substr($_GET['dir'], -11)!='/') {
        
$_GET['dir'] = $_GET['dir'] . '/';
    }
    
    
$dirok true;
    
$dirnames split('/'$_GET['dir']);
    for(
$di=0$di<sizeof($dirnames); $di++) {
        
        if(
$di<(sizeof($dirnames)-2)) {
            
$dotdotdir $dotdotdir $dirnames[$di] . '/';
        }
        
        if(
$dirnames[$di] == '..') {
            
$dirok false;
        }
    }
    
    if(
substr($_GET['dir'], 01)=='/') {
        
$dirok false;
    }
    
    if(
$dirok) {
         
$leadon $leadon $_GET['dir'];
    }
}



$opendir $leadon;
if(!
$leadon$opendir '.';
if(!
file_exists($opendir)) {
    
$opendir '.';
    
$leadon $startdir;
}

clearstatcache();
if (
$handle opendir($opendir)) {
    while (
false !== ($file readdir($handle))) { 
        
//first see if this file is required in the listing
        
if ($file == "." || $file == "..")  continue;
        
$discard false;
        for(
$hi=0;$hi<sizeof($hide);$hi++) {
            if(
strpos($file$hide[$hi])!==false) {
                
$discard true;
            }
        }
        
        if(
$discard) continue;
        if (@
filetype($leadon.$file) == "dir") {
            if(!
$showdirs) continue;
        
            
$n++;
            if(
$_GET['sort']=="date") {
                
$key = @filemtime($leadon.$file) . ".$n";
            }
            else {
                
$key $n;
            }
            
$dirs[$key] = $file "/";
        }
        else {
            
$n++;
            if(
$_GET['sort']=="date") {
                
$key = @filemtime($leadon.$file) . ".$n";
            }
            elseif(
$_GET['sort']=="size") {
                
$key = @filesize($leadon.$file) . ".$n";
            }
            else {
                
$key $n;
            }
            
$files[$key] = $file;
            
            if(
$displayindex) {
                if(
in_array(strtolower($file), $indexfiles)) {
                    
header("Location: $file");
                    die();
                }
            }
        }
    }
    
closedir($handle); 
}

//sort our files
if($_GET['sort']=="date") {
    @
ksort($dirsSORT_NUMERIC);
    @
ksort($filesSORT_NUMERIC);
}
elseif(
$_GET['sort']=="size") {
    @
natcasesort($dirs); 
    @
ksort($filesSORT_NUMERIC);
}
else {
    @
natcasesort($dirs); 
    @
natcasesort($files);
}

//order correctly
if($_GET['order']=="desc" && $_GET['sort']!="size") {$dirs = @array_reverse($dirs);}
if(
$_GET['order']=="desc") {$files = @array_reverse($files);}
$dirs = @array_values($dirs); $files = @array_values($files);


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Welcome to <? print $host?></title>
<link rel="stylesheet" type="text/css" href="http://www.000webhost.com/images/index/styles.css" />
</head>
<body>
<div id="container">
  
    </p>      
      

demo.</p>
  </div>
  <div id="listingcontainer">
    <div id="listingheader"> 
    <div id="headerfile">File</div>
    <div id="headersize">Size</div>
    <div id="headermodified">Last Modified</div>
    </div>
    <div id="listing">
    <?
    $class 
'b';
    if(
$dirok) {
    
?>
    <div>[url="<?=$dotdotdir;?>"]">[img]http://www.000webhost.com/images/index/dirup.png[/img][b]..[/b] [i]-[/i] <?=date ("M d Y h:i:s A"filemtime($dotdotdir));?>[/url]</div>
    <?
        
if($class=='b'$class='w';
        else 
$class 'b';
    }
    
$arsize sizeof($dirs);
    for(
$i=0;$i<$arsize;$i++) {
    
?>
    <div>[url="<?=$leadon.$dirs[$i];?>"]">[img]http://www.000webhost.com/images/index/folder.png[/img]" />[b]<?=$dirs[$i];?>[/b] [i]-[/i] <?=date ("M d Y h:i:s A"filemtime($leadon.$dirs[$i]));?>[/url]</div>
    <?
        
if($class=='b'$class='w';
        else 
$class 'b';    
    }
    
    
$arsize sizeof($files);
    for(
$i=0;$i<$arsize;$i++) {
        
$icon 'unknown.png';
        
$ext strtolower(substr($files[$i], strrpos($files[$i], '.')+1));
        
$supportedimages = array('gif''png''jpeg''jpg');
        
$thumb '';
                
        if(
$filetypes[$ext]) {
            
$icon $filetypes[$ext];
        }
        
        
$filename $files[$i];
        if(
strlen($filename)>43) {
            
$filename substr($files[$i], 040) . '...';
        }
        
        
$fileurl $leadon $files[$i];
    
?>
    <div>[url="<?=$fileurl;?>"]"<?=$thumb2;?>>[img]http://www.000webhost.com/images/index/<?=$icon;?>[/img]" />[b]<?=$filename;?>[/b] [i]<?=round(filesize($leadon.$files[$i])/1024);?>KB[/i] <?=date ("M d Y h:i:s A"filemtime($leadon.$files[$i]));?><?=$thumb;?>[/url]</div>
    <?
        
if($class=='b'$class='w';
        else 
$class 'b';    
    }    
    
?></div>
  </div>
</div>
<div id="copy">
</body>
</html>
voglio modificare questo codice in modo che esegua un listing automatico delle directory da me scelte