-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.php
More file actions
83 lines (74 loc) · 2.07 KB
/
delete.php
File metadata and controls
83 lines (74 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* WebsiteBaker Community Edition (WBCE)
* Way Better Content Editing.
* Visit http://wbce.org to learn more and to join the community.
*
* @copyright Ryan Djurovich (2004-2009)
* @copyright WebsiteBaker Org. e.V. (2009-2015)
* @copyright WBCE Project (2015-)
* @license GNU GPL2 (or any later version)
*
*/
/**
* AJAX Function to delete the backup, logfile and ev. sql file
* Check if called by file parameter
*
*/
if (!isset($_GET['file'])) {
die(header('Location: ../../index.php'));
}
/**
* Include all initial routines
*
*/
require_once('init.php');
/**
* Delete the backup and the log file
*
*/
$error = array();
$logfile = $_GET['file'];
$logfilepath = WB_PATH.BACKUP_DATA_DIR.$logfile;
if (!unlink($logfilepath)) {
$error[] = $MOD_BACKUP['BACKUP_DELETE_LOG_ERROR'];
}
$zipfile = str_replace('.log', '.zip', $logfile);
$zipfilepath = WB_PATH.BACKUP_DATA_DIR.$zipfile;
if (file_exists($zipfilepath)) {
if (!unlink($zipfilepath)) {
$error[] = $MOD_BACKUP['BACKUP_DELETE_ZIP_ERROR'];
}
}
$sqlfile = str_replace('.log', '.sql', $logfile);
$sqlfilepath = WB_PATH.BACKUP_DATA_DIR.$sqlfile;
if (file_exists($sqlfilepath)) {
if (!unlink($sqlfilepath)) {
$error[] = $MOD_BACKUP['BACKUP_DELETE_SQL_ERROR'];
}
}
// Check if there was an error, otherwise say successful
if (count($error) > 0) {
$error_msg = implode('<br>', $error);
die(json_encode(array('code' => 403, 'error' => $error_msg)));
}
// Date time of backup
preg_match('#(\d{10}).(.)#', $logfile, $matches);
if (empty($matches[1])) {
$datetime = "?";
} else {
$datetime = gmdate(DEFAULT_DATE_FORMAT.', '.DEFAULT_TIME_FORMAT.':s', $matches[1] + DEFAULT_TIMEZONE);
}
// get backup type
if ($matches[2] == 'f') {
$name = $MOD_BACKUP['BACKUP_LIST_FULL'];
} elseif ($matches[2] == 'w') {
$name = $MOD_BACKUP['BACKUP_LIST_WBCE'];
} elseif ($matches[2] == 'p') {
$name = $MOD_BACKUP['BACKUP_LIST_PAGE'];
} elseif ($matches[2] == 'r') {
$name = $MOD_BACKUP['BACKUP_LIST_RECO'];
} else {
$name = "?";
}
die(json_encode(array('code' => 200, 'error' => '', 'message' => "$name $datetime - ".$TEXT['DELETED'])));