Nov 20, 2009

Php Script To Make A Link List - From the list of the Directory Files

free web hosting
Open Discussion > MODERATED AREA > Tutorials

Php Script To Make A Link List - From the list of the Directory Files

jlhaslip
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.

 

 

 


Comment/Reply (w/o sign-up)

sxyloverboy
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.

Comment/Reply (w/o sign-up)

jlhaslip
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.

Comment/Reply (w/o sign-up)

sportytalk
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.

Comment/Reply (w/o sign-up)

LevinZ
nice guide.....

Comment/Reply (w/o sign-up)

angel86
hi good tutoriaal biggrin.gif

nice smile.gif

Comment/Reply (w/o sign-up)

FA Ace

Great Script, Hope you make more wink.gif

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : php, script, make, link, list, list, directory, files

  1. Deny Or Grant Users Access To Files Of Choice (vista)
    Uses Bat Files To Deny Or Grant People Access To Files (3)
  2. How To Create Pdf Files Using Free Tool
    Introduction to use a free tool to create PDF file (10)
    Now, that you don't need to have expensive software like Acrobat to create PDF. All you need is
    Microsoft Office and a software name doPDF. You can download the freeware from
    http://www.dopdf.com/download.php After downloading dopdf.exe, follow the instruction below 1.
    Double click to install it, as display at image 1.jpg, choose a language and click OK 2. You will
    see 2.jpg click next 3. Click I accept the agreement see 3.jpg, click next 4. Now you will see
    4.jpg, select the folder to install it and click next 5. When seeing 5.jpg, This is the folder group
    in Star....
  3. Clearing Your Ie Tif
    Clear your Temporary Internet Files on IE (0)
    -Welcome to: Clearing your Internet Explorer Temporary Internet Files Tutorial-!
    Attention!: As some of the members on here may know, it is possible to clear your Internet Explorer
    Temporary Files. I have searched this entire Tutorials subforum to find a topic already made, and I
    have found nothing. This tutorial I did NOT find this on Google, or any other search engine. I
    always find this out for myself. Lets start: Ok, first we open up Internet Explorer, then we
    click "Tools"...then we click on "Internet Options...". On the Main page "General" we l....
  4. How To Download Any Flv Files From Any Sites
    (7)
    Now you can download any flv files from any websites!! People often know how to download youtubes
    clip, but not from other sites. In this tutorial you will need a tool name Moyea FLV Downloader, it
    is free and you can download it at http://www.flvsoft.com/download_flv/ This is the best tool i
    have meet up with to download flv files in any site. Since it can detect flv files, and list it, you
    can download it as you want, so no more favourite clips goes away from your sight and now you have
    it on your own hard drive! 1. Run moyea flv downloader see 1.jpg 2. At the left....
  5. Debug Exe Files
    How to debug an exe file. (4)
    Think that we have written a program, and some codes are wrong. We can go back to compiler and
    change the code, and compile again. But I will show you how to correct our mistakes without using
    the compiler. Let's start: I have written a program in Delphi. Let's see my mistake. I
    have created a form like this. After this I wrote the codes in the Compare Button click as
    below. CODE 1.   procedure TForm1.ComparebuttonClick(Sender: TObject); 2.   var 3.    
    a,b:integer; 4.   begin 5.     a := StrToInt(EditA.Text); 6.     b := StrToInt(EditB.Text); 7. 8.  ....
  6. Download Files Off Esnips.com
    even now that the download button is gone! (0)
    hey everyone, i am sure that many of you may have heard of esnips , which is basically online file
    storage/sharing. you can now find almost any file imaginable on esnips, and in many ways it is
    better than rapidshare. previously, once you are signed in to esnips, you were able to download any
    esnips file via a button only viewable to members. back then, there was a method to download any
    file without even signing in. then, probably due to legal issues, users were able to choose whether
    or not people could download their files. the hack mentioned above, though, still....
  7. [phpbb] Member Last-visit Report Script
    for phpbb2 databases (0)
    One flaw in the phpbb2 administration section is a report to list out the 'last-visit'
    time/date of the membership. I wrote a script to do exactly that and will be sharing the script with
    you here. the first section defines the variables required for the Database connection, finding the
    right database, supplying passwords, etc. HTML DEFINE ('DB_USER', 'YOUR DB USER
    NAME'); // change these defined values to suit your own situation DEFINE ('DB_PASSWORD',
    'YOUR DB PASSWORD'); DEFINE ('DB_HOST', 'localhost'); DEF....
  8. How To Hide Your Important Files And Folders
    In Ms. Windows, Without Using Programmes. (7)
    Most of people share their computers with others -family, mates, buddy or whoever- and that sharing
    threatens their secrets and private file to be revealed, letting some people to know things they
    shouldn't know.. My Securing Way: Operation - Camouflage Use an Icon
    Editor to generate a 1x1 Transparent Icon and Save it .. > 1 Open CMD.. Start >> Run or Press
    WindowsLogo+R.. Lets Say you wanna hide a Folder named " secure " and it's located in
    E:\folder\ so Write E: and Press Enter then Write Cd folder and Enter then Attrib +s +h....
  9. Background Image Swap Script
    Change a Background Image based on clock time (15)
    Background Image Changer Script To swap the background image from your CSS file according to the
    Server Clock Time. 1.) In your CSS file, add the following rule: CODE body {     background:
    url(time.png); } 2.) Create a "folder" named time.png. 3.) Into the folder, place three images
    named morning.png, day.png, night.png. 4.) Also, in the same folder, create an index.php file and
    copy/paste the following script. CODE $hour = date('H'); if ($hour     $image =
    "morning.png"; } elseif ($hour      $image = "day.png"; } else {      $image = "night.pn....
  10. Image Rotator Script (another One)
    easy to implement (0)
    In case you haven't noticed, I have a different Avatar display on the Forum each time the page
    is refreshed. /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif"
    /> For those of you who might want the script to do that, here is the one I am using: HTML
    $filesp = glob('*.png'); if(empty($filesp)){ echo 'no images found...die br >';
    die(); } else{ foreach ($filesp as $file) { $img_array = trim($file); } } shuffle($img_array);
    //select image at random header("C o n t e n t{dash}t y p e: image/png"); // replace th....
  11. How To Better Compress Files In Winrar
    (7)
    How to better compress files in winrar As you know Winrar is more popular and powerful than
    other compressor softwares. To better compress your files and folders follow below steps: 1- Right
    click on your file and select "Add to archive…" from context menu. A dialog box will appear. 2- In
    General tab and in "Compression Method" dropdown menu, select "Best". 3- Click on Advanced tab and
    then click on "Compression" botton. Advanced Compression Parameters dialog box will appear. 4- In
    Text Compression section select Force and in Prediction Order type 63 and in Memory....
  12. For ... Next Loops And Script Planning
    My Fifth PHP Tutorial (2)
    Be sure to read the other ones. They are located in the TUTORIALS section, and at the time of this
    writing all on the first page. Intro To PHP Tutorial 5 - For ... Next Loops and Planning Scripts
    Released 4/15/07 By Chris Feilbach aka GhostRider Contact Info: E-mail: assembler7@gmail.com AIM:
    emptybinder78 Yahoo: drunkonmarshmellows Website: http://www.ghostrider.trap17.com Before I start
    talking about what wonderful things loops are and all the cool stuff they can do, I want to address
    something first. I was asked about something to write in PHP. There isn't....
  13. Cpanel Analysis And Log Files
    Part 4 of My 7 Part Tutorial (0)
    This Tutorial will be divided into 7 different parts, and this is the first part, when i get the
    other parts together, i will post the links under here /biggrin.gif" style="vertical-align:middle"
    emoid=":D" border="0" alt="biggrin.gif" /> Enjoy. Part 1: E-mail Management Part 2: Useful Site
    Management Tools Part 3: Useful Site Management Tools2.1 Part 5: Advanced Tools Part 6:
    PreInstalled Scripts, Extras, and Cpanel Options Part 7: Fantastico Detailed Cpanel Tutorial
    Part 3: Analysis and Log Files In this tutorial I will, in detail explain all ....
  14. How To Fix Problems With Shareaza
    ONLY for people to download LEGAL files with. (1)
    Can't run shareaza and surf the internet at the same time? There could be two
    problems: Your uploads are killing your downloads and/or you are using Windows 95/98/ME. If you
    are uploading constantly and havent limited the bandwidth then it is likely that you are killing
    your download speed which is affecting your ability to surf the web and do other tasks. If you
    are uploading lots and download speeds are suffering: Start Shareaza. Click on the Tools menu,
    then click Shareaza Settings. In the box that just popped up, there is a list of men....
  15. How To Chmod Files
    (16)
    This is a short but useful tutorial on how to chmod files I offen find wap/web masters
    uploading scripts into their severs,creating databases,confirming scripts to work with the databases
    etc. but little you know that some people dont know how to chmod files.know how can you become a
    good wap/web master without knowing the important basics? Never the less this tutorial will guide
    and teach you how to chmod files and the importance it has. How many times have you uploaded a
    script/file and did everything right but you still getting errors,or you not being able to ....
  16. How To Create Self-unzipping Files
    for beginners (18)
    This tutorial is based on winzip 10.0 (but it should work on other versions). Create or open the
    file you would like unzipped. Now, on the Actions menu, click make .exe file. A popup box should
    popup. Click ok. Now in the popup box that appears, type in the default folder that the program
    will unzip to. Press ok. Now another popup will tell you if you want to test the file, click yes.
    Now click ok again in the box that appears. Now press unzip. If it says - files unzipped
    succsessfully! Click ok and pat your self on the back! You have created the self-zipping ....
  17. How To: Ip Configuration Script (win Xp)
    If you travel a lot with your laptop, and need to switch between diff (0)
    How To: IP Configuration Script (win XP) If you travel a lot with your laptop, and need to switch
    between different IP's in different locations, this script is for you. There are many programs
    that handle this task very well, but they cost sometimes pretty big money. This tutorial will show
    you how to make your own IP Configuration Script for free. This script is for a static ip address
    configuration and is based on a little program called "NETSH.EXE" which is supplied with Windows.
    How it works. QUOTE Microsoft Windows XP - Using Netsh Netsh.exe is a....
  18. How To Protect A Directory From Being Viewed
    without admin username and password (4)
    Well i ran across this script awhile back, and i am tired of storing it on my computer, so i am
    going to post it here and whenever i need it i will come here and get it /biggrin.gif"
    style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> hopefully Anyways, it is a
    verry simple process just copy and paste this QUOTE if (($user) && ($passwort)) { # get url
    $url = $DOCUMENT_ROOT . dirname($PHP_SELF) . "/.htpasswd"; # make .htaccess and .htpasswd
    $htaccess_txt = "AuthType Basic" . "\n"; $htaccess_txt .= "AuthName \"protected area\"" . ....
  19. How To Open Bam & Tt Files, long 3 part tutorial
    (2)
    Part 1 Extracting files PLEASE DO NOT COPY ! This links with my other topic to 5.6 bams ,
    Loads of people have asked me how do you get pview , extract .mf files. Well im going to show you
    all in one. 1. Download Panda3D v.1.1.0 from here Start Picture Totorial Again, ugggh
    ! 1. Navigate your way to where you installed Panda3D ( It is usually : C:\Panda3D-1.1.0 )
    2. Open the bin folder in the Panda3d directory 3. Find and copy Multify.exe and PView.exe
    4. Paste the Files to the desktop 5. Navigate your way to C:\Documents and s....
  20. Templating System Using Php Includes
    Building a Dynamic site using Includes and flat-files. (13)
    Php based Templating System http://jlhaslip.trap17.com/template/index.php The Source Code
    for the scripts are included (literally) on the different pages on the Demo, including the Contact /
    Email script. The only page not there yet is the Message Script. Maybe tonight I will upload that.
    This one uses a little bit of query-string checking to confirm that the contents of the page are
    actually available (file_exists())and an allowed page content before serving it up. The
    'allowed page content' is done by checking against a flat-file containing an array....
  21. Page Generation Time Script
    A script to tell how long it took to generate (17)
    this is a script used to tell you or visitors how fast your page was generated for the person who is
    viewing it... Ok it is verry simple!! all you have to do is put this script on every page... that
    you want it to be on CODE $starttime = explode(' ', microtime()); $starttime =
    $starttime + $starttime ; ?> and put it before everything on the page, for me i put it right
    underneith the DOCTYPE script which i think is a bloody waste of space to have it on there, but
    anyways.. i put it right below that and it works fine!! now where you want the time it....
  22. Building An Unordered List Of Anchors
    From a list of files in a folder (4)
    Building an Unordered List of Anchors from a Folder of files This script reads files from the
    named folder and then builds a list of links from the filenames using the contents of the first
    tag as the link description and the file-name as the anchor href . The file should be a web
    readable file such as html or php. This script may come in handy for creating a list of clickable
    links for use in sidebars and on 'sitemap' pages. Simply build a series of html files and
    store them all in a single folder, ensuring that the description inside the first h3....
  23. Verifying Email Addresses
    Using a simple PHP script (9)
    This simple script will allow you to run some basic checks to make sure that any email address
    entered is actually an email address. There is no guarantee offered that this will stop every single
    fake email address, but it'll provide some protection. Now, the code! First we need to get the
    email address to verify. Here, I get it using POST from an HTML form. CODE //Load email
    address from web form $email = $_POST ; Now, we move on to our first check. Does the text that
    has been entered look like it could be an email address? This check can be performed....
  24. Delete Files And Directories Using Php
    following up from creating and writing (11)
    How To Delete Files and Directories follow up from creating them Hello all and
    welcome to my second tutorial involving file management. In my previous tutorial , I explained how
    to create, write and read files. In this tutorial I'll explain how to remove the files and
    directories you took so long to create. I did not explain last time how to create directories as I
    did not know, now I do, you can use the mkdir() function. Now with this tutorial.... Removing
    Files Removing files can easily be done with the unlink() function: CODE unlink("....
  25. How To Stop Image Hot Linking
    for a selected directory. (17)
    Those of you that don't know what is meant by 'hotlinking', it is when someone directly
    links to an image on your site so it will display on their site. This is what is called
    'bandwidth theft' and being as accounts here have a limit on bandwidth, your bandwidth limit
    could be exceeded by someone else hotlinking to your images. As most users of cPanel will know,
    there is an option to disable hotlinking of images in the "Site Management Tools" section.
    However, this disables hotlinking to all directories, what if you only want to disable hotlinki....
  26. How To Read And Write Files Using Php
    php :: reading and writing files (21)
    How To Read And Write And Files a simple trick using php For this script all you need is a
    php enabled server, a text document and a basic understanding of php itself: Beginning Create a
    text file called name.txt in any directory. Change the file permissions to 777 Create a empty
    php file in the same directory. You are now ready to begin reading and writing your files. If you
    just want to read the file scroll straight down to Reading the File else read through the whole
    tut /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /> ....
  27. Css And Javascript Combined For Dynamic Layout
    use of different CSS files at same site (9)
    This tutorial is meant for people that are dealing with problems while coding their site at 100% of
    width. Important notice: Some people has JavaScript disabled, so they will not be able to load CSS
    file (take this in account when creating your website). How this script works. In the HEAD of your
    HTML document will apply this command, so variable.js file will be load at start: CODE
    In browser JavaScript file variable.js is loaded. This Javascript file consist of this parameters,
    copy this code and name it variable.js CODE // JavaScript Document if (sc....
  28. [php] Simple Newsletter Script
    (17)
    This tutorial will give you the code needed and tell you how to implement it. First off you need to
    create a file called mailing.php this will be the file that processes the adding of emails to the
    list. CODE $email = $_POST ; $file = fopen("mailing.txt", "a"); fwrite($file, "\n" . $email);
    fclose($file); header("Location: mailing_thankyou.php"); ?> Next you need to create a file
    called mailing_thankyou.php , simple a page thanking them for signing up. Now create a file called
    mailing.txt with nothing in it, when uploaded to the server set it writable (c....
  29. Email Script/form With Php
    how to make a simple email script using php (37)
    Today, I'm going to show you how to make an email script using PHP and HTML. Most people usually
    put Email me if they want an email link on their site, but there are several cons to this.
    First, it's very inconvenient for those people who use web-based mail such as Yahoo!, Hotmail,
    or Gmail because that darn Micro$oft Outlook program comes up if one accidently click the link.
    Second, you are very suseptible to spam bots because they scan your HTML source code for anything
    with the same pattern as an email address and add it to their database. If you are pre....
  30. Php Quiz Script
    Make quizzes for your site. (29)
    Hello all, A little bit back I decided to make a quiz scriptjust out of no where lol. However it
    doesnt do anything special but I am going to make an email mod for it so that it will email results
    to your email address. So here is the basis of it. INSTRUCTIONS: Open a new page in your text
    editor and paste in the following code. CODE $qid = "Quiz ID-00"; ?>
    Username: 1.) Question number one is? Answer1 Answer2 2.) Question number two is?
    Answer1 Answer2 3.) Question number three is? Answer1 Answer2 4.) Question num....

    1. Looking for php, script, make, link, list, list, directory, files
