Re: custom CAD directory/file browser
| From: | Marlin Unruh | Date: | Thu, 01 Dec 2005 14:36:31 +0000 |
| Subject: | Re: custom CAD directory/file browser | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-226703@lists.php.net to get a copy of this message | ||
Jay Blanchard wrote:
[snip]
http://localhost/cad.php?directory=c:/suncosys/cyl/../sbr/../act/2d/obsolete /.. [/snip] I would have to see your code to see how the $_GET array grows. [/snip]Following is my code as it is. I wrote something similar in Python but it creates static html pages with way more code. I decided to switch to PHP and make it dynamic. <html><head> <title>Cad File Finder</title> </head> <body> <?php
// this is not polished code with all the gotcha stuff in place
// this is very much in the rough at this point. I am not concerned with looks yet.
$the_dir = $_GET['directory'];
if($the_dir == '') $the_dir = 'c:/suncosys'; // edit to some existing directory
echo $the_dir.'<br>';
$dh = @opendir($the_dir);
while (($filename = readdir($dh))) {
if (is_dir($the_dir."/".$filename)) {
echo "<a href=\"cad.php?directory=".$the_dir."/".$filename."\"/>".$filename."</a>";
echo "<br/>";
}
if (is_file($the_dir."/".$filename)) {
$the_file = $the_dir."/".$filename;
$f_contents = file_get_contents($the_file);
echo "<a href=\"file:///".$the_file."\">".$filename."</a>";
echo " : file size : ".filesize($the_file);
echo " : ";
print strpos($f_content, "_Title_");
fclose($f_handle); // close the file
echo "<br/>";
}
}
@closedir($dh);
$the_dir = NULL;
$_PUT['directory'] = NULL; // ????
// printed for debugging only
echo 'the_dir: '.$the_dir.'<br>';
echo 'get_dir: '.$_GET['directory'].'<br>';
// phpinfo(); // uncommment to display php info
?>
</body>
</html>
--
Regards,
Marlin Unruh
Sunco Systems Inc.
(308) 326-4400