配置更新,位置迁移

This commit is contained in:
筱锋xiao_lfeng 2023-05-02 17:53:25 +08:00
parent 70b7c0b378
commit 438323623a
13 changed files with 80 additions and 26 deletions

View File

@ -36,7 +36,13 @@ public static function Templates(string $G_code): ?string
private static function Register(): string
{
// 变量获取
$getTitle = SendMail::$WebTitle;
$getNowTime = self::$NowTime;
$getReceiver = SendMail::$EmailReceiver;
$getEndTime = date("Y年m月d日 H:i:s", time() + SendMail::$ExpTime);
$getExpTime = (double)SendMail::$ExpTime / 60;
$getYear = date('Y');
$getDomain = $_SERVER['SERVER_NAME'];
// 结果返回
return <<<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@ -48,26 +54,27 @@ private static function Register(): string
</head>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="600" style="border-collapse: collapse;border: 1px solid #cccccc;box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175)">
<tr>
<td align="center" bgcolor="#70bbd9" style="padding: 30px 0 30px 0; font-size: 30px;">$G_TitleName</td>
<td align="center" bgcolor="#70bbd9" style="padding: 30px 0 30px 0; font-size: 30px;">$getTitle</td>
</tr>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="padding: 30px 30px 30px 30px;">
<tr>
<td style="padding: 10px 0px 30px 0px;color: #08212b; font-family: Arial, sans-serif; font-size: 10px;">
时间: <b>$G_Date</b>
发送时间: <b>$getNowTime</b>
</td>
</tr>
<tr>
<td style="padding: 0px 0px 10px 0px;color: #000000; font-family: Arial, sans-serif; font-size: 24px;">
Dear. <a style="text-decoration: none;color: #198754;" href="mailto:$G_Email">$G_Email</a>
Dear. <a style="text-decoration: none;color: #198754;" href="mailto:$getReceiver">$getReceiver</a>
</td>
</tr>
<tr>
<td style="padding: 0px 5px 5px 0px;color: #000000; font-family: Arial, sans-serif; font-size: 20px;">
您的验证码为:<strong>$G_Code</strong><br/>
您的验证码 <strong>$G_UseTime</strong> 分钟内有效,此验证码为 $G_TitleName 激活使用。<br/>
有效期至:$G_endTimes
<a href="$getDomain/account/activation.php"><button style="background-color: #008CBA;font-size: 16px;border-radius: 8px;">点击激活</button></a>
<br/>
您的身份激活 <strong>$getExpTime</strong> 分钟内有效,此身份激活为 <strong>账户注册</strong> 使用。<br/>
有效期至:$getEndTime
</td>
</tr>
</table>
@ -78,7 +85,7 @@ private static function Register(): string
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="font-family: Arial, sans-serif; font-size: 14px;">
<font style="color: grey;">&copy; 2022 - $G_Year. $G_TitleName All Rights Reserved.</font><br/>
<font style="color: grey;">&copy; 2022 - $getYear. $getTitle All Rights Reserved.</font><br/>
<font style="color: grey;">本邮件为自动发出,请勿直接回复</font>
</td>
</tr>

View File

@ -8,7 +8,7 @@
namespace Mailer\PHPMailer;
/**
* PHPMailer POP-Before-SMTP Authentication Class.
* PHPMailer POP-Before-SMTP Authentication class.
* Specifically for PHPMailer to use for RFC1939 POP-before-SMTP authentication.
* 1) This class does not support APOP authentication.
* 2) Opening and closing lots of POP3 connections can be quite slow. If you need

View File

@ -14,8 +14,11 @@ class SendMail
{
public static int $EmailType;
public static string $EmailReceiver;
private array $ConfigData;
public static int $ExpDate;
public static int $ExpTime;
public static string $WebTitle;
private PHPMailer $Mail;
/**
@ -32,7 +35,8 @@ protected function __consort()
$this->ConfigData = json_decode($Array_ConfigData, JSON_UNESCAPED_UNICODE)["Smtp"];
fclose($FileData);
// 参数赋予
self::$ExpDate = $Array_ConfigData["Mail"]['ExpDate'];
self::$ExpTime = $Array_ConfigData["Mail"]['ExpDate'];
self::$WebTitle = $Array_ConfigData["Web"]['Title'];
// 类导入
$this->Mail = new PHPMailer(true);
@ -65,9 +69,10 @@ private function SSLCheck(string $Smtp_Type)
* - [2] 站点邮件登录
* @param string $EmailReceiver 邮件接收方(邮箱地址)
* @param int $EmailType 发送邮件类型
* @param string $OtherPush 其他备注内容,例如激活码
* @return bool 邮件发送成功返回 true 否则返回 false
*/
public function PostMail(string $EmailReceiver, int $EmailType): bool
public function PostMail(string $EmailReceiver, int $EmailType, string $OtherPush = null): bool
{
self::$EmailType = $EmailType;
self::$EmailReceiver = $EmailReceiver;
@ -87,8 +92,8 @@ public function PostMail(string $EmailReceiver, int $EmailType): bool
$this->Mail->addAddress($EmailReceiver);
// 发件编写
if ($EmailType == 1) $this->EmailRegister();
else if ($EmailType == 2) $this->EmailLogin();
if ($EmailType == 1) $this->EmailRegister($OtherPush);
else if ($EmailType == 2) $this->EmailLogin($OtherPush);
$this->Mail->send();
return true;
@ -98,13 +103,13 @@ public function PostMail(string $EmailReceiver, int $EmailType): bool
}
}
private function EmailRegister(): void
private function EmailRegister(string $Input_Code): void
{
$this->Mail->Subject = $this->ConfigData['Name'] . ' - 站点注册'; // 邮箱标题
$this->Mail->Body = MailTemplate::Templates($Input_Code);
}
private function EmailLogin()
private function EmailLogin(string $OtherPush)
{
$this->Mail->Subject = $this->ConfigData['Name'] . ' - 邮箱登录验证码'; // 邮箱标题
$this->Mail->Body = MailTemplate::Templates($Input_Code);

View File

@ -60,6 +60,38 @@ private static function OutputMessage(int $gType, int $bCode)
if ($bCode == 0) return 'Success';
else if ($bCode == 1) return 200;
else return "操作成功";
else if ($gType == 201)
if ($bCode == 0) return 'SuccessButEmail';
else if ($bCode == 1) return 200;
else return "操作成功但邮件发送失败";
else if ($gType == 300)
if ($bCode == 0) return 'SqlInsertFail';
else if ($bCode == 1) return 400;
else return "数据表内容插入失败";
else if ($gType == 310)
if ($bCode == 0) return 'TokenTooShort';
else if ($bCode == 1) return 502;
else return "Token长度过短";
else if ($gType == 311)
if ($bCode == 0) return 'TokenTooLong';
else if ($bCode == 1) return 502;
else return "Token长度过长";
else if ($gType == 400)
if ($bCode == 0) return 'usernameFormat';
else if ($bCode == 1) return 405;
else return "用户名格式不符合 格式允许0-9,A-Z,a-z及_";
else if ($gType == 401)
if ($bCode == 0) return 'emailFormat';
else if ($bCode == 1) return 405;
else return "邮箱格式不符合";
else if ($gType == 500)
if ($bCode == 0) return 'CaptchaEffective';
else if ($bCode == 1) return 200;
else return "激活码任然有效";
else if ($gType == 600)
if ($bCode == 0) return 'AlReadyUser';
else if ($bCode == 1) return 403;
else return "已经有这个用户";
else
return null;
}

