note 65426 deleted from function.opendir by bjori
| From: | bjori@php.net | Date: | Sun, 30 Apr 2006 17:38:17 +0000 |
| Subject: | note 65426 deleted from function.opendir by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-110203@lists.php.net to get a copy of this message | ||
Note Submitter: cynthia at heathernova dot info
Reason: useless
----
Hi tozeiler, I have adjusted your code a little bit and changed it into a 'filemanager'.
It will open the specified file or directory on your webserver.
<?php
# This is a simple filemanager for your webserver
#
# Feel free to use it ;-)
$new_url = $_GET[new_url];
// this is the path where the script start,
// change it into your own.
$path="../downloads/";
$dh = opendir($path);
echo ("<table border=0><tr>\n");
// This is the first_time that the program is used
if ($new_url == ""):
while (($file = readdir($dh)) !== false) {
$file = trim($file);
$test=strlen($file);
$total = $path . $file;
$bytes = filesize($total);
$type=filetype($file);
if ( $type == "dir" & $file != "..") :
?><td><a href="testbank-2.php?new_url=<?php echo $path. "" . $file;
?>/" target="_self"><?php echo $file;?></a>
open this directory</td></tr>
<?php
endif;
if ( $type != "dir" ) :
?>
<td width="265"><a title="<?php echo $file; ?> <?php echo $type;
?>" href="<?php echo $path . "" . $file; ?>"
target="_blank"><?php echo $file; ?></a> <?php echo $bytes; ?>
bytes</td></tr>
<?php
endif;
}
closedir($dh);
echo ("</table>");
endif;
// User want to look in a sub directory..
if ($new_url !=""):
$path=$new_url;
$dh = opendir($path);
echo ("<table border=0><tr>\n");
while (($file = readdir($dh)) !== false) {
$file = trim($file);
$test=strlen($file);
$total = $path . $file;
$bytes = filesize($total);
$type=filetype($file);
if ( $type == "dir") :
?><td width="265"><a href="testbank-2.php?new_url=<?php echo $path.
"" . $file; ?>/" target="_self"><?php echo $file;?></a>
open this directory</td></tr>
<?php
endif;
if ( $type != "dir" ) :
?>
<td width="265"><a title="<?php echo $file; ?> <?php echo $type;
?>" href="<?php echo $path . "" . $file; ?>"
target="_blank"><?php echo $file; ?></a> <?php echo $bytes; ?>
bytes</td></tr>
<?php
endif;
}
closedir($dh);
echo ("</table>");
endif;
?>