Jul 26, 2008

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

Free Web Hosting, No Ads > CONTRIBUTE > Tutorials

free web hosting

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.

 

 

 


Reply

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.

Reply

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.

Reply

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.

Reply

LevinZ
nice guide.....

Reply

angel86
hi good tutoriaal biggrin.gif

nice smile.gif

Reply

FA Ace

Great Script, Hope you make more wink.gif

Reply



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*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

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

  1. Debug Exe Files
    How to debug an exe file. (4)
  2. 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....
  3. [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', '....
  4. 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 At....
  5. 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 <?php $hour =
    date('H'); if ($hour < 12 ) {     $image =
    "morning.png"; } ....
  6. 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); }....
  7. 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....
  8. 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....
  9. 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 ....
  10. 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....
  11. Flatfile User Login/signup
    Uses text files only (compatable with forums and message system) (24)
    With this tutorial, you will learn how to create a textfile login script. This user membership
    script is for use also with my forums and message system scripts. I will also give you the scripts
    to make it so that people can change their profiles. Ok, The first thing we need to do is make the
    database. To do this, create a blank text file called 'userdata.txt' , make sure it is ALL
    LOWER-CASE. Edit this file and put
    '**username|##|password|##|email|##|rank|##|userid|##|name|##|picture**'. This will not be
    used, however it will give you an idea of how the....
  12. 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 ....
  13. 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-....
  14. 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....
  15. 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....
  16. 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:�....
  17. 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....
  18. How To Create Html Page Anchors
    Click A Link And Take You To A Certin Place On The Same Page (5)
    Have you ever wondered how people have a normal link but all it does it take you to the middle of a
    long page? well here is a solution DEMO: Here Ok well first off for the link it will be just
    like a normal link code except you wont put a http://URL.com/file.php it will look somthing like
    this QUOTE name ">Click This Link! there must be a # sign in front of this to work..
    now, for the content that the person will be re-directed to after clicking the link QUOTE name
    "> the items in bold is what you need to change QUOTE name "> i....
  19. Php Menu Bulding Script And Site Template
    available for download (0)
    A Php Menu-builder Tutorial This Sidebar Menu-builder code and the php scripts are adapted from
    a Tutorial on the Astahost.com Forum titled : CMS101 - Content Management System Design .
    Since the original tutorial's author (vujsa) did such a marvellous job of describing the system
    in the original Topic posting, I will not attempt to explain it here, rather, I invite you to have a
    look at his Topic and learn from it. The Basic tutorial provided coding for developing a table-based
    web-site template which used php includes and embedded data to create a &....
  20. Script To Build A List Of Links
    from filenames and h3 tags (2)
    Another Unordered List Script If you remember this Script , that tutorial was about creating
    an un-ordered list of links from a list of files contained in a Folder which was specifically named
    in the script. This current Tutorial goes several steps beyond that first Tutorial by being able to
    create a list from several folder names and, more importantly, the script reads the list of links
    from a 'flat file' rather than depending on the name of the folder to be hard coded in the
    script. It is only one small step to have the folder names found in a mysql ....
  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 <?php $starttime = explode(' ',
    microtime()); $starttime = $starttime[1] + $starttime[0];
    ?> 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.. ....
  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. How To Set Up A Phbb Forum On A Simple Page.
    simple page link to phBB (4)
    Ok, I am going to teach you how to set up and include a phBB Forum on your web site hsted on your
    local computer set up as a Server. This tutorial references to snlildude87's tutorial at
    http://www.trap17.com/forums/-t20432.html . You have to set up a MYSQL DATABASE and a Apache server
    sucessfully in order for this to work. Do that first then come here and we can start. Ok, Now that
    you got your Apache server set up and your MYSQL Database setup according to the Tutorial from
    snllildude87, lets BEGIN! Step 1: First off you got to have a working HTML page wit....
  24. Delete Files And Directories Using Php
    following up from creating and writing (7)
    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 <? un....
  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 (20)
    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
    <script type="text/javascript" src="variable.js"></script> In
    browser JavaScript file variable.js is loaded. This Javascript file consist of this para....
  28. Secure The Email Addresses On Your Website!
    Wonderful script and useful! And working (10)
    Just follow the instructions below: /* Secure Email Function by Juan Karlo Aquino de
    Guzman Website: http://www.karlo.ph.tc and http://www.abs-cbn.ph.tc E-mail:
    http://www.karlo.ph.tc/send.php Usage: showEmail("support@microsoft.com",0); OR
    showEmail("support@microsoft.com",1); Types: 0 = ordinary random 1 = more secure random To
    include to a script: include_once("email_secure.php"); */ And here is the code :
    CODE <?php /*     Secure Email Function by Juan Karlo Aquino de Guzman     Website:
    http://www.karlo.....
  29. Email Script/form With Php
    how to make a simple email script using php (35)
    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 yo....
  30. Php Quiz Script
    Make quizzes for your site. (20)
    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 <?php $qid = "Quiz ID-00"; ?>
    <html> <head> <title><? echo "Gamers Pub $qid";
    ?></title> </head> <body> <p><h3><? echo "....

    1. Looking for php, script, make, link, list, list, directory, files

Searching Video's for php, script, make, link, list, list, directory, files
Similar
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.
Flatfile
User
Login/signup
- Uses text
files only
(compatable
with forums
and message
system)
How To Chmod
Files
How To
Create
Self-unzippi
ng Files -
for
beginners
How To: Ip
Configuratio
n 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.
How To
Create Html
Page Anchors
- Click A
Link And
Take You To
A Certin
Place On The
Same Page
Php Menu
Bulding
Script And
Site
Template -
available
for download
Script To
Build A List
Of Links -
from
filenames
and h3 tags
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
How To Set
Up A Phbb
Forum On A
Simple Page.
- simple
page link to
phBB
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
Secure The
Email
Addresses On
Your
Website!
- Wonderful
script and
useful!
And working
Email
Script/form
With Php -
how to make
a simple
email script
using php
Php Quiz
Script -
Make quizzes
for your
site.
advertisement



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



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE