阿拉德客户端注册文件
把文件放进网站目录application\account\controller
替换掉原来的即可 无需重启 就能游戏内注册了
将下面代码重命名Reg.php,并替换到指定目录
<?php
namespace app\account\controller;
class Reg
{
public function index()
{
$res = new \app\common\controller\Res();
$request = \think\Request::instance()->post();
if ($request) {
$rule = ["username" => [0 => "require", "regex" => "/(?![0-9]+\$)(?![a-z]+\$)[0-9A-Za-z]{3,18}\$/"], "pwd" => [0 => "require", "regex" => "/(?![0-9]+\$)(?![a-z]+\$)(?![A-Z]+\$)[0-9A-Za-z]{6,18}\$/"]];
$msg = ["username.require" => "用户名不能为空", "username.regex" => "用户名不能有特殊字符 且不能出现汉字空格 ,包含字母, 示例:Aa10001 3-18位", "username.token" => "验证错误token", "pwd.require" => "密码不能为空", "pwd.regex" => "密码必须6到18位,且不能出现空格 ,包含字母,不能有特殊字符 示例:Aa10001 6-18位", "safety.require" => "安全码必须", "safety.regex" => "密码必须6到18位,且不能出现空格 ,包含字母,不能有特殊字符 示例:Aa10001 6-18位", "vercode.require" => "验证码必须", "vaptcha_token.require" => "手绘必须"];
$validate = \think\Validate::make($rule, $msg);
$result = $validate->check($request);
if (true !== $result) {
$err = $validate->getError();
return '{"ret":1,"msg":"' . $err . '","data":[]}';
} else {
$requestD = \think\Request::instance();
if ($request["username"] && $request["pwd"] && $request["username"] != "admin") {
$username = \think\Db::name("user")->field("Id")->where("account", $request["username"])->find();
if (!$username) {
$username = \think\Db::name("user")->field("Id")->where("ip", $requestD->ip())->count();
if ($username >= 999) {
return '{"ret":900,"msg":"注册以上限 50","data":[]}';
} else {
$time = date("Y-m-d H:i:s", time());
$data = ["account" => $request["username"], "password" => md5($request["pwd"]), "email" => "", "agent" => "zgy520", "state" => "1", "logintime" => $time, "regtime" => $time, "recharge" => "0", "ip" => $requestD->ip(), "ipd" => $requestD->ip(), "safety" => "zgy520", "lock" => 0];
$datae = \think\Db::name("user")->insert($data);
if ($datae) {
//ret=0返回直接登陆界面的,不过要写登陆验证这里懒得搞了!!!!!!
//return '{"ret":0,"msg":"注册成功!请返回登陆!","data":[]}';
return '{"ret":900,"msg":"注册成功!请返回登陆!","data":[]}';
}
}
} else {
return '{"ret":900,"msg":"用户已存在!!!请返回直接登陆即可!!!","data":[]}';
}
}
}
}
}
}
快来抢楼王
快来抢楼王
感谢楼主分享
感谢楼主分享
感谢分享
看到这帖子真是高兴!