-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·91 lines (77 loc) · 3.44 KB
/
index.php
File metadata and controls
executable file
·91 lines (77 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* 主入口文件
* 处理域名识别、配置加载和页面渲染
*/
// 引入核心类
require_once __DIR__ . '/core/DomainConfig.php';
require_once __DIR__ . '/core/EmailHandler.php';
require_once __DIR__ . '/core/StatsTracker.php';
// 初始化域名配置
$domainConfig = new DomainConfig();
// 初始化访问统计(自动记录当前访问)
$statsTracker = new StatsTracker();
$statsTracker->track();
// 处理 AJAX 请求
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
header('Content-Type: application/json; charset=UTF-8');
require_once __DIR__ . '/core/VerificationCode.php';
$verificationCode = new VerificationCode();
switch ($_POST['action']) {
case 'send_code':
// 发送验证码
$email = isset($_POST['email']) ? trim($_POST['email']) : '';
$emailHandler = new EmailHandler($domainConfig);
$result = $verificationCode->sendCode($email, $emailHandler, $domainConfig);
echo json_encode($result, JSON_UNESCAPED_UNICODE);
exit;
case 'verify_code':
// 验证验证码
$email = isset($_POST['email']) ? trim($_POST['email']) : '';
$code = isset($_POST['code']) ? trim($_POST['code']) : '';
$result = $verificationCode->verifyCode($email, $code);
echo json_encode($result, JSON_UNESCAPED_UNICODE);
exit;
case 'contact':
// 提交表单
$email = isset($_POST['email']) ? trim($_POST['email']) : '';
$offerPrice = isset($_POST['offer_price']) ? trim($_POST['offer_price']) : '';
// 验证邮箱是否已验证
if (!$verificationCode->isVerified($email)) {
echo json_encode([
'success' => false,
'message' => '请先验证您的邮箱'
], JSON_UNESCAPED_UNICODE);
exit;
}
$emailHandler = new EmailHandler($domainConfig);
$result = $emailHandler->sendContactForm([
'name' => isset($_POST['name']) ? trim($_POST['name']) : '',
'email' => $email,
'message' => isset($_POST['message']) ? trim($_POST['message']) : '',
'offer_price' => $offerPrice
]);
echo json_encode($result, JSON_UNESCAPED_UNICODE);
exit;
}
}
// 获取配置信息
$title = $domainConfig->get('title');
$description = $domainConfig->get('description');
$domainIntro = $domainConfig->get('domain_intro'); // 域名介绍
$themeColor = $domainConfig->get('theme_color');
$currentDomain = $domainConfig->getCurrentDomain();
$domainPrice = $domainConfig->get('domain_price');
$siteNameRaw = $domainConfig->get('site_name', 'NameDeal'); // 站点名称默认值
$siteName = trim(str_replace('域名停放', '', (string)$siteNameRaw));
if ($siteName === '') {
$siteName = 'NameDeal';
}
$footerLinks = $domainConfig->get('footer_links', []);
$footerWhoisUrl = $domainConfig->get('footer_whois_url', 'https://bluewhois.com/{domain}');
$footerXifengUrl = $domainConfig->get('footer_xifeng_url', 'https://xifeng.net');
$footerMoreDomainsUrl = $domainConfig->get('footer_more_domains_url', 'https://domain.ls');
$footerAnalyticsCode = $domainConfig->get('footer_analytics_code', '');
$domainValueSettings = $domainConfig->get('domain_value', []);
// 引入页面模板
include __DIR__ . '/templates/parking.php';