PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.10.2
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.10.2
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / back / Controllers / FileController.php

FileController.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.10.2, at back/Controllers/FileController.php

64 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\Controllers;
4
5 use AcyMailing\Core\AcymController;
6 use AcyMailing\Types\FileTreeType;
7
8 class FileController extends AcymController
9 {
10 public function __construct()
11 {
12 parent::__construct();
13
14 $this->setDefaultTask('select');
15 }
16
17 public function select(): void
18 {
19 acym_setVar('layout', 'select');
20
21 $warnings = '';
22 $uploadFolderBase = acym_getFilesFolder();
23 $currentFolder = acym_getVar('string', 'currentFolder', $uploadFolderBase);
24 if (strpos($currentFolder, $uploadFolderBase) !== 0 || strpos($currentFolder, '..') !== false) {
25 $currentFolder = $uploadFolderBase;
26 }
27
28 $uploadFolder = trim(str_replace('/', DS, trim($currentFolder)), DS);
29 $uploadPath = acym_cleanPath(ACYM_ROOT.$uploadFolder);
30 $folders = acym_generateArborescence([$uploadFolderBase]);
31
32 $uploadedFile = acym_getVar('array', 'uploadedFile', [], 'files');
33 $selectedFile = '';
34 if (!empty($uploadedFile['name'])) {
35 ob_start();
36 $uploaded = acym_importFile($uploadedFile, $uploadPath, false);
37 $warnings = ob_get_clean();
38 if (!empty($uploaded)) {
39 $selectedFile = $uploaded;
40 }
41 }
42
43 $files = [];
44 if (file_exists($uploadPath)) {
45 $files = acym_getFiles($uploadPath);
46 }
47
48 $data = [
49 'files' => $files,
50 'uploadFolder' => $uploadFolder,
51 'map' => acym_getVar('string', 'id'),
52 'displayType' => acym_getVar('string', 'displayType', 'icons'),
53 'imageExtensions' => acym_getImageFileExtensions(),
54 'allowedExtensions' => explode(',', $this->config->get('allowed_files')),
55 'folders' => $folders,
56 'fileTreeType' => new FileTreeType(),
57 'selectedFile' => $selectedFile,
58 'warnings' => $warnings,
59 ];
60
61 parent::display($data);
62 }
63 }
64