note 46127 added to function.ftp-rawlist

From: Date: Thu, 30 Sep 2004 04:52:11 +0000
Subject: note 46127 added to function.ftp-rawlist
Groups: php.notes 
Request: Send a blank email to php-notes+get-77604@lists.php.net to get a copy of this message
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); ?> ---- Manual Page -- http://www.php.net/manual/en/function.ftp-rawlist.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46127 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46127&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+46127&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#77604) next »