From 4652803d38db5fbabb16ae4bc4d2bb2e30d96b51 Mon Sep 17 00:00:00 2001 From: filesite Date: Sun, 28 Apr 2024 16:17:07 +0800 Subject: [PATCH] add friends code check --- controller/Controller.php | 12 +++---- plugins/Common.php | 34 +++++++++++++++++++ .../tajian/controller/FrontapiController.php | 31 +++++++++++++++-- themes/tajian/views/site/login.php | 2 +- themes/tajian/views/site/register.php | 2 +- 5 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 plugins/Common.php diff --git a/controller/Controller.php b/controller/Controller.php index 478650c..ea9e4af 100644 --- a/controller/Controller.php +++ b/controller/Controller.php @@ -131,7 +131,7 @@ Class Controller { } //get params by key - protected function get($key = '', $defaultValue = '') { + protected function get($key = '', $defaultValue = '') { if (empty($key)) { return $_GET; } @@ -139,7 +139,7 @@ Class Controller { } //post params by key - protected function post($key = '', $defaultValue = '') { + protected function post($key = '', $defaultValue = '') { if (empty($key)) { return $_POST; } @@ -147,7 +147,7 @@ Class Controller { } //debug log - protected function logTimeCost() { + protected function logTimeCost() { if (!empty(FSC::$app['config']['debug'])) { $end_time = microtime(true); $timeCost = ceil( ($end_time - FSC::$app['start_time']) * 1000 ); //ms @@ -163,7 +163,7 @@ Class Controller { } //error log - protected function logError($error_message) { + protected function logError($error_message) { if (!empty(FSC::$app['config']['debug'])) { $thisUrl = FSC::$app['requestUrl']; $logTime = date('Y-m-d H:i:s'); @@ -172,7 +172,7 @@ Class Controller { $logOk = @error_log("{$logTime}\t{$thisUrl}\tERROR: {$error_message}\n", 3, "{$logDir}{$logFilename}"); if (!$logOk) { //try to mkdir @mkdir($logDir, 0700, true); - @error_log("{$logTime}\t{$thisUrl}\ttERROR: {$error_message} ms\n", 3, "{$logDir}{$logFilename}"); + @error_log("{$logTime}\t{$thisUrl}\tERROR: {$error_message}\n", 3, "{$logDir}{$logFilename}"); } } } @@ -245,7 +245,7 @@ Class Controller { //set cookie for message show //type: info, warning, danger, success - protected function sendMsgToClient($msg, $type = 'info') { + protected function sendMsgToClient($msg, $type = 'info') { $cookieKey = "alert_msg_{$type}"; $expires = time() + 15; $path = '/'; diff --git a/plugins/Common.php b/plugins/Common.php new file mode 100644 index 0000000..bc0b269 --- /dev/null +++ b/plugins/Common.php @@ -0,0 +1,34 @@ +post(); + if (!empty($postParams)) { + $friends_code = $this->post('friendscode', ''); + $cellphone = $this->post('username', ''); + $sms_code = $this->post('smscode', ''); + + if (empty($friends_code) || empty($cellphone) || empty($sms_code)) { + $err = "请填写注册邀请码、手机号码和短信验证码哦"; + }else if (Common::isCellphoneNumber($cellphone) == false) { + $err = "手机号码格式错误,请填写正确的手机号码"; + }else if (Common::isFriendsCode($friends_code) == false) { + $err = "邀请码格式错误,请填写邀请你的朋友的手机号码末 6 位,还可以加客服微信索取"; + }else if (Common::existFriendsCode($friends_code) == false) { + $err = "邀请码不存在,请填写邀请你的朋友的手机号码末 6 位,或者加客服微信索取"; + } + + //TODO: 验证短信验证码是否正确 + + } + + return $this->renderJson(compact('code', 'msg', 'err', 'data')); } //用户登录 diff --git a/themes/tajian/views/site/login.php b/themes/tajian/views/site/login.php index 118bb5c..011cd5c 100644 --- a/themes/tajian/views/site/login.php +++ b/themes/tajian/views/site/login.php @@ -6,7 +6,7 @@
- +
diff --git a/themes/tajian/views/site/register.php b/themes/tajian/views/site/register.php index 21493d2..01878be 100644 --- a/themes/tajian/views/site/register.php +++ b/themes/tajian/views/site/register.php @@ -14,7 +14,7 @@
- +