作者 邓超

x

... ... @@ -13,6 +13,7 @@ use Model\listsSql;
use Model\sendJobsSql;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use function Swoole\Coroutine\Http\request;
/**
... ... @@ -64,7 +65,11 @@ class Home extends Base {
// 文件夹id
if($folderList){
foreach ($folderList as $item){
if($item['folder'] == $folder){
if(
// 数组文件夹
(is_array($folder) && in_array($item['folder'],$folder))
|| $item['folder'] == $folder
){
$folder_id[] = $item['id'];
}
}
... ... @@ -76,12 +81,56 @@ class Home extends Base {
//目录
$where['folder_id'] = $folder_id;
if($ids) $where['id'] = $ids;
if($attachment) $where['is_file'] = 1; //附件
if(paramHas('attachment')){
$where['is_file'] = $attachment ? 1 : 0; //附件
}
// 软删
$where['deleted'] = $deleted;
// 已读/未读
if(in_array($seen,[0,1])){
$where['seen'] = $seen;
if(paramHas('seen')){
if(in_array($seen,[0,1])){
$where['seen'] = $seen;
}
}
$where['_'] = [];
// 搜索关键字
$keyword = app()->request('keyword','',['htmlspecialchars','addslashes']);
if($keyword){
$where['_'][] = '`subject` like "%'.$keyword.'%"';
}
// 那个发的
$address = app()->request('address');
if($address){
if(is_array($address)){
// 发贱人
if(Verify::sEmail($address['from']??'')){
$where['from'] = $address['from'];
}
// 收件人
if(Verify::sEmail($address['to']??'')){
$where['_'][] = '`to_name` like "%'.$address.'%"';
}
}else if(Verify::sEmail($address)){
// 收件人/发件人
$where['_'][] = '(`from` = "'.$address.'" or `to_name` like "%'.$address.'%")';
}
}
// 回复
if (paramHas('answered')){
$where['answered'] = app()->request('answered',0,'bool_Val')?1:0;
}
$fromto = app()->request('formorto');
if($fromto=='from'){
$where['from'] = $this->getEmails('email');
}elseif ($fromto=='to'){
$where['from.notin'] = $this->getEmails('email');
}
$lists = db()->all(
... ...
... ... @@ -16,19 +16,10 @@ class Test {
public function home(){
$a = [];
$v = $a['b'];
return [];
http_response_code(404);
app()->e(404,404);
}
public function a(){
}
}
... ...
... ... @@ -141,7 +141,14 @@ function my_filter($value,$filter=null){
function dbWhere(array $where, string $ar = 'and'):string{
$sql = [];
foreach ($where as $f=>$v){
list($f,$t) = explode('.',$f.'.');
if(is_array($v)){
if($f ==='_'){
$sql = array_merge($sql,$v);
continue;
}
$v = array_map(function ($n){
if (is_string($n)){
return "'".addslashes($n)."'";
... ... @@ -152,11 +159,16 @@ function dbWhere(array $where, string $ar = 'and'):string{
// 只有一个值时就是 =
$sql[] = "`{$f}` = ".$v[0];
}elseif (count($v) > 1){
$sql[] = "`{$f}` in (".implode(',',$v).")";
$sql[] = "`{$f}` ".($t=='notin'?'not in':'in')." (".implode(',',$v).")";
}
}else{
$sql[] = "`{$f}` = '". (is_string($v) ? addslashes($v): $v) ."'";
if($f ==='_'){
$sql[] = $v;
}else{
$sql[] = "`{$f}` = '". (is_string($v) ? addslashes($v): $v) ."'";
}
}
}
... ... @@ -377,7 +389,15 @@ function bool_Val($val):bool {
}
/**
* @param string $name
* @return bool
* @author:dc
* @time 2023/4/15 16:50
*/
function paramHas(string $name):bool {
return app()->requestHas($name);
}
... ...
... ... @@ -190,6 +190,17 @@ class App {
return null;
}
/**
* 是否存在
* @param string $name
* @return bool
* @author:dc
* @time 2023/4/15 16:43
*/
public function requestHas(string $name):bool {
return isset($this->request[$name]);
}
/**
* @param string $key
... ...