<?php
namespace think;

// +----------------------------------------------------------------------
// | 修复百度蜘蛛抓到重复域名的 URL（如 /https://www.dailitong.net/xxx）
// | 必须在 require vendor/autoload.php 之前执行，不依赖 ThinkPHP
// +----------------------------------------------------------------------
if (isset($_SERVER['REQUEST_URI']) && preg_match('#^/https?://[^/]+(/.*)$#', $_SERVER['REQUEST_URI'], $m)) {
    $scheme     = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https://' : 'http://';
    $host       = $_SERVER['HTTP_HOST'] ?? '';
    $correctUrl = $scheme . $host . $m[1];
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: ' . $correctUrl);
    exit;
}

require __DIR__ . '/../vendor/autoload.php';

// 定义应用启动时间（用于响应时间计算和性能监控）
define('APP_START_TIME', microtime(true));

// 执行HTTP应用并响应
$http = (new App())->http;

$response = $http->run();

$response->send();

$http->end($response);
