-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool.php
More file actions
289 lines (249 loc) · 7.45 KB
/
tool.php
File metadata and controls
289 lines (249 loc) · 7.45 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
<?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)
*/
/**
* Direct access prevention
*
*/
defined('WB_PATH') OR die(header('Location: ../../index.php'));
/**
* Load module language file
*
*/
$lang = __DIR__.'/languages/'.LANGUAGE.'.php';
require __DIR__.'/languages/EN.php'; // default
if (file_exists($lang)) { // override with user language
require $lang;
}
/**
* Include module backup_settings.php
*
*/
require_once('backup_settings.php');
/**
* Check if all necessary parameter exists
*
*/
if (!defined('BACKUP_DATA_DIR')) stop( 'BACKUP_DATA_DIR' );
if (empty($max_file_size)) stop( 'max_file_size' );
if (empty($includeDirs)) stop( 'includeDirs' );
if (empty($exportTables)) stop( 'exportTables' );
if (empty($ignoreWbceDirs)) stop( 'ignoreWbceDirs' );
if (empty($ignoreFullDirs)) stop( 'ignoreFullDirs' );
if (empty($log_excluded_large_files)) {
$log_excluded_large_files = true;
}
if (empty($log_excluded_extensions)) {
$log_excluded_extensions = true;
}
if (empty($ignoreExts)) {
$ignoreExts = array();
}
function stop($msg) {
global $MOD_BACKUP;
die(sprintf( $MOD_BACKUP['BACKUP_PARAMETER_ERROR'], $msg ));
}
// Make directory for the backups if not yet existing
$dir_path = WB_PATH.BACKUP_DATA_DIR;
make_dir($dir_path);
/**
* Show form
*
*/
?>
<link href="<?php echo WB_URL . '/modules/backup_plus/css/tool.css' ?>" rel="stylesheet" type="text/css" media="screen" />
<div id="backup_plus_main">
<div id="left">
<h2><b><?php echo $MOD_BACKUP['BACKUP_HEADER'] ?></b></h2>
<form name="prompt" method="post">
<div>
<input type="radio" name="backup" value="page" checked="checked"> <?php echo $MOD_BACKUP['BACKUP_PAGES'] ?><br>
<?php if ($wb->ami_group_member('1')) { ?>
<input type="radio" name="backup" value="wbce"> <?php echo $MOD_BACKUP['BACKUP_WBCE'] ?><br>
<input type="radio" name="backup" value="full"> <?php echo $MOD_BACKUP['BACKUP_COMPLETE'] ?><br>
<?php } ?>
<br>
</div>
<div><?php printf($MOD_BACKUP['BACKUP_INFO'], $max_file_size); ?></div><br>
<input type="button" id="backup" value="<?php echo $MOD_BACKUP['BACKUP_START'] ?>">
<br>
</form>
<br style="clear:both">
<?php
// called from restore.php with params?
if (isset($_GET['result'])) {
if (empty($_GET['error'])) {
?>
<div class="alert alert-success" style="display:inherit"><?php echo $_GET['result'] ?></div>
<div class="alert alert-fail"> </div>
<?php } else { ?>
<div class="alert alert-success"> </div>
<div class="alert alert-fail" style="display:inherit"><?php echo $_GET['error'] ?></div>
<?php }
} else {
?>
<div class="alert alert-success"> </div>
<div class="alert alert-fail"> </div>
<?php
}
?>
<br><br>
</div>
<div id="right">
<div id="backupList"></div>
</div>
</div>
<script src="<?php echo WB_URL . '/modules/backup_plus/js/alerty.min.js' ?>" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
$(function() {
'use strict';
// show of the backup file list first
getBackupfiles();
// all backup functions
$( document ).on( "click", "#backup", function(e) {
e.preventDefault();
var type = $('input[name=backup]:checked').val();
var txtbku = '<?php echo ($MESSAGE['GENERIC_PLEASE_BE_PATIENT'] . $MOD_BACKUP['BACKUP_WARNING1']) ?>';
confirm( '<?php echo $MOD_BACKUP['BACKUP_START'] ?>', txtbku, backupFunction, type );
});
function backupFunction( type ){
var myURL = '<?php echo WB_URL ?>' + '/modules/backup_plus/backup.php';
var _request = $.ajax({
type: 'GET',
url: myURL,
dataType: 'json',
data: {
backup: "yes",
type: type
}
});
_request.done(function(msg) {
checkDone(msg, myURL);
});
_request.fail(function(xhr, ajaxOptions, thrownError) {
showError(xhr.status, thrownError, myURL);
});
};
// delete function
$( document ).on( "click", ".delete", function(e) {
e.preventDefault();
confirm( '<?php echo $MOD_BACKUP['BACKUP_DELETE'] ?>', '<?php echo $MOD_BACKUP['BACKUP_SURE'] ?>', deleteFunction, $(this).attr('data-file') );
});
function deleteFunction( file ) {
var myURL = '<?php echo WB_URL ?>' + '/modules/backup_plus/delete.php';
var _request = $.ajax({
type: 'GET',
url: myURL,
dataType: 'json',
data: {
file: file
}
});
_request.done(function(msg) {
checkDone(msg, myURL);
});
_request.fail(function(xhr, ajaxOptions, thrownError) {
showError(xhr.status, thrownError, myURL);
});
};
// restore backup to original position from zipfile
$( document ).on( "click", ".restore", function(e) {
e.preventDefault();
var txtres = '<?php echo ($MOD_BACKUP['BACKUP_SURE'] . $MOD_BACKUP['BACKUP_RESTORE_WARNING'] . $MOD_BACKUP['BACKUP_WARNING1'] . $MOD_BACKUP['BACKUP_WARNING2']) ?>';
confirm( '<?php echo $MOD_BACKUP['BACKUP_LIST_RECO'] ?>', txtres, restoreFunction, $(this).attr('data-file') );
});
function restoreFunction( file ) {
window.location.href = '<?php echo WB_URL ?>' + '/modules/backup_plus/restore.php?file=' + file;
return true;
};
// show logfile
$( document ).on( "click", ".showlog", function(e) {
e.preventDefault();
popup($(this).attr('data-file'));
});
// ajax show the list of the backup files
function getBackupfiles() {
var myURL = '<?php echo WB_URL ?>' + '/modules/backup_plus/list.php';
var _request = $.ajax({
type: 'GET',
url: myURL,
dataType: 'json',
data: {
dir: 'backups'
}
});
_request.done(function(msg) {
if (typeof msg === 'object' && msg !== null) {
if (msg.code === 200) {
$('#backupList').html(msg.list);
} else {
showError(msg.code, msg.error, myURL);
}
} else {
showError(403, 'PHP error?', myURL);
}
});
_request.fail(function(xhr, ajaxOptions, thrownError) {
showError(xhr.status, thrownError, myURL);
});
}
function checkDone(msg,url) {
if (typeof msg === 'object' && msg !== null) {
if (msg.code === 200) {
showSuccess(msg.message);
} else {
showError(msg.code, msg.error, url);
}
} else {
showError(403, 'PHP error?', url);
}
}
function showWaiting() {
$('#backup').hide();
$('div.alert.alert-fail').text('').hide();
$('div.alert.alert-success').html('<?php echo $MOD_BACKUP['BACKUP_WAIT'] ?>').show();
}
function showSuccess( message ) {
$('#backup').show();
$('div.alert.alert-fail').text('').hide();
$('div.alert.alert-success').html(message);
getBackupfiles();
}
function showError( status, error, url ) {
$('#backup').show();
$('div.alert.alert-success').text('').hide();
$('div.alert.alert-fail').html('Status: ' + status + '<br>' + error + '<br>URL: ' + url ).show();
getBackupfiles();
}
function confirm( tit, body, func, par ) {
alerty.confirm( body, {title: tit, cancelLabel: '<?php echo $TEXT['CANCEL'] ?>', okLabel: 'OK'},
function(){
$('#backupList').html('');
showWaiting();
func(par);
},
function(){return false}
)
}
// show a popup window
function popup(url,w,h) {
if(url==null||url=="") return;
var w = (w) ? w : $(window).width() - 50;
var h = (h) ? h : $(window).height() - 100;
var l = $(window.parent).width() - w;
var pop = window.open( url, 'popup', 'width='+w+',height='+h+',left='+l+',top=80,resizable=yes,scrollbars=yes,status=no,location=no');
if (pop) pop.focus();
}
});
//]]>
</script>