<?php
$ip = '';
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
    $ip = trim($ips[0]);  // 只取第一个IP
} elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
    $ip = $_SERVER['HTTP_CLIENT_IP'];
} else {
    $ip = $_SERVER['REMOTE_ADDR'];
}

$allowed_ips = ['154.17.10.11','2605:52c0:2:78f:3435:e4ff:fe37:4542','2605:52c0:1:1cb:be24:11ff:fe9a:e514','64.186.253.83'];
$is_chinese = (strpos($_SERVER['HTTP_ACCEPT_LANGUAGE'], 'zh') === 0);

if (in_array($ip, $allowed_ips) || !$is_chinese) {
    // This is either the allowed IP or a non-Chinese language browser
    // Allow access
} else {
    // This is a Chinese language browser from a disallowed IP
    // Deny access
    // echo $ip;exit;
    header('HTTP/1.1 403 Forbidden');
    exit('Access denied');
}

// Version
define('VERSION', '3.0.3.8');

// Configuration
if (is_file('config.php')) {
    require_once('config.php');
}

// Install
if (!defined('DIR_APPLICATION')) {
    header('Location: install/index.php');
    exit;
}

// Startup
require_once(DIR_SYSTEM . 'startup.php');

start('catalog');
