invite signup check code's owner

This commit is contained in:
xiaomlove
2021-05-04 14:21:18 +08:00
parent 8bcf4a7d4c
commit 9be4043031
9 changed files with 54 additions and 8 deletions
+12
View File
@@ -0,0 +1,12 @@
<?php
namespace App\Models;
class Invite extends NexusModel
{
protected $table = 'invites';
protected $fillable = [
'inviter', 'invitee', 'hash', 'time_invited',
];
}
-1
View File
@@ -14,7 +14,6 @@ class NexusModel extends Model
// protected $perPage = 2; // protected $perPage = 2;
/** /**
* 为数组 / JSON 序列化准备日期。
* *
* @param \DateTimeInterface $date * @param \DateTimeInterface $date
* @return string * @return string
+6 -1
View File
@@ -53,11 +53,16 @@ $inviter = $_POST["inviter"];
$code = unesc($_POST["hash"]); $code = unesc($_POST["hash"]);
//check invite code //check invite code
$sq = sprintf("SELECT inviter FROM invites WHERE hash ='%s'",mysql_real_escape_string($code)); $sq = sprintf("SELECT id, inviter FROM invites WHERE hash ='%s'",mysql_real_escape_string($code));
$res = sql_query($sq) or sqlerr(__FILE__, __LINE__); $res = sql_query($sq) or sqlerr(__FILE__, __LINE__);
$inv = mysql_fetch_assoc($res); $inv = mysql_fetch_assoc($res);
if (!$inv) if (!$inv)
bark('invalid invite code'); bark('invalid invite code');
if ($inv['inviter'] != $inviter) {
\App\Models\Invite::query()->where('id', $inv['id'])->delete();
stderr(nexus_trans('nexus.invalid_argument'), nexus_trans('invite.invalid_inviter'));
exit();
}
$ip = getip(); $ip = getip();
+5
View File
@@ -0,0 +1,5 @@
<?php
return [
'invalid_inviter' => 'Invalid inviter! The invite code is banned!',
];
+5
View File
@@ -0,0 +1,5 @@
<?php
return [
'invalid_argument' => 'Invalid argument',
];
+5
View File
@@ -0,0 +1,5 @@
<?php
return [
'invalid_inviter' => '非法邀请者!此邀请码已被禁用!',
];
+5
View File
@@ -0,0 +1,5 @@
<?php
return [
'invalid_argument' => '参数错误',
];
+5
View File
@@ -0,0 +1,5 @@
<?php
return [
'invalid_inviter' => '非法邀請者!此邀請碼已被禁用!',
];
+5
View File
@@ -0,0 +1,5 @@
<?php
return [
'invalid_argument' => '參數錯誤',
];