mirror of
https://github.com/tznb1/TwoNav.git
synced 2025-08-10 08:51:49 +00:00
v2.1.15-20240513
This commit is contained in:
@@ -47,149 +47,8 @@ if(!preg_match('/^[A-Za-z0-9]{4,13}$/', $user)){
|
||||
msg(-1,'POST提交的密码异常≠32!');
|
||||
}elseif(preg_match("/^(system|data|static|templates|index|root|admin)$/i",$user) ) {
|
||||
msg(-1,'改用户名已被系统保留!');
|
||||
}elseif(!empty(get_db('global_user','ID',['User'=>$user ]))){
|
||||
msg(-1,'该账号已被注册!');
|
||||
}elseif(!empty(get_db('global_user','ID',['Email'=>$Email ]))){
|
||||
msg(-1,'该邮箱已被使用!');
|
||||
}elseif(!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/i",$Email)){
|
||||
msg(-1,'邮箱错误!');
|
||||
}elseif(username_retain_verify($user)){
|
||||
msg(-1,'该账号已被站长保留!');
|
||||
}
|
||||
|
||||
//插入用户表和创建初始数据库
|
||||
$RegTime = time();
|
||||
$PassMD5 = Get_MD5_Password($pass,$RegTime);
|
||||
$Elogin = Get_Exclusive_Login($user);
|
||||
|
||||
//用户组
|
||||
if(!empty($regcode_info['u_group'])){
|
||||
$UserGroup = $regcode_info['u_group'];
|
||||
}elseif(!empty($global_config['default_UserGroup'])){
|
||||
$UserGroup = $global_config['default_UserGroup'];
|
||||
}else{
|
||||
$UserGroup = 'default';
|
||||
}
|
||||
|
||||
//读取用户组信息,如果用户组不存在则设为默认用户组
|
||||
if(!in_array($UserGroup,['default','root','visitor'])){
|
||||
$Group = get_db('user_group','*',['code' => $UserGroup]);
|
||||
if(empty( $Group )){
|
||||
$UserGroup = 'default';
|
||||
}
|
||||
}
|
||||
|
||||
$blueprint = !empty(get_db('global_user','ID',['ID'=>$Group['uid']]));
|
||||
|
||||
if($blueprint){
|
||||
$LoginConfig = unserialize(get_db('global_user','LoginConfig',['ID'=>$Group['uid']]));
|
||||
$LoginConfig['Password2'] = '';
|
||||
}else{
|
||||
//不需要修改内容,无需反序化
|
||||
$LoginConfig = get_db('global_config','v',['k'=>'LoginConfig']);
|
||||
}
|
||||
//父ID
|
||||
if(!empty($regcode_info['user'])){
|
||||
$FID = get_db('global_user','ID',['User'=>$regcode_info['user']]);
|
||||
}else{
|
||||
$FID = 0;
|
||||
}
|
||||
|
||||
|
||||
insert_db("global_user", [
|
||||
"FID"=>$FID,
|
||||
"User"=>$user,
|
||||
"Password"=>$PassMD5,
|
||||
"UserGroup"=>$UserGroup,
|
||||
"Email"=>$Email,
|
||||
"SecretKey"=>'',
|
||||
"Token"=>'',
|
||||
"RegIP"=>$IP,
|
||||
"RegTime"=>$RegTime,
|
||||
"Login"=>$Elogin,
|
||||
"LoginConfig"=>$LoginConfig
|
||||
]);
|
||||
|
||||
//读取用户信息
|
||||
$USER_DB = get_db("global_user", "*", ["User"=>$user]);
|
||||
//记录日志
|
||||
insert_db("user_log", ["uid" => $USER_DB['ID'],"user"=>$USER_DB['User'],"ip"=>$IP,"time"=>time(),"type" => 'register',"content"=>Get_Request_Content(),"description"=>"注册账号"]);
|
||||
//生成Cookie
|
||||
Set_key($USER_DB);
|
||||
|
||||
//注册码注册时回写数据
|
||||
if(!empty($regcode_info)){
|
||||
update_db('regcode_list',['use_time'=>time(),'use_state'=>'已使用,用户名:'.$user],['id'=>$regcode_info['id']]);
|
||||
}
|
||||
|
||||
//写默认站点配置
|
||||
if($blueprint){
|
||||
$s_site = get_db('user_config','v',['k'=>'s_site','uid'=>$Group['uid']]);
|
||||
}else{
|
||||
$s_site = get_db('global_config','v',['k'=>'s_site']);
|
||||
}
|
||||
|
||||
insert_db("user_config", ["uid"=>$USER_DB['ID'], "k" => "s_site","v" => $s_site,"d" => '站点配置','t'=>'config']);
|
||||
|
||||
//写默认模板
|
||||
if($blueprint){
|
||||
$global_templates = unserialize(get_db('user_config','v',['k'=>'s_templates','uid'=>$Group['uid']]));
|
||||
}else{
|
||||
$global_templates = unserialize(get_db('global_config','v',['k'=>'s_templates']));
|
||||
}
|
||||
|
||||
insert_db("user_config", ["uid" => $USER_DB['ID'],"k"=>"s_templates","v"=>$global_templates,"t"=>"config","d" => '默认模板']);
|
||||
|
||||
//写初始分类和链接
|
||||
$time = time();
|
||||
if($blueprint){
|
||||
$categorys = select_db('user_categorys','*',['uid'=>$Group['uid']]);
|
||||
$links = select_db('user_links','*',['uid'=>$Group['uid']]);
|
||||
}else{
|
||||
$categorys = select_db('user_categorys','*',['uid'=>0]);
|
||||
$links = select_db('user_links','*',['uid'=>0]);
|
||||
}
|
||||
|
||||
foreach ($categorys as $key => $data){
|
||||
$data['uid'] = $USER_DB['ID'];
|
||||
$data['add_time'] = $time;
|
||||
$data['up_time'] = $time;
|
||||
unset($data['id']);
|
||||
insert_db('user_categorys',$data);
|
||||
}
|
||||
|
||||
foreach ($links as $key => $data){
|
||||
$data['uid'] = $USER_DB['ID'];
|
||||
$data['add_time'] = $time;
|
||||
$data['up_time'] = $time;
|
||||
unset($data['id']);
|
||||
insert_db('user_links',$data);
|
||||
}
|
||||
|
||||
//写初始ID
|
||||
$link_id = intval(max_db('user_links','lid',['uid'=>$USER_DB['ID']])) +1;
|
||||
insert_db("user_config", ["uid"=>$USER_DB['ID'],"k"=>"link_id","v"=>$link_id,"t"=>"max_id","d"=>'链接ID']);
|
||||
$category_id = intval(max_db('user_categorys','cid',['uid'=>$USER_DB['ID']])) +1;
|
||||
insert_db("user_config", ["uid"=>$USER_DB['ID'],"k"=>"category_id","v"=>$category_id,"t"=>"max_id","d"=>'分类ID']);
|
||||
insert_db("user_config", ["uid"=>$USER_DB['ID'],"k"=>"pwd_group_id","v"=>1,"t"=>"max_id","d"=>'加密组ID']);
|
||||
|
||||
|
||||
//账号保留
|
||||
function username_retain_verify($username){
|
||||
$list = get_db("global_config", "v", ["k" => "username_retain"]);
|
||||
if(empty($list)){
|
||||
return false;
|
||||
}
|
||||
$patterns = explode("\n", $list);
|
||||
foreach($patterns as $pattern){
|
||||
if (preg_match($pattern, $username)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//返回注册成功
|
||||
msg(1,'注册成功');
|
||||
|
||||
|
||||
msg(-1,'免费版不支持此功能<br /> <a href="https://gitee.com/tznb/TwoNav/wikis/pages?sort_id=7968669&doc_id=3767990" target="_blank" style="color: #1e9fff;">点击此处前往购买页面</a>');
|
||||
|
||||
@@ -1084,7 +1084,7 @@ function read_theme(){
|
||||
|
||||
//没有缓存 或 禁止缓存 或 缓存过时
|
||||
if(empty($template) || $_GET['cache'] === 'no' || time() - $data["time"] > 1800 ){
|
||||
$urls = ["gitee" => "http://tznb.gitee.io/twonav_resource/{$request_dir}_template.json"];
|
||||
$urls = ["gitee" => "http://gitee.com/tznb/TwoNav_Resource/raw/master/{$request_dir}_template.json"];
|
||||
$Source = $global_config['Update_Source'] ?? '';
|
||||
if (!empty($Source) && isset($urls[$Source])) {
|
||||
$urls = [$Source => $urls[$Source]];
|
||||
|
||||
@@ -522,7 +522,7 @@ function other_services(){
|
||||
if(is_subscribe('bool')){
|
||||
$Res = ccurl('http://service.twonav.cn/service.php',$overtime,true,data_encryption('get_new_ver',['ver'=>SysVer]));
|
||||
}else{
|
||||
$Res = ccurl('http://tznb.gitee.io/twonav_resource/Notice.json',$overtime);
|
||||
$Res = ccurl('http://gitee.com/tznb/TwoNav_Resource/raw/master/Notice.json',$overtime);
|
||||
}
|
||||
$new_data = json_decode($Res['content'], true);
|
||||
if($new_data["code"] == 200 ){
|
||||
|
||||
@@ -1 +1 @@
|
||||
v2.1.14-20240419
|
||||
v2.1.15-20240513
|
||||
Reference in New Issue
Block a user