AV1611 Posted June 10, 2007 Share Posted June 10, 2007 I was playing with a snippet I found and made this if anyone wants it, or, Any improvements would be welcome. What it is is a tool for when you are developing a website that you just want to view a particular file. not ftp or anything, just view it. like if you wanna snag it real quick. You leave it in the folder, and call it up when you want it. you delete it when the site is done. It display a like to all files, and makes thumbnails of the pics for you. <?php // ************Variable**************** $uri = $_SERVER['REQUEST_URI']; $url = substr($uri, 0, -32); $documentroot=$_SERVER['DOCUMENT_ROOT']; $servername=$_SERVER['SERVER_NAME']; $path = "http://".$servername.$url; $directory = $documentroot.$url; $pw=sha1('nosecrets'); // ************Variable**************** // Check to see password is set if(!isset($_GET['PASSWORD'])) { echo "<center><br/><form name='list' action='listfiles.php'>"; echo "<input type='password' name='PASSWORD'>"; echo "<input type='submit' value='Submit'>"; echo "</form></center>"; } elseif (sha1($_GET['PASSWORD']) != $pw) { header('Location: listfiles.php'); } elseif (sha1($_GET['PASSWORD']) == $pw) { echo "<table border='1'>"; echo "<tr><td>URL PATH: ".$path."</td></tr>"; echo "<tr><td>DIRECTORY: ".$directory."</td></tr>"; if ($handle = opendir($directory)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $test1 = substr($file, -4); if (preg_match("/.jpg$/i", $file)) { $filename = $path . $file; echo "<tr><td><a href='$filename'><img src='$filename' width='100' /></a><br />"; echo "<a href='$filename'>$file</a></td></tr>"; } if (preg_match("/.gif$/i", $file)) { $filename = $path . $file; echo "<tr><td><a href='$filename'><img src='$filename' width='100' /></a><br />"; echo "<a href='$filename'>$file</a></td></tr>"; } if (preg_match("/.png$/i", $file)) { $filename = $path . $file; echo "<tr><td><a href='$filename'><img src='$filename' width='100' /></a><br />"; echo "<a href='$filename'>$file</a></td></tr>"; } if (preg_match("/.bmp$/i", $file)) { $filename = $path . $file; echo "<tr><td><a href='$filename'><img src='$filename' width='100' /></a><br />"; echo "<a href='$filename'>$file</a></td></tr>"; } else { $filename = $path . $file; echo "<tr><td><a href='$filename'>$file</a></td></tr>"; } } } closedir($handle); } } ?> echo "</table>"; Quote Link to comment https://forums.phpfreaks.com/topic/54932-if-anyone-wants-it/ Share on other sites More sharing options...
DJTim666 Posted June 10, 2007 Share Posted June 10, 2007 All this does is display the files that are in my directory ??? And makes a link to them. So this is basically a quicklink to all the files. Quote Link to comment https://forums.phpfreaks.com/topic/54932-if-anyone-wants-it/#findComment-271670 Share on other sites More sharing options...
AV1611 Posted June 10, 2007 Author Share Posted June 10, 2007 That is exactly all it does. It's very helpful if you are developing a site or if you want to make some files available without having to mess with an ftp. Quote Link to comment https://forums.phpfreaks.com/topic/54932-if-anyone-wants-it/#findComment-271671 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.