Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Php Script To Make A Link List, From the list of the Directory Files
jlhaslip
post 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 Icon

Group: [MODERATOR]
Posts: 3,882
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



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.
Go to the top of the page
 
+Quote Post
sxyloverboy
post 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. smile.gif But i think it is not right for a Sitemap because many people have filenames that wouldnt look good for a sitemap.

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.
Go to the top of the page
 
+Quote Post
jlhaslip
post 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 Icon

Group: [MODERATOR]
Posts: 3,882
Joined: 24-July 05
From: In Trouble Again... still?
Member No.: 9,787
Spam Patrol



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.
Go to the top of the page
 
+Quote Post
sportytalk
post 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.
Go to the top of the page
 
+Quote Post
LevinZ
post 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.....
Go to the top of the page
 
+Quote Post
angel86
post May 12 2006, 02:39 AM
Post #6


Newbie
*

Group: Members
Posts: 6
Joined: 12-May 06
Member No.: 23,498



hi good tutoriaal biggrin.gif

nice smile.gif
Go to the top of the page
 
+Quote Post
FA Ace
post 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 wink.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Php Quiz Script(20)
  2. Email Script/form With Php(35)
  3. Secure The Email Addresses On Your Website!(10)
  4. Css And Javascript Combined For Dynamic Layout(9)
  5. How To Read And Write Files Using Php(20)
  6. How To Stop Image Hot Linking(17)
  7. Delete Files And Directories Using Php(7)
  8. Building An Unordered List Of Anchors(4)
  9. Page Generation Time Script(17)
  10. Php Menu Bulding Script And Site Template(0)
  11. How To Create Html Page Anchors(5)
  12. Templating System Using Php Includes(13)
  13. How To Open Bam & Tt Files, long 3 part tutorial(2)
  14. How To Protect A Directory From Being Viewed(4)
  15. How To: Ip Configuration Script (win Xp)(0)
  1. How To Create Self-unzipping Files(18)
  2. How To Chmod Files(16)
  3. Flatfile User Login/signup(24)
  4. How To Fix Problems With Shareaza(1)
  5. Cpanel Analysis And Log Files(0)
  6. For ... Next Loops And Script Planning(2)
  7. How To Better Compress Files In Winrar(7)
  8. Image Rotator Script (another One)(0)
  9. Background Image Swap Script(15)
  10. How To Hide Your Important Files And Folders(7)
  11. [phpbb] Member Last-visit Report Script(0)
  12. Download Files Off Esnips.com(0)
  13. Debug Exe Files(4)


 



- Lo-Fi Version Time is now: 26th July 2008 - 04:22 PM