master
lion 1 month ago
parent 8beba0fe59
commit 51ff80a2c8

@ -14,6 +14,9 @@
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# English homepage: /en → public/en/(宝塔未配伪静态时避免 404
RewriteRule ^en$ en/index.php [L]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

@ -0,0 +1,2 @@
DirectoryIndex index.php index.html
Options -Indexes

File diff suppressed because it is too large Load Diff

@ -0,0 +1,96 @@
<?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 = '/frontend/prototype/login-en.html?role=user';
$audienceLoginEnUrl = '/frontend/prototype/login-en.html?role=audience';
$html = str_replace(
[
'url("assets/',
"url('assets/",
'src="assets/',
"src='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.'/',
'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;

@ -43,6 +43,10 @@ class ExampleTest extends TestCase
->assertSee('href="/" lang="zh-CN"', false)
->assertSee('>中文</a>', false)
->assertSee('hero-banner hero-banner--photonic', false);
$this->assertFileExists(public_path('en/index.php'));
$this->assertFileExists(public_path('en/index.html'));
$this->assertFileExists(public_path('frontend/event-site-en.html'));
}
public function test_homepage_signup_link_preserves_public_source(): void

Loading…
Cancel
Save