Skip to content

BaseMax/server-side-text-search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

🔍 Server-Side Text Search (PHP)

A fast, dependency-free, single-file PHP tool for recursively searching files and directories on the server.

This project provides a powerful web-based interface to scan directories, filter files, and search content using plain text or regular expressions all from a single index.php file.


✨ Features

  • High-performance recursive search
  • 🔎 Content-based search (text or regex)
  • 📁 File filtering by extension, name, or path
  • 🚫 Exclude/include directories and files
  • 🔤 Case-sensitive / insensitive search
  • 🧠 Whole-word matching support
  • 📊 Search statistics (files, matches, size, time)
  • 📄 Line previews with highlighting
  • 🛑 Binary file detection
  • 📏 File size limits for safe scanning
  • 🔐 Root jail protection (filesystem restriction)
  • 🧾 Single-file deployment (no dependencies)

📸 Overview

This tool provides a clean web UI to:

  • Input a base directory
  • Define search conditions
  • Execute scans
  • View matched files with highlighted results

🚀 Installation

  1. Clone the repository:
git clone https://github.com/BaseMax/server-side-text-search.git
  1. Upload index.php to your server:
/var/www/html/index.php
  1. Open in browser:
http://your-domain.com/index.php

⚙️ Configuration

Inside index.php, modify the $CONFIG array:

$CONFIG = [
    'base_path'      => __DIR__,
    'root_jail'      => __DIR__,
    'max_file_bytes' => 5 * 1024 * 1024,
    'max_results'    => 2000,
    'max_preview'    => 5,
    'max_depth'      => 0,
];

Important Options

Option Description
base_path Default search directory
root_jail Restricts search to a safe directory
max_file_bytes Max file size to scan
max_results Maximum returned results
max_depth Directory recursion depth

🔐 Security Warning

⚠️ This tool provides direct access to your filesystem.

You MUST:

  • Protect with authentication (e.g., HTTP auth)
  • Restrict access via IP or VPN
  • Configure root_jail properly
  • Never expose publicly without protection

🧪 Usage

Basic Search

  • Enter a base path
  • Enter text to search
  • Click Search

Advanced Options

  • Regex search
  • Case sensitivity toggle
  • Whole word matching
  • Include/exclude filters
  • File extension filtering

Example Queries

Use Case Input
Find PHP functions function\s+\w+\( (Regex ON)
Find exact word Enable "Whole word"
Only PHP files php in extensions
Exclude vendor vendor in ignore dirs

📊 Output

Each result shows:

  • File path
  • Match count
  • File size
  • Last modified time
  • Preview lines with highlights

🏗️ Architecture

  • Pure PHP (no frameworks)
  • Recursive directory traversal
  • Line-by-line file scanning
  • Memory-efficient processing
  • Early stopping via caps

⚡ Performance Notes

  • Skips large files (configurable)
  • Avoids binary files automatically
  • Limits results for responsiveness
  • Uses streaming (fgets) instead of loading full files

📁 Project Structure

.
├── index.php     # Main application (single file)
├── README.md
└── LICENSE

🧩 Use Cases

  • Debugging large codebases
  • Searching logs on production servers
  • Finding hardcoded values
  • Security audits
  • DevOps file inspection

📜 License

This project is licensed under the GPL-3.0 License.


⭐ Support

If you find this project useful:

  • Star the repository ⭐
  • Share it with others
  • Contribute improvements

🤝 Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.


🔧 Future Improvements

  • CLI version
  • API endpoint support
  • Export results (JSON/CSV)
  • Async scanning
  • Multi-threading (via extensions)

⚠️ Disclaimer

This tool is provided "as-is" without any warranties. Use at your own risk, especially in production environments.


© Copyright

Copyright © 2026 Seyyed Ali Mohammadiyeh (Max Base) All rights reserved.

About

A fast, dependency-free, single-file PHP tool for recursively searching files and directories on the server. This project provides a powerful web-based interface to scan directories, filter files, and search content using plain text or regular expressions all from a single `index.php` file.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages