YaWK  24.1
Yet another WebKit
settings-backup.php
Go to the documentation of this file.
1 <?php
2 use YAWK\alert;
3 use YAWK\backend;
5 use YAWK\db;
7 use YAWK\language;
8 use YAWK\sys;
9 /** @var $db db */
10 /** @var $lang language */
11 
12 // include backup class - main methods and helpers
13 require_once '../system/classes/backup.php';
14 // check if backup object is set
15 if (!isset($backup) || (empty($backup)))
16 { // create new backup object
17  $backup = new backup($db);
18 }
19 // check if GET data is set
20 if (isset($_GET))
21 { // check if delete is requested
22  if (isset($_GET['deleteBackup']) == true)
23  { // check if backup folder and backup file are set and not empty
24  if (isset($_GET['backupFolder']) && (!empty($_GET['backupFolder'])
25  && (isset($_GET['backupFile']) && (!empty($_GET['backupFile'])))))
26  {
27  // delete this backup file
28  if (is_dir($_GET['backupFolder']))
29  { // path (backup folder and file)
30  $file = $_GET['backupFolder'].$_GET['backupFile'];
31  // check if requested file is there
32  if (is_file($file))
33  { // delete file
34  if (unlink($file))
35  { // file deleted
36  sys::setSyslog($db, 50, 3, "deleted backup: $file", 0, 0, 0, 0);
37  alert::draw("success", "$lang[BACKUP_DEL_SUCCESS]", "$lang[DELETED]: $_GET[backupFile]", "", 2600);
38  }
39  else
40  { // failed to delete file
41  sys::setSyslog($db, 52, 2, "failed to delete backup: $file", 0, 0, 0, 0);
42  alert::draw("danger", "$lang[ERROR]", "$lang[BACKUP_DEL_FAILED] $_GET[backupFile]", "", 4200);
43  }
44  }
45  else
46  { // file not found - unable to delete
47  sys::setSyslog($db, 51, 1, "unable to delete backup: $file - file not found", 0, 0, 0, 0);
48  alert::draw("warning", "$lang[FILE_NOT_FOUND]", "$_GET[backupFolder]$_GET[backupFile] $lang[NOT_FOUND] $lang[FILEMAN_FILE_DOES_NOT_EXIST]", "", 6200);
49  }
50  }
51  else
52  { // backup folder not found
53  sys::setSyslog($db, 51, 1, "unable to delete backup: $_GET[backupFolder] - folder not found", 0, 0, 0, 0);
54  alert::draw("warning", "$lang[DIR_NOT_FOUND]", "$_GET[backupFolder] $lang[NOT_FOUND]", "", 6200);
55  }
56  }
57  else
58  { // backup folder or file not set
59  sys::setSyslog($db, 51, 1, "failed to delete backup: file or folder not set or not valid", 0, 0, 0, 0);
60  alert::draw("warning", "$lang[ERROR]", "$lang[FILE_FOLDER_NOT_SET]", "", 6200);
61  }
62  }
63  // check if delete archive folder is requested
64  if (isset($_GET['deleteArchiveSubFolder']) === true)
65  { // check if backup folder and backup file are set and not empty
66  if (isset($_GET['archiveSubFolder']) && (!empty($_GET['archiveSubFolder'])))
67  {
68  $backup->archiveBackupSubFolder = $_GET['archiveSubFolder'];
69  // delete this backup file
70  if (is_dir($backup->archiveBackupSubFolder))
71  { // path (backup folder and file)
72  if (filemanager::recursiveRemoveDirectory($backup->archiveBackupSubFolder) === true)
73  {
74  sys::setSyslog($db, 50, 3, "deleted complete archive: $backup->archiveBackupSubFolder", 0, 0, 0, 0);
75  alert::draw("success", "$lang[DELETED]", "$backup->archiveBackupSubFolder", "", 3200);
76  }
77  }
78  else
79  { // archive sub folder not found
80  sys::setSyslog($db, 52, 2, "failed to delete archive: $backup->archiveBackupSubFolder", 0, 0, 0, 0);
81  alert::draw("warning", "$lang[FOLDER_NOT_FOUND]", "$_GET[backupFolder] $lang[NOT_FOUND]", "", 6200);
82  }
83  }
84  else
85  { // backup folder or file not set
86  sys::setSyslog($db, 51, 1, "unable to delete archive - archive subfolder not set.", 0, 0, 0, 0);
87  alert::draw("warning", "$lang[ERROR]", "$lang[FILE_FOLDER_NOT_SET]", "", 6200);
88  }
89  }
90  // check if complete archive folder should be downloaded
91  if (isset($_GET['downloadArchive']) == true)
92  { // check if backup folder and backup file are set and not empty
93  if (isset($_GET['folder']) && (!empty($_GET['folder'])))
94  {
95  // set backup archive sub folder
96  $backup->archiveBackupSubFolder = $backup->archiveBackupFolder.$_GET['folder'];
97 
98  // zip this whole folder
99  if (is_dir($backup->archiveBackupSubFolder))
100  { // zip (backup folder and file)
101  if ($backup->zipFolder($db, $backup->archiveBackupSubFolder, $backup->downloadFolder."$_GET[folder].zip") == true)
102  { // zipped file / download requested
103  sys::setSyslog($db, 50, 0, "downloaded: $backup->downloadFolder$_GET[folder].zip", 0, 0, 0, 0);
104  alert::draw("success", $lang['BACKUP_ZIP_CREATED'], $lang['BACKUP_ZIP_CREATED_MSG'], "", 6200);
105  }
106  else
107  { // failed to zip for download
108  sys::setSyslog($db, 51, 1, "failed to zip $backup->downloadFolder$_GET[folder].zip for downloading", 0, 0, 0, 0);
109  alert::draw("danger", "$lang[ERROR]", "$_GET[folder] $lang[BACKUP_ZIP_CREATED_FAILED]", "", 6200);
110  }
111  }
112  else
113  { // archive sub folder not found
114  sys::setSyslog($db, 51, 0, "failed to download: $backup->downloadFolder$_GET[folder].zip - $backup->archiveBackupSubFolder not found.", 0, 0, 0, 0);
115  alert::draw("warning", "$lang[ERROR]", "$_GET[backupFolder] $lang[NOT_FOUND]", "", 6200);
116  }
117  }
118  else
119  { // backup folder or file not set
120  sys::setSyslog($db, 51, 0, "failed to zip download: folder or file not set", 0, 0, 0, 0);
121  alert::draw("warning", "$lang[ERROR]", "$lang[FILE_FOLDER_NOT_SET]", "", 6200);
122  }
123  }
124 
125  // check if restore is requested
126  if (isset($_GET['restore']) && ($_GET['restore'] == "true"))
127  { // check if file and folder are set
128  if (isset($_GET['file']) && (!empty($_GET['file'])
129  && (isset($_GET['folder']) && (!empty($_GET['folder'])))))
130  {
131  // strip html + script tags
132  $file = strip_tags($_GET['file']);
133  $folder = strip_tags($_GET['folder']);
134 
135  // start restore method
136  $restoreStatus = $backup->restore($db, $file, $folder);
137 
138  // how many elements should be restored?
139  $totalElements = count($restoreStatus);
140  // success elements counter
141  $successElements = 0;
142  // failed elements counter
143  $failedElements = 0;
144 
145  // init status text variable (will be displayed in the success / error alert box)
146  $status = "<br><br>";
147  // success | danger css class
148  $alertClass = "";
149  // SUCCESS | ERROR language tag
150  $langTag = "";
151  // custom alert text
152  $alertText = "";
153 
154  // walk through restore status array
155  foreach ($restoreStatus as $value)
156  { // foreach element
157  foreach ($value as $element => $folder)
158  { // add element to status text
159  $status .= "<i>&nbsp;&nbsp;".$element."&nbsp;&nbsp;";
160  // check state for each folder
161  foreach ($folder as $state)
162  {
163  // set vars if state is true
164  if ($state === "true")
165  {
166  $icon = "<i class=\"fa fa-check\"></i>";
167  $alertClass = "success";
168  $alertText = $lang['BACKUP_RESTORE_SUCCESS'];
169  $successElements++;
170  }
171  else
172  { // set vars if state is false
173  $icon = "<i class=\"fa fa-times\"></i>";
174  $alertClass = "danger";
175  $alertText = $restoreStatus['ERROR'];
176  $failedElements++;
177  }
178  $status .= $icon."</i><br>";
179  }
180  }
181  }
182 
183  // all elements processed successful
184  if ($totalElements == $successElements)
185  { // restore successful
186  sys::setSyslog($db, 50, 3, "successfully restored $successElements of $totalElements from $_GET[folder]$file", 0, 0, 0, 0);
187  alert::draw("$alertClass", "$lang[SUCCESS]", "$file $alertText $status", "", 6400);
188  }
189  else
190  { // restore failed
191  sys::setSyslog($db, 50, 3, "failed to restore $failedElements of $totalElements from $_GET[folder]$file", 0, 0, 0, 0);
192  alert::draw("$alertClass", "$lang[ERROR]", "$file $alertText $status", "", 6400);
193  }
194  }
195  }
196 }
197 
198 // check if post data is set
199 if (isset($_POST))
200 {
201  // check if action is set
202  if (isset($_POST['action']))
203  { // check which action is requested
204  switch ($_POST['action'])
205  {
206  // start backup selected
207  case "startBackup":
208  {
209  // CHECK POST SETTINGS AND SET BACKUP PROPERTIES
210  // check if backup method is set
211  if (isset($_POST['backupMethod']) && (!empty($_POST['backupMethod'])))
212  { // set backup method property depending on select field
213  $backup->backupMethod = $_POST['backupMethod'];
214  }
215 
216  // check if zip is enabled
217  if (isset($_POST['zipBackup']) && (!empty($_POST['zipBackup'])))
218  { // zip backup to true (checkbox is checked)
219  $backup->zipBackup = $_POST['zipBackup'];
220  }
221  else
222  { // zip backup disabled - checkbox not checked
223  // $backup->zipBackup = false;
224 
225  // ALWAYS ZIP (toggle switch is removed for now, see line ~575)
226  $backup->zipBackup = true;
227  }
228 
229  // should files be removed after backup (save .zip file only)
230  if (isset($_POST['removeAfterZip']) && (!empty($_POST['removeAfterZip'])))
231  { // set backup method property depending on select field
232  $backup->removeAfterZip = $_POST['removeAfterZip'];
233  }
234  else
235  { // remove files after zip disabled
236  $backup->removeAfterZip = "false";
237  }
238 
239  // check if overwrite backup is allowed
240  if (isset($_POST['overwriteBackup']) && (!empty($_POST['overwriteBackup'])))
241  { // set backup method property depending on select field
242  if ($_POST['overwriteBackup'] == "true")
243  { // set overwrite backup property
244  $backup->overwriteBackup = $_POST['overwriteBackup'];
245  }
246  else
247  { // false means backup will be saved in archive
248  $backup->overwriteBackup = "false";
249  }
250  }
251 
252  // initialize backup
253  if ($backup->init($db) === true)
254  { // ok, backup successful
255  alert::draw("success", $lang['BACKUP_SUCCESSFUL'], $lang['BACKUP_SUCCESSFUL_TEXT'], "", 2600);
256  }
257  else
258  { // backup failed
259  alert::draw("danger", $lang['BACKUP_FAILED'], $lang['BACKUP_FAILED_TEXT'], "", 6400);
260  }
261  }
262  break;
263 
264  // upload a backup archive
265  case "upload":
266  {
267  // SET UPLOAD SETTINGS
268  // check if new folder was entered by user
269  if (isset($_POST['newFolder']) && (!empty($_POST['newFolder'])))
270  { // remove html tags from new folder
271  $_POST['newFolder'] = strip_tags($_POST['newFolder']);
272  // update restore folder path
273  $backup->restoreFolder = "../system/backup/archive/".$_POST['newFolder']."/";
274  // try to create new directory
275  if (!mkdir($backup->restoreFolder))
276  { // failed to create archive sub folder
277  sys::setSyslog($db, 51, 1, "failed to upload - unable to create $backup->restoreFolder", 0, 0, 0, 0);
278  alert::draw("success", $lang['ERROR'], "$backup->restoreFolder $lang[WAS_NOT_CREATED]", "", 2600);
279  }
280  }
281 
282  // check if existing folder was selected by user
283  else if (isset($_POST['selectFolder']) && (!empty($_POST['selectFolder'])))
284  { // set archive sub foder path
285  $backup->restoreFolder = $_POST['selectFolder'];
286  }
287  else
288  { // no folder was selected - throw error msg
289  sys::setSyslog($db, 51, 1, "failed to upload - no folder was set", 0, 0, 0, 0);
290  alert::draw("danger", $_POST['file'], $lang['BACKUP_NO_FOLDER_SELECTED'], "", 6400);
291  }
292 
293  // check if restore folder is writeable
294  if (!is_writeable(dirname($backup->restoreFolder)))
295  { // if not, throw alert message
296  sys::setSyslog($db, 51, 1, "failed to upload - restore folder $backup->restoreFolder is not writeable. Please check folder permissions", 0, 0, 0, 0);
297  alert::draw("danger", $lang['BACKUP_FAILED'], $lang['BACKUP_FAILED_WRITE_FOLDER'], "", 6400);
298  }
299 
300  // set target file name
301  $backup->restoreFile = $backup->restoreFolder . basename($_FILES['backupFile']['name']);
302  $maxFileSize = filemanager::getUploadMaxFilesize();
303  $postMaxSize = filemanager::getPostMaxSize();
304 
305  // check file size
306  if ($_FILES["backupFile"]["size"] > $maxFileSize || $postMaxSize)
307  {
308  // calculate and filter current filesize
309  $currentFileSize = filemanager::sizeFilter($_FILES["backupFile"]["size"], 2);
310  // file is too large
311  sys::setSyslog($db, 51, 1, "failed to upload - $backup->restoreFile ($currentFileSize) exceeeds post_max_size: $postMaxSize upload_max_filesize: $maxFileSize", 0, 0, 0, 0);
312  echo alert::draw("warning", "$lang[ERROR]", "$lang[FILE_UPLOAD_TOO_LARGE]","","4800");
313  }
314 
315  // check if file type is ZIP
316  if ($_FILES['backupFile']['type'] !== 'application/x-zip-compressed')
317  { // if not, throw alert
318  sys::setSyslog($db, 51, 1, "failed to upload - $backup->restoreFile is not a zip - uploaded filetype: $_FILES[backupFile][type]", 0, 0, 0, 0);
319  alert::draw("danger", $lang['BACKUP_FAILED'], $lang['BACKUP_NOT_A_ZIP_FILE'], "", 6400);
320  }
321 
322  // check if file extension is zip (or similar)
323  $fileType = pathinfo($backup->restoreFile,PATHINFO_EXTENSION);
324  if($fileType != "zip" && $fileType != "ZIP" && $fileType != "7z" && $fileType != "gzip")
325  {
326  sys::setSyslog($db, 51, 1, "failed to upload file - extension $fileType seems not to be a zip file", 0, 0, 0, 0);
327  echo alert::draw("warning", "$lang[ERROR]", "$lang[UPLOAD_ONLY_ZIP_ALLOWED]","","4800");
328  }
329 
330  // check for errors
331  if ($_FILES['backupFile']['error'] !== 0)
332  { // unknown error - upload failed
333  sys::setSyslog($db, 52, 2, "failed to upload file - unknown error ($_FILES[backupFile][error]) processing file $_FILES[backupFile][name]", 0, 0, 0, 0);
334  echo alert::draw("warning", "$lang[ERROR]", "$lang[FILE_UPLOAD_FAILED]","","4800");
335  }
336  else
337  { // try to move uploaded file
338  if (!move_uploaded_file($_FILES["backupFile"]["tmp_name"], $backup->restoreFile))
339  { // throw error msg
340  sys::setSyslog($db, 52, 2, "failed to move upload file $backup->restoreFile to folder $_FILES[backupFile][tmp_name]", 0, 0, 0, 0);
341  echo alert::draw("danger", "$lang[ERROR]", "$backup->restoreFile - $lang[FILE_UPLOAD_ERROR]","","4800");
342  }
343  else
344  { // file upload seem to be successful...
345  // check if uploaded file is there
346  if (is_file($backup->restoreFile))
347  {
348  // here we could check more things - eg latest file timestamp
349  // throw success message
350  sys::setSyslog($db, 50, 3, "uploaded backup package $backup->restoreFile successfully", 0, 0, 0, 0);
351  echo alert::draw("success", "$lang[UPLOAD_SUCCESSFUL]", "$backup->restoreFile $lang[BACKUP_UPLOAD_SUCCESS]","","4800");
352  }
353  else
354  { // failed to check uploaded file - file not found
355  sys::setSyslog($db, 51, 2, "failed to check uploaded file - $backup->restoreFile not found.", 0, 0, 0, 0);
356  echo alert::draw("danger", "$lang[ERROR]", "$backup->restoreFile - $lang[FILE_UPLOAD_ERROR]","","4800");
357  }
358  }
359  }
360  // restore a backup from file
361  }
362  break;
363 
364  // move backup to archive
365  case "moveToArchive":
366  {
367  // check if filename was sent
368  if (isset($_POST['file']) && (!empty($_POST['file'])))
369  {
370  // check if new folder was entered by user
371  if (isset($_POST['newFolder']) && (!empty($_POST['newFolder'])))
372  {
373  // create new archive sub folder path
374  $backup->archiveBackupSubFolder = $backup->archiveBackupFolder.$_POST['newFolder']."/";
375  // create new directory in archive
376  if (!is_dir(dirname($backup->archiveBackupSubFolder)))
377  {
378  if (mkdir($backup->archiveBackupSubFolder))
379  { // all good, new archive subfolder created
380  alert::draw("success", $_POST['file'], "$backup->archiveBackupSubFolder $lang[CREATED]", "", 2600);
381  }
382  else
383  { // failed to create new archive subfolder
384  sys::setSyslog($db, 51, 2, "failed to create new archive subfolder $backup->archiveBackupSubFolder", 0, 0, 0, 0);
385  alert::draw("danger", $_POST['file'], "$backup->archiveBackupSubFolder $lang[WAS_NOT_CREATED]", "", 6400);
386  }
387  }
388  }
389  // check if existing folder was selected by user
390  else if (isset($_POST['selectFolder']) && (!empty($_POST['selectFolder'])))
391  { // set archive sub foder path
392  $backup->archiveBackupSubFolder = $backup->archiveBackupFolder.$_POST['selectFolder']."/";
393  }
394  else
395  { // no folder was selected - throw error msg
396  sys::setSyslog($db, 50, 0, "failed to move backup to archive folder: $backup->archiveBackupSubFolder - no folder was selected", 0, 0, 0, 0);
397  alert::draw("danger", $_POST['file'], $lang['BACKUP_NO_FOLDER_SELECTED'], "", 6400);
398  }
399 
400  // prepare backup move to archive...
401  // old file
402  $backup->archiveBackupFile = $backup->currentBackupFolder.$_POST['file'];
403  // new file
404  $backup->archiveBackupNewFile = $backup->archiveBackupSubFolder.$_POST['file'];
405  // check if file can be moved
406  if (file_exists($backup->archiveBackupFile)
407  && ((!file_exists($backup->archiveBackupNewFile)) || is_writable($backup->archiveBackupNewFile)))
408  {
409  if (rename($backup->archiveBackupFile, $backup->archiveBackupNewFile))
410  { // success
411  sys::setSyslog($db, 50, 0, "archive backup: $backup->archiveBackupFile to $backup->archiveBackupNewFile successful", 0, 0, 0, 0);
412  alert::draw("success", $_POST['file'], $backup->archiveBackupNewFile, "", 2600);
413  }
414  else
415  { // error: throw msg
416  sys::setSyslog($db, 52, 2, "failed to move backup to archive: $backup->archiveBackupFile to $backup->archiveBackupNewFile", 0, 0, 0, 0);
417  alert::draw("danger", $_POST['file'], "$lang[BACKUP_FAILED_TO_MOVE] $backup->archiveBackupFile $lang[MOVE_TO] $backup->archiveBackupNewFile", "", 6400);
418  }
419  }
420  else
421  {
422  sys::setSyslog($db, 52, 2, "failed to move backup to archive because backup file is missing or not writeable $backup->archiveBackupNewFile", 0, 0, 0, 0);
423  alert::draw("warning", $_POST['file'], "$lang[BACKUP_FAILED_TO_MOVE] $backup->archiveBackupNewFile $lang[BACKUP_FAILED_TO_MOVE_CHMOD]", "", 6400);
424  }
425  }
426  else
427  {
428  // no file was clicked - failed to select any file
429  sys::setSyslog($db, 52, 2, "failed to move backup to archive: no file selected - this should not be possible.", 0, 0, 0, 0);
430  alert::draw("danger", "$lang[BACKUP_NO_FILE_SELECTED]", "$lang[BACKUP_NO_FILE_SELECTED]", "", 6400);
431  }
432  }
433  break;
434  }
435  }
436 }
437 ?>
438 <script type="text/javascript">
439  $(document).ready(function()
440  {
441 
442  $('[data-toggle="tooltip"]').tooltip();
443 
444  // TRY TO DISABLE CTRL-S browser hotkey
445  function saveHotkey() {
446  // simply disables save event for chrome
447  $(window).keypress(function (event) {
448  if (!(event.which === 115 && (navigator.platform.match("Mac") ? event.metaKey : event.ctrlKey)) && !(event.which === 19)) return true;
449  event.preventDefault();
450  formmodified=0; // do not warn user, just save.
451  return false;
452  });
453  // used to process the cmd+s and ctrl+s events
454  $(document).keydown(function (event) {
455  if (event.which === 83 && (navigator.platform.match("Mac") ? event.metaKey : event.ctrlKey)) {
456  event.preventDefault();
457  $('#savebutton').click(); // SAVE FORM AFTER PRESSING STRG-S hotkey
458  formmodified=0; // do not warn user, just save.
459  // save(event);
460  return false;
461  }
462  });
463  }
464  saveHotkey();
465 
466  // ok, lets go...
467  // we need to check if user clicked on save button
468  $(savebutton).click(function() {
469  // add loading indicator to give the user feedback as long as his backup is processing
470  var savebutton = ('#savebutton');
471  var savebuttonIcon = ('#savebuttonIcon');
472  var savebuttonText = $('#savebuttonText');
473  var processingText = $(savebutton).attr("data-processingText");
474  var savebuttonTitle = $(savebutton).attr("data-processingTitle");
475 
476  // add some animation and disable the button to prevent nervous user actions...
477  $(savebutton).removeClass('btn btn-success').addClass('btn btn-warning disabled').attr('title', savebuttonTitle);
478  $(savebuttonText).html(processingText);
479  $(savebuttonIcon).removeClass('fa fa-check').addClass('fa fa-spinner fa-spin fa-fw');
480  $(document.body).css( 'cursor', 'wait' );
481  });
482 
483  // EXTENDED SETTINGS
484  // required checkboxes are grouped to improve usability of 'custom backup' method.
485  // grouping of toggle switches allows users to enable or disable a whole category.
486  // this piece of js manage the toggle switches on custom backup form
487 
488  // CONTENT TOGGLE SWITCH
489  $('#contentCheckAll').change(function() {
490  // get all checkboxes of this group
491  $('.checkbox-group-content').each(function() {
492  // toggle checkbox group
493  $(this).find('input[type="checkbox"]').each(function () { this.checked = !this.checked; });
494  });
495  });
496 
497  // MEDIA TOGGLE SWITCH
498  $('#mediaCheckAll').change(function() {
499  // get all checkboxes of this group
500  $('.checkbox-group-media').each(function() {
501  // toggle checkbox group
502  $(this).find('input[type="checkbox"]').each(function () { this.checked = !this.checked; });
503  });
504  });
505 
506  // SYSTEM TOGGLE
507  $('#systemFolderCheckAll').change(function() {
508  // get all checkboxes of this group
509  $('.checkbox-group-system').each(function() {
510  // toggle checkbox group
511  $(this).find('input[type="checkbox"]').each(function () { this.checked = !this.checked; });
512  });
513  });
514 
515  // DATABASE TOGGLE
516  $('#databaseCheckAll').change(function() {
517  // get all checkboxes of this group
518  $('.checkbox-group-database').each(function() {
519  // toggle checkbox group
520  $(this).find('input[type="checkbox"]').each(function () { this.checked = !this.checked; });
521  });
522  });
523 
524  // check overwrite backup switch
525  $('#overwriteBackup').on('change', function()
526  { // set switch + label vars
527  var overwriteBackupSwitch = $('#overwriteBackup');
528  var overwriteBackupLabel = $('#overwriteBackupLabel');
529  var overwriteLabelTextOn = $(overwriteBackupSwitch).attr("data-overwriteOn");
530  var overwriteLabelTextOff = $(overwriteBackupSwitch).attr("data-overwriteOff");
531  var newFolder = $('#newFolder');
532  var selectFolder = $('#selectFolder');
533  var backupHelpOngoingBox = $('#backupHelp-ongoing');
534  var backupHelpArchiveBox = $('#backupHelp-archive');
535 
536  // check if overwrite switch is on
537  if ($(overwriteBackupSwitch).is(':checked'))
538  { // set ON label text (overwrite current backup)
539  $(overwriteBackupSwitch).val('true');
540  $(overwriteBackupLabel).text(overwriteLabelTextOn);
541  $('#archiveGroup').fadeOut();
542 
543  // set ongoing help
544  $(backupHelpOngoingBox).removeClass('hidden').addClass('fadeIn');
545  $(backupHelpArchiveBox).addClass('hidden');
546  }
547  else
548  { // set OFF label text (save to archive)
549  $(overwriteBackupSwitch).val('false');
550  $(overwriteBackupLabel).text(overwriteLabelTextOff);
551  $('#archiveGroup').fadeIn().removeClass('hidden');
552  $(backupHelpOngoingBox).removeClass('hidden').addClass('fadeIn');
553 
554  // set archive help
555  $(backupHelpArchiveBox).removeClass('hidden').addClass('fadeIn');
556  $(backupHelpOngoingBox).addClass('hidden');
557 
558  // if text input field has focus
559  $(newFolder).focus(function() {
560  // select first option (please select....) to improve usability
561  $(selectFolder).prop("selectedIndex", 0);
562  });
563 
564  // if selectfolder changes...
565  $(selectFolder).on('change', function() {
566  // set newFolder text input field value to empty
567  $(newFolder).val('');
568  });
569  }
570 
571  });
572 
573  // check if pulldown (select field) has changed (any item has been selected)
574  // and display additional according backup settings
575  $("#backupMethod").on('change', function() {
576  // backup method (from select field)
577  var backupMethod = this.value;
578  // content div box
579  var contentBox = $('#contentBox');
580  // mediaFolder div box
581  var mediaBox = $('#mediaBox');
582  // systemFolder div box
583  var systemBox = $('#systemBox');
584  // database div box
585  var databaseBox = $('#databaseBox');
586  // custom settings div box
587  var customSettings = $('#customSettings');
588 
589  // user selected complete backup method
590  if (backupMethod === "complete")
591  {
592  // enable all form fields
593  $(contentBox).find('input, button').removeAttr("disabled");
594  $(mediaBox).find('input, button').removeAttr("disabled");
595  $(systemBox).find('input, button').removeAttr("disabled");
596  $(databaseBox).find('input, button').removeAttr("disabled");
597 
598  // fadeIn all form fields
599  $(contentBox).fadeIn();
600  $(mediaBox).fadeIn();
601  $(systemBox).fadeIn();
602  $(databaseBox).fadeIn();
603  // fadeIn custom settings form
604  $(customSettings).fadeIn().removeClass('hidden');
605  }
606 
607  // user selected database backup method
608  if (backupMethod === "database")
609  {
610  // DATABASE FIELDS NEEDED - set form
611  // disable not needed form fields
612  $(contentBox).find('input, button').attr('disabled','disabled');
613  $(mediaBox).find('input, button').attr('disabled','disabled');
614  $(systemBox).find('input, button').attr('disabled','disabled');
615  // hide not needed form fields
616  $(contentBox).hide();
617  $(systemBox).hide();
618  $(mediaBox).hide();
619 
620  // enable database form fields
621  $(databaseBox).find('input, button').removeAttr('disabled');
622  // fadeIn database box
623  $(databaseBox).fadeIn();
624  // fadeIn settings form
625  $(customSettings).fadeIn().removeClass('hidden');
626 
627  }
628 
629  // user selected file backup method
630  if (backupMethod === "mediaFolder")
631  {
632  // MEDIA FOLDER NEEDED - set form
633  // disable not needed fields
634  $(contentBox).find('input, button').attr('disabled','disabled');
635  $(systemBox).find('input, button').attr('disabled','disabled');
636  $(databaseBox).find('input, button').attr('disabled','disabled');
637 
638  // hide not needed form fields
639  $(contentBox).hide();
640  $(systemBox).hide();
641  $(databaseBox).hide();
642 
643  // enable media form fields
644  $(mediaBox).find('input, button').removeAttr('disabled');
645  // fadeIn mediaFolder form fields
646  $(mediaBox).fadeIn();
647  // fadeIn settings form
648  $(customSettings).fadeIn().removeClass('hidden');
649  }
650 
651  // user selected file backup method
652  if (backupMethod === "custom")
653  {
654  // enable all form fields
655  $(contentBox).find('input, button').removeAttr("disabled");
656  $(mediaBox).find('input, button').removeAttr("disabled");
657  $(systemBox).find('input, button').removeAttr("disabled");
658  $(databaseBox).find('input, button').removeAttr("disabled");
659 
660  // fadeIn all divs
661  $(contentBox).fadeIn();
662  $(mediaBox).fadeIn();
663  $(systemBox).fadeIn();
664  $(databaseBox).fadeIn();
665 
666  // display form field
667  $(customSettings).fadeIn().removeClass('hidden');
668  }
669  });
670 
671  // MODAL 'move to archive' WINDOW:
672  // to archive a file, a modal window is used.
673  // this checks, if modal window is currently shown
674  $('#myModal').on('show.bs.modal', function(e) {
675  // if so, get the according file by read the data-file value
676  var file = e.relatedTarget.dataset.file;
677  var newFolderModal = $("#newFolderModal");
678  var selectFolderModal = $("#selectFolderModal");
679  // update hidden field in modal window with current file value
680  $("#file").val(file);
681 
682  // if text input field has focus
683  $(newFolderModal).focus(function() {
684  // select first option (please select....) to improve usability
685  $(selectFolderModal).prop("selectedIndex", 0);
686  });
687 
688  // if selectfolder changes...
689  $(selectFolderModal).on('change', function() {
690  // set newFolder text input field value to empty
691  $(newFolderModal).val('');
692  });
693  });
694 
695  // MODAL 'RESTORE (upload) FILE' WINDOW:
696  // to archive a file, a modal window is used.
697  // this checks, if modal window is currently shown
698  $('#restoreModal').on('show.bs.modal', function(e) {
699  // if so, get the according file by read the data-file value
700  var file = e.relatedTarget.dataset.file;
701  var newFolderModal = $("#newFolderModal2");
702  var selectFolderModal = $("#selectFolderModal2");
703  // update hidden field in modal window with current file value
704  $("#file").val(file);
705 
706  // if text input field has focus
707  $(newFolderModal).focus(function() {
708  // select first option (please select....) to improve usability
709  $(selectFolderModal).prop("selectedIndex", 0);
710  });
711 
712  // if selectfolder changes...
713  $(selectFolderModal).on('change', function() {
714  // set newFolder text input field value to empty
715  $(newFolderModal).val('');
716  });
717  });
718  });
719 </script>
720 <?php
721 // TEMPLATE WRAPPER - HEADER & breadcrumbs
722 echo "
723  <!-- Content Wrapper. Contains page content -->
724  <div class=\"content-wrapper\" id=\"content-FX\">
725  <!-- Content Header (Page header) -->
726  <section class=\"content-header\">";
727 /* draw Title on top */
728 echo backend::getTitle($lang['BACKUP'], $lang['BACKUP_SUBTEXT']);
729 echo"<ol class=\"breadcrumb\">
730  <li><a href=\"index.php\" title=\"$lang[DASHBOARD]\"><i class=\"fa fa-dashboard\"></i> $lang[DASHBOARD]</a></li>
731  <li class=\"active\"><a href=\"index.php?page=settings-backup\" title=\"$lang[BACKUP]\"> $lang[BACKUP]</a></li>
732  </ol>
733  </section>
734  <!-- Main content -->
735  <section class=\"content\">";
736 /* page content start here */
737 ?>
738 <div class="row" id="pageBody">
739 <div class="col-md-6">
740  <form name="backup" action="index.php?page=settings-backup&action=startBackup" method="POST">
741  <div class="box">
742  <div class="box-header">
743  <h3 class="box-title">
744  <?php echo $lang['BACKUP_CREATE']; ?>
745  </h3>
746  </div>
747  <div class="box-body">
748  <input type="hidden" name="action" value="startBackup">
749  <button type="submit"
750  class="btn btn-success pull-right"
751  id="savebutton"
752  data-processingText="<?php echo $lang['BACKUP_PROCESSING']; ?>"
753  data-processingTitle="<?php echo $lang['BACKUP_PROCESSING_TITLE']; ?>"
754  data-restoreText="<?php echo $lang['BACKUP_RESTORE_TEXT']; ?>"
755  data-restoreTitle="<?php echo $lang['BACKUP_RESTORE_TITLE']; ?>">
756  <i class="fa fa-check" id="savebuttonIcon"></i> &nbsp;
757  <span id="savebuttonText"><?php echo $lang['BACKUP_CREATE']; ?></span>
758  </button>
759  <br><br>
760  <label for="backupMethod"><?php echo $lang['BACKUP_WHAT_TO_BACKUP']; ?></label>
761  <select name="backupMethod" id="backupMethod" class="form-control">
762  <optgroup label="<?php echo $lang['STANDARD']; ?>"></optgroup>
763  <option name="complete" value="complete">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $lang['BACKUP_FULL']; ?></option>
764  <option name="database" value="database">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $lang['BACKUP_DB_ONLY']; ?></option>
765  <option name="mediaFolder" value="mediaFolder">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $lang['BACKUP_FILES_ONLY']; ?></option>
766  <optgroup label="<?php echo $lang['CUSTOM']; ?>"></optgroup>
767  <option name="custom" value="custom">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $lang['BACKUP_CUSTOM']; ?></option>
768  </select>
769 
770  <div class="row">
771  <div class="col-md-6">
772  <br><br>
773  <input type="hidden" class="hidden" name="overwriteBackup" id="overwriteBackupHidden" value="false">
774  <input type="checkbox" data-on="<i class='fa fa-refresh'>" data-off="<i class='fa fa-archive'>" data-overwriteOff="<?php echo $lang['BACKUP_OVERWRITE_OFF']; ?>" data-overwriteOn="<?php echo $lang['BACKUP_OVERWRITE_ON']; ?>" data-toggle="toggle" data-onstyle="success" data-offstyle="success" class="checkbox" name="overwriteBackup" id="overwriteBackup" value="true" checked>
775  &nbsp;&nbsp;<label for="overwriteBackup" id="overwriteBackupLabel"><?php echo $lang['BACKUP_OVERWRITE_ON']; ?>&nbsp;&nbsp;</label>
776  <br><br>
777  <div id="archiveGroup" class="hidden">
778  <?php
779  // archive backup folders
780  $backup->archiveBackupSubFolders = filemanager::getSubfoldersToArray($backup->archiveBackupFolder);
781  // if any folder is there, draw a select field to choose from
782  if (count($backup->archiveBackupSubFolders) > 0)
783  {
784  echo "
785  <label for=\"selectFolder\">$lang[BACKUP_FOLDER_SELECT]</label>
786  <select class=\"form-control\" name=\"selectFolder\" id=\"selectFolder\">
787  <option label=\"$lang[BACKUP_PLEASE_SELECT]\"></option>";
788  foreach ($backup->archiveBackupSubFolders as $subFolder)
789  {
790  echo "<option value=\"$subFolder\">$subFolder</option>";
791  }
792 
793  echo"</select>
794  <div class=\"text-center\"><br><i>$lang[OR]</i><br><br></div>";
795  }
796  // otherwise draw text input field to create a folder
797  ?>
798  <label for="newFolder"><?php echo $lang['BACKUP_FOLDER_NAME']; ?></label>
799  <input type="text" id="newFolder" name="newFolder" class="form-control">
800  <br>
801  </div>
802 
803  </div>
804  <div class="col-md-6">
805  <br><br>
806  <div id="backupHelp-ongoing">
807  <b><?php echo $lang['BACKUP_HELP_ONGOING_TITLE']; ?></b><br>
808  <?php echo $lang['BACKUP_HELP_ONGOING_TEXT']; ?>
809  </div>
810  <div id="backupHelp-archive" class="hidden">
811  <b><?php echo $lang['BACKUP_HELP_ARCHIVE_TITLE']; ?></b><br>
812  <?php echo $lang['BACKUP_HELP_ARCHIVE_TEXT']; ?>
813  </div>
814 
815  </div>
816  </div>
817  </div>
818  </div>
819  <div class="box hidden" id="customSettings">
820  <div class="box-header">
821  <h3 class="box-title">
822  <?php echo $lang['EXTENDED_SETTINGS']; ?>
823  </h3>
824  </div>
825  <div class="box-body">
826  <div>
827  <div id="contentBox">
828  <h3>
829  <input type="checkbox" data-on="<i class='fa fa-file-o'></i>" data-off="<?php echo $lang['OFF_']; ?>" data-toggle="toggle" data-onstyle="success" data-offstyle="danger" class="checkbox" name="contentCheckAll" id="contentCheckAll" value="true" checked>
830  <label for="contentCheckAll" id="contentCheckAllLabel"> <?php echo $lang['PAGES']; ?></label>
831  </h3>
832  <div class="checkbox-group-content">
833  <?php
834  // get content folder + subfolders into array
835  $contentFolderArray = filemanager::getSubfoldersToArray('../content/');
836  // walk through folders and draw checkboxes
838  {
839  echo "&nbsp;&nbsp;&nbsp;&nbsp;
840  <input type=\"checkbox\" data-name=\"$folder\" id=\"contentFolder-$folder\" name=\"contentFolder[]\" checked=\"checked\" value=\"$folder\">
841  <label id=\"contentFolderLabel-$folder\" for=\"contentFolder-$folder\">".ucfirst($folder)."</label><br>";
842  }
843  ?>
844  </div>
845  </div>
846  <div id="mediaBox">
847  <h3>
848  <input type="checkbox" data-on="<i class='fa fa-folder-open-o'></i>" data-off="<?php echo $lang['OFF_']; ?>" data-toggle="toggle" data-onstyle="success" data-offstyle="danger" class="checkbox" name="mediaCheckAll" id="mediaCheckAll" value="true" checked>
849  <label for="mediaCheckAll" id="mediaCheckAllLabel"> <?php echo $lang['BACKUP_MEDIA_FOLDER']; ?></label>
850  </h3>
851  <div class="checkbox-group-media">
852  <?php
853  // get media folder + subfolders into array
854  $mediaFolderArray = filemanager::getSubfoldersToArray('../media/');
855  // walk through folders and draw checkboxes
856  foreach ($mediaFolderArray as $folder)
857  {
858  echo "&nbsp;&nbsp;&nbsp;&nbsp;
859  <input type=\"checkbox\" data-name=\"$folder\" id=\"mediaFolder-$folder\" name=\"mediaFolder[]\" checked=\"checked\" value=\"$folder\">
860  <label id=\"mediaFolderLabel-$folder\" for=\"mediaFolder-$folder\">".ucfirst($folder)."</label><br>";
861  }
862  ?>
863  </div>
864  </div>
865  <div id="systemBox">
866  <h3>
867  <input type="checkbox" data-on="<i class='fa fa-gears'></i>" data-off="<?php echo $lang['OFF_']; ?>" data-toggle="toggle" data-onstyle="success" data-offstyle="danger" class="checkbox" name="systemFolderCheckAll" id="systemFolderCheckAll" value="true" checked="checked">
868  <label for="systemFolderCheckAll" id="systemFolderCheckAllLabel"> <?php echo $lang['SYSTEM']; ?></label>
869  </h3>
870  <div class="checkbox-group-system">
871  <?php
872  // get database tables
873  $systemFolders = array('fonts', 'language', 'plugins', 'templates', 'widgets');
874  foreach ($systemFolders AS $folder)
875  {
876  echo "&nbsp;&nbsp;&nbsp;&nbsp;
877  <input type=\"checkbox\" id=\"systemFolder-$folder\" value=\"$folder\" name=\"systemFolder[]\" checked>
878  <label id=\"systemFolderLabel-$folder\" for=\"systemFolder-$folder\">".ucfirst($folder)."</label><br>";
879  }
880  ?>
881  </div>
882  </div>
883 
884  <div id="databaseBox">
885  <h3>
886  <input type="checkbox" data-on="<i class='fa fa-database'></i>" data-off="<?php echo $lang['OFF_']; ?>" data-toggle="toggle" data-onstyle="success" data-offstyle="danger" class="checkbox" name="databaseCheckAll" id="databaseCheckAll" value="true" checked="checked">
887  <label for="databaseCheckAll" id="databaseCheckAllLabel"> <?php echo $lang['DATABASE']; ?></label>
888  </h3>
889  <div class="checkbox-group-database">
890  <?php
891  // get database tables
892  $dbTables = $db->get_tables();
893  foreach ($dbTables AS $id=>$table)
894  {
895  echo "&nbsp;&nbsp;&nbsp;&nbsp;
896  <input type=\"checkbox\" id=\"database-$table\" value=\"$table\" name=\"database[]\" checked>
897  <label id=\"databaseLabel-$table\" for=\"database-$table\">$table</label><br>";
898  }
899  ?>
900  </div>
901  </div>
902  </div>
903  </div>
904  <br><br>
905  </div>
906  </form>
907 </div>
908 <div class="col-md-6">
909 
910 <!-- CURRENT BACKUP BOX -->
911  <div class="box">
912  <div class="box-header">
913  <h3 class="box-title"><?php echo $lang['BACKUP_ONGOING']; ?> <small>system/backup/current/</small></h3>
914  </div>
915  <div class="box-body">
916  <table class="table table-striped table-hover table-responsive">
917  <?php
918  // get all current files into array
919  $currentFiles = $backup->getCurrentBackupFilesArray();
920  // set ID for spinning restore Icon
922 
923  foreach ($currentFiles as $file)
924  {
925  // get current path (folder and file)
926  $currentFile = "$backup->currentBackupFolder$file";
927  // get date of current file
928  $currentFileDate = date("F d Y H:i", filemtime($currentFile));
929  // get month of current file
930  $month = date("F", filemtime($currentFile));
931  // get year of current file
932  $year = date("Y", filemtime($currentFile));
933  // get file size of current backup file
934  $currentFileSize = filemanager::sizeFilter(filesize($currentFile), 0);
935 
936  // calculate how long it is ago...
937  $ago = sys::time_ago($currentFileDate, $lang);
938 
940 
941  echo "
942  <tr>
943  <td style=\"10%;\" class=\"text-center\"><h4><i id=\"zipIcon$currentRestoreID\" class=\"fa fa-file-zip-o\"></i><br><small>$month<br>$year</small></h4></td>
944  <td style=\"51%;\" class=\"text-left\"><h4><a href=\"$backup->currentBackupFolder$file\">$file</a><br><small><b>$currentFileDate</b><br><i>($ago)</i></small></h4></td>
945  <td style=\"12%;\" class=\"text-right\"><br><small><b>$currentFileSize</b></small></td>
946  <td style=\"27%;\" class=\"text-right\">
947  <br>
948 
949  <a href=\"$backup->currentBackupFolder$file\" title=\"$lang[TO_DOWNLOAD]\"><i class=\"fa fa-download\"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;
950  <a title=\"$lang[BACKUP_RESTORE_QUESTION_TITLE]\" data-cancelBtnText=\"$lang[CANCEL]\" data-okBtnText=\"$lang[BACKUP_RESTORE]\" data-icon=\"fa fa-history\" data-title=\"$lang[BACKUP_RESTORE_QUESTION]\" id=\"restoreCurrent$currentRestoreID\" data-restoreID=\"$currentRestoreID\" data-location=\"archive\" href=\"index.php?page=settings-backup&restore=true&folder=$backup->currentBackupFolder&file=$file&currentRestoreID=$currentRestoreID\"><i id=\"restoreCurrentIcon$currentRestoreID\" class=\"fa fa-history\"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;
951  <a href=\"#\" data-file=\"$file\" data-toggle=\"modal\" data-target=\"#myModal\" title=\"$lang[BACKUP_MOVE_TO_ARCHIVE]\"><i class=\"fa fa-archive\"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;
952  <a class=\"fa fa-trash-o\" role=\"dialog\" data-confirm=\"$backup->currentBackupFolder$file ".$lang['DELETE']."? - $lang[BEWARE] $lang[UNDO_NOT_POSSIBLE]!\" title=\"$lang[ATTENTION] $lang[BACKUP] $lang[DELETE]\" href=\"index.php?page=settings-backup&deleteBackup=true&backupFolder=$backup->currentBackupFolder&backupFile=$file\"></a>
953  </td>
954  </tr>";
955  /* JS LOOP FOR CURRENT RESTORE ICONS
956  * JS code to add click functions to each current restore icon
957  *
958  * The page loads with restore icons on by default. If any restore
959  * icon is clicked, the icon changes itself to a spinning indicator.
960  * after restore is processed, page reloads and default restore icons will be loaded.
961  *
962  * To indicate that restore is in progress and make sure it cannot be interrupted
963  * by clicking on 'create Backup', this create backup btn will be disabled and changed
964  * to btn-warning. The btn also gets another text, indicating that restore is going on.
965  * after restore is processed, page reloads and default savebutton will be loaded.
966  */
967 
968  echo "
969  <script>
970  $(document).ready(function()
971  {
972  // prepare vars
973  var selectLink = '#restoreCurrent$currentRestoreID';
974  var selector = '#restoreCurrentIcon$currentRestoreID';
975  var zipIcon = '#zipIcon$currentRestoreID'
976  var savebutton = ('#savebutton');
977  var savebuttonIcon = ('#savebuttonIcon');
978  var savebuttonText = $('#savebuttonText');
979  var processingText = $(savebutton).attr(\"data-restoreText\");
980  var savebuttonTitle = $(savebutton).attr(\"data-restoreTitle\");
981 
982  // click event for each restore icon
983  $(selectLink).click(function() {
984  // add spinner icon
985  $(zipIcon).removeClass('fa fa-file-zip-o').addClass('fa fa-spinner fa-spin fa-fw');
986  $(selector).removeClass('fa fa-history').addClass('fa fa-spinner fa-spin fa-fw');
987  // add some animation and disable the button to prevent nervous user actions
988  $(savebutton).removeClass('btn btn-success').addClass('btn btn-warning disabled').attr('title', savebuttonTitle);
989  // add spinner icon to savebutton
990  $(savebuttonIcon).removeClass('fa fa-check').addClass('fa fa-spinner fa-spin fa-fw');
991  // change savebutton text to somewhat like: 'restore in process...'
992  $(savebuttonText).html(processingText);
993  // avoid double clicks and other nervous dumbclicks
994  $(selectLink).css( 'cursor', 'wait' ).attr('title', savebuttonTitle);
995  $(document.body).css( 'cursor', 'wait' );
996  // $(selectLink).preventDefault();
997  $(savebutton).preventDefault();
998  });
999 
1000  });
1001  </script>";
1002  }
1003  ?>
1004  </table>
1005  </div>
1006  </div>
1007 
1008 <!-- ARCHIVE BACKUP BOX -->
1009  <div class="box">
1010  <div class="box-header">
1011  <h3 class="box-title"><?php echo $lang['BACKUP_ARCHIVE']; ?> <small>system/backup/archive/</small></h3>
1012  </div>
1013  <div class="box-body">
1014 
1015  <table class="table table-responsive">
1016  <?php
1017  // get all archive backup files into array
1018  $backup->archiveBackupFiles = filemanager::ritit($backup->archiveBackupFolder);
1019  // set ID for link: download whole archive
1021  // set ID for spinning restore Icon
1023  // walk through archive folder
1024  foreach ($backup->archiveBackupFiles as $folder => $files)
1025  {
1026  // set current archive subfolder
1027  $backup->archiveBackupSubFolder = "$backup->archiveBackupFolder$folder/";
1028  // last change of archive subfolder (month)
1029  $month = date("F", @filemtime($backup->archiveBackupSubFolder));
1030  // last change of archive subfolder (year)
1031  $year = date("Y", @filemtime($backup->archiveBackupSubFolder));
1032 
1033  $archiveFolderDate = date("F d Y H:i", @filemtime($backup->archiveBackupSubFolder));
1034  $lastUpdate = sys::time_ago($archiveFolderDate, $lang);
1035 
1036  $archiveID++;
1037 
1038  echo "
1039  <tr>
1040  <td style=\"10%;\" class=\"text-center\"><h4><i id=\"archiveIcon$archiveID\" class=\"fa fa-archive\"></i><br><small>$month<br>$year</small></h4></td>
1041  <td style=\"90%;\">
1042 
1043  <table class=\"table table-striped table-hover table-responsive\">
1044  <thead>
1045  <h4><i class=\"fa fa-folder-open-o\"></i> $folder <small><small><i>&nbsp;&nbsp;($lang[LAST_UPDATE] $lastUpdate)</i></small>
1046  <a class=\"fa fa-trash-o fa-2x text-gray pull-right\" role=\"dialog\" data-confirm=\"$folder ".$lang['DELETE']."? - $lang[BEWARE] $lang[UNDO_NOT_POSSIBLE]!\" title=\"$lang[ATTENTION] $lang[BACKUP_ARCHIVE] $lang[DELETE]\" href=\"index.php?page=settings-backup&deleteArchiveSubFolder=true&archiveSubFolder=$backup->archiveBackupSubFolder\"></a>
1047  <a class=\"fa fa-history fa-2x text-gray pull-right hidden\" role=\"dialog\" data-confirm=\"$folder ".$lang['DELETE']."? - $lang[BEWARE] $lang[UNDO_NOT_POSSIBLE]!\" title=\"$lang[BACKUP_ARCHIVE_RESTORE]\" href=\"index.php?page=settings-backup&deleteArchiveSubFolder=true&archiveSubFolder=$backup->archiveBackupSubFolder\"></a>
1048  <a class=\"fa fa-download fa-2x text-gray pull-right\" id=\"archive-$archiveID\" title=\"$lang[BACKUP_ARCHIVE_DOWNLOAD]\" href=\"index.php?page=settings-backup&downloadArchive=true&folder=$folder&archiveID=$archiveID\" data-archiveBackupFolder=\"$backup->archiveBackupFolder\" data-downloadFolder=\"$backup->downloadFolder\" data-folder=\"$folder\"></a>
1049  </small>
1050  </h4>
1051  </thead>";
1052 
1053  // walk through archive subfolder files
1054  foreach($files as $file => $value)
1055  {
1056  // set current archive/subfolder/file path
1057  $archiveFile = $backup->archiveBackupSubFolder.$value;
1058  // get date of current archive file
1059  $archiveFileDate = date("F d Y H:i", filemtime($archiveFile));
1060  // get archive file size
1061  $archiveFileSize = filemanager::sizeFilter(filesize($archiveFile), 0);
1062  // calculate how long it is ago...
1063  $ago = sys::time_ago($archiveFileDate, $lang);
1064 
1066 
1067  echo "
1068  <tr>
1069  <td style=\"62%;\">
1070  &nbsp;&nbsp;&nbsp;&nbsp;<small><b><a href=\"$archiveFile\">$value</a><br>&nbsp;&nbsp;&nbsp;&nbsp;
1071  <small>$archiveFileDate</small></b><small>&nbsp;&nbsp;<i>($ago)</i></small>
1072  </td>
1073  <td style=\"18%;\">
1074  <div style=\"margin-top:-10px;\" class=\"text-right\">
1075  <br><small><b>$archiveFileSize</b></small>
1076  </div>
1077  </td>
1078 
1079  <td style=\"20%;\" class=\"text-right\">
1080  <div style=\"margin-top:-10px;\"><br>
1081  <a href=\"$archiveFile\" title=\"$lang[TO_DOWNLOAD]\"><i class=\"fa fa-download\"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;
1082  <a id=\"restoreArchive$archiveRestoreID\" data-restoreID=\"$archiveRestoreID\" href=\"index.php?page=settings-backup&restore=true&folder=$backup->archiveBackupSubFolder&file=$value&archiveRestoreID=$archiveRestoreID\" title=\"$lang[BACKUP_RESTORE]\"><i id=\"restoreArchiveIcon$archiveRestoreID\" class=\"fa fa-history\"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;
1083  <a class=\"fa fa-trash-o\" role=\"dialog\" data-confirm=\"$archiveFile ".$lang['DELETE']."? - $lang[BEWARE] $lang[UNDO_NOT_POSSIBLE]!\" title=\"$lang[ATTENTION] $lang[BACKUP] $lang[DELETE]\" href=\"index.php?page=settings-backup&deleteBackup=true&backupFolder=$backup->archiveBackupSubFolder&backupFile=$value\"></a>&nbsp;&nbsp;&nbsp;
1084  </div>
1085  </td>
1086  </tr>";
1087 
1088  /* JS LOOP FOR ARCHIVE RESTORE ICONS
1089  * JS code to add click functions to each archive restore icon
1090  *
1091  * The page loads with restore icons on by default. If any restore
1092  * icon is clicked, the icon changes itself to a spinning indicator.
1093  * after restore is processed, page reloads and default restore icons will be loaded.
1094  *
1095  * To indicate that restore is in progress and make sure it cannot be interrupted
1096  * by clicking on 'create Backup', this create backup btn will be disabled and changed
1097  * to btn-warning. The btn also gets another text, indicating that restore is going on.
1098  * after restore is processed, page reloads and default savebutton will be loaded.
1099  */
1100 
1101  echo "
1102  <script>
1103  $(document).ready(function()
1104  {
1105  // prepare vars
1106  var selectLink = '#restoreArchive$archiveRestoreID';
1107  var selector = '#restoreArchiveIcon$archiveRestoreID';
1108  var archiveIcon = '#archiveIcon$archiveID'
1109  var savebutton = ('#savebutton');
1110  var savebuttonIcon = ('#savebuttonIcon');
1111  var savebuttonText = $('#savebuttonText');
1112  var processingText = $(savebutton).attr(\"data-restoreText\");
1113  var savebuttonTitle = $(savebutton).attr(\"data-restoreTitle\");
1114 
1115  // click event for each restore icon
1116  $(selector).click(function() {
1117  // add spinner icon
1118  $(archiveIcon).removeClass('fa fa-archive').addClass('fa fa-spinner fa-spin fa-fw');
1119  $(selector).removeClass('fa fa-history').addClass('fa fa-spinner fa-spin fa-fw');
1120  // add some animation and disable the button to prevent nervous user actions
1121  $(savebutton).removeClass('btn btn-success').addClass('btn btn-warning disabled').attr('title', savebuttonTitle);
1122  // add spinner icon to savebutton
1123  $(savebuttonIcon).removeClass('fa fa-check').addClass('fa fa-spinner fa-spin fa-fw');
1124  // change savebutton text to somewhat like: 'restore in process...'
1125  $(savebuttonText).html(processingText);
1126  // avoid double clicks and other nervous dumbclicks
1127  $(selectLink).css( 'cursor', 'wait' ).attr('title', savebuttonTitle);
1128  $(document.body).css( 'cursor', 'wait' );
1129  $(selectLink).preventDefault();
1130  $(savebutton).preventDefault();
1131  });
1132  });
1133  </script>";
1134  }
1135  echo"</table>
1136  </td>
1137  </tr>";
1138  } // end foreach files
1139  ?>
1140  </table>
1141  </div>
1142  </div>
1143 
1144  <!-- UPLOAD / RESTORE BACKUP -->
1145  <div class="box">
1146  <div class="box-header">
1147  <h3 class="box-title">
1148  <?php echo $lang['BACKUP_UPLOAD']." <small>".$lang['BACKUP_UPLOAD_TO_FOLDER']."</small>"; ?>
1149  </h3>
1150  </div>
1151  <div class="box-body">
1152  <button id="upload" data-toggle="modal" data-target="#restoreModal" class="btn btn-success"><i class="fa fa-upload"></i>&nbsp;&nbsp; <?php echo $lang['BACKUP_UPLOAD']; ?></button>
1153  <br><br>
1154  </div>
1155  </div>
1156 </div>
1157 </div>
1158 
1159 <!-- Modal --MOVE TO ARCHIVE-- -->
1160 <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModal2Label" aria-hidden="true">
1161  <div class="modal-dialog">
1162  <div class="modal-content">
1163  <form enctype="multipart/form-data" action="index.php?page=settings-backup&moveToArchive=true" method="POST">
1164  <div class="modal-header">
1165  <!-- modal header with close controls -->
1166  <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> </button>
1167  <br>
1168  <div class="col-md-1"><h3 class="modal-title"><i class="fa fa-archive"></i></h3></div>
1169  <div class="col-md-11"><h3 class="modal-title"><?php echo $lang['BACKUP_MOVE_TO_ARCHIVE']; ?></h3></div>
1170  </div>
1171 
1172  <!-- modal body -->
1173  <div class="modal-body">
1174  <!-- SELECT BACKUP ARCHIVE SUB FOLDER -->
1175  <?php if (isset($_GET['file'])) { echo $_GET['file']; } ?>
1176  <h4><b><?php echo $lang['BACKUP_ADD_ARCHIVE_SUBFOLDER']; ?></b></h4>
1177  <?php
1178  $backup->archiveBackupSubFolders = filemanager::getSubfoldersToArray($backup->archiveBackupFolder);
1179  if (count($backup->archiveBackupSubFolders) > 0)
1180  {
1181  echo "
1182  <label for=\"selectFolder\">$lang[BACKUP_FOLDER_SELECT]</label>
1183  <option value=\"currentFolder\" id=\"currentFolder\">Current Folder</option>
1184  <option label=\"$lang[BACKUP_PLEASE_SELECT]\" id=\"pleaseSelect\"></option>";
1185  foreach ($backup->archiveBackupSubFolders as $subFolder)
1186  {
1187  echo "<option value=\"$subFolder\">$subFolder</option>";
1188  }
1189 
1190  echo"</select>
1191  <div class=\"text-center\"><br><i>$lang[OR]</i></div>";
1192  }
1193  ?>
1194  <label for="newFolderModal"><?php echo $lang['BACKUP_FOLDER_NAME']; ?></label>
1195  <input type="text" class="form-control" id="newFolderModal" name="newFolder" placeholder="<?php echo $lang['BACKUP_FOLDER_NAME_PH']; ?>">
1196  <input type="hidden" name="file" id="file" value=""> <!-- gets filled via JS -->
1197  <input type="hidden" name="action" id="action" value="moveToArchive"> <!-- gets filled via JS -->
1198 
1199  </div>
1200 
1201  <!-- modal footer /w submit btn -->
1202  <div class="modal-footer">
1203  <input class="btn btn-large btn-default" data-dismiss="modal" aria-hidden="true" type="submit" value="<?php echo $lang['CANCEL']; ?>">
1204  <button class="btn btn-large btn-success" type="submit"><i class="fa fa-check"></i>&nbsp; <?php echo $lang['BACKUP_ARCHIVE_THIS']; ?></button>
1205  <br><br>
1206  </div>
1207  </form>
1208  </div> <!-- modal content -->
1209  </div> <!-- modal dialog -->
1210 </div> <!-- modal fade window -->
1211 
1212 
1213 <!-- Modal --RESTORE TO ARCHIVE-- -->
1214 <div class="modal fade" id="restoreModal" tabindex="-1" role="dialog" aria-labelledby="myModal2Label" aria-hidden="true">
1215  <div class="modal-dialog">
1216  <div class="modal-content">
1217  <form action="index.php?page=settings-backup" method="post" enctype="multipart/form-data">
1218  <div class="modal-header">
1219  <!-- modal header with close controls -->
1220  <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i> </button>
1221  <br>
1222  <div class="col-md-1"><h3 class="modal-title"><i class="fa fa-upload"></i></h3></div>
1223  <div class="col-md-11"><h3 class="modal-title"><?php echo $lang['BACKUP_UPLOAD_TO_FOLDER']; ?></h3></div>
1224  </div>
1225 
1226  <!-- modal body -->
1227  <div class="modal-body">
1228  <!-- SELECT BACKUP ARCHIVE SUB FOLDER -->
1229  <?php if (isset($_GET['file'])) { echo $_GET['file']; } ?>
1230  <h4><b><?php echo $lang['SELECT_FILE']; ?>:</b></h4>
1231  <input type="file" name="backupFile" id="backupFile" class="form-control">
1232  <label for="backupFile"><?php echo $lang['POST_MAX_SIZE']; echo filemanager::getPostMaxSize();
1233  echo " &nbsp; / &nbsp; ".$lang['UPLOAD_MAX_SIZE']; echo filemanager::getUploadMaxFilesize(); ?>
1234  <i class="fa fa-question-circle-o text-info" data-placement="auto right" data-toggle="tooltip" title="" data-original-title="<?php echo $lang['UPLOAD_MAX_PHP']; ?>"></i>
1235 
1236  </label>
1237 
1238  <!-- MAX_FILE_SIZE muss vor dem Dateiupload Input Feld stehen -->
1239  <input type="hidden" name="MAX_FILE_SIZE" value="67108864">
1240  <br><br>
1241 
1242 
1243  <h4><b><?php echo $lang['BACKUP_ADD_ARCHIVE_SUBFOLDER']; ?></b></h4>
1244  <?php
1245  $backup->archiveBackupSubFolders = filemanager::getSubfoldersToArray($backup->archiveBackupFolder);
1246 
1247  echo"<label for=\"selectFolder\">$lang[BACKUP_FOLDER_SELECT]</label>
1248  <select class=\"form-control\" name=\"selectFolder\" id=\"selectFolderModal2\">
1249  <option label=\"$lang[BACKUP_PLEASE_SELECT]\" id=\"pleaseSelect\"></option>
1250  <optgroup label=\"$lang[BACKUP_ONGOING]\">$lang[BACKUP_ONGOING]</optgroup>
1251  <option value=\"$backup->currentBackupFolder\" id=\"currentFolder\">&nbsp;&nbsp;&nbsp;&nbsp;$lang[BACKUP_ONGOING]</option>";
1252 
1253  if (count($backup->archiveBackupSubFolders) > 0)
1254  {
1255  echo "<optgroup label=\"$lang[BACKUP_ARCHIVE]\">$lang[BACKUP_ARCHIVE]</optgroup>";
1256 
1257  foreach ($backup->archiveBackupSubFolders as $subFolder)
1258  {
1259  echo "<option value=\"../system/backup/archive/$subFolder/\">&nbsp;&nbsp;&nbsp;&nbsp;$subFolder</option>";
1260  }
1261  }
1262 
1263  echo"</select>
1264  <div class=\"text-center\"><br><i>$lang[OR]</i></div>";
1265  ?>
1266  <label for="newFolderModal2"><?php echo $lang['BACKUP_FOLDER_NAME']; ?></label>
1267  <input type="text" class="form-control" id="newFolderModal2" name="newFolder" placeholder="<?php echo $lang['BACKUP_FOLDER_NAME_PH']; ?>">
1268  <input type="hidden" name="action" id="action" value="upload"> <!-- gets filled via JS -->
1269 
1270  </div>
1271 
1272  <!-- modal footer /w submit btn -->
1273  <div class="modal-footer">
1274  <input class="btn btn-large btn-default" data-dismiss="modal" aria-hidden="true" type="submit" value="<?php echo $lang['CANCEL']; ?>">
1275  <button class="btn btn-large btn-success" type="submit"><i class="fa fa-check"></i>&nbsp; <?php echo $lang['BACKUP_UPLOAD']; ?></button>
1276  <br><br>
1277  <span class="pull-left text-red"><i class="fa fa-exclamation-triangle"></i> &nbsp;<?php echo $lang['BACKUP_UPLOAD_OVERWRITE_WARNING']; ?></span>
1278  <br><br>
1279  </div>
1280  </form>
1281  </div> <!-- modal content -->
1282  </div> <!-- modal dialog -->
1283 </div> <!-- modal fade window -->
1284 
1285 
1286 <!-- Bootstrap toggle css -->
1287 <link rel="stylesheet" href="../system/engines/bootstrap-toggle/css/bootstrap-toggle.css">
1288 <!-- Bootstrap toggle js -->
1289 <script type="text/javascript" src="../system/engines/bootstrap-toggle/js/bootstrap-toggle.min.js"></script>
$folder
Definition: actions.php:9
$maxFileSize
print $lang['FILEMAN_UPLOAD']
Throws a fancy Bootstrap Alert (success, info, warning or danger)
Definition: alert.php:19
Backend class serves a few useful functions for the admin backend.
Definition: backend.php:27
Mysqli database class; returns db connection object.
Definition: db.php:16
Basic File Manager (Backend)
Definition: filemanager.php:17
The language class - support multilingual backend.
Definition: language.php:17
The sys class - handles yawk's system core functions.
Definition: sys.php:17
if(!isset($db)) $id
function window
Definition: fuckAdBlock.js:8
FuckAdBlock prototype on
Definition: fuckAdBlock.js:227
function b(a)
Definition: browser.js:14
c jPlayer event
type
Definition: menu-new.php:35
print $page title
Definition: page-edit.php:377
print $_GET['id']
Definition: page-edit.php:357
function e
Definition: plyr.js:1
function i(e, t)
Definition: plyr.js:1
function w(e, t)
Definition: plyr.js:1
$archiveRestoreID
$systemFolders
$mediaFolderArray
$currentRestoreID
$currentFiles
$contentFolderArray
<!-- backend language -->< h3 >< i class="fa fa-language"></i > & nbsp
$template name
print $tourdates date
$value
document ready(function() { $('a[data-confirm]').click(function(ev) { modal='#dataConfirmModal';var href=$(this).attr('href');var title=$(this).attr('title');var icon=$(this).attr('data-icon');if(!icon) { icon='fa fa-trash-o';} if(!$(modal).length) { $('body').append('< div id="dataConfirmModal" class="modal fade" role="dialog" aria-labelledby="dataConfirmLabel" aria-hidden="true">< div class="modal-dialog">< div class="modal-content">< div class="modal-header">< button type="button" class="close" data-dismiss="modal" aria-hidden="true">< i class="fa fa-times"></i ></button >< br >< div class="col-md-1">< h3 class="modal-title">< i class="'+icon+'"></i ></h3 ></div >< div class="col-md-11">< h3 class="modal-title" id="dataConfirmLabel">'+title+'</h3 ></div ></h3 ></div >< div class="modal-body"></div >< div class="modal-footer">< button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">Abbrechen</button >< a type="button" class="btn btn-danger" id="dataConfirmOK">< i class="'+icon+'"></i > L &ouml;schen</a ></div ></div ></div ></div >');} $(modal).find('.modal-body').text($(this).attr('data-confirm'));$('#dataConfirmOK').attr('href', href);$(modal).modal({show:true});return false;});$('#terminateUser').click(function() { var terminate=window.confirm("ACHTUNG!\nDas wird Deinen Account permanent deaktivieren.\n"+"Bist Du Dir sicher, dass Du das tun willst?");if(terminate===true) { var terminateUser=window.confirm("Bist Du Dir wirklich ganz sicher?\n"+"Diese Aktion kann nicht rueckgaengig gemacht werden.");if(terminateUser===true) { $.get('system/templates/YaWK-bootstrap3/js/terminate-user.php', function(data) { if(data==="true") { setTimeout("window.location='logout.html'", 0);} else { alert("Fehler: "+data);} });} } });function dismissNotifications() { $.ajax({ url:'js/dismiss-notifications.php', type:'POST', success:function(data) { if(!data) { alert('Something went wrong!');return false;} } });$("#bell-label").fadeOut();$('#notification-header').html('You have 0 notifications');$('#notification-menu').fadeOut();} $("#dismiss").click(function() { dismissNotifications();});function disableButtons(delay) { $('#loginButton').removeClass().addClass('btn btn-success disabled').attr('id', 'LOGIN_FORBIDDEN');$('#resetPasswordButton').removeClass().addClass('btn btn-danger disabled');setTimeout(function() { $('#LOGIN_FORBIDDEN').attr('id', 'loginButton').removeClass().addClass('btn btn-success');$('#resetPasswordButton').removeClass().addClass('btn btn-danger');}, delay);} $("#loginButton").click(function(){ if($('#loginButton').length > 0) { if($('#loginButton').hasClass('btn') &&$('#loginButton').hasClass('btn-success') &&$('#loginButton').hasClass('disabled')) { } else { $("#loginForm").submit();disableButtons(10000);} } else if($('#LOGIN_FORBIDDEN').length > 0) { if($('#LOGIN_FORBIDDEN').hasClass('btn') &&$('#LOGIN_FORBIDDEN').hasClass('btn-success') &&$('#LOGIN_FORBIDDEN').hasClass('disabled')) { } else { } } });$("#blockedBtn").hover(function() { $("#blockedBtn").hide();$("#askBtn").fadeIn(820);});})