Commit c3b1b8e1 authored by wangtao's avatar wangtao

学习资料

parent 48708b23
name = build
title = Veitool框架命令构建器
intro = 基于Veitool快捷开发框架的命令构建器
author = veitool
website = https://www.veitool.com
title = ''
intro = ''
author = ''
website = ''
version = 1.0.1
state = 1
home = 0
......
......@@ -92,7 +92,20 @@ abstract class BaseController
$ip = $this->request->ip();
$websitelog = Cache::get('webistelog:' . $ip);
if (empty($websitelog)) {
if ($websitelog) {
return;
}
$filename = 'data_lock_' . $ip . '.txt';
$fp = fopen($filename, 'c + '); // 'c + ' 模式避免截断文件
try {
// 尝试获取锁
if (flock($fp, LOCK_EX)) {
$websitelog = Cache::get('webistelog:' . $ip);
if ($websitelog) {
return;
}
$url = substr(vhtmlspecialchars(strip_sql($this->request->url())), 0, 200);
$a = substr(vhtmlspecialchars(strip_sql(request()->header('user-agent'))), 0, 200);
$data['ip'] = $ip;
......@@ -102,8 +115,21 @@ abstract class BaseController
Db::name('webiste_log')->insert($data);
Db::name('webiste')->where('id', 1)->setInc('unique_visitors');
Cache::set('webistelog:' . $ip, $ip, 72000);
// 释放锁
flock($fp, LOCK_UN);
}
fclose($fp);
unlink($filename);
} catch (\Exception $e) {
// 确保发生异常时释放锁并关闭文件
if (is_resource($fp)) {
flock($fp, LOCK_UN);
fclose($fp);
unlink($filename);
}
}
}
/**
......@@ -206,9 +232,9 @@ abstract class BaseController
protected final function exitMsg($m, $c = 0, $d = [], $h = [])
{
if ($c == 400) {
$re = Response::create(ROOT_PATH . 'app/v_msg.tpl', 'view')->assign(['msg' => $m, 'site' => vconfig('site_title')])->header($h);
$re = Response::create(ROOT_PATH . 'app / v_msg . tpl', 'view')->assign(['msg' => $m, 'site' => vconfig('site_title')])->header($h);
} else if ($c == 303) {
$re = Response::create(ROOT_PATH . 'app/v_msg.tpl', 'view')->assign(['msg' => $m, 'site' => vconfig('site_title'), 'url' => $d['url']])->header($h);
$re = Response::create(ROOT_PATH . 'app / v_msg . tpl', 'view')->assign(['msg' => $m, 'site' => vconfig('site_title'), 'url' => $d['url']])->header($h);
} else {
$rs = json_encode(['code' => $c, 'msg' => $m, 'data' => $d, 'token' => $this->token]);
$re = Response::create($rs)->header($h);
......@@ -265,7 +291,7 @@ abstract class BaseController
*/
protected final function returnTpl($msg = '', $tpl = '', $url = '')
{
$tpl = $tpl ?: ($this->request->isMobile() ? 'err' : ROOT_PATH . 'app/v_msg.tpl');
$tpl = $tpl ?: ($this->request->isMobile() ? 'err' : ROOT_PATH . 'app / v_msg . tpl');
$this->assign(['msg' => $msg, 'url' => $url]);
return $this->fetch($tpl);
}
......@@ -296,12 +322,18 @@ abstract class BaseController
'e' => [2 => 'email', 3 => '邮箱地址格式错误', 4 => '', 5 => ''],
'm' => [2 => 'mobile', 3 => '手机号码格式错误', 4 => '', 5 => ''],
'c' => [2 => 'idcard', 3 => '身份证号格式错误', 4 => '', 5 => ''],
'p' => [2 => '{6,16}', 3 => '密码', 4 => '5', 5 => ''],
'u' => [2 => '{4,30}', 3 => '帐号', 4 => '1,2,3', 5 => '._@'],
'n' => [2 => '{2,30}', 3 => '姓名', 4 => '0', 5 => ' .'],
'i' => [2 => '{1,30}', 3 => '数串', 4 => '1', 5 => ','],
'a' => [2 => '{3,20}', 3 => '插件名', 4 => '1,2', 5 => ''],
'v' => [2 => '{2,20}', 3 => '配置名', 4 => '1,2,3', 5 => '_']
'p' => [2 => '{
6,16}', 3 => '密码', 4 => '5', 5 => ''],
'u' => [2 => '{
4,30}', 3 => '帐号', 4 => '1,2,3', 5 => ' . _@'],
'n' => [2 => '{
2,30}', 3 => '姓名', 4 => '0', 5 => ' . '],
'i' => [2 => '{
1,30}', 3 => '数串', 4 => '1', 5 => ','],
'a' => [2 => '{
3,20}', 3 => '插件名', 4 => '1,2', 5 => ''],
'v' => [2 => '{
2,20}', 3 => '配置名', 4 => '1,2,3', 5 => '_']
];
foreach ($name as $key => $val) {
$default = '';
......@@ -356,6 +388,7 @@ abstract class BaseController
$v = dround($v);
break;
case '*':
if ($sub[2] == 'p') $must = is_md5($v) ? false : $must;
$tip = $sub[3];
if (isset($preg[$sub[2]])) {
......@@ -422,10 +455,10 @@ abstract class BaseController
PhpOffice::ossdownfile($fileinfo['fileurl'], $path);
register_shutdown_function(function () use ($path) {
// 处理完成后删除临时文件
unlink(VT_PUBLIC.'/'.$path);
unlink(VT_PUBLIC . '/' . $path);
});
return download('./' . $path, $fileinfo['filename'])->force(true);
}catch (\Exception $e) {
} catch (\Exception $e) {
return $this->exitMsg($e->getMessage());
}
}
......
......@@ -76,13 +76,16 @@ class Login extends BaseController
*/
public function check()
{
//多次尝试验证
$ip = $this->request->ip();
if(Lock::check(['key'=>'LOGIN_'.$ip])) return $this->returnMsg(Lock::msg());
$d = $this->only(['username/*/u/管理帐号','password/*/p/登录密码','captcha']);
$d = $this->only(['username/u/管理帐号','password/p/登录密码','captcha']);
if(vconfig('admin_captcha',1) && !captcha_check($d['captcha'])) return $this->returnMsg('验证码错误!');
$username = $d['username'];
$password = $d['password'];
//查询用户数据
$rs = Manager::one(compact('username'));
if(empty($rs)){
......
......@@ -12,6 +12,7 @@ namespace app\admin\controller\caiwu;
use app\admin\controller\AdminBase;
use app\event\PhpOffice;
use app\model\project\Mail;
use think\App;
use think\facade\Db;
use app\model\project\UserWithdrawal;
......@@ -159,6 +160,9 @@ class Withdrawal extends AdminBase
Db::rollback();
throw new \Exception('余额变动失败');
}
Mail::createmail($txinfo['user_id'], "您申请提现【" . $txinfo['sn']. "】打款失败 - " . $errordesc);
}else{
Mail::createmail($txinfo['user_id'], "您申请提现:【" . $txinfo['sn'] . "】已通过打款请注意查收");
}
$updatedata['dk_status'] = $shstatus;
......
......@@ -12,6 +12,7 @@ namespace app\admin\controller\cert;
use app\admin\controller\AdminBase;
use app\model\CertOrder as CertOrderModel;
use app\model\project\Mail;
use think\App;
/**
* 后台主控制器
......@@ -103,7 +104,12 @@ class CertOrder extends AdminBase
$result = $this->certorder->where('id', $post['id'])->update($updatedata);
if ($result) {
$cert_order_info = $this->certorder->where('id', $post['id'])->with(['certdata'])->find();
if ($post['shstatus'] == 1) {
Mail::createmail($cert_order_info['user_id'], "您报名的证书【" . $cert_order_info['certdata']['title'] . "】已审核通过");
} else {
Mail::createmail($cert_order_info['user_id'], "您报名的证书【" . $cert_order_info['certdata']['title']. "】审核不通过 - " . $errordesc);
}
return $this->returnMsg("操作成功", 1);
} else {
return $this->returnMsg("操作失败");
......
......@@ -12,6 +12,7 @@ namespace app\admin\controller\course;
use app\admin\controller\AdminBase;
use app\job\Jobtask;
use app\model\project\Mail;
use app\model\ShCourse as ShCourseModel;
use think\App;
use think\facade\Db;
......@@ -53,10 +54,10 @@ class Course extends AdminBase
}
if (isset($post['status']) && $post['status'] > -1) {
$map[] = ['status', '=', $post['status']];
}else{
} else {
$map[] = ['status', '>', 0];
}
$list = $this->course->where($map)->append(['thumbpath', 'cate_name', 'teacher_name', 'status_text', 'tag_title', 'user_info', 'is_sell_text','is_hot_arr'])->order('createtime desc')->paginate($post['limit']);
$list = $this->course->where($map)->append(['thumbpath', 'cate_name', 'teacher_name', 'status_text', 'tag_title', 'user_info', 'is_sell_text', 'is_hot_arr'])->order('createtime desc')->paginate($post['limit']);
return $this->returnMsg($list);
}
......@@ -73,13 +74,13 @@ class Course extends AdminBase
$post = input();
$result = $this->course->update([$post['af'] => $post['av']], [['id', '=', $post['id']]]);
if($post['af'] == 'is_sell'){
if ($post['af'] == 'is_sell') {
$course_id = $post['id'];
event('Course', ['course_id' => $course_id, 'tasktype' => 'course', 'action' => 'shcourseupdate']);
}
if($result){
return $this->returnMsg('修改成功',1);
}else{
if ($result) {
return $this->returnMsg('修改成功', 1);
} else {
return $this->returnMsg('修改失败');
}
}
......@@ -125,8 +126,12 @@ class Course extends AdminBase
$result = $this->course->where('id', $post['id'])->update($updatedata);
if ($result) {
$courseinfo = Db::name('course')->where('id', $post['id'])->field('id,title,user_id')->find();
if ($post['shstatus'] == 1) {
event('Course', ['course_id' => $post['id'], 'tasktype' => 'course', 'action' => 'shstatus']);
Mail::createmail($courseinfo['user_id'], "您的课程【" . $courseinfo['title'] . "】已审核通过");
} else {
Mail::createmail($courseinfo['user_id'], "您的课程【" . $courseinfo['title'] . "】审核不通过 - " . $errordesc);
}
return $this->returnMsg("操作成功", 1);
} else {
......@@ -149,7 +154,7 @@ class Course extends AdminBase
{
$post = input();
if($this->request->isAjax()){
if ($this->request->isAjax()) {
$data['is_hot'] = isset($post['is_hot']) ? $post['is_hot'] : 0;
$data['is_tj'] = isset($post['is_tj']) ? $post['is_tj'] : 0;
......
......@@ -12,6 +12,7 @@ namespace app\admin\controller\project;
use app\admin\controller\AdminBase;
use app\model\Project as ProjectModel;
use app\model\project\Mail;
use app\model\project\User;
use app\model\project\UserMoneyLog;
use think\App;
......@@ -145,6 +146,12 @@ class Project extends AdminBase
$result = $this->project->where('id', $post['id'])->update($updatedata);
if ($result) {
$projuect = $this->project->where('id', $post['id'])->field('id,user_id,title')->find();
if ($post['shstatus'] == 1) {
Mail::createmail($projuect['user_id'], "您的项目【" . $projuect['title'] . "】已审核通过");
} else {
Mail::createmail($projuect['user_id'], "您的项目【" . $projuect['title'] . "】审核不通过 - " . $errordesc);
}
return $this->returnMsg("操作成功", 1);
} else {
return $this->returnMsg("操作失败");
......
......@@ -679,3 +679,18 @@ function http_get($url)
return false;
}
}
/**
* 将手机号中间4位替换为星号
* @param string $phone 手机号码
* @return string 处理后的手机号码
*/
function maskPhoneNumber($phone) {
// 验证手机号长度是否为11位
if (strlen($phone) !== 11) {
return $phone; // 如果不是11位,原样返回
}
// 使用正则表达式匹配并替换中间4位
return preg_replace('/(\d{3})\d{4}(\d{4})/', '$1****$2', $phone);
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ use app\model\CourseClass;
use app\model\CourseClassCategory;
use app\model\CourseWork;
use app\model\ShCourse;
use app\model\project\Mail;
use app\model\ShCourseClass;
use app\model\ShCourseClassCategory;
use app\model\ShCourseWork;
......
......@@ -25,7 +25,14 @@ class CourseUserWork extends Model
*/
public static function workList($userId, $page = 1, $pageSize = 10)
{
$status = request()->post('status');
$map = [];
if($status){
$map['status'] = $status;
}
return self::where(['user_id' => $userId, 'is_del' => 0])
->where($map)
->with(['course', 'courseWork'])
->field('id,user_id,work_id,status,course_id,createtime')
->paginate([
......
......@@ -8,6 +8,7 @@ use think\model\concern\SoftDelete;
class Mail extends Model
{
use SoftDelete;
protected $deleteTime = 'deletetime';
protected $autoWriteTimestamp = true;
protected $createTime = 'createtime';
......@@ -24,4 +25,12 @@ class Mail extends Model
{
return $data['type'] == 1 ? '系统通知' : '后台发送';
}
//添加消息
public static function createmail($user_id, $content, $title = '', $type = 1)
{
$data = ['content' => $content, 'type' => $type, 'user_id' => $user_id,'title'=>$title];
return self::create($data);
}
}
\ No newline at end of file
......@@ -148,7 +148,7 @@ class UserMoneyLog extends Model
$query = $this->with(['getuserdata'])
->order('createtime', 'desc');
$query->where('user_id','=',$params['userId']);
if (isset($params['type']) && $params['type'] !== '') {
$query->where('type', intval($params['type']));
}
......@@ -166,7 +166,7 @@ class UserMoneyLog extends Model
$query->where('money','<',0);
}
}
$query->append(['type_text']);
//按日期范围筛选
if (!empty($params['start_date'])) {
$query->where('createtime', '>=', strtotime($params['start_date']));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment