You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.8 KiB

<?php
/**
* 英文官网物理入口。宝塔 Nginx 未把 /en 交给 Laravel 时,可直接由 public/en/ 提供页面。
*/
declare(strict_types=1);
$eventSitePath = dirname(__DIR__).'/frontend/event-site-en.html';
if (! is_file($eventSitePath)) {
http_response_code(503);
header('Content-Type: text/plain; charset=UTF-8');
echo 'English event site is missing.';
exit;
}
$html = (string) file_get_contents($eventSitePath);
$assetBase = '/frontend/assets';
$homeUrl = '/';
$homeEnUrl = '/en';
$participantLoginUrl = '/admin/c/hsxt/login';
$audienceLoginUrl = '/admin/c/hsxt/audience/login';
$participantLoginEnUrl = '/admin/c/hsxt/login?lang=en';
$audienceLoginEnUrl = '/admin/c/hsxt/audience/login?lang=en';
$html = str_replace(
[
'url("assets/',
"url('assets/",
'src="assets/',
"src='assets/",
'srcset="assets/',
"srcset='assets/",
'href="assets/',
"href='assets/",
'href="event-site-en.html"',
"href='event-site-en.html'",
'href="event-site.html"',
"href='event-site.html'",
'href="login.html"',
"href='login.html'",
'href="prototype/login-en.html?role=user"',
"href='prototype/login-en.html?role=user'",
'href="prototype/login-en.html?role=audience"',
"href='prototype/login-en.html?role=audience'",
'href="login-en.html?role=user"',
"href='login-en.html?role=user'",
'href="login-en.html?role=audience"',
"href='login-en.html?role=audience'",
'href="layout.html?role=user&amp;lang=en"',
"href='layout.html?role=user&amp;lang=en'",
'href="layout.html?role=audience&amp;lang=en"',
"href='layout.html?role=audience&amp;lang=en'",
'href="layout.html?role=user&lang=en"',
"href='layout.html?role=user&lang=en'",
'href="layout.html?role=audience&lang=en"',
"href='layout.html?role=audience&lang=en'",
'href="layout.html?role=audience"',
"href='layout.html?role=audience'",
],
[
'url("'.$assetBase.'/',
"url('".$assetBase.'/',
'src="'.$assetBase.'/',
"src='".$assetBase.'/',
'srcset="'.$assetBase.'/',
"srcset='".$assetBase.'/',
'href="'.$assetBase.'/',
"href='".$assetBase.'/',
'href="'.$homeEnUrl.'"',
"href='".$homeEnUrl."'",
'href="'.$homeUrl.'"',
"href='".$homeUrl."'",
'href="'.$participantLoginUrl.'"',
"href='".$participantLoginUrl."'",
'href="'.$participantLoginEnUrl.'"',
"href='".$participantLoginEnUrl."'",
'href="'.$audienceLoginEnUrl.'"',
"href='".$audienceLoginEnUrl."'",
'href="'.$participantLoginEnUrl.'"',
"href='".$participantLoginEnUrl."'",
'href="'.$audienceLoginEnUrl.'"',
"href='".$audienceLoginEnUrl."'",
'href="'.$participantLoginEnUrl.'"',
"href='".$participantLoginEnUrl."'",
'href="'.$audienceLoginEnUrl.'"',
"href='".$audienceLoginEnUrl."'",
'href="'.$participantLoginEnUrl.'"',
"href='".$participantLoginEnUrl."'",
'href="'.$audienceLoginEnUrl.'"',
"href='".$audienceLoginEnUrl."'",
'href="'.$audienceLoginUrl.'"',
"href='".$audienceLoginUrl."'",
],
$html
);
$sourceCode = trim((string) ($_GET['src'] ?? ''));
if (preg_match('/^[A-Za-z0-9_-]{2,64}$/', $sourceCode) === 1) {
$script = '<script>try{localStorage.setItem("cxxfds_public_source_code",'.json_encode($sourceCode, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES).');localStorage.setItem("cxxfds_public_source_checked_at",String(Date.now()));}catch(e){}</script>';
$html = preg_replace('/<\/head>/i', $script."\n</head>", $html, 1) ?? ($html.$script);
}
header('Content-Type: text/html; charset=UTF-8');
echo $html;