ScotlandPHP

ftp_rawlist

(PHP 4, PHP 5, PHP 7)

ftp_rawlistFait une liste détaillée des fichiers d'un dossier

Description

mixed ftp_rawlist ( resource $ftp_stream , string $directory [, bool $recursive = false ] )

ftp_rawlist() exécute la commande FTP LIST, et retourne le résultat dans un tableau.

Liste de paramètres

ftp_stream

L'identifiant du lien de connexion FTP.

directory

Le chemin vers le dossier. Peut inclure les arguments pour la commande LIST.

recursive

Si défini à TRUE, la commande sera LIST -R.

Valeurs de retour

Retourne un tableau où les éléments correspondent à une ligne de texte. Retourne FALSE lorsque le paramètre directory est invalide.

La sortie n'est jamais analysée. L'identifiant du type système retourné par la fonction ftp_systype() peut être utilisé pour déterminer comment les résultats doivent être interprétés.

Exemples

Exemple #1 Exemple avec ftp_rawlist()

<?php

// Mise en place d'une connexion basique
$conn_id ftp_connect($ftp_server);

// Identification avec un nom d'utilisateur et un mot de passe
$login_result ftp_login($conn_id$ftp_user_name$ftp_user_pass);

// Récupère la liste des fichiers de /
$buff ftp_rawlist($conn_id'/');

// Fermeture de la connexion
ftp_close($conn_id);

// Affiche le buffer
var_dump($buff);
?>

L'exemple ci-dessus va afficher quelque chose de similaire à :

array(3) {
  [0]=>
  string(65) "drwxr-x---   3 vincent  vincent      4096 Jul 12 12:16 public_ftp"
  [1]=>
  string(66) "drwxr-x---  15 vincent  vincent      4096 Nov  3 21:31 public_html"
  [2]=>
  string(73) "lrwxrwxrwx   1 vincent  vincent        11 Jul 12 12:16 www -> public_html"
}

Voir aussi

  • ftp_nlist() - Retourne la liste des fichiers d'un dossier

add a note add a note

User Contributed Notes 50 notes

up
36
fredvanetten at tinqle dot com
4 years ago
Here's a simple function that'll parse the data returned by ftp_rawlist() into an associative array. I wrote it because some of the functions listed below are way to long, complex or won't work with file names that contain spaces.

<?php
   
function listDetailed($resource, $directory = '.') {
        if (
is_array($children = @ftp_rawlist($resource, $directory))) {
           
$items = array();

            foreach (
$children as $child) {
               
$chunks = preg_split("/\s+/", $child);
                list(
$item['rights'], $item['number'], $item['user'], $item['group'], $item['size'], $item['month'], $item['day'], $item['time']) = $chunks;
               
$item['type'] = $chunks[0]{0} === 'd' ? 'directory' : 'file';
               
array_splice($chunks, 0, 8);
               
$items[implode(" ", $chunks)] = $item;
            }

            return
$items;
        }

       
// Throw exception or return false < up to you
   
}
?>
up
4
mediaboat at gmail dot com
3 years ago
All  parse_rawlist Functions here have one Problem.

when a file starts with a space character like " robots.txt ", it will be ignored.

Rename, delete will fail...
up
3
Johnny Doe
6 years ago
In case anybody wants to get a detailed listing using the MLSD command over a passive connection, the following function might be helpful as a starting point for your own implementation:

<?php
function ftp_mlsd($ftp, $directory) {
   
$ok = @ftp_chdir($ftp, $directory);
    if (!
$ok) {
        return
false;
    }
   
$ret = ftp_raw($ftp, 'PASV');
    if (
preg_match(
       
'/^227.*\(([0-9]+,[0-9]+,[0-9]+,[0-9]+),([0-9]+),([0-9]+)\)$/',
       
$ret[0], $matches)) {
       
$controlIP = str_replace(',', '.', $matches[1]);
       
$controlPort = intval($matches[2])*256+intval($matches[3]);
       
$socket = fsockopen($controlIP, $controlPort);
       
ftp_raw($ftp, 'MLSD');
       
$s = '';
        while (!
feof($socket)) {
           
$s .= fread($socket, 4096);
        }
       
fclose($socket);
       
$files = array();
        foreach (
explode("\n", $s) as $line) {
            if (!
$line) {
                continue;
            }
           
$file = array();
            foreach (
explode(';', $line) as $property) {
                list(
$key, $value) = explode('=', $property);
                if (
$value) {
                   
$file[$key] = $value;
                } else {
                   
$filename = trim($key);
                }
            }
           
$files[$filename] = $file;
        }
        return
$files;
    }
    return
false;
}
?>

Please note that this function ignores the setting of ftp_pasv(). Making the function to work universally for both active and passive connections is left as an exercise to the reader ;-)
up
1
MSpreij at GMail
11 years ago
The following was inspired by a few others here, ofcourse ;-)
Works for filenames with spaces (leading, trailing, consecutive and what not), formats the date a little taking year/time into account, leaves out items not in the $filetypes array below, and returns a nice nested assoc array:

<?php

$filetypes
= array('-'=>'file', 'd'=>'directory', 'l'=>'link');

$c = ftp_connect('localhost');
ftp_login($c, 'jackcrow', 'banshee');
$data = ftp_rawlist($c, '/users/jackcrow');

foreach(
$data as $line) {
    if (
substr(strtolower($line), 0, 5) == 'total') continue; # first line, skip it
   
preg_match('/'. str_repeat('([^\s]+)\s+', 7) .'([^\s]+) (.*)/', $line, $matches); # Here be Dragons
   
list($permissions, $children, $owner, $group, $size, $month, $day, $time, $name) = array_slice($matches, 1);
   
# if it's not a file, directory or link, I don't really care to know about it :-) comment out the next line if you do
   
if (! in_array($permissions[0], array_keys($filetypes))) continue;
   
$type = $filetypes[$permissions[0]];
   
$date = date('d/m/y H:i', (strpos($time, ':') ? mktime(substr($time, 0, 2), substr($time, -2), 0, $month, $day) : mktime(0,0,0,$month, $day, $time) ) );
   
$files[$name] = array('type'=>$type, 'permissions'=>substr($permissions, 1), 'children'=>$children, 'owner'=>$owner, 'group'=>$group, 'size'=>$size, 'date'=>$date);
}

print_r($files);

?>

