feat(web): localize public entry pages

go
codex 4 weeks ago
parent ad21830be5
commit 24faed1428

@ -30,7 +30,6 @@ use App\Models\EmailVerify;
class AuthController extends BaseController
{
private $language = 'false';
private $login_forbidden_ips = '';
private $enable_login_email_verify = 'false';
private $login_session_ttl = 2592000;
@ -97,16 +96,17 @@ class AuthController extends BaseController
});
$this->trusted_login_device_ttl = TrustedLoginDeviceService::ttlSeconds($trustedLoginDeviceDays);
$this->appName = Config::get('appName');
$this->initializePublicLocale();
}
public function login()
{
$this->getLoginDeviceId();
return $this->view()->assign('captch_login', CaptchaConfig::get('captch_login'))
return $this->publicView()->assign('captch_login', CaptchaConfig::get('captch_login'))
->assign('cdn', $this->cdn)->assign('backup_cdn', $this->backup_cdn)
->assign('appName', $this->appName)->assign('seo', $this->seo)
->assign('language', $this->language)->display('auth/login.tpl');
->display('auth/login.tpl');
}
private function getLoginClientIp()
@ -374,7 +374,10 @@ class AuthController extends BaseController
$email = $request->getParam('email');
$passwd = $request->getParam('passwd');
if (!is_string($email) || !is_string($passwd) || strlen($email) > 254 || strlen($passwd) > 72) {
return $response->withJson(['ret' => 0, 'msg' => '邮箱或密码格式无效'], 400);
return $response->withJson([
'ret' => 0,
'msg' => $this->publicText('邮箱或密码格式无效', 'The email or password format is invalid.'),
], 400);
}
$email = strtolower(trim($email));
$code = $request->getParam('code');
@ -404,7 +407,10 @@ class AuthController extends BaseController
unset($_SESSION['captch']);
}
if ($this->isLoginVerifyPasswordLimited($redis, $email, $clientIp)) {
return $response->withJson(['ret' => 0, 'msg' => '尝试次数过多,请稍后再试'], 429);
return $response->withJson([
'ret' => 0,
'msg' => $this->publicText('尝试次数过多,请稍后再试', 'Too many attempts. Please try again later.'),
], 429);
}
// Handle Login
$user = User::where('email', '=', $email)->first();
@ -445,7 +451,10 @@ class AuthController extends BaseController
}
if ((int) $user->enable !== 1) {
return $this->echoJson($response, ['ret' => 0, 'msg' => '账户已停用']);
return $this->echoJson($response, [
'ret' => 0,
'msg' => $this->publicText('账户已停用', 'This account has been disabled.'),
]);
}
$this->clearLoginVerifyPasswordFail($redis, $email, $clientIp);
@ -699,14 +708,14 @@ class AuthController extends BaseController
Cookie::set(['affid' => (string) $legacyAffid], time() + 86400 * 30);
}
return $this->view()->assign('enable_invite_code', $this->enable_invite_code)
return $this->publicView()->assign('enable_invite_code', $this->enable_invite_code)
->assign('enable_email_verify', CaptchaConfig::get('enable_email_verify'))
->assign('code', $code)->assign('aff_code', $code)->assign('aff', max(0, $legacyAffid))->assign('aff_method', $this->aff_method)
->assign('invite_required', $this->aff_method === 'code')->assign('tos_reg', Config::get('tos_reg'))
->assign('captch_reg', CaptchaConfig::get('captch_reg'))
->assign('cdn', $this->cdn)->assign('backup_cdn', $this->backup_cdn)
->assign('appName', $this->appName)->assign('seo', $this->seo)
->assign('language', $this->language)->display('auth/register.tpl');
->display('auth/register.tpl');
}
public function sendVerify($request, $response, $next)
@ -848,35 +857,59 @@ class AuthController extends BaseController
{
Cookie::startSession();
if (Config::get('enable_register', 'true') === 'false') {
return $this->echoJson($response, ['ret' => 0, 'msg' => '目前关闭注册']);
return $this->echoJson($response, [
'ret' => 0,
'msg' => $this->publicText('目前关闭注册', 'Registration is currently unavailable.'),
]);
}
$read = static function ($name) use ($request) {
$value = $request->getParam($name, '');
return is_string($value) ? $value : '';
};
if (Config::get('tos_reg') === 'true' && $read('accept_legal') !== 'true') {
return $this->echoJson($response, ['ret' => 0, 'msg' => '请先阅读并同意服务条款和隐私政策']);
return $this->echoJson($response, [
'ret' => 0,
'msg' => $this->publicText(
'请先阅读并同意服务条款和隐私政策',
'Please read and accept the Terms of Service and Privacy Policy.'
),
]);
}
$email = strtolower(trim($read('email')));
$name = trim($read('name'));
$password = $read('passwd');
$code = trim($read('code'));
if (!Check::isEmailLegal($email) || strlen($email) > 254 || $name === '' || mb_strlen($name) > 128) {
return $this->echoJson($response, ['ret' => 0, 'msg' => '请填写有效的用户名和邮箱']);
return $this->echoJson($response, [
'ret' => 0,
'msg' => $this->publicText('请填写有效的用户名和邮箱', 'Please enter a valid username and email address.'),
]);
}
$whitelist = RegistrationEmailWhitelist::configuredRules();
if ($whitelist['enabled'] && !RegistrationEmailWhitelist::allows($email, $whitelist['domains'])) {
return $this->echoJson($response, ['ret' => 0, 'msg' => '此邮箱暂不允许注册']);
return $this->echoJson($response, [
'ret' => 0,
'msg' => $this->publicText('此邮箱暂不允许注册', 'This email address is not currently allowed to register.'),
]);
}
$error = Hash::newPasswordError($password);
if ($error !== null || $password !== $read('repasswd')) {
return $this->echoJson($response, ['ret' => 0, 'msg' => $error ?? '两次密码不一致']);
$message = $error !== null
? $this->publicText(
$error,
'The password must be 12–72 bytes and include uppercase and lowercase letters, a number, and a symbol.'
)
: $this->publicText('两次密码不一致', 'The passwords do not match.');
return $this->echoJson($response, ['ret' => 0, 'msg' => $message]);
}
if (CaptchaConfig::get('captch_reg') === 'true') {
$expected = isset($_SESSION['captch']) && is_string($_SESSION['captch']) ? strtolower($_SESSION['captch']) : '';
$provided = strtolower(trim($read('captch')));
if ($expected === '' || !hash_equals($expected, $provided)) {
return $this->echoJson($response, ['ret' => 0, 'msg' => '验证码错误']);
return $this->echoJson($response, [
'ret' => 0,
'msg' => $this->publicText('验证码错误', 'The verification code is incorrect.'),
]);
}
unset($_SESSION['captch']);
}
@ -885,13 +918,19 @@ class AuthController extends BaseController
try {
$connection->transaction(function () use ($read, $email, $name, $password, $code) {
if (User::where('email', $email)->exists()) {
throw new \InvalidArgumentException('该邮箱已被注册');
throw new \InvalidArgumentException($this->publicText(
'该邮箱已被注册',
'This email address is already registered.'
));
}
if (CaptchaConfig::get('enable_email_verify') === 'true') {
$verification = EmailVerify::where('email', $email)->where('code', $read('emailcode'))
->where('expire_in', '>', time())->lockForUpdate()->first();
if ($verification === null) {
throw new \InvalidArgumentException('邮箱验证码错误或已过期');
throw new \InvalidArgumentException($this->publicText(
'邮箱验证码错误或已过期',
'The email verification code is incorrect or expired.'
));
}
EmailVerify::where('email', $email)->delete();
}
@ -905,7 +944,10 @@ class AuthController extends BaseController
if ($affCode !== '') {
$invitation = ReferralService::findInvitation($affCode, true);
if ($invitation === null) {
throw new \InvalidArgumentException('推广链接无效');
throw new \InvalidArgumentException($this->publicText(
'推广链接无效',
'The referral link is invalid.'
));
}
$refBy = (int) $invitation->user_id;
} elseif ($code !== '' && $this->aff_method === 'code') {
@ -913,28 +955,43 @@ class AuthController extends BaseController
// older installations while new links stay eight chars.
$invitation = InviteCode::where('code', $code)->lockForUpdate()->first();
if ($invitation === null) {
throw new \InvalidArgumentException('邀请码无效');
throw new \InvalidArgumentException($this->publicText(
'邀请码无效',
'The invitation code is invalid.'
));
}
$refBy = (int) $invitation->user_id;
} elseif ($this->aff_method === 'code') {
throw new \InvalidArgumentException('推广链接或邀请码无效');
throw new \InvalidArgumentException($this->publicText(
'推广链接或邀请码无效',
'A valid referral link or invitation code is required.'
));
} else {
if ($aff !== '' && (!ctype_digit($aff) || (int) $aff < 0)) {
throw new \InvalidArgumentException('邀请链接无效');
throw new \InvalidArgumentException($this->publicText(
'邀请链接无效',
'The invitation link is invalid.'
));
}
$refBy = (int) $aff;
}
if ($refBy > 0) {
$referrer = User::where('id', $refBy)->lockForUpdate()->first();
if ($referrer === null || !$referrer->canInvite()) {
throw new \InvalidArgumentException('邀请服务暂不可用');
throw new \InvalidArgumentException($this->publicText(
'邀请服务暂不可用',
'The invitation service is currently unavailable.'
));
}
// New eight-character promotion links are reusable and do
// not consume the legacy invite quota. Older, longer
// `code` invitations retain their one-time quota rules.
if ($invitation !== null && $affCode === '') {
if ((int) $referrer->invite_num < 1) {
throw new \InvalidArgumentException('邀请次数不足');
throw new \InvalidArgumentException($this->publicText(
'邀请次数不足',
'The inviter has no invitation quota remaining.'
));
}
$referrer->invite_num = (int) $referrer->invite_num - 1;
$referrer->save();
@ -963,10 +1020,16 @@ class AuthController extends BaseController
return $this->echoJson($response, ['ret' => 0, 'msg' => $exception->getMessage()]);
} catch (\Throwable $exception) {
error_log('Account registration failed: ' . get_class($exception));
return $this->echoJson($response, ['ret' => 0, 'msg' => '注册失败,请稍后重试']);
return $this->echoJson($response, [
'ret' => 0,
'msg' => $this->publicText('注册失败,请稍后重试', 'Registration failed. Please try again later.'),
]);
}
return $this->echoJson($response, ['ret' => 1, 'msg' => '注册成功']);
return $this->echoJson($response, [
'ret' => 1,
'msg' => $this->publicText('注册成功', 'Registration completed successfully.'),
]);
}
public function logout($request, $response, $next)

@ -5,8 +5,10 @@ namespace App\Controllers;
use App\Models\Configurations;
use App\Services\Auth;
use App\Services\Config;
use App\Services\PublicLocale;
use App\Services\RedisClient;
use App\Services\View;
use App\Utils\Cookie;
/**
* BaseController
@ -20,6 +22,10 @@ class BaseController
public $smarty;
protected $viewTheme = null;
protected $language = 'false';
protected $publicLocale = PublicLocale::CHINESE;
public function construct__()
{
@ -36,6 +42,37 @@ class BaseController
return $this->smarty();
}
protected function initializePublicLocale()
{
$query = is_array($_GET) ? $_GET : [];
$cookies = is_array($_COOKIE) ? $_COOKIE : [];
$requestedLocale = PublicLocale::requestedLocale($query);
if ($requestedLocale !== null) {
Cookie::set([
PublicLocale::COOKIE_NAME => $requestedLocale,
], time() + PublicLocale::COOKIE_TTL);
$cookies[PublicLocale::COOKIE_NAME] = $requestedLocale;
}
$this->publicLocale = PublicLocale::resolve(
$query,
$cookies,
isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? (string) $_SERVER['HTTP_ACCEPT_LANGUAGE'] : ''
);
$this->language = PublicLocale::templateLanguage($this->publicLocale);
}
protected function publicView()
{
$requestUri = isset($_SERVER['REQUEST_URI']) ? (string) $_SERVER['REQUEST_URI'] : '/';
return $this->view()->assign(PublicLocale::viewData($this->publicLocale, $requestUri));
}
protected function publicText(string $chinese, string $english): string
{
return $this->language === 'true' ? $english : $chinese;
}
/**
* @param $response
* @param $res

@ -18,8 +18,6 @@ use App\Utils\Tools;
*/
class HomeController extends BaseController
{
protected $language = 'false';
public function __construct()
{
$configurations = $this->getDomainConfigurations();
@ -49,11 +47,12 @@ class HomeController extends BaseController
return Configurations::where('name', 'seo')->value('value');
});
$this->appName = Config::get('appName');
$this->initializePublicLocale();
}
public function index()
{
return $this->view()->assign('cdn', $this->cdn)->assign('backup_cdn', $this->backup_cdn)->assign('appName', $this->appName)->assign('seo', $this->seo)->assign('language', $this->language)->display('index.tpl');
return $this->publicView()->assign('cdn', $this->cdn)->assign('backup_cdn', $this->backup_cdn)->assign('appName', $this->appName)->assign('seo', $this->seo)->display('index.tpl');
}
public function page404($request, $response, $args)

@ -18,24 +18,20 @@ final class LegalController extends HomeController
private function renderDocument($request, $response, string $slug)
{
$query = $request->getQueryParams();
$requestedLocale = $query['lang'] ?? '';
$locale = is_string($requestedLocale) && in_array($requestedLocale, ['zh-CN', 'en'], true)
? $requestedLocale
: ($this->language === 'true' ? 'en' : 'zh-CN');
$locale = $this->publicLocale;
$document = LegalDocumentService::published($slug, $locale, (string) $this->appName);
$smarty = $this->view()->assign([
$smarty = $this->publicView()->assign([
'cdn' => $this->cdn,
'backup_cdn' => $this->backup_cdn,
'appName' => $this->appName,
'seo' => $this->seo,
'language' => $locale === 'en' ? 'true' : 'false',
'legal_document' => $document,
'legal_slug' => $slug,
]);
$response->getBody()->write($smarty->fetch('legal.tpl'));
return $response
->withHeader('Cache-Control', 'public, max-age=60')
->withHeader('Vary', 'Accept-Language, Cookie')
->withHeader('X-Content-Type-Options', 'nosniff');
}
}

@ -17,18 +17,16 @@ use App\Utils\Cookie;
class PasswordController extends BaseController
{
private $language = 'false';
public function __construct()
{
$this->applyDomainTheme($this->getDomainConfigurations());
$this->initializePublicLocale();
}
public function reset()
{
return $this->view()
return $this->publicView()
->assign('captch_respass', CaptchaConfig::get('captch_respass'))
->assign('language', $this->language)
->display('password/reset.tpl');
}
@ -69,9 +67,8 @@ class PasswordController extends BaseController
public function token($request, $response, $args)
{
$token = $args['token'];
return $this->view()
return $this->publicView()
->assign('token', $token)
->assign('language', $this->language)
->display('password/token.tpl');
}
@ -80,22 +77,37 @@ class PasswordController extends BaseController
$password = $request->getParam('password');
$error = Hash::newPasswordError($password);
if ($error !== null || $password !== $request->getParam('repasswd')) {
return $this->echoJson($response, ['ret' => 0, 'msg' => $error ?? '两次密码不一致']);
$message = $error !== null
? $this->publicText(
$error,
'The password must be 12–72 bytes and include uppercase and lowercase letters, a number, and a symbol.'
)
: $this->publicText('两次密码不一致', 'The passwords do not match.');
return $this->echoJson($response, ['ret' => 0, 'msg' => $message]);
}
$tokenStr = isset($args['token']) && is_string($args['token']) ? $args['token'] : '';
if (preg_match('/^[a-f0-9]{64}$/', $tokenStr) !== 1) {
return $this->echoJson($response, ['ret' => 0, 'msg' => '链接无效或已过期']);
return $this->echoJson($response, [
'ret' => 0,
'msg' => $this->publicText('链接无效或已过期', 'This link is invalid or has expired.'),
]);
}
$connection = (new User())->getConnection();
try {
$connection->transaction(function () use ($tokenStr, $password) {
$token = PasswordReset::where('token', $tokenStr)->lockForUpdate()->first();
if ($token === null || (int) $token->expire_time < time()) {
throw new \InvalidArgumentException('链接无效或已过期');
throw new \InvalidArgumentException($this->publicText(
'链接无效或已过期',
'This link is invalid or has expired.'
));
}
$user = User::where('email', $token->email)->lockForUpdate()->first();
if ($user === null) {
throw new \InvalidArgumentException('链接无效或已过期');
throw new \InvalidArgumentException($this->publicText(
'链接无效或已过期',
'This link is invalid or has expired.'
));
}
$user->updatePassword($password);
PasswordReset::where('email', $token->email)->delete();
@ -104,9 +116,15 @@ class PasswordController extends BaseController
return $this->echoJson($response, ['ret' => 0, 'msg' => $exception->getMessage()]);
} catch (\Throwable $exception) {
error_log('Password recovery failed: ' . get_class($exception));
return $this->echoJson($response, ['ret' => 0, 'msg' => '重置失败,请稍后重试']);
return $this->echoJson($response, [
'ret' => 0,
'msg' => $this->publicText('重置失败,请稍后重试', 'Password reset failed. Please try again later.'),
]);
}
return $this->echoJson($response, ['ret' => 1, 'msg' => '密码已重置,请重新登录']);
return $this->echoJson($response, [
'ret' => 1,
'msg' => $this->publicText('密码已重置,请重新登录', 'Your password has been reset. Please log in again.'),
]);
}
}

@ -0,0 +1,132 @@
<?php
namespace App\Services;
final class PublicLocale
{
public const COOKIE_NAME = 'venix_public_locale';
public const COOKIE_TTL = 31536000;
public const ENGLISH = 'en';
public const CHINESE = 'zh-CN';
public static function resolve(array $query, array $cookies, string $acceptLanguage): string
{
$requested = self::requestedLocale($query);
if ($requested !== null) {
return $requested;
}
$cookieLocale = self::normalizeLocale($cookies[self::COOKIE_NAME] ?? null);
if ($cookieLocale !== null) {
return $cookieLocale;
}
return self::browserLocale($acceptLanguage);
}
public static function requestedLocale(array $query): ?string
{
return self::normalizeLocale($query['lang'] ?? null);
}
public static function normalizeLocale($value): ?string
{
if (!is_string($value)) {
return null;
}
$locale = strtolower(str_replace('_', '-', trim($value)));
if ($locale === 'zh' || str_starts_with($locale, 'zh-')) {
return self::CHINESE;
}
if ($locale === 'en' || str_starts_with($locale, 'en-')) {
return self::ENGLISH;
}
return null;
}
public static function browserLocale(string $acceptLanguage): string
{
$acceptLanguage = trim($acceptLanguage);
if ($acceptLanguage === '') {
return self::CHINESE;
}
$supported = [];
foreach (explode(',', $acceptLanguage) as $position => $entry) {
$parts = array_map('trim', explode(';', $entry));
$locale = self::normalizeLocale(array_shift($parts));
if ($locale === null) {
continue;
}
$quality = 1.0;
foreach ($parts as $parameter) {
if (stripos($parameter, 'q=') !== 0) {
continue;
}
$qualityValue = substr($parameter, 2);
$quality = is_numeric($qualityValue) ? (float) $qualityValue : 0.0;
break;
}
if ($quality <= 0.0 || $quality > 1.0) {
continue;
}
$supported[] = [
'locale' => $locale,
'quality' => $quality,
'position' => $position,
];
}
usort($supported, static function (array $left, array $right): int {
if ($left['quality'] === $right['quality']) {
return $left['position'] <=> $right['position'];
}
return $left['quality'] < $right['quality'] ? 1 : -1;
});
return $supported[0]['locale'] ?? self::ENGLISH;
}
public static function templateLanguage(string $locale): string
{
return self::normalizeLocale($locale) === self::ENGLISH ? 'true' : 'false';
}
public static function switchUrl(string $locale, string $requestUri): string
{
$locale = self::normalizeLocale($locale) ?? self::CHINESE;
$parts = parse_url($requestUri);
if (!is_array($parts) || isset($parts['scheme']) || isset($parts['host'])) {
$parts = ['path' => '/'];
}
$path = is_array($parts) && isset($parts['path']) ? (string) $parts['path'] : '/';
if ($path === '' || $path[0] !== '/' || str_starts_with($path, '//')
|| preg_match('/[\x00-\x1F\x7F]/', $path)) {
$path = '/';
}
$query = [];
if (is_array($parts) && isset($parts['query'])) {
parse_str((string) $parts['query'], $query);
}
$query['lang'] = $locale;
return $path . '?' . http_build_query($query, '', '&', PHP_QUERY_RFC3986);
}
public static function viewData(string $locale, string $requestUri): array
{
$locale = self::normalizeLocale($locale) ?? self::CHINESE;
return [
'public_locale' => $locale,
'language' => self::templateLanguage($locale),
'language_zh_url' => self::switchUrl(self::CHINESE, $requestUri),
'language_en_url' => self::switchUrl(self::ENGLISH, $requestUri),
];
}
}

@ -1059,41 +1059,6 @@ body.venix-auth {
background: radial-gradient(circle at 12% 8%, rgba(41, 194, 197, .12), transparent 26%),
radial-gradient(circle at 88% 92%, rgba(42, 102, 150, .09), transparent 30%), var(--vu-bg);
}
body.venix-auth .auth-site-nav {
min-height: 78px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
padding: 16px clamp(22px, 5vw, 76px);
background: rgba(255, 255, 255, .86);
border-bottom: 1px solid rgba(223, 231, 238, .85);
backdrop-filter: blur(16px);
}
body.venix-auth .auth-site-nav .home-brand {
min-width: 0;
display: flex;
align-items: center;
gap: 12px;
color: var(--vu-text);
font-size: 20px;
font-weight: 800;
letter-spacing: -.3px;
text-decoration: none;
}
body.venix-auth .auth-site-nav .home-brand > span:last-child {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
body.venix-auth .auth-site-nav nav {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: flex-end;
gap: 8px;
}
body.venix-auth .auth-site-nav nav a,
body.venix-auth .auth-link {
padding: 9px 11px;
color: var(--vu-brand-strong);
@ -1102,15 +1067,7 @@ body.venix-auth .auth-link {
font-weight: 750;
text-decoration: none;
}
body.venix-auth .auth-site-nav nav a:hover,
body.venix-auth .auth-site-nav nav a[aria-current="page"],
body.venix-auth .auth-link:hover { background: var(--vu-brand-soft); }
body.venix-auth .auth-site-nav .home-nav-button { color: #fff; background: var(--vu-brand); }
body.venix-auth .auth-site-nav .home-nav-button:hover,
body.venix-auth .auth-site-nav .home-nav-button[aria-current="page"] {
color: #fff;
background: var(--vu-brand-strong);
}
body.venix-auth .auth-shell {
width: 100%;
@ -1258,10 +1215,6 @@ body.venix-auth .auth-legal-consent a:hover { text-decoration: underline; }
background: radial-gradient(circle at 12% 8%, rgba(41, 194, 197, .1), transparent 26%),
radial-gradient(circle at 88% 92%, rgba(42, 102, 150, .11), transparent 30%), var(--vu-bg);
}
:root[data-bs-theme="dark"] body.venix-auth .auth-site-nav {
background: rgba(16, 32, 52, .86);
border-color: var(--vu-border);
}
:root[data-bs-theme="dark"] body.venix-auth .auth-panel { background: rgba(20, 36, 56, .96); }
@media (max-width: 1150px) {
@ -1353,9 +1306,6 @@ body.venix-auth .auth-legal-consent a:hover { text-decoration: underline; }
padding: 25px 20px;
border-radius: 16px;
}
body.venix-auth .auth-site-nav { min-height: 68px; padding: 13px 16px; }
body.venix-auth .auth-site-nav .home-brand { font-size: 17px; }
body.venix-auth .auth-site-nav nav a { padding: 7px 8px; font-size: 12px; }
body.venix-auth .auth-shell { align-items: start; padding: 28px 14px; }
body.venix-auth .auth-panel { padding: 26px 20px; border-radius: 15px; }
body.venix-auth .auth-panel-wide {
@ -1374,7 +1324,6 @@ body.venix-auth .auth-legal-consent a:hover { text-decoration: underline; }
}
@media (max-width: 390px) {
body.venix-auth .auth-site-nav .home-brand > span:last-child { max-width: 138px; }
body.vu-body .vu-top-actions > :where(.vu-btn, .vu-theme-toggle) {
width: 100%;
flex-basis: 100%;
@ -1389,8 +1338,6 @@ body.venix-auth .auth-legal-consent a:hover { text-decoration: underline; }
body.vu-body .vu-invoice-head,
body.vu-body .vu-invoice-parties,
body.vu-body .vu-invoice-bottom { flex-direction: column; }
body.venix-auth .auth-site-nav nav { gap: 2px; }
body.venix-auth .auth-site-nav nav a:not(.home-nav-button) { display: none; }
body.venix-auth .auth-row-inline { flex-wrap: wrap; }
body.venix-auth .auth-row-inline .auth-field { flex-basis: 100%; }
}
@ -1955,48 +1902,6 @@ body.venix-auth.virsh-auth {
background: #fff;
}
body.venix-auth.virsh-auth .auth-site-nav {
position: absolute;
top: 0;
right: 0;
left: 0;
z-index: 20;
width: 100%;
min-height: 86px;
padding: 24px clamp(32px, 5vw, 88px);
background: transparent;
border: 0;
backdrop-filter: none;
}
body.venix-auth.virsh-auth .auth-site-nav .home-brand {
max-width: min(40vw, 520px);
color: #fff;
font-size: 23px;
letter-spacing: -.6px;
}
body.venix-auth.virsh-auth .auth-site-nav nav {
margin-left: auto;
}
body.venix-auth.virsh-auth .auth-site-nav nav a {
color: #526276;
}
body.venix-auth.virsh-auth .auth-site-nav nav a:hover,
body.venix-auth.virsh-auth .auth-site-nav nav a[aria-current="page"] {
color: #0f8f9a;
background: #e7f7f8;
}
body.venix-auth.virsh-auth .auth-site-nav .home-nav-button,
body.venix-auth.virsh-auth .auth-site-nav .home-nav-button:hover,
body.venix-auth.virsh-auth .auth-site-nav .home-nav-button[aria-current="page"] {
color: #fff;
background: #0f9eaa;
}
body.venix-auth.virsh-auth .auth-shell-virsh {
width: 100%;
min-height: 100vh;
@ -2283,39 +2188,19 @@ body.venix-auth.virsh-auth .auth-switch a {
body.venix-auth.virsh-auth .auth-switch a:hover { text-decoration: underline; }
body.venix-auth.virsh-auth .auth-copyright {
margin: 25px 0 0;
color: #9aa5b2;
font-size: 12px;
line-height: 1.7;
}
@media (max-width: 740px) {
body.venix-auth.virsh-auth .auth-site-nav {
position: relative;
min-height: 68px;
padding: 13px 18px;
background: #fff;
border-bottom: 1px solid #e7edf2;
}
body.venix-auth.virsh-auth .auth-site-nav .home-brand {
max-width: 52vw;
color: #15243a;
font-size: 18px;
}
body.venix-auth.virsh-auth .auth-shell-virsh {
min-height: calc(100vh - 68px);
min-height: calc(100svh - 68px);
min-height: 100vh;
min-height: 100svh;
display: block;
padding-top: 88px;
}
body.venix-auth.virsh-auth .auth-story-virsh { display: none; }
body.venix-auth.virsh-auth .auth-panel-wrap {
min-height: calc(100vh - 68px);
min-height: calc(100svh - 68px);
min-height: calc(100vh - 88px);
min-height: calc(100svh - 88px);
align-items: flex-start;
padding: 46px 25px 64px;
}
@ -2323,10 +2208,16 @@ body.venix-auth.virsh-auth .auth-copyright {
body.venix-auth.virsh-auth .auth-title { font-size: 29px; }
}
@media (max-width: 560px) {
body.venix-auth.virsh-auth .auth-shell-virsh { padding-top: 76px; }
body.venix-auth.virsh-auth .auth-panel-wrap {
min-height: calc(100vh - 76px);
min-height: calc(100svh - 76px);
}
}
@media (max-width: 420px) {
body.venix-auth.virsh-auth .auth-panel-wrap { padding: 38px 20px 54px; }
body.venix-auth.virsh-auth .auth-site-nav nav { gap: 2px; }
body.venix-auth.virsh-auth .auth-site-nav nav a { padding: 7px 8px; font-size: 12px; }
body.venix-auth.virsh-auth .auth-row-inline { flex-wrap: wrap; }
body.venix-auth.virsh-auth .auth-row-inline > input { flex-basis: 100%; }
body.venix-auth.virsh-auth .auth-row-inline .auth-button,

@ -82,7 +82,31 @@ body.venix-home ::selection { color: #04191b; background: var(--landing-teal-bri
}
.landing-nav-actions { display: flex; align-items: center; gap: 16px; }
.landing-nav-login { color: rgba(255, 255, 255, .8); font-size: 13px; font-weight: 750; text-decoration: none; }
.landing-nav-login:hover { color: #fff; }
.landing-nav-login:hover,
.landing-nav-login.is-active { color: #fff; }
.landing-language-switch {
padding: 3px;
border: 1px solid rgba(255,255,255,.14);
border-radius: 9px;
display: inline-flex;
align-items: center;
gap: 2px;
background: rgba(255,255,255,.05);
}
.landing-language-switch a {
min-width: 35px;
padding: 6px 8px;
border-radius: 6px;
color: rgba(255,255,255,.58);
font-size: 10px;
font-weight: 850;
line-height: 1;
text-align: center;
text-decoration: none;
}
.landing-language-switch a:hover { color: #fff; }
.landing-language-switch a.is-active { color: #04191b; background: var(--landing-teal-bright); }
.landing-mobile-nav-actions { display: none; }
.landing-button {
min-height: 48px;
padding: 0 21px;
@ -361,6 +385,20 @@ body.venix-home > main.home-error { width: 100%; min-height: 100vh; min-height:
.landing-site-header.is-menu-open .landing-main-nav a { padding: 12px; border-radius: 8px; }
.landing-site-header.is-menu-open .landing-main-nav a:hover { background: rgba(255,255,255,.06); }
.landing-site-header.is-menu-open .landing-main-nav a.is-active::after { display: none; }
.landing-site-header.is-menu-open .landing-mobile-nav-actions {
grid-column: 1 / -1;
margin-top: 8px;
padding-top: 14px;
border-top: 1px solid rgba(255,255,255,.1);
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 10px;
}
.landing-site-header.is-menu-open .landing-mobile-nav-actions .landing-language-switch { margin-right: auto; }
.landing-site-header.is-menu-open .landing-mobile-nav-actions .landing-language-switch a { min-width: 34px; padding: 6px 8px; }
.landing-site-header.is-menu-open .landing-mobile-nav-actions .landing-nav-login { padding: 9px 11px; }
.landing-site-header.is-menu-open .landing-mobile-nav-actions .landing-button { min-height: 38px; padding: 0 13px; }
.landing-hero { gap: 40px; }
.landing-feature-grid { grid-template-columns: 1fr; }
.landing-feature-grid article { min-height: 300px; border-right: 0; border-bottom: 1px solid #cfdbdd; }

@ -1 +0,0 @@
<p class="auth-copyright">&copy; 2026 {$auth_app_name|escape:"html"}. All rights reserved.</p>

@ -0,0 +1,2 @@
{include file='home/site_footer.tpl'}
{include file='auth/layout_scripts.tpl'}

@ -1,4 +1,5 @@
{include file='layout_assets.tpl'}
{assign var=home_active value=$auth_page|default:''}
<!DOCTYPE html>
<html lang="{if $language == 'true'}en{else}zh-CN{/if}">
<head>
@ -12,22 +13,8 @@
<link href="{$cdn}/theme/venix/css/icons.min.css?v={$venix_asset_version}" rel="stylesheet">
<link href="/cloud/styles.css?v={$venix_asset_version}" rel="stylesheet">
<link href="/cloud/account.css?v={$venix_asset_version}" rel="stylesheet">
<link href="{$cdn}/theme/venix/css/home.css?v={$venix_asset_version}" rel="stylesheet">
<link href="/theme/venix/css/site-brand.css?v={$venix_asset_version}" rel="stylesheet">
</head>
<body class="venix-auth{if isset($auth_page)} virsh-auth{/if}"{if isset($auth_page)} data-auth-page="{$auth_page|escape:'html'}"{/if}>
<header class="auth-site-nav">
<a class="home-brand" href="/" aria-label="{$auth_app_name|escape:"html"}{if $language == 'true'} home{else}首页{/if}">
{include file='components/site_brand_mark.tpl'}
<span>{$auth_app_name|escape:"html"}</span>
</a>
<nav aria-label="{if $language == 'true'}Account navigation{else}账户导航{/if}">
{if isset($user) && $user->isLogin}
<a href="/user">{if $language == 'true'}User dashboard{else}用户中心{/if}</a>
{if $user->isAdmin()}<a href="/admin">{if $language == 'true'}Admin panel{else}管理面板{/if}</a>{/if}
<a class="home-nav-button" href="/user/logout">{if $language == 'true'}Log out{else}退出{/if}</a>
{else}
<a {if $auth_title == '登录' || $auth_title == 'Log in'}aria-current="page" {/if}href="/auth/login">{if $language == 'true'}Log in{else}登录{/if}</a>
<a class="home-nav-button" {if $auth_title == '注册' || $auth_title == 'Register'}aria-current="page" {/if}href="/auth/register">{if $language == 'true'}Register{else}注册{/if}</a>
{/if}
</nav>
</header>
{include file='home/site_header.tpl'}

@ -54,12 +54,11 @@
</form>
<p class="auth-switch">{if $language == 'true'}No account yet?{else}还没有账户?{/if} <a href="/auth/register">{if $language == 'true'}Create one{else}立即注册{/if}</a></p>
{include file='auth/copyright.tpl' auth_app_name=$appName}
</div>
</section>
</main>
{include file='auth/layout_scripts.tpl'}
{include file='auth/layout_footer.tpl'}
<script>
VenixAuth.blockWeixin();

@ -65,7 +65,7 @@
{if $tos_reg == 'true'}
<label class="auth-legal-consent" for="accept_legal">
<input id="accept_legal" name="accept_legal" type="checkbox" value="true" required>
<span>{if $language == 'true'}I have read and agree to the <a href="/terms?lang=en" target="_blank" rel="noopener">Terms of Service</a> and <a href="/privacy?lang=en" target="_blank" rel="noopener">Privacy Policy</a>.{else}我已阅读并同意 <a href="/terms" target="_blank" rel="noopener">服务条款</a> 和 <a href="/privacy" target="_blank" rel="noopener">隐私政策</a>。{/if}</span>
<span>{if $language == 'true'}I have read and agree to the <a href="/terms" target="_blank" rel="noopener">Terms of Service</a> and <a href="/privacy" target="_blank" rel="noopener">Privacy Policy</a>.{else}我已阅读并同意 <a href="/terms" target="_blank" rel="noopener">服务条款</a> 和 <a href="/privacy" target="_blank" rel="noopener">隐私政策</a>。{/if}</span>
</label>
{/if}
@ -75,12 +75,11 @@
</form>
<p class="auth-switch">{if $language == 'true'}Already have an account?{else}已经有账户?{/if} <a href="/auth/login">{if $language == 'true'}Return to login{else}返回登录{/if}</a></p>
{include file='auth/copyright.tpl' auth_app_name=$appName}
</div>
</section>
</main>
{include file='auth/layout_scripts.tpl'}
{include file='auth/layout_footer.tpl'}
<script>
VenixAuth.blockWeixin();
@ -118,7 +117,7 @@
function register() {
if (affCode === '' && !Number.isInteger(affid)) {
VenixAuth.showMessage(registerForm, 'error', '邀请链接无效');
VenixAuth.showMessage(registerForm, 'error', {if $language == 'true'}'The invitation link is invalid.'{else}'邀请链接无效'{/if});
return;
}
@ -138,9 +137,9 @@
var password = fieldValue('passwd');
var bytes = new TextEncoder().encode(password).length;
if (bytes < 12 || bytes > 72 || !/[A-Z]/.test(password) || !/[a-z]/.test(password) || !/[0-9]/.test(password) || !/[^A-Za-z0-9]/.test(password)) {
VenixAuth.showMessage(registerForm, 'warning', '密码需为 12–72 字节,包含大写、小写字母、数字和符号。'); return;
VenixAuth.showMessage(registerForm, 'warning', {if $language == 'true'}'The password must be 12–72 bytes and include uppercase and lowercase letters, a number, and a symbol.'{else}'密码需为 12–72 字节,包含大写、小写字母、数字和符号。'{/if}); return;
}
if (password !== fieldValue('repasswd')) { VenixAuth.showMessage(registerForm, 'warning', '两次密码不一致。'); return; }
if (password !== fieldValue('repasswd')) { VenixAuth.showMessage(registerForm, 'warning', {if $language == 'true'}'The passwords do not match.'{else}'两次密码不一致。'{/if}); return; }
var done = VenixAuth.setLoading(registerButton, {if $language == 'true'}'Creating...'{else}'创建中...'{/if});
VenixAuth.post('/auth/register', {

@ -0,0 +1,4 @@
<span class="landing-language-switch" role="group" aria-label="{if $language == 'true'}Choose language{else}选择语言{/if}">
<a class="{if $language != 'true'}is-active{/if}" href="{$language_zh_url|escape:'html'}" lang="zh-CN" hreflang="zh-CN"{if $language != 'true'} aria-current="true"{/if}>中文</a>
<a class="{if $language == 'true'}is-active{/if}" href="{$language_en_url|escape:'html'}" lang="en" hreflang="en"{if $language == 'true'} aria-current="true"{/if}>EN</a>
</span>

@ -0,0 +1,8 @@
{include file='home/language_switch.tpl'}
{if $user->isLogin}
{if $user->isAdmin()}<a class="landing-nav-login" href="/admin">{if $language == 'true'}Admin{else}管理后台{/if}</a>{/if}
<a class="landing-button landing-button-small landing-button-primary" href="/user">{if $language == 'true'}Open console{else}进入控制台{/if}<i class="mdi mdi-arrow-right" aria-hidden="true"></i></a>
{else}
<a class="landing-nav-login{if $home_active|default:'' == 'login' || $home_active|default:'' == 'password-reset' || $home_active|default:'' == 'password-token'} is-active{/if}" href="/auth/login">{if $language == 'true'}Log in{else}登录{/if}</a>
<a class="landing-button landing-button-small landing-button-primary{if $home_active|default:'' == 'register'} is-active{/if}" href="/auth/register">{if $language == 'true'}Create account{else}创建账户{/if}<i class="mdi mdi-arrow-right" aria-hidden="true"></i></a>
{/if}

@ -8,11 +8,11 @@
</div>
<div class="landing-footer-links">
<div><strong>{if $language == 'true'}Product{else}产品{/if}</strong><a href="/">{if $language == 'true'}Home{else}产品首页{/if}</a><a href="/#capabilities">{if $language == 'true'}Capabilities{else}产品能力{/if}</a><a href="/user">{if $language == 'true'}Console{else}用户控制台{/if}</a></div>
<div><strong>{if $language == 'true'}Legal{else}法律{/if}</strong><a href="/terms{if $language == 'true'}?lang=en{/if}">{if $language == 'true'}Terms of Service{else}服务条款{/if}</a><a href="/privacy{if $language == 'true'}?lang=en{/if}">{if $language == 'true'}Privacy Policy{else}隐私政策{/if}</a></div>
<div><strong>{if $language == 'true'}Legal{else}法律{/if}</strong><a href="/terms">{if $language == 'true'}Terms of Service{else}服务条款{/if}</a><a href="/privacy">{if $language == 'true'}Privacy Policy{else}隐私政策{/if}</a></div>
</div>
<div class="landing-footer-bottom">
<span>&copy; 2026 {$appName|escape:'html'}. All rights reserved.</span>
<span>{if $language == 'true'}LANGUAGE · ENGLISH{else}LANGUAGE · 简体中文{/if}</span>
<span>{if $language == 'true'}LANGUAGE · ENGLISH{else}语言 · 简体中文{/if}</span>
</div>
</footer>
<script>

@ -4,19 +4,14 @@
<span>{$appName|escape:'html'}</span>
</a>
<nav class="landing-main-nav" id="landing-main-nav" aria-label="{if $language == 'true'}Main navigation{else}主导航{/if}">
<a {if $home_active|default:'home' == 'home'}class="is-active" aria-current="page"{/if} href="/">{if $language == 'true'}Home{else}产品首页{/if}</a>
<a {if $home_active|default:'' == 'home'}class="is-active" aria-current="page"{/if} href="/">{if $language == 'true'}Home{else}产品首页{/if}</a>
<a href="/#capabilities">{if $language == 'true'}Capabilities{else}产品能力{/if}</a>
<a {if $home_active|default:'' == 'terms'}class="is-active" aria-current="page"{/if} href="/terms{if $language == 'true'}?lang=en{/if}">{if $language == 'true'}Terms{else}服务条款{/if}</a>
<a {if $home_active|default:'' == 'privacy'}class="is-active" aria-current="page"{/if} href="/privacy{if $language == 'true'}?lang=en{/if}">{if $language == 'true'}Privacy{else}隐私政策{/if}</a>
<a {if $home_active|default:'' == 'terms'}class="is-active" aria-current="page"{/if} href="/terms">{if $language == 'true'}Terms{else}服务条款{/if}</a>
<a {if $home_active|default:'' == 'privacy'}class="is-active" aria-current="page"{/if} href="/privacy">{if $language == 'true'}Privacy{else}隐私政策{/if}</a>
<span class="landing-mobile-nav-actions">{include file='home/nav_actions.tpl'}</span>
</nav>
<div class="landing-nav-actions">
{if $user->isLogin}
{if $user->isAdmin()}<a class="landing-nav-login" href="/admin">{if $language == 'true'}Admin{else}管理后台{/if}</a>{/if}
<a class="landing-button landing-button-small landing-button-primary" href="/user">{if $language == 'true'}Open console{else}进入控制台{/if}<i class="mdi mdi-arrow-right" aria-hidden="true"></i></a>
{else}
<a class="landing-nav-login" href="/auth/login">{if $language == 'true'}Log in{else}登录{/if}</a>
<a class="landing-button landing-button-small landing-button-primary" href="/auth/register">{if $language == 'true'}Create account{else}创建账户{/if}<i class="mdi mdi-arrow-right" aria-hidden="true"></i></a>
{/if}
{include file='home/nav_actions.tpl'}
</div>
<button class="landing-mobile-menu" type="button" aria-label="{if $language == 'true'}Open navigation{else}打开导航{/if}" aria-expanded="false" aria-controls="landing-main-nav" data-site-menu>
<i class="mdi mdi-menu" aria-hidden="true"></i>

@ -17,7 +17,7 @@
<div class="landing-hero-proof"><span class="landing-proof-mark"><i class="mdi mdi-check" aria-hidden="true"></i></span><span><strong>{if $language == 'true'}A complete service lifecycle{else}完整服务周期{/if}</strong><small>{if $language == 'true'}Orders, resources, tasks, and audit history stay connected.{else}订单、资源、任务与操作记录保持关联{/if}</small></span></div>
</div>
<div class="landing-console" aria-label="{if $language == 'true'}Cloud console illustration{else}云资源控制台示意图{/if}">
<div class="landing-console-top"><span><i></i><i></i><i></i></span><b>{if $language == 'true'}Resource overview{else}资源概览{/if}</b><em>LIVE</em></div>
<div class="landing-console-top"><span><i></i><i></i><i></i></span><b>{if $language == 'true'}Resource overview{else}资源概览{/if}</b><em>{if $language == 'true'}LIVE{else}实时{/if}</em></div>
<div class="landing-console-body">
<aside><span class="is-active"><i class="mdi mdi-server-outline"></i></span><span><i class="mdi mdi-chart-areaspline"></i></span><span><i class="mdi mdi-shield-outline"></i></span><span><i class="mdi mdi-earth"></i></span></aside>
<div class="landing-console-main">
@ -44,11 +44,11 @@
</section>
<section class="landing-section landing-workflow" aria-labelledby="landing-workflow-title">
<div class="landing-workflow-copy"><span>02 · WORKFLOW</span><h2 id="landing-workflow-title">{if $language == 'true'}Every operation has a visible result.{else}每一次操作,<br>都有明确结果。{/if}</h2><p>{if $language == 'true'}Long-running infrastructure work stays in the task center. Leaving the page does not cancel the task, and uncertain outcomes remain available for reconciliation.{else}耗时的基础设施操作进入任务中心执行。离开页面不会取消任务,结果不确定的操作也会保留并持续核对。{/if}</p></div>
<div class="landing-workflow-copy"><span>{if $language == 'true'}02 · WORKFLOW{else}02 · 操作流程{/if}</span><h2 id="landing-workflow-title">{if $language == 'true'}Every operation has a visible result.{else}每一次操作,<br>都有明确结果。{/if}</h2><p>{if $language == 'true'}Long-running infrastructure work stays in the task center. Leaving the page does not cancel the task, and uncertain outcomes remain available for reconciliation.{else}耗时的基础设施操作进入任务中心执行。离开页面不会取消任务,结果不确定的操作也会保留并持续核对。{/if}</p></div>
<ol><li><span>01</span><div><strong>{if $language == 'true'}Choose resources{else}选择资源{/if}</strong><small>{if $language == 'true'}Plan, image, region, and billing period{else}套餐、镜像、地区与账期{/if}</small></div></li><li><span>02</span><div><strong>{if $language == 'true'}Confirm the invoice{else}确认账单{/if}</strong><small>{if $language == 'true'}Pricing and payment deadline stay explicit{else}费用与支付截止时间清晰可见{/if}</small></div></li><li><span>03</span><div><strong>{if $language == 'true'}Track delivery{else}跟踪交付{/if}</strong><small>{if $language == 'true'}Task state and operation history are retained{else}任务状态与操作日志完整保留{/if}</small></div></li></ol>
</section>
<section class="landing-cta"><div><div class="landing-eyebrow"><span></span>READY WHEN YOU ARE</div><h2>{if $language == 'true'}Ready to launch your next instance?{else}准备好启动下一台实例了吗?{/if}</h2><p>{if $language == 'true'}Create an account and choose the resources your workload needs today.{else}注册账户,选择适合当前业务的资源计划。{/if}</p></div><a class="landing-button landing-button-light" href="{if $user->isLogin}/user/cloud/deploy{else}/auth/register{/if}">{if $language == 'true'}Open console{else}打开控制台{/if}<i class="mdi mdi-arrow-right"></i></a></section>
<section class="landing-cta"><div><div class="landing-eyebrow"><span></span>{if $language == 'true'}READY WHEN YOU ARE{else}随时准备为你服务{/if}</div><h2>{if $language == 'true'}Ready to launch your next instance?{else}准备好启动下一台实例了吗?{/if}</h2><p>{if $language == 'true'}Create an account and choose the resources your workload needs today.{else}注册账户,选择适合当前业务的资源计划。{/if}</p></div><a class="landing-button landing-button-light" href="{if $user->isLogin}/user/cloud/deploy{else}/auth/register{/if}">{if $language == 'true'}Open console{else}打开控制台{/if}<i class="mdi mdi-arrow-right"></i></a></section>
</main>
{include file='home/site_footer.tpl'}
</div>

@ -1,2 +1,2 @@
{* Shared Venix CSS/JS cache key. Increment whenever a shared browser asset changes. *}
{assign var=venix_asset_version value='2026102418' scope='global'}
{assign var=venix_asset_version value='2026102419' scope='global'}

@ -6,7 +6,7 @@
{include file='home/site_header.tpl'}
<main class="legal-page">
<section class="legal-hero">
<div><span>{if $legal_slug == 'terms'}TERMS OF SERVICE{else}PRIVACY POLICY{/if}</span><h1>{$legal_document.title|escape:'html'}</h1><p>{if $legal_slug == 'terms'}{if $language == 'true'}These rules explain the service relationship between you and the platform.{else}这些规则说明你与平台之间的服务关系。{/if}{else}{if $language == 'true'}This policy explains how information connected to you is handled.{else}这份政策说明我们如何处理与你有关的信息。{/if}{/if}</p></div>
<div><span>{if $legal_slug == 'terms'}{if $language == 'true'}TERMS OF SERVICE{else}服务条款{/if}{else}{if $language == 'true'}PRIVACY POLICY{else}隐私政策{/if}{/if}</span><h1>{$legal_document.title|escape:'html'}</h1><p>{if $legal_slug == 'terms'}{if $language == 'true'}These rules explain the service relationship between you and the platform.{else}这些规则说明你与平台之间的服务关系。{/if}{else}{if $language == 'true'}This policy explains how information connected to you is handled.{else}这份政策说明我们如何处理与你有关的信息。{/if}{/if}</p></div>
<dl><div><dt>{if $language == 'true'}Effective date{else}生效日期{/if}</dt><dd>{$legal_document.effective_date|escape:'html'}</dd></div><div><dt>{if $language == 'true'}Current version{else}当前版本{/if}</dt><dd>v{$legal_document.version|escape:'html'}</dd></div></dl>
</section>
{if $legal_document.fallback}

@ -1,6 +1,7 @@
{assign var=auth_app_name value=$config["appName"]}
{assign var=auth_page value='password-reset'}
{include file='auth/layout_header.tpl' auth_title='Reset Password' auth_app_name=$auth_app_name auth_page=$auth_page}
{if $language == 'true'}{assign var=auth_title value='Reset password'}{else}{assign var=auth_title value='重置密码'}{/if}
{include file='auth/layout_header.tpl' auth_title=$auth_title auth_app_name=$auth_app_name auth_page=$auth_page}
<main class="auth-shell auth-shell-virsh">
{include file='auth/virsh_story.tpl' auth_app_name=$auth_app_name auth_page=$auth_page}
@ -32,12 +33,11 @@
</form>
<p class="auth-switch">{if $language == 'true'}Remembered your password?{else}想起密码了?{/if} <a href="/auth/login">{if $language == 'true'}Return to login{else}返回登录{/if}</a></p>
{include file='auth/copyright.tpl' auth_app_name=$auth_app_name}
</div>
</section>
</main>
{include file='auth/layout_scripts.tpl'}
{include file='auth/layout_footer.tpl'}
<script>
var resetForm = document.getElementById('resetRequestForm');
var resetButton = document.getElementById('reset');

@ -1,6 +1,7 @@
{assign var=auth_app_name value=$config["appName"]}
{assign var=auth_page value='password-token'}
{include file='auth/layout_header.tpl' auth_title='Reset Password' auth_app_name=$auth_app_name auth_page=$auth_page}
{if $language == 'true'}{assign var=auth_title value='Set new password'}{else}{assign var=auth_title value='设置新密码'}{/if}
{include file='auth/layout_header.tpl' auth_title=$auth_title auth_app_name=$auth_app_name auth_page=$auth_page}
<main class="auth-shell auth-shell-virsh">
{include file='auth/virsh_story.tpl' auth_app_name=$auth_app_name auth_page=$auth_page}
@ -26,12 +27,11 @@
<button type="submit" class="auth-button auth-button-block" id="reset">{if $language == 'true'}Set new password{else}提交新密码{/if}</button>
</form>
{include file='auth/copyright.tpl' auth_app_name=$auth_app_name}
</div>
</section>
</main>
{include file='auth/layout_scripts.tpl'}
{include file='auth/layout_footer.tpl'}
<script>
var resetForm = document.getElementById('resetTokenForm');
var resetButton = document.getElementById('reset');

@ -11,9 +11,10 @@ $register = file_get_contents($views . '/auth/register.tpl');
$passwordReset = file_get_contents($views . '/password/reset.tpl');
$passwordToken = file_get_contents($views . '/password/token.tpl');
$layout = file_get_contents($views . '/auth/layout_header.tpl');
$layoutFooter = file_get_contents($views . '/auth/layout_footer.tpl');
$story = file_get_contents($views . '/auth/virsh_story.tpl');
$copyright = file_get_contents($views . '/auth/copyright.tpl');
$styles = file_get_contents($root . '/public/cloud/account.css');
$homeStyles = file_get_contents($root . '/public/theme/venix/css/home.css');
$assets = file_get_contents($views . '/layout_assets.tpl');
foreach ([$login, $register, $passwordReset, $passwordToken] as $template) {
@ -21,26 +22,31 @@ foreach ([$login, $register, $passwordReset, $passwordToken] as $template) {
'Authentication page is missing the virsh-cloud shell.');
$assert(str_contains($template, "include file='auth/virsh_story.tpl'"),
'Authentication page is missing the shared virsh-cloud artwork.');
$assert(str_contains($template, "include file='auth/copyright.tpl'"),
'Authentication page is missing the shared copyright footer.');
$assert(str_contains($template, "include file='auth/layout_footer.tpl'"),
'Authentication page is missing the shared public footer.');
}
$assert(str_contains($layout, 'venix-auth{if isset($auth_page)} virsh-auth{/if}'),
'Authentication layout does not scope the migrated visual treatment.');
$assert(str_contains($layout, "include file='home/site_header.tpl'")
&& str_contains($layout, 'theme/venix/css/home.css'),
'Authentication pages do not reuse the persistent public header styles.');
$assert(str_contains($layoutFooter, "include file='home/site_footer.tpl'")
&& str_contains($layoutFooter, "include file='auth/layout_scripts.tpl'"),
'Authentication pages do not reuse the persistent public footer and scripts.');
$assert(str_contains($story, '{$auth_app_name|escape:"html"}')
&& !str_contains($story, 'VirtPilot'),
'Virsh-cloud artwork must use the configured site name.');
$assert(str_contains($copyright, '&copy; 2026 {$auth_app_name|escape:"html"}. All rights reserved.'),
'Authentication copyright footer must use the configured site name.');
$assert(!str_contains($login, '请通过 HTTPS 安全连接')
&& !str_contains($register, '密码和验证码不会写入浏览器存储'),
'Retired authentication security hints are still present.');
$assert(str_contains($styles, 'grid-template-columns: minmax(390px, 48%) minmax(0, 1fr);')
&& str_contains($styles, '.auth-story-virsh')
&& str_contains($styles, '.virsh-auth-art-grid')
&& str_contains($styles, '.auth-copyright')
&& str_contains($styles, '@media (max-width: 740px)')
&& str_contains($styles, '.auth-story-virsh { display: none; }'),
&& str_contains($styles, '.auth-story-virsh { display: none; }')
&& preg_match('/\.landing-site-header\s*\{[^}]*position:\s*fixed;/s', $homeStyles) === 1
&& str_contains($homeStyles, '.landing-site-footer'),
'Responsive virsh-cloud authentication styles are incomplete.');
$assert(str_contains($login, "VenixAuth.post('/auth/login'")

@ -58,7 +58,7 @@ $assert(str_contains($legal, '{$legal_document.content_html nofilter}')
'Published legal content or its responsive information architecture is missing.');
$assert(str_contains($footer, '&copy; 2026 {$appName|escape:\'html\'}. All rights reserved.')
&& str_contains($footer, 'href="/terms') && str_contains($footer, 'href="/privacy')
&& substr_count($footer, "?lang=en") === 2,
&& !str_contains($footer, '?lang=en'),
'Landing footer lacks dynamic copyright or legal links.');
$register = $read('web/resources/views/venix/auth/register.tpl');
@ -73,7 +73,7 @@ $assert(str_contains($auth, "Config::get('tos_reg') === 'true'")
'Legal consent is only client-side and can be bypassed.');
$assets = $read('web/resources/views/venix/layout_assets.tpl');
$assert(str_contains($assets, "value='2026102418'")
$assert(str_contains($assets, "value='2026102419'")
&& str_contains($admin, '?v={$venix_asset_version}')
&& str_contains($read('web/resources/views/venix/home/layout_header.tpl'), '?v={$venix_asset_version}'),
'Shared browser asset version was not coupled to the new assets.');

@ -0,0 +1,71 @@
<?php
require dirname(__DIR__) . '/vendor/autoload.php';
use App\Services\PublicLocale;
$assertSame = static function ($expected, $actual, string $message): void {
if ($expected !== $actual) {
throw new RuntimeException($message . ' Expected ' . var_export($expected, true)
. ', got ' . var_export($actual, true) . '.');
}
};
$assertSame(PublicLocale::ENGLISH, PublicLocale::resolve(
['lang' => 'en-US'],
[PublicLocale::COOKIE_NAME => 'zh-CN'],
'zh-CN,zh;q=0.9'
), 'An explicit English selection must override the cookie and browser preference.');
$assertSame(PublicLocale::CHINESE, PublicLocale::resolve(
['lang' => 'zh'],
[PublicLocale::COOKIE_NAME => 'en'],
'en-US,en;q=0.9'
), 'An explicit Chinese selection must override the cookie and browser preference.');
$assertSame(PublicLocale::ENGLISH, PublicLocale::resolve(
[],
[PublicLocale::COOKIE_NAME => 'en'],
'zh-CN,zh;q=0.9'
), 'A saved manual selection must override automatic browser detection.');
$assertSame(PublicLocale::CHINESE, PublicLocale::resolve(
[],
[],
'zh-CN,zh;q=0.9,en;q=0.8'
), 'A Chinese browser preference was not detected.');
$assertSame(PublicLocale::ENGLISH, PublicLocale::resolve(
[],
[],
'en-US,en;q=0.9,zh;q=0.8'
), 'An English browser preference was not detected.');
$assertSame(PublicLocale::CHINESE, PublicLocale::resolve(
[],
[],
'fr-FR,zh;q=0.8,en;q=0.6'
), 'Unsupported languages must be skipped in favor of the best supported preference.');
$assertSame(PublicLocale::ENGLISH, PublicLocale::resolve(
[],
[],
'fr-FR,fr;q=0.9'
), 'A non-Chinese browser with no supported preference must fall back to English.');
$assertSame(PublicLocale::CHINESE, PublicLocale::resolve([], [], ''),
'Requests without a browser language must retain the existing Chinese default.');
$assertSame(PublicLocale::ENGLISH, PublicLocale::browserLocale('zh-CN;q=0,en;q=0.5'),
'A language excluded with q=0 must not be selected.');
$englishUrl = PublicLocale::switchUrl('en', '/auth/register?aff=ABCDEFGH&source=landing');
$assertSame('/auth/register?aff=ABCDEFGH&source=landing&lang=en', $englishUrl,
'Language switching must preserve registration referral parameters.');
$chineseUrl = PublicLocale::switchUrl('zh-CN', '/auth/register?aff=ABCDEFGH&lang=en');
$assertSame('/auth/register?aff=ABCDEFGH&lang=zh-CN', $chineseUrl,
'Language switching must replace, rather than duplicate, the current locale.');
$assertSame('/?lang=en', PublicLocale::switchUrl('en', '//external.example/path?x=1'),
'Language switching must never emit a protocol-relative external URL.');
$viewData = PublicLocale::viewData('en', '/password/reset?from=login');
$assertSame('en', $viewData['public_locale'], 'The resolved public locale is missing from view data.');
$assertSame('true', $viewData['language'], 'English must retain the legacy template language flag.');
$assertSame('/password/reset?from=login&lang=zh-CN', $viewData['language_zh_url'],
'The Chinese switch URL is incorrect.');
$assertSame('/password/reset?from=login&lang=en', $viewData['language_en_url'],
'The English switch URL is incorrect.');
echo "Public locale detection and switching tests passed.\n";

@ -0,0 +1,86 @@
<?php
$root = dirname(__DIR__, 2);
$read = static function (string $path) use ($root): string {
$content = file_get_contents($root . '/' . $path);
if ($content === false) {
throw new RuntimeException('Cannot read ' . $path);
}
return $content;
};
$assert = static function (bool $condition, string $message): void {
if (!$condition) {
throw new RuntimeException($message);
}
};
$locale = $read('web/app/Services/PublicLocale.php');
$base = $read('web/app/Controllers/BaseController.php');
$home = $read('web/app/Controllers/HomeController.php');
$auth = $read('web/app/Controllers/AuthController.php');
$password = $read('web/app/Controllers/PasswordController.php');
$legal = $read('web/app/Controllers/LegalController.php');
$assert(str_contains($locale, "COOKIE_NAME = 'venix_public_locale'")
&& str_contains($locale, 'HTTP_ACCEPT_LANGUAGE') === false
&& str_contains($locale, 'browserLocale(')
&& str_contains($locale, "\$query['lang']"),
'The public locale resolver is missing explicit selection, cookie, or browser-language support.');
$assert(str_contains($base, 'PublicLocale::requestedLocale($query)')
&& str_contains($base, 'Cookie::set([')
&& str_contains($base, "\$_SERVER['HTTP_ACCEPT_LANGUAGE']")
&& str_contains($base, 'PublicLocale::viewData('),
'The shared controller does not persist and expose the resolved public locale.');
foreach ([$home, $auth, $password] as $controller) {
$assert(str_contains($controller, '$this->initializePublicLocale();'),
'A public-page controller does not initialize the shared locale resolver.');
$assert(str_contains($controller, '$this->publicView()'),
'A public-page controller does not expose shared locale data to its templates.');
}
$assert(str_contains($legal, '$this->publicLocale')
&& str_contains($legal, "withHeader('Vary', 'Accept-Language, Cookie')"),
'Legal pages do not use the shared locale or declare cache variance.');
foreach ([$base, $home, $auth, $password, $legal] as $controller) {
$assert(!str_contains($controller, "Configurations::where('name', 'language'")
&& !str_contains($controller, "Config::get('language'"),
'A public page still depends on the removed administrator language setting.');
}
$layoutHeader = $read('web/resources/views/venix/auth/layout_header.tpl');
$layoutFooter = $read('web/resources/views/venix/auth/layout_footer.tpl');
$siteHeader = $read('web/resources/views/venix/home/site_header.tpl');
$navActions = $read('web/resources/views/venix/home/nav_actions.tpl');
$languageSwitch = $read('web/resources/views/venix/home/language_switch.tpl');
$siteFooter = $read('web/resources/views/venix/home/site_footer.tpl');
$css = $read('web/public/theme/venix/css/home.css');
$accountCss = $read('web/public/cloud/account.css');
$assert(str_contains($layoutHeader, "include file='home/site_header.tpl'")
&& str_contains($layoutHeader, 'theme/venix/css/home.css'),
'Authentication pages do not reuse the landing-page header and its stylesheet.');
$assert(str_contains($layoutFooter, "include file='home/site_footer.tpl'"),
'Authentication pages do not reuse the landing-page footer.');
foreach (['auth/login.tpl', 'auth/register.tpl', 'password/reset.tpl', 'password/token.tpl'] as $templatePath) {
$template = $read('web/resources/views/venix/' . $templatePath);
$assert(str_contains($template, "include file='auth/layout_footer.tpl'"),
$templatePath . ' does not include the persistent public footer.');
$assert(!str_contains($template, "include file='auth/copyright.tpl'"),
$templatePath . ' still includes the retired local copyright fragment.');
}
$assert(str_contains($siteHeader, "include file='home/nav_actions.tpl'")
&& str_contains($navActions, "include file='home/language_switch.tpl'")
&& str_contains($languageSwitch, '$language_zh_url')
&& str_contains($languageSwitch, '$language_en_url'),
'The shared navigation does not expose both language switch targets.');
$assert(!str_contains($siteHeader, '?lang=en') && !str_contains($siteFooter, '?lang=en'),
'Public navigation still hard-codes English query parameters instead of using the locale cookie.');
$assert(preg_match('/\.landing-site-header\s*\{[^}]*position:\s*fixed;/s', $css) === 1
&& str_contains($css, '.landing-language-switch')
&& str_contains($css, '.landing-mobile-nav-actions')
&& str_contains($accountCss, 'padding-top: 88px;')
&& str_contains($accountCss, 'padding-top: 76px;'),
'Persistent desktop or mobile public-navigation styling is incomplete.');
$assert(str_contains($read('web/resources/views/venix/layout_assets.tpl'), "value='2026102419'"),
'The shared browser asset version was not advanced with the navigation styles.');
echo "Public page locale and shared-layout contract tests passed.\n";

@ -0,0 +1,108 @@
<?php
require dirname(__DIR__) . '/vendor/autoload.php';
use App\Services\PublicLocale;
final class PublicPageGuestForLocaleTest
{
public bool $isLogin = false;
public function isAdmin(): bool
{
return false;
}
}
$directory = sys_get_temp_dir() . '/virt-public-locale-render-' . bin2hex(random_bytes(8));
if (!mkdir($directory, 0700)) {
throw new RuntimeException('Cannot create private public-page render directory.');
}
$assert = static function (bool $condition, string $message): void {
if (!$condition) {
throw new RuntimeException($message);
}
};
$smarty = new Smarty();
$smarty->setTemplateDir(dirname(__DIR__) . '/resources/views/venix');
$smarty->setCompileDir($directory);
$smarty->setCacheDir($directory);
foreach (['urlencode', 'number_format', 'date'] as $modifier) {
$smarty->registerPlugin('modifier', $modifier, $modifier);
}
$smarty->assign([
'appName' => 'Locale Test Cloud',
'config' => [
'appName' => 'Locale Test Cloud',
'jump_delay' => 500,
],
'cdn' => '',
'backup_cdn' => '',
'seo' => '',
'user' => new PublicPageGuestForLocaleTest(),
'captch_login' => 'false',
'captch_reg' => 'false',
'captch_respass' => 'false',
'enable_invite_code' => 'false',
'enable_email_verify' => 'false',
'invite_required' => false,
'tos_reg' => 'true',
'code' => '',
'aff_code' => '',
'aff' => 0,
'aff_method' => '',
'token' => str_repeat('a', 64),
]);
$pages = [
'index.tpl' => ['Your cloud resources', '你的云资源'],
'auth/login.tpl' => ['Log in to your account', '登录账户'],
'auth/register.tpl' => ['Create your account', '注册新账户'],
'password/reset.tpl' => ['Request a password reset', '重置密码请求'],
'password/token.tpl' => ['Enter and confirm your new password.', '输入并确认你的新密码。'],
];
try {
foreach ([PublicLocale::ENGLISH, PublicLocale::CHINESE] as $locale) {
$smarty->assign(PublicLocale::viewData($locale, '/auth/register?aff=ABCDEFGH'));
$expectedFlag = $locale === PublicLocale::ENGLISH ? 0 : 1;
foreach ($pages as $template => $copy) {
$html = $smarty->fetch($template);
$assert(str_contains($html, '<html lang="' . $locale . '">'),
$template . ' rendered the wrong HTML language for ' . $locale . '.');
$assert(str_contains($html, $copy[$expectedFlag]),
$template . ' did not render its ' . $locale . ' copy.');
$assert(substr_count($html, 'class="landing-site-header"') === 1,
$template . ' did not render exactly one shared site header.');
$assert(substr_count($html, 'class="landing-site-footer"') === 1,
$template . ' did not render exactly one shared site footer.');
$assert(str_contains($html, 'lang="zh-CN" hreflang="zh-CN"')
&& str_contains($html, 'lang="en" hreflang="en"'),
$template . ' is missing one of the language switch links.');
$assert(str_contains($html, 'aff=ABCDEFGH&amp;lang=en')
&& str_contains($html, 'aff=ABCDEFGH&amp;lang=zh-CN'),
$template . ' did not preserve query parameters in language switch links.');
$assert(str_contains($html, '&copy; 2026 Locale Test Cloud. All rights reserved.'),
$template . ' is missing the persistent dynamic copyright footer.');
$assert(!str_contains($html, 'auth-site-nav') && !str_contains($html, 'auth-copyright'),
$template . ' rendered a retired authentication-only header or footer.');
}
}
} finally {
$generatedFiles = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($directory, FilesystemIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST
);
foreach ($generatedFiles as $generated) {
if ($generated->isFile()) {
unlink($generated->getPathname());
} elseif ($generated->isDir()) {
rmdir($generated->getPathname());
}
}
rmdir($directory);
}
echo "Public landing and authentication pages rendered in Chinese and English.\n";

@ -41,7 +41,6 @@ foreach ($layouts as $layout) {
$presenters = [
'web/resources/views/venix/home/site_header.tpl' => 1,
'web/resources/views/venix/home/site_footer.tpl' => 1,
'web/resources/views/venix/auth/layout_header.tpl' => 1,
'web/resources/views/venix/user/panel_sidebar.tpl' => 1,
'web/resources/views/venix/user/disable.tpl' => 1,
'web/resources/views/venix/admin/static_header.tpl' => 4,
@ -50,6 +49,8 @@ foreach ($presenters as $template => $expectedIncludes) {
$assert(substr_count($read($template), "include file='components/site_brand_mark.tpl'") === $expectedIncludes,
$template . ' does not render the canonical site-brand mark.');
}
$assert(str_contains($read('web/resources/views/venix/auth/layout_header.tpl'), "include file='home/site_header.tpl'"),
'The authentication layout does not reuse the canonical public site header.');
$templates = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(
$root . '/web/resources/views/venix',
@ -68,7 +69,7 @@ foreach ($templates as $template) {
}
$assets = $read('web/resources/views/venix/layout_assets.tpl');
$assert(str_contains($assets, "value='2026102418'"),
$assert(str_contains($assets, "value='2026102419'"),
'The shared asset version was not updated for the canonical logo.');
echo "Shared site-brand contract passed across public, auth, user, cloud and admin layouts.\n";

Loading…
Cancel
Save