From 438323623a7568e3e43ac038c13ba38e893f95de Mon Sep 17 00:00:00 2001 From: XiaoLFeng Date: Tue, 2 May 2023 17:53:25 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=9B=B4=E6=96=B0,=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- {Class => class}/Key.php | 0 {Class => class}/Mailer/MailTemplate.php | 23 ++++++++----- {Class => class}/Mailer/PHPMailer/OAuth.php | 0 .../Mailer/PHPMailer/OAuthTokenProvider.php | 0 .../Mailer/PHPMailer/PHPMailer.php | 0 {Class => class}/Mailer/PHPMailer/POP3.php | 2 +- {Class => class}/Mailer/PHPMailer/SMTP.php | 0 {Class => class}/Mailer/SendMail.php | 19 +++++++---- {Class => class}/Normal.php | 32 +++++++++++++++++++ {Class => class}/Sql.php | 0 {Class => class}/Token.php | 0 mastermind/OutputMessage.md | 24 ++++++++------ setting.inc.json | 6 ++++ 13 files changed, 80 insertions(+), 26 deletions(-) rename {Class => class}/Key.php (100%) rename {Class => class}/Mailer/MailTemplate.php (77%) rename {Class => class}/Mailer/PHPMailer/OAuth.php (100%) rename {Class => class}/Mailer/PHPMailer/OAuthTokenProvider.php (100%) rename {Class => class}/Mailer/PHPMailer/PHPMailer.php (100%) rename {Class => class}/Mailer/PHPMailer/POP3.php (99%) rename {Class => class}/Mailer/PHPMailer/SMTP.php (100%) rename {Class => class}/Mailer/SendMail.php (86%) rename {Class => class}/Normal.php (77%) rename {Class => class}/Sql.php (100%) rename {Class => class}/Token.php (100%) diff --git a/Class/Key.php b/class/Key.php similarity index 100% rename from Class/Key.php rename to class/Key.php diff --git a/Class/Mailer/MailTemplate.php b/class/Mailer/MailTemplate.php similarity index 77% rename from Class/Mailer/MailTemplate.php rename to class/Mailer/MailTemplate.php index dd0ee8d..7393360 100644 --- a/Class/Mailer/MailTemplate.php +++ b/class/Mailer/MailTemplate.php @@ -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 << @@ -48,26 +54,27 @@ private static function Register(): string - +
$G_TitleName$getTitle
- 时间: $G_Date + 发送时间: $getNowTime
- Dear. $G_Email + Dear. $getReceiver
- 您的验证码为:$G_Code
- 您的验证码 $G_UseTime 分钟内有效,此验证码为 $G_TitleName 激活使用。
- 有效期至:$G_endTimes + +
+ 您的身份激活 $getExpTime 分钟内有效,此身份激活为 账户注册 使用。
+ 有效期至:$getEndTime
@@ -78,7 +85,7 @@ private static function Register(): string diff --git a/Class/Mailer/PHPMailer/OAuth.php b/class/Mailer/PHPMailer/OAuth.php similarity index 100% rename from Class/Mailer/PHPMailer/OAuth.php rename to class/Mailer/PHPMailer/OAuth.php diff --git a/Class/Mailer/PHPMailer/OAuthTokenProvider.php b/class/Mailer/PHPMailer/OAuthTokenProvider.php similarity index 100% rename from Class/Mailer/PHPMailer/OAuthTokenProvider.php rename to class/Mailer/PHPMailer/OAuthTokenProvider.php diff --git a/Class/Mailer/PHPMailer/PHPMailer.php b/class/Mailer/PHPMailer/PHPMailer.php similarity index 100% rename from Class/Mailer/PHPMailer/PHPMailer.php rename to class/Mailer/PHPMailer/PHPMailer.php diff --git a/Class/Mailer/PHPMailer/POP3.php b/class/Mailer/PHPMailer/POP3.php similarity index 99% rename from Class/Mailer/PHPMailer/POP3.php rename to class/Mailer/PHPMailer/POP3.php index eeea2e4..6f46698 100644 --- a/Class/Mailer/PHPMailer/POP3.php +++ b/class/Mailer/PHPMailer/POP3.php @@ -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 diff --git a/Class/Mailer/PHPMailer/SMTP.php b/class/Mailer/PHPMailer/SMTP.php similarity index 100% rename from Class/Mailer/PHPMailer/SMTP.php rename to class/Mailer/PHPMailer/SMTP.php diff --git a/Class/Mailer/SendMail.php b/class/Mailer/SendMail.php similarity index 86% rename from Class/Mailer/SendMail.php rename to class/Mailer/SendMail.php index 6a91ea8..68cafe4 100644 --- a/Class/Mailer/SendMail.php +++ b/class/Mailer/SendMail.php @@ -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); diff --git a/Class/Normal.php b/class/Normal.php similarity index 77% rename from Class/Normal.php rename to class/Normal.php index 9f9059d..90f210e 100644 --- a/Class/Normal.php +++ b/class/Normal.php @@ -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; } diff --git a/Class/Sql.php b/class/Sql.php similarity index 100% rename from Class/Sql.php rename to class/Sql.php diff --git a/Class/Token.php b/class/Token.php similarity index 100% rename from Class/Token.php rename to class/Token.php diff --git a/mastermind/OutputMessage.md b/mastermind/OutputMessage.md index 616c9f4..6d7c2fb 100644 --- a/mastermind/OutputMessage.md +++ b/mastermind/OutputMessage.md @@ -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 | 已经有这个用户 | +| | | | | +| | | | | \ No newline at end of file diff --git a/setting.inc.json b/setting.inc.json index 7b97dbd..5a5c2ed 100644 --- a/setting.inc.json +++ b/setting.inc.json @@ -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",
- © 2022 - $G_Year. $G_TitleName All Rights Reserved.
+ © 2022 - $getYear. $getTitle All Rights Reserved.
本邮件为自动发出,请勿直接回复