(I'm using a pretty simple regex pattern (non-space-stuff, whitespace, non-space-stuff etc), but amazingly /it still works!/ K.I.S.S.! The time part in the pattern is done separately to make sure only 1 space is taken out before the filename, which might start with spaces for all you know)
up
2
shaun at shaunfreeman dot co dot uk
7 years ago
Get a listing of all files including hidden files except '.' or '..' use:

<?php
ftp_chdir
($connid, $dir);
ftp_rawlist($connid, "-A");
?>

This had me dancing in circles for some time!
up
2
paul maybe at squirrel mail org
9 years ago
Regarding converting permissions from symbolic notation to octal, note that Hazem dot Khaled at gmail dot com's chmodnum function produces INCORRECT results.  The resutls are base-10 numbers that only LOOK like they are octal numbers.  The function also ignores setuid, setgid and sticky bits, and will produce incorrect numbers if such a file is encountered.  Instead, this brute-force code works.  Maybe there is something more slick, but this isn't too CPU-intensive (note that it assumes you've error-checked that you indeed have a 10-character string!):

      $permissions = 'drwxr-xr-x';  // or whatever
      $mode = 0;

      if ($permissions[1] == 'r') $mode += 0400;
      if ($permissions[2] == 'w') $mode += 0200;
      if ($permissions[3] == 'x') $mode += 0100;
      else if ($permissions[3] == 's') $mode += 04100;
      else if ($permissions[3] == 'S') $mode += 04000;

      if ($permissions[4] == 'r') $mode += 040;
      if ($permissions[5] == 'w') $mode += 020;
      if ($permissions[6] == 'x') $mode += 010;
      else if ($permissions[6] == 's') $mode += 02010;
      else if ($permissions[6] == 'S') $mode += 02000;

      if ($permissions[7] == 'r') $mode += 04;
      if ($permissions[8] == 'w') $mode += 02;
      if ($permissions[9] == 'x') $mode += 01;
      else if ($permissions[9] == 't') $mode += 01001;
      else if ($permissions[9] == 'T') $mode += 01000;

      printf('Mode is %d decimal and %o octal', $mode, $mode);
up
2
weltvolk
9 years ago
With this handy function based on functions presented here you get the file list in alphabetical order with all directories on top:

<?php
function rawlist_dump() {
  global
$ftp_connect;
 
$ftp_rawlist = ftp_rawlist($ftp_connect, ".");
  foreach (
$ftp_rawlist as $v) {
   
$info = array();
   
$vinfo = preg_split("/[\s]+/", $v, 9);
    if (
$vinfo[0] !== "total") {
     
$info['chmod'] = $vinfo[0];
     
$info['num'] = $vinfo[1];
     
$info['owner'] = $vinfo[2];
     
$info['group'] = $vinfo[3];
     
$info['size'] = $vinfo[4];
     
$info['month'] = $vinfo[5];
     
$info['day'] = $vinfo[6];
     
$info['time'] = $vinfo[7];
     
$info['name'] = $vinfo[8];
     
$rawlist[$info['name']] = $info;
    }
  }
 
$dir = array();
 
$file = array();
  foreach (
$rawlist as $k => $v) {
    if (
$v['chmod']{0} == "d") {
     
$dir[$k] = $v;
    } elseif (
$v['chmod']{0} == "-") {
     
$file[$k] = $v;
    }
  }
  foreach (
$dir as $dirname => $dirinfo) {
      echo
"[ $dirname ] " . $dirinfo['chmod'] . " | " . $dirinfo['owner'] . " | " . $dirinfo['group'] . " | " . $dirinfo['month'] . " " . $dirinfo['day'] . " " . $dirinfo['time'] . "<br>";
  }
  foreach (
$file as $filename => $fileinfo) {
      echo
"$filename " . $fileinfo['chmod'] . " | " . $fileinfo['owner'] . " | " . $fileinfo['group'] . " | " . $fileinfo['size'] . " Byte | " . $fileinfo['month'] . " " . $fileinfo['day'] . " " . $fileinfo['time'] . "<br>";
  }
}
rawlist_dump();
?>
up
2
tig3r at poczta dot onet dot pl
12 years ago
Previous example (by davidknoll at o2 dot co dot uk) works well if ftp_systype() returned "UNIX", but sometimes I am experiencing "Windows_NT". Here is some improvement:

<?php
function parsed_listing($path)
{
  
$conn = ftp_connect(FTP_HOST);
  
ftp_login($conn, FTP_USER, FTP_PASS);
  
$systype = ftp_systype($conn_id);
  
$list = ftp_rawlist($conn, "-a ".FTP_BASE.$path);
  
ftp_close($conn);
  
$i = 0;

   foreach (
$list as $current) {
      switch (
$systype) {
         case
"Windows_NT":
        
ereg("([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)",$current,$split);
         if (
is_array($split)) {
            if (
$split[3]<70) { $split[3]+=2000; } else { $split[3]+=1900; } // 4digit year fix
           
$parsed[$i]['isdir'] = ($split[7]=="<DIR>");
           
$parsed[$i]['size'] = $split[7];
           
$parsed[$i]['month'] = $split[1];
           
$parsed[$i]['day'] = $split[2];
           
$parsed[$i]['time/year'] = $split[3];
           
$parsed[$i]['name'] = $split[8];
           
$i++;
         }
         break;

         case
"UNIX":
         default:

// etc.

        
break;
      }
   }
   return
$parsed;
}
?>
up
0
John
7 years ago
There are a couple of php-related reasons given here for ftp_rawlist returning an empty result. However be aware that ZoneAlarm (and possibly other) firewalls can block responses without giving any visible clue so be sure to check that first.
up
0
nospam at advancedonsite dot com
7 years ago
ftp_rawlist kept returning empty file listing, it would work on some machines but not others, it turned out to be ftp_pasv command was needed.
Very frustrating
up
-1
admin at proxy-list dot org
3 years ago
Please pay attention that ftp_rawlist() function returns empty result if there is a folder with space. You must backslash it with addcslashes() function.

IMPORTANT: at the same time any other function like ftp_delete() or ftp_rmdir() in opposite, will not be able to delete file/folder if folder name with space will be backslashes http://proxy-list.org/
up
-1
nickman at freemail dot hu
3 years ago
The solution of fredvanetten at tinqle dot com is nice but needs further evaluation as because of the preg_split and static listing of the variables will produce different values: comparing a file of today or an older, from a previous year:

Array
(
    [time] => 2012
    [day] => 11
    [month] => Sep
    [size] => 37262
    [group] => group
    [user] => owner
    [number] => 1
    [rights] => -rw-rw-rw-
)

Array
(
    [time] => 14:01
    [day] => 23
    [month] => Apr
    [size] => 37262
    [group] => group
    [user] => owner
    [number] => 1
    [rights] => -rw-rw-rw-
)
up
0
ahmadmarafa at gmail dot com
8 years ago
this is function to check for dirs

<?php
function ftp_isdir($connect_id,$dir)
{
    if(
ftp_chdir($connect_id,$dir))
    {
       
ftp_cdup($connect_id);
        return
true;

    }
    else
    {
        return
false;
    }
}
?>
up
0
tmp at gmx dot de
8 years ago
To format the _recrusive_ result of this function I use this:

<?php
$conn_id
= ftp_connect(FTP_SERVER);

$login_result = ftp_login($conn_id, FTP_USR, FTP_PASS);

$rawfiles = ftp_rawlist($conn_id, '/', true);

ftp_close($conn_id);

// here the magic begins!
$structure = array();
$arraypointer = &$structure;
foreach (
$rawfiles as $rawfile) {
    if (
$rawfile[0] == '/') {
       
$paths = array_slice(explode('/', str_replace(':', '', $rawfile)), 1);
       
$arraypointer = &$structure;
        foreach (
$paths as $path) {
            foreach (
$arraypointer as $i => $file) {
                if (
$file['text'] == $path) {
                   
$arraypointer = &$arraypointer[ $i ]['children'];
                    break;
                }
            }
        }
    } elseif(!empty(
$rawfile)) {
       
$info = preg_split("/[\s]+/", $rawfile, 9);       
       
$arraypointer[] = array(
           
'text'   => $info[8],
           
'isDir'  => $info[0]{0} == 'd',
           
'size'   => byteconvert($info[4]),
           
'chmod'  => chmodnum($info[0]),
           
'date'   => strtotime($info[6] . ' ' . $info[5] . ' ' . $info[7]),
           
'raw'    => $info
           
// the 'children' attribut is automatically added if the folder contains at least one file
       
);
    }
}

// in $structure is all the data
print_r($structure);

// little helper functions
function byteconvert($bytes) {
   
$symbol = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
   
$exp = floor( log($bytes) / log(1024) );
    return
sprintf( '%.2f ' . $symbol[ $exp ], ($bytes / pow(1024, floor($exp))) );
}

function
chmodnum($chmod) {
   
$trans = array('-' => '0', 'r' => '4', 'w' => '2', 'x' => '1');
   
$chmod = substr(strtr($chmod, $trans), 1);
   
$array = str_split($chmod, 3);
    return
array_sum(str_split($array[0])) . array_sum(str_split($array[1])) . array_sum(str_split($array[2]));
}

?>
up
0
francois frao_o
8 years ago
Why not using POSIX regex to do the job here ? A preg_replace returns the information in an associative array with the following keys:

<rights>
<number>
<owner>
<group>
<file_size>
<mod_time>
<file>
<type> * that's a bonus: it will tell you if the item is either a file or a directory

Code is shown below:

$list=@ftp_rawlist($con,$directory) ;

$items=array() ;

foreach($list as $_)
preg_replace(

'`^(.{10}+)(\s*)(\d{1})(\s*)(\d*|\w*)'.
'(\s*)(\d*|\w*)(\s*)(\d*)\s'.
'([a-zA-Z]{3}+)(\s*)([0-9]{1,2}+)'.
'(\s*)([0-9]{2}+):([0-9]{2}+)(\s*)(.*)$`Ue',

'$items[]=array(
"rights"=>"$1",
"number"=>"$3",
"owner"=>"$5", "group"=>"$7",
"file_size"=>"$9",
"mod_time"=>"$10 $12 $14:$15",
"file"=>"$17",
"type"=>print_r((preg_match("/^d/","$1"))?"dir":"file",1));',

$_) ; # :p
up
0
www.bosssftp.com
8 years ago
Some FTP servers only allow you to get list of files under current working directory. So if you always get result as empty array (array(0){ }), try changing the cwd befor get the list:

<?php
function ftprawlist($connid, $dir) {
 
ftp_chdir($connid, $dir);
  return
ftp_rawlist($connid, "-a");
}
?>
up
0
phpnet uschlaepfer ch
8 years ago
On my PC (XP and Apache installed) - ftp_rawlist (with Parameter true) does only print a folder list - no subfolders, no files.
So i created this recursive function that writes all filenames (incl. paths) to a array. I tested it on Mac, Linux and Windows - it works (as long as you don't use folders with spaces...).
If you need more information: feel free to set more split[x]-Options and write them to the $files-array.

<?php
# the directory where ftp_rawlist starts
$startdir = "example";

# optional Datatypefilter (leave blank if not needed)
$suffix   = "gif,png,jpeg,pdf,php";
# ftp-login
$ftp_server = "";
$ftp_user   = "";
$ftp_pw     = "";
$ftp_mode   = "";
$conn_id    = ftp_connect($ftp_server);
ftp_login($conn_id, $ftp_user, $ftp_pw) OR die("<br>ftp-login failed");
ftp_pasv($conn_id, true);

#*********************************************************************
# create filelist (recursiv)
#*********************************************************************
$files    = array(); # must be defined here
$files    = raw_list("$startdir");

#*********************************************************************
# print result
#*********************************************************************
$i = 0; $count = count($files);
while (
$i < $count):
  echo
"$files[$i]<br>";
 
$i++;
endwhile;
ftp_close($conn_id);

#*********************************************************************
# rawlist in recursive form (without parameter true!!!)
#*********************************************************************
function raw_list($folder)
{
Global
$conn_id;
Global
$suffix;
Global
$files;
$suffixes = explode(",", $suffix);
$list     = ftp_rawlist($conn_id, $folder);
$anzlist  = count($list);
$i = 0;
while (
$i < $anzlist):
 
$split    = preg_split("/[\s]+/", $list[$i], 9, PREG_SPLIT_NO_EMPTY);
 
$ItemName = $split[8];
 
$endung   = strtolower(substr(strrchr($ItemName,"."),1));
 
$path     = "$folder/$ItemName";
  if (
substr($list[$i],0,1) === "d" AND substr($ItemName,0,1) != "."):
#      array_push($files, $path); # write directory in array if desired
    
raw_list($path);
  elseif (
substr($ItemName,0,2) != "._" AND in_array($endung,$suffixes)):
    
array_push($files, $path);
  endif;
 
$i++;
endwhile;
return
$files;
}
?>

Ueli, Zurich
up
0
ari at bs-inc dot com
11 years ago
This is a little cleaner:

function parse_rawlist( $array )
{
    foreach($array as $curraw)
    {
        $struc = array();
        $current = preg_split("/[\s]+/",$curraw,9);

        $struc['perms']  = $current[0];
        $struc['number'] = $current[1];
        $struc['owner']  = $current[2];
        $struc['group']  = $current[3];
        $struc['size']  = $current[4];
        $struc['month']  = $current[5];
        $struc['day']    = $current[6];
        $struc['time']  = $current[7];
        $struc['year']  = $current[8];
        $struc['raw']  = $curraw;
        $structure[$struc['name']] = $struc;
    }
   return $structure;

}
up
0
kerbpm
11 years ago
Your code is ok, just replace $i = 0 instead of 1
Thank you

<?php

function parse_rawlist( $array ) {

   for (
$i = 1; $i < count($array); $i++ ) {

      
$current = $array[$i];
  
      
$structure[$i]['perms']  = substr($current, 0, 10);
      
$structure[$i]['number'] = trim(substr($current, 11, 3));
      
$structure[$i]['owner']  = trim(substr($current, 15, 8));
      
$structure[$i]['group']  = trim(substr($current, 24, 8));
      
$structure[$i]['size']  = trim(substr($current, 33, 8));
      
$structure[$i]['month']  = trim(substr($current, 42, 3));
      
$structure[$i]['day']    = trim(substr($current, 46, 2));
      
$structure[$i]['time']  = substr($current, 49, 5);
      
$structure[$i]['name']  = substr($current, 55, strlen($current) - 55);

   }

   return
$structure;

}

?>
up
0
admin at mikeholloway dot co dot uk
11 years ago
I was having problems picking up the directories on a mac using cjacobsen at pge dot cl's (11-Jan-05) solution. Slight ammendment to the regexp works for me:

ereg("([-dl][rwxstST-]+).* ?([0-9 ]* )?([a-zA-Z0-9]+).* ([a-zA-Z0-9]+).* ([0-9]*) ([a-zA-Z]+[0-9: ]*[0-9])[ ]+(([0-9]{2}:[0-9]{2})|[0-9]{4}) (.+)", $file, $regs)
up
0
d dot lloyd at tnw dot tudelft dot nl
12 years ago
One comment regaring the method tig3r uses to determine the listing type.

Windows servers can return a listing in unix format if the ftp server has been told to use unix formatting. The only robust solution I have is to try both ereg commands once and see which one successfully returns an array.
up
0
davidknoll at o2 dot co dot uk
12 years ago
Well, this works for me:

<?php
function parsed_listing($path)
{
   
$conn = ftp_connect(FTP_HOST);
   
ftp_login($conn, FTP_USER, FTP_PASS);
   
$list = ftp_rawlist($conn, "-a ".FTP_BASE.$path);
   
ftp_close($conn);
   
$i = 0;
    foreach (
$list as $current) {
       
$split = preg_split("[ ]", $current, 9, PREG_SPLIT_NO_EMPTY);
        if (
$split[0] != "total") {
           
$parsed[$i]['isdir']        = $split[0]{0} === "d";
           
$parsed[$i]['perms']        = $split[0];
           
$parsed[$i]['number']    = $split[1];
           
$parsed[$i]['owner']        = $split[2];
           
$parsed[$i]['group']        = $split[3];
           
$parsed[$i]['size']        = $split[4];
           
$parsed[$i]['month']        = $split[5];
           
$parsed[$i]['day']        = $split[6];
           
$parsed[$i]['time/year']    = $split[7];
           
$parsed[$i]['name']        = $split[8];
           
$i++;
        }
    }
    return
$parsed;
}
?>
up
0
nate at 8networks dot com
12 years ago
this snip fixes the date problem with the listing and sorts out the variables:

$filedata['access_permissions']
$filedata['link_count']
$filedata['uid']
$filedata['gid']
$filedata['size']
$filedata['mod_date_month']
$filedata['mod_date_day']
$filedata['mod_time']
$filedata['name']

list($filedata['access_permissions'], $filedata['link_count'], $filedata['uid'], $filedata['gid'], $filedata['size'], $filedata['mod_date_month'], $filedata['mod_date_day'], $filedata['mod_time'], $filedata['name']) = preg_split("/[\s,]+/", $value);

$filedata['type'] = $filedata['access_permissions']{0};

$filedata['access_permissions'] = substr($filedata['access_permissions'],1);

// now check the date to see if the last modifcation was this year or last.

if ( strrpos($filedata['mod_time'], ':') != 2 ) { $filedata['mod_date'] = $filedata['mod_date_month'] ." " . $filedata['mod_date_day'] . " " . $filedata['mod_time']; $filedata['mod_time'] = "00:00"; } else { $filedata['mod_date'] = $filedata['mod_date_month'] ." " . $filedata['mod_date_day'] . " " . date("Y"); }
up
0
john at nm-design dot com
12 years ago
I'm not a traditional programmer, so I often take a different approach then most programmers. Here's how I get file information from an FTP file list. It's very simple (which I like). Comments are welcome:

    // make your FTP connection calls here, then ...   
    $contents = ftp_rawlist($ftp_id, ".");
   
    echo '<TABLE>';
   
    foreach ($contents as $key => $value) {
   
        $info = explode(" ", $value);
        $clean = array();
        foreach ($info as $key => $value) {
            if (!empty($value)) { $clean[] = $value; }
        } // end foreach loop 2
       
        if ( ($clean[8] != ".") AND ($clean[8] != "..") AND ($clean[8] != "html") AND ($clean[8] != "logs") AND ($clean[8] != "protected") AND ($clean[8] != "sys") ) {
            echo '<TR>';
            print "<TD WIDTH=\"40%\">$clean[8]</TD>"; // name of file
            print "<TD WIDTH=\"20%\" ALIGN=\"CENTER\">$clean[5] $clean[6] $clean[7]</TD>"; // date info
            // prep size
            $size = $clean[4];
            $size = $size / 1000; $size = ceil($size); if ($size <= 0) { $size = 1; }
            if ($size >= 1000) { $measure = "MB"; $size = $size /  1000; } else { $measure = "K"; }
            print "<TD WIDTH=\"20%\" ALIGN=\"CENTER\">$size $measure</TD>"; // size
            echo '<TD WIDTH="20%" ALIGN="CENTER" BGCOLOR="#FFFFE6" CLASS="bodyBold">'; print "<A HREF=\"$PHP_SELF?Submit=DELETE&file=$clean[8]\">"; echo 'DELETE</A></TD>'; // link to delete file
            echo '</TR>';
        } // end if
       
    } // end foreach loop 1
   
    echo '</TABLE>';
up
0
marc dot peterlongo at francetelecom dot com
12 years ago
When you try:

$path = "directory pathname with spaces";
$list = ftp_rawlist($conn_id,$path);

It doesn't work

but when you try:

$path = "directory pathname with spaces";
ftp_chdir($conn_id,$path);
$list = ftp_rawlist($conn_id,".");

It works
up
0
cjacobsen at pge dot cl
12 years ago
Excelent expresion, but don't match SUID, SGUI and Sticky flags when 'x' is disabled. Fix it with [rwxstST-].

<?php

function itemize_dir($contents) {
   foreach (
$contents as $file) {
       if(
ereg("([-dl][rwxstST-]+).* ([0-9]*) ([a-zA-Z0-9]+).* ([a-zA-Z0-9]+).* ([0-9]*) ([a-zA-Z]+[0-9: ]*[0-9])[ ]+(([0-9]{2}:[0-9]{2})|[0-9]{4}) (.+)", $file, $regs)) {
          
$type = (int) strpos("-dl", $regs[1]{0});
          
$tmp_array['line'] = $regs[0];
          
$tmp_array['type'] = $type;
          
$tmp_array['rights'] = $regs[1];
          
$tmp_array['number'] = $regs[2];
          
$tmp_array['user'] = $regs[3];
          
$tmp_array['group'] = $regs[4];
          
$tmp_array['size'] = $regs[5];
          
$tmp_array['date'] = date("m-d",strtotime($regs[6]));
          
$tmp_array['time'] = $regs[7];
          
$tmp_array['name'] = $regs[9];
       }
      
$dir_list[] = $tmp_array;
   }
   return
$dir_list;
}
$buff = ftp_rawlist($cid, "/");
$items = itemize_dir($buff);

?>
up
0
greg at upsdn dot net
12 years ago
list all (including hidden files and dirs):
<?php
  $contents
= ftp_rawlist($conn_id, "-al ".$dir_name);
?>

just as ftp command:
LIST al

"-aF " is equal to '-al', please refer to "ls --help"
up
0
greg at upsdn dot net
12 years ago
The previous regular expression(by Jonathan Almarez,ergye at yahoo dot com and guru at virusas dot lt) is very good.But i found it does not  take into account for directories(number>9)

Change [0-9] to [0-9]*

The code below not only parses:
drwxrwxr-x     9 msik     ia           4096 Nov  5 14:19 Group3

It also parses:
drwxrwxr-x   19 msik     ia           4096 Nov  5 14:19 Group3
3
drwxrwxr-x   119 msik     ia           4096 Nov  5 14:19 Group3
3

0 = file
1 = directory
2 = simlink
<?php

function itemize_dir($contents) {
   foreach (
$contents as $file) {
       if(
ereg("([-dl][rwxst-]+).* ([0-9]*) ([a-zA-Z0-9]+).* ([a-zA-Z0-9]+).* ([0-9]*) ([a-zA-Z]+[0-9: ]*[0-9])[ ]+(([0-9]{2}:[0-9]{2})|[0-9]{4}) (.+)", $file, $regs)) {
          
$type = (int) strpos("-dl", $regs[1]{0});
          
$tmp_array['line'] = $regs[0];
          
$tmp_array['type'] = $type;
          
$tmp_array['rights'] = $regs[1];
          
$tmp_array['number'] = $regs[2];
          
$tmp_array['user'] = $regs[3];
          
$tmp_array['group'] = $regs[4];
          
$tmp_array['size'] = $regs[5];
          
$tmp_array['date'] = date("m-d",strtotime($regs[6]));
          
$tmp_array['time'] = $regs[7];
          
$tmp_array['name'] = $regs[9];
       }
      
$dir_list[] = $tmp_array;
   }
   return
$dir_list;
}
$buff = ftp_rawlist($cid, "/");
$items = itemize_dir($buff);

?>
up
0
Jonathan Almarez
12 years ago
To make the latest correction to the parsing code:

"ergye at yahoo dot com" dosen't take into account for files or directories that are older than a year where instead of showing the time, it shows the year.

The code below not only parses:
drwxrwxr-x   2 503      503          4096 Dec  3 12:12 CVAR

It also parses:
drwxrwxr-x   2 503      503          4096 Dec  3  2003 CVAR

0 = file
1 = directory
2 = simlink
<?php

function itemize_dir($contents) {
   foreach (
$contents as $file) {
       if(
ereg("([-dl][rwxst-]+).* ([0-9]) ([a-zA-Z0-9]+).* ([a-zA-Z0-9]+).* ([0-9]*) ([a-zA-Z]+[0-9: ]*[0-9])[ ]+(([0-9]{2}:[0-9]{2})|[0-9]{4}) (.+)", $file, $regs)) {
          
$type = (int) strpos("-dl", $regs[1]{0});
          
$tmp_array['line'] = $regs[0];
          
$tmp_array['type'] = $type;
          
$tmp_array['rights'] = $regs[1];
          
$tmp_array['number'] = $regs[2];
          
$tmp_array['user'] = $regs[3];
          
$tmp_array['group'] = $regs[4];
          
$tmp_array['size'] = $regs[5];
          
$tmp_array['date'] = date("m-d",strtotime($regs[6]));
          
$tmp_array['time'] = $regs[7];
          
$tmp_array['name'] = $regs[9];
       }
      
$dir_list[] = $tmp_array;
   }
   return
$dir_list;
}
$buff = ftp_rawlist($cid, "/");
$items = itemize_dir($buff);

?>
up
0
Anonymous
12 years ago
Note that there is no standard for the format, therefore don't be suprised when parsing routines for this work perfectly on some servers, and fail horribly on some.
up
0
ergye at yahoo dot com
13 years ago
The previous regular expression is super, but does not take simlinks into account. Change [-d] to [-dl] and instead of indicating directories we should indicate the type of the items:

0 = file
1 = directory
2 = simlink

<?php

function itemize_dir($contents) {
    foreach (
$contents as $file) {
        if(
ereg("([-dl][rwxst-]+).* ([0-9]) ([a-zA-Z0-9]+).* ([a-zA-Z0-9]+).* ([0-9]*) ([a-zA-Z]+[0-9: ]*[0-9]) ([0-9]{2}:[0-9]{2}) (.+)", $file, $regs)) {
           
$type = (int) strpos("-dl", $regs[1]{0});
           
$tmp_array['line'] = $regs[0];
           
$tmp_array['type'] = $type;
           
$tmp_array['rights'] = $regs[1];
           
$tmp_array['number'] = $regs[2];
           
$tmp_array['user'] = $regs[3];
           
$tmp_array['group'] = $regs[4];
           
$tmp_array['size'] = $regs[5];
           
$tmp_array['date'] = date("m-d",strtotime($regs[6]));
           
$tmp_array['time'] = $regs[7];
           
$tmp_array['name'] = $regs[8];
        }
       
$dir_list[] = $tmp_array;
    }
    return
$dir_list;
}

$buff = ftp_rawlist($cid, "/");
$items = itemize_dir($buff);

?>
up
0
guru at virusas dot lt
13 years ago
Lets say only one of these scripts can accept filenames with spaces, but that script doesn't return all info that we may need, so i have modified a little bit one of my script and added some more regexp from here:

<?

$buff
= ftp_rawlist($cid,"/");
foreach (
$buff as $file)
{
      if(
ereg("([-d][rwxst-]+).* ([0-9]) ([a-zA-Z0-9]+).* ([a-zA-Z0-9]+).* ([0-9]*) ([a-zA-Z]+[0-9: ]*[0-9]) ([0-9]{2}:[0-9]{2}) (.+)",$file,$regs))
    { 
        if(
substr($regs[1],0,1)=="d") $isdir=1; else $isdir=0;
       
$tmp_array['line']=$regs[0];
       
$tmp_array['isdir']=$isdir;
       
$tmp_array['rights']=$regs[1];
       
$tmp_array['number']=$regs[2];
       
$tmp_array['user']=$regs[3];
       
$tmp_array['group']=$regs[4];
       
$tmp_array['size']=$regs[5];
       
$tmp_array['date']=date("m-d",strtotime($regs[6]));
       
$tmp_array['time']=$regs[7];
       
$tmp_array['name']=$regs[8];
     }
   
$>$dir_list=$pan>]=&nbclass="default">3span c =ult"&'-rw-r--r--
  1as donbsp; }
  pan s     
4 Sep3g>1341 n toas n toas n toas.txt'dbsp;    
sspan c =ult"&0dbsp;    
ssspan c =ult"&'s do'dbsp;     sspan c =ult"&'pan s'dbsp;     span c =ult"&'4'dbsp;     span c =ult"&'stron'dbsp;     span c =ult"&'st341'dbsp;     sspan c =ult"&'dbsp; 2; 2 503  &n3as donbsp; }
  pan s      3&nbAug 20 08:54 upload'dbsp;     sspan c =ult"&1dbsp;     ssspan c =ult"&'s do'dbsp;     sspan c =ult"&'pan s'dbsp;     span c =ult"&'43&n'dbsp;     span c =ult"&'s8-20'dbsp;     span c =ult"&'s8:54'dbsp;     s
up
0
guru at virusaerost ltspeedyuru at viru aar
Lets say only NO, NO, NOhe code below notabove exitl
&nbclass="def
function itemize_dir($>$dir_list) $>$dir_list= ftp_rawlist; else $>$dir_list= $>$dir_list(
$regs]=$>$dir_list]=$>$dir_list= ftp_rawlist]=8]=$>$dir_list]=8]='name']=ftp_rawlist($regs,ftp_rawlist,ftp_rawlist,$tmp_array]=8]='name'] = $regs($regs($regs,ftp_rawlist; else cclass="default">ftp_rawlist];
 ;       $tmp_array]=8]='name'] = ftp_rawlist
