<?php
/**
 * 统一入口文件
 */
$lockFile = __DIR__ . '/data/install.lock';
if (!file_exists($lockFile)) {
    header('Location: install.php');
    exit;
}
require_once __DIR__ . '/includes/error_handler.php';
require_once __DIR__ . '/includes/360safe/360webscan.php';
require_once __DIR__ . '/includes/config.php';
require_once ROOT_PATH . 'includes/templates_functions.php';
require_once ROOT_PATH . 'includes/user_functions.php';
require_once ROOT_PATH . 'includes/Router.php';
require_once ROOT_PATH . 'includes/exception_handler.php';

$isAjax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && 
          strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest';

if (!$isAjax) {
    extract($viewData);
    include ROOT_PATH . 'templates/header.php';
}
extract($viewData);
include $viewFile;

if (!$isAjax && basename($viewFile) !== '404.php') {
    include ROOT_PATH . 'templates/footer.php';
}
