...
|
...
|
@@ -46,15 +46,17 @@ class Folder extends Base { |
|
|
* @time 2023/2/18 17:56
|
|
|
*/
|
|
|
public function create(){
|
|
|
$email = $this->getEmail('id');
|
|
|
|
|
|
$formData = app()->request(['pid','folder']);
|
|
|
// 验证目录 可以输入中文英文数字
|
|
|
if(empty($formData['folder']) || !preg_match("/^[\u4E00-\u9FA5A-Za-z0-9_]+$/",$formData['folder'])){
|
|
|
if(empty($formData['folder'])){
|
|
|
app()->e('folder_create_name_error');
|
|
|
}
|
|
|
// 不为空上级
|
|
|
if(!empty($formData['pid'])){
|
|
|
$parent = db()->first(folderSql::first(['id'=>$formData['pid']]));
|
|
|
if(!$parent || $parent['email_id'] != $this->login_email['id']){
|
|
|
if(!$parent || $parent['email_id'] != $email['id']){
|
|
|
app()->e('folder_parent_not_fount');
|
|
|
}
|
|
|
if($parent['pid']){
|
...
|
...
|
@@ -63,11 +65,13 @@ class Folder extends Base { |
|
|
|
|
|
}
|
|
|
|
|
|
$formData['folder'] = str_replace(["'",'"','/','\\','&','*','(',')'],'',$formData['folder']);
|
|
|
|
|
|
// 判断文件夹是否存在
|
|
|
$has = db()->count(folderSql::has(
|
|
|
[
|
|
|
'email_id' => $this->login_email['id'],
|
|
|
'origin_folder' => $formData['folder']
|
|
|
'email_id' => $email['id'],
|
|
|
'origin_folder' => MailFun::folderEncoding($formData['folder'])
|
|
|
]
|
|
|
));
|
|
|
|
...
|
...
|
@@ -76,8 +80,19 @@ class Folder extends Base { |
|
|
}
|
|
|
|
|
|
// 远程创建
|
|
|
$mail = new Mail();
|
|
|
$mail->login($this->login_email['email'],$this->login_email['password'],$this->login_email['imap']);
|
|
|
$mail = new Mail(
|
|
|
$email['email'],
|
|
|
$email['password'],
|
|
|
$email['imap']
|
|
|
);
|
|
|
|
|
|
if(!$mail->login()){
|
|
|
app()->e('login_error_imap');
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$folder = $mail->client->folderCreate($formData['folder']);
|
|
|
|
|
|
|
...
|
...
|
|