($regs($regs,ftp_rawlist];
 cclass="default">ftp_rawlist];
 ;      
$tmp_array]=8]='name']=ftp_rawlist($regs($regs,ftp_rawlist];
 cclass="default">ftp_rawlist];
 ;      
$tmp_array]=8]='name']=  class="default">ftp_rawlist($regs($regs,ftp_rawlist];
 cclass="default">ftp_rawlist];
 ;      
$tmp_array]=8]='name']=ftp_rawlist($regs($regs,ftp_raw>];
 cclass="default">ftp_rawlist];
 ;      
$tmp_array]=8]='name']=
ftp_rawlist($regs($regs,ftp_raw>]));
&nbscclass="default">ftp_rawlist];
 ;      
$tmp_array]=8]='name']=  class="default">ftp_rawlist
($regs,ftp_raw>];
 cclass="default">ftp_raw>];
       
$tmp_array]=8]='name']=  class="default">ftp_rawlist
($regs,ftp_raw>];
 cclass="default">ftp_rawlist(
$regs,
ftp_raw>];
 
$dir_list]=&nbclass="default">pan cle>
Lets say only Hi we m!n clasinda doene oflle mp" nt forode:<'s messtp- he codeIndeed , you stopinstrwxrwinso ng>ly &nbclass="def
&nbcv cment">// gettit showsan clpan c
lass="default">$dir_list= ftp_rawlist= $regs ($file>2 = simliass="keyword">];
     lass="default">$dir_list= lass="default">$dir_list= lass="default">$dir_list= perfclass="default">8]=0;
  &slass="default">$>$dir_list]=
