PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 3.1.22.3
JetBackup – Backup, Restore & Migrate v3.1.22.3
3.1.22.3 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.8.1 1.4.9 1.5.0 1.5.1 1.5.1.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.10 1.6.11 1.6.12 1.6.13 1.6.15 1.6.5.1 1.6.8.8 1.6.9 1.6.9.1 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7.5 2.0.8.7 2.0.9.11 2.0.9.14 2.0.9.15 2.0.9.6 2.0.9.7 2.0.9.9 3.1.10.7 3.1.11.1 3.1.12.3 3.1.13.4 3.1.14.17 3.1.15.4 3.1.16.1 3.1.17.5 3.1.18.10 3.1.18.8 3.1.18.9 3.1.19.8 3.1.20.3 3.1.21.3 3.1.7.9 3.1.9.2 trunk 1.1.90 1.1.91 1.2.0 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2
backup / src / JetBackup / DirIterator / DirIteratorExcludes.php
backup / src / JetBackup / DirIterator Last commit date
.htaccess 1 year ago DirIterator.php 5 months ago DirIteratorExcludes.php 1 year ago DirIteratorFile.php 1 year ago index.html 1 year ago web.config 1 year ago
DirIteratorExcludes.php
111 lines
1 <?php
2
3 namespace JetBackup\DirIterator;
4
5 if (!defined( '__JETBACKUP__')) die('Direct access is not allowed');
6
7 // Shows "file manager" for the excludes
8
9 use DateTime;
10 use DirectoryIterator;
11 use Exception;
12 use JetBackup\Config\System;
13 use JetBackup\JetBackup;
14
15 class DirIteratorExcludes {
16
17 private string $_source;
18
19 public function __construct() {
20
21 }
22
23 public function setSource( $source ) {
24 $this->_source = $source;
25 }
26
27 public function ListTree($files, &$currentPosition, $skip): array {
28
29 $totalNumbers = count($files);
30 $numbersPerPage = 10;
31 $newPosition = $currentPosition + $skip;
32 $currentPosition = max(0, min($newPosition, $totalNumbers - $numbersPerPage));
33 return array_slice($files, $currentPosition, $numbersPerPage);
34
35 }
36
37
38 /**
39 * @throws Exception
40 */
41 public function ExcludeTree ($path = null): array {
42
43 $list = array();
44 $_is_windows = System::isWindowsOS();
45
46 if ($path) {
47
48 if ($_is_windows) {
49
50 $_path = explode('\\', $path);
51 $_clean_value = '';
52
53 foreach ($_path as $value) {
54
55 if (!trim($value) || $value == '') continue;
56
57 $value = ltrim(rtrim($value, '/'), '/');
58 $value = ltrim(rtrim($value, '\\'), '\\');
59
60 $_clean_value .= $value . '\\';
61
62 }
63
64 $this->_source = rtrim($_clean_value, JetBackup::SEP);
65
66 } else {
67
68 $this->_source = ltrim( rtrim( $this->_source, JetBackup::SEP ), JetBackup::SEP );
69 $path = ltrim( rtrim( $path, JetBackup::SEP ), JetBackup::SEP );
70 if ( strpos( $path, basename( $this->_source ) ) !== false ) {
71 $path = str_replace( basename( $this->_source ), '', $path );
72 }
73 $this->_source = JetBackup::SEP . $this->_source . $path;
74 }
75 }
76
77 $iterator = new DirectoryIterator($this->_source);
78 foreach ($iterator as $fileinfo) {
79 $file = array();
80
81 if ($fileinfo->isDot()) continue;
82
83 if ($fileinfo->isFile()) {
84
85 $file['icon'] = 'file';
86 $file['type'] = 'File';
87 }
88
89 if ($fileinfo->isDir()) {
90
91 $file['icon'] = 'dir';
92 $file['type'] = 'Directory';
93 }
94
95 $file['name'] = $fileinfo->getFilename();
96 $file['size'] = $fileinfo->getSize();
97 $file['created'] = (new DateTime())->setTimestamp($fileinfo->getMTime())->format('Y-m-d H:i:s');
98 $file['fullpath'] = $fileinfo->getPath();
99 $file['hash'] = md5($file['type'].'|'.$fileinfo->getPath().'|'.$fileinfo->getFilename());
100
101 $list[] = $file;
102
103 }
104
105
106 return $list;
107
108
109 }
110
111 }