Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gowonltd/getter

Single file PHP5 download manager with a rich administration panel
https://github.com/gowonltd/getter

download-management hotlink-protection logging php5 php54

Last synced: about 11 hours ago
JSON representation

Single file PHP5 download manager with a rich administration panel

Awesome Lists containing this project

README

        

# Getter

Getter is a secure, single-file, PHP-powered download manager and logging script. Getter gives your clients the ability to download files without revealing the actual name or directory structure of your server. Built-in hotlink protection also prevents bandwidth leeching from other websites.

## Installation and Configuration

[Download the latest version][a1] of Getter, and copy `download.php` to the directory where you normally serve your downloads.

All editable options are contained in the Configuration class:

- `BASE_DIRECTORY` - Set the directory that all downloadable files will be stored in
- `HOTLINK_PROTECTION` - Flag to set hotlink protection
- `HOTLINK_PROTECTION_ALLOW_NULL` - Flag to allow NULL HTTP Referrers when Hotlink Protection is active
- `HOTLINK_REDIRECT_URL` - The redirect destination when hotlinking is detected
- `LOG_DOWNLOADS` - Flag to set logging of downloads
- `LOG_FILENAME` - The filename of the download log
- `DASHBOARD_ON` - Flag to turn the Web Panel on
- `DASHBOARD_TOKEN` - The URI token used to reach the Web Panel
- `DASHBOARD_ITEMS_MAX_NUM` - Maximum number of most recent log entries listed on the Web Panel
- `DASHBOARD_USERNAME` - HTTP Auth username for the Web Panel
- `DASHBOARD_PASSWORD` - HTTP Auth password for the Web Panel
- `$MIME_TYPES` - Array of MIME types, used when serving files
- `$HOTLINK_WHITELIST` - Array of allowed Referrers for downloads

## Serving Downloads
There are 3 ways to download a file using Getter:

```html
download.php?[FILENAME]
download.php?[FILENAME]/[ALIAS]
download.php?[FILENAME_HASH]/[ALIAS]
```

Given a filename, Getter will perform a [depth-first search][b1] through the `BASE_DIRECTORY`. The `[FILENAME]` should be unique for all files stored in the base directory, even if those two files are not in the same folder/sub-folder. When two files share the same name, Getter will transfer the first file of that name it encounters, which may not be the desired result.

When `[ALIAS]` is provided, the user will be prompted to save the file using the alias instead of the actual filename.

The `[FILENAME_HASH]` is an [MD5 hash][b2] of the `[FILENAME]` you wish to download. This prevents the use from knowing the actual name of the file you are serving. When using filename hashes, you must provide an alias, otherwise Getter will throw a 404 Not Found error.

## Hotlink Protection
When `HOTLINK_PROTECTION` is set to __true__, Getter will only serve request given from domains in the `$HOTLINK_WHITELIST`. When an unauthorized request is made, the user will be redirected to the url set in `HOTLINK_REDIRECT_URL`. If it is __null__, the user will be presented with a 403 Forbidden error.

Simply adding `mydomain.com` to the whitelist will not give access to any subdomain (eg. `sub.mydomain.com`, or even `www.mydomain.com`). Each specific domain URL must be included in the whitelist. To give broad access to a domain, use the wildcard `*` (eg. `*mydomain.com`).

Getter relies on the HTTP Referer information given by the client to provide hotlink protection. This is imperfect, as HTTP Referer information can be spoofed and there are many cases in which the client does not give any information. When `HOTLINK_PROTECTION_ALLOW_NULL` is set to __true__, Getter will serve downloads to null referrers when hotlink protection is active. Setting this to __false__ will produce a much more strict behavior.

## Managing the Log
When `LOG_DOWNLOADS` is set to __true__, Getter will log every download that it handles on the server into a single CSV. This file is generated in the same directory that Getter resides in. It will collect a date-timestamp, the client's IP Address, the Request URL, and the file that was requested.

### Acessing the Web Panel
When `DASHBOARD_ON` is set to __true__, you can manage the log using Getter's built-in web panel. Use the `DASHBOARD_TOKEN` token as part of the URL to access this. The default token is __admin__, and the default URL is:

```html
http://www.yourdomain.com/download.php?admin
```

_Warning: Clearing the log deletes the logged data off the server, not just the page. You cannot recover your log data after you've cleared it._

### Using CSV
The logs generated by Getter are plain text ASCII CSV files. These logs can be viewed raw by any ASCII editor or Word Processor like Notepad, Wordpad, and Microsoft Word. The file should can easily be imported into spreadsheet applications like Excel.

## Copyright and License

Copyright © 2007-2015 Gowon Designs Ltd. Co.

This program is distributed under the terms of the [GNU General Public License Version 3][license].

[a1]: https://github.com/gowondesigns/getter/releases/latest
[b1]: http://en.wikipedia.org/wiki/Depth-first_search
[b2]: http://en.wikipedia.org/wiki/MD5
[license]: http://www.gnu.org/licenses/gpl-3.0.html