This commit is contained in:
Your Name
2026-04-14 23:16:47 +08:00
parent 27d193be28
commit 887e95286f
428 changed files with 25304 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
<?php
declare(strict_types=1);
namespace app\api\middleware;
use app\Request;
class SeoCollectorTokenAuth
{
public function handle(Request $request, \Closure $next)
{
$expectedToken = $this->resolveExpectedToken();
if ($expectedToken === '') {
return $this->jsonError('9999', 'SEO_COLLECTOR_TOKEN 未配置');
}
$providedToken = $this->resolveProvidedToken($request);
if ($providedToken === '' || !hash_equals($expectedToken, $providedToken)) {
return $this->jsonError('9995', '采集 token 无效');
}
return $next($request);
}
protected function resolveExpectedToken(): string
{
$candidates = [
trim((string)getenv('SEO_COLLECTOR_TOKEN')),
trim((string)env('SEO_COLLECTOR_TOKEN', '')),
trim((string)($_SERVER['SEO_COLLECTOR_TOKEN'] ?? '')),
trim((string)($_ENV['SEO_COLLECTOR_TOKEN'] ?? '')),
];
foreach ($candidates as $value) {
if ($value !== '') {
return $value;
}
}
return '';
}
protected function resolveProvidedToken(Request $request): string
{
$headerToken = trim((string)$request->header('x-seo-collector-token', ''));
if ($headerToken !== '') {
return $headerToken;
}
$bearer = trim((string)$request->header('authorization', ''));
if (preg_match('/^Bearer\s+(.+)$/i', $bearer, $matches)) {
return trim((string)($matches[1] ?? ''));
}
$queryToken = trim((string)$request->get('token', ''));
if ($queryToken !== '') {
return $queryToken;
}
return trim((string)$request->post('token', ''));
}
protected function jsonError(string $code, string $message)
{
return json([
'code' => $code,
'msg' => $message,
'data' => [],
], 200, [], [JSON_UNESCAPED_UNICODE]);
}
}

View File

@@ -0,0 +1 @@
<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8"><title>Domain Import Health Workbench</title><style>body{font-family:Arial,sans-serif;padding:24px;}h1{margin-bottom:8px;}ul{margin-top:8px;}code{background:#f3f3f3;padding:2px 4px;}table{border-collapse:collapse;width:100%;margin-top:16px;}th,td{border:1px solid #ddd;padding:8px;text-align:left;}th{background:#f6f6f6;}</style></head><body><h1>Domain Import Health Workbench</h1><p>generated_at: <code>2026-04-12T14:15:32+08:00</code></p><p>health_label: <strong>worsening</strong> / stage: <strong>idle</strong></p><p>hero_summary: 当前还没有导入记录,先从批量导入建立健康主线。</p><h3>Priority Actions</h3><ul><li>先导入一批站点 / 当前还没有导入记录,先从批量导入开始建立主线数据。</li><li>回看最近重跑 / 最近已有 1 笔重跑记录,可以先判断恢复主要靠重跑还是继续卡住。</li></ul><h3>Top Failed Stages</h3><ul><li>-</li></ul><h3>Recovery Mix</h3><p>primary_path: <strong>none</strong></p><p>resolved_total: <strong>0</strong> / rerun: <strong>0</strong> / remediation: <strong>0</strong></p></body></html>

View File

@@ -0,0 +1,96 @@
{
"generated_at": "2026-04-12T14:15:32+08:00",
"health_label": "worsening",
"workbench_stage": "idle",
"import_runs_count": 0,
"queue_count": 0,
"active_count": 0,
"resolved_count": 0,
"resolved_by_rerun_count": 0,
"resolved_by_remediation_count": 0,
"rerun_runs_count": 1,
"remediation_runs_count": 0,
"self_healing_runs_count": 0,
"manual_attention_count": 0,
"manual_handle_runs_count": 0,
"latest_import_run": [],
"latest_failed_item": [],
"latest_rerun_run": {
"run_id": "141325_failed_queue_57b4d0",
"run_root_public": "/www/wwwroot/diff-maccms/SEONexus/code/app/public/_admin_templates/domain-import-reruns/20260412/141325_failed_queue_57b4d0",
"processed_count": 0,
"passed_count": 0,
"failed_count": 0,
"hosts": [],
"summary_json_path": "/www/wwwroot/diff-maccms/SEONexus/code/app/public/_admin_templates/domain-import-reruns/20260412/141325_failed_queue_57b4d0/import-rerun.summary.json",
"summary_html_path": "/www/wwwroot/diff-maccms/SEONexus/code/app/public/_admin_templates/domain-import-reruns/20260412/141325_failed_queue_57b4d0/import-rerun.summary.html",
"updated_at": "2026-04-12T14:13:25+08:00"
},
"latest_remediation_run": [],
"latest_self_healing_run": [],
"latest_manual_attention_item": [],
"latest_manual_handle_run": [],
"failure_trend": {
"latest_failed_count": 0,
"previous_failed_count": 0,
"direction": 0,
"label": "flat"
},
"resolved_hosts_preview": [],
"recent_import_runs": [],
"recent_rerun_runs": [
{
"run_id": "141325_failed_queue_57b4d0",
"run_root_public": "/www/wwwroot/diff-maccms/SEONexus/code/app/public/_admin_templates/domain-import-reruns/20260412/141325_failed_queue_57b4d0",
"processed_count": 0,
"passed_count": 0,
"failed_count": 0,
"hosts": [],
"summary_json_path": "/www/wwwroot/diff-maccms/SEONexus/code/app/public/_admin_templates/domain-import-reruns/20260412/141325_failed_queue_57b4d0/import-rerun.summary.json",
"summary_html_path": "/www/wwwroot/diff-maccms/SEONexus/code/app/public/_admin_templates/domain-import-reruns/20260412/141325_failed_queue_57b4d0/import-rerun.summary.html",
"updated_at": "2026-04-12T14:13:25+08:00"
}
],
"recent_remediation_runs": [],
"recent_self_healing_runs": [],
"recent_manual_attention_items": [],
"recent_manual_handle_runs": [],
"manual_attention_buckets": {
"high": 0,
"medium": 0,
"low": 0
},
"top_failed_stages": [],
"recovery_mix": {
"resolved_total": 0,
"resolved_by_rerun_count": 0,
"resolved_by_remediation_count": 0,
"self_healing_runs_count": 0,
"primary_path": "none"
},
"priority_actions": [
{
"key": "import_runs",
"label": "先导入一批站点",
"summary": "当前还没有导入记录,先从批量导入开始建立主线数据。",
"action_key": "open_import_runs",
"action_label": "看最近导入记录",
"tag_type": "info"
},
{
"key": "rerun_runs",
"label": "回看最近重跑",
"summary": "最近已有 1 笔重跑记录,可以先判断恢复主要靠重跑还是继续卡住。",
"action_key": "open_rerun_runs",
"action_label": "看重跑记录",
"tag_type": "info"
}
],
"hero_summary": "当前还没有导入记录,先从批量导入建立健康主线。",
"meta": {
"trigger": "async_job",
"self_healing_root": "/www/wwwroot/diff-maccms/SEONexus/code/app/public/_admin_templates/domain-import-self-healing"
},
"summary_json_path": "/www/wwwroot/diff-maccms/SEONexus/code/app/public/_admin_templates/domain-import-health-workbench/20260412/141532_scheduler_5fb0d6/import-health-workbench.summary.json",
"summary_html_path": "/www/wwwroot/diff-maccms/SEONexus/code/app/public/_admin_templates/domain-import-health-workbench/20260412/141532_scheduler_5fb0d6/import-health-workbench.summary.html"
}