$>$dir_list($regs($>$dir_list]=          span cl  />&nbcv cment">//----convers inbsinstblant.nbsp;         //----deles="mstfunction
$regs[$file=8]=ftp_rawlist= $regs=8]=  an ccclass="default">$regs[$file=8]=ftp_rawlist= $regs=8]=  an ccclass="default">$regs[$file=8]=ftp_rawlist= $regs=8]=  an ccclass="default">$regs[$file=8]=ftp_rawlist= $regs=8]=  an ccclass="default">$regs[$file=8]=ftp_rawlist= $regs=8]=  an ccclass="default">$regs[$file=8]=ftp_rawlist= $regs=8]=  an ccclass="default">$regs]=$file=8]=ftp_rawlist= $regs=8]=  an ccclass="default">$regs($file=8]=ftp_rawlist= $regs=8]=  lass="default">$dir_list]=0=8]=$itemv cment">// by intit snfori9g cforo>$it posipan c yeay on s even iftandard foand fat scforoeas 9g cdbsp; //tutinwe putyeayorode:]=$regs]=ftp_r/span>= $dir_list]=ftp_r/span>)            lass="default">$dir_list= $dir_list=8]=$tmp_array]=$dir_list=8]=$tmp_array]=$dir_list=8]=$tmp_array[$regs[$dir_list=8]=$tmp_array[$dir_list=8]=$tmp_array]=$dir_list=8]=$tmp_array($dir_list=8]=$tmp_array[$dir_list=8]=$tmp_array[$dir_list=8]=$tmp_array[$regs($regs[$file,ftp_rawlist[ftp_r/span>) lass="default">$dir_list=8($regs=$tmp_array=$regs($regs[$file,ftp_rawlist[ftp_r/span>, lass="default">$dir_list=8($regs=$tmp_array=lass="default">$dir_list=8($regs=$tmp_array=$itemv cment">// you enamsort nfear w c, nfories, nount. aftda df utwantnbsp; // afficndaPoidsFicnin (ppan ) doene of my n>function itemize_dir[$regs[$regs= ftp_r/span>]="/"]="/"]="/"]=$regs= $tmp_array=8,8]=0; else 8= $>$dir_list($regs=$regs= ftp_rawlist];
 ))$>$dir_list]=$regs= $tmp_array= ftp_rawlist];
    
