begin of thinksaas 3.68

Signed-off-by: kevin <kevin@lmve.net>
This commit is contained in:
2023-06-22 13:33:25 +08:00
commit 963ec1b2ea
2746 changed files with 331806 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
<?php
defined('IN_TS') or die('Access Denied.');
//管理入口
if(is_file('app/'.$app.'/action/admin/'.$mg.'.php')){
include_once 'app/'.$app.'/action/admin/'.$mg.'.php';
}else{
tsNotice('sorry:no index!');
}
+73
View File
@@ -0,0 +1,73 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
//用户组列表
case "list":
$arrGroup = $new['user']->findAll('user_group',null,'ugid asc');
include template('admin/group_list');
break;
//创建用户组
case "add":
$ugname = tsTrim($_POST['ugname']);
$uginfo = tsTrim($_POST['uginfo']);
if($ugname && $uginfo){
$new['user']->create('user_group',array(
'ugname'=>$ugname,
'uginfo'=>$uginfo,
));
}
header('Location: '.SITE_URL.'index.php?app=user&ac=admin&mg=group&ts=list');
break;
case "edit":
$ugid = tsIntval($_POST['ugid']);
$ugname = tsTrim($_POST['ugname']);
$uginfo = tsTrim($_POST['uginfo']);
if(in_array($ugid,array(1,2,3,4))) qiMsg('非法操作!');
$new['user']->update('user_group',array(
'ugid'=>$ugid,
),array(
'ugname'=>$ugname,
'uginfo'=>$uginfo,
));
header('Location: '.SITE_URL.'index.php?app=user&ac=admin&mg=group&ts=list');
break;
//删除用户组
case "delete":
$ugid = tsIntval($_GET['ugid']);
if(in_array($ugid,array(1,2,3,4))){
qiMsg('非法操作!');
}
$new['user']->delete('user_group',array(
'ugid'=>$ugid,
));
#降为普通用户
$new['user']->update('user_info',array(
'ugid'=>$ugid,
),array(
'ugid'=>3,
));
header('Location: '.SITE_URL.'index.php?app=user&ac=admin&mg=group&ts=list');
break;
}
+35
View File
@@ -0,0 +1,35 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
case "list":
$page = tsIntval($_GET['page'],1);
$url = SITE_URL.'index.php?app=user&ac=admin&mg=guestbook&ts=list&page=';
$lstart = $page*20-20;
$arrGuestbook = $new['user']->findAll('user_gb',null,'addtime desc',null,$lstart.',20');
$guestNum = $new['user']->findCount('user_gb');
$pageUrl = pagination($guestNum, 20, $page, $url);
include template('admin/guestbook_list');
break;
case "delete":
$guestid = tsIntval($_GET['guestid']);
$page = tsIntval($_GET['page']);
$new['user']->delete('user_gb',array(
'id'=>$guestid,
));
header('Location: '.SITE_URL.'index.php?app=user&ac=admin&mg=guestbook&ts=list&page='.$page);
break;
}
+28
View File
@@ -0,0 +1,28 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
//基本配置
case "":
$strOption = getAppOptions('user');
include template("admin/options");
break;
case "do":
$arrOption = $_POST['option'];
#更新app配置选项
upAppOptions('user',$arrOption);
#更新app导航和我的导航
upAppNav('user',$arrOption['appname']);
qiMsg('修改成功!');
break;
}
+39
View File
@@ -0,0 +1,39 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
case "":
$ugid = tsIntval($_GET['ugid'],1);
$arrUg = $new['user']->findAll('user_group',null,'ugid asc');
include template('admin/permissions');
break;
case "do":
/**
* 权限参数说明,app,action必须,其他参数可选
* app-action-ts
* app-action-mg-ts 当action=admin
* app-action-api-ts 当action=api
*/
$ugid = tsIntval($_POST['ugid']);
$arrOption = $_POST['option'];
aac('pubs')->upAppPermissions($ugid,'user',$arrOption);
qiMsg('操作成功!');
break;
}
+49
View File
@@ -0,0 +1,49 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
//角色列表
case "list":
$arrRole = $new['user']->findAll('user_role');
include template('admin/role_list');
break;
//角色修改
case "do":
$arrRoleName = $_POST['rolename'];
$arrScoreStart = $_POST['score_start'];
$arrScoreEnd = $_POST['score_end'];
//先清空
$db->query("TRUNCATE TABLE `".dbprefix."user_role`");
//后添加
foreach($arrRoleName as $key=>$item){
$rolename = tsTrim($item);
$score_start = tsTrim($arrScoreStart[$key]);
$score_end = tsTrim($arrScoreEnd[$key]);
if($rolename){
$new['user']->create('user_role',array(
'rolename'=>$rolename,
'score_start'=>$score_start,
'score_end'=>$score_end,
));
}
}
//再生成缓存文件
$arrRole = $new['user']->findAll('user_role',null,null,'rolename,score_start,score_end');
fileWrite('user_role.php','data',$arrRole);
$tsMySqlCache->set('user_role',$arrRole);
qiMsg("修改成功!");
break;
}
+123
View File
@@ -0,0 +1,123 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
case "list":
$arrScore = $new['user']->findAll('user_score');
include template('admin/score_list');
break;
case "adddo":
$scorekey = tsTrim($_POST['scorekey']);
$scorename = tsTrim($_POST['scorename']);
$score = tsIntval($_POST['score']);
$app = tsTrim($_POST['app']);
$action = tsTrim($_POST['action']);
$mg = tsTrim($_POST['mg']);
$api = tsTrim($_POST['api']);
$ts = tsTrim($_POST['ts']);
$status = tsIntval($_POST['status']);
$new['user']->create('user_score',array(
'scorekey'=>$scorekey,
'scorename'=>$scorename,
'score'=>$score,
'app'=>$app,
'action'=>$action,
'mg'=>$mg,
'api'=>$api,
'ts'=>$ts,
'status'=>$status,
));
header('Location: '.SITE_URL.'index.php?app=user&ac=admin&mg=score&ts=list');
break;
case "editdo":
$scoreid = tsIntval($_POST['scoreid']);
$score = tsIntval($_POST['score']);
$app = tsTrim($_POST['app']);
$action = tsTrim($_POST['action']);
$mg = tsTrim($_POST['mg']);
$api = tsTrim($_POST['api']);
$ts = tsTrim($_POST['ts']);
$status = tsIntval($_POST['status']);
$new['user']->update('user_score',array(
'scoreid'=>$scoreid,
),array(
'score'=>$score,
'app'=>$app,
'action'=>$action,
'mg'=>$mg,
'api'=>$api,
'ts'=>$ts,
'status'=>$status,
));
header('Location: '.SITE_URL.'index.php?app=user&ac=admin&mg=score&ts=list');
break;
//加积分
case "send":
include template('admin/score_send');
break;
case "senddo":
$userid = tsIntval($_POST['userid']);
$score = tsIntval($_POST['score']);
$status = tsIntval($_POST['status']);
$scorename = tsTrim($_POST['scorename']);
if($userid && $score && $scorename){
$return = false;
if($status==1){
//减积分
$return = $new['user']->delScore($userid,$scorename,$score);
$jiajian = '减去';
}else{
//加积分
$return = $new['user']->addScore($userid,$scorename,$score,1);
$jiajian = '增加';
}
if($return==true){
//发送系统消息
$msg_userid = '0';
$msg_touserid = $userid;
$msg_content = $scorename.$jiajian.$score.'积分';
aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content);
}
qiMsg('操作成功!');
}else{
qiMsg('操作失败!');
}
break;
case "delete":
$scoreid = tsIntval($_GET['scoreid']);
$new['user']->delete('user_score',array(
'scoreid'=>$scoreid,
));
qiMsg('删除成功!');
break;
}
+403
View File
@@ -0,0 +1,403 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
//用户列表
case "list":
$page = tsIntval($_GET['page'],1);
$userid = tsIntval($_GET['userid']);
$username = tsFilter($_GET['username']);
$arrData = null;
if($userid > 0 && $username==''){
$arrData = array('userid'=>$userid);
}elseif($userid==0 && $username != ''){
$arrData = array('username'=>$username);
}elseif($userid>0 && $username != ''){
$arrData = array('userid'=>$userid,'username'=>$username);
}
$lstart = $page*20-20;
$url = SITE_URL.'index.php?app=user&ac=admin&mg=user&ts=list&userid='.$userid.'&username='.$username.'&page=';
$arrAllUser = $new['user']->findAll('user_info',$arrData,'userid desc',null,$lstart.',20');
$userNum = $new['user']->findCount('user_info');
$pageUrl = pagination($userNum, 20, $page, $url);
#用户组
$arrUg = $new['user']->findAll('user_group',"`ugid`!=4",'ugid asc');
foreach($arrUg as $key=>$item){
$arrUg1[$item['ugid']] = $item['ugname'];
}
include template("admin/user_list");
break;
//用户编辑
case "edit":
$userid = $_GET['userid'];
$strUser = $new['user']->getOneUser($userid);
include template("admin/user_edit");
break;
//用户查看
case "view":
$userid = $_GET['userid'];
$strUser = $new['user']->getOneUser($userid);
include template("admin/user_view");
break;
//用户停用启用
case "isenable":
$userid = tsIntval($_GET['userid']);
if($userid==1) qiMsg('无法停用该用户!');
$page = tsIntval($_GET['page']);
$strUser = $new['user']->find('user_info',array(
'userid'=>$userid,
));
if($strUser['isadmin']==1) qiMsg('管理员不能停用!');
//禁用
if($strUser['isenable']==0){
$new['user']->update('user_info',array(
'userid'=>$userid,
),array(
'isenable'=>1,
));
//封用户Id
$isuser = $new['user']->findCount('anti_user',array(
'userid'=>$userid,
));
if($isuser==0){
$new['user']->create('anti_user',array(
'userid'=>$userid,
'addtime'=>date('Y-m-d H:i:s'),
));
}
//封IP
$isip = $new['user']->findCount('anti_ip',array(
'ip'=>$strUser['ip']
));
if($isip==0 && $strUser['ip']){
$new['user']->create('anti_ip',array(
'ip'=>$strUser['ip'],
'addtime'=>date('Y-m-d H:i:s'),
));
}
}
//启用
if($strUser['isenable']==1){
$new['user']->update('user_info',array(
'userid'=>$userid,
),array(
'isenable'=>0,
));
$new['user']->delete('anti_user',array(
'userid'=>$userid,
));
$new['user']->delete('anti_ip',array(
'ip'=>$strUser['ip'],
));
}
#qiMsg('操作成功!');
header('Location: '.SITE_URL.'index.php?app=user&ac=admin&mg=user&ts=list&page='.$page);
break;
//修改密码
case "pwd":
$userid = tsIntval($_GET['userid']);
$strUser = $new['user']->find('user',array(
'userid'=>$userid,
));
include template('admin/user_pwd');
break;
//执行修改密码
case "pwddo":
$userid = tsIntval($_POST['userid']);
$pwd = tsTrim($_POST['pwd']);
if($pwd == '') qiMsg('密码不能为空!');
$strUser = $new['user']->find('user',array(
'userid'=>$userid,
));
$salt = md5(rand());
$new['user']->update('user',array(
'userid'=>$userid,
),array(
'pwd'=>md5($salt.$pwd),
'salt'=>$salt,
));
qiMsg('密码修改成功:'.$pwd);
break;
//清空用户数据
case "deldata":
$userid = tsIntval($_GET['userid']);
if($userid==1) qiMsg('该用户数据无法清空!');
aac('user')->toEmpty($userid);
qiMsg('清空数据成功!');
break;
//管理员
case "admin":
$userid = tsIntval($_GET['userid']);
if($userid==1) qiMsg('该用户无法取消管理员!');
$strUser = $new['user']->find('user_info',array(
'userid'=>$userid,
));
if($strUser['isadmin']==1){
$new['user']->update('user_info',array(
'userid'=>$userid,
),array(
'isadmin'=>'0',
'isverify'=>'0',
'isverifyphone'=>'0',
'isrenzheng'=>'0',
));
}elseif($strUser['isadmin']==0){
$new['user']->update('user_info',array(
'userid'=>$userid,
),array(
'isadmin'=>'1',//系统管理员
'isverify'=>'1',//Email验证
'isverifyphone'=>'1',//手机号验证
'isrenzheng'=>'1',//人工认证
));
}
qiMsg('操作成功!');
break;
//清空全部被禁用的用户数据并保存垃圾Email
case "clean":
$arrUser = $new['user']->findAll('user_info',array(
'isenable'=>1,
));
foreach($arrUser as $key=>$item){
//执行删除用户数据
aac('user')->toEmpty($item['userid']);
}
qiMsg('垃圾用户清空完毕!');
break;
case "face":
$userid = tsIntval($_GET['userid']);
$new['user']->update('user_info',array(
'userid'=>$userid,
),array(
'path'=>'',
'face'=>'',
));
qiMsg('操作成功!');
break;
//是否手工认证
case "isrenzheng":
$userid = tsIntval($_GET['userid']);
if($userid==1) qiMsg('该用户无法操作!');
$strUser = $new['user']->find('user_info',array(
'userid'=>$userid,
));
//开通认证
if($strUser['isrenzheng']==0){
$new['user']->update('user_info',array(
'userid'=>$userid,
),array(
'isrenzheng'=>1,
));
//发系统消息
$msg_userid = '0';
$msg_touserid = $userid;
$msg_content = '恭喜你,系统已经通过你的个人信息认证!';
aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content);
}
//取消认证
if($strUser['isrenzheng']==1){
$new['user']->update('user_info',array(
'userid'=>$userid,
),array(
'isrenzheng'=>0,
));
//发系统消息
$msg_userid = '0';
$msg_touserid = $userid;
$msg_content = '很抱歉,系统取消了你的个人信息认证!';
aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content);
}
qiMsg('操作成功!');
break;
case "isverify":
$userid = tsIntval($_GET['userid']);
$strUser = $new['user']->find('user_info',array(
'userid'=>$userid,
));
if($strUser['isverify']==0){
$isverify = 1;
}else{
$isverify = 0;
}
$new['user']->update('user_info',array(
'userid'=>$userid,
),array(
'isverify'=>$isverify,
));
qiMsg('操作成功!');
break;
case "isverifyphone":
$userid = tsIntval($_GET['userid']);
$strUser = $new['user']->find('user_info',array(
'userid'=>$userid,
));
if($strUser['isverifyphone']==0){
$isverifyphone = 1;
}else{
$isverifyphone = 0;
}
$new['user']->update('user_info',array(
'userid'=>$userid,
),array(
'isverifyphone'=>$isverifyphone,
));
qiMsg('操作成功!');
break;
case "ugid":
$userid = tsIntval($_POST['userid']);
$ugid = tsIntval($_POST['ugid']);
if($userid==1) $ugid=1;
if($ugid==4) qiMsg('非法操作!');
$new['user']->update('user_info',array(
'userid'=>$userid,
),array(
'ugid'=>$ugid,
));
break;
case "add":
include template('admin/user_add');
break;
case "adddo":
$email = tsTrim($_POST['email']);
$username = tsTrim($_POST['username']);
$pwd = tsTrim($_POST['pwd']);
if($email=='' || $username=='' || $pwd==''){
qiMsg('信息输入不完整');
}
#判断Email是否存在
$isEmail = $new['user']->findCount('user',array(
'email'=>$email,
));
if($isEmail > 0){
qiMsg('账号已经注册');
}
if(count_string_len($username) < 4 || count_string_len($username) > 20){
qiMsg('姓名长度必须在4和20之间');
}
#判断用户名是否存在
$isUserName = $new['user']->findCount('user_info',array(
'username'=>$username,
));
if($isUserName > 0){
qiMsg('用户名已经存在,请换个用户名!');
}
$new['user']->register($email,$username,$pwd,$fuserid,$invitecode,1);
header('Location: '.SITE_URL.'index.php?app=user&ac=admin&mg=user&ts=list');
break;
}
+20
View File
@@ -0,0 +1,20 @@
<?php
defined('IN_TS') or die('Access Denied.');
$userid = tsIntval($TS_USER['userid']);
if($userid){
//过滤用户
$tsSystemAntiUser = aac('system')->antiUser();
if($tsSystemAntiUser){
if(in_array($userid,$tsSystemAntiUser)){
aac('user')->logout();
}
}
echo 1;
}else{
echo 0;
}
+9
View File
@@ -0,0 +1,9 @@
<?php
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
// api入口
if (is_file ( 'app/' . $TS_URL['app'] . '/action/api/' . $TS_URL['api'] . '.php' )) {
include_once 'app/' . $TS_URL['app'] . '/action/api/' . $TS_URL['api'] . '.php';
} else {
qiMsg ( 'sorry:no api!' );
}
+21
View File
@@ -0,0 +1,21 @@
<?php
defined('IN_TS') or die('Access Denied.');
echo '<pre>
-----------------------------------------------
User Http Api List
URL:https://demo.thinksaas.cn
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
-----------------------------------------------
</pre>';
+29
View File
@@ -0,0 +1,29 @@
<?php
defined('IN_TS') or die('Access Denied.');
include 'userinfo.php';
$page = tsIntval($_GET['page'],1);
$url = tsUrl ( 'user', 'article', array ('id'=>$strUser['userid'],'page' => '' ) );
$lstart = $page * 20 - 20;
$arrArticle = $new ['user']->findAll ( 'article', array (
'userid' => $strUser['userid'],
), 'addtime desc','articleid,userid,cateid,title,gaiyao,score,path,photo,count_comment,count_love,count_view,addtime', $lstart . ',20' );
foreach($arrArticle as $key=>$item){
$arrArticle [$key]['title'] = tsTitle($item['title']);
$arrArticle [$key]['gaiyao'] = tsTitle($item['gaiyao']);
$arrArticle [$key] ['cate'] = $new ['user']->find( 'article_cate', array (
'cateid' => $item ['cateid']
) );
}
$articleNum = $new ['user']->findCount ( 'article', array (
'userid' => $strUser['userid'],
) );
$pageUrl = pagination ( $articleNum, 20, $page, $url );
$title = $strUser['username'].'的文章';
include template('article');
+24
View File
@@ -0,0 +1,24 @@
<?php
defined('IN_TS') or die('Access Denied.');
include 'userinfo.php';
$page = isset($_GET['page']) ? intval($_GET['page']) : '1';
$url = tsUrl('user','collect',array('id'=>$strUser['userid'],'page'=>''));
$lstart = $page*30-30;
$arrTopicLists = $new['user']->findAll('group_topic_collect',array(
'userid'=>$strUser['userid'],
),'addtime desc',null,$lstart.',30');
foreach($arrTopicLists as $key=>$item){
$arrTopicList[] = aac('group')->getOneTopic($item['topicid']);
}
$topicNum = $new['user']->findCount('group_topic_collect',array(
'userid'=>$strUser['userid'],
));
$pageUrl = pagination($topicNum, 30, $page, $url);
$title = $strUser['username'].'的喜欢';
include template('collect');
+33
View File
@@ -0,0 +1,33 @@
<?php
defined('IN_TS') or die('Access Denied.');
include 'userinfo.php';
$page = isset($_GET['page']) ? intval($_GET['page']) : '1';
$url = tsUrl('user','comment',array('id'=>$strUser['userid'],'page'=>''));
$lstart = $page*20-20;
$arrComments = $new['user']->findAll('group_topic_comment',array(
'userid'=>$strUser['userid'],
),'addtime desc',null,$lstart.',20');
foreach($arrComments as $key=>$item){
$arrComment[] = $item;
$arrComment[$key]['topic']=aac('group')->getOneTopic($item['topicid']);
}
$commentNum = $new['user']->findCount('group_topic_comment',array(
'userid'=>$strUser['userid'],
));
$pageUrl = pagination($commentNum, 20, $page, $url);
$title = $strUser['username'].'的评论';
//SEO
$sitekey = '';
$sitedesc = '';
include template('comment');
+123
View File
@@ -0,0 +1,123 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
case "":
include 'userinfo.php';
$page = tsIntval($_GET['page'],1);
$url = tsUrl('user','follow',array('id'=>$strUser['userid'],'page'=>''));
$lstart = $page*80-80;
//关注的用户
$arrUsers = $new['user']->findAll('user_follow',array(
'userid'=>$strUser['userid'],
),'addtime desc',null,$lstart.',80');
$userNum = $new['user']->findCount('user_follow',array(
'userid'=>$strUser['userid'],
));
$pageUrl = pagination($userNum, 80, $page, $url);
if(is_array($arrUsers)){
foreach($arrUsers as $item){
$arrUser[] = $new['user']->getSimpleUser($item['touserid']);
}
}
$title = $strUser['username'].'关注的人';
include template("follow");
break;
//关注执行
case "do":
$userid = tsIntval($TS_USER['userid']);
$touserid = tsIntval($_POST['userid']);
if($userid == 0){
echo json_encode(array(
'status'=>0,
'msg'=>'你还没有登录!',
));
exit;
}
if($userid == $touserid){
echo json_encode(array(
'status'=>0,
'msg'=>'自己不能关注自己哦',
));
exit;
}
$isFollow = $new['user']->findCount('user_follow',array(
'userid'=>$userid,
'touserid'=>$touserid,
));
if($isFollow>0){
echo json_encode(array(
'status'=>1,
'msg'=>'你已经关注此用户!',
));
exit;
}
$new['user']->create('user_follow',array(
'userid'=>$userid,
'touserid'=>$touserid,
));
//统计用户关注数和粉丝数
$new['user']->countFollowFans($userid);
$new['user']->countFollowFans($touserid);
#发个消息
echo json_encode(array(
'status'=>2,
'msg'=>'关注成功!',
));
exit;
break;
//取消关注
case "un":
$userid = tsIntval($TS_USER['userid']);
$touserid = tsIntval($_POST['userid']);
if($userid == 0){
echo json_encode(array(
'status'=>0,
'msg'=>'你还没有登录!',
));
exit;
}
$new['user']->delete('user_follow',array(
'userid'=>$userid,
'touserid'=>$touserid,
));
//统计用户关注数和粉丝数
$new['user']->countFollowFans($userid);
$new['user']->countFollowFans($touserid);
echo json_encode(array(
'status'=>1,
'msg'=>'解除关注成功',
));
exit;
break;
}
+27
View File
@@ -0,0 +1,27 @@
<?php
defined('IN_TS') or die('Access Denied.');
include 'userinfo.php';
$page = tsIntval($_GET['page'],1);
$url = tsUrl('user','followed',array('id'=>$strUser['userid'],'page'=>''));
$lstart = $page*80-80;
//跟随他的用户
$arrUsers = $new['user']->findAll('user_follow',array(
'touserid'=>$strUser['userid'],
),'addtime desc',null,$lstart.',80');
$userNum = $new['user']->findCount('user_follow',array(
'touserid'=>$strUser['userid'],
));
$pageUrl = pagination($userNum, 80, $page, $url);
if(is_array($arrUsers)){
foreach($arrUsers as $item){
$arrUser[$key] = $new['user']->getSimpleUser($item['userid']);
}
}
$title = $strUser['username'].'的粉丝';
include template('followed');
+143
View File
@@ -0,0 +1,143 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
/**
* 通过Email找回密码
*/
case "":
if ($GLOBALS['TS_USER']){
header('Location: '.SITE_URL);
exit;
}
$title = '找回登陆密码';
include template("forgetpwd");
break;
/**
* 重置Email密码
*/
case "resetpwd":
$js = tsIntval($_GET['js']);
$email = tsTrim($_POST['email']);
$pwd = tsTrim($_POST['pwd']);
$authcode = strtolower($_POST['authcode']);
$emailcode = tsTrim($_POST['emailcode']);
if($email == '' || $pwd=='' || $authcode=='' || $emailcode==''){
getJson('所有输入项都不能为空',$js);
}
if(valid_email($email)==false){
getJson('Email邮箱输入不正确',$js);
}
$strUser = $new['user']->find('user',array(
'email'=>$email,
));
if($strUser==''){
getJson("Email邮箱不存在,你可能还没有注册^_^",$js);
}
if ($authcode != $_SESSION['verify']) {
getJson('图片验证码输入有误,请重新输入!', $js);
}
#验证手机验证码
if(aac('pubs')->verifyEmailCode($email,$emailcode)==false){
getJson('Email验证码输入有误',$js);
}
$salt = md5(rand());
$new['user']->update('user',array(
'userid'=>$strUser['userid'],
),array(
'pwd'=>md5($salt.$pwd),
'salt'=>$salt,
));
$new['user']->update('user_info',array(
'userid'=>$strUser['userid'],
),array(
'email'=>$strUser['email'],
'isverify'=>'1',
));
$_SESSION['tsuser']['isverify']=1;
getJson('密码修改成功!',$js,2,tsUrl('user','login'));
break;
/**
* 通过手机号找回密码
*/
case "phone":
$title = '找回登陆密码';
include template("forgetpwd_phone");
break;
//执行登录
case "do":
$js = tsIntval($_GET['js']);
$email = tsTrim($_POST['email']);
if(valid_email($email)==false){
getJson('Email输入不正确',$js);
}
$emailNum = $new['user']->findCount('user',array(
'email'=>$email,
));
if($email==''){
getJson('Email输入不能为空^_^',$js);
}elseif($emailNum == '0'){
getJson("Email不存在,你可能还没有注册^_^",$js);
}else{
//加密
$resetpwd = base_convert(sha1(uniqid(mt_rand(), true)), 16, 36);
$new['user']->update('user',array(
'email'=>$email,
),array(
'resetpwd'=>$resetpwd,
));
//发送邮件
$subject = $TS_SITE['site_title'].'会员密码找回';
$content = '您的登陆信息:<br />Email'.$email.'<br />重设密码链接:<br /><a href="'.$TS_SITE['site_url'].'index.php?app=user&ac=resetpwd&mail='.$email.'&set='.$resetpwd.'">'.$TS_SITE['site_url'].'index.php?app=user&ac=resetpwd&mail='.$email.'&set='.$resetpwd.'</a>';
$result = aac('mail')->postMail($email,$subject,$content);
if($result == '0'){
getJson('找回密码所需信息不完整^_^',$js);
}elseif($result == '1'){
getJson('系统已经向你的邮箱发送了邮件,请尽快查收^_^',$js);
}
}
break;
}
+17
View File
@@ -0,0 +1,17 @@
<?php
defined('IN_TS') or die('Access Denied.');
include 'userinfo.php';
$arrGroupsList = $new['user']->findAll('group_user',array(
'userid'=>$strUser['userid'],
),null,'groupid');
foreach($arrGroupsList as $key=>$item){
$arrGroupList[] = aac('group')->getOneGroup($item['groupid']);
}
$title = $strUser['username'].'的小组';
include template('group');
+130
View File
@@ -0,0 +1,130 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
case "":
include 'userinfo.php';
$page = tsIntval($_GET['page'],1);
$url = tsUrl('user','guestbook',array('id'=>$strUser['userid'],'page'=>''));
$lstart = $page*20-20;
$arrGuestList = $new['user']->findAll('user_gb',array(
'touserid'=>$strUser['userid'],
),'addtime desc',null,$lstart.',20');
foreach($arrGuestList as $key=>$item){
$arrGuestList[$key]['content'] = tsTitle($item['content']);
$arrGuestList[$key]['user']=$new['user']->getSimpleUser($item['userid']);
$arrGuestList[$key]['reply'] = $new['user']->find('user_gb',array(
'reid'=>$item['id'],
));
if($arrGuestList[$key]['reply']){
$arrGuestList[$key]['reply']['content'] = tsTitle($arrGuestList[$key]['reply']['content']);
}
}
$guestNum = $new['user']->findCount('user_gb',array(
'touserid'=>$strUser['userid'],
));
$pageUrl = pagination($guestNum, 20, $page, $url);
$title = $strUser['username'].'的留言板';
include template('guestbook');
break;
case "do":
$userid = $new['user']->isLogin();
$touserid = tsIntval($_POST['touserid']);
$content = tsTrim($_POST['content']);
if($content == ''){
tsNotice('留言内容不能为空!');
}
$content = antiWord($content);
$new['user']->create('user_gb',array(
'userid'=>$userid,
'touserid'=>$touserid,
'content'=>$content,
'addtime'=>date('Y-m-d H:i:s'),
));
//发送系统消息
$msg_userid = '0';
$msg_touserid = $touserid;
$msg_content = '有人在你的留言板上留言了哦,快去看看吧';
$msg_tourl = tsUrl('user','space',array('id'=>$touserid));
aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content,$msg_tourl);
#tsNotice('留言成功!');
header('Location: '.tsUrl('user','guestbook',array('id'=>$touserid)));
exit;
break;
case "redo":
$userid = $new['user']->isLogin();
$touserid = tsIntval($_POST['touserid']);
$reid = tsIntval($_POST['reid']);
$content = tsTrim($_POST['content']);
$arrContent = explode('#',$content);
$content = $arrContent['1'];
if($content==''){
tsNotice('留言不能为空!');
}
$content = antiWord($content);
$new['user']->create('user_gb',array(
'userid'=>$userid,
'reid'=>$reid,
'touserid'=>$touserid,
'content'=>$content,
'addtime'=>date('Y-m-d H:i:s'),
));
//发送系统消息
$msg_userid = '0';
$msg_touserid = $touserid;
$msg_content = '有人在你的留言板上留言了哦,快去看看吧!';
$msg_tourl = tsUrl('user','guestbook',array('id'=>$touserid));
aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content,$msg_tourl);
tsNotice('回复成功!');
break;
//删除留言
case "delete":
$userid = $new['user']->isLogin();
$gbid = tsIntval($_GET['gbid']);
$strGuest = $new['user']->find('user_gb',array(
'id'=>$gbid,
));
if($strGuest['touserid'] == $userid){
$new['user']->delete('user_gb',array(
'id'=>$gbid,
));
}
tsNotice('留言删除成功');
break;
}
+21
View File
@@ -0,0 +1,21 @@
<?php
defined('IN_TS') or die('Access Denied.');
//最多积分用户
$arrScoreUser = $new['user']->getScoreUser(10);
//关注最多的用户
$arrFollowUser = $new['user']->getFollowUser(10);
//活跃会员
$arrHotUser = $new['user']->getHotUser(10);
//最新会员
$arrNewUser = $new['user']->getNewUser(10);
$title = '用户';
$sitekey = $TS_APP['appkey'];
$sitedesc = $TS_APP['appdesc'];
include template('index');
+66
View File
@@ -0,0 +1,66 @@
<?php
defined('IN_TS') or die('Access Denied.');
//用户是否登录
$userid = aac('user')->isLogin();
$strUser = $new['user']->find('user_info',array(
'userid'=>$userid,
));
//邀请好友
switch($ts){
case "":
//计算是否还有邀请码
$codeNum = $new['user']->findCount('user_invites',array(
'userid'=>$userid,
'isused'=>0,
));
$arrCode = $new['user']->findAll('user_invites',array(
'userid'=>$userid,
'isused'=>0,
));
#邀请的用户
$arrInviteUser = $new['user']->findAll('user_info',array(
'fuserid'=>$userid,
),'addtime desc','userid,username');
$title = '邀请码';
include template("invite");
break;
//取邀请码
case "code":
//计算是否还有邀请码
$codeNum = $new['user']->findCount('user_invites',array(
'userid'=>$userid,
'isused'=>0,
));
if($codeNum == 0 && $TS_USER['isadmin']==1){
//当数据库中没码的时间生成10个码
for($i=1;$i<=10;$i++){
$new['user']->create('user_invites',array(
'userid'=>$userid,
'invitecode'=>random(18).$userid,
'addtime'=>time(),
));
}
}
header('Location: '.tsUrl('user','invite'));
break;
}
+134
View File
@@ -0,0 +1,134 @@
<?php
defined('IN_TS') or die('Access Denied.');
use EasyWeChat\Factory;
if(tsIntval($TS_USER['userid']) > 0) {
header('Location: '.SITE_URL);exit;
}
#微信公众号授权
if(isWeixin()==true && $TS_SITE['is_weixin']==1){
$config = [
'app_id' => $TS_SITE['weixin_appid'],
'oauth' => [
'scopes' => ['snsapi_userinfo'],
'callback' => SITE_URL.'index.php?app=user&ac=wxlogin',
],
];
$app = Factory::officialAccount($config);
$oauth = $app->oauth;
$oauth->redirect()->send();
exit();
}
//程序主体
switch($ts){
case "":
//记录上次访问地址
$jump = $_SERVER['HTTP_REFERER'];
$title = '登录';
include template("login");
break;
//执行登录
case "do":
//用于JS提交验证
$js = tsIntval($_GET['js']);
$ad = tsIntval($_POST['ad']);
/*禁止以下IP用户登陆或注册*/
/*
$arrIp = aac('system')->antiIp();
if(in_array(getIp(),$arrIp)){
getJson('你的IP已被锁定,暂无法登录!',$js);
}
*/
$jump = tsTrim($_POST['jump']);
$email = tsTrim($_POST['email']);
$pwd = tsTrim($_POST['pwd']);
$cktime = tsIntval($_POST['cktime']);
#人机验证
$vaptcha_token = tsTrim($_POST ['vaptcha_token']);
$vaptcha_server = tsTrim($_POST ['vaptcha_server']);
if ($TS_SITE['is_vaptcha'] && $ad==0) {
$strVt = vaptcha($vaptcha_token,0,$vaptcha_server);
if($strVt['success']==0) {
getJson('人机验证未通过!',$js);
}
}
if($email=='' || $pwd=='') getJson('账号和密码都不能为空!',$js);
#先判断是否是Email
if(valid_email($email)==true){
$strUser = $new['user']->find('user',array(
'email'=>$email,
));
//if($strUser == '') getJson('Email不存在,你可能还没有注册!',$js);
if($strUser == '') getJson('账号/密码输入有误!',$js);
}else{
#判断是否是手机号
if(isPhone($email)==true){
$strUser = $new['user']->find('user',array(
'phone'=>$email,
));
#if($strUser == '') getJson('手机号不存在,你可能还没有注册!',$js);
if($strUser == '') getJson('账号/密码输入有误!',$js);
}else{
#getJson('账号不存在,你可能还没有注册!',$js);
getJson('账号/密码输入有误!',$js);
}
}
if(md5($strUser['salt'].$pwd)!==$strUser['pwd']) {
#getJson('密码错误!',$js);
getJson('账号/密码输入有误!',$js);
}
$new['user']->login($strUser['userid']);
//对积分进行处理
aac('user')->doScore($TS_URL['app'], $TS_URL['ac'],$TS_URL['mg'],$TS_URL['api'], $TS_URL['ts'],0,1);
if($ad==1){
getJson('登录成功!',$js,2,SITE_URL.'index.php?app=system');
}
//跳转
if($jump != ''){
getJson('登录成功!',$js,2,$jump);
}else{
//登陆是否跳转到我的社区
if($TS_SITE['istomy']){
getJson('登录成功!',$js,2,tsUrl('my'));
}else{
getJson('登录成功!',$js,2,SITE_URL);
}
}
break;
}
+7
View File
@@ -0,0 +1,7 @@
<?php
defined('IN_TS') or die('Access Denied.');
aac('user')->logout();
//header('Location: '.tsUrl('user','login'));
header('Location: '.SITE_URL);
exit;
+89
View File
@@ -0,0 +1,89 @@
<?php
defined('IN_TS') or die('Access Denied.');
//用户是否登录
$userid = aac('user')->isLogin();
switch($ts){
//发送消息页面
case "add":
$touserid = tsIntval($_GET['touserid']);
if($userid == $touserid || !$touserid) {
tsNotice("Sorry!自己不能给自己发送消息的!& 对方为空!");
}
#互为粉丝的2个人才可以发送消息
$isFollow = $new['user']->findCount('user_follow',array(
'userid'=>$userid,
'touserid'=>$touserid,
));
$isFollow2 = $new['user']->findCount('user_follow',array(
'userid'=>$touserid,
'touserid'=>$userid,
));
if(($isFollow && $isFollow2) || $TS_USER['isadmin']==1){
$strUser = $new['user']->getSimpleUser($userid);
$strTouser = $new['user']->getSimpleUser($touserid);
if(!$strTouser) tsNotice("Sorry!对方不存在!");
$title = "发送短消息";
include template("message_add");
}else{
tsNotice("互相关注的2个人才可以互相发送私信!");
}
break;
case "do":
$js = tsIntval($_GET['js']);
$msg_userid = $userid;
$msg_touserid = tsIntval($_POST['touserid']);
if($msg_userid == $msg_touserid || !$msg_touserid) {
getJson("Sorry!自己不能给自己发送消息的!& 对方为空!",$js,0);
}
#互为粉丝的2个人才可以发送消息
$isFollow = $new['user']->findCount('user_follow',array(
'userid'=>$msg_userid,
'touserid'=>$msg_touserid,
));
$isFollow2 = $new['user']->findCount('user_follow',array(
'userid'=>$msg_touserid,
'touserid'=>$msg_userid,
));
if(($isFollow && $isFollow2) || $TS_USER['isadmin']==1){
$msg_content = tsTrim($_POST['content']);
if($msg_content==''){
getJson('消息内容不能为空!',$js,0);
}
$msg_content = antiWord($msg_content);
aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content);
getJson('消息发送成功',$js,1);
}else{
getJson("互相关注的2个人才可以互相发送私信!",$js,0);
}
break;
}
+10
View File
@@ -0,0 +1,10 @@
<?php
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
// 管理入口
if (is_file ( 'app/' . $TS_URL['app'] . '/action/my/' . $TS_URL['my'] . '.php' )) {
include_once 'app/' . $TS_URL['app'] . '/action/my/common.php';
include_once 'app/' . $TS_URL['app'] . '/action/my/' . $TS_URL['my'] . '.php';
} else {
qiMsg ( 'sorry:no index!' );
}
+6
View File
@@ -0,0 +1,6 @@
<?php
defined('IN_TS') or die('Access Denied.');
$userid = aac('user')->isLogin();
$strUser = aac('user')->getOneUser($userid);
+6
View File
@@ -0,0 +1,6 @@
<?php
defined ( 'IN_TS' ) or die ( 'Access Denied.' );
$title = '我的小组';
include template('my/index');
+462
View File
@@ -0,0 +1,462 @@
<?php
defined('IN_TS') or die('Access Denied.');
switch($ts){
//手机号注册
case "":
if(tsIntval($TS_USER['userid']) > 0) {
header('Location: '.SITE_URL);exit;
}
#如果网站只采用Email注册,就跳转到Email注册
if($TS_SITE['regtype']==0){
header('Location: '.tsUrl('user','register'));exit;
}
//邀请用户ID
$fuserid = tsIntval($_GET['fuserid']);
$title = '手机号注册';
include template("phone");
break;
case "do":
//用于JS提交验证
$js = tsIntval($_GET['js']);
$phone = tsTrim($_POST['email']);
$pwd = tsTrim($_POST['pwd']);
$repwd = tsTrim($_POST['repwd']);
$username = t($_POST['username']);
$fuserid = tsIntval($_POST['fuserid']);
$authcode = strtolower($_POST['authcode']);
$phonecode = tsTrim($_POST['phonecode']);
/*禁止以下IP用户登陆或注册*/
$arrIp = aac('system')->antiIp();
if(in_array(getIp(),$arrIp)){
getJson('你的IP已被锁定,暂无法登录!',$js);
}
//是否开启邀请注册
if($TS_SITE['isinvite']=='1'){
$invitecode = tsTrim($_POST['invitecode']);
if($invitecode == '') getJson('邀请码不能为空!',$js);
$codeNum = $new['user']->findCount('user_invites',array(
'invitecode'=>$invitecode,
'isused'=>0,
));
if($codeNum == 0) getJson('邀请码已经被使用,请更换其他邀请码!',$js);
}
if($phone=='' || $pwd=='' || $repwd=='' || $username=='' || $phonecode==''){
getJson('所有必选项都不能为空!',$js);
}
if(isPhone($phone)==false) getJson('手机号输入有误!',$js);
#验证手机验证码
if(aac('pubs')->verifyPhoneCode($phone,$phonecode)==false){
getJson('手机验证码输入有误',$js);
}
#手机号是否存在
$isPhone = $new['user']->findCount('user',array(
'phone'=>$phone,
));
if($isPhone > 0){
getJson('手机号已经存在',$js);
}
if($pwd != $repwd){
getJson('两次输入密码不正确!',$js);
}
if(count_string_len($username) < 4 || count_string_len($username) > 20){
getJson('姓名长度必须在4和20之间',$js);
}
#用户名是否存在
$isUserName = $new['user']->findCount('user_info',array(
'username'=>$username,
),'userid');
if($isUserName > 0){
getJson('用户名已经存在,请换个用户名!',$js);
}
#验证码
if ($authcode != $_SESSION['verify']) {
getJson('验证码输入有误,请重新输入!', $js);
}
$salt = md5(rand());
$userid = $new['user']->create('user',array(
'pwd'=>md5($salt.$pwd),
'salt'=>$salt,
'email'=>$phone,
'phone'=>$phone,
));
//插入用户信息
$new['user']->create('user_info',array(
'userid' => $userid,
'fuserid' => $fuserid,
'username' => $username,
'email' => $phone,
'phone' => $phone,
'ip' => getIp(),
'comefrom'=>'9',
'isverifyphone'=>1,
'addtime' => time(),
'uptime' => time(),
));
//默认加入小组
$isGroup = $new['user']->find('user_options',array(
'optionname'=>'isgroup',
));
if($isGroup['optionvalue']){
$arrGroup = explode(',',$isGroup['optionvalue']);
if($arrGroup){
foreach($arrGroup as $key=>$item){
$groupUserNum = $new['user']->findCount('group_user',array(
'userid'=>$userid,
'groupid'=>$item,
));
if($groupUserNum == 0){
$new['user']->create('group_user',array(
'userid'=>$userid,
'groupid'=>$item,
'addtime'=>time(),
));
//统计更新
$count_user = $new['user']->findCount('group_user',array(
'groupid'=>$item,
));
$new['user']->update('group',array(
'groupid'=>$item,
),array(
'count_user'=>$count_user,
));
}
}
}
}
//用户信息
$userData = $new['user']->find('user_info',array(
'userid'=>$userid,
),'userid,username,email,path,face,isadmin,signin,isverify,isverifyphone,uptime');
//用户session信息
$_SESSION['tsuser'] = $userData;
//发送消息
aac('message')->sendmsg(0,$userid,'亲爱的 '.$username.' :您成功加入了 '.$TS_SITE['site_title'].'。在遵守本站的规定的同时,享受您的愉快之旅吧!');
//注销邀请码并将关注邀请用户
if($TS_SITE['isinvite']=='1'){
//邀请码信息
$strInviteCode = $new['user']->find('user_invites',array(
'invitecode'=>$invitecode,
));
$new['user']->create('user_follow',array(
'userid'=>$userid,
'touserid'=>$strInviteCode['userid'],
));
//注销
$new['user']->update('user_invites',array(
'invitecode'=>$invitecode,
),array(
'isused'=>'1',
));
}
//对积分进行处理
aac('user')->doScore($TS_URL['app'], $TS_URL['ac'],$TS_URL['mg'],$TS_URL['api'], $TS_URL['ts']);
//跳转
getJson('登录成功!',$js,2,SITE_URL);
break;
//验证手机号
case "verify":
$userid = aac('user')->isLogin();
$strUser = $new['user']->getOneUser($userid);
$title = '验证手机号';
include template("phone_verify");
break;
case "verifydo":
$js = tsIntval($_GET['js']);
$userid = aac('user')->isLogin();
$phone = tsTrim($_POST['phone']);
$authcode = strtolower($_POST['authcode']);
$phonecode = tsTrim($_POST['phonecode']);
if($phone == '' || $authcode=='' || $phonecode==''){
getJson('所有输入项都不能为空',$js);
}
if(isPhone($phone)==false){
getJson('手机号输入有误!',$js);
}
if ($authcode != $_SESSION['verify']) {
getJson('图片验证码输入有误,请重新输入!', $js);
}
#验证手机验证码
if(aac('pubs')->verifyPhoneCode($phone,$phonecode)==false){
getJson('手机验证码输入有误',$js);
}
$strUserInfo = $new['user']->find('user_info',array(
'userid'=>$userid,
),'phone');
if($strUserInfo['phone']!=$phone){
#判断手机号是否存在
$isPhone = $new['user']->findCount('user',array(
'phone'=>$phone,
));
if($isPhone){
getJson('手机号已存在!请更换其他手机号!',$js);
}
//getJson('手机号有误!',$js);
}
#更新手机号
$new['user']->update('user',array(
'userid'=>$userid,
),array(
'phone'=>$phone,
));
#更新手机号和手机验证状态
$new['user']->update('user_info',array(
'userid'=>$userid,
),array(
'phone'=>$phone,
'isverifyphone'=>'1',
));
$_SESSION['tsuser']['isverifyphone']=1;
getJson('手机号验证成功!',$js,2,SITE_URL);
break;
//如果手机号不对,可以修改手机号
case "setphone":
$userid = aac('user')->isLogin();
$phone = tsTrim($_POST['phone']);
if($phone==''){
tsNotice('手机号不能为空!');
}
if(isPhone($phone)==false){
tsNotice('手机号输入有误!');
}
$isPhone = $new['user']->findCount('user',array(
'phone'=>$phone,
));
if($isPhone>0){
tsNotice('手机号已经存在,请更换其他手机号!');
}
$new['user']->update('user',array(
'userid'=>$userid,
),array(
'phone'=>$phone,
));
$new['user']->update('user_info',array(
'userid'=>$userid,
),array(
'phone'=>$phone,
));
tsNotice('手机号修改成功!');
break;
//修改成新手机号
case "editphone":
$js = tsIntval($_GET['js']);
$userid = aac('user')->isLogin();
$phone = tsTrim($_POST['phone']);
$authcode = strtolower($_POST['authcode']);
$phonecode = tsTrim($_POST['phonecode']);
if($phone == '' || $authcode=='' || $phonecode==''){
getJson('所有输入项都不能为空',$js);
}
if(isPhone($phone)==false){
getJson('手机号输入有误!',$js);
}
if ($authcode != $_SESSION['verify']) {
getJson('图片验证码输入有误,请重新输入!', $js);
}
#验证手机验证码
if(aac('pubs')->verifyPhoneCode($phone,$phonecode)==false){
getJson('手机验证码输入有误',$js);
}
$isPhone = $new['user']->findCount('user',array(
'phone'=>$phone,
));
if($isPhone>0){
getJson('手机号已经存在,请更换其他手机号!',$js);
}
$new['user']->update('user',array(
'userid'=>$userid,
),array(
'phone'=>$phone,
));
$new['user']->update('user_info',array(
'userid'=>$userid,
),array(
'phone'=>$phone,
'isverifyphone'=>'1',
));
$_SESSION['tsuser']['isverifyphone']=1;
getJson('手机号修改成功!',$js,2,tsUrl('my','setting',array('ts'=>'email')));
break;
/**
* 通过手机号重置密码
*/
case "resetpwd":
$js = tsIntval($_GET['js']);
$phone = tsTrim($_POST['phone']);
$pwd = tsTrim($_POST['pwd']);
$authcode = strtolower($_POST['authcode']);
$phonecode = tsTrim($_POST['phonecode']);
if($phone == '' || $pwd=='' || $authcode=='' || $phonecode==''){
getJson('所有输入项都不能为空',$js);
}
if(isPhone($phone)==false){
getJson('手机号输入不正确',$js);
}
$strUser = $new['user']->find('user',array(
'phone'=>$phone,
));
if($strUser==''){
getJson("手机号不存在,你可能还没有注册^_^",$js);
}
if ($authcode != $_SESSION['verify']) {
getJson('图片验证码输入有误,请重新输入!', $js);
}
#验证手机验证码
if(aac('pubs')->verifyPhoneCode($phone,$phonecode)==false){
getJson('手机验证码输入有误',$js);
}
$salt = md5(rand());
$new['user']->update('user',array(
'userid'=>$strUser['userid'],
),array(
'pwd'=>md5($salt.$pwd),
'salt'=>$salt,
));
$new['user']->update('user_info',array(
'userid'=>$strUser['userid'],
),array(
'phone'=>$strUser['phone'],
'isverifyphone'=>'1',
));
$_SESSION['tsuser']['isverifyphone']=1;
getJson('密码修改成功!',$js,2,tsUrl('user','login'));
break;
}
+63
View File
@@ -0,0 +1,63 @@
<?php
defined('IN_TS') or die('Access Denied.');
if($TS_SITE['isplogin']!=1){
tsNotice('短信登录未开启!');
}
/**
* 手机验证码登录
*/
if(tsIntval($TS_USER['userid']) > 0) {
header('Location: '.SITE_URL);exit;
}
switch($ts){
case "":
$title = '手机验证码登录';
include template("plogin");
break;
case "do":
$js = tsIntval($_GET['js']);
$phone = tsTrim($_POST['email']);
$authcode = strtolower($_POST['authcode']);
$phonecode = tsTrim($_POST['phonecode']);
if($phone=='' || $phonecode==''){
getJson('所有输入项都不能为空!',$js);
}
if(isPhone($phone)==false) getJson('手机号输入有误!',$js);
#验证手机验证码
if(aac('pubs')->verifyPhoneCode($phone,$phonecode)==false){
getJson('手机验证码输入有误!',$js);
}
#手机号是否存在
$strUser = $new['user']->find('user',array(
'phone'=>$phone,
));
if($strUser){
$new['user']->login($strUser['userid'],$phone);
getJson('登录成功!',$js,2,SITE_URL);
}else{
$new['user']->register($phone);
}
//跳转
getJson('登录成功!',$js,2,SITE_URL);
break;
}
+13
View File
@@ -0,0 +1,13 @@
<?php
//插件条件入口
defined('IN_TS') or die('Access Denied.');
if(is_file('plugins/'.$app.'/'.$plugin.'/'.$in.'.php')){
require_once('plugins/'.$app.'/'.$plugin.'/'.$in.'.php');
}else{
tsNotice('sorry:no plugin!');
}
//形如这样
//index.php?app=group&ac=plugin&plugin=qq&in=do
+190
View File
@@ -0,0 +1,190 @@
<?php
defined('IN_TS') or die('Access Denied.');
use EasyWeChat\Factory;
if(tsIntval($TS_USER['userid']) > 0) {
header('Location: '.SITE_URL);exit;
}
if($TS_SITE['isinvite']==2){
tsNotice('暂不开放用户注册!');
}
#微信公众号授权
if(isWeixin()==true && $TS_SITE['is_weixin']==1){
$config = [
'app_id' => $TS_SITE['weixin_appid'],
'oauth' => [
'scopes' => ['snsapi_userinfo'],
'callback' => SITE_URL.'index.php?app=user&ac=wxlogin',
],
];
$app = Factory::officialAccount($config);
$oauth = $app->oauth;
$oauth->redirect()->send();
exit();
}
//用户注册
switch($ts){
case "":
#如果网站只采用手机号注册,就跳转到手机号注册
if($TS_SITE['regtype']==1){
header('Location: '.tsUrl('user','phone'));exit;
}
//邀请用户ID
$fuserid = tsIntval($_GET['fuserid']);
if($fuserid){
$strFuser = $new['user']->getSimpleUser($fuserid);
}
$title = '注册';
include template("register");
break;
case "do":
//用于JS提交验证
$js = tsIntval($_GET['js']);
$email = tsTrim($_POST['email']);
$pwd = tsTrim($_POST['pwd']);
$repwd = tsTrim($_POST['repwd']);
$username = t($_POST['username']);
$fuserid = tsIntval($_POST['fuserid']);
$authcode = strtolower(tsTrim($_POST['authcode']));
#人机验证
$vaptcha_token = tsTrim($_POST['vaptcha_token']);
$vaptcha_server = tsTrim($_POST['vaptcha_server']);
if ($TS_SITE['is_vaptcha']) {
$strVt = vaptcha($vaptcha_token,0,$vaptcha_server);
if($strVt['success']==0) {
getJson('人机验证未通过!',$js);
}
}
//检测垃圾Email后缀
$arrEmail = explode('@',$email);
$emails = array(
'chacuo.net',
'mail.ru',
'yandex.ru',
'yandex.com',
'027168.net',
'027168.com',
);
if(in_array($arrEmail[1],$emails)){
getJson('禁止该邮箱注册!',$js);
}
/*禁止以下IP用户登陆或注册*/
/*
$arrIp = aac('system')->antiIp();
if(in_array(getIp(),$arrIp)){
getJson('你的IP已被锁定,暂无法登录!',$js);
}
*/
//是否开启邀请注册
if($TS_SITE['isinvite']=='1'){
$invitecode = tsTrim($_POST['invitecode']);
if($invitecode == '') getJson('邀请码不能为空!',$js);
$codeNum = $new['user']->findCount('user_invites',array(
'invitecode'=>$invitecode,
'isused'=>0,
));
if($codeNum == 0) getJson('邀请码已经被使用/或者不存在,请更换其他邀请码!',$js);
}
if($email=='' || $pwd=='' || $repwd=='' || $username==''){
getJson('所有必选项都不能为空!',$js);
}
if(valid_email($email) == false){
getJson('Email邮箱输入有误',$js);
}
#Email过滤
$is_anti_email = $new['user']->find('anti_email',array(
'email'=>$email,
));
if($is_anti_email>0){
getJson('非法操作!',$js);
}
#验证Email验证码
if($TS_SITE['isverify']){
$emailcode = tsTrim($_POST['emailcode']);
if(aac('pubs')->verifyEmailCode($email,$emailcode)==false){
getJson('Email验证码输入有误',$js);
}
}
#判断Email是否存在
$isEmail = $new['user']->findCount('user',array(
'email'=>$email,
));
if($isEmail > 0){
getJson('Email已经注册',$js);
}
if($pwd != $repwd){
getJson('两次输入密码不正确!',$js);
}
if(count_string_len($username) < 4 || count_string_len($username) > 20){
getJson('姓名长度必须在4和20之间',$js);
}
#用户名敏感词
$username = antiWord ($username,1);
$username = str_replace('.','',$username);
#判断用户名是否存在
$isUserName = $new['user']->findCount('user_info',array(
'username'=>$username,
));
if($isUserName > 0){
getJson('用户名已经存在,请换个用户名!',$js);
}
if($TS_SITE['isauthcode']){
if ($authcode != $_SESSION['verify']) {
getJson('验证码输入有误,请重新输入!', $js);
}
}
$new['user']->register($email,$username,$pwd,$fuserid,$invitecode);
//对积分进行处理
aac('user')->doScore($TS_URL['app'], $TS_URL['ac'],$TS_URL['mg'],$TS_URL['api'], $TS_URL['ts']);
//跳转
getJson('登录成功!',$js,2,SITE_URL);
break;
}
+81
View File
@@ -0,0 +1,81 @@
<?php
defined('IN_TS') or die('Access Denied.');
//重设密码
switch($ts){
case "":
$email = tsTrim($_GET['mail']);
$resetpwd = tsUrlCheck($_GET['set']);
if(valid_email($email)==false){
tsNotice('非法操作');
}
$userNum = $new['user']->findCount('user',array(
'email'=>$email,
'resetpwd'=>$resetpwd,
));
if($email=='' || $resetpwd==''){
tsNotice("你应该去火星生活啦!");
}elseif($userNum == 0){
tsNotice("你应该去火星生活啦!");
}else{
$title = '重设密码';
include template("resetpwd");
}
break;
case "do":
$js = tsIntval($_GET['js']);
$email = tsTrim($_POST['email']);
$pwd = tsTrim($_POST['pwd']);
$repwd = tsTrim($_POST['repwd']);
$resetpwd = tsTrim($_POST['resetpwd']);
if($email=='' || $pwd=='' || $repwd=='' || $resetpwd==''){
getJson("所有输入项都不能为空!",$js);
}
if(valid_email($email)==false){
getJson('Email输入不正确',$js);
}
$userNum = $new['user']->findCount('user',array(
'email'=>$email,
'resetpwd'=>$resetpwd,
));
if($userNum == '0'){
getJson("你应该去火星生活啦!",$js);
}
$salt = md5(rand());
$new['user']->update('user',array(
'email'=>$email,
),array(
'pwd'=>md5($salt.$pwd),
'salt'=>$salt,
'resetpwd'=>'',
));
getJson("密码修改成功^_^",$js);
break;
}
+7
View File
@@ -0,0 +1,7 @@
<?php
defined('IN_TS') or die('Access Denied.');
$arrRole = $new['user']->findAll('user_role');
$title = '角色';
include template('role');
+39
View File
@@ -0,0 +1,39 @@
<?php
defined('IN_TS') or die('Access Denied.');
$userid = tsIntval($GLOBALS['TS_USER']['userid']);
switch($ts){
case "":
if($userid==0){
echo 2;exit;
}
if($new['user']->signin()){
echo 1;exit;
}else{
echo 0;exit;
}
break;
case "ajax":
$strSign = $new['user']->find('sign',array(
'userid'=>$userid,
'addtime'=>date('Y-m-d'),
));
$strScore = $new['user']->find('user_score',array(
'app'=>'user',
'action'=>'signin',
'mg'=>'',
'ts'=>'',
));
include template('signin_ajax');
break;
}
+30
View File
@@ -0,0 +1,30 @@
<?php
defined('IN_TS') or die('Access Denied.');
//用户空间
include 'userinfo.php';
//加入的小组
$arrGroupUser = $new['user']->findAll('group_user',array(
'userid'=>$userid,
));
if(is_array($arrGroupUser)){
foreach($arrGroupUser as $key=>$item){
$arrGroup[] = aac('group')->getOneGroup($item['groupid']);
}
}
//留言
$arrGuest = $new['user']->findAll('user_gb',array(
'touserid'=>$strUser['userid'],
),'addtime desc',null,10);
foreach($arrGuest as $key=>$item){
$arrGuest[$key]['content'] = tsDecode($item['content']);
$arrGuest[$key]['user']=$new['user']->getSimpleUser($item['userid']);
}
$title = $strUser['username'];
include template("space");
+5
View File
@@ -0,0 +1,5 @@
<?php
defined('IN_TS') or die('Access Denied.');
$title = '后台登录';
include template('system');
+20
View File
@@ -0,0 +1,20 @@
<?php
defined('IN_TS') or die('Access Denied.');
include 'userinfo.php';
$page = tsIntval($_GET['page'],1);
$url = tsUrl('user','topic',array('id'=>$strUser['userid'],'page'=>''));
$lstart = $page*30-30;
$arrTopic = $new['user']->findAll('topic',array(
'userid'=>$strUser['userid'],
),'addtime desc',null,$lstart.',30');
$topicNum = $new['user']->findCount('topic',array(
'userid'=>$strUser['userid'],
));
$pageUrl = pagination($topicNum, 30, $page, $url);
$title = $strUser['username'].'的帖子';
include template('topic');
+36
View File
@@ -0,0 +1,36 @@
<?php
defined('IN_TS') or die('Access Denied.');
$userid = tsIntval($_GET['id']);
if($new['user']->isUser($userid)==false){
header("HTTP/1.1 404 Not Found");
header("Status: 404 Not Found");
$title = '404';
include pubTemplate("404");
exit;
}
$strUser = $new['user']->getOneUser($userid);
//是否关注
if($TS_USER['userid'] != '' && $TS_USER['userid'] != $strUser['userid']){
$followNum = $db->once_num_rows("select * from ".dbprefix."user_follow where userid='".$TS_USER['userid']."' and touserid='$userid'");
if($followNum > '0'){
$strUser['isfollow'] = true;
}else{
$strUser['isfollow'] = false;
}
}else{
$strUser['isfollow'] = false;
}
//他关注的用户
$followUsers = $db->fetch_all_assoc("select touserid from ".dbprefix."user_follow where userid='$userid' order by addtime desc limit 12");
if(is_array($followUsers)){
foreach($followUsers as $item){
$arrFollowUser[] = $new['user']->getSimpleUser($item['touserid']);
}
}
+189
View File
@@ -0,0 +1,189 @@
<?php
defined('IN_TS') or die('Access Denied.');
//用户是否登录
switch($ts){
case "":
$userid = aac('user')->isLogin();
$strUser = $new['user']->getOneUser($userid);
$title = '用户验证';
include template('verify');
break;
//发送验证
case "post":
$userid = aac('user')->isLogin();
$strUser = $new['user']->find('user_info',array(
'userid'=>$userid,
));
if($strUser['verifycode']==''){
$verifycode = random(11);
$new['user']->update('user_info',array(
'userid'=>$userid,
),array(
'verifycode'=>$verifycode,
));
}else{
$verifycode = $strUser['verifycode'];
}
$email = $strUser['email'];
//发送邮件
$subject = $TS_SITE['site_title'].'会员真实性验证';
$content = '尊敬的'.$strUser['username'].'<br />请点击以下链接进行会员验证:<a href="'.$TS_SITE['link_url'].'index.php?app=user&ac=verify&ts=do&email='.$email.'&verifycode='.$verifycode.'">'.$TS_SITE['link_url'].'index.php?app=user&ac=verify&ts=do&email='.$email.'&verifycode='.$verifycode.'</a>';
$result = aac('mail')->postMail($email,$subject,$content);
if($result == '0'){
tsNotice("验证失败,可能是你的Email邮箱错误哦^_^");
}elseif($result == '1'){
tsNotice("系统已经向你的邮箱发送了验证邮件,请尽快查收^_^");
}
break;
//接收验证
case "do":
$email = tsFilter($_GET['email']);
$verifycode = tsFilter($_GET['verifycode']);
$verify = $new['user']->findCount('user_info',array(
'email'=>$email,
'verifycode'=>$verifycode,
));
if($verify > 0){
$new['user']->update('user_info',array(
'email'=>$email,
),array(
'isverify'=>'1',
));
$_SESSION['tsuser']['isverify']=1;
tsNotice("Email验证成功!",'点击回首页!',SITE_URL);
}else{
tsNotice("Email验证失败!");
}
break;
//修改Email
case "setemail":
$userid = aac('user')->isLogin();
$strUser = $new['user']->getOneUser($userid);
$email = tsTrim($_POST['email']);
if($email=='') tsNotice('Email不能为空!');
if(valid_email($email) == false) tsNotice('Email输入有误!');
if($email != $strUser['email']){
$emailNum = $new['user']->findCount('user',array(
'email'=>$email,
));
if($emailNum > 0) tsNotice("Email帐号已经存在,请换个其他Email帐号!");
//更新Email
$new['user']->update('user',array(
'userid'=>$strUser['userid'],
),array(
'email'=>$email,
));
//修改信息并将用户设为未验证状态
$new['user']->update('user_info',array(
'userid'=>$strUser['userid'],
),array(
'email'=>$email,
'isverify'=>'0',
));
tsNotice('Email帐号修改成功,请返回重新验证!');
}else{
tsNotice('新Email帐号不能和旧Email帐号一样!');
}
break;
//必须上传头像
case "face":
$userid = aac('user')->isLogin();
$strUser = $new['user']->getOneUser($userid);
$_SESSION['tsuser']['face'] = $strUser['face'];
$title = '上传头像';
include template('verify_face');
break;
case "facedo":
$userid = aac('user')->isLogin();
if($_FILES['picfile']){
//上传
$arrUpload = tsUpload($_FILES['picfile'],$userid,'user',array('jpg','gif','png','jpeg'));
if($arrUpload){
$new['user']->update('user_info',array(
'userid'=>$userid,
),array(
'path'=>$arrUpload['path'],
'face'=>$arrUpload['url'],
'uptime'=>time(),
));
#本地图片验证
if($TS_SITE['file_upload_type']=='0' || $TS_SITE['file_upload_type']==''){
$filesize=abs(filesize('uploadfile/user/'.$arrUpload['url']));
if($filesize<=0){
$new['user']->update('user_info',array(
'userid'=>$userid,
),array(
'path'=>'',
'face'=>'',
));
tsNotice('上传头像失败!请联系网站管理员处理!');
}elseif($filesize>1048576){
#限制头像图片1M以内
$new['user']->update('user_info',array(
'userid'=>$userid,
),array(
'path'=>'',
'face'=>'',
));
tsNotice('请选择1M以内的头像图片');
}
}
tsDimg($arrUpload['url'],'user','120','120',$arrUpload['path']);
header('Location: '.tsUrl('user','verify',array('ts'=>'face')));
}else{
tsNotice('头像修改失败');
}
}
break;
}
+181
View File
@@ -0,0 +1,181 @@
<?php
defined('IN_TS') or die('Access Denied.');
use EasyWeChat\Factory;
$config = [
'app_id' => $TS_SITE['weixin_appid'],
'secret' => $TS_SITE['weixin_appsecret'],
];
$app = Factory::officialAccount($config);
$oauth = $app->oauth;
// 获取 OAuth 授权结果用户信息
$user = $oauth->user();
// $user 可以用的方法:
// $user->getId(); // 对应微信的 OPENID
// $user->getNickname(); // 对应微信的 nickname
// $user->getName(); // 对应微信的 nickname
// $user->getAvatar(); // 头像网址
// $user->getOriginal(); // 原始API返回的结果
// $user->getToken(); // access_token 比如用于地址共享时使用
if($user->getToken() && $user->getId()){
$openid = $user->getId();
$access_token = $user->getToken();
$strOpen = $new['user']->find('user_open',array(
'sitename'=>'weixin',
'openid'=>$openid,
));
//10天更换一次access_token
if(time()-10*86400>$strOpen['uptime']){
$new['user']->update('user_open',array(
'sitename'=>'weixin',
'openid'=>$openid,
),array(
'access_token'=>$access_token,
'uptime'=>time(),
));
}
if($strOpen['userid']){
/*
$userid = $strOpen['userid'];
$username = $user->getNickname();
$userface = $user->getAvatar();
//更新用户头像
if($userface!='' && $userface!='/0'){
//1000个图片一个目录
$menu2=intval($userid/1000);
$menu1=intval($menu2/1000);
$menu = $menu1.'/'.$menu2;
$photo = $userid.'.jpg';
$photos = $menu.'/'.$photo;
$dir = 'uploadfile/user/'.$menu;
$dfile = $dir.'/'.$photo;
createFolders($dir);
if(!is_file($dfile)){
$img = file_get_contents($userface);
file_put_contents($dfile,$img);
};
$new['user']->update('user_info',array(
'userid'=>$userid,
),array(
'path'=>$menu,
'face'=>$photos,
));
}
*/
//更新登录时间
$new['user']->update('user_info',array(
'userid'=>$strOpen['userid'],
),array(
//'username'=>$username,
'ip'=>getIp(), //更新登录ip
'uptime'=>time(), //更新登录时间
));
//用户session信息
$sessionData = $new['user']->sessionData($strOpen['userid']);
$_SESSION['tsuser'] = $sessionData;
if($_COOKIE['wx_jump']){
header("Location: ".$_COOKIE['wx_jump']);
}else{
header("Location: ".SITE_URL);
}
exit;
}else{
$salt = md5(rand());
$pwd = random(5,0);
$userid = $new['user']->create('user',array(
'pwd'=>md5($salt.$pwd),
'salt'=>$salt,
'email'=>$openid,
'phone'=>$openid,
));
$username = $user->getNickname();
$userface = $user->getAvatar();
//插入ts_user_info
$new['user']->create('user_info',array(
'userid' => $userid,
'username' => $username,
'email' => $openid,
'phone' => $openid,
'ip' => getIp(),
'addtime' => time(),
'uptime' => time(),
));
//插入ts_user_open
$new['user']->create('user_open',array(
'userid'=>$userid,
'sitename'=>'weixin',
'openid' => $openid,
'access_token'=>$access_token,
'uptime'=>time(),
));
//更新用户头像
if($userface!='' && $userface!='/0'){
//1000个图片一个目录
$menu2=intval($userid/1000);
$menu1=intval($menu2/1000);
$menu = $menu1.'/'.$menu2;
$photo = $userid.'.jpg';
$photos = $menu.'/'.$photo;
$dir = 'uploadfile/user/'.$menu;
$dfile = $dir.'/'.$photo;
createFolders($dir);
if(!is_file($dfile)){
$img = file_get_contents($userface);
file_put_contents($dfile,$img);
};
$new['user']->update('user_info',array(
'userid'=>$userid,
),array(
'path'=>$menu,
'face'=>$photos,
));
}
//发送系统消息(恭喜注册成功)
$msg_userid = '0';
$msg_touserid = $userid;
$msg_content = '亲爱的微信用户 '.$username.' :您成功加入了 '
.$TS_SITE['site_title'].'在遵守本站的规定的同时,享受您的愉快之旅吧!';
aac('message')->sendmsg($msg_userid,$msg_touserid,$msg_content);
//用户session信息
$sessionData = $new['user']->sessionData($userid);
$_SESSION['tsuser'] = $sessionData;
if($_COOKIE['wx_jump']){
header("Location: ".$_COOKIE['wx_jump']);
}else{
header("Location: ".SITE_URL);
}
exit;
}
}