4
This commit is contained in:
+52
-3
@@ -1,6 +1,11 @@
|
||||
<?php
|
||||
use Bilulanlv\ThinkCache\facade\ThinkCache;
|
||||
use support\Env;
|
||||
if (!function_exists('admin_path')) {
|
||||
function admin_path(){
|
||||
return '/app/admin';
|
||||
}
|
||||
}
|
||||
if (!function_exists('cache')) {
|
||||
/**
|
||||
* 缓存管理
|
||||
@@ -150,16 +155,19 @@ if (!function_exists('addJob')) {
|
||||
if (!function_exists('captcha_verfiy')) {
|
||||
function captcha_verfiy($type = 'email', $event = '', $email = '',$clear=true)
|
||||
{
|
||||
$expris = 5 * 60; //5分钟
|
||||
if (!$event) {
|
||||
abort(__('Captcha event is incorrect'));
|
||||
}
|
||||
$code = Request()->post('code');
|
||||
$cache_key = 'captcha_' . $event . '_' . $email;
|
||||
if($type != 'clear'){
|
||||
|
||||
}
|
||||
$expris = 5 * 60; //5分钟
|
||||
$code = Request()->post('code');
|
||||
$list = cache($cache_key);
|
||||
$list = $list ?: [];
|
||||
if (!isset($list[$code])) {
|
||||
abort(__('Captcha is incorrect'));
|
||||
abort(__('Captcha is incorrect').$cache_key.$code);
|
||||
}
|
||||
if ($list[$code] + $expris < time()) {
|
||||
unset($list[$code]);
|
||||
@@ -818,4 +826,45 @@ if(!function_exists('generateShortUniqueID')){
|
||||
// 生成指定长度的随机字节,转为 Base64 编码并去除不必要字符
|
||||
return substr(bin2hex(random_bytes($length / 2)), 0, $length);
|
||||
}
|
||||
}
|
||||
if(!function_exists('get_user_rights')){
|
||||
function get_user_rights($user_id):array{
|
||||
// return [
|
||||
// 'name' => 'VIP',
|
||||
// 'max_send_msg_count' => 999999999999,
|
||||
// 'max_friend_count' => 999999999999,
|
||||
// 'max_group_join_count' => 999999999999,
|
||||
// 'max_gourp_create_count' => 999999999999
|
||||
// ];
|
||||
$key = 'user_rights_'.$user_id;
|
||||
$result = cache($key);
|
||||
if(!$result){
|
||||
$result = \think\facade\Db::name('user_role')->alias('ur')
|
||||
->join('user u','ur.id = u.role_id')
|
||||
->field('ur.name,ur.max_send_msg_count,ur.max_friend_count,ur.max_group_join_count,ur.max_gourp_create_count')
|
||||
->find();
|
||||
cache($key,$result,86400);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
if(!function_exists('__my__template_inputs')){
|
||||
function __my__template_inputs(&$template, &$vars, &$app, &$plugin){
|
||||
// cp('__after__template_inputs:');
|
||||
// cp('template:'.$template);
|
||||
// cp('app:'.$app);
|
||||
// cp('plugin:'.$plugin);
|
||||
$request = request();
|
||||
if(!$template){
|
||||
$baseViewPath = $plugin ? base_path() . "/plugin/$plugin/app" : app_path();
|
||||
$viewPath = $app === '' ? "$baseViewPath/view/" : "$baseViewPath/$app/view/";
|
||||
$template = strtolower($request->controller_name."/".$request->action_name);
|
||||
}
|
||||
if(count(explode('/',$template)) == 1){
|
||||
$template = strtolower($request->controller_name."/".$template);
|
||||
}
|
||||
return [$template, $vars, $app, $plugin];
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user