Re: Using PHP for directory indexing

From: Date: Mon, 12 Nov 2001 14:23:56 +0000
Subject: Re: Using PHP for directory indexing
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-74285@lists.php.net to get a copy of this message
Hi! Kevin! Try this... :-) have a nica day! <? // this is qw.php // is incoming parametr $catalog; // there can be better way to protect filesystem // directory where operations aloved define("START_PATH", "named"); $catalog = eregi_replace('([/]{2,})|([./]{2,})|([/.]{2,})', '/', $catalog); $handle=opendir(START_PATH.'/'.$catalog); rewinddir($handle); while ($file = readdir($handle)) { $filenames[]=$file; } closedir($handle); $str = 'Current directory: <b>&laquo;'.START_PATH.$catalog.'&raquo;</b>'; print $str; echo '<br><br><table class=tabler>'; echo '<tr class=menu_tr>'; echo '<td><h4>Record type <td><h4>Path</tr>'; for ($i = 0; $i < count($filenames); $i++) { if ($filenames[$i]!='.' && $filenames[$i]!='..') { if (is_dir(START_PATH.$catalog.'/'.$filenames[$i])) { print '<tr class=ordinary_tr><td>Directory</td><td>'; print '<a href=qw.php?catalog='.$catalog."/".$filenames[$i].'>'.$filenames[$i].'</a></ td>'; } else { print '<tr class=ordinary_tr><td>File</td><td>'; print '<a href=qw.php?pather='.START_PATH.$catalog."/".$filenames[$i].'>'.$filenames[$ i].'</a></td>'; } print '</tr>'; } } ?> </table>

« previous php.general (#74285) next »