|
|
|
|
![]() ![]() |
Apr 14 2006, 03:51 AM
Post
#1
|
|
|
A computer once beat me at chess, but it was no match for me at kick boxing. ![]() Group: [MODERATOR] Posts: 3,882 Joined: 24-July 05 From: In Trouble Again... still? Member No.: 9,787 ![]() |
Well, it has been a while since I have added anything to the Tutorial Sectiion, so here is another script for the members to enjoy.
This one creates a list of links from the contents of the directory which it is run from. For instance, if you run it from the public_html folder, then all the files (not the Directores) are listed and linked so when you click on the link, that file is parsed and output to the browser. Here is the code: CODE <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>An XHTML 1.0 Strict Page to List the files in this directory</title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> </head> <body> <p>... Your HTML content here ...</p> <?php //dir_list.php $default_dir = "./"; // lists files only for the directory which this script is run from echo '<div id="link_div"><ul>' . "\r\n\t"; if(!($dp = opendir($default_dir))) die("Cannot open $default_dir."); while($file = readdir($dp)) { if(is_dir($file)) { continue; } else if($file != '.' && $file != '..') { echo '<li><a href="' . $file . ' " class="link_li" >' . $file . '</a></li>' . "\r\n\t"; } } closedir($dp); echo '</ul> </div>'; ?> <p>... Your HTML content here ...</p> <p> <a href="http://validator.w3.org/check?uri=referer">validate the xhtml</a> </p> </body> </html> If you save it as the index.html file for the public_html folder of your account and alter the .htaccess file for the account to parse html as php, then the script will list out all the files in the folder as links. Alternately, if you use it as a page on your site, then it will create a 'sitemap' of all the files in that folder. Use it freely. I hope it helps someone. Enjoy. |
|
|
|
Apr 14 2006, 09:41 AM
Post
#2
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 302 Joined: 17-June 05 From: Frankfurt, Germany Member No.: 8,358 |
I think this is a pretty cool script. Thanks for sharing it.
But surely its usefull if someone wants to make a filemanager or somehting an is just learning php. It would be intresting to see how this works with listing subfolders and the files under it. Then if someone made the right filenames and you made it filter out all files except html and php files and remove the extension from the end it would be pretty nice. |
|
|
|
Apr 14 2006, 03:33 PM
Post
#3
|
|
|
A computer once beat me at chess, but it was no match for me at kick boxing. ![]() Group: [MODERATOR] Posts: 3,882 Joined: 24-July 05 From: In Trouble Again... still? Member No.: 9,787 ![]() |
Yes, those are all good characteristics of a file manager/sitemap script.
One of the issues which determines the scripts I post in the Tutorial Section is their relative in-completeness. This allows users to customize them and develop their own php scripting abilities. This script is in no way complete, I agree, but maybe someone would be able to use it and expand it with their own enhancements to do exactly what they want. |
|
|
|
Apr 22 2006, 12:24 AM
Post
#4
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 326 Joined: 7-October 05 Member No.: 12,650 |
another cool script. I haven't really had the need to have a file manager styled php code yet, although If I decide to do it in the future, this code will most certainly help.
I'm sure though that with a little bit of modification to the code by another php user, this code will be professional and contain many new enhancements. |
|
|
|
Apr 25 2006, 05:35 AM
Post
#5
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 17 Joined: 25-April 06 Member No.: 22,436 |
nice guide.....
|
|
|
|
May 12 2006, 02:39 AM
Post
#6
|
|
|
Newbie ![]() Group: Members Posts: 6 Joined: 12-May 06 Member No.: 23,498 |
hi good tutoriaal
nice |
|
|
|
May 30 2006, 09:58 PM
Post
#7
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 11 Joined: 30-May 06 Member No.: 24,543 |
Great Script, Hope you make more |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 26th July 2008 - 04:22 PM |