View File

@ -1,12 +1,16 @@
# OutputMessage 标准对照表
| 序号 | output内容 | HTTP状态码 | 中文解释 |
|-----|---------------|---------|-----------|
| 100 | SessionError | 502 | 通讯密钥错误 |
| 200 | Success | 200 | 操作成功 |
| 300 | Sql | 502 | |
| 310 | TokenTooShort | 502 | Token长度过短 |
| 311 | TokenTooLong | 502 | Token长度过长 |
| 序号 | output内容 | HTTP状态码 | 中文解释 |
|-----|------------------|---------|------------------------------|
| 100 | SessionError | 502 | 通讯密钥错误 |
| 200 | Success | 200 | 操作成功 |
| 201 | SuccessButEmail | 200 | 操作成功但邮件发送失败 |
| 300 | SqlInsertFail | 400 | 数据表内容插入失败 |
| 310 | TokenTooShort | 502 | Token长度过短 |
| 311 | TokenTooLong | 502 | Token长度过长 |
| 400 | usernameFormat | 405 | 用户名格式不符合 格式允许0-9,A-Z,a-z及_ |
| 401 | emailFormat | 405 | 邮箱格式不符合 |
| 500 | CaptchaEffective | 200 | 激活码任然有效 |
| 600 | AlReadyUser | 403 | 已经有这个用户 |
| | | | |
| | | | |

View File

@ -1,5 +1,11 @@
{
"Session": "xiaolfengindex",
"Web": {
"Title": "筱锋xiao_lfeng",
"subTitle": "不为如何,只为在茫茫人海中有自己的一片天空~",
"Keyword": "",
"Icon": "https://api.x-lf.cn/avatar/?uid=1"
},
"Mysql": {
"Host": "127.0.0.1",
"Port": "3306",