EN | RU
This script is a simple PHP-based web application for secure access to files, using PDF as an example.
Features include:
- Authorization via secret key
- Client geolocation check and country-based access restriction
- Logging and emailing all access attempts with client information (IP, city, provider, User-Agent)
- Displaying a list of files with optional month-based filtering
- Downloading one or multiple files (ZIP archive for multiple selections)
- Simple design and ability to upload an organization logo
- PHP: version 7.4 or higher (8.0+ recommended)
- PHP extensions:
zip(for packaging multiple files into an archive)openssl(recommended for HTTPS support)
- Web server: Apache / Nginx
- Internet access to the
ip-api.comservice (for geolocation detection) - Write permissions for the following directories:
reports/temp/
- Clone the repository into your web server's directory:
git clone https://github.com/<your-username>/php-secure-report-viewer.git
- Navigate to the project folder:
cd php-secure-report-viewer - Create the required directories:
mkdir reports temp chmod 755 reports temp
- Make sure the web server has write permissions for these folders.
- Open the
index.phpfile in any text editor. - Specify your secret keys in the
$SECRET_KEYSarray:$SECRET_KEYS = [ '123345' => [ 'code' => 'test', // organization code (reports folder) 'name' => 'Display name' // display name ], ];
- Configure directories:
$BASE_DIR = __DIR__ . '/reports/'; $TEMP_DIR = __DIR__ . '/temp/';
- Set email addresses for notifications:
mail("receiver@example.com", ...);
- For each client, create a separate subfolder in
reports/:reports/ └── test/ ├── logo.png ├── work_report_2025-07-07_2025-07-11.pdf └── work_report_2025-07-14_2025-07-18.pdf
Main page with file list:
Month-based filtering:
Selecting and downloading files:
This project is distributed under the MIT license. You are free to use, modify, and distribute the script while retaining copyright.


