Php Script for Directory Listing

This php script allows you to host a directory listing similar to that of Yahoo and Google. This script makes searching for sites more organized and easier. Information is stored in a MySQL database which can be updated via a text file. The search query is performed using regular expressions, which are optimized to run fast on large directories. Syntax highlighting functions are used to highlight input fields, making them easy to read.

An easy to install PHP script generates an alphabetical listing of your file directory and subdirectories when a web browser requests the filename.php from the same directory. Your visitors can browse the entire directory structure with just one click!

PHP DIRECTORY LISTING SCRIPT

Back in 2008 we created the original version of our popular directory listing script. Since then we’ve released three new versions, addressing a number of known issues. In 2015 we completely rebuilt the script from scratch, introducing some handy new features and improvements.

The PHP Directory Listing Script is a highly configurable script, allowing you to simply upload one file into a web-accessible directory, and it’ll be turned into a well formatted, mobile friendly directory browser.

With the release of version 4, we’ve got some great new features, including:

  • Full mobile browser support.
  • The ability to upload multiple files and restrict the allowed file-types.
  • Support for restricting access to the script by either password or IP Address whitelisting (ideal if you want only yourself and clients to have access!).
  • Support for creating new directories and sub-directories.
  • Upload zip files and extract them automatically, with the option to delete the zip file after it’s been extracted.
  • Optionally hide certain file types, names or extensions, as well as directories.
  • Sort file listings by name, size or last modified date.

Finally, the last feature is that the Directory Listing Script now runs as a single file, weighing in at less than 400kb. This means the script runs faster, and is extremely easy to use!

All of the new features can be enabled and disabled individually, so whether you’re looking for a full file manager, or a simple list of downloads, the PHP Directory Listing script has you covered.

SYSTEM REQUIREMENTS

To run the PHP Directory Listing Script on your website, you’ll need to be running PHP 5.3 or above and have the GD2 library installed. If you wish to enable the unzip support, you’ll also need the ZipArchive php extension installed.

Viavi – Directory Listing Script

byviaviwebtech in Miscellaneous

  • Software Version: PHP 5.6 – 7.x, MySQL 5.x
  • Software Framework: Laravel

File Types Included:

  • JavaScript JS
  • HTML
  • CSS
  • PHP

DirList – Complete Business Directory and Listing Script (SaaS)

bywebsolutionus in Miscellaneous

  • Software Version: PHP 7.x
  • Software Framework: Laravel

File Types Included:

  • JavaScript JS
  • JavaScript JSON
  • HTML
  • CSS
  • PHP
  • SQL

The opendirreaddir, and closedir Functions

In this section, we’ll discuss the opendirreaddir, and closedir functions to see how you can use them to get a list of files in a specific directory.

The opendir function allows you to open up a directory handle, which you can use along with other functions for different operations on the directory. You need to pass the path to the directory in the first argument of the opendir function. If the directory path is valid, a directory handle resource will be returned.

The readdir function allows you to read a directory. You need to provide a valid directory handle in the first argument of the readdir function, and you can iterate over all the entries and get a list of all files in a directory.

The closedir function allows you to close the directory handle which is opened by the opendir function. It’s a good practice to use the closedir function once you’re done with your operations on the directory handle (which was initially opened by the opendir function).

Now, let’s see it in action in the following example.

010203040506070809101112<?php$arrFiles = array();$handle = opendir('/path/to/directory'); if ($handle) {    while (($entry = readdir($handle)) !== FALSE) {        $arrFiles[] = $entry;    }} closedir($handle);?>

Firstly, we’ve used the opendir function to get the directory handle. Next, we’ve used the readdir function to iterate over the $handle directory handle and store a list of files in the $arrFiles array.

Urbainx – Modern Directory Listing Script Theme

byMeteros in Miscellaneous

  • Software Version: PHP 7.x, MySQL 5.x
  • Software Framework: Laravel

File Types Included:

  • JavaScript JS
  • JavaScript JSON
  • HTML
  • CSS
  • PHP
  • SQL

The scandir Function

In this section, we’ll see how you can use the scandir function to get directory contents.

The scandir function is a pretty straightforward way to get a list of files and directories in a specific directory. You just need to pass a directory path which you want to read in the first argument of the scandir function.

Let’s go through the following example to understand how it works.

123<?php$arrFiles = scandir('/path/to/directory');?>

As you can see, this provides a list of files and directories in a single call! If you just need to get a list of files in a directory, this is a better choice than using opendirreaddir, and closedir

Guido – Directory & Listing Laravel Script

byBookingCore in Php Scripts

  • Software Version: PHP 7.x – 8.x
  • Software Framework: Laravel

File Types Included:

  • JavaScript JS
  • HTML
  • CSS
  • PHP

The glob Function

The glob function works similarly to the scandir function, with the difference that it allows you to specify a pattern for filtering and matching the files in the directory.

Let’s see how to use the glob function to read all the contents of a specific directory.

123<?php$arrFiles = glob('/path/to/dir/*');?>

As you can see, we’ve passed the * pattern since we want to read all the contents. On the other hand, if you want to list only a specific type of file, you can do that as well, as shown in the following snippet.

123<?php$arrFiles = glob('/path/to/dir/*.txt');?>

in this case, $arrFiles would contain only the names of .txt files.

The dir Function

The options that we’ve discussed so far allow you to read directory contents in a procedural way. In this section, we’ll see how you can use the dir function, which is an object-oriented mechanism for reading a directory.

When you use the dir function, and pass a directory path in the first argument, it returns an instance of the Directory class, which you can use subsequently to read the directory contents.

Let’s go through the following example to see how it works exactly.

01020304050607080910<?php$arrFiles = array();$objDir = dir("/path/to/dir"); while (false !== ($entry = $objDir->read())) {   $arrFiles[] = $entry;} $objDir->close();?>

First, we used the dir function to initialize an instance of the Directory class into the $objDir variable. Next, we used the read method of the Directory class to iterate over all the entries.

Conclusion

This Php script allows you to create a directory listing. It comes with cron-job capabilities and requires no database.

0 Comments

No Comment.