文件
freeshop/lang.php
T
2026-08-16 16:52:43 +08:00

20 行
635 B
PHP

<?php
require __DIR__ . '/includes/init.php';
$lang = trim($_GET['lang'] ?? '');
$allowed = [];
foreach (Lang::available() as $l) {
$allowed[] = $l['code'];
}
if ($lang !== '' && in_array($lang, $allowed, true)) {
$_SESSION['lang'] = $lang;
setcookie('fnw_lang', $lang, time() + 31536000, '/');
Lang::setLocale($lang);
}
$ref = $_SERVER['HTTP_REFERER'] ?? '';
$host = parse_url((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? '' : '') . ($_SERVER['HTTP_HOST'] ?? ''), PHP_URL_HOST);
if ($ref === '' || parse_url($ref, PHP_URL_HOST) !== $host) {
$ref = '/';
}
header('Location: ' . $ref, true, 302);
exit;