File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed
Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,30 @@ private function load()
2323 }
2424 } else {
2525 $ this ->config = $ this ->getDefaultConfig ();
26+ // Index existing files in the directory
27+ $ this ->indexExistingFiles ();
28+ // Save the config with indexed files
29+ $ this ->save ();
30+ }
31+ }
32+
33+ private function indexExistingFiles ()
34+ {
35+ $ dir = ROOT .DS .'.. ' .DS .'data ' .DS .$ this ->hostname ;
36+ if (is_dir ($ dir )) {
37+ $ files = scandir ($ dir );
38+ foreach ($ files as $ file ) {
39+ if ($ file === '. ' || $ file === '.. ' || $ file === 'config.json ' ) {
40+ continue ;
41+ }
42+ $ filepath = $ dir .DS .$ file ;
43+ if (is_file ($ filepath )) {
44+ $ this ->config ['files ' ][$ file ] = [
45+ 'uploaded ' => filemtime ($ filepath ),
46+ 'size ' => filesize ($ filepath )
47+ ];
48+ }
49+ }
2650 }
2751 }
2852
@@ -116,4 +140,18 @@ public function getRetention()
116140 {
117141 return $ this ->config ['retention ' ];
118142 }
143+
144+ public function isDirectoryWritable ()
145+ {
146+ $ dir = dirname ($ this ->configPath );
147+ if (!is_dir ($ dir )) {
148+ return is_writable (dirname ($ dir ));
149+ }
150+ return is_writable ($ dir );
151+ }
152+
153+ public function getDirectoryPath ()
154+ {
155+ return dirname ($ this ->configPath );
156+ }
119157}
Original file line number Diff line number Diff line change 3636 .files-list { margin-top: 20px; }
3737 .file-item { padding: 10px; background: #f8f9fa; border-radius: 4px; margin-bottom: 5px; display: flex; justify-content: space-between; align-items: center; }
3838 .file-info { font-family: monospace; font-size: 13px; }
39+ .warning-box { background: #fff3cd; border-left: 4px solid #ffc107; color: #856404; padding: 15px; margin-bottom: 20px; border-radius: 4px; }
40+ .warning-box strong { display: block; margin-bottom: 5px; }
3941 </style>
4042</head>
4143<body>
4244 <div class="container">
45+ <?php if (!$ config ->isDirectoryWritable ()): ?>
46+ <div class="warning-box">
47+ <strong>⚠️ Warning: Directory Not Writable</strong>
48+ <p>The backup directory <code><?= htmlspecialchars ($ config ->getDirectoryPath ())?> </code> is not writable. Backups cannot be saved until this is fixed.</p>
49+ <p>Please check your file permissions and ensure the web server has write access to this directory.</p>
50+ </div>
51+ <?php endif ; ?>
52+
4353 <div class="card">
4454 <h1>Backup: <?= htmlspecialchars ($ hostname )?> </h1>
4555 <form action="/<?= htmlspecialchars ($ url [0 ])?> " class="dropzone" id="backup-dropzone" method="POST" enctype="multipart/form-data"></form>
You can’t perform that action at this time.
0 commit comments