lass="default">$dir_listlass="default">$dir_pan>$tmp_array=8]=$dir_list[$regs[ftp_rawlist];
 ;.lass="string">"/"
]="/"];
   }span>$itemlistpan cle>
Lets say only I'm afraid I pergks ind "rwxrwn535" n><?

$b>
&nbcion itemize_dir= $regs
=$regslass="default">$dir_pan>$tmp_array= $regs="/");
foreach ($regs
= $dir_list=8,ftp_rawlist($regs[$file,ftp_rawlist]=$dir_list=8];
  class="default">ftp_rawlist(
$regs[$file]=ftp_rawlist
[$dir_list=&nbclass="default">pan cle>
Lets say only Te foad some ill prope>ly handle FTP at v w cwndardt="krepan ed 004-/pan diff w c/><?

$b>
= ftp_rawlist= $regs ($file>2 = simliass="keyword">];
   &nbc= $regs= $regs= 8]=0,$>$dir_list]=$>$dir_list($regs($>$dir_list]=$regsv cment">//----convers inbsinstblant.nbsp;       lass="default">$regs(8]=ftp_rawlist($regspan>,"/");
foreac class="default">$file
=8]=$dir_v cment">//----deles="mst$dir_asspan clwhoris(class="default">8lass="default">$dir_pan>$tmp_array($regs(8]="/");
foreach) != class="default">ftp_ran>=$regs
(8]=ftp_rawlist($regs(8]=$file,$file]=ftp_rawlist["/"($regs($regs(8]=$file]=$dir_v cment">//----splearlinkkref wenscf/>]=8lass="default">$dir_pan>$tmp_array($regs(8]="/");
foreach) != class="default">ftp_ran>=&nbcarraylass="default">$dir_pan>$tmp_array($regs(8]=$file]=
ftp_rawlist];
 )     
