作者 邓超

x

@@ -13,6 +13,7 @@ use Model\listsSql; @@ -13,6 +13,7 @@ use Model\listsSql;
13 use Model\sendJobsSql; 13 use Model\sendJobsSql;
14 use PHPMailer\PHPMailer\PHPMailer; 14 use PHPMailer\PHPMailer\PHPMailer;
15 use PHPMailer\PHPMailer\SMTP; 15 use PHPMailer\PHPMailer\SMTP;
  16 +use function Swoole\Coroutine\Http\request;
16 17
17 18
18 /** 19 /**
@@ -64,7 +65,11 @@ class Home extends Base { @@ -64,7 +65,11 @@ class Home extends Base {
64 // 文件夹id 65 // 文件夹id
65 if($folderList){ 66 if($folderList){
66 foreach ($folderList as $item){ 67 foreach ($folderList as $item){
67 - if($item['folder'] == $folder){ 68 + if(
  69 + // 数组文件夹
  70 + (is_array($folder) && in_array($item['folder'],$folder))
  71 + || $item['folder'] == $folder
  72 + ){
68 $folder_id[] = $item['id']; 73 $folder_id[] = $item['id'];
69 } 74 }
70 } 75 }
@@ -76,13 +81,57 @@ class Home extends Base { @@ -76,13 +81,57 @@ class Home extends Base {
76 //目录 81 //目录
77 $where['folder_id'] = $folder_id; 82 $where['folder_id'] = $folder_id;
78 if($ids) $where['id'] = $ids; 83 if($ids) $where['id'] = $ids;
79 - if($attachment) $where['is_file'] = 1; //附件 84 +
  85 + if(paramHas('attachment')){
  86 + $where['is_file'] = $attachment ? 1 : 0; //附件
  87 + }
  88 +
  89 +
80 // 软删 90 // 软删
81 $where['deleted'] = $deleted; 91 $where['deleted'] = $deleted;
82 // 已读/未读 92 // 已读/未读
  93 + if(paramHas('seen')){
83 if(in_array($seen,[0,1])){ 94 if(in_array($seen,[0,1])){
84 $where['seen'] = $seen; 95 $where['seen'] = $seen;
85 } 96 }
  97 + }
  98 +
  99 + $where['_'] = [];
  100 + // 搜索关键字
  101 + $keyword = app()->request('keyword','',['htmlspecialchars','addslashes']);
  102 + if($keyword){
  103 + $where['_'][] = '`subject` like "%'.$keyword.'%"';
  104 + }
  105 +
  106 + // 那个发的
  107 + $address = app()->request('address');
  108 + if($address){
  109 + if(is_array($address)){
  110 + // 发贱人
  111 + if(Verify::sEmail($address['from']??'')){
  112 + $where['from'] = $address['from'];
  113 + }
  114 + // 收件人
  115 + if(Verify::sEmail($address['to']??'')){
  116 + $where['_'][] = '`to_name` like "%'.$address.'%"';
  117 + }
  118 +
  119 + }else if(Verify::sEmail($address)){
  120 + // 收件人/发件人
  121 + $where['_'][] = '(`from` = "'.$address.'" or `to_name` like "%'.$address.'%")';
  122 + }
  123 + }
  124 + // 回复
  125 + if (paramHas('answered')){
  126 + $where['answered'] = app()->request('answered',0,'bool_Val')?1:0;
  127 + }
  128 +
  129 + $fromto = app()->request('formorto');
  130 + if($fromto=='from'){
  131 + $where['from'] = $this->getEmails('email');
  132 + }elseif ($fromto=='to'){
  133 + $where['from.notin'] = $this->getEmails('email');
  134 + }
86 135
87 $lists = db()->all( 136 $lists = db()->all(
88 listsSql::lists( 137 listsSql::lists(
@@ -16,19 +16,10 @@ class Test { @@ -16,19 +16,10 @@ class Test {
16 16
17 17
18 public function home(){ 18 public function home(){
19 - $a = [];  
20 -  
21 - $v = $a['b'];  
22 -  
23 - return []; 19 + http_response_code(404);
  20 + app()->e(404,404);
24 } 21 }
25 22
26 - public function a(){  
27 -  
28 - }  
29 -  
30 -  
31 -  
32 23
33 24
34 } 25 }
@@ -141,7 +141,14 @@ function my_filter($value,$filter=null){ @@ -141,7 +141,14 @@ function my_filter($value,$filter=null){
141 function dbWhere(array $where, string $ar = 'and'):string{ 141 function dbWhere(array $where, string $ar = 'and'):string{
142 $sql = []; 142 $sql = [];
143 foreach ($where as $f=>$v){ 143 foreach ($where as $f=>$v){
  144 +
  145 + list($f,$t) = explode('.',$f.'.');
  146 +
144 if(is_array($v)){ 147 if(is_array($v)){
  148 + if($f ==='_'){
  149 + $sql = array_merge($sql,$v);
  150 + continue;
  151 + }
145 $v = array_map(function ($n){ 152 $v = array_map(function ($n){
146 if (is_string($n)){ 153 if (is_string($n)){
147 return "'".addslashes($n)."'"; 154 return "'".addslashes($n)."'";
@@ -152,14 +159,19 @@ function dbWhere(array $where, string $ar = 'and'):string{ @@ -152,14 +159,19 @@ function dbWhere(array $where, string $ar = 'and'):string{
152 // 只有一个值时就是 = 159 // 只有一个值时就是 =
153 $sql[] = "`{$f}` = ".$v[0]; 160 $sql[] = "`{$f}` = ".$v[0];
154 }elseif (count($v) > 1){ 161 }elseif (count($v) > 1){
155 - $sql[] = "`{$f}` in (".implode(',',$v).")"; 162 + $sql[] = "`{$f}` ".($t=='notin'?'not in':'in')." (".implode(',',$v).")";
156 } 163 }
157 164
158 }else{ 165 }else{
  166 + if($f ==='_'){
  167 + $sql[] = $v;
  168 + }else{
159 $sql[] = "`{$f}` = '". (is_string($v) ? addslashes($v): $v) ."'"; 169 $sql[] = "`{$f}` = '". (is_string($v) ? addslashes($v): $v) ."'";
160 } 170 }
161 171
162 } 172 }
  173 +
  174 + }
163 return implode(' '.$ar.' ',$sql); 175 return implode(' '.$ar.' ',$sql);
164 } 176 }
165 177
@@ -377,7 +389,15 @@ function bool_Val($val):bool { @@ -377,7 +389,15 @@ function bool_Val($val):bool {
377 389
378 } 390 }
379 391
380 - 392 +/**
  393 + * @param string $name
  394 + * @return bool
  395 + * @author:dc
  396 + * @time 2023/4/15 16:50
  397 + */
  398 +function paramHas(string $name):bool {
  399 + return app()->requestHas($name);
  400 +}
381 401
382 402
383 403
@@ -190,6 +190,17 @@ class App { @@ -190,6 +190,17 @@ class App {
190 return null; 190 return null;
191 } 191 }
192 192
  193 + /**
  194 + * 是否存在
  195 + * @param string $name
  196 + * @return bool
  197 + * @author:dc
  198 + * @time 2023/4/15 16:43
  199 + */
  200 + public function requestHas(string $name):bool {
  201 + return isset($this->request[$name]);
  202 + }
  203 +
193 204
194 /** 205 /**
195 * @param string $key 206 * @param string $key