Foros del Web » Programando para Internet » PHP »

Ayuda con manejador de archivos/directorios

Estas en el tema de Ayuda con manejador de archivos/directorios en el foro de PHP en Foros del Web. Buenas tengo un problema con un script que me lista en miniatura los archivos y directorios de un directorio. Los directorios y archivos aparecen en ...
  #1 (permalink)  
Antiguo 15/08/2006, 14:45
 
Fecha de Ingreso: agosto-2006
Mensajes: 12
Antigüedad: 17 años, 8 meses
Puntos: 0
Ayuda con manejador de archivos/directorios

Buenas tengo un problema con un script que me lista en miniatura los archivos y directorios de un directorio. Los directorios y archivos aparecen en grande, en el caso de los directorios muestra la imagen correspondiente a una carpeta ubicada en una carpeta "icons". El problema es que cuando hago click sobre un directorio listado ya deja de ejecutarse el script y pierdo la vista en miniatura de mis archivos y directorios. Si por favor me pueden dar una ayuda para hacer esto funcionar, me he estado dando golpes y no lo he logrado.

Este es el codigo del script:
Código PHP:
<?php

class DIRINFO
{
    var 
$root_dir;
    var 
$root_url;
    var 
$date_format="%d %b %y %H:%M";
    var 
$icon = array(
                
'default'=>'none.gif',
                
'File Folder'=>'/icons/dir.gif',
                
'html'=>'/icons/world1.gif');
    var 
$list_detail = array(
        
"Name-url"=>"Name",
        
"Size"=>"Size",
        
"Type"=>"Type",
        
"Modified"=>"Modified"
    
);

    var 
$stat=array( array() );
    var 
$sort=array();

    function 
DIRINFO($root_dir$root_url$filter$icon=NULL$date="")
    {   
// initialize class
        
$this->root_dir $root_dir;
        
$this->root_url $root_url;
        
$this->filter $filter;
        if (
$date != ""$this->date_format $date;
        if ( 
$icon != NULL)
            
$this->icon $icon;
        
// files
        
$this->no_item 0;
        
$dh = ( is_dir($root_dir) ? opendir($root_dir): FALSE);
        foreach ( 
glob("$root_dir/$filter") as $file_full )
        {   
$file basename($file_full);
            if ( 
$file != "." && $file != "..")
            {   
// set index
                
$id $this->no_item;
                
$this->order[$id] = $id;
                
$this->no_item ++;
                
// item info
                
$item="$root_dir/$file";
                
//=== Extract File Information
                
$stat stat($item);
                
//=== Determine Name and Name-url
                
$this->stat[$id]['fname'] = $file;
                
// determine icon
                
$this->stat[$id]['ftype'] = filetype($item);
                if ( 
$this->stat[$id]['ftype'] == "dir" )
                    
$this->stat[$id]['Type'] = "File Folder";
                else  if ( 
$this->stat[$id]['ftype'] == "file")
                   
$this->stat[$id]['Type'] = substr(strrchr($file'.'), );
                else
                   
$this->stat[$id]['Type'] = "Unknown";
                
$icon $this->icon[$this->stat[$id]['Type']];
                if (
$icon == '')
                    
$icon $this->icon['default'];
                
// url
                
$this->stat[$id]['url']=$this->root_url "/$file";
                
// file name
                
$this->stat[$id]['Name'] =
                        
'<IMG class=dir-icon SRC="'.$icon.'"></IMG>&nbsp;'.$file;
                
// file name with url link
               // $this->stat[$id]['Name-url'] =
                 //       '<A HREF="'.$this->stat[$id]['url'].'">'.
                   //     '<IMG class=dir-icon SRC="'.$icon.'"></IMG>&nbsp;'.
                     //   $file."</A>";
                
$this->stat[$id]['icon']=
                        
'<A HREF="'.$this->stat[$id]['url'].'">'.
                        
'<IMG class=dir-icon SRC="'.$icon.'"></IMG><BR/>'.
                        
$file."</A>";
                
//=== Determine Size
                
$this->stat[$id]['Size'] =
                        
$stat['size']. " Byte";
                
//=== Determine Attribute
                
$this->stat[$id]['Attribute'] = $stat['mode'];
                
$this->stat[$id]['Created'] = strftime($this->date_format$stat['ctime']);
                
$this->stat[$id]['Accessed'] = strftime($this->date_format$stat['atime']);
                
$this->stat[$id]['Modified'] = strftime($this->date_format$stat['mtime']);
            }
        } 
// if glob
    
// end GetFileList

    
function Sort($sortkey=array('ftype''Name'))
    {   if (
$this->no_item 0)
        {
            
$this->sort $sortkey;
            
usort($this->order, array($this"DirSort"));
        }
    }

    function 
DirSort($a$b)
    {   
$order=1;
        foreach ( 
$this->sort as  $key )
        {   if ( 
$this->stat[$a][$key] <  $this->stat[$b][$key])
            {   
$order = -1;
                break;
            }
        }
        return 
$order;
    }

    
    function 
DisplayIcon($id=""$no_col=11$attrib=array())
    {
        if (
$attrib==NULL)
            
$attrib=array('icon'=>'Name''Modified'=>'Size');
        echo 
"<TABLE $id>";
        
$count=$no_col;
        if (
$this->no_item 0)
        {   for (
$id 0$id $this->no_item$id ++)
            {   
// Generate new row
                
if ($count == $no_col)
                {   
$count 0;
                    echo 
"<TR>";
                }
                
$count ++;
                
// Print out
                
echo "<TD>";
                
$i $this->order[$id];
                foreach ( 
$attrib as $column=>$desc )
                    echo 
"<SPAN class='$column'>".$this->stat[$i][$column]."</SPAN><BR/>";
                echo 
"\n";
            } 
// for $id
        
// if no_item > 0
        
echo "</TABLE>";
    }


// End class 
?>
  #2 (permalink)  
Antiguo 15/08/2006, 14:57
 
Fecha de Ingreso: agosto-2006
Mensajes: 12
Antigüedad: 17 años, 8 meses
Puntos: 0
No puedo postear el script de ejemplo que ejecuta el script anterior. Tengo este mensaje de advertencia:
1. Usted puede incluir enlaces hacia otros sitios después de haber publicado al menos 15 mensajes.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:25.