1. Go to this page and download the library: Download gembla/traffic-rotator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gembla / traffic-rotator example snippets
embla\TrafficRotator\Rotator;
// Check and automatically create the logs directory if it does not exist
$logDir = __DIR__ . '/logs';
if (!is_dir($logDir)) {
mkdir($logDir, 0755, true);
}
// Set up the dynamic path to the log file (a new file each month)
$logPath = $logDir . '/clicks_' . date('Y-m') . '.log';
$rotator = new Rotator($logPath);
// Add casino offer URLs and their respective weights
// The system automatically calculates percentages based on the total sum of all weights
$rotator->addOffer('https://casino-brand-a.com', 20);
$rotator->addOffer('https://casino-brand-b.com', 50);
$rotator->addOffer('https://casino-brand-c.com', 30);
$rotator->addOffer('https://casino-brand-aa.com', 70);
// Selects a random offer based on weight, records the click to the log, and executes a secure redirect
$rotator->redirect();
if ($rotator->hasOffers()) {
$rotator->redirect();
} else {
// Fallback logic if no offers are available
header("Location: https://your-default-landing.com");
exit;
}
bash
composer dump-autoload
bash
php -S localhost:8000
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.