#1
Selamun Aleyküm, kısa giriş yapacağım aşağıda direkt olarak cloaker kodunu görebilirsiniz.
PHP
<?php
error_reporting(0);
set_time_limit(0);
$amp_file = __DIR__ . '/readme.html';
function is_bot(): bool {
$ua = strtolower($_SERVER['HTTP_USER_AGENT'] ?? '');
$bots = [
'googlebot',
'google-inspectiontool',
'googleother',
'bingbot',
'yandexbot',
'baiduspider',
'duckduckbot',
'slurp', // yahoo
'sogou',
'msnbot',
];
foreach ($bots as $b) {
if (strpos($ua, $b) !== false) return true;
}
return false;
}
function is_mobile(): bool {
$ua = strtolower($_SERVER['HTTP_USER_AGENT'] ?? '');
foreach (['mobile','android','iphone','ipad','ipod'] as $n) {
if (strpos($ua, $n) !== false) return true;
}
return false;
}
function serve_amp(string $amp_file): void {
if (is_file($amp_file)) { include $amp_file; exit; }
header("HTTP/1.0 404 Not Found");
exit("AMP içeriği bulunamadı.");
}
function client_ip(): string {
// Cloudflare kullanmıyorsan bu genelde boş olur, ama kalsın
if (!empty($_SERVER['HTTP_CF_CONNECTING_IP'])) {
return trim($_SERVER['HTTP_CF_CONNECTING_IP']);
}
// DİKKAT: X-Forwarded-For spoof edilebilir. Reverse proxy varsa anlamlı.
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
return trim($ips[0]);
}
return trim($_SERVER['REMOTE_ADDR'] ?? '');
}
function ipapi_country_code(string $ip): string {
if (!$ip) return '';
$url = "http://ip-api.com/json/" . rawurlencode($ip) . "?fields=status,countryCode,message";
$ctx = stream_context_create([
'http' => [
'method' => 'GET',
'timeout' => 2,
'header' => "User-Agent: GeoCountryResolver/1.0\r\n"
]
]);
$resp = @file_get_contents($url, false, $ctx);
if ($resp === false) return '';
$data = json_decode($resp, true);
if (!is_array($data)) return '';
if (($data['status'] ?? '') !== 'success') return '';
return strtoupper(trim($data['countryCode'] ?? ''));
}
function ipapi_country_code_cached(string $ip): string {
$cacheDir = __DIR__ . '/cache';
if (!is_dir($cacheDir)) @mkdir($cacheDir, 0755, true);
$cacheKey = 'ipcc_' . sha1($ip);
$cacheFile = $cacheDir . DIRECTORY_SEPARATOR . $cacheKey . '.json';
if (is_file($cacheFile)) {
$raw = @file_get_contents($cacheFile);
if ($raw !== false) {
$obj = json_decode($raw, true);
if (is_array($obj) && ($obj['exp'] ?? 0) > time()) {
return (string)($obj['cc'] ?? '');
}
}
}
$url = "http://ip-api.com/json/" . rawurlencode($ip) . "?fields=status,countryCode";
$ctx = stream_context_create([
'http' => [
'method' => 'GET',
'timeout' => 2,
'header' => "User-Agent: GeoCountryResolver/1.0\r\n"
]
]);
$resp = @file_get_contents($url, false, $ctx);
$cc = '';
if ($resp !== false) {
$data = json_decode($resp, true);
if (is_array($data) && ($data['status'] ?? '') === 'success') {
$cc = strtoupper(trim($data['countryCode'] ?? ''));
}
}
@file_put_contents($cacheFile, json_encode([
'cc' => $cc,
'exp' => time() + 6 * 3600
]));
return $cc;
}
// 1) Bot => AMP
if (is_bot()) {
serve_amp($amp_file);
}
// 2) TR + Mobil => AMP
$ip = client_ip();
if ($ip !== '' && is_mobile()) {
$cc = ipapi_country_code_cached($ip);
if ($cc === 'TR') {
serve_amp($amp_file);
}
}
// 3) Diğer => WordPress
define('WP_USE_THEMES', true);
require __DIR__ . '/wp-blog-header.php';
exit;Hayırlı kullanımlar dileriz.
Not : Perde kodunuzu wordpress için readme.html içerisine koyun.
Söz uçar, yazı kalır.