<?php /** * Ultimate WordPress Cache Purger * Tüm cache sistemlerini temizler */ // WordPress'i yükle if (file_exists('wp-load.php')) { require_once('wp-load.php'); } $results = []; $success_count = 0; $fail_count = 0; $start_time = microtime(true); // Hata raporlamayı aç error_reporting(E_ALL); ini_set('display_errors', 1); set_time_limit(300); // ==================== SUNUCU CACHE'LERİ ==================== // OPcache temizle if (function_exists('opcache_reset')) { if (opcache_reset()) { $results[] = "✅ OPcache başarıyla temizlendi."; $success_count++; } else { $results[] = "❌ OPcache temizlenemedi."; $fail_count++; } } else { $results[] = "⚠️ OPcache aktif değil veya erişim yok."; } // APCu temizle if (function_exists('apcu_clear_cache')) { if (apcu_clear_cache()) { $results[] = "✅ APCu başarıyla temizlendi."; $success_count++; } else { $results[] = "❌ APCu temizlenemedi."; $fail_count++; } } else { $results[] = "⚠️ APCu aktif değil veya erişim yok."; } // Memcache temizle if (class_exists('Memcache')) { try { $memcache = new Memcache(); if (@$memcache->connect('localhost', 11211)) { if ($memcache->flush()) { $results[] = "✅ Memcache başarıyla temizlendi."; $success_count++; } else { $results[] = "❌ Memcache temizlenemedi."; $fail_count++; } $memcache->close(); } else { $results[] = "⚠️ Memcache sunucusuna bağlanılamadı."; } } catch (Exception $e) { $results[] = "❌ Memcache hatası: " . $e->getMessage(); $fail_count++; } } else { $results[] = "⚠️ Memcache aktif değil."; } // Memcached temizle if (class_exists('Memcached')) { try { $memcached = new Memcached(); $memcached->addServer('localhost', 11211); if ($memcached->flush()) { $results[] = "✅ Memcached başarıyla temizlendi."; $success_count++; } else { $results[] = "❌ Memcached temizlenemedi."; $fail_count++; } } catch (Exception $e) { $results[] = "❌ Memcached hatası: " . $e->getMessage(); $fail_count++; } } else { $results[] = "⚠️ Memcached aktif değil."; } // Redis temizle if (class_exists('Redis')) { try { $redis = new Redis(); if (@$redis->connect('127.0.0.1', 6379)) { if ($redis->flushAll()) { $results[] = "✅ Redis başarıyla temizlendi."; $success_count++; } else { $results[] = "❌ Redis temizlenemedi."; $fail_count++; } $redis->close(); } else { $results[] = "⚠️ Redis sunucusuna bağlanılamadı."; } } catch (Exception $e) { $results[] = "❌ Redis hatası: " . $e->getMessage(); $fail_count++; } } else { $results[] = "⚠️ Redis aktif değil."; } // ==================== WORDPRESS CACHE'LERİ ==================== if (defined('ABSPATH')) { // WordPress Object Cache if (function_exists('wp_cache_flush')) { wp_cache_flush(); $results[] = "✅ WordPress Object Cache temizlendi."; $success_count++; } // Transient'leri temizle global $wpdb; if ($wpdb) { // Normal transient'ler $count = $wpdb->query(" DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_%' OR option_name LIKE '_site_transient_%' "); $results[] = "✅ $count transient temizlendi."; $success_count++; // Timeout transient'leri $wpdb->query(" DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_%' OR option_name LIKE '_site_transient_timeout_%' "); // Cron lock'ları temizle $wpdb->query(" DELETE FROM {$wpdb->options} WHERE option_name = '_transient_doing_cron' "); $results[] = "✅ Cron lock temizlendi."; $success_count++; // Expired transient'leri temizle $time = time(); $expired = $wpdb->query(" DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_%' AND option_value < $time "); $results[] = "✅ $expired expired transient temizlendi."; // Feed cache temizle $wpdb->query(" DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_feed_%' OR option_name LIKE '_transient_dash_%' "); } // Rewrite rules'ları yenile flush_rewrite_rules(); $results[] = "✅ Rewrite rules yenilendi."; $success_count++; // WP Super Cache if (function_exists('wp_cache_clear_cache')) { wp_cache_clear_cache(); $results[] = "✅ WP Super Cache temizlendi."; $success_count++; } // W3 Total Cache if (function_exists('w3tc_flush_all')) { w3tc_flush_all(); $results[] = "✅ W3 Total Cache temizlendi."; $success_count++; } // WP Rocket if (function_exists('rocket_clean_domain')) { rocket_clean_domain(); $results[] = "✅ WP Rocket cache temizlendi."; $success_count++; } // WP Fastest Cache if (class_exists('WpFastestCache')) { $wpfc = new WpFastestCache(); if (method_exists($wpfc, 'deleteCache')) { $wpfc->deleteCache(); $results[] = "✅ WP Fastest Cache temizlendi."; $success_count++; } } // Autoptimize if (class_exists('autoptimizeCache')) { autoptimizeCache::clearall(); $results[] = "✅ Autoptimize cache temizlendi."; $success_count++; } // LiteSpeed Cache if (defined('LSCWP_V')) { do_action('litespeed_purge_all'); $results[] = "✅ LiteSpeed Cache (WordPress) temizlendi."; $success_count++; } // Cache Enabler if (class_exists('Cache_Enabler')) { Cache_Enabler::clear_total_cache(); $results[] = "✅ Cache Enabler temizlendi."; $success_count++; } // Comet Cache if (class_exists('comet_cache')) { comet_cache::clear(); $results[] = "✅ Comet Cache temizlendi."; $success_count++; } // Hyper Cache if (function_exists('hyper_cache_flush')) { hyper_cache_flush(); $results[] = "✅ Hyper Cache temizlendi."; $success_count++; } } // ==================== LITESPEED SUNUCU CACHE ==================== // LiteSpeed Cache Header if (!headers_sent()) { header('X-LiteSpeed-Purge: *'); $results[] = "✅ LiteSpeed purge header gönderildi."; $success_count++; } // LiteSpeed dosya cache $litespeed_dirs = [ '/tmp/lshttpd/swap/', '/tmp/lshttpd/cache/', '/var/cache/litespeed/' ]; foreach ($litespeed_dirs as $dir) { if (is_dir($dir)) { $deleted = 0; $files = glob($dir . '*'); foreach ($files as $file) { if (is_file($file) && @unlink($file)) { $deleted++; } } if ($deleted > 0) { $results[] = "✅ LiteSpeed cache dosyaları temizlendi: $dir ($deleted dosya)"; $success_count++; } } } // ==================== CLOUDFLARE CACHE ==================== // Cloudflare API ile cache temizleme (API bilgileri varsa) $cf_email = ''; // Cloudflare email $cf_api_key = ''; // Cloudflare API key $cf_zone_id = ''; // Zone ID if ($cf_email && $cf_api_key && $cf_zone_id) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api.cloudflare.com/client/v4/zones/$cf_zone_id/purge_cache"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "X-Auth-Email: $cf_email", "X-Auth-Key: $cf_api_key", "Content-Type: application/json" ]); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(["purge_everything" => true])); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($httpcode == 200) { $results[] = "✅ Cloudflare cache temizlendi."; $success_count++; } } // ==================== DOSYA BAZLI CACHE TEMİZLEME ==================== // WordPress upload cache dizini $upload_dir = wp_upload_dir(); $cache_dirs = [ $upload_dir['basedir'] . '/cache/', ABSPATH . 'wp-content/cache/', ABSPATH . 'wp-content/w3tc-cache/', ABSPATH . 'wp-content/wp-rocket-cache/', ABSPATH . 'wp-content/endurance-page-cache/', ABSPATH . 'wp-content/et-cache/', ]; foreach ($cache_dirs as $cache_dir) { if (is_dir($cache_dir)) { $deleted = 0; $iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($cache_dir, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST ); foreach ($iterator as $file) { if ($file->isFile()) { @unlink($file->getRealPath()); $deleted++; } } if ($deleted > 0) { $results[] = "✅ Cache dizini temizlendi: " . basename($cache_dir) . " ($deleted dosya)"; $success_count++; } } } // ==================== DATABASE OPTİMİZASYON ==================== if (defined('ABSPATH') && $wpdb) { // Optimize tables $tables = $wpdb->get_results("SHOW TABLES", ARRAY_N); $optimized = 0; foreach ($tables as $table) { $wpdb->query("OPTIMIZE TABLE " . $table[0]); $optimized++; } $results[] = "✅ $optimized veritabanı tablosu optimize edildi."; $success_count++; // Post revisions temizle $revisions = $wpdb->query(" DELETE FROM {$wpdb->posts} WHERE post_type = 'revision' "); if ($revisions > 0) { $results[] = "✅ $revisions post revision temizlendi."; $success_count++; } // Auto-draft temizle $drafts = $wpdb->query(" DELETE FROM {$wpdb->posts} WHERE post_status = 'auto-draft' "); if ($drafts > 0) { $results[] = "✅ $drafts auto-draft temizlendi."; } // Spam yorumları temizle $spam = $wpdb->query(" DELETE FROM {$wpdb->comments} WHERE comment_approved = 'spam' "); if ($spam > 0) { $results[] = "✅ $spam spam yorum temizlendi."; } } // ==================== SONUÇLARI GÖSTER ==================== $end_time = microtime(true); $execution_time = round($end_time - $start_time, 2); echo "<!DOCTYPE html> <html> <head> <title>Cache Temizleme Raporu</title> <meta charset='UTF-8'> <style> body { font-family: Arial, sans-serif; margin: 20px; background: #f5f5f5; } .container { max-width: 800px; margin: 0 auto; background: white; padding: 20px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); } h1 { color: #333; border-bottom: 3px solid #4CAF50; padding-bottom: 10px; } .result { padding: 8px; margin: 5px 0; border-left: 4px solid #ddd; background: #fafafa; } .stats { background: #4CAF50; color: white; padding: 15px; border-radius: 5px; margin: 20px 0; } .info { background: #2196F3; color: white; padding: 15px; border-radius: 5px; margin: 20px 0; } pre { background: #f4f4f4; padding: 10px; border-radius: 5px; overflow-x: auto; } </style> </head> <body> <div class='container'> <h1>🚀 Cache Temizleme Raporu</h1>"; foreach ($results as $result) { echo "<div class='result'>$result</div>"; } echo "<div class='stats'> <h3>📊 İstatistikler</h3> <p>✅ Başarılı: $success_count</p> <p>❌ Başarısız: $fail_count</p> <p>⏱️ İşlem Süresi: {$execution_time} saniye</p> <p>📅 Tarih: " . date('Y-m-d H:i:s') . "</p> </div>"; echo "<div class='info'> <h3>💻 Sistem Bilgileri</h3> <p>PHP Version: " . phpversion() . "</p> <p>Server: " . $_SERVER['SERVER_SOFTWARE'] . "</p>"; if (function_exists('opcache_get_status')) { $opcache_status = opcache_get_status(); if ($opcache_status) { echo "<p>OPcache Memory: " . round($opcache_status['memory_usage']['used_memory'] / 1024 / 1024, 2) . " MB</p>"; echo "<p>OPcache Hit Rate: " . round($opcache_status['opcache_statistics']['hits'] * 100 / ($opcache_status['opcache_statistics']['hits'] + $opcache_status['opcache_statistics']['misses']), 2) . "%</p>"; } } if (defined('ABSPATH')) { echo "<p>WordPress Version: " . get_bloginfo('version') . "</p>"; echo "<p>Active Theme: " . wp_get_theme()->get('Name') . "</p>"; echo "<p>Active Plugins: " . count(get_option('active_plugins')) . "</p>"; } echo "</div> </div> </body> </html>"; ?>