Similar
Deny Or Grant Users Access To Files Of Choice (vista) - Uses Bat Files To Deny Or Grant People Access To Files
How To Create Pdf Files Using Free Tool - Introduction to use a free tool to create PDF file
Clearing Your Ie Tif - Clear your Temporary Internet Files on IE
How To Download Any Flv Files From Any Sites
Debug Exe Files - How to debug an exe file.
Download Files Off Esnips.com - even now that the download button is gone!
[phpbb] Member Last-visit Report Script - for phpbb2 databases
How To Hide Your Important Files And Folders - In Ms. Windows, Without Using Programmes.
Background Image Swap Script - Change a Background Image based on clock time
Image Rotator Script (another One) - easy to implement
How To Better Compress Files In Winrar
For ... Next Loops And Script Planning - My Fifth PHP Tutorial
Cpanel Analysis And Log Files - Part 4 of My 7 Part Tutorial
How To Fix Problems With Shareaza - ONLY for people to download LEGAL files with.
How To Chmod Files
How To Create Self-unzipping Files - for beginners
How To: Ip Configuration Script (win Xp) - If you travel a lot with your laptop, and need to switch between diff
How To Protect A Directory From Being Viewed - without admin username and password
How To Open Bam & Tt Files, long 3 part tutorial
Templating System Using Php Includes - Building a Dynamic site using Includes and flat-files.
Page Generation Time Script - A script to tell how long it took to generate
Building An Unordered List Of Anchors - From a list of files in a folder
Verifying Email Addresses - Using a simple PHP script
Delete Files And Directories Using Php - following up from creating and writing
How To Stop Image Hot Linking - for a selected directory.
How To Read And Write Files Using Php - php :: reading and writing files
Css And Javascript Combined For Dynamic Layout - use of different CSS files at same site
[php] Simple Newsletter Script
Email Script/form With Php - how to make a simple email script using php
Php Quiz Script - Make quizzes for your site.

Searching Video's for php, script, make, link, list, list, directory, files
See Also,
advertisement


Php Script To Make A Link List - From the list of the Directory Files

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com