Base.php
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace Controller;
use Model\emailSql;
/**
* 基础控制器,根据需求 可以不继承此类
* @author:dc
* @time 2023/2/18 16:34
* Class Base
* @package Controller
*/
abstract class Base {
/**
* 多个邮箱前端提交
* @param string $filed
* @return mixed|null
* @throws \Lib\Err
* @author:dc
* @time 2023/3/10 15:15
*/
protected final function getEmails($filed='*'){
static $data;
if(empty($data)){
$data = db()->cache(600)->all(emailSql::all(dbWhere(['email'=>web_request_emails()])));
if(empty($data)){
app()->e('email_request_required');
}
}
if($filed == '*'){
return $data;
}
return array_column($data,$filed);
}
/**
* 一个邮箱前端提交
* @param string $filed
* @return mixed|string|null
* @throws \Lib\Err
* @author:dc
* @time 2023/3/10 16:07
*/
protected final function getEmail($filed='*'){
static $data;
if(empty($data)){
$data = db()->cache(600)->first(emailSql::first(web_request_email()));
if(empty($data)){
app()->e('email_request_required');
}
if($data['pwd_error']){
app()->e('imap_password_error',403);
}
}
if($filed == '*'){
return $data;
}
return $data[$filed]??'';
}
}