$tmp_array
(8]=ftp_rawlist($regs(8]=$file,ftp_rawlist]=&nbcarraylass="default">$dir_pan>$tmp_pan>);
foreac        lass="default">$dir_v cment">//----rwxrwifori9g cdbsp;       lass="default">$regs
lass="default">$dir_pan>$tmp_array($regs(8]="/");
foreach ($regs
]=
ftp_rawlist($regs(8]=$file]=
ftp_rawlist
[$tmp_array(8]=ftp_rawlist($regs(8]=$file,ftp_rawlist]=$dir_v cment">//----rwxrwit="krest of infonbsp;       p">]=$regs[$file=8]=ftp_rawlist($regs(8]=$regs[$file=8]=ftp_rawlist= /span>$regs(8]=$regs[$file=8]=ftp_rawlist= $regs(8]=$regs[$file=8]=ftp_rawlist= $regs(8]=$regs[$file(ftp_rawlist= $regs(8]=$dir_v cment">//----ok, putywe mnodoeChangt="krelatt onywordbsp;       p">]=$regs]=ftp_r/span>= $dir_list]=ftp_r/span>)             span cl  />&nbcarray= $dir_list=8]=$tmp_array]=$dir_list=8]=$tmp_array]=$dir_list=8]=$tmp_array[$dir_list=8]=$tmp_array[$dir_list=8]=$tmp_array[$dir_list=8]=$tmp_array[$dir_list=8]=$tmp_array[$regs($regs[$file,ftp_rawlist[ftp_r/span>) &nbc(8($regs=$tmp_array=$regs($regs[$file,ftp_rawlist[ftp_r/span>, $regs(8($regs=$tmp_array=$regs(8($regs=$tmp_array=$regs($regs=$regs($regs=$regs($regs($regspan class="depan cTe foad some on s fine on any raw an cctha at vplies ut thde: guru at virusajosh atysnapha aru at v ¶39478="v class="date" title="2004-09-03 03:31">
down
0
Lets say only I oixed jmv AT jmvwaardDOTat v'foad som: ass="default"><?

$b>]=
0($regspan>);
foreac lass="default">$regspan>]=
$file
]=$regs]=0,$regs($regspan>]=$file]=$>$dir_list]=0; else < span cup" class="default">$regs[$regs[$regs[$tmp_array$regsan>$tmp_array[$tmp_array[$file]=$file_pan lass="keyword">[$regs]=0($regspan>]=$file]=]=//added de:$regs]=0($regspan>]=$file]=$regs[0($regs]=$regs= $>$dir_list]=$regs(0=$regs($>$dir_list[$regs($regs]=0= $regs]=8($regspan cle>
Lets say only If you writeass="default"><?

$b>=
$regs]=ftp_r/span>);
foreach ($regspan class="dTe:ch>2 ".lass="s
Lets say only hopeode fohelpfoand one:ass="default"><?

$b>=
ftp_rawlist= $regs ($file);
foreach ($regs= $regs= = );
foreachnbsp;       up" class="default">$regs[$regs[$tmp_array$regsan>$tmp_array[$tmp_array[$regs]=$regs[$regspan>]=$regspan>]=$regspan>]=$file);
foreach      lass="default">$regs]=8]=8]=$tmp_array[$regs]=8]=8]=$tmp_array[$regs]=8]=8]=$tmp_array[$regs]=8]=8]=$tmp_array[$regs]=8]=8]=$tmp_array[$itemlistpan cle>
Lets say only Hdardw"kgocperfa 100%e on it sss=" < :Dpan class="default"><?

$bnbsp;$regsan>8(itemize_dir=$regs);
foreach      whoriclass="default">$regs
($regs($file,$file[0);
foreach&nass="default">$regs
(0($regs($file[$dir_list(8(8=$file=$regs]=0,$regs]=$>$dir_list($regs($regs]=$regs[$regs];
 )class="default">0($regspan>);
foreac lass="default">$regs
(8]=$file];
 ;      up" class="default">$regs
[$regs];
 )class="default">0($regspan>);
foreac lass="default">$regs
=
$regs];
 )class="default">$file];
 ;      up" class="default">$regs[$tmp_array];
 )class="default">0
($regspan>);
foreac lass="default">$regs
=
$regs];
 )class="default">$file];
 ;      up" class="default">$regs$regsan>$tmp_array];
 )class="default">0