View File

@@ -0,0 +1 @@
<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8"><title>Domain Import Rerun Summary</title><style>body{font-family:Arial,sans-serif;padding:24px;}table{border-collapse:collapse;width:100%;margin-top:16px;}th,td{border:1px solid #ddd;padding:8px;text-align:left;vertical-align:top;}th{background:#f6f6f6;}code{background:#f3f3f3;padding:2px 4px;}</style></head><body><h1>Domain Import Rerun Summary</h1><p>generated_at: <code>2026-04-12T14:13:25+08:00</code></p><p>processed: <strong>0</strong> / passed: <strong>0</strong> / failed: <strong>0</strong></p><table><thead><tr><th>host</th><th>status</th><th>failed_stage</th><th>message</th></tr></thead><tbody></tbody></table></body></html>

View File

@@ -0,0 +1,15 @@
{
"processed_count": 0,
"passed_count": 0,
"failed_count": 0,
"items": [],
"queue_count": 0,
"generated_at": "2026-04-12T14:13:25+08:00",
"meta": {
"queue_count": 0,
"selected_host": "cnzhenbang.com",
"run_root": "/www/wwwroot/diff-maccms/SEONexus/code/app/public/_admin_templates/domain-import-runs"
},
"summary_json_path": "/www/wwwroot/diff-maccms/SEONexus/code/app/public/_admin_templates/domain-import-reruns/20260412/141325_failed_queue_57b4d0/import-rerun.summary.json",
"summary_html_path": "/www/wwwroot/diff-maccms/SEONexus/code/app/public/_admin_templates/domain-import-reruns/20260412/141325_failed_queue_57b4d0/import-rerun.summary.html"
}

View File

@@ -0,0 +1 @@
<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8"><title>Domain Import Rerun Summary</title><style>body{font-family:Arial,sans-serif;padding:24px;}table{border-collapse:collapse;width:100%;margin-top:16px;}th,td{border:1px solid #ddd;padding:8px;text-align:left;vertical-align:top;}th{background:#f6f6f6;}code{background:#f3f3f3;padding:2px 4px;}</style></head><body><h1>Domain Import Rerun Summary</h1><p>generated_at: <code>2026-04-12T14:15:44+08:00</code></p><p>processed: <strong>0</strong> / passed: <strong>0</strong> / failed: <strong>0</strong></p><table><thead><tr><th>host</th><th>status</th><th>failed_stage</th><th>message</th></tr></thead><tbody></tbody></table></body></html>

View File

@@ -0,0 +1,15 @@
{
"processed_count": 0,
"passed_count": 0,
"failed_count": 0,
"items": [],
"queue_count": 0,
"generated_at": "2026-04-12T14:15:44+08:00",
"meta": {
"queue_count": 0,
"selected_host": "cnzhenbang.com",
"run_root": "/www/wwwroot/diff-maccms/SEONexus/code/app/public/_admin_templates/domain-import-runs"
},
"summary_json_path": "/www/wwwroot/diff-maccms/SEONexus/code/app/public/_admin_templates/domain-import-reruns/20260412/141544_failed_queue_ad717a/import-rerun.summary.json",
"summary_html_path": "/www/wwwroot/diff-maccms/SEONexus/code/app/public/_admin_templates/domain-import-reruns/20260412/141544_failed_queue_ad717a/import-rerun.summary.html"
}