作者 邓超

1

... ... @@ -16,6 +16,7 @@ abstract class Base {
/**
* 多个邮箱前端提交
* @param string $filed
* @return mixed|null
* @throws \Lib\Err
... ... @@ -39,6 +40,29 @@ abstract class Base {
}
/**
* 一个邮箱前端提交
* @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()->first(emailSql::first(web_request_email()));
if(empty($data)){
app()->e('email_request_required');
}
}
if($filed == '*'){
return $data;
}
return $data[$filed]??'';
}
}
\ No newline at end of file
... ...
... ... @@ -26,8 +26,8 @@ class Folder extends Base {
// 查询
$folders = db()->all(
\Model\folderSql::all(
$this->login_email['id'],
'`id`,`folder`,`pid`'
$this->getEmail('id'),
'`id`,`folder`,`pid`,`exsts`,`unseen`'
)
);
... ...
... ... @@ -84,7 +84,7 @@ function _echo($message){
* @time 2023/2/13 10:51
*/
function __($key):mixed{
return $key ? \Lib\Lang::msg($key) : '';
return $key ? \Lib\Lang::msg($key) : '';
}
... ... @@ -188,7 +188,7 @@ function web_request_emails():array {
$emails = app()->request('emails');
$emails = is_array($emails) ? $emails : [$emails];
foreach ($emails as $k=>$email){
if(!preg_match('/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',$email)){
if(!\Lib\Verify::email($email)){
unset($emails[$k]);
}
}
... ... @@ -200,6 +200,25 @@ function web_request_emails():array {
return array_values($emails);
}
/**
* 前端获取邮箱一个
* @return string
* @throws \Lib\Err
* @author:dc
* @time 2023/3/10 16:05
*/
function web_request_email():string {
$email = app()->request('email');
if(!\Lib\Verify::email($email)){
app()->e('email_request_required');
}
return $email;
}
/**
* 分页数据
... ...
<?php
namespace Lib;
/**
* 验证
* @author:dc
* @time 2023/3/10 16:03
* Class Verify
* @package Lib
*/
class Verify {
/**
* 验证邮箱
* @param $email
* @return false|int
* @author:dc
* @time 2023/3/10 16:04
*/
public static function email($email){
return preg_match('/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',$email);
}
}
\ No newline at end of file
... ...