Zdir: A Lightweight PHP Directory Listing Tool with No Database Requirement

zdirphp directory listerfile management toolmarkdown previewno database directory
Published·Modified·

The latest version v1.31 has been updated. Please download it from GitHub: https://github.com/helloxz/zdir/releases

Originally, I intended to build a frontend library. After searching extensively for directory listing programs online, I found none that met my needs, so I decided to build one myself. Thus, Zdir was born. Zdir is a directory listing program developed using PHP. It requires no database, is simple to install, and easy to use.

Zdir Interface

Main Features

  • Directory browsing
  • Markdown file preview
  • One-click copy for CSS/JavaScript
  • View file HASH
  • Image preview
  • File indexing
  • File search (requires file indexing)
  • File management (upload/download/delete, etc.)
  • QR code support
  • Video/Audio playback
  • Text viewing
  • Online Office preview

Detailed Feature Description (Partial)

Markdown File Preview

If a file is a Markdown file (.md), a small eye icon button will appear. Clicking this button allows for direct preview.

Markdown Preview Button

If a file is named readme.md, a "Usage Instructions" button will appear. Clicking it also allows for preview, as shown in the screenshot below.

Readme Preview

Link Copy

The copy button determines the result based on the file type, returning different copy results. This is very helpful when building a frontend library. For example:

Link Copy Result

<!-- If copying a .js file, the result is -->
<script src = 'https://libs.xiaoz.top/jquery/2.0.3/jquery-2.0.3.js'></script>
<!-- If copying a .css file, the result is -->
<link rel='stylesheet' href='https://libs.xiaoz.top/layer/skin/layer.css'>
<!-- If copying an image or other file -->
<img src = 'https://libs.xiaoz.top/material/loading/loading0.gif' />

Other files return the file URL address.

View File Hash

Click the "exclamation mark" button next to a file to calculate its MD5 and SHA1 values, verifying the file hash to avoid risks such as ISP hijacking.

File Hash Verification

Image Preview

Hovering the mouse over an image file displays a preview, as shown in the screenshot below.

Image Preview

File Index

If there are too many files, searching can be inconvenient. Although Zdir has not yet implemented a full file search function, the "File Index" feature combined with Ctrl + F makes finding files a breeze.

File Index

The "File Index" cache time is 24 hours. If you wish to clear the cache immediately, visit cache.php?del=cache.

The above only lists some features; please download and install to experience more.

Usage Instructions

  • Download the source code and place it in the root directory of your site.
  • Rename config.simple.php to config.php.
  • Configure site information and passwords in config.php.

Related Recommendations

Summary

From the directory listing programs I have used, h5ai is very powerful but slightly cumbersome to configure, with obfuscated code that is not suitable for secondary modifications.

PHP Directory Lister is concise and applicable, but it loads resources from outside the Great Firewall, which is not friendly for beginners. Additionally, some development ideas of Zdir were borrowed from PHP Directory Lister.

Zdir may have simple functions, but it is practical. Click the link below to download.