HEX
HEX
Server: LiteSpeed
System: Linux br-asc-web1722.main-hosting.eu 5.14.0-611.34.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Feb 18 05:51:10 EST 2026 x86_64
User: u865067301 (865067301)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: /home/u865067301/domains/agapeextintores.com.br/public_html/create_autologin_o5i0lnvrunstr3v.php
<?php

$hostingerLoginData = array (
  'client_id' => 1017383869,
  'username' => 'u865067301',
  'domain' => 'agapeextintores.com.br',
  'directory' => '',
  'email' => 'geyzon@geyzon.com',
  'redirect_location' => 'hpanel',
  'source' => 'website_list',
  'callback_url' => 'https://hpanel.hostinger.com/api/rest-hosting/v3/wordpress/login/callback/b01a21d944ed453e5a58124ba668865bfe861633',
  'acting_client_id' => NULL,
);

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

// Initialize WordPress
define( 'WP_USE_THEMES', true );
$timeSinceScriptCreation = time() - stat( __FILE__ )['mtime'];

if ( ! isset( $wp_did_header ) ) {
    $wp_did_header = true;
    // Load the WordPress library.
    require_once( dirname( __FILE__ ) . '/wp-load.php' );

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

        exit();
    }

    // Delete itself to make sure it is executed only once
    unlink( __FILE__ );

    //Workaround to fix deactivating plugins after autologin if NextGEN Gallery plugin is enabled.
    if ( class_exists( 'C_NextGEN_Bootstrap' ) ) {
        define( 'DOING_AJAX', true );
    }

    add_filter( 'option_active_plugins' , function ( $plugins ) {

        return array_filter( $plugins , function ( $item ) {
            return strpos( $item, 'hostinger' ) !== false;
        });
    });

    if ( is_user_logged_in() ) {
        $current_user = wp_get_current_user();

        if ( ! in_array( 'administrator', $current_user->roles ) ) {
            wp_logout();
            hostinger_auto_login( $hostingerLoginData );
        }

        $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();
    // Load the theme template
    require_once( ABSPATH . WPINC . '/template-loader.php' );

    hostinger_callback( $hostingerLoginData );
}

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 );
        // Go to admin area
        $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 (isset($admins[0]->ID)) {
        return $admins[0]->ID;
    }

    $admins = get_users( [ 'role' => 'administrator' ] );
    if (isset($admins[0]->ID)) {
        return $admins[0]->ID;
    }

    return 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] );
}