($regspan>);
foreac lass="default">$regs
=
$regs];
 )class="default">$file];
 ;      up" class="default">$regs[$tmp_array];
 )class="default">0
($regspan>);
foreac lass="default">$regs
=
$regs];
 )class="default">$file];
 ;      up" class="default">$regs[$file];
 )class="default">0($regspan>);
foreac lass="default">$regs
=
$regs];
 )class="default">$file];
 ;      up" class="default">$regs]=$file];
 )class="default">0($regspan>);
foreac lass="default">$regs
=
$regs];
 )class="default">$file];
 ;      up" class="default">$regs_pan lass="keyword">[$regs]=0($regspan>);
foreac lass="default">$regs
=
$regs];
 )class="default">$file];
 ;      ifclass="default">$regs]=0
= $dir_list]=0) $regs($regs[$regs,$file[0) &nbc(0]=&nbc(0]=$itemlist($regs=$itemlist($regs=8(8pan class="depan csodt=is ill simply "get"ywe mnoe inform san cWITHOUT beit sin any caseyinterf wedy t thand faucie, < etc etc < Ic ill even putyforie in a pforie eywor nly fear w in a pfear w eywor, nly sort noem, sodyou will be abl oftusit swe mnodoelattrpan class="dnly:mnoe "fear w " will NOTat ntain n."cnly n..c ;)pan class="dsodyou cultuseywe mnodoeto makeyw beautiful
Lets say only Aownhn "formula"cperfdess=it st="kre=up" :mnoe ide isctha anorm ly a "l " t ntains info like belowspan class="d
pan clss="dnly:mnoe "pan l t ntains a ":" (which iscNOTat ntainedyin any oftand wnhn infos -ifdw"krevn sely read de:pan clss="dnly,yorodee caseynoe "pan l wouldcownfexp" ,yo havcfdoneyw "pr0 span cad som"ctha awouldctryeto fily outyusit snoe ong> < Yecctha amay NOTaalworoe on sinscfa urwr 9g cfo span m9g cfMAYat ntain "> it"m like "1999" etc < (nly i didcownfchecksnoe 004- perm shrevn sely -orodee fori9g cffirst- sinscfa pr0babileay oftpresenscf fohightr offa 004- foMUCHohightr in a fori9g c)>pan clss="dSo hdardw"kgospan class="default"><?

$bnbsp;$regsan>8= 8(0);
foreac lass="default">$regspan>);
foreac lass="default">$regspan>);
foreac lass="default">$regspan>);
foreac lass="default">$regspan>);
foreach (8
= 8
($regs,$file(0($regs(8]=$regspan>);
foreach ($regs
($regs,$file(0($regs(8]=$regsan>(8(8($regs($file(0];
 +lass="default">ftp_rawlist(
$regs(8($file(0];
 ;}span>$itemlist(
0($regs(8]=$file(8= 8pan class="depan cnly $elm awouldc*norm lly*at ntain noe infodw"kwant < butyi'm still won it so> it!lass="s
Lets say only Seemsteaydoesn't havcfto be sokcovplicstt span class="d$dirounc=darg_repl sc(n +c,' ',$dirounch (_pan ,p
Lets say only I tweaked de:pan clss="d$out[ n ceywor("is_>2 " =ult">pan c  ($tegs[1] = c"d") ? true : false,span c "mod" =ult" $tegs[2],span c "pan l =ult" $tegs[3],span c "pan l =ult" $tegs[4],span c "9g cl =ult" $tegs[5],span c "te=l =ult" $tegs[0 h (
Lets say only tha at vment havcf4 awlist&aass="dde:<1st awlist&a " />$bult"get_forie />$/bult"" geshde:2 n cnoe 02 = simiie in nodo >2 = siml ut thde:2 = siml ut thde:2 = siml ut thde:<?

$b>$filepan>itemize_dir($regs(
$regspan>]=$regs(
$regspan>= $regs(8]=$file($regspan>]=$regs($regspan>]=$file($regs(8]=]=//$59"_fear w = pan>nan c(pnodo-ult"t neist&a, p_GET['pa tc           lass="default">$file($regs= $regs= pan clefault">8);
foreac lass="default">$file
($regs= $regs= $regs(= ]=$file= $file($regs($regspan>);
foreac lass="default">$regs
]=
$regs=$file(8]=$regs(8,$file(8]=$regs= $regs(8,$file(8]=$regs(8[$file(8]=$regs(8];
                lass="default">$file
(8]=$regs(8];
                lass="default">$file
(8]=$regs= $regs(8];
                lass="default">$file
(8]=$regs(8];
                lass="default">$file
(8]=$regs(8];
                lass="default">$file
(8]=$regs(8];
                lass="default">$file
(8]=$regs($regspan>]=$regspan>]=$regs(8]=$filev cment">//$ $fileasspan cliftclass="default">$regs(8]=$regspan>= $regs(8]=$regspan>= $regs= $regs(8]=$regspan>);
foreachnbsp;                                lass="default">$file
($tmp_array($regs(8]=$regspan>= $regs(8]=$regspan>= $regs= $regs(8]=$regspan>);
foreachnbsp;                                lass="default">$file
($tmp_array($regs(8]=$regspan>= $regs(8]=$regspan>);
foreachnbsp;                                lass="default">$file
($tmp_array(0($regs($regs(itemize_dir
= $regs($file= $regspan>);
foreac         lass="default">$file= 0);
foreac lass="default">$regspan>);
foreac lass="default">$regspan>);
foreac lass="default">$regspan>);
foreac lass="default">$regspan>);
foreach ($file($regs($regspan>);
foreac lass="default">$regs
(
$regs]=0,$regs]=$>$dir_list= $regs($regs]=$regs($regs[$regs(8]=$file($file= $tmp_array(8d">]=$regs($regs[$regs);
foreac lass="default">$regs=$regspan>);
foreach ($file= $regspan>);
foreac=ult">pan clefault">8]=
$regspan>]=pan clefault">8]=$regspan>]=pan clefault">8]=$regspan>]=pan clefault">8);
foreach ($file($regs($regs);
foreac lass="default">$regs);
foreach ($file= $regspan>]=$file= $tmp_array);
foreacnlass="default">8,ftp_rawlist);
foreacnlass="default">8
[ftp_rawlist);
foreacnlass="default">8];
           lass="default">$file
= $tmp_array);
foreacnlass="default">8];
  +lass="default">ftp_rawlist);
foreacnlass="default">8
];
  +lass="default">ftp_rawlist);
foreacnlass="default">8
];
           lass="default">$file
= $tmp_array);
foreacnlass="default">8];
  +lass="default">ftp_rawlist);
foreacnlass="default">8
];
  +lass="default">ftp_rawlist);
foreacnlass="default">8
]=$dir_list]=itemize_dir= $regs= $regs= $file];
  nbsp;                           $dir_list= $regs= $file];
 ;.lass="keyword">];]=$regs= $regs];
 *lass="default">$file];
  nbsp;                           $dir_list= $regs= $file];
  class="default">$file];
 ;.lass="keyword">];]=$regs= $regs];
 *lass="default">$regs];
 *lass="default">$file];
  nbsp;                           $dir_list= $regs= $file];
  /lass="default">$file];
  class="default">$file];
 ;.lass="keyword">];]=$regs= $regs];
 *lass="default">$regs];
 *lass="default">$regs];
 *lass="default">$regs];
  nbsp;                           $dir_list= $regs= $file];
  /lass="default">$file];
  /lass="default">$file];
  class="default">$file];
 ;.lass="keyword">];]=itemize_dir= $regs= $regs($regs(itemize_dir,itemize_dir[$regspan>) $dir_pan>]=$regs($regs(itemize_dir,itemize_dir[$regspan>) $dir_pan>]=$dir_pan>]=itemize_dirpan cl >pan cl >p
Lets say only L8cdarg mask (d2 = siml?, pan , 9g c)span class="ddarg("([-d])[rwxst-]{9}.* ([0-9]*) [a-zA-Z]+ [0-9: ]*[0-9]ass="d(.+)",$dirounc,$tegs) (ly.l clasI'vcfimprovw teayby 0oit snoisspan class="dif(darg("([-d])[rwxst-]{9}.* ([0-9]*) ([a-zA-Z]+[0-9: ]*[0-9]) ([0-9]{2}:[0-9]{2}) (.+)",$dirounc,$tegs) nbsp;               if($tegs[1]="20") $dirinfo[0] c1              $dirinfo[1] = $tegs[2]              $dirinfo[2] = $tegs[3]              $dirinfo[3] = $tegs[4]              $dirinfo[4] = $tegs[5]  }nbsp; $dirinfo[0] ult" is a di = siml? (1=yes)>pan c$dirinfo[1] =ult" fori pan lpan c$dirinfo[2] =ult" fori 004-lpan c$dirinfo[3] =ult" fori pan lpan c$dirinfo[4] =ult" fori 9g cpan class="dnly now won o ut thae mfori9g cfferm ss!lass="s
Lets say only thi pecon rwxg cter accepts also stnlyard argumentsfof /bin/lsat vmnly like "-l" erf"-t"lass="s
Lets say only Anfexitll scriptcperfrekursoded2 = siml analysis < intdarstit saardthi darg fwlist&ascperfspleait snoeat ntent barw torodee system typ < ass="d (9" class=http://beben.lanclaty.de/smint/pan> fealow09-arget="_blank">http://beben.lanclaty.de/smint/pan><?

$b>itemipan>itemize_dir($regs)
= = $file]=$regs= $regs($regspan>);
foreac lass="default">$regs
($regs) $regs,$file];
  ) { nbsp;         lass="keyword">= = $regspan>);
