forked from XiaoLFeng/XF_Index
初步递交
This commit is contained in:
parent
438323623a
commit
ef0fb839e5
@ -34,6 +34,7 @@ public static function MySqlConn()
|
||||
public static function SELECT(string $Mysql_Query): array
|
||||
{
|
||||
$CC_i = 0;
|
||||
$Result = null;
|
||||
$Array_OutPut = [];
|
||||
if (preg_match('/^SELECT/', $Mysql_Query)) {
|
||||
$Result = mysqli_query(self::MySqlConn(), $Mysql_Query);
|
||||
@ -45,6 +46,7 @@ public static function SELECT(string $Mysql_Query): array
|
||||
$Array_OutPut['output'] = 'EmptyResult';
|
||||
} else
|
||||
$Array_OutPut['output'] = 'TypeError';
|
||||
mysqli_free_result($Result);
|
||||
return $Array_OutPut;
|
||||
}
|
||||
|
||||
|
@ -1 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
||||
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
||||
* https://www.x-lf.com/
|
||||
*/
|
||||
|
||||
|
||||
|
8
public/account/activation.php
Normal file
8
public/account/activation.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
||||
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
||||
* https://www.x-lf.com/
|
||||
*/
|
||||
|
||||
|
21
public/admin/index.php
Normal file
21
public/admin/index.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
||||
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
||||
* https://www.x-lf.com/
|
||||
*/
|
||||
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="zh-cn">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
92
public/api/auth/register/index.php
Normal file
92
public/api/auth/register/index.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
||||
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
||||
* https://www.x-lf.com/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @var Array $Json_Data 最终数据编译输出
|
||||
* @var array $Array_ConfigData 配置文件
|
||||
*/
|
||||
|
||||
session_start();
|
||||
// 引入配置
|
||||
include dirname(__FILE__, 5) . "/Modules/API/header.php";
|
||||
require dirname(__FILE__, 5) . "/class/Sql.php";
|
||||
require dirname(__FILE__, 5) . "/class/Token.php";
|
||||
require dirname(__FILE__, 5) . "/class/Mailer/SendMail.php";
|
||||
require dirname(__FILE__, 5) . "/class/Normal.php";
|
||||
require dirname(__FILE__, 5) . "/class/Key.php";
|
||||
|
||||
// 类配置
|
||||
$ClassToken = new Token(40);
|
||||
$ClassMailer = new Mailer\SendMail();
|
||||
|
||||
// 数据获取类型
|
||||
$PostData = file_get_contents('php://input');
|
||||
$PostData = json_decode($PostData, true);
|
||||
|
||||
// 函数构建
|
||||
if ($Array_ConfigData['Session'] == $_SERVER['HTTP_SESSION']) {
|
||||
if (empty($_COOKIE['user'])) {
|
||||
// 检查数据
|
||||
if (preg_match('/^[0-9A-Za-z_]+$/', $PostData['username'])) {
|
||||
if (preg_match('/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/', $PostData['email'])) {
|
||||
// 密码加密
|
||||
$PostData['password'] = password_hash($PostData['password'], PASSWORD_DEFAULT);
|
||||
// 进行数据查找
|
||||
$AResult_User = Sql::SELECT("SELECT * FROM `index`.xf_user WHERE `username`='{$PostData['username']}' OR `email`='{$PostData['email']}'");
|
||||
if ($AResult_User['output'] == "EmptyResult") {
|
||||
// 创建用户
|
||||
if (Sql::INSERT("INSERT INTO `index`.xf_user (`username`,`email`,`password`,`reg_time`,`reg_ip`) VALUES ('{$PostData['username']}','{$PostData['email']}','{$PostData['password']}','" . time() . "','" . $_SERVER['REMOTE_ADDR'] . "')")) {
|
||||
// 生成激活码
|
||||
$Data_Captcha = Key::Captcha(100);
|
||||
$Data_NowTime = time();
|
||||
// 查找是否需要重新生成激活码
|
||||
$AResult_UserEmailVerify = Sql::SELECT("SELECT * FROM `index`.xf_email_verify WHERE `uid`={$PostData['username']} AND `time` >= $Data_NowTime-{$Array_ConfigData['Mail']['ExpDate']}");
|
||||
if ($AResult_UserEmailVerify['output'] == "EmptyResult") {
|
||||
// 创建激活码
|
||||
if (Sql::INSERT("INSERT INTO `index`.xf_email_verify (`uid`, `code`, `time`) VALUES ('{$PostData['username']}','$Data_Captcha','$Data_NowTime')")) {
|
||||
// 邮件发送
|
||||
if ($ClassMailer->PostMail($PostData['email'], 1, $Data_Captcha))
|
||||
Normal::Output(200);
|
||||
else Normal::Output(201);
|
||||
} else Normal::Output(300);
|
||||
} else Normal::Output(500);
|
||||
} else Normal::Output(300);
|
||||
} else Normal::Output(600);
|
||||
} else Normal::Output(401);
|
||||
} else Normal::Output(400);
|
||||
} else {
|
||||
// 数据库查找用户是否存在
|
||||
$AResult_User = Sql::SELECT("SELECT * FROM `index`.xf_user WHERE `uid`='{$_COOKIE['user']}'");
|
||||
if ($AResult_User['output'] == 'Success') {
|
||||
$Json_Data = [
|
||||
'output' => "AlReadyLogin",
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => "您已登录",
|
||||
],
|
||||
];
|
||||
} else if ($AResult_User['output'] == 'EmptyResult') {
|
||||
$Json_Data = [
|
||||
'output' => "IllegalLogin",
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => "非法登录",
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$Json_Data = [
|
||||
'output' => $AResult_User['output'],
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => "数据库搜索类型错误",
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Normal::Output(100);
|
||||
}
|
39
public/api/auth/registerCheck/index.php
Normal file
39
public/api/auth/registerCheck/index.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
||||
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
||||
* https://www.x-lf.com/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @var array $Json_Data 最终数据编译输出
|
||||
* @var array $Array_ConfigData 配置文件
|
||||
*/
|
||||
|
||||
// 引入配置
|
||||
include dirname(__FILE__, 5) . "/Modules/API/header.php";
|
||||
require dirname(__FILE__, 5) . "/class/Sql.php";
|
||||
require dirname(__FILE__, 5) . "/class/Normal.php";
|
||||
|
||||
// 数据获取类型
|
||||
$GetData = [
|
||||
'code' => urldecode(htmlspecialchars($_GET['code'])),
|
||||
];
|
||||
|
||||
// 函数构建
|
||||
if ($Array_ConfigData['Session'] == $_SERVER['HTTP_SESSION']) { /* 检查通讯密钥是否正确 */
|
||||
if (!empty($_COOKIE['user'])) {
|
||||
|
||||
} else {
|
||||
$Json_Data = [
|
||||
'output' => 'NoLogin',
|
||||
'code' => 502,
|
||||
'data' => [
|
||||
'message' => '需要登陆',
|
||||
],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
// 编译输出
|
||||
Normal::Output(100);
|
||||
}
|
8
public/api/index.php
Normal file
8
public/api/index.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
||||
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
||||
* https://www.x-lf.com/
|
||||
*/
|
||||
|
||||
|
50
public/api/token/create/index.php
Normal file
50
public/api/token/create/index.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
||||
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
||||
* https://www.x-lf.com/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @var Array $Json_Data 最终数据编译输出
|
||||
*/
|
||||
|
||||
// 类引入
|
||||
require dirname(__FILE__, 5) . "/class/Token.php";
|
||||
// 类构建
|
||||
$ClassToken = new Token(40, true);
|
||||
|
||||
// 函数构建
|
||||
if (empty($_COOKIE['Token'])) {
|
||||
if (preg_match('/^Token:/', $ClassToken->getToken())) {
|
||||
// 不匹配Token
|
||||
$Data_Token = substr($ClassToken->getToken(), 6);
|
||||
// 生成Token
|
||||
$Json_Data = [
|
||||
'output' => 'Success',
|
||||
'code' => 200,
|
||||
'data' => [
|
||||
'message' => '生成完毕',
|
||||
'token' => $Data_Token,
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$Json_Data = [
|
||||
'output' => $ClassToken->getToken(),
|
||||
'code' => 502,
|
||||
'data' => [
|
||||
'message' => '按需检查对应错误',
|
||||
],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$Json_Data = [
|
||||
'output' => 'TokenNotEmpty',
|
||||
'code' => 403,
|
||||
'data' => [
|
||||
'message' => "Token不为空",
|
||||
],
|
||||
];
|
||||
}
|
||||
// 输出JSON
|
||||
echo json_encode($Json_Data, JSON_UNESCAPED_UNICODE);
|
6
public/index.php
Normal file
6
public/index.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
|
||||
* 开发开源遵循 MIT 许可,若需商用请联系开发者
|
||||
* https://www.x-lf.com/
|
||||
*/
|
Loading…
x
Reference in New Issue
Block a user