note 91029 added to function.ftp-rawlist
| From: | mikr at osu1 dot php dot net | Date: | Thu, 21 May 2009 14:45:52 +0000 |
| Subject: | note 91029 added to function.ftp-rawlist | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-155840@lists.php.net to get a copy of this message | ||
@francois frao_o
Your code works as long as every file in the directory (and it's parent directory) have been
created within the last year. But if not, then it fails. The following works better (mod_time will
either result as Mth dd YYYY or Mth dd HH:mm). Also, the regex is tighter now.
<?php
$list = @ftp_rawlist($con, $directory) ;
$files = array() ;
foreach ($list as $file) {
// I've commented the replace to better show what
// it's trying to do.
preg_replace(
'`^(.{10}+)'. // rights
'\s+'.
'(\d+)'. // number
'\s+'.
'(\d+|\w+)'. // owner
'\s+'.
'(\d+|\w+)'. // group
'\s+'.
'(\d+)'. // size
'\s+'.
'([a-zA-Z]{3})'. // Mon
'\s+'.
'([0-9]+)'. // dd
'\s+'.
'([0-9]{2}:?[0-9]{2})'. // YYYY or HH:MM
'\s+'.
'(.+)$`Ue',
'$files[]=array('.
'"rights" => "$1",'.
'"number" => "$2",'.
'"owner" => "$3",'.
'"group" => "$4",'.
'"file_size"=> "$5",'.
'"mod_time" => "$6 $7 $8",'.
'"file" => basename("$9"),'.
'"type" => print_r('.
'(preg_match("/^d/","$1"))?"dir":"file",1));',
$file);
}
?>
----
Server IP: 208.69.120.35
Probable Submitter: 68.166.48.242
----
Manual Page -- http://www.php.net/manual/en/function.ftp-rawlist.php
Edit -- https://master.php.net/note/edit/91029
Del: integrated -- https://master.php.net/note/delete/91029/integrated
Del: useless -- https://master.php.net/note/delete/91029/useless
Del: bad code -- https://master.php.net/note/delete/91029/bad+code
Del: spam -- https://master.php.net/note/delete/91029/spam
Del: non-english -- https://master.php.net/note/delete/91029/non-english
Del: in docs -- https://master.php.net/note/delete/91029/in+docs
Del: other reasons-- https://master.php.net/note/delete/91029
Reject -- https://master.php.net/note/reject/91029
Search -- https://master.php.net/manage/user-notes.php