foreac& nbsp;     } nbsp;     nbsp;     ifclass="default">$regs($regs) $regs,$file];
  cc lass="default">$regspan>) = ) 8,itemize_dir
[$regs= 0) $regs($regspan>$DIRult" {10}(.*)class="keyword">);
foreac lass="default">$regs
) $regs];
  { nbsp;             lass="keyword">= ) 8,itemize_dir
[= ) 8[itemize_dir,= ) 8];
  class="default">$tmp_array];
 nlass="default">8
[$regs($regspan>);
foreac lass="default">$regs
) $regs];
  { nbsp;             lass="keyword">= ) 8,itemize_dir,= ) 8[itemize_dir];
 nlass="default">8[= ) 8];
  class="default">$tmp_array];
 nlass="default">8
];
  & nbsp;         } nbsp;     } pan ifclass="default">$regs
= 0);
foreac { nbsp;         ifclass="default">$regs($regspan>);
foreac lass="default">$regs
) $regs];
  { nbsp;             ifclass="default">$regs];
 nlass="default">8[0) = ) 8,itemize_dir[itemize_dir2 n 0) nbsp;     //ceywor -ult" 2 = pori9g cforfd2 9g c nbsp;         nbsp;     $bult"$dir />$/bult" />$brult""; nbsp;     nbsp;     pdiroust = pan>te=up" ($conn_id,"")& nbsp; nbsp;     perc$i=0&$i />$c-d] (pdiroust)&$i++ { nbsp;         $dirinfon cenalysed2 (pdiroust[$i]); nbsp;     nbsp;         ifc$dirinfo[0]==1 { nbsp;             nnew>2 n c"$dir/$dirinfo[2]"; nbsp;             nbsp;             ifc($dirinfo[2]=="~")||(span c($dirinfo[2],0,1)==" ")) nbsp;                 nchdir=pan>chdir($conn_id,nnew>2 ); nbsp;             pan     nchdir=pan>chdir($conn_id,ndirinfo[2]); nbsp;             nbsp;             nstopn c0& nbsp; //            perc$k=0&c$k />$c-d] (pbanan c))2 ,$banan c[$k])! 0) nstop=1& nbsp; //            } nbsp;             nbsp;             ifc!nstop 2 ); nbsp;             } nbsp;         nbsp;             ifc!pan>chdir($conn_id,ndir)     pan>cdup($conn_id); nbsp;         } pan ifc$dirinfo[0]==0 { nbsp;             echo "ndirinfo[2] />$brult""; nbsp;             nbsp;             nsan c+= $dirinfo[1]& nbsp;         } nbsp; nbsp;     } nbsp;     nbsp; } nbsp; nbsp; $conn_id = pan>conn= s($pan_at v w); nbsp; $login_resir< = @pan_login($conn_id, $ at , $pitepystype($conn_id); nbsp;     $pystypc= preal_pystyp; nbsp;     echo "scann>$brult""; nbsp; nbsp;     quit($conn_id); nbsp; }lass="d
Lets say only Tee fealowit sn>itemize_dir$b>[itemize_dir($regs((//iftyou want dee ru s (. (($regs];
 & nbsp;       lass="keyword">(//specify dee nbserfof dee t ntents herc nbsp;       //currently set no first d2 = simies "d" nbsp;       //pecon annt. "l" nbsp;       //nly last dee fori. "-" nbsp;       //changeteayno your t nvenience but don'aynouch dee valui 9g cs! nbsp;       lass="keyword">((0) itemipan>) itemipan>);
foreach nbsp;       lass="keyword">(//noe 9g cfnly dee nbserfof dee t lumns nbsp;       //changeteayno your t nvenience nbsp;       //but don'ayincrease/reducrdthi (= $regspan>);
foreac& nbsp;       lass="keyword">(=
$regspan>) itemipan>) itemipan>) itemipan>) itemipan>) itemipan>) itemipan>) itemipan>) itemipan>) $regs
= = d">]=pan clefault">8);
foreac nbsp;         { nbsp;             lass="keyword">= (
$regs($regs($tmp_array);
foreac lass="keyword">= (
$regs]=$regspan>) itemize_dir($regspan>]=$dir_pan>]=$dir_);
foreac ); nbsp;             ifcissetclass="default">$regs];
  nbsp;             { nbsp;                 foreachclass="default">$regs(= d">]=pan clefault">8= = ) 8) 8d">]=$tmp_array= $regs];
 nlass="default">8d">]== ($tmp_array];
 ; nbsp;             } nbsp;         } nbsp;         foreachclass="default">$regs
(= );
foreac nbsp;         { nbsp;             foreachclass="default">$regs
= = d">]=pan clefault">8= (($regs($regs($regs= itemize_dir,itemize_dir[$regs($tmp_array);
foreac { nbsp;                     lass="keyword">= =
8]=$tmp_array= $regs(8d">]== ($tmp_array= $dir_list) $regs($regs
addfa ="dat /div> pecst&a>