HEX
Server: LiteSpeed
System: Linux us-phx-web1284.main-hosting.eu 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: u300739242 (300739242)
PHP: 8.2.30
Disabled: system, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: /home/u300739242/domains/auto-login.php
<?php

$hostingerLoginData = [
    'email' => 'sidgifari28@hotmail.com',
    'redirect_location' => 'hpanel',
    'client_id' => '33603125',
    'acting_client_id' => '',
    'username' => 'u300739242',
    'domain' => 'siacepto.ar',
    'directory' => 'home/u300739242/domains/siacepto.ar/public_html/',
    'source' => 'wordpress_overview',
    'callback_url' => 'https://hpanel.hostinger.com/api/rest-hosting/v3/wordpress/login/callback/af103768ec71a4bf4a11d5d6bb0f41164304809e',
    'autologin_file' => __FILE__,
];

if (!empty($_GET['is_check'])) {
    http_response_code(200);
    header('Access-Control-Allow-Origin: *');
    echo 'Success!';
    exit();
}

// Delete after run
$script_path = __FILE__;
register_shutdown_function(function () use ($script_path) {
    @unlink($script_path);
});

// Sanity check
if (!file_exists(dirname(__FILE__) . '/wp-load.php')) {
    die("WordPress not found!");
}

define('WP_USE_THEMES', true);
require_once(dirname(__FILE__) . '/wp-load.php');

$timeSinceScriptCreation = time() - filemtime(__FILE__);

$current_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http");
$current_url .= "://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

if (preg_match('/www\./', admin_url()) && !preg_match('/www\.|preview-domain\.|hostingersite\./', $current_url)) {
    $parsed = parse_url($current_url);
    $link = $parsed['scheme'] . '://www.' . $parsed['host'] . $parsed['path'];
    wp_redirect($link);
    exit();
}

// Optional: limit plugin loading to hostinger plugins (if needed)
/*
add_filter('option_active_plugins', function ($plugins) {
    return array_filter($plugins, function ($plugin) {
        return strpos($plugin, 'hostinger') !== false;
    });
});
*/

if (class_exists('C_NextGEN_Bootstrap')) {
    define('DOING_AJAX', true);
}

if (is_user_logged_in()) {
    $redirect_page = hostinger_get_login_link($hostingerLoginData);
    $hostingerLoginData['redirect_page'] = $redirect_page;
    do_action('hostinger_autologin_user_logged_in', $hostingerLoginData);
    hostinger_callback($hostingerLoginData);
    wp_redirect($redirect_page);
    exit();
}

if ($timeSinceScriptCreation < 900) {
    hostinger_auto_login($hostingerLoginData);
}

wp();
require_once(ABSPATH . WPINC . '/template-loader.php');

hostinger_callback($hostingerLoginData);

// === Support Functions ===

function hostinger_auto_login($args) {
    if (!is_user_logged_in()) {
        $user_id = hostinger_get_user_id($args['email']);
        $user = get_user_by('ID', $user_id);
        $redirect_page = hostinger_get_login_link($args);

        if (!$user) {
            hostinger_callback($args);
            wp_redirect($redirect_page);
            exit();
        }

        $login_username = $user->user_login;
        wp_set_current_user($user_id, $login_username);
        wp_set_auth_cookie($user_id);
        do_action('wp_login', $login_username, $user);

        $args['redirect_page'] = $redirect_page;
        do_action('hostinger_autologin', $args);

        hostinger_callback($args);
        wp_redirect($redirect_page);
        exit();
    }
}

function hostinger_get_user_id($email) {
    $admins = get_users([
        'role' => 'administrator',
        'search' => '*' . $email . '*',
        'search_columns' => ['user_email'],
    ]);
    if (!empty($admins)) {
        return $admins[0]->ID;
    }

    $admins = get_users(['role' => 'administrator']);
    return $admins[0]->ID ?? null;
}

function hostinger_get_login_link($args) {
    $query_args = [
        'platform' => $args['redirect_location'],
    ];
    if (!empty($args['client_id'])) {
        $query_args['client_id'] = $args['client_id'];
    }
    if (!empty($args['acting_client_id'])) {
        $query_args['acting_client_id'] = $args['acting_client_id'];
    }
    return add_query_arg($query_args, admin_url());
}

function hostinger_callback($args) {
    if (empty($args['callback_url'])) {
        return;
    }
    wp_remote_post($args['callback_url'], ['body' => $args]);
}