Version Description
- changes for user checking
- removed Plugin init action
Download this release
Release Info
Developer | danielhuesken |
Plugin | BackWPup – WordPress Backup Plugin |
Version | 1.5.2 |
Comparing to | |
See all releases |
Code changes from version 1.5.1 to 1.5.2
- app/functions.php +679 -706
- app/functions5.php +439 -439
- backwpup.php +29 -4
- readme.txt +5 -1
app/functions.php
CHANGED
@@ -3,769 +3,742 @@
|
|
3 |
if ( !defined('ABSPATH') )
|
4 |
die('-1');
|
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 |
-
if ($_REQUEST['action2']!='-1' and !empty($_REQUEST['doaction2']))
|
123 |
-
$_REQUEST['action']=$_REQUEST['action2'];
|
124 |
-
|
125 |
-
switch($_REQUEST['subpage']) {
|
126 |
-
case 'logs':
|
127 |
-
if (!empty($_REQUEST['action'])) {
|
128 |
-
require_once(dirname(__FILE__).'/options-save.php');
|
129 |
-
backwpup_log_operations($_REQUEST['action']);
|
130 |
-
}
|
131 |
-
require_once(dirname(__FILE__).'/list-tables.php');
|
132 |
-
$table = new BackWPup_Logs_Table;
|
133 |
-
$table->check_permissions();
|
134 |
-
$table->prepare_items();
|
135 |
-
break;
|
136 |
-
case 'edit':
|
137 |
-
if (!empty($_POST['submit'])) {
|
138 |
-
require_once(dirname(__FILE__).'/options-save.php');
|
139 |
-
$backwpup_message=backwpup_save_job();
|
140 |
-
}
|
141 |
-
break;
|
142 |
-
case 'settings':
|
143 |
-
if (!empty($_POST['submit'])) {
|
144 |
-
require_once(dirname(__FILE__).'/options-save.php');
|
145 |
-
$backwpup_message=backwpup_save_settings();
|
146 |
-
}
|
147 |
-
break;
|
148 |
-
case 'tools':
|
149 |
-
break;
|
150 |
-
case 'backups':
|
151 |
-
if (!empty($_REQUEST['action'])) {
|
152 |
-
require_once(dirname(__FILE__).'/options-save.php');
|
153 |
-
backwpup_backups_operations($_REQUEST['action']);
|
154 |
-
}
|
155 |
-
require_once(dirname(__FILE__).'/list-tables.php');
|
156 |
-
$table = new BackWPup_Backups_Table;
|
157 |
-
$table->check_permissions();
|
158 |
-
$table->prepare_items();
|
159 |
-
break;
|
160 |
-
case 'runnow':
|
161 |
-
break;
|
162 |
-
case 'view_log':
|
163 |
-
break;
|
164 |
-
default:
|
165 |
-
if (!empty($_REQUEST['action'])) {
|
166 |
-
require_once(dirname(__FILE__).'/options-save.php');
|
167 |
-
backwpup_job_operations($_REQUEST['action']);
|
168 |
-
}
|
169 |
-
require_once(dirname(__FILE__).'/list-tables.php');
|
170 |
-
$table = new BackWPup_Jobs_Table;
|
171 |
-
$table->check_permissions();
|
172 |
-
$table->prepare_items();
|
173 |
-
break;
|
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 |
-
wp_clear_scheduled_hook('backwpup_cron');
|
240 |
}
|
241 |
-
|
242 |
-
//
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
}
|
|
|
|
|
248 |
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
|
|
255 |
}
|
256 |
-
return $links;
|
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 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
}
|
322 |
}
|
323 |
-
} else {
|
324 |
-
$typename=array('WPEXP','DB','FILE','OPTIMIZE','CHECK');
|
325 |
-
}
|
326 |
-
|
327 |
-
if ($echo)
|
328 |
-
echo $typename;
|
329 |
-
else
|
330 |
-
return $typename;
|
331 |
-
}
|
332 |
-
|
333 |
-
//read log file header
|
334 |
-
function backwpup_read_logheader($logfile) {
|
335 |
-
$headers=array("backwpup_version" => "version","backwpup_logtime" => "logtime","backwpup_errors" => "errors","backwpup_warnings" => "warnings","backwpup_jobid" => "jobid","backwpup_jobname" => "name","backwpup_jobtype" => "type","backwpup_jobruntime" => "runtime","backwpup_backupfilesize" => "backupfilesize");
|
336 |
-
if (!is_readable($logfile))
|
337 |
-
return false;
|
338 |
-
//Read file
|
339 |
-
if (strtolower(substr($logfile,-3))==".gz") {
|
340 |
-
$fp = gzopen( $logfile, 'r' );
|
341 |
-
$file_data = gzread( $fp, 1536 ); // Pull only the first 1,5kiB of the file in.
|
342 |
-
gzclose( $fp );
|
343 |
-
} else {
|
344 |
-
$fp = fopen( $logfile, 'r' );
|
345 |
-
$file_data = fread( $fp, 1536 ); // Pull only the first 1,5kiB of the file in.
|
346 |
-
fclose( $fp );
|
347 |
}
|
|
|
|
|
|
|
348 |
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
else
|
355 |
-
$joddata[$field]='';
|
356 |
-
}
|
357 |
|
358 |
-
|
359 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
360 |
|
361 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
}
|
363 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
364 |
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
}
|
377 |
-
|
378 |
-
|
|
|
|
|
379 |
}
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
echo '
|
391 |
-
|
392 |
-
|
393 |
-
echo ' <span style="color:red;">'.$logdata['errors'].' '.__('ERROR(S)','backwpup').'</span>';
|
394 |
-
if ($logdata['warnings']>0)
|
395 |
-
echo ' <span style="color:yellow;">'.$logdata['warnings'].' '.__('WARNING(S)','backwpup').'</span>';
|
396 |
-
} else {
|
397 |
-
echo ' <span style="color:green;">'.__('OK','backwpup').'</span>';
|
398 |
-
}
|
399 |
-
echo '</a><br />';
|
400 |
-
$count++;
|
401 |
-
if ($count>=5)
|
402 |
-
break;
|
403 |
}
|
404 |
-
|
405 |
-
echo '<i>'.__('none','backwpup').'</i><br />';
|
406 |
}
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
}
|
421 |
-
if (empty($jobs))
|
422 |
-
echo '<i>'.__('none','backwpup').'</i><br />';
|
423 |
-
|
424 |
}
|
425 |
-
|
426 |
-
|
427 |
-
function backwpup_add_dashboard() {
|
428 |
-
wp_add_dashboard_widget( 'backwpup_dashboard_widget', 'BackWPup', 'backwpup_dashboard_output' );
|
429 |
}
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
echo "<meta http-equiv=\"cache-control\" content=\"no-cache\" />\n";
|
436 |
}
|
437 |
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
443 |
}
|
|
|
|
|
444 |
|
445 |
-
function backwpup_get_upload_dir() {
|
446 |
-
global $switched;
|
447 |
-
$upload_path = get_option( 'upload_path' );
|
448 |
-
$upload_path = trim($upload_path);
|
449 |
-
$main_override = defined( 'MULTISITE' ) && is_main_site();
|
450 |
-
if ( empty($upload_path) ) {
|
451 |
-
$dir = WP_CONTENT_DIR . '/uploads';
|
452 |
-
} else {
|
453 |
-
$dir = $upload_path;
|
454 |
-
if ( 'wp-content/uploads' == $upload_path ) {
|
455 |
-
$dir = WP_CONTENT_DIR . '/uploads';
|
456 |
-
} elseif ( 0 !== strpos($dir, ABSPATH) ) {
|
457 |
-
// $dir is absolute, $upload_path is (maybe) relative to ABSPATH
|
458 |
-
$dir = path_join( ABSPATH, $dir );
|
459 |
-
}
|
460 |
-
}
|
461 |
-
if ( defined('UPLOADS') && !$main_override && ( !isset( $switched ) || $switched === false ) ) {
|
462 |
-
$dir = ABSPATH . UPLOADS;
|
463 |
-
}
|
464 |
-
if (function_exists('is_multisite')) {
|
465 |
-
if ( is_multisite() && !$main_override && ( !isset( $switched ) || $switched === false ) ) {
|
466 |
-
if ( defined( 'BLOGUPLOADDIR' ) )
|
467 |
-
$dir = untrailingslashit(BLOGUPLOADDIR);
|
468 |
-
}
|
469 |
-
}
|
470 |
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
$
|
477 |
-
|
478 |
-
$
|
479 |
-
|
480 |
-
$excludedir[]=trailingslashit(str_replace('\\','/',WP_CONTENT_DIR));
|
481 |
-
if (false !== stripos(trailingslashit(str_replace('\\','/',WP_PLUGIN_DIR)),$folder) and trailingslashit(str_replace('\\','/',WP_PLUGIN_DIR))!=$folder)
|
482 |
-
$excludedir[]=trailingslashit(str_replace('\\','/',WP_PLUGIN_DIR));
|
483 |
-
if (false !== stripos(str_replace('\\','/',trailingslashit(WP_CONTENT_DIR).'themes/'),$folder) and str_replace('\\','/',trailingslashit(WP_CONTENT_DIR).'themes/')!=$folder)
|
484 |
-
$excludedir[]=str_replace('\\','/',trailingslashit(WP_CONTENT_DIR).'themes/');
|
485 |
-
if (false !== stripos(backwpup_get_upload_dir(),$folder) and backwpup_get_upload_dir()!=$folder)
|
486 |
-
$excludedir[]=backwpup_get_upload_dir();
|
487 |
-
//Exclude Backup dirs
|
488 |
-
$jobs=(array)get_option('backwpup_jobs');
|
489 |
-
foreach($jobs as $jobsvale) {
|
490 |
-
if (!empty($jobsvale['backupdir']) and $jobsvale['backupdir']!='/')
|
491 |
-
$excludedir[]=trailingslashit(str_replace('\\','/',$jobsvale['backupdir']));
|
492 |
}
|
493 |
-
return $excludedir;
|
494 |
-
}
|
495 |
-
|
496 |
-
|
497 |
-
function backwpup_calc_db_size($jobvalues) {
|
498 |
-
global $wpdb;
|
499 |
-
$dbsize=array('size'=>0,'num'=>0,'rows'=>0);
|
500 |
-
$status=$wpdb->get_results("SHOW TABLE STATUS FROM `".DB_NAME."`;", ARRAY_A);
|
501 |
-
foreach($status as $tablekey => $tablevalue) {
|
502 |
-
if (!in_array($tablevalue['Name'],$jobvalues['dbexclude'])) {
|
503 |
-
$dbsize['size']=$dbsize['size']+$tablevalue["Data_length"]+$tablevalue["Index_length"];
|
504 |
-
$dbsize['num']++;
|
505 |
-
$dbsize['rows']=$dbsize['rows']+$tablevalue["Rows"];
|
506 |
-
}
|
507 |
-
}
|
508 |
-
return $dbsize;
|
509 |
}
|
|
|
|
|
510 |
|
511 |
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
}
|
522 |
-
if ( @is_dir( $folder.$file )) {
|
523 |
-
if (!in_array(trailingslashit($folder.$file),$excludedirs))
|
524 |
-
_backwpup_calc_file_size_file_list_folder( trailingslashit($folder.$file), $levels - 1, $excludes);
|
525 |
-
} elseif ((@is_file( $folder.$file ) or @is_executable($folder.$file)) and @is_readable($folder.$file)) {
|
526 |
-
$backwpup_temp_files['num']++;
|
527 |
-
$backwpup_temp_files['size']=$backwpup_temp_files['size']+filesize($folder.$file);
|
528 |
-
}
|
529 |
}
|
530 |
-
@
|
531 |
-
|
532 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
533 |
}
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
|
|
563 |
}
|
564 |
-
|
565 |
-
return $backwpup_temp_files;
|
566 |
-
|
567 |
}
|
568 |
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
$
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
598 |
$step=5;
|
599 |
-
$
|
600 |
-
for ($i=$first;$i<=$last;$i=$i+$step)
|
601 |
$range[]=$i;
|
602 |
-
$cron[$cronarraykey]=array_merge($cron[$cronarraykey],$range);
|
603 |
-
} elseif ($value=='*') {
|
604 |
-
$range=array();
|
605 |
-
if ($cronarraykey=='minutes') {
|
606 |
-
if ($step<5) //set step ninmum to 5 min.
|
607 |
-
$step=5;
|
608 |
-
for ($i=0;$i<=59;$i=$i+$step)
|
609 |
-
$range[]=$i;
|
610 |
-
}
|
611 |
-
if ($cronarraykey=='hours') {
|
612 |
-
for ($i=0;$i<=23;$i=$i+$step)
|
613 |
-
$range[]=$i;
|
614 |
-
}
|
615 |
-
if ($cronarraykey=='mday') {
|
616 |
-
for ($i=$step;$i<=31;$i=$i+$step)
|
617 |
-
$range[]=$i;
|
618 |
-
}
|
619 |
-
if ($cronarraykey=='mon') {
|
620 |
-
for ($i=$step;$i<=12;$i=$i+$step)
|
621 |
-
$range[]=$i;
|
622 |
-
}
|
623 |
-
if ($cronarraykey=='wday') {
|
624 |
-
for ($i=0;$i<=6;$i=$i+$step)
|
625 |
-
$range[]=$i;
|
626 |
-
}
|
627 |
-
$cron[$cronarraykey]=array_merge($cron[$cronarraykey],$range);
|
628 |
-
} else {
|
629 |
-
//Month names
|
630 |
-
if (strtolower($value)=='jan')
|
631 |
-
$value=1;
|
632 |
-
if (strtolower($value)=='feb')
|
633 |
-
$value=2;
|
634 |
-
if (strtolower($value)=='mar')
|
635 |
-
$value=3;
|
636 |
-
if (strtolower($value)=='apr')
|
637 |
-
$value=4;
|
638 |
-
if (strtolower($value)=='may')
|
639 |
-
$value=5;
|
640 |
-
if (strtolower($value)=='jun')
|
641 |
-
$value=6;
|
642 |
-
if (strtolower($value)=='jul')
|
643 |
-
$value=7;
|
644 |
-
if (strtolower($value)=='aug')
|
645 |
-
$value=8;
|
646 |
-
if (strtolower($value)=='sep')
|
647 |
-
$value=9;
|
648 |
-
if (strtolower($value)=='oct')
|
649 |
-
$value=10;
|
650 |
-
if (strtolower($value)=='nov')
|
651 |
-
$value=11;
|
652 |
-
if (strtolower($value)=='dec')
|
653 |
-
$value=12;
|
654 |
-
//Week Day names
|
655 |
-
if (strtolower($value)=='sun')
|
656 |
-
$value=0;
|
657 |
-
if (strtolower($value)=='sat')
|
658 |
-
$value=6;
|
659 |
-
if (strtolower($value)=='mon')
|
660 |
-
$value=1;
|
661 |
-
if (strtolower($value)=='tue')
|
662 |
-
$value=2;
|
663 |
-
if (strtolower($value)=='wed')
|
664 |
-
$value=3;
|
665 |
-
if (strtolower($value)=='thu')
|
666 |
-
$value=4;
|
667 |
-
if (strtolower($value)=='fri')
|
668 |
-
$value=5;
|
669 |
-
if (!is_numeric($value) or $value>60) //check
|
670 |
-
return false;
|
671 |
-
$cron[$cronarraykey]=array_merge($cron[$cronarraykey],array(0=>$value));
|
672 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
673 |
}
|
674 |
}
|
|
|
675 |
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
}
|
687 |
}
|
688 |
}
|
689 |
}
|
690 |
}
|
691 |
}
|
692 |
-
return false;
|
693 |
}
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
$message.=__('- PHP 5.2.0 or higher needed!','backwpup') . '<br />';
|
706 |
-
$checks=false;
|
707 |
-
}
|
708 |
-
if (!is_dir($cfg['dirlogs'])) { // check logs folder
|
709 |
-
$message.=__('- Logs Folder not exists (Try too create it on first Job run):','backwpup') . ' '.$cfg['dirlogs'].'<br />';
|
710 |
-
}
|
711 |
-
if (!is_writable($cfg['dirlogs'])) { // check logs folder
|
712 |
-
$message.=__('- Logs Folder not writeable:','backwpup') . ' '.$cfg['dirlogs'].'<br />';
|
713 |
-
}
|
714 |
-
if (!is_dir($cfg['dirtemp'])) { // check Temp folder
|
715 |
-
$message.=__('- Temp Folder not exists (Try too create it on first Job run):','backwpup') . ' '.$cfg['dirtemp'].'<br />';
|
716 |
-
}
|
717 |
-
if (!is_writable($cfg['dirtemp'])) { // check Temp folder
|
718 |
-
$message.=__('- Temp Folder not writeable:','backwpup') . ' '.$cfg['dirtemp'].'<br />';
|
719 |
-
}
|
720 |
-
$jobs=(array)get_option('backwpup_jobs');
|
721 |
-
foreach ($jobs as $jobid => $jobvalue) { //check for old cheduling
|
722 |
-
if (isset($jobvalue['scheduletime']) and empty($jobvalue['cron']))
|
723 |
-
$message.=__('- Please Check Scheduling time for Job:','backwpup') . ' '.$jobid.'. '.$jobvalue['name'].'<br />';
|
724 |
-
}
|
725 |
-
if (wp_next_scheduled('backwpup_cron')!=0 and wp_next_scheduled('backwpup_cron')>(time()+360)) { //check cron jobs work
|
726 |
-
$message.=__("- WP-Cron don't working please check it!","backwpup") .'<br />';
|
727 |
-
}
|
728 |
-
//put massage if one
|
729 |
-
if (!empty($message))
|
730 |
-
$backwpup_admin_message = '<div id="message" class="error fade"><strong>BackWPup:</strong><br />'.$message.'</div>';
|
731 |
-
return $checks;
|
732 |
}
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
echo $backwpup_admin_message;
|
737 |
}
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
if (
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
add_filter('cron_schedules', 'backwpup_intervals');
|
758 |
-
//Actions for Cron job
|
759 |
-
add_action('backwpup_cron', 'backwpup_cron');
|
760 |
-
//test if cron active
|
761 |
-
if (!(wp_next_scheduled('backwpup_cron')))
|
762 |
-
wp_schedule_event(0, 'backwpup_int', 'backwpup_cron');
|
763 |
-
//add Dashboard widget
|
764 |
-
if (current_user_can('export'))
|
765 |
-
add_action('wp_dashboard_setup', 'backwpup_add_dashboard');
|
766 |
-
// add ajax function
|
767 |
-
add_action('wp_ajax_backwpup_get_aws_buckets', 'backwpup_get_aws_buckets');
|
768 |
-
add_action('wp_ajax_backwpup_get_rsc_container', 'backwpup_get_rsc_container');
|
769 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
770 |
|
771 |
?>
|
3 |
if ( !defined('ABSPATH') )
|
4 |
die('-1');
|
5 |
|
6 |
+
//Thems Option menu entry
|
7 |
+
function backwpup_admin_menu() {
|
8 |
+
$hook = add_management_page(__('BackWPup','backwpup'), __('BackWPup','backwpup'), BACKWPUP_USER_CAPABILITY, 'BackWPup','backwpup_options_page') ;
|
9 |
+
add_action('load-'.$hook, 'backwpup_options_load');
|
10 |
+
}
|
11 |
+
|
12 |
+
//Options Page
|
13 |
+
function backwpup_options_page() {
|
14 |
+
global $table,$backwpup_message,$page_hook;
|
15 |
+
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
16 |
+
return;
|
17 |
+
if(!empty($backwpup_message))
|
18 |
+
echo '<div id="message" class="updated fade"><p><strong>'.$backwpup_message.'</strong></p></div>';
|
19 |
+
switch($_REQUEST['subpage']) {
|
20 |
+
case 'edit':
|
21 |
+
require_once(dirname(__FILE__).'/options-edit-job.php');
|
22 |
+
break;
|
23 |
+
case 'logs':
|
24 |
+
echo "<div class=\"wrap\">";
|
25 |
+
echo "<div id=\"icon-tools\" class=\"icon32\"><br /></div>";
|
26 |
+
echo "<h2>".__('BackWPup Logs', 'backwpup')."</h2>";
|
27 |
+
backwpup_option_submenues();
|
28 |
+
echo "<form id=\"posts-filter\" action=\"\" method=\"post\">";
|
29 |
+
echo "<input type=\"hidden\" name=\"page\" value=\"BackWPup\" />";
|
30 |
+
echo "<input type=\"hidden\" name=\"subpage\" value=\"logs\" />";
|
31 |
+
$table->display();
|
32 |
+
echo "<div id=\"ajax-response\"></div>";
|
33 |
+
echo "</form>";
|
34 |
+
echo "</div>";
|
35 |
+
break;
|
36 |
+
case 'settings':
|
37 |
+
require_once(dirname(__FILE__).'/options-settings.php');
|
38 |
+
break;
|
39 |
+
case 'tools':
|
40 |
+
require_once(dirname(__FILE__).'/options-tools.php');
|
41 |
+
break;
|
42 |
+
case 'backups':
|
43 |
+
echo "<div class=\"wrap\">";
|
44 |
+
echo "<div id=\"icon-tools\" class=\"icon32\"><br /></div>";
|
45 |
+
echo "<h2>".__('BackWPup Manage Backups', 'backwpup')."</h2>";
|
46 |
+
backwpup_option_submenues();
|
47 |
+
echo "<form id=\"posts-filter\" action=\"\" method=\"post\">";
|
48 |
+
echo "<input type=\"hidden\" name=\"page\" value=\"BackWPup\" />";
|
49 |
+
echo "<input type=\"hidden\" name=\"subpage\" value=\"backups\" />";
|
50 |
+
$table->display();
|
51 |
+
echo "<div id=\"ajax-response\"></div>";
|
52 |
+
echo "</form>";
|
53 |
+
echo "</div>";
|
54 |
+
break;
|
55 |
+
case 'runnow':
|
56 |
+
$jobid = (int) $_GET['jobid'];
|
57 |
+
check_admin_referer('runnow-job_' . $jobid);
|
58 |
+
$jobs=get_option('backwpup_jobs');
|
59 |
+
echo "<div class=\"wrap\">";
|
60 |
+
echo "<div id=\"icon-tools\" class=\"icon32\"><br /></div>";
|
61 |
+
echo "<h2>".__('BackWPup Job Running', 'backwpup')."</h2>";
|
62 |
+
backwpup_option_submenues();
|
63 |
+
echo "<br class=\"clear\" />";
|
64 |
+
echo "<big>".__('Running Job','backwpup')." <strong>".$jobs[$jobid]['name']."</strong></big>";
|
65 |
+
echo "<iframe src=\"".wp_nonce_url(plugins_url('options-runnow-iframe.php',__FILE__).'?wpabs='.trailingslashit(ABSPATH).'&jobid=' . $jobid, 'dojob-now_' . $jobid)."\" name=\"runframe\" id=\"runframe\" width=\"100%\" height=\"450\" align=\"left\" scrolling=\"auto\" style=\"border: 1px solid gray\" frameborder=\"0\"></iframe>";
|
66 |
+
echo "</div>";
|
67 |
+
break;
|
68 |
+
case 'view_log':
|
69 |
+
check_admin_referer('view-log_'.basename($_GET['logfile']));
|
70 |
+
echo "<div class=\"wrap\">";
|
71 |
+
echo "<div id=\"icon-tools\" class=\"icon32\"><br /></div>";
|
72 |
+
echo "<h2>".__('BackWPup View Logs', 'backwpup')."</h2>";
|
73 |
+
backwpup_option_submenues();
|
74 |
+
echo "<br class=\"clear\" />";
|
75 |
+
echo "<big>".__('View Log','backwpup')." <strong>".basename($_GET['logfile'])."</strong></big>";
|
76 |
+
echo "<iframe src=\"".wp_nonce_url(plugins_url('options-view_log-iframe.php',__FILE__).'?wpabs='.trailingslashit(ABSPATH).'&logfile=' . $_GET['logfile'], 'viewlognow_'.basename($_GET['logfile']))."\" name=\"logframe\" id=\"logframe\" width=\"100%\" height=\"450\" align=\"left\" scrolling=\"auto\" style=\"border: 1px solid gray\" frameborder=\"0\"></iframe>";
|
77 |
+
echo "</div>";
|
78 |
+
break;
|
79 |
+
default:
|
80 |
+
echo "<div class=\"wrap\">";
|
81 |
+
echo "<div id=\"icon-tools\" class=\"icon32\"><br /></div>";
|
82 |
+
echo "<h2>".__('BackWPup', 'backwpup')." <a href=\"".wp_nonce_url('admin.php?page=BackWPup&subpage=edit', 'edit-job')."\" class=\"button add-new-h2\">".esc_html__('Add New')."</a></h2>";
|
83 |
+
backwpup_option_submenues();
|
84 |
+
echo "<form id=\"posts-filter\" action=\"\" method=\"post\">";
|
85 |
+
echo "<input type=\"hidden\" name=\"page\" value=\"BackWPup\" />";
|
86 |
+
echo "<input type=\"hidden\" name=\"subpage\" value=\"\" />";
|
87 |
+
$table->display();
|
88 |
+
echo "<div id=\"ajax-response\"></div>";
|
89 |
+
echo "</form>";
|
90 |
+
echo "</div>";
|
91 |
+
break;
|
|
|
92 |
}
|
93 |
+
}
|
94 |
+
|
95 |
+
//Options Page
|
96 |
+
function backwpup_options_load() {
|
97 |
+
global $current_screen,$table,$backwpup_message;
|
98 |
+
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
99 |
+
return;
|
100 |
+
//Css for Admin Section
|
101 |
+
wp_enqueue_style('BackWpup',plugins_url('css/options.css',__FILE__),'',BACKWPUP_VERSION,'screen');
|
102 |
+
wp_enqueue_script('BackWpupOptions',plugins_url('js/options.js',__FILE__),'',BACKWPUP_VERSION,true);
|
103 |
+
add_contextual_help($current_screen,
|
104 |
+
'<div class="metabox-prefs">'.
|
105 |
+
'<a href="http://wordpress.org/tags/backwpup" target="_blank">'.__('Support').'</a>'.
|
106 |
+
' | <a href="http://wordpress.org/extend/plugins/backwpup/faq/" target="_blank">' . __('FAQ') . '</a>'.
|
107 |
+
' | <a href="http://danielhuesken.de/portfolio/backwpup" target="_blank">' . __('Plugin Homepage', 'backwpup') . '</a>'.
|
108 |
+
' | <a href="http://wordpress.org/extend/plugins/backwpup" target="_blank">' . __('Plugin Home on WordPress.org', 'backwpup') . '</a>'.
|
109 |
+
' | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=daniel%40huesken-net%2ede&item_name=Daniel%20Huesken%20Plugin%20Donation&item_number=BackWPup&no_shipping=0&no_note=1&tax=0&currency_code=EUR&lc=DE&bn=PP%2dDonationsBF&charset=UTF%2d8" target="_blank">' . __('Donate') . '</a>'.
|
110 |
+
' | <script type="text/javascript">
|
111 |
+
var flattr_btn = \'compact\'
|
112 |
+
var flattr_url = \'http://danielhuesken.de/portfolio/backwpup/\'
|
113 |
+
</script><script src="http://api.flattr.com/button/load.js" type="text/javascript"></script>'.
|
114 |
+
'</div>'.
|
115 |
+
'<div class="metabox-prefs">'.
|
116 |
+
__('Version:', 'backwpup').' '.BACKWPUP_VERSION.' | '.
|
117 |
+
__('Author:', 'backwpup').' <a href="http://danielhuesken.de" target="_blank">Daniel Hüsken</a>'.
|
118 |
+
'</div>'
|
119 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
+
if ($_REQUEST['action2']!='-1' and !empty($_REQUEST['doaction2']))
|
122 |
+
$_REQUEST['action']=$_REQUEST['action2'];
|
123 |
+
|
124 |
+
switch($_REQUEST['subpage']) {
|
125 |
+
case 'logs':
|
126 |
+
if (!empty($_REQUEST['action'])) {
|
127 |
+
require_once(dirname(__FILE__).'/options-save.php');
|
128 |
+
backwpup_log_operations($_REQUEST['action']);
|
129 |
+
}
|
130 |
+
require_once(dirname(__FILE__).'/list-tables.php');
|
131 |
+
$table = new BackWPup_Logs_Table;
|
132 |
+
$table->check_permissions();
|
133 |
+
$table->prepare_items();
|
134 |
+
break;
|
135 |
+
case 'edit':
|
136 |
+
if (!empty($_POST['submit'])) {
|
137 |
+
require_once(dirname(__FILE__).'/options-save.php');
|
138 |
+
$backwpup_message=backwpup_save_job();
|
139 |
+
}
|
140 |
+
break;
|
141 |
+
case 'settings':
|
142 |
+
if (!empty($_POST['submit'])) {
|
143 |
+
require_once(dirname(__FILE__).'/options-save.php');
|
144 |
+
$backwpup_message=backwpup_save_settings();
|
145 |
+
}
|
146 |
+
break;
|
147 |
+
case 'tools':
|
148 |
+
break;
|
149 |
+
case 'backups':
|
150 |
+
if (!empty($_REQUEST['action'])) {
|
151 |
+
require_once(dirname(__FILE__).'/options-save.php');
|
152 |
+
backwpup_backups_operations($_REQUEST['action']);
|
153 |
+
}
|
154 |
+
require_once(dirname(__FILE__).'/list-tables.php');
|
155 |
+
$table = new BackWPup_Backups_Table;
|
156 |
+
$table->check_permissions();
|
157 |
+
$table->prepare_items();
|
158 |
+
break;
|
159 |
+
case 'runnow':
|
160 |
+
break;
|
161 |
+
case 'view_log':
|
162 |
+
break;
|
163 |
+
default:
|
164 |
+
if (!empty($_REQUEST['action'])) {
|
165 |
+
require_once(dirname(__FILE__).'/options-save.php');
|
166 |
+
backwpup_job_operations($_REQUEST['action']);
|
167 |
+
}
|
168 |
+
require_once(dirname(__FILE__).'/list-tables.php');
|
169 |
+
$table = new BackWPup_Jobs_Table;
|
170 |
+
$table->check_permissions();
|
171 |
+
$table->prepare_items();
|
172 |
+
break;
|
173 |
}
|
174 |
+
}
|
175 |
+
|
176 |
+
|
177 |
+
function backwpup_option_submenues() {
|
178 |
+
$maincurrent="";$logscurrent="";$backupscurrent="";$toolscurrent="";$settingscurrent="";
|
179 |
+
if (empty($_REQUEST['subpage']))
|
180 |
+
$maincurrent=" class=\"current\"";
|
181 |
+
if ($_REQUEST['subpage']=='logs')
|
182 |
+
$logscurrent=" class=\"current\"";
|
183 |
+
if ($_REQUEST['subpage']=='backups')
|
184 |
+
$backupscurrent=" class=\"current\"";
|
185 |
+
if ($_REQUEST['subpage']=='tools')
|
186 |
+
$toolscurrent=" class=\"current\"";
|
187 |
+
if ($_REQUEST['subpage']=='settings')
|
188 |
+
$settingscurrent=" class=\"current\"";
|
189 |
+
echo "<ul class=\"subsubsub\">";
|
190 |
+
echo "<li><a href=\"admin.php?page=BackWPup\"$maincurrent>".__('Jobs','backwpup')."</a> |</li>";
|
191 |
+
echo "<li><a href=\"admin.php?page=BackWPup&subpage=logs\"$logscurrent>".__('Logs','backwpup')."</a> |</li>";
|
192 |
+
echo "<li><a href=\"admin.php?page=BackWPup&subpage=backups\"$backupscurrent>".__('Backups','backwpup')."</a> |</li>";
|
193 |
+
echo "<li><a href=\"admin.php?page=BackWPup&subpage=tools\"$toolscurrent>".__('Tools','backwpup')."</a> |</li>";
|
194 |
+
echo "<li><a href=\"admin.php?page=BackWPup&subpage=settings\"$settingscurrent>".__('Settings','backwpup')."</a></li>";
|
195 |
+
echo "</ul>";
|
196 |
+
}
|
197 |
+
|
198 |
+
//On Plugin activate
|
199 |
+
function backwpup_plugin_activate() {
|
200 |
+
//remove old cron jobs
|
201 |
+
$jobs=(array)get_option('backwpup_jobs');
|
202 |
+
foreach ($jobs as $jobid => $jobvalue) {
|
203 |
+
if ($time=wp_next_scheduled('backwpup_cron',array('jobid'=>$jobid))) {
|
204 |
+
wp_unschedule_event($time,'backwpup_cron',array('jobid'=>$jobid));
|
205 |
}
|
|
|
206 |
}
|
207 |
+
wp_clear_scheduled_hook('backwpup_cron');
|
208 |
+
//make schedule
|
209 |
+
wp_schedule_event(0, 'backwpup_int', 'backwpup_cron');
|
210 |
+
//Set defaults
|
211 |
+
$cfg=get_option('backwpup'); //Load Settings
|
212 |
+
if (empty($cfg['mailsndemail'])) $cfg['mailsndemail']=sanitize_email(get_bloginfo( 'admin_email' ));
|
213 |
+
if (empty($cfg['mailsndname'])) $cfg['mailsndname']='BackWPup '.get_bloginfo( 'name' );
|
214 |
+
if (empty($cfg['mailmethod'])) $cfg['mailmethod']='mail';
|
215 |
+
if (empty($cfg['mailsendmail'])) $cfg['mailsendmail']=substr(ini_get('sendmail_path'),0,strpos(ini_get('sendmail_path'),' -'));
|
216 |
+
if (empty($cfg['maxlogs'])) $cfg['maxlogs']=0;
|
217 |
+
if (!function_exists('gzopen') or !isset($cfg['gzlogs'])) $cfg['gzlogs']=false;
|
218 |
+
if (empty($cfg['dirtemp'])) {
|
219 |
+
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
220 |
+
$cfg['dirtemp']=backwpup_get_upload_dir();
|
221 |
+
}
|
222 |
+
if (empty($cfg['dirlogs'])) {
|
223 |
+
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
224 |
+
$cfg['dirlogs']=str_replace('\\','/',trailingslashit(WP_CONTENT_DIR)).'backwpup-'.$rand.'-logs/';
|
225 |
}
|
226 |
+
update_option('backwpup',$cfg);
|
227 |
+
}
|
228 |
|
229 |
+
//on Plugin deaktivate
|
230 |
+
function backwpup_plugin_deactivate() {
|
231 |
+
//remove old cron jobs
|
232 |
+
$jobs=(array)get_option('backwpup_jobs');
|
233 |
+
foreach ($jobs as $jobid => $jobvalue) {
|
234 |
+
if ($time=wp_next_scheduled('backwpup_cron',array('jobid'=>$jobid))) {
|
235 |
+
wp_unschedule_event($time,'backwpup_cron',array('jobid'=>$jobid));
|
236 |
}
|
|
|
237 |
}
|
238 |
+
wp_clear_scheduled_hook('backwpup_cron');
|
239 |
+
}
|
240 |
|
241 |
+
//add edit setting to plugins page
|
242 |
+
function backwpup_plugin_options_link($links) {
|
243 |
+
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
244 |
+
return $links;
|
245 |
+
$settings_link='<a href="admin.php?page=BackWPup" title="' . __('Go to Settings Page','backwpup') . '" class="edit">' . __('Settings') . '</a>';
|
246 |
+
array_unshift( $links, $settings_link );
|
247 |
+
return $links;
|
248 |
+
}
|
249 |
+
|
250 |
+
//add links on plugins page
|
251 |
+
function backwpup_plugin_links($links, $file) {
|
252 |
+
if (!current_user_can('install_plugins'))
|
253 |
+
return $links;
|
254 |
+
if ($file == BACKWPUP_PLUGIN_BASEDIR.'/backwpup.php') {
|
255 |
+
$links[] = '<a href="http://wordpress.org/extend/plugins/backwpup/faq/" target="_blank">' . __('FAQ') . '</a>';
|
256 |
+
$links[] = '<a href="http://wordpress.org/tags/backwpup/" target="_blank">' . __('Support') . '</a>';
|
257 |
+
$links[] = '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=daniel%40huesken-net%2ede&item_name=Daniel%20Huesken%20Plugin%20Donation&item_number=BackWPup&no_shipping=0&no_note=1&tax=0&currency_code=EUR&lc=DE&bn=PP%2dDonationsBF&charset=UTF%2d8" target="_blank">' . __('Donate') . '</a>';
|
258 |
}
|
259 |
+
return $links;
|
260 |
+
}
|
261 |
+
|
262 |
+
//Add cron interval
|
263 |
+
function backwpup_intervals($schedules) {
|
264 |
+
$intervals['backwpup_int']=array('interval' => '300', 'display' => __('BackWPup', 'backwpup'));
|
265 |
+
$schedules=array_merge($intervals,$schedules);
|
266 |
+
return $schedules;
|
267 |
+
}
|
268 |
+
|
269 |
+
//cron work
|
270 |
+
function backwpup_cron() {
|
271 |
+
$jobs=(array)get_option('backwpup_jobs');
|
272 |
+
foreach ($jobs as $jobid => $jobvalue) {
|
273 |
+
if (!$jobvalue['activated'])
|
274 |
+
continue;
|
275 |
+
if ($jobvalue['cronnextrun']<=current_time('timestamp')) {
|
276 |
+
backwpup_dojob($jobid);
|
277 |
}
|
278 |
}
|
279 |
+
}
|
280 |
|
281 |
+
//DoJob
|
282 |
+
function backwpup_dojob($jobid) {
|
283 |
+
global $backwpup_logfile;
|
284 |
+
if (empty($jobid))
|
285 |
+
return false;
|
286 |
+
require_once(dirname(__FILE__).'/backwpup_dojob.php');
|
287 |
+
$backwpup_dojob= new backwpup_dojob($jobid);
|
288 |
+
unset($backwpup_dojob);
|
289 |
+
return $backwpup_logfile;
|
290 |
+
}
|
291 |
+
|
292 |
+
//file size
|
293 |
+
function backwpup_formatBytes($bytes, $precision = 2) {
|
294 |
+
$units = array('B', 'KB', 'MB', 'GB', 'TB');
|
295 |
+
$bytes = max($bytes, 0);
|
296 |
+
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
|
297 |
+
$pow = min($pow, count($units) - 1);
|
298 |
+
$bytes /= pow(1024, $pow);
|
299 |
+
return round($bytes, $precision) . ' ' . $units[$pow];
|
300 |
+
}
|
301 |
+
|
302 |
+
//echo long backup type name
|
303 |
+
function backwpup_backup_types($type='',$echo=false) {
|
304 |
+
$typename='';
|
305 |
+
if (!empty($type)) {
|
306 |
+
$todo=explode('+',$type);
|
307 |
+
foreach($todo as $key => $value) {
|
308 |
+
switch($value) {
|
309 |
+
case 'WPEXP':
|
310 |
+
$typename.=__('WP XML Export','backwpup')."<br />";
|
311 |
+
break;
|
312 |
+
case 'DB':
|
313 |
+
$typename.=__('Database Backup','backwpup')."<br />";
|
314 |
+
break;
|
315 |
+
case 'FILE':
|
316 |
+
$typename.=__('File Backup','backwpup')."<br />";
|
317 |
+
break;
|
318 |
+
case 'OPTIMIZE':
|
319 |
+
$typename.=__('Optimize Database Tables','backwpup')."<br />";
|
320 |
+
break;
|
321 |
+
case 'CHECK':
|
322 |
+
$typename.=__('Check Database Tables','backwpup')."<br />";
|
323 |
+
break;
|
|
|
324 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
325 |
}
|
326 |
+
} else {
|
327 |
+
$typename=array('WPEXP','DB','FILE','OPTIMIZE','CHECK');
|
328 |
+
}
|
329 |
|
330 |
+
if ($echo)
|
331 |
+
echo $typename;
|
332 |
+
else
|
333 |
+
return $typename;
|
334 |
+
}
|
|
|
|
|
|
|
335 |
|
336 |
+
//read log file header
|
337 |
+
function backwpup_read_logheader($logfile) {
|
338 |
+
$headers=array("backwpup_version" => "version","backwpup_logtime" => "logtime","backwpup_errors" => "errors","backwpup_warnings" => "warnings","backwpup_jobid" => "jobid","backwpup_jobname" => "name","backwpup_jobtype" => "type","backwpup_jobruntime" => "runtime","backwpup_backupfilesize" => "backupfilesize");
|
339 |
+
if (!is_readable($logfile))
|
340 |
+
return false;
|
341 |
+
//Read file
|
342 |
+
if (strtolower(substr($logfile,-3))==".gz") {
|
343 |
+
$fp = gzopen( $logfile, 'r' );
|
344 |
+
$file_data = gzread( $fp, 1536 ); // Pull only the first 1,5kiB of the file in.
|
345 |
+
gzclose( $fp );
|
346 |
+
} else {
|
347 |
+
$fp = fopen( $logfile, 'r' );
|
348 |
+
$file_data = fread( $fp, 1536 ); // Pull only the first 1,5kiB of the file in.
|
349 |
+
fclose( $fp );
|
350 |
+
}
|
351 |
|
352 |
+
//get data form file
|
353 |
+
foreach ($headers as $keyword => $field) {
|
354 |
+
preg_match('/(<meta name="'.$keyword.'" content="(.*)" \/>)/i',$file_data,$content);
|
355 |
+
if (!empty($content))
|
356 |
+
$joddata[$field]=$content[2];
|
357 |
+
else
|
358 |
+
$joddata[$field]='';
|
359 |
}
|
360 |
|
361 |
+
if (empty($joddata['logtime']))
|
362 |
+
$joddata['logtime']=filectime($logfile);
|
363 |
+
|
364 |
+
return $joddata;
|
365 |
+
}
|
366 |
+
|
367 |
+
|
368 |
+
//Dashboard widget
|
369 |
+
function backwpup_dashboard_output() {
|
370 |
+
global $wpdb;
|
371 |
+
if (!current_user_can(BACKWPUP_USER_CAPABILITY))
|
372 |
+
return;
|
373 |
+
$cfg=get_option('backwpup');
|
374 |
+
echo '<strong>'.__('Logs:','backwpup').'</strong><br />';
|
375 |
+
//get log files
|
376 |
+
$logfiles=array();
|
377 |
+
if ( $dir = @opendir( $cfg['dirlogs'] ) ) {
|
378 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
379 |
+
if (is_file($cfg['dirlogs'].'/'.$file) and 'backwpup_log_' == substr($file,0,strlen('backwpup_log_')) and ('.html' == substr($file,-5) or '.html.gz' == substr($file,-8)))
|
380 |
+
$logfiles[]=$file;
|
381 |
+
}
|
382 |
+
closedir( $dir );
|
383 |
+
rsort($logfiles);
|
384 |
+
}
|
385 |
|
386 |
+
if (is_array($logfiles)) {
|
387 |
+
$count=0;
|
388 |
+
foreach ($logfiles as $logfile) {
|
389 |
+
$logdata=backwpup_read_logheader($cfg['dirlogs'].'/'.$logfile);
|
390 |
+
echo '<a href="'.wp_nonce_url('admin.php?page=BackWPup&subpage=view_log&logfile='.$cfg['dirlogs'].'/'.$logfile, 'view-log_'.$logfile).'" title="'.__('View Log','backwpup').'">'.date_i18n(get_option('date_format'),$logdata['logtime']).' '.date_i18n(get_option('time_format'),$logdata['logtime']).': <i>';
|
391 |
+
if (empty($logdata['name']))
|
392 |
+
echo $logdata['type'];
|
393 |
+
else
|
394 |
+
echo $logdata['name'];
|
395 |
+
echo '</i>';
|
396 |
+
if($logdata['errors']>0 or $logdata['warnings']>0) {
|
397 |
+
if ($logdata['errors']>0)
|
398 |
+
echo ' <span style="color:red;">'.$logdata['errors'].' '.__('ERROR(S)','backwpup').'</span>';
|
399 |
+
if ($logdata['warnings']>0)
|
400 |
+
echo ' <span style="color:yellow;">'.$logdata['warnings'].' '.__('WARNING(S)','backwpup').'</span>';
|
401 |
+
} else {
|
402 |
+
echo ' <span style="color:green;">'.__('OK','backwpup').'</span>';
|
403 |
}
|
404 |
+
echo '</a><br />';
|
405 |
+
$count++;
|
406 |
+
if ($count>=5)
|
407 |
+
break;
|
408 |
}
|
409 |
+
} else {
|
410 |
+
echo '<i>'.__('none','backwpup').'</i><br />';
|
411 |
+
}
|
412 |
+
$jobs=(array)get_option('backwpup_jobs');
|
413 |
+
echo '<strong>'.__('Scheduled Jobs:','backwpup').'</strong><br />';
|
414 |
+
foreach ($jobs as $jobid => $jobvalue) {
|
415 |
+
if ($jobvalue['activated']) {
|
416 |
+
echo '<a href="'.wp_nonce_url('admin.php?page=BackWPup&action=edit&jobid='.$jobid, 'edit-job').'" title="'.__('Edit Job','backwpup').'">';
|
417 |
+
if ($jobvalue['starttime']>0 and empty($jobvalue['stoptime'])) {
|
418 |
+
$runtime=current_time('timestamp')-$jobvalue['starttime'];
|
419 |
+
echo __('Running since:','backwpup').' '.$runtime.' '.__('sec.','backwpup');
|
420 |
+
} elseif ($jobvalue['activated']) {
|
421 |
+
echo date(get_option('date_format'),$jobvalue['cronnextrun']).' '.date(get_option('time_format'),$jobvalue['cronnextrun']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
422 |
}
|
423 |
+
echo ': <span>'.$jobvalue['name'].'</span></a><br />';
|
|
|
424 |
}
|
425 |
+
}
|
426 |
+
if (empty($jobs))
|
427 |
+
echo '<i>'.__('none','backwpup').'</i><br />';
|
428 |
+
|
429 |
+
}
|
430 |
+
|
431 |
+
//add dashboard widget
|
432 |
+
function backwpup_add_dashboard() {
|
433 |
+
wp_add_dashboard_widget( 'backwpup_dashboard_widget', 'BackWPup', 'backwpup_dashboard_output' );
|
434 |
+
}
|
435 |
+
|
436 |
+
//turn cache off
|
437 |
+
function backwpup_meta_no_cache() {
|
438 |
+
echo "<meta http-equiv=\"expires\" content=\"0\" />\n";
|
439 |
+
echo "<meta http-equiv=\"pragma\" content=\"no-cache\" />\n";
|
440 |
+
echo "<meta http-equiv=\"cache-control\" content=\"no-cache\" />\n";
|
441 |
+
}
|
442 |
+
|
443 |
+
function backwpup_send_no_cache_header() {
|
444 |
+
header("Expires: 0");
|
445 |
+
header("Cache-Control: no-cache, must-revalidate");
|
446 |
+
header("Pragma: no-cache");
|
447 |
+
header("Cache-Control: post-check=0, pre-check=0");
|
448 |
+
}
|
449 |
+
|
450 |
+
function backwpup_get_upload_dir() {
|
451 |
+
global $switched;
|
452 |
+
$upload_path = get_option( 'upload_path' );
|
453 |
+
$upload_path = trim($upload_path);
|
454 |
+
$main_override = defined( 'MULTISITE' ) && is_main_site();
|
455 |
+
if ( empty($upload_path) ) {
|
456 |
+
$dir = WP_CONTENT_DIR . '/uploads';
|
457 |
+
} else {
|
458 |
+
$dir = $upload_path;
|
459 |
+
if ( 'wp-content/uploads' == $upload_path ) {
|
460 |
+
$dir = WP_CONTENT_DIR . '/uploads';
|
461 |
+
} elseif ( 0 !== strpos($dir, ABSPATH) ) {
|
462 |
+
// $dir is absolute, $upload_path is (maybe) relative to ABSPATH
|
463 |
+
$dir = path_join( ABSPATH, $dir );
|
464 |
}
|
|
|
|
|
|
|
465 |
}
|
466 |
+
if ( defined('UPLOADS') && !$main_override && ( !isset( $switched ) || $switched === false ) ) {
|
467 |
+
$dir = ABSPATH . UPLOADS;
|
|
|
|
|
468 |
}
|
469 |
+
if (function_exists('is_multisite')) {
|
470 |
+
if ( is_multisite() && !$main_override && ( !isset( $switched ) || $switched === false ) ) {
|
471 |
+
if ( defined( 'BLOGUPLOADDIR' ) )
|
472 |
+
$dir = untrailingslashit(BLOGUPLOADDIR);
|
473 |
+
}
|
|
|
474 |
}
|
475 |
|
476 |
+
return str_replace('\\','/',trailingslashit($dir));
|
477 |
+
}
|
478 |
+
|
479 |
+
function backwpup_get_exclude_wp_dirs($folder) {
|
480 |
+
$folder=trailingslashit(str_replace('\\','/',$folder));
|
481 |
+
$excludedir=array();
|
482 |
+
if (false !== stripos(trailingslashit(str_replace('\\','/',ABSPATH)),$folder) and trailingslashit(str_replace('\\','/',ABSPATH))!=$folder)
|
483 |
+
$excludedir[]=trailingslashit(str_replace('\\','/',ABSPATH));
|
484 |
+
if (false !== stripos(trailingslashit(str_replace('\\','/',WP_CONTENT_DIR)),$folder) and trailingslashit(str_replace('\\','/',WP_CONTENT_DIR))!=$folder)
|
485 |
+
$excludedir[]=trailingslashit(str_replace('\\','/',WP_CONTENT_DIR));
|
486 |
+
if (false !== stripos(trailingslashit(str_replace('\\','/',WP_PLUGIN_DIR)),$folder) and trailingslashit(str_replace('\\','/',WP_PLUGIN_DIR))!=$folder)
|
487 |
+
$excludedir[]=trailingslashit(str_replace('\\','/',WP_PLUGIN_DIR));
|
488 |
+
if (false !== stripos(str_replace('\\','/',trailingslashit(WP_CONTENT_DIR).'themes/'),$folder) and str_replace('\\','/',trailingslashit(WP_CONTENT_DIR).'themes/')!=$folder)
|
489 |
+
$excludedir[]=str_replace('\\','/',trailingslashit(WP_CONTENT_DIR).'themes/');
|
490 |
+
if (false !== stripos(backwpup_get_upload_dir(),$folder) and backwpup_get_upload_dir()!=$folder)
|
491 |
+
$excludedir[]=backwpup_get_upload_dir();
|
492 |
+
//Exclude Backup dirs
|
493 |
+
$jobs=(array)get_option('backwpup_jobs');
|
494 |
+
foreach($jobs as $jobsvale) {
|
495 |
+
if (!empty($jobsvale['backupdir']) and $jobsvale['backupdir']!='/')
|
496 |
+
$excludedir[]=trailingslashit(str_replace('\\','/',$jobsvale['backupdir']));
|
497 |
}
|
498 |
+
return $excludedir;
|
499 |
+
}
|
500 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
501 |
|
502 |
+
function backwpup_calc_db_size($jobvalues) {
|
503 |
+
global $wpdb;
|
504 |
+
$dbsize=array('size'=>0,'num'=>0,'rows'=>0);
|
505 |
+
$status=$wpdb->get_results("SHOW TABLE STATUS FROM `".DB_NAME."`;", ARRAY_A);
|
506 |
+
foreach($status as $tablekey => $tablevalue) {
|
507 |
+
if (!in_array($tablevalue['Name'],$jobvalues['dbexclude'])) {
|
508 |
+
$dbsize['size']=$dbsize['size']+$tablevalue["Data_length"]+$tablevalue["Index_length"];
|
509 |
+
$dbsize['num']++;
|
510 |
+
$dbsize['rows']=$dbsize['rows']+$tablevalue["Rows"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
511 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
512 |
}
|
513 |
+
return $dbsize;
|
514 |
+
}
|
515 |
|
516 |
|
517 |
+
function _backwpup_calc_file_size_file_list_folder( $folder = '', $levels = 100, $excludes=array(),$excludedirs=array()) {
|
518 |
+
global $backwpup_temp_files;
|
519 |
+
if ( !empty($folder) and $levels and $dir = @opendir( $folder )) {
|
520 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
521 |
+
if ( in_array($file, array('.', '..','.svn') ) )
|
522 |
+
continue;
|
523 |
+
foreach ($excludes as $exclusion) { //exclude dirs and files
|
524 |
+
if (false !== stripos($folder.$file,$exclusion) and !empty($exclusion) and $exclusion!='/')
|
525 |
+
continue 2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
526 |
}
|
527 |
+
if ( @is_dir( $folder.$file )) {
|
528 |
+
if (!in_array(trailingslashit($folder.$file),$excludedirs))
|
529 |
+
_backwpup_calc_file_size_file_list_folder( trailingslashit($folder.$file), $levels - 1, $excludes);
|
530 |
+
} elseif ((@is_file( $folder.$file ) or @is_executable($folder.$file)) and @is_readable($folder.$file)) {
|
531 |
+
$backwpup_temp_files['num']++;
|
532 |
+
$backwpup_temp_files['size']=$backwpup_temp_files['size']+filesize($folder.$file);
|
533 |
+
}
|
534 |
+
}
|
535 |
+
@closedir( $dir );
|
536 |
}
|
537 |
+
return $files;
|
538 |
+
}
|
539 |
+
|
540 |
+
function backwpup_calc_file_size($jobvalues) {
|
541 |
+
global $backwpup_temp_files;
|
542 |
+
$backwpup_temp_files=array('size'=>0,'num'=>0);
|
543 |
+
//Exclude Temp Files
|
544 |
+
$backwpup_exclude=explode(',',trim($jobvalues['fileexclude']));
|
545 |
+
$backwpup_exclude=array_unique($backwpup_exclude);
|
546 |
+
|
547 |
+
//File list for blog folders
|
548 |
+
if ($jobvalues['backuproot'])
|
549 |
+
_backwpup_calc_file_size_file_list_folder(trailingslashit(ABSPATH),100,$backwpup_exclude,array_merge($jobvalues['backuprootexcludedirs'],backwpup_get_exclude_wp_dirs(ABSPATH)));
|
550 |
+
if ($jobvalues['backupcontent'])
|
551 |
+
_backwpup_calc_file_size_file_list_folder(trailingslashit(WP_CONTENT_DIR),100,$backwpup_exclude,array_merge($jobvalues['backupcontentexcludedirs'],backwpup_get_exclude_wp_dirs(WP_CONTENT_DIR)));
|
552 |
+
if ($jobvalues['backupplugins'])
|
553 |
+
_backwpup_calc_file_size_file_list_folder(trailingslashit(WP_PLUGIN_DIR),100,$backwpup_exclude,array_merge($jobvalues['backuppluginsexcludedirs'],backwpup_get_exclude_wp_dirs(WP_PLUGIN_DIR)));
|
554 |
+
if ($jobvalues['backupthemes'])
|
555 |
+
_backwpup_calc_file_size_file_list_folder(trailingslashit(trailingslashit(WP_CONTENT_DIR).'themes'),100,$backwpup_exclude,array_merge($jobvalues['backupthemesexcludedirs'],backwpup_get_exclude_wp_dirs(trailingslashit(WP_CONTENT_DIR).'themes')));
|
556 |
+
if ($jobvalues['backupuploads'])
|
557 |
+
_backwpup_calc_file_size_file_list_folder(trailingslashit(backwpup_get_upload_dir()),100,$backwpup_exclude,array_merge($jobvalues['backupuploadsexcludedirs'],backwpup_get_exclude_wp_dirs(backwpup_get_upload_dir())));
|
558 |
+
|
559 |
+
//include dirs
|
560 |
+
if (!empty($jobvalues['dirinclude'])) {
|
561 |
+
$dirinclude=explode(',',$jobvalues['dirinclude']);
|
562 |
+
$dirinclude=array_unique($dirinclude);
|
563 |
+
//Crate file list for includes
|
564 |
+
foreach($dirinclude as $dirincludevalue) {
|
565 |
+
if (is_dir($dirincludevalue))
|
566 |
+
_backwpup_calc_file_size_file_list_folder(trailingslashit($dirincludevalue),100,$backwpup_exclude);
|
567 |
}
|
|
|
|
|
|
|
568 |
}
|
569 |
|
570 |
+
return $backwpup_temp_files;
|
571 |
+
|
572 |
+
}
|
573 |
+
|
574 |
+
//Calcs next run for a cron string as timestamp
|
575 |
+
function backwpup_cron_next($cronstring) {
|
576 |
+
//Cronstring zerlegen
|
577 |
+
list($cronstr['minutes'],$cronstr['hours'],$cronstr['mday'],$cronstr['mon'],$cronstr['wday'])=explode(' ',$cronstring,5);
|
578 |
+
|
579 |
+
//make arrys form string
|
580 |
+
foreach ($cronstr as $key => $value) {
|
581 |
+
if (strstr($value,','))
|
582 |
+
$cronarray[$key]=explode(',',$value);
|
583 |
+
else
|
584 |
+
$cronarray[$key]=array(0=>$value);
|
585 |
+
}
|
586 |
+
//make arrys complete with ranges and steps
|
587 |
+
foreach ($cronarray as $cronarraykey => $cronarrayvalue) {
|
588 |
+
$cron[$cronarraykey]=array();
|
589 |
+
foreach ($cronarrayvalue as $key => $value) {
|
590 |
+
//steps
|
591 |
+
$step=1;
|
592 |
+
if (strstr($value,'/'))
|
593 |
+
list($value,$step)=explode('/',$value,2);
|
594 |
+
//replase weekeday 7 with 0 for sundays
|
595 |
+
if ($cronarraykey=='wday')
|
596 |
+
$value=str_replace('7','0',$value);
|
597 |
+
//ranges
|
598 |
+
if (strstr($value,'-')) {
|
599 |
+
list($first,$last)=explode('-',$value,2);
|
600 |
+
if (!is_numeric($first) or !is_numeric($last) or $last>60 or $first>60) //check
|
601 |
+
return false;
|
602 |
+
if ($cronarraykey=='minutes' and $step<5) //set step ninmum to 5 min.
|
603 |
+
$step=5;
|
604 |
+
$range=array();
|
605 |
+
for ($i=$first;$i<=$last;$i=$i+$step)
|
606 |
+
$range[]=$i;
|
607 |
+
$cron[$cronarraykey]=array_merge($cron[$cronarraykey],$range);
|
608 |
+
} elseif ($value=='*') {
|
609 |
+
$range=array();
|
610 |
+
if ($cronarraykey=='minutes') {
|
611 |
+
if ($step<5) //set step ninmum to 5 min.
|
612 |
$step=5;
|
613 |
+
for ($i=0;$i<=59;$i=$i+$step)
|
|
|
614 |
$range[]=$i;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
615 |
}
|
616 |
+
if ($cronarraykey=='hours') {
|
617 |
+
for ($i=0;$i<=23;$i=$i+$step)
|
618 |
+
$range[]=$i;
|
619 |
+
}
|
620 |
+
if ($cronarraykey=='mday') {
|
621 |
+
for ($i=$step;$i<=31;$i=$i+$step)
|
622 |
+
$range[]=$i;
|
623 |
+
}
|
624 |
+
if ($cronarraykey=='mon') {
|
625 |
+
for ($i=$step;$i<=12;$i=$i+$step)
|
626 |
+
$range[]=$i;
|
627 |
+
}
|
628 |
+
if ($cronarraykey=='wday') {
|
629 |
+
for ($i=0;$i<=6;$i=$i+$step)
|
630 |
+
$range[]=$i;
|
631 |
+
}
|
632 |
+
$cron[$cronarraykey]=array_merge($cron[$cronarraykey],$range);
|
633 |
+
} else {
|
634 |
+
//Month names
|
635 |
+
if (strtolower($value)=='jan')
|
636 |
+
$value=1;
|
637 |
+
if (strtolower($value)=='feb')
|
638 |
+
$value=2;
|
639 |
+
if (strtolower($value)=='mar')
|
640 |
+
$value=3;
|
641 |
+
if (strtolower($value)=='apr')
|
642 |
+
$value=4;
|
643 |
+
if (strtolower($value)=='may')
|
644 |
+
$value=5;
|
645 |
+
if (strtolower($value)=='jun')
|
646 |
+
$value=6;
|
647 |
+
if (strtolower($value)=='jul')
|
648 |
+
$value=7;
|
649 |
+
if (strtolower($value)=='aug')
|
650 |
+
$value=8;
|
651 |
+
if (strtolower($value)=='sep')
|
652 |
+
$value=9;
|
653 |
+
if (strtolower($value)=='oct')
|
654 |
+
$value=10;
|
655 |
+
if (strtolower($value)=='nov')
|
656 |
+
$value=11;
|
657 |
+
if (strtolower($value)=='dec')
|
658 |
+
$value=12;
|
659 |
+
//Week Day names
|
660 |
+
if (strtolower($value)=='sun')
|
661 |
+
$value=0;
|
662 |
+
if (strtolower($value)=='sat')
|
663 |
+
$value=6;
|
664 |
+
if (strtolower($value)=='mon')
|
665 |
+
$value=1;
|
666 |
+
if (strtolower($value)=='tue')
|
667 |
+
$value=2;
|
668 |
+
if (strtolower($value)=='wed')
|
669 |
+
$value=3;
|
670 |
+
if (strtolower($value)=='thu')
|
671 |
+
$value=4;
|
672 |
+
if (strtolower($value)=='fri')
|
673 |
+
$value=5;
|
674 |
+
if (!is_numeric($value) or $value>60) //check
|
675 |
+
return false;
|
676 |
+
$cron[$cronarraykey]=array_merge($cron[$cronarraykey],array(0=>$value));
|
677 |
}
|
678 |
}
|
679 |
+
}
|
680 |
|
681 |
+
//calc next timestamp
|
682 |
+
$currenttime=current_time('timestamp');
|
683 |
+
foreach (array(date('Y'),date('Y')+1) as $year) {
|
684 |
+
foreach ($cron['mon'] as $mon) {
|
685 |
+
foreach ($cron['mday'] as $mday) {
|
686 |
+
foreach ($cron['hours'] as $hours) {
|
687 |
+
foreach ($cron['minutes'] as $minutes) {
|
688 |
+
$timestamp=mktime($hours,$minutes,0,$mon,$mday,$year);
|
689 |
+
if (in_array(date('w',$timestamp),$cron['wday']) and $timestamp>$currenttime) {
|
690 |
+
return $timestamp;
|
|
|
691 |
}
|
692 |
}
|
693 |
}
|
694 |
}
|
695 |
}
|
|
|
696 |
}
|
697 |
+
return false;
|
698 |
+
}
|
699 |
+
|
700 |
+
function backwpup_env_checks() {
|
701 |
+
global $wp_version,$backwpup_admin_message;
|
702 |
+
$message='';
|
703 |
+
$checks=true;
|
704 |
+
$cfg=get_option('backwpup');
|
705 |
+
if (version_compare($wp_version, '2.8', '<')) { // check WP Version
|
706 |
+
$message.=__('- WordPress 2.8 or heiger needed!','backwpup') . '<br />';
|
707 |
+
$checks=false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
708 |
}
|
709 |
+
if (version_compare(phpversion(), '5.2.0', '<')) { // check PHP Version
|
710 |
+
$message.=__('- PHP 5.2.0 or higher needed!','backwpup') . '<br />';
|
711 |
+
$checks=false;
|
|
|
712 |
}
|
713 |
+
if (!is_dir($cfg['dirlogs'])) { // check logs folder
|
714 |
+
$message.=__('- Logs Folder not exists (Try too create it on first Job run):','backwpup') . ' '.$cfg['dirlogs'].'<br />';
|
715 |
+
}
|
716 |
+
if (!is_writable($cfg['dirlogs'])) { // check logs folder
|
717 |
+
$message.=__('- Logs Folder not writeable:','backwpup') . ' '.$cfg['dirlogs'].'<br />';
|
718 |
+
}
|
719 |
+
if (!is_dir($cfg['dirtemp'])) { // check Temp folder
|
720 |
+
$message.=__('- Temp Folder not exists (Try too create it on first Job run):','backwpup') . ' '.$cfg['dirtemp'].'<br />';
|
721 |
+
}
|
722 |
+
if (!is_writable($cfg['dirtemp'])) { // check Temp folder
|
723 |
+
$message.=__('- Temp Folder not writeable:','backwpup') . ' '.$cfg['dirtemp'].'<br />';
|
724 |
+
}
|
725 |
+
$jobs=(array)get_option('backwpup_jobs');
|
726 |
+
foreach ($jobs as $jobid => $jobvalue) { //check for old cheduling
|
727 |
+
if (isset($jobvalue['scheduletime']) and empty($jobvalue['cron']))
|
728 |
+
$message.=__('- Please Check Scheduling time for Job:','backwpup') . ' '.$jobid.'. '.$jobvalue['name'].'<br />';
|
729 |
+
}
|
730 |
+
if (wp_next_scheduled('backwpup_cron')!=0 and wp_next_scheduled('backwpup_cron')>(time()+360)) { //check cron jobs work
|
731 |
+
$message.=__("- WP-Cron don't working please check it!","backwpup") .'<br />';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
732 |
}
|
733 |
+
//put massage if one
|
734 |
+
if (!empty($message))
|
735 |
+
$backwpup_admin_message = '<div id="message" class="error fade"><strong>BackWPup:</strong><br />'.$message.'</div>';
|
736 |
+
return $checks;
|
737 |
+
}
|
738 |
+
|
739 |
+
function backwpup_admin_notice() {
|
740 |
+
global $backwpup_admin_message;
|
741 |
+
echo $backwpup_admin_message;
|
742 |
+
}
|
743 |
|
744 |
?>
|
app/functions5.php
CHANGED
@@ -3,509 +3,509 @@
|
|
3 |
if ( !defined('ABSPATH') )
|
4 |
die('-1');
|
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 |
-
if ($jobsettings['scheduleintervaltype']==3600) { //Houer
|
33 |
-
$jobsettings['cron']=(date('i',$jobsettings['scheduletime'])*1).' */'.$jobsettings['scheduleintervalteimes'].' * * *';
|
34 |
-
}
|
35 |
-
if ($jobsettings['scheduleintervaltype']==86400) { //Days
|
36 |
-
$jobsettings['cron']=(date('i',$jobsettings['scheduletime'])*1).' '.date('G',$jobsettings['scheduletime']).' */'.$jobsettings['scheduleintervalteimes'].' * *';
|
37 |
-
}
|
38 |
}
|
39 |
-
|
40 |
-
|
41 |
-
$jobsettings['cron']='0 3 * * *';
|
42 |
-
|
43 |
-
if (!isset($jobsettings['cronnextrun']) or !is_numeric($jobsettings['cronnextrun']))
|
44 |
-
$jobsettings['cronnextrun']=backwpup_cron_next($jobs[$jobid]['cron']);;
|
45 |
-
|
46 |
-
if (!is_string($jobsettings['mailaddresslog']) or false === $pos=strpos($jobsettings['mailaddresslog'],'@') or false === strpos($jobsettings['mailaddresslog'],'.',$pos))
|
47 |
-
$jobsettings['mailaddresslog']=get_option('admin_email');
|
48 |
-
|
49 |
-
if (!isset($jobsettings['mailerroronly']) or !is_bool($jobsettings['mailerroronly']))
|
50 |
-
$jobsettings['mailerroronly']=true;
|
51 |
-
|
52 |
-
if (!isset($jobsettings['dbexclude']) or !is_array($jobsettings['dbexclude'])) {
|
53 |
-
$jobsettings['dbexclude']=array();
|
54 |
-
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
55 |
-
foreach ($tables as $table) {
|
56 |
-
if (substr($table,0,strlen($wpdb->prefix))!=$wpdb->prefix)
|
57 |
-
$jobsettings['dbexclude'][]=$table;
|
58 |
-
}
|
59 |
}
|
60 |
-
$
|
61 |
-
|
62 |
-
if (empty($jobsettings['dbexclude'][$key]) or !in_array($value,$tables))
|
63 |
-
unset($jobsettings['dbexclude'][$key]);
|
64 |
}
|
65 |
-
|
66 |
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
-
|
71 |
-
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
$
|
76 |
-
foreach($
|
77 |
-
|
78 |
-
|
79 |
-
unset($fileexclude[$key]);
|
80 |
-
}
|
81 |
-
sort($fileexclude);
|
82 |
-
$jobsettings['fileexclude']=implode(',',$fileexclude);
|
83 |
-
|
84 |
-
if (!isset($jobsettings['dirinclude']) or !is_string($jobsettings['dirinclude']))
|
85 |
-
$jobsettings['dirinclude']='';
|
86 |
-
$dirinclude=explode(',',$jobsettings['dirinclude']);
|
87 |
-
foreach($dirinclude as $key => $value) {
|
88 |
-
$dirinclude[$key]=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($value))));
|
89 |
-
if ($dirinclude[$key]=='/' or empty($dirinclude[$key]) or !is_dir($dirinclude[$key]))
|
90 |
-
unset($dirinclude[$key]);
|
91 |
}
|
92 |
-
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
-
|
96 |
-
|
97 |
|
98 |
-
|
99 |
-
|
100 |
|
101 |
-
|
102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
-
|
105 |
-
|
106 |
|
107 |
-
|
108 |
-
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
foreach($jobsettings['backuprootexcludedirs'] as $key => $value) {
|
113 |
-
$jobsettings['backuprootexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
114 |
-
if (empty($jobsettings['backuprootexcludedirs'][$key]) or $jobsettings['backuprootexcludedirs'][$key]=='/' or !is_dir($jobsettings['backuprootexcludedirs'][$key]))
|
115 |
-
unset($jobsettings['backuprootexcludedirs'][$key]);
|
116 |
-
}
|
117 |
-
sort($jobsettings['backuprootexcludedirs']);
|
118 |
-
|
119 |
-
if (!isset($jobsettings['backupcontentexcludedirs']) or !is_array($jobsettings['backupcontentexcludedirs']))
|
120 |
-
$jobsettings['backupcontentexcludedirs']=array();
|
121 |
-
foreach($jobsettings['backupcontentexcludedirs'] as $key => $value) {
|
122 |
-
$jobsettings['backupcontentexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
123 |
-
if (empty($jobsettings['backupcontentexcludedirs'][$key]) or $jobsettings['backupcontentexcludedirs'][$key]=='/' or !is_dir($jobsettings['backupcontentexcludedirs'][$key]))
|
124 |
-
unset($jobsettings['backupcontentexcludedirs'][$key]);
|
125 |
-
}
|
126 |
-
sort($jobsettings['backupcontentexcludedirs']);
|
127 |
-
|
128 |
-
if (!isset($jobsettings['backuppluginsexcludedirs']) or !is_array($jobsettings['backuppluginsexcludedirs']))
|
129 |
-
$jobsettings['backuppluginsexcludedirs']=array();
|
130 |
-
foreach($jobsettings['backuppluginsexcludedirs'] as $key => $value) {
|
131 |
-
$jobsettings['backuppluginsexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
132 |
-
if (empty($jobsettings['backuppluginsexcludedirs'][$key]) or $jobsettings['backuppluginsexcludedirs'][$key]=='/' or !is_dir($jobsettings['backuppluginsexcludedirs'][$key]))
|
133 |
-
unset($jobsettings['backuppluginsexcludedirs'][$key]);
|
134 |
-
}
|
135 |
-
sort($jobsettings['backuppluginsexcludedirs']);
|
136 |
-
|
137 |
-
if (!isset($jobsettings['backupthemesexcludedirs']) or !is_array($jobsettings['backupthemesexcludedirs']))
|
138 |
-
$jobsettings['backupthemesexcludedirs']=array();
|
139 |
-
foreach($jobsettings['backupthemesexcludedirs'] as $key => $value) {
|
140 |
-
$jobsettings['backupthemesexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
141 |
-
if (empty($jobsettings['backupthemesexcludedirs'][$key]) or $jobsettings['backupthemesexcludedirs'][$key]=='/' or !is_dir($jobsettings['backupthemesexcludedirs'][$key]))
|
142 |
-
unset($jobsettings['backupthemesexcludedirs'][$key]);
|
143 |
-
}
|
144 |
-
sort($jobsettings['backupthemesexcludedirs']);
|
145 |
-
|
146 |
-
if (!isset($jobsettings['backupuploadsexcludedirs']) or !is_array($jobsettings['backupuploadsexcludedirs']))
|
147 |
-
$jobsettings['backupuploadsexcludedirs']=array();
|
148 |
-
foreach($jobsettings['backupuploadsexcludedirs'] as $key => $value) {
|
149 |
-
$jobsettings['backupuploadsexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
150 |
-
if (empty($jobsettings['backupuploadsexcludedirs'][$key]) or $jobsettings['backupuploadsexcludedirs'][$key]=='/' or !is_dir($jobsettings['backupuploadsexcludedirs'][$key]))
|
151 |
-
unset($jobsettings['backupuploadsexcludedirs'][$key]);
|
152 |
-
}
|
153 |
-
sort($jobsettings['backupuploadsexcludedirs']);
|
154 |
|
155 |
-
|
156 |
-
|
157 |
-
$jobsettings['fileformart']='.zip';
|
158 |
-
|
159 |
-
if (!isset($jobsettings['fileprefix']) or !is_string($jobsettings['fileprefix']))
|
160 |
-
$jobsettings['fileprefix']='backwpup_'.$jobid.'_';
|
161 |
-
|
162 |
-
if (!isset($jobsettings['mailefilesize']) or !is_float($jobsettings['mailefilesize']))
|
163 |
-
$jobsettings['mailefilesize']=0;
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
$jobsettings['backupdir']=str_replace('\\','/',trailingslashit(WP_CONTENT_DIR)).'backwpup-'.$rand.'/';
|
168 |
-
}
|
169 |
-
$jobsettings['backupdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['backupdir']))));
|
170 |
-
if ($jobsettings['backupdir']=='/')
|
171 |
-
$jobsettings['backupdir']='';
|
172 |
|
173 |
-
|
174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
-
|
177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
|
179 |
-
|
180 |
-
|
|
|
|
|
|
|
|
|
|
|
181 |
|
182 |
-
|
183 |
-
|
184 |
|
185 |
-
|
186 |
-
|
187 |
-
$jobsettings['ftpdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['ftpdir']))));
|
188 |
-
if (substr($jobsettings['ftpdir'],0,1)!='/')
|
189 |
-
$jobsettings['ftpdir']='/'.$jobsettings['ftpdir'];
|
190 |
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
if (!isset($jobsettings['ftppasv']) or !is_bool($jobsettings['ftppasv']))
|
195 |
-
$jobsettings['ftppasv']=true;
|
196 |
-
|
197 |
-
if (!isset($jobsettings['ftpssl']) or !is_bool($jobsettings['ftpssl']))
|
198 |
-
$jobsettings['ftpssl']=false;
|
199 |
|
200 |
-
|
201 |
-
|
202 |
|
203 |
-
|
204 |
-
|
|
|
|
|
|
|
205 |
|
206 |
-
|
207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
|
209 |
-
|
210 |
-
|
211 |
|
212 |
-
|
213 |
-
|
214 |
-
$jobsettings['awsdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['awsdir']))));
|
215 |
-
if (substr($jobsettings['awsdir'],0,1)=='/')
|
216 |
-
$jobsettings['awsdir']=substr($jobsettings['awsdir'],1);
|
217 |
|
218 |
-
|
219 |
-
|
220 |
|
221 |
-
|
222 |
-
|
223 |
|
224 |
-
|
225 |
-
|
|
|
|
|
|
|
226 |
|
227 |
-
|
228 |
-
|
229 |
|
230 |
-
|
231 |
-
|
232 |
-
$jobsettings['rscdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['rscdir']))));
|
233 |
-
if (substr($jobsettings['rscdir'],0,1)=='/')
|
234 |
-
$jobsettings['rscdir']=substr($jobsettings['rscdir'],1);
|
235 |
|
236 |
-
|
237 |
-
|
238 |
|
239 |
-
|
240 |
-
|
241 |
-
$jobsettings['dropemail']='';
|
242 |
|
243 |
-
|
244 |
-
|
|
|
|
|
|
|
245 |
|
246 |
-
|
247 |
-
|
248 |
-
$jobsettings['dropedir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['dropedir']))));
|
249 |
-
if (substr($jobsettings['dropedir'],0,1)=='/')
|
250 |
-
$jobsettings['dropedir']=substr($jobsettings['dropedir'],1);
|
251 |
-
|
252 |
-
if (!is_string($jobsettings['mailaddress']) or false === $pos=strpos($jobsettings['mailaddress'],'@') or false === strpos($jobsettings['mailaddress'],'.',$pos))
|
253 |
-
$jobsettings['mailaddress']='';
|
254 |
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
//ajax/normal get backup files and infos
|
260 |
-
function backwpup_get_backup_files($onlyjobid='') {
|
261 |
-
$jobs=(array)get_option('backwpup_jobs'); //Load jobs
|
262 |
-
$dests=explode(',',strtoupper(BACKWPUP_DESTS));
|
263 |
-
$filecounter=0;
|
264 |
-
$files=array();
|
265 |
-
$donefolders=array();
|
266 |
-
if (extension_loaded('curl') or @dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll')) {
|
267 |
-
if (!class_exists('CFRuntime'))
|
268 |
-
require_once(dirname(__FILE__).'/libs/aws/sdk.class.php');
|
269 |
-
if (!class_exists('CF_Authentication'))
|
270 |
-
require_once(dirname(__FILE__).'/libs/rackspace/cloudfiles.php');
|
271 |
-
}
|
272 |
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
297 |
}
|
298 |
-
closedir( $dir );
|
299 |
-
$donefolders[]=$jobvalue['backupdir'];
|
300 |
}
|
|
|
|
|
301 |
}
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
}
|
319 |
}
|
320 |
-
$donefolders[]=$jobvalue['awsAccessKey'].'|'.$jobvalue['awsBucket'].'|'.$jobvalue['awsdir'];
|
321 |
}
|
|
|
322 |
}
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
}
|
345 |
-
$donefolders[]=$jobvalue['rscUsername'].'|'.$jobvalue['rscContainer'].'|'.$jobvalue['rscdir'];
|
346 |
}
|
|
|
347 |
}
|
348 |
}
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
365 |
$loginok=true;
|
366 |
-
} else { //if PHP ftp login don't work use raw login
|
367 |
-
ftp_raw($ftp_conn_id,'USER '.$jobvalue['ftpuser']);
|
368 |
-
$return=ftp_raw($ftp_conn_id,'PASS '.base64_decode($jobvalue['ftppass']));
|
369 |
-
if (substr(trim($return[0]),0,3)<=400)
|
370 |
-
$loginok=true;
|
371 |
-
}
|
372 |
}
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
$filecounter++;
|
390 |
}
|
|
|
391 |
}
|
392 |
}
|
393 |
-
$donefolders[]=$jobvalue['ftphost'].'|'.$jobvalue['ftpuser'].'|'.$jobvalue['ftpdir'];
|
394 |
}
|
|
|
395 |
}
|
396 |
-
//Sort list
|
397 |
-
$tmp = Array();
|
398 |
-
foreach($files as &$ma)
|
399 |
-
$tmp[] = &$ma["time"];
|
400 |
-
array_multisort($tmp, SORT_DESC, $files);
|
401 |
-
return $files;
|
402 |
}
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
if ($ajax)
|
427 |
-
die();
|
428 |
-
else
|
429 |
-
return;
|
430 |
-
}
|
431 |
-
$s3 = new AmazonS3($awsAccessKey, $awsSecretKey);
|
432 |
-
$buckets=$s3->list_buckets();
|
433 |
-
//print_r($buckets);
|
434 |
-
if ($buckets->status!=200) {
|
435 |
-
echo '<span id="awsBucket" style="color:red;">'.__('No Buckets found! Or wrong Keys!','backwpup').'</span>';
|
436 |
-
if ($ajax)
|
437 |
-
die();
|
438 |
-
else
|
439 |
-
return;
|
440 |
-
}
|
441 |
-
echo '<select name="awsBucket" id="awsBucket">';
|
442 |
-
foreach ($buckets->body->Buckets->Bucket as $bucket) {
|
443 |
-
echo "<option ".selected(strtolower($awsselected),strtolower($bucket->Name),false).">".$bucket->Name."</option>";
|
444 |
-
}
|
445 |
-
echo '</select>';
|
446 |
if ($ajax)
|
447 |
die();
|
448 |
else
|
449 |
return;
|
450 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
451 |
|
452 |
-
|
453 |
-
|
454 |
-
if (
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
}
|
480 |
-
$auth = new CF_Authentication($rscUsername, $rscAPIKey);
|
481 |
-
|
482 |
-
try {
|
483 |
-
$auth->authenticate();
|
484 |
-
$conn = new CF_Connection($auth);
|
485 |
-
$containers=$conn->get_containers();
|
486 |
-
} catch (Exception $e) {
|
487 |
-
echo '<span id="rscContainer" style="color:red;">'.__($e->getMessage(),'backwpup').'</span>';
|
488 |
-
if ($ajax)
|
489 |
-
die();
|
490 |
-
else
|
491 |
-
return;
|
492 |
-
}
|
493 |
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
?>
|
3 |
if ( !defined('ABSPATH') )
|
4 |
die('-1');
|
5 |
|
6 |
+
//Checking,upgrade and default job setting
|
7 |
+
function backwpup_check_job_vars($jobsettings,$jobid='') {
|
8 |
+
global $wpdb;
|
9 |
+
//check job type
|
10 |
+
if (!isset($jobsettings['type']) or !is_string($jobsettings['type']))
|
11 |
+
$jobsettings['type']='DB+FILE';
|
12 |
+
$todo=explode('+',strtoupper($jobsettings['type']));
|
13 |
+
foreach($todo as $key => $value) {
|
14 |
+
if (!in_array($value,backwpup_backup_types()))
|
15 |
+
unset($todo[$key]);
|
16 |
+
}
|
17 |
+
$jobsettings['type']=implode('+',$todo);
|
18 |
+
if (empty($jobsettings['type']))
|
19 |
+
$jobsettings['type']='DB+FILE';
|
20 |
|
21 |
+
if (empty($jobsettings['name']) or !is_string($jobsettings['name']))
|
22 |
+
$jobsettings['name']= __('New');
|
23 |
|
24 |
+
if (!isset($jobsettings['activated']) or !is_bool($jobsettings['activated']))
|
25 |
+
$jobsettings['activated']=false;
|
26 |
|
27 |
+
//upgrade old schedule
|
28 |
+
if (!isset($jobsettings['cron']) and isset($jobsettings['scheduletime']) and isset($jobsettings['scheduleintervaltype']) and isset($jobsettings['scheduleintervalteimes'])) { //Upgrade to cron string
|
29 |
+
if ($jobsettings['scheduleintervaltype']==60) { //Min
|
30 |
+
$jobsettings['cron']='*/'.$jobsettings['scheduleintervalteimes'].' * * * *';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
}
|
32 |
+
if ($jobsettings['scheduleintervaltype']==3600) { //Houer
|
33 |
+
$jobsettings['cron']=(date('i',$jobsettings['scheduletime'])*1).' */'.$jobsettings['scheduleintervalteimes'].' * * *';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
}
|
35 |
+
if ($jobsettings['scheduleintervaltype']==86400) { //Days
|
36 |
+
$jobsettings['cron']=(date('i',$jobsettings['scheduletime'])*1).' '.date('G',$jobsettings['scheduletime']).' */'.$jobsettings['scheduleintervalteimes'].' * *';
|
|
|
|
|
37 |
}
|
38 |
+
}
|
39 |
|
40 |
+
if (!isset($jobsettings['cron']) or !is_string($jobsettings['cron']))
|
41 |
+
$jobsettings['cron']='0 3 * * *';
|
42 |
+
|
43 |
+
if (!isset($jobsettings['cronnextrun']) or !is_numeric($jobsettings['cronnextrun']))
|
44 |
+
$jobsettings['cronnextrun']=backwpup_cron_next($jobs[$jobid]['cron']);;
|
45 |
+
|
46 |
+
if (!is_string($jobsettings['mailaddresslog']) or false === $pos=strpos($jobsettings['mailaddresslog'],'@') or false === strpos($jobsettings['mailaddresslog'],'.',$pos))
|
47 |
+
$jobsettings['mailaddresslog']=get_option('admin_email');
|
48 |
|
49 |
+
if (!isset($jobsettings['mailerroronly']) or !is_bool($jobsettings['mailerroronly']))
|
50 |
+
$jobsettings['mailerroronly']=true;
|
51 |
|
52 |
+
if (!isset($jobsettings['dbexclude']) or !is_array($jobsettings['dbexclude'])) {
|
53 |
+
$jobsettings['dbexclude']=array();
|
54 |
+
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
55 |
+
foreach ($tables as $table) {
|
56 |
+
if (substr($table,0,strlen($wpdb->prefix))!=$wpdb->prefix)
|
57 |
+
$jobsettings['dbexclude'][]=$table;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
59 |
+
}
|
60 |
+
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
61 |
+
foreach($jobsettings['dbexclude'] as $key => $value) {
|
62 |
+
if (empty($jobsettings['dbexclude'][$key]) or !in_array($value,$tables))
|
63 |
+
unset($jobsettings['dbexclude'][$key]);
|
64 |
+
}
|
65 |
+
sort($jobsettings['dbexclude']);
|
66 |
|
67 |
+
if (!isset($jobsettings['dbshortinsert']) or !is_bool($jobsettings['dbshortinsert']))
|
68 |
+
$jobsettings['dbshortinsert']=false;
|
69 |
|
70 |
+
if (!isset($jobsettings['maintenance']) or !is_bool($jobsettings['maintenance']))
|
71 |
+
$jobsettings['maintenance']=false;
|
72 |
|
73 |
+
if (!isset($jobsettings['fileexclude']) or !is_string($jobsettings['fileexclude']))
|
74 |
+
$jobsettings['fileexclude']='';
|
75 |
+
$fileexclude=explode(',',$jobsettings['fileexclude']);
|
76 |
+
foreach($fileexclude as $key => $value) {
|
77 |
+
$fileexclude[$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
78 |
+
if (empty($fileexclude[$key]))
|
79 |
+
unset($fileexclude[$key]);
|
80 |
+
}
|
81 |
+
sort($fileexclude);
|
82 |
+
$jobsettings['fileexclude']=implode(',',$fileexclude);
|
83 |
+
|
84 |
+
if (!isset($jobsettings['dirinclude']) or !is_string($jobsettings['dirinclude']))
|
85 |
+
$jobsettings['dirinclude']='';
|
86 |
+
$dirinclude=explode(',',$jobsettings['dirinclude']);
|
87 |
+
foreach($dirinclude as $key => $value) {
|
88 |
+
$dirinclude[$key]=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($value))));
|
89 |
+
if ($dirinclude[$key]=='/' or empty($dirinclude[$key]) or !is_dir($dirinclude[$key]))
|
90 |
+
unset($dirinclude[$key]);
|
91 |
+
}
|
92 |
+
sort($dirinclude);
|
93 |
+
$jobsettings['dirinclude']=implode(',',$dirinclude);
|
94 |
|
95 |
+
if (!isset($jobsettings['backuproot']) or !is_bool($jobsettings['backuproot']))
|
96 |
+
$jobsettings['backuproot']=true;
|
97 |
|
98 |
+
if (!isset($jobsettings['backupcontent']) or !is_bool($jobsettings['backupcontent']))
|
99 |
+
$jobsettings['backupcontent']=true;
|
100 |
|
101 |
+
if (!isset($jobsettings['backupplugins']) or !is_bool($jobsettings['backupplugins']))
|
102 |
+
$jobsettings['backupplugins']=true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
+
if (!isset($jobsettings['backupthemes']) or !is_bool($jobsettings['backupthemes']))
|
105 |
+
$jobsettings['backupthemes']=true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
+
if (!isset($jobsettings['backupuploads']) or !is_bool($jobsettings['backupuploads']))
|
108 |
+
$jobsettings['backupuploads']=true;
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
+
if (!isset($jobsettings['backuprootexcludedirs']) or !is_array($jobsettings['backuprootexcludedirs']))
|
111 |
+
$jobsettings['backuprootexcludedirs']=array();
|
112 |
+
foreach($jobsettings['backuprootexcludedirs'] as $key => $value) {
|
113 |
+
$jobsettings['backuprootexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
114 |
+
if (empty($jobsettings['backuprootexcludedirs'][$key]) or $jobsettings['backuprootexcludedirs'][$key]=='/' or !is_dir($jobsettings['backuprootexcludedirs'][$key]))
|
115 |
+
unset($jobsettings['backuprootexcludedirs'][$key]);
|
116 |
+
}
|
117 |
+
sort($jobsettings['backuprootexcludedirs']);
|
118 |
+
|
119 |
+
if (!isset($jobsettings['backupcontentexcludedirs']) or !is_array($jobsettings['backupcontentexcludedirs']))
|
120 |
+
$jobsettings['backupcontentexcludedirs']=array();
|
121 |
+
foreach($jobsettings['backupcontentexcludedirs'] as $key => $value) {
|
122 |
+
$jobsettings['backupcontentexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
123 |
+
if (empty($jobsettings['backupcontentexcludedirs'][$key]) or $jobsettings['backupcontentexcludedirs'][$key]=='/' or !is_dir($jobsettings['backupcontentexcludedirs'][$key]))
|
124 |
+
unset($jobsettings['backupcontentexcludedirs'][$key]);
|
125 |
+
}
|
126 |
+
sort($jobsettings['backupcontentexcludedirs']);
|
127 |
+
|
128 |
+
if (!isset($jobsettings['backuppluginsexcludedirs']) or !is_array($jobsettings['backuppluginsexcludedirs']))
|
129 |
+
$jobsettings['backuppluginsexcludedirs']=array();
|
130 |
+
foreach($jobsettings['backuppluginsexcludedirs'] as $key => $value) {
|
131 |
+
$jobsettings['backuppluginsexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
132 |
+
if (empty($jobsettings['backuppluginsexcludedirs'][$key]) or $jobsettings['backuppluginsexcludedirs'][$key]=='/' or !is_dir($jobsettings['backuppluginsexcludedirs'][$key]))
|
133 |
+
unset($jobsettings['backuppluginsexcludedirs'][$key]);
|
134 |
+
}
|
135 |
+
sort($jobsettings['backuppluginsexcludedirs']);
|
136 |
+
|
137 |
+
if (!isset($jobsettings['backupthemesexcludedirs']) or !is_array($jobsettings['backupthemesexcludedirs']))
|
138 |
+
$jobsettings['backupthemesexcludedirs']=array();
|
139 |
+
foreach($jobsettings['backupthemesexcludedirs'] as $key => $value) {
|
140 |
+
$jobsettings['backupthemesexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
141 |
+
if (empty($jobsettings['backupthemesexcludedirs'][$key]) or $jobsettings['backupthemesexcludedirs'][$key]=='/' or !is_dir($jobsettings['backupthemesexcludedirs'][$key]))
|
142 |
+
unset($jobsettings['backupthemesexcludedirs'][$key]);
|
143 |
+
}
|
144 |
+
sort($jobsettings['backupthemesexcludedirs']);
|
145 |
+
|
146 |
+
if (!isset($jobsettings['backupuploadsexcludedirs']) or !is_array($jobsettings['backupuploadsexcludedirs']))
|
147 |
+
$jobsettings['backupuploadsexcludedirs']=array();
|
148 |
+
foreach($jobsettings['backupuploadsexcludedirs'] as $key => $value) {
|
149 |
+
$jobsettings['backupuploadsexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
150 |
+
if (empty($jobsettings['backupuploadsexcludedirs'][$key]) or $jobsettings['backupuploadsexcludedirs'][$key]=='/' or !is_dir($jobsettings['backupuploadsexcludedirs'][$key]))
|
151 |
+
unset($jobsettings['backupuploadsexcludedirs'][$key]);
|
152 |
+
}
|
153 |
+
sort($jobsettings['backupuploadsexcludedirs']);
|
154 |
|
155 |
+
$fileformarts=array('.zip','.tar.gz','.tar.bz2','.tar');
|
156 |
+
if (!isset($jobsettings['fileformart']) or !in_array($jobsettings['fileformart'],$fileformarts))
|
157 |
+
$jobsettings['fileformart']='.zip';
|
158 |
+
|
159 |
+
if (!isset($jobsettings['fileprefix']) or !is_string($jobsettings['fileprefix']))
|
160 |
+
$jobsettings['fileprefix']='backwpup_'.$jobid.'_';
|
161 |
+
|
162 |
+
if (!isset($jobsettings['mailefilesize']) or !is_float($jobsettings['mailefilesize']))
|
163 |
+
$jobsettings['mailefilesize']=0;
|
164 |
|
165 |
+
if (!isset($jobsettings['backupdir']) or (!is_dir($jobsettings['backupdir']) and !empty($jobsettings['backupdir']))) {
|
166 |
+
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
167 |
+
$jobsettings['backupdir']=str_replace('\\','/',trailingslashit(WP_CONTENT_DIR)).'backwpup-'.$rand.'/';
|
168 |
+
}
|
169 |
+
$jobsettings['backupdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['backupdir']))));
|
170 |
+
if ($jobsettings['backupdir']=='/')
|
171 |
+
$jobsettings['backupdir']='';
|
172 |
|
173 |
+
if (!isset($jobsettings['maxbackups']) or !is_int($jobsettings['maxbackups']))
|
174 |
+
$jobsettings['maxbackups']=0;
|
175 |
|
176 |
+
if (!isset($jobsettings['ftphost']) or !is_string($jobsettings['ftphost']))
|
177 |
+
$jobsettings['ftphost']='';
|
|
|
|
|
|
|
178 |
|
179 |
+
if (!isset($jobsettings['ftpuser']) or !is_string($jobsettings['ftpuser']))
|
180 |
+
$jobsettings['ftpuser']='';
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
|
182 |
+
if (!isset($jobsettings['ftppass']) or !is_string($jobsettings['ftppass']))
|
183 |
+
$jobsettings['ftppass']='';
|
184 |
|
185 |
+
if (!isset($jobsettings['ftpdir']) or !is_string($jobsettings['ftpdir']) or $jobsettings['ftpdir']=='/')
|
186 |
+
$jobsettings['ftpdir']='';
|
187 |
+
$jobsettings['ftpdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['ftpdir']))));
|
188 |
+
if (substr($jobsettings['ftpdir'],0,1)!='/')
|
189 |
+
$jobsettings['ftpdir']='/'.$jobsettings['ftpdir'];
|
190 |
|
191 |
+
if (!isset($jobsettings['ftpmaxbackups']) or !is_int($jobsettings['ftpmaxbackups']))
|
192 |
+
$jobsettings['ftpmaxbackups']=0;
|
193 |
+
|
194 |
+
if (!isset($jobsettings['ftppasv']) or !is_bool($jobsettings['ftppasv']))
|
195 |
+
$jobsettings['ftppasv']=true;
|
196 |
+
|
197 |
+
if (!isset($jobsettings['ftpssl']) or !is_bool($jobsettings['ftpssl']))
|
198 |
+
$jobsettings['ftpssl']=false;
|
199 |
|
200 |
+
if (!isset($jobsettings['awsAccessKey']) or !is_string($jobsettings['awsAccessKey']))
|
201 |
+
$jobsettings['awsAccessKey']='';
|
202 |
|
203 |
+
if (!isset($jobsettings['awsSecretKey']) or !is_string($jobsettings['awsSecretKey']))
|
204 |
+
$jobsettings['awsSecretKey']='';
|
|
|
|
|
|
|
205 |
|
206 |
+
if (!isset($jobsettings['awsrrs']) or !is_bool($jobsettings['awsrrs']))
|
207 |
+
$jobsettings['awsrrs']=false;
|
208 |
|
209 |
+
if (!isset($jobsettings['awsBucket']) or !is_string($jobsettings['awsBucket']))
|
210 |
+
$jobsettings['awsBucket']='';
|
211 |
|
212 |
+
if (!isset($jobsettings['awsdir']) or !is_string($jobsettings['awsdir']) or $jobsettings['awsdir']=='/')
|
213 |
+
$jobsettings['awsdir']='';
|
214 |
+
$jobsettings['awsdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['awsdir']))));
|
215 |
+
if (substr($jobsettings['awsdir'],0,1)=='/')
|
216 |
+
$jobsettings['awsdir']=substr($jobsettings['awsdir'],1);
|
217 |
|
218 |
+
if (!isset($jobsettings['awsmaxbackups']) or !is_int($jobsettings['awsmaxbackups']))
|
219 |
+
$jobsettings['awsmaxbackups']=0;
|
220 |
|
221 |
+
if (!isset($jobsettings['rscUsername']) or !is_string($jobsettings['rscUsername']))
|
222 |
+
$jobsettings['rscUsername']='';
|
|
|
|
|
|
|
223 |
|
224 |
+
if (!isset($jobsettings['rscAPIKey']) or !is_string($jobsettings['rscAPIKey']))
|
225 |
+
$jobsettings['rscAPIKey']='';
|
226 |
|
227 |
+
if (!isset($jobsettings['rscContainer']) or !is_string($jobsettings['rscContainer']))
|
228 |
+
$jobsettings['rscContainer']='';
|
|
|
229 |
|
230 |
+
if (!isset($jobsettings['rscdir']) or !is_string($jobsettings['rscdir']) or $jobsettings['rscdir']=='/')
|
231 |
+
$jobsettings['rscdir']='';
|
232 |
+
$jobsettings['rscdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['rscdir']))));
|
233 |
+
if (substr($jobsettings['rscdir'],0,1)=='/')
|
234 |
+
$jobsettings['rscdir']=substr($jobsettings['rscdir'],1);
|
235 |
|
236 |
+
if (!isset($jobsettings['rscmaxbackups']) or !is_int($jobsettings['rscmaxbackups']))
|
237 |
+
$jobsettings['rscmaxbackups']=0;
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
|
239 |
+
|
240 |
+
if (!isset($jobsettings['dropemail']) or !is_string($jobsettings['dropemail']))
|
241 |
+
$jobsettings['dropemail']='';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
|
243 |
+
if (!isset($jobsettings['dropepass']) or !is_string($jobsettings['dropepass']))
|
244 |
+
$jobsettings['dropepass']='';
|
245 |
+
|
246 |
+
if (!isset($jobsettings['dropedir']) or !is_string($jobsettings['dropedir']) or $jobsettings['dropedir']=='/')
|
247 |
+
$jobsettings['dropedir']='';
|
248 |
+
$jobsettings['dropedir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['dropedir']))));
|
249 |
+
if (substr($jobsettings['dropedir'],0,1)=='/')
|
250 |
+
$jobsettings['dropedir']=substr($jobsettings['dropedir'],1);
|
251 |
+
|
252 |
+
if (!is_string($jobsettings['mailaddress']) or false === $pos=strpos($jobsettings['mailaddress'],'@') or false === strpos($jobsettings['mailaddress'],'.',$pos))
|
253 |
+
$jobsettings['mailaddress']='';
|
254 |
+
|
255 |
+
return $jobsettings;
|
256 |
+
}
|
257 |
+
|
258 |
+
|
259 |
+
//ajax/normal get backup files and infos
|
260 |
+
function backwpup_get_backup_files($onlyjobid='') {
|
261 |
+
$jobs=(array)get_option('backwpup_jobs'); //Load jobs
|
262 |
+
$dests=explode(',',strtoupper(BACKWPUP_DESTS));
|
263 |
+
$filecounter=0;
|
264 |
+
$files=array();
|
265 |
+
$donefolders=array();
|
266 |
+
if (extension_loaded('curl') or @dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll')) {
|
267 |
+
if (!class_exists('CFRuntime'))
|
268 |
+
require_once(dirname(__FILE__).'/libs/aws/sdk.class.php');
|
269 |
+
if (!class_exists('CF_Authentication'))
|
270 |
+
require_once(dirname(__FILE__).'/libs/rackspace/cloudfiles.php');
|
271 |
+
}
|
272 |
+
|
273 |
+
foreach ($jobs as $jobid => $jobvalue) { //go job by job
|
274 |
+
if (!empty($onlyjobid) and $jobid!=$onlyjobid)
|
275 |
+
continue;
|
276 |
+
$jobvalue=backwpup_check_job_vars($jobvalue,$jobid); //Check job values
|
277 |
+
$todo=explode('+',$jobvalue['type']); //only for backup jobs
|
278 |
+
if (!in_array('FILE',$todo) and !in_array('DB',$todo) and !in_array('WPEXP',$todo))
|
279 |
+
continue;
|
280 |
+
|
281 |
+
//Get files/filinfo in backup folder
|
282 |
+
if (!empty($jobvalue['backupdir']) and !in_array($jobvalue['backupdir'],$donefolders)) {
|
283 |
+
if ( $dir = @opendir( $jobvalue['backupdir'] ) ) {
|
284 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
285 |
+
if (substr($file,0,1)=='.' or !(strtolower(substr($file,-4))=='.zip' or strtolower(substr($file,-4))=='.tar' or strtolower(substr($file,-7))=='.tar.gz' or strtolower(substr($file,-8))=='.tar.bz2'))
|
286 |
+
continue;
|
287 |
+
if (is_file($jobvalue['backupdir'].$file)) {
|
288 |
+
$files[$filecounter]['type']='FOLDER';
|
289 |
+
$files[$filecounter]['jobid']=$jobid;
|
290 |
+
$files[$filecounter]['file']=$jobvalue['backupdir'].$file;
|
291 |
+
$files[$filecounter]['filename']=$file;
|
292 |
+
$files[$filecounter]['downloadurl']='admin.php?page=BackWPup&subpage=backups&action=download&file='.$jobvalue['backupdir'].$file;
|
293 |
+
$files[$filecounter]['filesize']=filesize($jobvalue['backupdir'].$file);
|
294 |
+
$files[$filecounter]['time']=filemtime($jobvalue['backupdir'].$file);
|
295 |
+
$filecounter++;
|
296 |
}
|
|
|
|
|
297 |
}
|
298 |
+
closedir( $dir );
|
299 |
+
$donefolders[]=$jobvalue['backupdir'];
|
300 |
}
|
301 |
+
}
|
302 |
+
//Get files/filinfo from S3
|
303 |
+
if (class_exists('AmazonS3') and in_array('S3',$dests) and !in_array($jobvalue['awsAccessKey'].'|'.$jobvalue['awsBucket'].'|'.$jobvalue['awsdir'],$donefolders)) {
|
304 |
+
if (!empty($jobvalue['awsAccessKey']) and !empty($jobvalue['awsSecretKey']) and !empty($jobvalue['awsBucket'])) {
|
305 |
+
$s3 = new AmazonS3($jobvalue['awsAccessKey'], $jobvalue['awsSecretKey']);
|
306 |
+
if (($contents = $s3->list_objects($jobvalue['awsBucket'],array('prefix'=>$jobvalue['awsdir']))) !== false) {
|
307 |
+
foreach ($contents->body->Contents as $object) {
|
308 |
+
if (strtolower(substr($object->Key,-4))=='.zip' or strtolower(substr($object->Key,-4))=='.tar' or strtolower(substr($object->Key,-7))=='.tar.gz' or strtolower(substr($object->Key,-8))=='.tar.bz2') {
|
309 |
+
$files[$filecounter]['type']='S3';
|
310 |
+
$files[$filecounter]['jobid']=$jobid;
|
311 |
+
$files[$filecounter]['file']=(string)$object->Key;
|
312 |
+
$files[$filecounter]['filename']=basename($object->Key);
|
313 |
+
$files[$filecounter]['downloadurl']='admin.php?page=BackWPup&subpage=backups&action=downloads3&file='.$object->Key.'&jobid='.$jobid;
|
314 |
+
$files[$filecounter]['filesize']=(string)$object->Size;
|
315 |
+
$files[$filecounter]['time']=strtotime($object->LastModified);
|
316 |
+
$filecounter++;
|
317 |
}
|
318 |
}
|
|
|
319 |
}
|
320 |
+
$donefolders[]=$jobvalue['awsAccessKey'].'|'.$jobvalue['awsBucket'].'|'.$jobvalue['awsdir'];
|
321 |
}
|
322 |
+
}
|
323 |
+
//Get files/filinfo from RSC
|
324 |
+
if (class_exists('CF_Authentication') and in_array('RSC',$dests) and !in_array($jobvalue['rscUsername'].'|'.$jobvalue['rscContainer'].'|'.$jobvalue['rscdir'],$donefolders)) {
|
325 |
+
if (!empty($jobvalue['rscUsername']) and !empty($jobvalue['rscAPIKey']) and !empty($jobvalue['rscContainer'])) {
|
326 |
+
$auth = new CF_Authentication($jobvalue['rscUsername'], $jobvalue['rscAPIKey']);
|
327 |
+
$auth->ssl_use_cabundle();
|
328 |
+
if ($auth->authenticate()) {
|
329 |
+
$conn = new CF_Connection($auth);
|
330 |
+
$conn->ssl_use_cabundle();
|
331 |
+
$backwpupcontainer = $conn->get_container($jobvalue['rscContainer']);
|
332 |
+
$contents = $backwpupcontainer->get_objects(0,NULL,NULL,$jobvalue['rscdir']);
|
333 |
+
foreach ($contents as $object) {
|
334 |
+
if (strtolower(substr($object->name,-4))=='.zip' or strtolower(substr($object->name,-4))=='.tar' or strtolower(substr($object->name,-7))=='.tar.gz' or strtolower(substr($object->name,-8))=='.tar.bz2') {
|
335 |
+
$files[$filecounter]['type']='RSC';
|
336 |
+
$files[$filecounter]['jobid']=$jobid;
|
337 |
+
$files[$filecounter]['file']=$object->name;
|
338 |
+
$files[$filecounter]['filename']=basename($object->name);
|
339 |
+
$files[$filecounter]['downloadurl']='admin.php?page=BackWPup&subpage=backups&action=downloadrsc&file='.$object->name.'&jobid='.$jobid;
|
340 |
+
$files[$filecounter]['filesize']=$object->content_length;
|
341 |
+
$files[$filecounter]['time']=$object->last_modified;
|
342 |
+
$filecounter++;
|
343 |
}
|
|
|
344 |
}
|
345 |
+
$donefolders[]=$jobvalue['rscUsername'].'|'.$jobvalue['rscContainer'].'|'.$jobvalue['rscdir'];
|
346 |
}
|
347 |
}
|
348 |
+
}
|
349 |
+
//Get files/filinfo from FTP
|
350 |
+
if (!empty($jobvalue['ftphost']) and in_array('FTP',$dests) and !empty($jobvalue['ftpuser']) and !empty($jobvalue['ftppass']) and !in_array($jobvalue['ftphost'].'|'.$jobvalue['ftpuser'].'|'.$jobvalue['ftpdir'],$donefolders)) {
|
351 |
+
$ftpport=21;
|
352 |
+
$ftphost=$jobvalue['ftphost'];
|
353 |
+
if (false !== strpos($jobvalue['ftphost'],':')) //look for port
|
354 |
+
list($ftphost,$ftpport)=explode(':',$jobvalue,2);
|
355 |
+
|
356 |
+
if (function_exists('ftp_ssl_connect') and $jobvalue['ftpssl']) { //make SSL FTP connection
|
357 |
+
$ftp_conn_id = ftp_ssl_connect($ftphost,$ftpport,10);
|
358 |
+
} elseif (!$jobvalue['ftpssl']) { //make normal FTP conection if SSL not work
|
359 |
+
$ftp_conn_id = ftp_connect($ftphost,$ftpport,10);
|
360 |
+
}
|
361 |
+
$loginok=false;
|
362 |
+
if ($ftp_conn_id) {
|
363 |
+
//FTP Login
|
364 |
+
if (@ftp_login($ftp_conn_id, $jobvalue['ftpuser'], base64_decode($jobvalue['ftppass']))) {
|
365 |
+
$loginok=true;
|
366 |
+
} else { //if PHP ftp login don't work use raw login
|
367 |
+
ftp_raw($ftp_conn_id,'USER '.$jobvalue['ftpuser']);
|
368 |
+
$return=ftp_raw($ftp_conn_id,'PASS '.base64_decode($jobvalue['ftppass']));
|
369 |
+
if (substr(trim($return[0]),0,3)<=400)
|
370 |
$loginok=true;
|
|
|
|
|
|
|
|
|
|
|
|
|
371 |
}
|
372 |
+
}
|
373 |
+
if ($loginok) {
|
374 |
+
ftp_pasv($ftp_conn_id, $jobvalue['ftppasv']);
|
375 |
+
if ($ftpfilelist=ftp_nlist($ftp_conn_id, $jobvalue['ftpdir'])) {
|
376 |
+
foreach($ftpfilelist as $ftpfiles) {
|
377 |
+
if (substr(basename($ftpfiles),0,1)=='.' or !(strtolower(substr($ftpfiles,-4))=='.zip' or strtolower(substr($ftpfiles,-4))=='.tar' or strtolower(substr($ftpfiles,-7))=='.tar.gz' or strtolower(substr($ftpfiles,-8))=='.tar.bz2'))
|
378 |
+
continue;
|
379 |
+
$files[$filecounter]['type']='FTP';
|
380 |
+
$files[$filecounter]['jobid']=$jobid;
|
381 |
+
$files[$filecounter]['file']=$ftpfiles;
|
382 |
+
$files[$filecounter]['filename']=basename($ftpfiles);
|
383 |
+
$files[$filecounter]['downloadurl']="ftp://".$jobvalue['ftpuser'].":".base64_decode($jobvalue['ftppass'])."@".$jobvalue['ftphost'].$ftpfiles;
|
384 |
+
$files[$filecounter]['filesize']=ftp_size($ftp_conn_id,$ftpfiles);
|
385 |
+
if ('backwpup_log_' == substr(basename($ftpfiles),0,strlen('backwpup_log_'))) {
|
386 |
+
$filnameparts=explode('_',substr(basename($ftpfiles),0,strpos(basename($ftpfiles),'.')));
|
387 |
+
$files[$filecounter]['time']=strtotime($filnameparts[2].' '.str_replace('-',':',$filnameparts[3]));
|
|
|
388 |
}
|
389 |
+
$filecounter++;
|
390 |
}
|
391 |
}
|
|
|
392 |
}
|
393 |
+
$donefolders[]=$jobvalue['ftphost'].'|'.$jobvalue['ftpuser'].'|'.$jobvalue['ftpdir'];
|
394 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
395 |
}
|
396 |
+
//Sort list
|
397 |
+
$tmp = Array();
|
398 |
+
foreach($files as &$ma)
|
399 |
+
$tmp[] = &$ma["time"];
|
400 |
+
array_multisort($tmp, SORT_DESC, $files);
|
401 |
+
return $files;
|
402 |
+
}
|
403 |
+
|
404 |
+
//ajax/normal get buckests select box
|
405 |
+
function backwpup_get_aws_buckets($args='') {
|
406 |
+
if (is_array($args)) {
|
407 |
+
extract($args);
|
408 |
+
$ajax=false;
|
409 |
+
} else {
|
410 |
+
$awsAccessKey=$_POST['awsAccessKey'];
|
411 |
+
$awsSecretKey=$_POST['awsSecretKey'];
|
412 |
+
$awsselected=$_POST['awsselected'];
|
413 |
+
$ajax=true;
|
414 |
+
}
|
415 |
+
if (!class_exists('CFRuntime'))
|
416 |
+
require_once(dirname(__FILE__).'/libs/aws/sdk.class.php');
|
417 |
+
if (empty($awsAccessKey)) {
|
418 |
+
echo '<span id="awsBucket" style="color:red;">'.__('Missing Access Key ID!','backwpup').'</span>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
419 |
if ($ajax)
|
420 |
die();
|
421 |
else
|
422 |
return;
|
423 |
}
|
424 |
+
if (empty($awsSecretKey)) {
|
425 |
+
echo '<span id="awsBucket" style="color:red;">'.__('Missing Secret Access Key!','backwpup').'</span>';
|
426 |
+
if ($ajax)
|
427 |
+
die();
|
428 |
+
else
|
429 |
+
return;
|
430 |
+
}
|
431 |
+
$s3 = new AmazonS3($awsAccessKey, $awsSecretKey);
|
432 |
+
$buckets=$s3->list_buckets();
|
433 |
+
//print_r($buckets);
|
434 |
+
if ($buckets->status!=200) {
|
435 |
+
echo '<span id="awsBucket" style="color:red;">'.__('No Buckets found! Or wrong Keys!','backwpup').'</span>';
|
436 |
+
if ($ajax)
|
437 |
+
die();
|
438 |
+
else
|
439 |
+
return;
|
440 |
+
}
|
441 |
+
echo '<select name="awsBucket" id="awsBucket">';
|
442 |
+
foreach ($buckets->body->Buckets->Bucket as $bucket) {
|
443 |
+
echo "<option ".selected(strtolower($awsselected),strtolower($bucket->Name),false).">".$bucket->Name."</option>";
|
444 |
+
}
|
445 |
+
echo '</select>';
|
446 |
+
if ($ajax)
|
447 |
+
die();
|
448 |
+
else
|
449 |
+
return;
|
450 |
+
}
|
451 |
+
|
452 |
+
//ajax/normal get Container for RSC select box
|
453 |
+
function backwpup_get_rsc_container($args='') {
|
454 |
+
if (is_array($args)) {
|
455 |
+
extract($args);
|
456 |
+
$ajax=false;
|
457 |
+
} else {
|
458 |
+
$rscUsername=$_POST['rscUsername'];
|
459 |
+
$rscAPIKey=$_POST['rscAPIKey'];
|
460 |
+
$rscselected=$_POST['rscselected'];
|
461 |
+
$ajax=true;
|
462 |
+
}
|
463 |
+
if (!class_exists('CF_Authentication'))
|
464 |
+
require_once(dirname(__FILE__).'/libs/rackspace/cloudfiles.php');
|
465 |
|
466 |
+
if (empty($rscUsername)) {
|
467 |
+
echo '<span id="rscContainer" style="color:red;">'.__('Missing Username!','backwpup').'</span>';
|
468 |
+
if ($ajax)
|
469 |
+
die();
|
470 |
+
else
|
471 |
+
return;
|
472 |
+
}
|
473 |
+
if (empty($rscAPIKey)) {
|
474 |
+
echo '<span id="rscContainer" style="color:red;">'.__('Missing API Key!','backwpup').'</span>';
|
475 |
+
if ($ajax)
|
476 |
+
die();
|
477 |
+
else
|
478 |
+
return;
|
479 |
+
}
|
480 |
+
$auth = new CF_Authentication($rscUsername, $rscAPIKey);
|
481 |
+
|
482 |
+
try {
|
483 |
+
$auth->authenticate();
|
484 |
+
$conn = new CF_Connection($auth);
|
485 |
+
$containers=$conn->get_containers();
|
486 |
+
} catch (Exception $e) {
|
487 |
+
echo '<span id="rscContainer" style="color:red;">'.__($e->getMessage(),'backwpup').'</span>';
|
488 |
+
if ($ajax)
|
489 |
+
die();
|
490 |
+
else
|
491 |
+
return;
|
492 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
493 |
|
494 |
+
if (!is_array($containers)) {
|
495 |
+
echo '<span id="rscContainer" style="color:red;">'.__('No Containerss found!','backwpup').'</span>';
|
496 |
+
if ($ajax)
|
497 |
+
die();
|
498 |
+
else
|
499 |
+
return;
|
500 |
+
}
|
501 |
+
echo '<select name="rscContainer" id="rscContainer">';
|
502 |
+
foreach ($containers as $container) {
|
503 |
+
echo "<option ".selected(strtolower($rscselected),strtolower($container->name),false).">".$container->name."</option>";
|
504 |
+
}
|
505 |
+
echo '</select>';
|
506 |
+
if ($ajax)
|
507 |
+
die();
|
508 |
+
else
|
509 |
+
return;
|
510 |
+
}
|
511 |
?>
|
backwpup.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: BackWPup
|
|
4 |
Plugin URI: http://danielhuesken.de/portfolio/backwpup/
|
5 |
Description: Backup and more of your WordPress Blog Database and Files.
|
6 |
Author: Daniel Hüsken
|
7 |
-
Version: 1.5.
|
8 |
Author URI: http://danielhuesken.de
|
9 |
Text Domain: backwpup
|
10 |
Domain Path: /lang/
|
@@ -34,7 +34,9 @@ if ( !defined('ABSPATH') )
|
|
34 |
//Set plugin dirname
|
35 |
define('BACKWPUP_PLUGIN_BASEDIR', dirname(plugin_basename(__FILE__)));
|
36 |
//Set Plugin Version
|
37 |
-
define('BACKWPUP_VERSION', '1.5.
|
|
|
|
|
38 |
//Set useable destinations
|
39 |
if (!defined('BACKWPUP_DESTS'))
|
40 |
define('BACKWPUP_DESTS', 'S3,RSC,FTP,DROPBOX');
|
@@ -46,8 +48,31 @@ require_once(dirname(__FILE__).'/app/functions.php');
|
|
46 |
register_activation_hook(__FILE__, 'backwpup_plugin_activate');
|
47 |
//Plugin deactivate
|
48 |
register_deactivation_hook(__FILE__, 'backwpup_plugin_deactivate');
|
49 |
-
//Plugin init
|
50 |
-
add_action('plugins_loaded', 'backwpup_plugins_loaded');
|
51 |
//Admin message
|
52 |
add_action('admin_notices', 'backwpup_admin_notice');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
?>
|
4 |
Plugin URI: http://danielhuesken.de/portfolio/backwpup/
|
5 |
Description: Backup and more of your WordPress Blog Database and Files.
|
6 |
Author: Daniel Hüsken
|
7 |
+
Version: 1.5.2
|
8 |
Author URI: http://danielhuesken.de
|
9 |
Text Domain: backwpup
|
10 |
Domain Path: /lang/
|
34 |
//Set plugin dirname
|
35 |
define('BACKWPUP_PLUGIN_BASEDIR', dirname(plugin_basename(__FILE__)));
|
36 |
//Set Plugin Version
|
37 |
+
define('BACKWPUP_VERSION', '1.5.2');
|
38 |
+
//Set User Capability
|
39 |
+
define('BACKWPUP_USER_CAPABILITY', 'export');
|
40 |
//Set useable destinations
|
41 |
if (!defined('BACKWPUP_DESTS'))
|
42 |
define('BACKWPUP_DESTS', 'S3,RSC,FTP,DROPBOX');
|
48 |
register_activation_hook(__FILE__, 'backwpup_plugin_activate');
|
49 |
//Plugin deactivate
|
50 |
register_deactivation_hook(__FILE__, 'backwpup_plugin_deactivate');
|
|
|
|
|
51 |
//Admin message
|
52 |
add_action('admin_notices', 'backwpup_admin_notice');
|
53 |
+
if (backwpup_env_checks()) {
|
54 |
+
//include php5 functions
|
55 |
+
require_once(dirname(__FILE__).'/app/functions5.php');
|
56 |
+
//add Menu
|
57 |
+
add_action('admin_menu', 'backwpup_admin_menu');
|
58 |
+
//add cron intervals
|
59 |
+
add_filter('cron_schedules', 'backwpup_intervals');
|
60 |
+
//Actions for Cron job
|
61 |
+
add_action('backwpup_cron', 'backwpup_cron');
|
62 |
+
//add Dashboard widget
|
63 |
+
add_action('wp_dashboard_setup', 'backwpup_add_dashboard');
|
64 |
+
//Additional links on the plugin page
|
65 |
+
add_filter('plugin_action_links_'.BACKWPUP_PLUGIN_BASEDIR.'/backwpup.php', 'backwpup_plugin_options_link');
|
66 |
+
add_filter('plugin_row_meta', 'backwpup_plugin_links',10,2);
|
67 |
+
// add ajax function
|
68 |
+
add_action('wp_ajax_backwpup_get_aws_buckets', 'backwpup_get_aws_buckets');
|
69 |
+
add_action('wp_ajax_backwpup_get_rsc_container', 'backwpup_get_rsc_container');
|
70 |
+
//Disabele WP_Corn
|
71 |
+
$cfg=get_option('backwpup');
|
72 |
+
if ($cfg['disablewpcron'])
|
73 |
+
define('DISABLE_WP_CRON',true);
|
74 |
+
//test if cron active
|
75 |
+
if (!(wp_next_scheduled('backwpup_cron')))
|
76 |
+
wp_schedule_event(0, 'backwpup_int', 'backwpup_cron');
|
77 |
+
}
|
78 |
?>
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=danie
|
|
4 |
Tags: backup, admin, file, Database, mysql, cron, ftp, S3, export, xml, Rackspase, cloud, webdav, dropbox
|
5 |
Requires at least: 2.8
|
6 |
Tested up to: 3.1.0
|
7 |
-
Stable tag: 1.5.
|
8 |
|
9 |
Backup and more of your WordPress Blog Database and Files
|
10 |
|
@@ -98,6 +98,10 @@ Destinations are:
|
|
98 |
1. Job Page
|
99 |
|
100 |
== Changelog ==
|
|
|
|
|
|
|
|
|
101 |
= 1.5.1 =
|
102 |
* changed user capability from '10' to 'export'
|
103 |
* Updatet AWS SDK to ver.1.2.5 for Amazon S3
|
4 |
Tags: backup, admin, file, Database, mysql, cron, ftp, S3, export, xml, Rackspase, cloud, webdav, dropbox
|
5 |
Requires at least: 2.8
|
6 |
Tested up to: 3.1.0
|
7 |
+
Stable tag: 1.5.2
|
8 |
|
9 |
Backup and more of your WordPress Blog Database and Files
|
10 |
|
98 |
1. Job Page
|
99 |
|
100 |
== Changelog ==
|
101 |
+
= 1.5.2 =
|
102 |
+
* changes for user checking
|
103 |
+
* removed Plugin init action
|
104 |
+
|
105 |
= 1.5.1 =
|
106 |
* changed user capability from '10' to 'export'
|
107 |
* Updatet AWS SDK to ver.1.2.5 for Amazon S3
|