Version Description
- added fuction to check/update job settings
- added no ajax bucket list to job page
- changed error handling a bit and remove PHP errors that can't handeld
- fixed problem with not compiled --enable-memory-limit in php
- removed setting for memory limit use WP filter and default now (256M)
- now a time limit of 5 mins is set again for job execution but it will be resettet on every message. (prevent never ending jobs.)
- added a shutdown function if __destruct not called for job
- added more flexible Backup file selection
Download this release
Release Info
Developer | danielhuesken |
Plugin | BackWPup – WordPress Backup Plugin |
Version | 1.1.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.9 to 1.1.0
- app/backwpup_dojob.php +250 -179
- app/functions.php +276 -17
- app/js/options.js +0 -1
- app/options-jobs.php +89 -46
- app/options-runnow-iframe.php +0 -2
- app/options-save.php +21 -15
- app/options-settings.php +0 -18
- backwpup.php +3 -3
- readme.txt +15 -2
app/backwpup_dojob.php
CHANGED
@@ -8,94 +8,161 @@ if ( !defined('ABSPATH') )
|
|
8 |
function backwpup_joberrorhandler($errno, $errstr, $errfile, $errline) {
|
9 |
global $backwpup_logfile;
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
switch ($errno) {
|
12 |
case E_NOTICE:
|
13 |
case E_USER_NOTICE:
|
14 |
-
|
15 |
-
$style='';
|
16 |
break;
|
17 |
case E_WARNING:
|
18 |
case E_USER_WARNING:
|
19 |
-
case E_CORE_WARNING:
|
20 |
-
case E_COMPILE_WARNING:
|
21 |
-
$errorstype = __("[WARNING]");
|
22 |
$logheader=backwpup_read_logheader($backwpup_logfile); //read waring count from log header
|
23 |
$warnings=$logheader['warnings']+1;
|
24 |
-
$
|
25 |
break;
|
26 |
-
case E_ERROR:
|
27 |
case E_USER_ERROR:
|
28 |
-
case E_CORE_ERROR:
|
29 |
-
case E_COMPILE_ERROR:
|
30 |
-
$errorstype = __("[ERROR]");
|
31 |
$logheader=backwpup_read_logheader($backwpup_logfile); //read error count from log header
|
32 |
$errors=$logheader['errors']+1;
|
33 |
-
$
|
34 |
break;
|
35 |
case E_DEPRECATED:
|
36 |
case E_USER_DEPRECATED:
|
37 |
-
|
38 |
-
$style='';
|
39 |
-
break;
|
40 |
-
case E_PARSE:
|
41 |
-
$errorstype = __("[PARSING ERROR]");
|
42 |
-
$style='';
|
43 |
break;
|
44 |
case E_STRICT:
|
45 |
-
|
46 |
-
$style='';
|
47 |
break;
|
48 |
case E_RECOVERABLE_ERROR:
|
49 |
-
|
50 |
-
$style='';
|
51 |
break;
|
52 |
default:
|
53 |
-
|
54 |
-
$style='';
|
55 |
break;
|
56 |
}
|
57 |
|
58 |
-
|
|
|
|
|
|
|
|
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
}
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
$fd=@fopen($backwpup_logfile,"r+");
|
74 |
while (!feof($fd)) {
|
75 |
$line=@fgets($fd);
|
76 |
-
if (stripos($line,"<meta name=\"
|
77 |
-
@fseek($fd,$filepos);
|
78 |
-
@fputs($fd,str_pad("<meta name=\"backwpup_errors\" content=\"".$errors."\" />",100)."\n");
|
79 |
-
break;
|
80 |
-
}
|
81 |
-
if (stripos($line,"<meta name=\"backwpup_warnings\"") !== false and isset($warnings)) {
|
82 |
@fseek($fd,$filepos);
|
83 |
-
@fputs($fd,str_pad("<meta name=\"
|
84 |
break;
|
85 |
}
|
86 |
$filepos=ftell($fd);
|
87 |
}
|
88 |
@fclose($fd);
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
}
|
97 |
|
98 |
-
|
99 |
/**
|
100 |
* BackWPup PHP class for WordPress
|
101 |
*
|
@@ -104,6 +171,7 @@ class backwpup_dojob {
|
|
104 |
|
105 |
private $jobid=0;
|
106 |
private $filelist=array();
|
|
|
107 |
private $todo=array();
|
108 |
private $allfilesize=0;
|
109 |
private $backupfile='';
|
@@ -116,7 +184,11 @@ class backwpup_dojob {
|
|
116 |
private $job=array();
|
117 |
|
118 |
public function __construct($jobid) {
|
119 |
-
global $backwpup_logfile;
|
|
|
|
|
|
|
|
|
120 |
$this->jobid=$jobid; //set job id
|
121 |
$this->cfg=get_option('backwpup'); //load config
|
122 |
$jobs=get_option('backwpup_jobs'); //load jobdata
|
@@ -125,21 +197,19 @@ class backwpup_dojob {
|
|
125 |
if ($schedteime=wp_next_scheduled('backwpup_cron',array('jobid'=>$this->jobid))) //set Schedule time to next scheduled
|
126 |
$jobs[$this->jobid]['scheduletime']=$schedteime;
|
127 |
update_option('backwpup_jobs',$jobs); //Save job Settings
|
128 |
-
$this->job
|
129 |
//set waht to do
|
130 |
$this->todo=explode('+',$this->job['type']);
|
131 |
//set Backup File format Dir
|
132 |
-
|
133 |
-
$this->backupfileformat=$this->job['fileformart'];
|
134 |
//set Temp Dir
|
135 |
$this->tempdir=trailingslashit($this->cfg['dirtemp']);
|
136 |
if (empty($this->tempdir) or $this->tempdir=='/')
|
137 |
-
$this->tempdir=
|
138 |
//set Backup Dir
|
139 |
-
$this->backupdir
|
140 |
-
if (empty($this->backupdir)
|
141 |
$this->backupdir=$this->tempdir;
|
142 |
-
}
|
143 |
//set Logs Dir
|
144 |
$this->logdir=trailingslashit($this->cfg['dirlogs']);
|
145 |
if (empty($this->logdir) or $this->logdir=='/') {
|
@@ -164,36 +234,36 @@ class backwpup_dojob {
|
|
164 |
@fputs($fd,"<meta name=\"backwpup_jobid\" content=\"".$this->jobid."\" />\n");
|
165 |
@fputs($fd,"<meta name=\"backwpup_jobname\" content=\"".$this->job['name']."\" />\n");
|
166 |
@fputs($fd,"<meta name=\"backwpup_jobtype\" content=\"".$this->job['type']."\" />\n");
|
167 |
-
if (!empty($this->backupfile))
|
168 |
@fputs($fd,"<meta name=\"backwpup_backupfile\" content=\"".$this->backupdir.$this->backupfile."\" />\n");
|
169 |
@fputs($fd,str_pad("<meta name=\"backwpup_jobruntime\" content=\"0\" />",100)."\n");
|
170 |
@fputs($fd,"<title>".sprintf(__('BackWPup Log for %1$s from %2$s at %3$s','backwpup'),$this->job['name'],date_i18n(get_option('date_format')),date_i18n(get_option('time_format')))."</title>\n</head>\n<body style=\"font-family:monospace;font-size:12px;white-space:nowrap;\">\n");
|
171 |
@fclose($fd);
|
172 |
-
//PHP
|
173 |
-
|
|
|
|
|
|
|
|
|
|
|
174 |
//check dirs
|
175 |
-
if ($this->backupdir!=
|
176 |
if (!$this->_check_folders($this->backupdir))
|
177 |
return false;
|
178 |
}
|
179 |
//check max script execution tme
|
180 |
-
if (
|
181 |
-
set_time_limit(0); //300 is most webserver time limit. 0= max time
|
182 |
-
} else {
|
183 |
trigger_error(sprintf(__('PHP Safe Mode is on!!! Max exec time is %1$d sec.','backwpup'),ini_get('max_execution_time')),E_USER_WARNING);
|
184 |
-
}
|
185 |
// check function for memorylimit
|
186 |
if (!function_exists('memory_get_usage')) {
|
187 |
-
|
188 |
-
|
189 |
-
ini_set('memory_limit', $this->cfg['memorylimit']);
|
190 |
-
trigger_error(sprintf(__('Memory limit set to %1$s ,because can not use PHP: memory_get_usage() function to dynamicli increase the Memeory!','backwpup'),ini_get('memory_limit')),E_USER_WARNING);
|
191 |
}
|
192 |
//run job parts
|
193 |
foreach($this->todo as $key => $value) {
|
194 |
switch ($value) {
|
195 |
case 'DB':
|
196 |
-
$this->dump_db(
|
197 |
break;
|
198 |
case 'WPEXP':
|
199 |
$this->export_wp();
|
@@ -203,37 +273,33 @@ class backwpup_dojob {
|
|
203 |
break;
|
204 |
}
|
205 |
}
|
206 |
-
|
207 |
-
if (isset($this->filelist[0][79001])) { //
|
208 |
if ($this->backupfileformat==".zip")
|
209 |
$this->zip_files();
|
210 |
elseif ($this->backupfileformat==".tar.gz" or $this->backupfileformat==".tar.bz2" or $this->backupfileformat==".tar")
|
211 |
$this->tar_pack_files();
|
212 |
-
|
213 |
-
|
214 |
-
if (!file_exists($this->backupdir.$this->backupfile))
|
215 |
-
return;
|
216 |
$this->destination_mail();
|
217 |
$this->destination_ftp();
|
218 |
$this->destination_s3();
|
219 |
-
$this->destination_dir();
|
220 |
}
|
221 |
|
222 |
foreach($this->todo as $key => $value) {
|
223 |
switch ($value) {
|
224 |
case 'CHECK':
|
225 |
-
$this->check_db(
|
226 |
break;
|
227 |
case 'OPTIMIZE':
|
228 |
-
$this->optimize_db(
|
229 |
break;
|
230 |
}
|
231 |
}
|
232 |
-
}
|
233 |
|
234 |
private function _check_folders($folder) {
|
235 |
-
$folder=str_replace("\\","/",$folder);
|
236 |
-
$folder=untrailingslashit(str_replace("//","/",$folder));
|
237 |
if (!is_dir($folder)) { //create dir if not exists
|
238 |
if (!mkdir($folder,0777,true)) {
|
239 |
trigger_error(sprintf(__('Can not create Folder: %1$s','backwpup'),$folder),E_USER_ERROR);
|
@@ -246,15 +312,21 @@ class backwpup_dojob {
|
|
246 |
}
|
247 |
//create .htaccess for apache and index.html for other
|
248 |
if (strtolower(substr($_SERVER["SERVER_SOFTWARE"],0,6))=="apache") { //check if it a apache webserver
|
249 |
-
if (!is_file($folder.'
|
250 |
-
if($file = fopen($folder.'
|
251 |
fwrite($file, "Order allow,deny\ndeny from all");
|
252 |
fclose($file);
|
253 |
}
|
254 |
}
|
255 |
} else {
|
256 |
-
if (!is_file($folder.'
|
257 |
-
if($file = fopen($folder.'
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
fwrite($file,"\n");
|
259 |
fclose($file);
|
260 |
}
|
@@ -267,6 +339,11 @@ class backwpup_dojob {
|
|
267 |
//fail back if fuction not exist
|
268 |
if (!function_exists('memory_get_usage'))
|
269 |
return true;
|
|
|
|
|
|
|
|
|
|
|
270 |
|
271 |
//calc mem to bytes
|
272 |
if (strtoupper(substr(trim(ini_get('memory_limit')),-1))=='K')
|
@@ -278,13 +355,18 @@ class backwpup_dojob {
|
|
278 |
else
|
279 |
$memory=trim(ini_get('memory_limit'));
|
280 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
// increase Memory
|
282 |
-
if (
|
283 |
-
|
284 |
-
trigger_error(sprintf(__('PHP Safe Mode is on!!! Can not increase Memory Limit is %1$s','backwpup'),ini_get('memory_limit')),E_USER_WARNING);
|
285 |
-
return false;
|
286 |
-
}
|
287 |
-
$newmemory=round((memory_get_usage()+$memneed)/1024/1024)+1;
|
288 |
if ($oldmem=ini_set('memory_limit', $newmemory.'M'))
|
289 |
trigger_error(sprintf(__('Memory increased from %1$s to %2$s','backwpup'),$oldmem,ini_get('memory_limit')),E_USER_NOTICE);
|
290 |
else
|
@@ -327,22 +409,18 @@ class backwpup_dojob {
|
|
327 |
}
|
328 |
}
|
329 |
|
330 |
-
private function check_db(
|
331 |
global $wpdb;
|
332 |
|
333 |
trigger_error(__('Run Database check...','backwpup'),E_USER_NOTICE);
|
334 |
|
335 |
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
336 |
-
|
337 |
//exclude tables from check
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
unset($tables[$tablekey]);
|
342 |
-
}
|
343 |
}
|
344 |
-
|
345 |
-
|
346 |
//check tables
|
347 |
if (sizeof($tables)>0) {
|
348 |
$this->maintenance_mode(true);
|
@@ -440,22 +518,22 @@ class backwpup_dojob {
|
|
440 |
fwrite($file, "UNLOCK TABLES;\n");
|
441 |
}
|
442 |
|
443 |
-
|
444 |
global $wpdb;
|
445 |
trigger_error(__('Run Database Dump to file...','backwpup'),E_USER_NOTICE);
|
446 |
$this->maintenance_mode(true);
|
447 |
-
|
448 |
//Tables to backup
|
449 |
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
450 |
if ($sqlerr=mysql_error($wpdb->dbh))
|
451 |
trigger_error(sprintf(__('BackWPup database error %1$s for query %2$s','backwpup'), $sqlerr, "SHOW TABLES FROM `'.DB_NAME.'`"),E_USER_ERROR);
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
}
|
457 |
-
sort($tables);
|
458 |
}
|
|
|
|
|
459 |
|
460 |
if (sizeof($tables)>0) {
|
461 |
$result=$wpdb->get_results("SHOW TABLE STATUS FROM `".DB_NAME."`;", ARRAY_A); //get table status
|
@@ -524,7 +602,7 @@ class backwpup_dojob {
|
|
524 |
$this->maintenance_mode(false);
|
525 |
}
|
526 |
|
527 |
-
|
528 |
trigger_error(__('Run Wordpress Export to XML file...','backwpup'),E_USER_NOTICE);
|
529 |
if (copy(plugins_url('wp_xml_export.php',__FILE__).'?wpabs='.trailingslashit(ABSPATH).'&_nonce='.substr(md5(md5(SECURE_AUTH_KEY)),10,10),$this->tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml')) {
|
530 |
trigger_error(__('Export to XML done!','backwpup'),E_USER_NOTICE);
|
@@ -537,21 +615,18 @@ class backwpup_dojob {
|
|
537 |
}
|
538 |
}
|
539 |
|
540 |
-
|
541 |
global $wpdb;
|
542 |
|
543 |
trigger_error(__('Run Database optimize...','backwpup'),E_USER_NOTICE);
|
544 |
|
545 |
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
546 |
-
|
547 |
//exclude tables from optimize
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
unset($tables[$tablekey]);
|
552 |
-
}
|
553 |
}
|
554 |
-
|
555 |
if (sizeof($tables)>0) {
|
556 |
$this->maintenance_mode(true);
|
557 |
foreach ($tables as $table) {
|
@@ -574,7 +649,7 @@ class backwpup_dojob {
|
|
574 |
}
|
575 |
}
|
576 |
|
577 |
-
private function _file_list_folder( $folder = '', $levels = 100, $excludes) {
|
578 |
if( empty($folder) )
|
579 |
return false;
|
580 |
if( ! $levels )
|
@@ -587,17 +662,12 @@ class backwpup_dojob {
|
|
587 |
if (false !== stripos($folder.'/'.$file,$exclusion) and !empty($exclusion) and $exclusion!='/')
|
588 |
continue 2;
|
589 |
}
|
590 |
-
if (
|
591 |
-
|
592 |
-
|
593 |
-
continue;
|
594 |
-
if (!$this->job['backupplugins'] and false !== stripos($folder.'/'.$file,str_replace('\\','/',WP_PLUGIN_DIR)))
|
595 |
-
continue;
|
596 |
-
if ( is_dir( $folder . '/' . $file ) ) {
|
597 |
-
$this->_file_list_folder( $folder . '/' . $file, $levels - 1, $excludes);
|
598 |
} elseif (is_file( $folder . '/' . $file )) {
|
599 |
if (is_readable($folder . '/' . $file)) { //add file to filelist
|
600 |
-
$this->
|
601 |
$this->allfilesize=$this->allfilesize+filesize($folder . '/' . $file);
|
602 |
} else {
|
603 |
trigger_error(__('Can not read file:','backwpup').' '.$folder . '/' . $file,E_USER_WARNING);
|
@@ -610,36 +680,34 @@ class backwpup_dojob {
|
|
610 |
}
|
611 |
}
|
612 |
|
613 |
-
|
614 |
|
615 |
//Make filelist
|
616 |
trigger_error(__('Make a list of files to Backup ....','backwpup'),E_USER_NOTICE);
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
//Exclude Temp Files
|
622 |
$backwpup_exclude[]=$this->tempdir.DB_NAME.'.sql';
|
623 |
$backwpup_exclude[]=$this->tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml';
|
624 |
-
|
625 |
-
$jobs=get_option('backwpup_jobs');
|
626 |
-
foreach($jobs as $jobsvale) {
|
627 |
-
if (!empty($jobsvale['backupdir']) and $jobsvale['backupdir']!='/')
|
628 |
-
$backwpup_exclude[]=$jobsvale['backupdir'];
|
629 |
-
}
|
630 |
-
$backwpup_exclude=array_unique($backwpup_exclude);
|
631 |
|
632 |
-
//
|
633 |
-
if (
|
634 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
635 |
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
$dirinclude[]=WP_CONTENT_DIR;
|
640 |
-
if ($this->job['backupplugins'] and ((strtolower(str_replace('\\','/',substr(WP_PLUGIN_DIR,0,strlen(ABSPATH))))!=strtolower(str_replace('\\','/',ABSPATH)) and $this->job['backuproot']) or !$this->job['backuproot']) and ((strtolower(str_replace('\\','/',substr(WP_PLUGIN_DIR,0,strlen(WP_CONTENT_DIR))))!=strtolower(str_replace('\\','/',WP_CONTENT_DIR)) and $this->job['backupcontent']) or !$this->job['backupcontent']))
|
641 |
-
$dirinclude[]=WP_PLUGIN_DIR;
|
642 |
-
$dirinclude=array_unique($dirinclude);
|
643 |
//Crate file list
|
644 |
if (is_array($dirinclude)) {
|
645 |
foreach($dirinclude as $dirincludevalue) {
|
@@ -648,6 +716,13 @@ class backwpup_dojob {
|
|
648 |
}
|
649 |
}
|
650 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
651 |
if (!is_array($this->filelist[0])) {
|
652 |
trigger_error(__('No files to Backup','backwpup'),E_USER_ERROR);
|
653 |
} else {
|
@@ -656,13 +731,15 @@ class backwpup_dojob {
|
|
656 |
|
657 |
}
|
658 |
|
659 |
-
|
660 |
|
661 |
if (class_exists('ZipArchive')) { //use php zip lib
|
662 |
trigger_error(__('Create Backup Zip file...','backwpup'),E_USER_NOTICE);
|
663 |
$zip = new ZipArchive;
|
664 |
if ($res=$zip->open($this->backupdir.$this->backupfile,ZIPARCHIVE::CREATE) === TRUE) {
|
665 |
-
foreach($this->filelist as $key => $files) {
|
|
|
|
|
666 |
if ($zip->addFile($files[79001], $files[79003])) {
|
667 |
trigger_error(__('Add File to ZIP file:','backwpup').' '.$files[79001].' '.backwpup_formatBytes(filesize($files[79001])),E_USER_NOTICE);
|
668 |
} else {
|
@@ -677,7 +754,8 @@ class backwpup_dojob {
|
|
677 |
|
678 |
} else { //use PclZip
|
679 |
define( 'PCLZIP_TEMPORARY_DIR', $this->tempdir );
|
680 |
-
if (!class_exists('PclZip'))
|
|
|
681 |
|
682 |
//Create Zip File
|
683 |
if (is_array($this->filelist[0])) {
|
@@ -696,7 +774,7 @@ class backwpup_dojob {
|
|
696 |
}
|
697 |
}
|
698 |
|
699 |
-
|
700 |
|
701 |
if ($this->backupfileformat=='.tar.gz') {
|
702 |
$tarbackup=gzopen($this->backupdir.$this->backupfile,'w9');
|
@@ -717,6 +795,11 @@ class backwpup_dojob {
|
|
717 |
|
718 |
foreach($this->filelist as $key => $files) {
|
719 |
trigger_error(__('Add File to Backup Archive:','backwpup').' '.$files[79001].' '.backwpup_formatBytes(filesize($files[79001])),E_USER_NOTICE);
|
|
|
|
|
|
|
|
|
|
|
720 |
// Get file information
|
721 |
$file_information = stat($files[79001]);
|
722 |
|
@@ -789,7 +872,7 @@ class backwpup_dojob {
|
|
789 |
}
|
790 |
|
791 |
|
792 |
-
|
793 |
$return=ftp_raw($ftp_conn_id,$command);
|
794 |
if (strtoupper(substr(trim($command),0,4))=="PASS") {
|
795 |
trigger_error(__('FTP Client command:','backwpup').' PASS *******',E_USER_NOTICE);
|
@@ -818,11 +901,7 @@ class backwpup_dojob {
|
|
818 |
}
|
819 |
|
820 |
|
821 |
-
|
822 |
-
$this->job['ftpdir']=trailingslashit($this->job['ftpdir']);
|
823 |
-
if ($this->job['ftpdir']=='/')
|
824 |
-
$this->job['ftpdir']='';
|
825 |
-
|
826 |
|
827 |
if (empty($this->job['ftphost']) or empty($this->job['ftpuser']) or empty($this->job['ftppass']))
|
828 |
return false;
|
@@ -926,20 +1005,15 @@ class backwpup_dojob {
|
|
926 |
|
927 |
}
|
928 |
|
929 |
-
|
930 |
if (empty($this->job['mailaddress']))
|
931 |
return false;
|
932 |
|
933 |
trigger_error(__('Prepare Sending backupfile with mail...','backwpup'),E_USER_NOTICE);
|
934 |
|
935 |
-
if (!is_file($this->backupdir.$this->backupfile)) {
|
936 |
-
trigger_error(__('No file to send!','backwpup'),E_USER_ERROR);
|
937 |
-
return false;
|
938 |
-
}
|
939 |
-
|
940 |
//Crate PHP Mailer
|
941 |
-
require_once
|
942 |
-
require_once
|
943 |
$phpmailer = new PHPMailer();
|
944 |
//Setting den methode
|
945 |
if ($this->cfg['mailmethod']=="SMTP") {
|
@@ -984,7 +1058,7 @@ class backwpup_dojob {
|
|
984 |
}
|
985 |
|
986 |
trigger_error(__('Adding Attachment to mail','backwpup'),E_USER_NOTICE);
|
987 |
-
$this->need_free_memory(filesize($this->backupdir.$this->backupfile)*
|
988 |
$phpmailer->AddAttachment($this->backupdir.$this->backupfile);
|
989 |
|
990 |
trigger_error(__('Send mail....','backwpup'),E_USER_NOTICE);
|
@@ -996,10 +1070,7 @@ class backwpup_dojob {
|
|
996 |
|
997 |
}
|
998 |
|
999 |
-
|
1000 |
-
$this->job['awsdir']=trailingslashit($this->job['awsdir']);
|
1001 |
-
if ($this->job['awsdir']=='/')
|
1002 |
-
$this->job['awsdir']='';
|
1003 |
|
1004 |
if (empty($this->job['awsAccessKey']) or empty($this->job['awsSecretKey']) or empty($this->job['awsBucket']))
|
1005 |
return false;
|
@@ -1010,7 +1081,7 @@ class backwpup_dojob {
|
|
1010 |
}
|
1011 |
|
1012 |
if (!class_exists('S3'))
|
1013 |
-
require_once('libs/S3.php');
|
1014 |
|
1015 |
$s3 = new S3($this->job['awsAccessKey'], $this->job['awsSecretKey'], $this->job['awsSSL']);
|
1016 |
|
@@ -1051,12 +1122,12 @@ class backwpup_dojob {
|
|
1051 |
}
|
1052 |
}
|
1053 |
|
1054 |
-
|
1055 |
-
if (empty($this->job['backupdir'])
|
1056 |
return;
|
1057 |
//Delete old Backupfiles
|
1058 |
$backupfilelist=array();
|
1059 |
-
if (!empty($this->job['maxbackups'])
|
1060 |
if ( $dir = @opendir($this->job['backupdir']) ) { //make file list
|
1061 |
while (($file = readdir($dir)) !== false ) {
|
1062 |
if ('backwpup_'.$this->jobid.'_' == substr($file,0,strlen('backwpup_'.$this->jobid.'_')) and $this->backupfileformat == substr($file,-strlen($this->backupfileformat)))
|
@@ -1092,7 +1163,7 @@ class backwpup_dojob {
|
|
1092 |
unlink($this->tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml');
|
1093 |
}
|
1094 |
|
1095 |
-
if (
|
1096 |
unlink($this->backupdir.$this->backupfile);
|
1097 |
}
|
1098 |
|
8 |
function backwpup_joberrorhandler($errno, $errstr, $errfile, $errline) {
|
9 |
global $backwpup_logfile;
|
10 |
|
11 |
+
//genrate timestamp
|
12 |
+
if (!function_exists('memory_get_usage')) { // test if memory functions compiled in
|
13 |
+
$timestamp="<span style=\"background-color:c3c3c3;\" title=\"[Line: ".$errline."|File: ".basename($errfile)."\">".date_i18n('Y-m-d H:i.s').":</span> ";
|
14 |
+
} else {
|
15 |
+
if (version_compare(phpversion(), '5.2.0', '<'))
|
16 |
+
$timestamp="<span style=\"background-color:c3c3c3;\" title=\"[Line: ".$errline."|File: ".basename($errfile)."|Mem: ".backwpup_formatBytes(@memory_get_usage())."|Mem Max: ".backwpup_formatBytes(@memory_get_peak_usage())."|Mem Limit: ".ini_get('memory_limit')."]\">".date_i18n('Y-m-d H:i.s').":</span> ";
|
17 |
+
else
|
18 |
+
$timestamp="<span style=\"background-color:c3c3c3;\" title=\"[Line: ".$errline."|File: ".basename($errfile)."|Mem: ".backwpup_formatBytes(@memory_get_usage(true))."|Mem Max: ".backwpup_formatBytes(@memory_get_peak_usage(true))."|Mem Limit: ".ini_get('memory_limit')."]\">".date_i18n('Y-m-d H:i.s').":</span> ";
|
19 |
+
}
|
20 |
+
|
21 |
switch ($errno) {
|
22 |
case E_NOTICE:
|
23 |
case E_USER_NOTICE:
|
24 |
+
$massage=$timestamp."<span>".$errstr."</span>";
|
|
|
25 |
break;
|
26 |
case E_WARNING:
|
27 |
case E_USER_WARNING:
|
|
|
|
|
|
|
28 |
$logheader=backwpup_read_logheader($backwpup_logfile); //read waring count from log header
|
29 |
$warnings=$logheader['warnings']+1;
|
30 |
+
$massage=$timestamp."<span style=\"background-color:yellow;\">".__('[WARNING]','backwpup')." ".$errstr."</span>";
|
31 |
break;
|
|
|
32 |
case E_USER_ERROR:
|
|
|
|
|
|
|
33 |
$logheader=backwpup_read_logheader($backwpup_logfile); //read error count from log header
|
34 |
$errors=$logheader['errors']+1;
|
35 |
+
$massage=$timestamp."<span style=\"background-color:red;\">".__('[ERROR]','backwpup')." ".$errstr."</span>";
|
36 |
break;
|
37 |
case E_DEPRECATED:
|
38 |
case E_USER_DEPRECATED:
|
39 |
+
$massage=$timestamp."<span>".__('[DEPRECATED]','backwpup')." ".$errstr."</span>";
|
|
|
|
|
|
|
|
|
|
|
40 |
break;
|
41 |
case E_STRICT:
|
42 |
+
$massage=$timestamp."<span>".__('[STRICT NOTICE]','backwpup')." ".$errstr."</span>";
|
|
|
43 |
break;
|
44 |
case E_RECOVERABLE_ERROR:
|
45 |
+
$massage=$timestamp."<span>".__('[RECOVERABLE ERROR]','backwpup')." ".$errstr."</span>";
|
|
|
46 |
break;
|
47 |
default:
|
48 |
+
$massage=$timestamp."<span>[".$errno."] ".$errstr."</span>";
|
|
|
49 |
break;
|
50 |
}
|
51 |
|
52 |
+
if (!empty($massage)) {
|
53 |
+
//wirte log file
|
54 |
+
$fd=@fopen($backwpup_logfile,"a+");
|
55 |
+
@fputs($fd,$massage."<br />\n");
|
56 |
+
@fclose($fd);
|
57 |
|
58 |
+
//output on run now
|
59 |
+
if (!defined('DOING_CRON')) {
|
60 |
+
echo $massage."<script type=\"text/javascript\">window.scrollBy(0, 15);</script><br />\n";
|
61 |
+
@flush();
|
62 |
+
@ob_flush();
|
63 |
+
}
|
64 |
|
65 |
+
//write new log header
|
66 |
+
if (isset($errors) or isset($warnings)) {
|
67 |
+
$fd=@fopen($backwpup_logfile,"r+");
|
68 |
+
while (!feof($fd)) {
|
69 |
+
$line=@fgets($fd);
|
70 |
+
if (stripos($line,"<meta name=\"backwpup_errors\"") !== false and isset($errors)) {
|
71 |
+
@fseek($fd,$filepos);
|
72 |
+
@fputs($fd,str_pad("<meta name=\"backwpup_errors\" content=\"".$errors."\" />",100)."\n");
|
73 |
+
break;
|
74 |
+
}
|
75 |
+
if (stripos($line,"<meta name=\"backwpup_warnings\"") !== false and isset($warnings)) {
|
76 |
+
@fseek($fd,$filepos);
|
77 |
+
@fputs($fd,str_pad("<meta name=\"backwpup_warnings\" content=\"".$warnings."\" />",100)."\n");
|
78 |
+
break;
|
79 |
+
}
|
80 |
+
$filepos=ftell($fd);
|
81 |
+
}
|
82 |
+
@fclose($fd);
|
83 |
+
}
|
84 |
+
|
85 |
+
if ($errno==E_ERROR or $errno==E_CORE_ERROR or $errno==E_COMPILE_ERROR) //Die on fatal php errors.
|
86 |
+
die();
|
87 |
+
|
88 |
+
|
89 |
+
@set_time_limit(300); //300 is most webserver time limit. 0= max time! Give script 5 min. more to work.
|
90 |
+
//true for no more php error hadling.
|
91 |
+
return true;
|
92 |
+
} else {
|
93 |
+
return false;
|
94 |
}
|
95 |
+
}
|
96 |
+
|
97 |
+
//Job shutdown function for abort
|
98 |
+
function backwpup_jobshutdown() {
|
99 |
+
global $backwpup_logfile;
|
100 |
+
$logheader=backwpup_read_logheader($backwpup_logfile); //read waring count from log header
|
101 |
+
$cfg=get_option('backwpup'); //load config
|
102 |
+
$jobs=get_option('backwpup_jobs'); //load job options
|
103 |
+
|
104 |
+
if (!empty($jobs[$logheader['jobid']]['stoptime'])) //abort if job exits normaly
|
105 |
+
return;
|
106 |
+
|
107 |
+
backwpup_joberrorhandler(E_USER_WARNING, __('Job shutdown function is working! Please delete temp Backupfiles by hand.','backwpup'), __FILE__, __LINE__);
|
108 |
+
|
109 |
+
//try to get last error
|
110 |
+
$lasterror=error_get_last();
|
111 |
+
backwpup_joberrorhandler($lasterror['type'], __('Last ERROR:','backwpup').' '.$lasterror['message'], $lasterror['file'], $lasterror['line']);
|
112 |
+
|
113 |
+
//set Temp Dir
|
114 |
+
$tempdir=trailingslashit($cfg['dirtemp']);
|
115 |
+
if ($tempdir=='/')
|
116 |
+
$tempdir=backwpup_get_upload_dir();
|
117 |
+
|
118 |
+
if (is_file($tempdir.DB_NAME.'.sql') ) { //delete sql temp file
|
119 |
+
unlink($tempdir.DB_NAME.'.sql');
|
120 |
+
}
|
121 |
+
|
122 |
+
if (is_file($tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml') ) { //delete WP XML Export temp file
|
123 |
+
unlink($tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml');
|
124 |
+
}
|
125 |
+
|
126 |
+
$jobs[$logheader['jobid']]['stoptime']=current_time('timestamp');
|
127 |
+
$jobs[$logheader['jobid']]['lastrun']=$jobs[$logheader['jobid']]['starttime'];
|
128 |
+
$jobs[$logheader['jobid']]['lastruntime']=$jobs[$logheader['jobid']]['stoptime']-$jobs[$logheader['jobid']]['starttime'];
|
129 |
+
update_option('backwpup_jobs',$jobs); //Save Settings
|
130 |
+
|
131 |
+
//write runtime header
|
132 |
$fd=@fopen($backwpup_logfile,"r+");
|
133 |
while (!feof($fd)) {
|
134 |
$line=@fgets($fd);
|
135 |
+
if (stripos($line,"<meta name=\"backwpup_jobruntime\"") !== false) {
|
|
|
|
|
|
|
|
|
|
|
136 |
@fseek($fd,$filepos);
|
137 |
+
@fputs($fd,str_pad("<meta name=\"backwpup_jobruntime\" content=\"".$jobs[$logheader['jobid']]['lastruntime']."\" />",100)."\n");
|
138 |
break;
|
139 |
}
|
140 |
$filepos=ftell($fd);
|
141 |
}
|
142 |
@fclose($fd);
|
143 |
+
//logfile end
|
144 |
+
$fd=fopen($backwpup_logfile,"a+");
|
145 |
+
fputs($fd,"</body>\n</html>\n");
|
146 |
+
fclose($fd);
|
147 |
+
restore_error_handler();
|
148 |
+
$logdata=backwpup_read_logheader($backwpup_logfile);
|
149 |
+
//Send mail with log
|
150 |
+
$sendmail=false;
|
151 |
+
if ($logdata['errors']>0 and $jobs[$logheader['jobid']]['mailerroronly'] and !empty($jobs[$logheader['jobid']]['mailaddresslog']))
|
152 |
+
$sendmail=true;
|
153 |
+
if (!$jobs[$logheader['jobid']]['mailerroronly'] and !empty($jobs[$logheader['jobid']]['mailaddresslog']))
|
154 |
+
$sendmail=true;
|
155 |
+
if ($sendmail) {
|
156 |
+
$mailbody=__("Jobname:","backwpup")." ".$logdata['name']."\n";
|
157 |
+
$mailbody.=__("Jobtype:","backwpup")." ".$logdata['type']."\n";
|
158 |
+
if (!empty($logdata['errors']))
|
159 |
+
$mailbody.=__("Errors:","backwpup")." ".$logdata['errors']."\n";
|
160 |
+
if (!empty($logdata['warnings']))
|
161 |
+
$mailbody.=__("Warnings:","backwpup")." ".$logdata['warnings']."\n";
|
162 |
+
wp_mail($jobs[$logheader['jobid']]['mailaddresslog'],__('BackWPup Log File from','backwpup').' '.date_i18n('Y-m-d H:i',$jobs[$logheader['jobid']]['starttime']).': '.$jobs[$logheader['jobid']]['name'] ,$mailbody,'',array($backwpup_logfile));
|
163 |
+
}
|
164 |
}
|
165 |
|
|
|
166 |
/**
|
167 |
* BackWPup PHP class for WordPress
|
168 |
*
|
171 |
|
172 |
private $jobid=0;
|
173 |
private $filelist=array();
|
174 |
+
private $tempfilelist=array();
|
175 |
private $todo=array();
|
176 |
private $allfilesize=0;
|
177 |
private $backupfile='';
|
184 |
private $job=array();
|
185 |
|
186 |
public function __construct($jobid) {
|
187 |
+
global $backwpup_logfile,$backwpup_dojob;
|
188 |
+
@ini_get('safe_mode','Off'); //disable safe mode
|
189 |
+
//Set no user abort
|
190 |
+
@ini_set('ignore_user_abort','Off'); //Set PHP ini setting
|
191 |
+
ignore_user_abort(true); //user can't abort script (close windows or so.)
|
192 |
$this->jobid=$jobid; //set job id
|
193 |
$this->cfg=get_option('backwpup'); //load config
|
194 |
$jobs=get_option('backwpup_jobs'); //load jobdata
|
197 |
if ($schedteime=wp_next_scheduled('backwpup_cron',array('jobid'=>$this->jobid))) //set Schedule time to next scheduled
|
198 |
$jobs[$this->jobid]['scheduletime']=$schedteime;
|
199 |
update_option('backwpup_jobs',$jobs); //Save job Settings
|
200 |
+
$this->job=backwpup_check_job_vars($jobs[$this->jobid]);//Set and check job settings
|
201 |
//set waht to do
|
202 |
$this->todo=explode('+',$this->job['type']);
|
203 |
//set Backup File format Dir
|
204 |
+
$this->backupfileformat=$this->job['fileformart'];
|
|
|
205 |
//set Temp Dir
|
206 |
$this->tempdir=trailingslashit($this->cfg['dirtemp']);
|
207 |
if (empty($this->tempdir) or $this->tempdir=='/')
|
208 |
+
$this->tempdir=backwpup_get_upload_dir();
|
209 |
//set Backup Dir
|
210 |
+
$this->backupdir=$this->job['backupdir'];
|
211 |
+
if (empty($this->backupdir))
|
212 |
$this->backupdir=$this->tempdir;
|
|
|
213 |
//set Logs Dir
|
214 |
$this->logdir=trailingslashit($this->cfg['dirlogs']);
|
215 |
if (empty($this->logdir) or $this->logdir=='/') {
|
234 |
@fputs($fd,"<meta name=\"backwpup_jobid\" content=\"".$this->jobid."\" />\n");
|
235 |
@fputs($fd,"<meta name=\"backwpup_jobname\" content=\"".$this->job['name']."\" />\n");
|
236 |
@fputs($fd,"<meta name=\"backwpup_jobtype\" content=\"".$this->job['type']."\" />\n");
|
237 |
+
if (!empty($this->backupfile) and $this->backupdir!=$this->tempdir)
|
238 |
@fputs($fd,"<meta name=\"backwpup_backupfile\" content=\"".$this->backupdir.$this->backupfile."\" />\n");
|
239 |
@fputs($fd,str_pad("<meta name=\"backwpup_jobruntime\" content=\"0\" />",100)."\n");
|
240 |
@fputs($fd,"<title>".sprintf(__('BackWPup Log for %1$s from %2$s at %3$s','backwpup'),$this->job['name'],date_i18n(get_option('date_format')),date_i18n(get_option('time_format')))."</title>\n</head>\n<body style=\"font-family:monospace;font-size:12px;white-space:nowrap;\">\n");
|
241 |
@fclose($fd);
|
242 |
+
//set function for PHP user defineid error handling
|
243 |
+
if (defined(WP_DEBUG) and WP_DEBUG)
|
244 |
+
set_error_handler('backwpup_joberrorhandler',E_ALL | E_STRICT);
|
245 |
+
else
|
246 |
+
set_error_handler('backwpup_joberrorhandler',E_ALL & ~E_NOTICE);
|
247 |
+
//set a schutdown function.
|
248 |
+
register_shutdown_function('backwpup_jobshutdown');
|
249 |
//check dirs
|
250 |
+
if ($this->backupdir!=backwpup_get_upload_dir()) {
|
251 |
if (!$this->_check_folders($this->backupdir))
|
252 |
return false;
|
253 |
}
|
254 |
//check max script execution tme
|
255 |
+
if (ini_get('safe_mode') or strtolower(ini_get('safe_mode'))=='on' or ini_get('safe_mode')=='1')
|
|
|
|
|
256 |
trigger_error(sprintf(__('PHP Safe Mode is on!!! Max exec time is %1$d sec.','backwpup'),ini_get('max_execution_time')),E_USER_WARNING);
|
|
|
257 |
// check function for memorylimit
|
258 |
if (!function_exists('memory_get_usage')) {
|
259 |
+
ini_set('memory_limit', apply_filters( 'admin_memory_limit', '256M' )); //Wordpress default
|
260 |
+
trigger_error(sprintf(__('Memory limit set to %1$s ,because can not use PHP: memory_get_usage() function to dynamicly increase the Memeory!','backwpup'),ini_get('memory_limit')),E_USER_WARNING);
|
|
|
|
|
261 |
}
|
262 |
//run job parts
|
263 |
foreach($this->todo as $key => $value) {
|
264 |
switch ($value) {
|
265 |
case 'DB':
|
266 |
+
$this->dump_db();
|
267 |
break;
|
268 |
case 'WPEXP':
|
269 |
$this->export_wp();
|
273 |
break;
|
274 |
}
|
275 |
}
|
276 |
+
|
277 |
+
if (isset($this->filelist[0][79001])) { // Make backup file
|
278 |
if ($this->backupfileformat==".zip")
|
279 |
$this->zip_files();
|
280 |
elseif ($this->backupfileformat==".tar.gz" or $this->backupfileformat==".tar.bz2" or $this->backupfileformat==".tar")
|
281 |
$this->tar_pack_files();
|
282 |
+
}
|
283 |
+
if (file_exists($this->backupdir.$this->backupfile)) { // Put backup file to destination
|
|
|
|
|
284 |
$this->destination_mail();
|
285 |
$this->destination_ftp();
|
286 |
$this->destination_s3();
|
287 |
+
$this->destination_dir();
|
288 |
}
|
289 |
|
290 |
foreach($this->todo as $key => $value) {
|
291 |
switch ($value) {
|
292 |
case 'CHECK':
|
293 |
+
$this->check_db();
|
294 |
break;
|
295 |
case 'OPTIMIZE':
|
296 |
+
$this->optimize_db();
|
297 |
break;
|
298 |
}
|
299 |
}
|
300 |
+
}
|
301 |
|
302 |
private function _check_folders($folder) {
|
|
|
|
|
303 |
if (!is_dir($folder)) { //create dir if not exists
|
304 |
if (!mkdir($folder,0777,true)) {
|
305 |
trigger_error(sprintf(__('Can not create Folder: %1$s','backwpup'),$folder),E_USER_ERROR);
|
312 |
}
|
313 |
//create .htaccess for apache and index.html for other
|
314 |
if (strtolower(substr($_SERVER["SERVER_SOFTWARE"],0,6))=="apache") { //check if it a apache webserver
|
315 |
+
if (!is_file($folder.'.htaccess')) {
|
316 |
+
if($file = fopen($folder.'.htaccess', 'w')) {
|
317 |
fwrite($file, "Order allow,deny\ndeny from all");
|
318 |
fclose($file);
|
319 |
}
|
320 |
}
|
321 |
} else {
|
322 |
+
if (!is_file($folder.'index.html')) {
|
323 |
+
if($file = fopen($folder.'index.html', 'w')) {
|
324 |
+
fwrite($file,"\n");
|
325 |
+
fclose($file);
|
326 |
+
}
|
327 |
+
}
|
328 |
+
if (!is_file($folder.'index.php')) {
|
329 |
+
if($file = fopen($folder.'index.php', 'w')) {
|
330 |
fwrite($file,"\n");
|
331 |
fclose($file);
|
332 |
}
|
339 |
//fail back if fuction not exist
|
340 |
if (!function_exists('memory_get_usage'))
|
341 |
return true;
|
342 |
+
|
343 |
+
if (ini_get('safe_mode') or strtolower(ini_get('safe_mode'))=='on' or ini_get('safe_mode')=='1') {
|
344 |
+
trigger_error(sprintf(__('PHP Safe Mode is on!!! Can not increase Memory Limit is %1$s','backwpup'),ini_get('memory_limit')),E_USER_WARNING);
|
345 |
+
return false;
|
346 |
+
}
|
347 |
|
348 |
//calc mem to bytes
|
349 |
if (strtoupper(substr(trim(ini_get('memory_limit')),-1))=='K')
|
355 |
else
|
356 |
$memory=trim(ini_get('memory_limit'));
|
357 |
|
358 |
+
//use real memory at php version 5.2.0
|
359 |
+
if (version_compare(phpversion(), '5.2.0', '<'))
|
360 |
+
$memnow=memory_get_usage();
|
361 |
+
else
|
362 |
+
$memnow=memory_get_usage(true);
|
363 |
+
|
364 |
+
//need memory
|
365 |
+
$needmemory=$memnow+$memneed;
|
366 |
+
|
367 |
// increase Memory
|
368 |
+
if ($needmemory>$memory) {
|
369 |
+
$newmemory=round($needmemory/1024/1024)+1;
|
|
|
|
|
|
|
|
|
370 |
if ($oldmem=ini_set('memory_limit', $newmemory.'M'))
|
371 |
trigger_error(sprintf(__('Memory increased from %1$s to %2$s','backwpup'),$oldmem,ini_get('memory_limit')),E_USER_NOTICE);
|
372 |
else
|
409 |
}
|
410 |
}
|
411 |
|
412 |
+
private function check_db() {
|
413 |
global $wpdb;
|
414 |
|
415 |
trigger_error(__('Run Database check...','backwpup'),E_USER_NOTICE);
|
416 |
|
417 |
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
|
|
418 |
//exclude tables from check
|
419 |
+
foreach($tables as $tablekey => $tablevalue) {
|
420 |
+
if (in_array($tablevalue,$this->job['dbexclude']))
|
421 |
+
unset($tables[$tablekey]);
|
|
|
|
|
422 |
}
|
423 |
+
|
|
|
424 |
//check tables
|
425 |
if (sizeof($tables)>0) {
|
426 |
$this->maintenance_mode(true);
|
518 |
fwrite($file, "UNLOCK TABLES;\n");
|
519 |
}
|
520 |
|
521 |
+
private function dump_db() {
|
522 |
global $wpdb;
|
523 |
trigger_error(__('Run Database Dump to file...','backwpup'),E_USER_NOTICE);
|
524 |
$this->maintenance_mode(true);
|
525 |
+
|
526 |
//Tables to backup
|
527 |
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
528 |
if ($sqlerr=mysql_error($wpdb->dbh))
|
529 |
trigger_error(sprintf(__('BackWPup database error %1$s for query %2$s','backwpup'), $sqlerr, "SHOW TABLES FROM `'.DB_NAME.'`"),E_USER_ERROR);
|
530 |
+
|
531 |
+
foreach($tables as $tablekey => $tablevalue) {
|
532 |
+
if (in_array($tablevalue,$this->job['dbexclude']))
|
533 |
+
unset($tables[$tablekey]);
|
|
|
|
|
534 |
}
|
535 |
+
sort($tables);
|
536 |
+
|
537 |
|
538 |
if (sizeof($tables)>0) {
|
539 |
$result=$wpdb->get_results("SHOW TABLE STATUS FROM `".DB_NAME."`;", ARRAY_A); //get table status
|
602 |
$this->maintenance_mode(false);
|
603 |
}
|
604 |
|
605 |
+
private function export_wp() {
|
606 |
trigger_error(__('Run Wordpress Export to XML file...','backwpup'),E_USER_NOTICE);
|
607 |
if (copy(plugins_url('wp_xml_export.php',__FILE__).'?wpabs='.trailingslashit(ABSPATH).'&_nonce='.substr(md5(md5(SECURE_AUTH_KEY)),10,10),$this->tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml')) {
|
608 |
trigger_error(__('Export to XML done!','backwpup'),E_USER_NOTICE);
|
615 |
}
|
616 |
}
|
617 |
|
618 |
+
private function optimize_db() {
|
619 |
global $wpdb;
|
620 |
|
621 |
trigger_error(__('Run Database optimize...','backwpup'),E_USER_NOTICE);
|
622 |
|
623 |
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
|
|
624 |
//exclude tables from optimize
|
625 |
+
foreach($tables as $tablekey => $tablevalue) {
|
626 |
+
if (in_array($tablevalue,$this->job['dbexclude']))
|
627 |
+
unset($tables[$tablekey]);
|
|
|
|
|
628 |
}
|
629 |
+
|
630 |
if (sizeof($tables)>0) {
|
631 |
$this->maintenance_mode(true);
|
632 |
foreach ($tables as $table) {
|
649 |
}
|
650 |
}
|
651 |
|
652 |
+
private function _file_list_folder( $folder = '', $levels = 100, $excludes,$excludedirs=array()) {
|
653 |
if( empty($folder) )
|
654 |
return false;
|
655 |
if( ! $levels )
|
662 |
if (false !== stripos($folder.'/'.$file,$exclusion) and !empty($exclusion) and $exclusion!='/')
|
663 |
continue 2;
|
664 |
}
|
665 |
+
if ( is_dir( $folder . '/' . $file )) {
|
666 |
+
if (!in_array(trailingslashit($folder.'/'.$file),$excludedirs))
|
667 |
+
$this->_file_list_folder( $folder . '/' . $file, $levels - 1, $excludes);
|
|
|
|
|
|
|
|
|
|
|
668 |
} elseif (is_file( $folder . '/' . $file )) {
|
669 |
if (is_readable($folder . '/' . $file)) { //add file to filelist
|
670 |
+
$this->tempfilelist[]=$folder.'/'.$file;
|
671 |
$this->allfilesize=$this->allfilesize+filesize($folder . '/' . $file);
|
672 |
} else {
|
673 |
trigger_error(__('Can not read file:','backwpup').' '.$folder . '/' . $file,E_USER_WARNING);
|
680 |
}
|
681 |
}
|
682 |
|
683 |
+
private function file_list() {
|
684 |
|
685 |
//Make filelist
|
686 |
trigger_error(__('Make a list of files to Backup ....','backwpup'),E_USER_NOTICE);
|
687 |
+
|
688 |
+
$this->tempfilelist=array();
|
689 |
+
|
690 |
+
$backwpup_exclude=explode(',',trim($this->job['fileexclude']));
|
691 |
//Exclude Temp Files
|
692 |
$backwpup_exclude[]=$this->tempdir.DB_NAME.'.sql';
|
693 |
$backwpup_exclude[]=$this->tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml';
|
694 |
+
$backwpup_exclude=array_unique($backwpup_exclude,SORT_STRING);
|
|
|
|
|
|
|
|
|
|
|
|
|
695 |
|
696 |
+
//File list for blog folders
|
697 |
+
if ($this->job['backuproot'])
|
698 |
+
$this->_file_list_folder(untrailingslashit(str_replace('\\','/',ABSPATH)),100,$backwpup_exclude,array_merge($this->job['backuprootexcludedirs'],backwpup_get_exclude_wp_dirs(ABSPATH)));
|
699 |
+
if ($this->job['backupcontent'])
|
700 |
+
$this->_file_list_folder(untrailingslashit(str_replace('\\','/',WP_CONTENT_DIR)),100,$backwpup_exclude,array_merge($this->job['backupcontentexcludedirs'],backwpup_get_exclude_wp_dirs(WP_CONTENT_DIR)));
|
701 |
+
if ($this->job['backupplugins'])
|
702 |
+
$this->_file_list_folder(untrailingslashit(str_replace('\\','/',WP_PLUGIN_DIR)),100,$backwpup_exclude,array_merge($this->job['backuppluginsexcludedirs'],backwpup_get_exclude_wp_dirs(WP_PLUGIN_DIR)));
|
703 |
+
if ($this->job['backupthemes'])
|
704 |
+
$this->_file_list_folder(untrailingslashit(str_replace('\\','/',trailingslashit(WP_CONTENT_DIR).'themes')),100,$backwpup_exclude,array_merge($this->job['backupthemesexcludedirs'],backwpup_get_exclude_wp_dirs(trailingslashit(WP_CONTENT_DIR).'themes')));
|
705 |
+
if ($this->job['backupuploads'])
|
706 |
+
$this->_file_list_folder(untrailingslashit(backwpup_get_upload_dir()),100,$backwpup_exclude,array_merge($this->job['backupuploadsexcludedirs'],backwpup_get_exclude_wp_dirs(backwpup_get_upload_dir())));
|
707 |
|
708 |
+
//include dirs
|
709 |
+
$dirinclude=explode(',',$this->job['dirinclude']);
|
710 |
+
$dirinclude=array_unique($dirinclude,SORT_STRING);
|
|
|
|
|
|
|
|
|
711 |
//Crate file list
|
712 |
if (is_array($dirinclude)) {
|
713 |
foreach($dirinclude as $dirincludevalue) {
|
716 |
}
|
717 |
}
|
718 |
|
719 |
+
$this->tempfilelist=array_unique($this->tempfilelist,SORT_STRING); //all files only one time in list
|
720 |
+
sort($this->tempfilelist);
|
721 |
+
foreach ($this->tempfilelist as $files) {
|
722 |
+
$this->filelist[]=array(79001=>$files,79003=>str_replace(str_replace('\\','/',trailingslashit(ABSPATH)),'',$files));
|
723 |
+
}
|
724 |
+
$this->tempfilelist=array();
|
725 |
+
|
726 |
if (!is_array($this->filelist[0])) {
|
727 |
trigger_error(__('No files to Backup','backwpup'),E_USER_ERROR);
|
728 |
} else {
|
731 |
|
732 |
}
|
733 |
|
734 |
+
private function zip_files() {
|
735 |
|
736 |
if (class_exists('ZipArchive')) { //use php zip lib
|
737 |
trigger_error(__('Create Backup Zip file...','backwpup'),E_USER_NOTICE);
|
738 |
$zip = new ZipArchive;
|
739 |
if ($res=$zip->open($this->backupdir.$this->backupfile,ZIPARCHIVE::CREATE) === TRUE) {
|
740 |
+
foreach($this->filelist as $key => $files) {
|
741 |
+
if (!is_file($files[79001])) //check file exists
|
742 |
+
continue;
|
743 |
if ($zip->addFile($files[79001], $files[79003])) {
|
744 |
trigger_error(__('Add File to ZIP file:','backwpup').' '.$files[79001].' '.backwpup_formatBytes(filesize($files[79001])),E_USER_NOTICE);
|
745 |
} else {
|
754 |
|
755 |
} else { //use PclZip
|
756 |
define( 'PCLZIP_TEMPORARY_DIR', $this->tempdir );
|
757 |
+
if (!class_exists('PclZip'))
|
758 |
+
require_once (plugin_dir_path(__FILE__).'libs/pclzip.lib.php');
|
759 |
|
760 |
//Create Zip File
|
761 |
if (is_array($this->filelist[0])) {
|
774 |
}
|
775 |
}
|
776 |
|
777 |
+
private function tar_pack_files() {
|
778 |
|
779 |
if ($this->backupfileformat=='.tar.gz') {
|
780 |
$tarbackup=gzopen($this->backupdir.$this->backupfile,'w9');
|
795 |
|
796 |
foreach($this->filelist as $key => $files) {
|
797 |
trigger_error(__('Add File to Backup Archive:','backwpup').' '.$files[79001].' '.backwpup_formatBytes(filesize($files[79001])),E_USER_NOTICE);
|
798 |
+
|
799 |
+
//check file exists
|
800 |
+
if (!is_file($files[79001]))
|
801 |
+
continue;
|
802 |
+
|
803 |
// Get file information
|
804 |
$file_information = stat($files[79001]);
|
805 |
|
872 |
}
|
873 |
|
874 |
|
875 |
+
private function _ftp_raw_helper($ftp_conn_id,$command) { //FTP Comands helper function
|
876 |
$return=ftp_raw($ftp_conn_id,$command);
|
877 |
if (strtoupper(substr(trim($command),0,4))=="PASS") {
|
878 |
trigger_error(__('FTP Client command:','backwpup').' PASS *******',E_USER_NOTICE);
|
901 |
}
|
902 |
|
903 |
|
904 |
+
private function destination_ftp() {
|
|
|
|
|
|
|
|
|
905 |
|
906 |
if (empty($this->job['ftphost']) or empty($this->job['ftpuser']) or empty($this->job['ftppass']))
|
907 |
return false;
|
1005 |
|
1006 |
}
|
1007 |
|
1008 |
+
private function destination_mail() {
|
1009 |
if (empty($this->job['mailaddress']))
|
1010 |
return false;
|
1011 |
|
1012 |
trigger_error(__('Prepare Sending backupfile with mail...','backwpup'),E_USER_NOTICE);
|
1013 |
|
|
|
|
|
|
|
|
|
|
|
1014 |
//Crate PHP Mailer
|
1015 |
+
require_once(ABSPATH.WPINC.'/class-phpmailer.php');
|
1016 |
+
require_once(ABSPATH.WPINC.'/class-smtp.php');
|
1017 |
$phpmailer = new PHPMailer();
|
1018 |
//Setting den methode
|
1019 |
if ($this->cfg['mailmethod']=="SMTP") {
|
1058 |
}
|
1059 |
|
1060 |
trigger_error(__('Adding Attachment to mail','backwpup'),E_USER_NOTICE);
|
1061 |
+
$this->need_free_memory(filesize($this->backupdir.$this->backupfile)*5);
|
1062 |
$phpmailer->AddAttachment($this->backupdir.$this->backupfile);
|
1063 |
|
1064 |
trigger_error(__('Send mail....','backwpup'),E_USER_NOTICE);
|
1070 |
|
1071 |
}
|
1072 |
|
1073 |
+
private function destination_s3() {
|
|
|
|
|
|
|
1074 |
|
1075 |
if (empty($this->job['awsAccessKey']) or empty($this->job['awsSecretKey']) or empty($this->job['awsBucket']))
|
1076 |
return false;
|
1081 |
}
|
1082 |
|
1083 |
if (!class_exists('S3'))
|
1084 |
+
require_once(plugin_dir_path(__FILE__).'libs/S3.php');
|
1085 |
|
1086 |
$s3 = new S3($this->job['awsAccessKey'], $this->job['awsSecretKey'], $this->job['awsSSL']);
|
1087 |
|
1122 |
}
|
1123 |
}
|
1124 |
|
1125 |
+
private function destination_dir() {
|
1126 |
+
if (empty($this->job['backupdir'])) //Go back if no destination dir
|
1127 |
return;
|
1128 |
//Delete old Backupfiles
|
1129 |
$backupfilelist=array();
|
1130 |
+
if (!empty($this->job['maxbackups'])) {
|
1131 |
if ( $dir = @opendir($this->job['backupdir']) ) { //make file list
|
1132 |
while (($file = readdir($dir)) !== false ) {
|
1133 |
if ('backwpup_'.$this->jobid.'_' == substr($file,0,strlen('backwpup_'.$this->jobid.'_')) and $this->backupfileformat == substr($file,-strlen($this->backupfileformat)))
|
1163 |
unlink($this->tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml');
|
1164 |
}
|
1165 |
|
1166 |
+
if (empty($this->job['backupdir']) and is_file($this->backupdir.$this->backupfile)) { //delete backup file in temp dir
|
1167 |
unlink($this->backupdir.$this->backupfile);
|
1168 |
}
|
1169 |
|
app/functions.php
CHANGED
@@ -109,13 +109,216 @@ if ( !defined('ABSPATH') )
|
|
109 |
delete_option('backwpup');
|
110 |
delete_option('backwpup_jobs');
|
111 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
//On Plugin activate
|
114 |
function backwpup_plugin_activate() {
|
115 |
-
//delete old log table
|
116 |
-
global $wpdb;
|
117 |
-
$wpdb->backwpup_logs = $wpdb->prefix.'backwpup_logs';
|
118 |
-
$wpdb->query("DROP TABLE IF EXISTS ".$wpdb->backwpup_logs);
|
119 |
//add cron jobs
|
120 |
$jobs=get_option('backwpup_jobs');
|
121 |
if (is_array($jobs)) {
|
@@ -131,11 +334,10 @@ if ( !defined('ABSPATH') )
|
|
131 |
if (empty($cfg['mailsndname'])) $cfg['mailsndname']='BackWPup '.get_bloginfo( 'name' );
|
132 |
if (empty($cfg['mailmethod'])) $cfg['mailmethod']='mail';
|
133 |
if (empty($cfg['mailsendmail'])) $cfg['mailsendmail']=substr(ini_get('sendmail_path'),0,strpos(ini_get('sendmail_path'),' -'));
|
134 |
-
if (empty($cfg['memorylimit'])) $cfg['memorylimit']='128M';
|
135 |
if (empty($cfg['maxlogs'])) $cfg['maxlogs']=0;
|
136 |
if (empty($cfg['dirtemp'])) {
|
137 |
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
138 |
-
$cfg['dirtemp']=
|
139 |
}
|
140 |
if (empty($cfg['dirlogs'])) {
|
141 |
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
@@ -198,8 +400,8 @@ if ( !defined('ABSPATH') )
|
|
198 |
if (empty($jobid))
|
199 |
return false;
|
200 |
require_once('backwpup_dojob.php');
|
201 |
-
$
|
202 |
-
unset($
|
203 |
return $backwpup_logfile;
|
204 |
}
|
205 |
|
@@ -347,7 +549,6 @@ if ( !defined('ABSPATH') )
|
|
347 |
echo "<meta http-equiv=\"cache-control\" content=\"no-cache\" />\n";
|
348 |
}
|
349 |
|
350 |
-
|
351 |
function backwpup_send_no_cache_header() {
|
352 |
header("Expires: 0");
|
353 |
header("Cache-Control: no-cache, must-revalidate");
|
@@ -355,18 +556,75 @@ if ( !defined('ABSPATH') )
|
|
355 |
header("Cache-Control: post-check=0, pre-check=0");
|
356 |
}
|
357 |
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
echo '<span id="awsBucket" style="color:red;">'.__('Missing Access Key ID!','backwpup').'</span>';
|
363 |
die();
|
364 |
}
|
365 |
-
if (empty($
|
366 |
echo '<span id="awsBucket" style="color:red;">'.__('Missing Secret Access Key!','backwpup').'</span>';
|
367 |
die();
|
368 |
}
|
369 |
-
$s3 = new S3($
|
370 |
$buckets=@$s3->listBuckets();
|
371 |
if (!is_array($buckets)) {
|
372 |
echo '<span id="awsBucket" style="color:red;">'.__('No Buckets found! Or wrong Keys!','backwpup').'</span>';
|
@@ -374,10 +632,11 @@ if ( !defined('ABSPATH') )
|
|
374 |
}
|
375 |
echo '<select name="awsBucket" id="awsBucket">';
|
376 |
foreach ($buckets as $bucket) {
|
377 |
-
echo "<option ".selected(strtolower($
|
378 |
}
|
379 |
echo '</select>';
|
380 |
-
|
|
|
381 |
}
|
382 |
|
383 |
// add all action and so on only if plugin loaded.
|
109 |
delete_option('backwpup');
|
110 |
delete_option('backwpup_jobs');
|
111 |
}
|
112 |
+
|
113 |
+
//Checking,upgrade and default job setting
|
114 |
+
function backwpup_check_job_vars($jobsettings) {
|
115 |
+
global $wpdb;
|
116 |
+
//check job type
|
117 |
+
if (!isset($jobsettings['type']) or !is_string($jobsettings['type']))
|
118 |
+
$jobsettings['type']='DB+FILE';
|
119 |
+
$todo=explode('+',strtoupper($jobsettings['type']));
|
120 |
+
foreach($todo as $key => $value) {
|
121 |
+
if (!in_array($value,backwpup_backup_types()))
|
122 |
+
unset($todo[$key]);
|
123 |
+
}
|
124 |
+
$jobsettings['type']=implode('+',$todo);
|
125 |
+
if (empty($jobsettings['type']))
|
126 |
+
$jobsettings['type']='DB+FILE';
|
127 |
+
|
128 |
+
if (empty($jobsettings['name']) or !is_string($jobsettings['name']))
|
129 |
+
$jobsettings['name']= __('New');
|
130 |
+
|
131 |
+
if (!isset($jobsettings['activated']) or !is_bool($jobsettings['activated']))
|
132 |
+
$jobsettings['activated']=false;
|
133 |
+
|
134 |
+
if (!isset($jobsettings['scheduletime']) or !is_numeric($jobsettings['scheduletime']))
|
135 |
+
$jobsettings['scheduletime']=current_time('timestamp');
|
136 |
+
|
137 |
+
if (!isset($jobsettings['scheduleintervaltype']) or !is_int($jobsettings['scheduleintervaltype']))
|
138 |
+
$jobsettings['scheduleintervaltype']=3600;
|
139 |
+
if ($jobsettings['scheduleintervaltype']!=60 and $jobsettings['scheduleintervaltype']!=3600 and $jobsettings['scheduleintervaltype']!=86400)
|
140 |
+
$jobsettings['scheduleintervaltype']=3600;
|
141 |
+
|
142 |
+
if (!isset($jobsettings['scheduleintervalteimes']) or !is_int($jobsettings['scheduleintervalteimes']) or ($jobsettings['scheduleintervalteimes']<1 and $jobsettings['scheduleintervalteimes']>100))
|
143 |
+
$jobsettings['scheduleintervalteimes']=1;
|
144 |
+
|
145 |
+
$jobsettings['scheduleinterval']=$jobsettings['scheduleintervaltype']*$jobsettings['scheduleintervalteimes'];
|
146 |
+
|
147 |
+
if (!is_string($jobsettings['mailaddresslog']) or false === $pos=strpos($jobsettings['mailaddresslog'],'@') or false === strpos($jobsettings['mailaddresslog'],'.',$pos))
|
148 |
+
$jobsettings['mailaddresslog']=get_option('admin_email');
|
149 |
+
|
150 |
+
if (!isset($jobsettings['mailerroronly']) or !is_bool($jobsettings['mailerroronly']))
|
151 |
+
$jobsettings['mailerroronly']=true;
|
152 |
+
|
153 |
+
if (!isset($jobsettings['dbexclude']) or !is_array($jobsettings['dbexclude'])) {
|
154 |
+
$jobsettings['dbexclude']=array();
|
155 |
+
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
156 |
+
foreach ($tables as $table) {
|
157 |
+
if (substr($table,0,strlen($wpdb->prefix))!=$wpdb->prefix)
|
158 |
+
$jobsettings['dbexclude'][]=$table;
|
159 |
+
}
|
160 |
+
}
|
161 |
+
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
162 |
+
foreach($jobsettings['dbexclude'] as $key => $value) {
|
163 |
+
if (empty($jobsettings['dbexclude'][$key]) or !in_array($value,$tables))
|
164 |
+
unset($jobsettings['dbexclude'][$key]);
|
165 |
+
}
|
166 |
+
sort($jobsettings['dbexclude']);
|
167 |
+
|
168 |
+
if (!isset($jobsettings['dbshortinsert']) or !is_bool($jobsettings['dbshortinsert']))
|
169 |
+
$jobsettings['dbshortinsert']=false;
|
170 |
+
|
171 |
+
if (!isset($jobsettings['maintenance']) or !is_bool($jobsettings['maintenance']))
|
172 |
+
$jobsettings['maintenance']=false;
|
173 |
+
|
174 |
+
if (!isset($jobsettings['fileexclude']) or !is_string($jobsettings['fileexclude']))
|
175 |
+
$jobsettings['fileexclude']='';
|
176 |
+
$fileexclude=explode(',',$jobsettings['fileexclude']);
|
177 |
+
foreach($fileexclude as $key => $value) {
|
178 |
+
$fileexclude[$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
179 |
+
if (empty($fileexclude[$key]))
|
180 |
+
unset($fileexclude[$key]);
|
181 |
+
}
|
182 |
+
sort($fileexclude);
|
183 |
+
$jobsettings['fileexclude']=implode(',',$fileexclude);
|
184 |
+
|
185 |
+
if (!isset($jobsettings['dirinclude']) or !is_string($jobsettings['dirinclude']))
|
186 |
+
$jobsettings['dirinclude']='';
|
187 |
+
$dirinclude=explode(',',$jobsettings['dirinclude']);
|
188 |
+
foreach($dirinclude as $key => $value) {
|
189 |
+
$dirinclude[$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
190 |
+
if (empty($dirinclude[$key]) or !is_dir($dirinclude[$key]))
|
191 |
+
unset($dirinclude[$key]);
|
192 |
+
}
|
193 |
+
sort($dirinclude);
|
194 |
+
$jobsettings['dirinclude']=implode(',',$dirinclude);
|
195 |
+
|
196 |
+
if (!isset($jobsettings['backuproot']) or !is_bool($jobsettings['backuproot']))
|
197 |
+
$jobsettings['backuproot']=true;
|
198 |
+
|
199 |
+
if (!isset($jobsettings['backupcontent']) or !is_bool($jobsettings['backupcontent']))
|
200 |
+
$jobsettings['backupcontent']=true;
|
201 |
+
|
202 |
+
if (!isset($jobsettings['backupplugins']) or !is_bool($jobsettings['backupplugins']))
|
203 |
+
$jobsettings['backupplugins']=true;
|
204 |
+
|
205 |
+
if (!isset($jobsettings['backupthemes']) or !is_bool($jobsettings['backupthemes']))
|
206 |
+
$jobsettings['backupthemes']=true;
|
207 |
+
|
208 |
+
if (!isset($jobsettings['backupuploads']) or !is_bool($jobsettings['backupuploads']))
|
209 |
+
$jobsettings['backupuploads']=true;
|
210 |
+
|
211 |
+
if (!isset($jobsettings['backuprootexcludedirs']) or !is_array($jobsettings['backuprootexcludedirs']))
|
212 |
+
$jobsettings['backuprootexcludedirs']=array();
|
213 |
+
foreach($jobsettings['backuprootexcludedirs'] as $key => $value) {
|
214 |
+
$jobsettings['backuprootexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
215 |
+
if (empty($jobsettings['backuprootexcludedirs'][$key]) or $jobsettings['backuprootexcludedirs'][$key]=='/' or !is_dir($jobsettings['backuprootexcludedirs'][$key]))
|
216 |
+
unset($jobsettings['backuprootexcludedirs'][$key]);
|
217 |
+
}
|
218 |
+
sort($jobsettings['backuprootexcludedirs']);
|
219 |
+
|
220 |
+
if (!isset($jobsettings['backupcontentexcludedirs']) or !is_array($jobsettings['backupcontentexcludedirs']))
|
221 |
+
$jobsettings['backupcontentexcludedirs']=array();
|
222 |
+
foreach($jobsettings['backupcontentexcludedirs'] as $key => $value) {
|
223 |
+
$jobsettings['backupcontentexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
224 |
+
if (empty($jobsettings['backupcontentexcludedirs'][$key]) or $jobsettings['backupcontentexcludedirs'][$key]=='/' or !is_dir($jobsettings['backupcontentexcludedirs'][$key]))
|
225 |
+
unset($jobsettings['backupcontentexcludedirs'][$key]);
|
226 |
+
}
|
227 |
+
sort($jobsettings['backupcontentexcludedirs']);
|
228 |
+
|
229 |
+
if (!isset($jobsettings['backuppluginsexcludedirs']) or !is_array($jobsettings['backuppluginsexcludedirs']))
|
230 |
+
$jobsettings['backuppluginsexcludedirs']=array();
|
231 |
+
foreach($jobsettings['backuppluginsexcludedirs'] as $key => $value) {
|
232 |
+
$jobsettings['backuppluginsexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
233 |
+
if (empty($jobsettings['backuppluginsexcludedirs'][$key]) or $jobsettings['backuppluginsexcludedirs'][$key]=='/' or !is_dir($jobsettings['backuppluginsexcludedirs'][$key]))
|
234 |
+
unset($jobsettings['backuppluginsexcludedirs'][$key]);
|
235 |
+
}
|
236 |
+
sort($jobsettings['backuppluginsexcludedirs']);
|
237 |
+
|
238 |
+
if (!isset($jobsettings['backupthemesexcludedirs']) or !is_array($jobsettings['backupthemesexcludedirs']))
|
239 |
+
$jobsettings['backupthemesexcludedirs']=array();
|
240 |
+
foreach($jobsettings['backupthemesexcludedirs'] as $key => $value) {
|
241 |
+
$jobsettings['backupthemesexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
242 |
+
if (empty($jobsettings['backupthemesexcludedirs'][$key]) or $jobsettings['backupthemesexcludedirs'][$key]=='/' or !is_dir($jobsettings['backupthemesexcludedirs'][$key]))
|
243 |
+
unset($jobsettings['backupthemesexcludedirs'][$key]);
|
244 |
+
}
|
245 |
+
sort($jobsettings['backupthemesexcludedirs']);
|
246 |
+
|
247 |
+
if (!isset($jobsettings['backupuploadsexcludedirs']) or !is_array($jobsettings['backupuploadsexcludedirs']))
|
248 |
+
$jobsettings['backupuploadsexcludedirs']=array();
|
249 |
+
foreach($jobsettings['backupuploadsexcludedirs'] as $key => $value) {
|
250 |
+
$jobsettings['backupuploadsexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
251 |
+
if (empty($jobsettings['backupuploadsexcludedirs'][$key]) or $jobsettings['backupuploadsexcludedirs'][$key]=='/' or !is_dir($jobsettings['backupuploadsexcludedirs'][$key]))
|
252 |
+
unset($jobsettings['backupuploadsexcludedirs'][$key]);
|
253 |
+
}
|
254 |
+
sort($jobsettings['backupuploadsexcludedirs']);
|
255 |
+
|
256 |
+
$fileformarts=array('.zip','.tar.gz','tar.bz2','.tar');
|
257 |
+
if (!isset($jobsettings['fileformart']) or !in_array($jobsettings['fileformart'],$fileformarts))
|
258 |
+
$jobsettings['fileformart']='.zip';
|
259 |
+
|
260 |
+
if (!isset($jobsettings['mailefilesize']) or !is_float($jobsettings['mailefilesize']))
|
261 |
+
$jobsettings['mailefilesize']=0;
|
262 |
+
|
263 |
+
if (!isset($jobsettings['backupdir']) or (!is_dir($jobsettings['backupdir']) and !empty($jobsettings['backupdir']))) {
|
264 |
+
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
265 |
+
$jobsettings['backupdir']=str_replace('\\','/',trailingslashit(WP_CONTENT_DIR)).'backwpup-'.$rand.'/';
|
266 |
+
}
|
267 |
+
$jobsettings['backupdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['backupdir']))));
|
268 |
+
if ($jobsettings['backupdir']=='/')
|
269 |
+
$jobsettings['backupdir']='';
|
270 |
+
|
271 |
+
if (!isset($jobsettings['maxbackups']) or !is_int($jobsettings['maxbackups']))
|
272 |
+
$jobsettings['maxbackups']=0;
|
273 |
+
|
274 |
+
if (!isset($jobsettings['ftphost']) or !is_string($jobsettings['ftphost']))
|
275 |
+
$jobsettings['ftphost']='';
|
276 |
+
|
277 |
+
if (!isset($jobsettings['ftpuser']) or !is_string($jobsettings['ftpuser']))
|
278 |
+
$jobsettings['ftpuser']='';
|
279 |
+
|
280 |
+
if (!isset($jobsettings['ftppass']) or !is_string($jobsettings['ftppass']))
|
281 |
+
$jobsettings['ftppass']='';
|
282 |
+
|
283 |
+
if (!isset($jobsettings['ftpdir']) or !is_string($jobsettings['ftpdir']) or $jobsettings['ftpdir']=='/')
|
284 |
+
$jobsettings['ftpdir']='';
|
285 |
+
$jobsettings['ftpdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['ftpdir']))));
|
286 |
+
if (substr($jobsettings['ftpdir'],0,1)=='/')
|
287 |
+
$jobsettings['ftpdir']=substr($jobsettings['ftpdir'],1);
|
288 |
+
|
289 |
+
if (!isset($jobsettings['ftpmaxbackups']) or !is_int($jobsettings['ftpmaxbackups']))
|
290 |
+
$jobsettings['ftpmaxbackups']=0;
|
291 |
+
|
292 |
+
if (!isset($jobsettings['awsAccessKey']) or !is_string($jobsettings['awsAccessKey']))
|
293 |
+
$jobsettings['awsAccessKey']='';
|
294 |
+
|
295 |
+
if (!isset($jobsettings['awsSecretKey']) or !is_string($jobsettings['awsSecretKey']))
|
296 |
+
$jobsettings['awsSecretKey']='';
|
297 |
+
|
298 |
+
if (!isset($jobsettings['awsSSL']) or !is_bool($jobsettings['awsSSL']))
|
299 |
+
$jobsettings['awsSSL']=true;
|
300 |
+
|
301 |
+
if (!isset($jobsettings['awsBucket']) or !is_string($jobsettings['awsBucket']))
|
302 |
+
$jobsettings['awsBucket']='';
|
303 |
+
|
304 |
+
if (!isset($jobsettings['awsdir']) or !is_string($jobsettings['awsdir']) or $jobsettings['awsdir']=='/')
|
305 |
+
$jobsettings['awsdir']='';
|
306 |
+
$jobsettings['awsdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['awsdir']))));
|
307 |
+
if (substr($jobsettings['awsdir'],0,1)=='/')
|
308 |
+
$jobsettings['awsdir']=substr($jobsettings['awsdir'],1);
|
309 |
+
|
310 |
+
if (!isset($jobsettings['awsmaxbackups']) or !is_int($jobsettings['awsmaxbackups']))
|
311 |
+
$jobsettings['awsmaxbackups']=0;
|
312 |
+
|
313 |
+
if (!is_string($jobsettings['mailaddress']) or false === $pos=strpos($jobsettings['mailaddress'],'@') or false === strpos($jobsettings['mailaddress'],'.',$pos))
|
314 |
+
$jobsettings['mailaddress']='';
|
315 |
+
|
316 |
+
return $jobsettings;
|
317 |
+
}
|
318 |
+
|
319 |
|
320 |
//On Plugin activate
|
321 |
function backwpup_plugin_activate() {
|
|
|
|
|
|
|
|
|
322 |
//add cron jobs
|
323 |
$jobs=get_option('backwpup_jobs');
|
324 |
if (is_array($jobs)) {
|
334 |
if (empty($cfg['mailsndname'])) $cfg['mailsndname']='BackWPup '.get_bloginfo( 'name' );
|
335 |
if (empty($cfg['mailmethod'])) $cfg['mailmethod']='mail';
|
336 |
if (empty($cfg['mailsendmail'])) $cfg['mailsendmail']=substr(ini_get('sendmail_path'),0,strpos(ini_get('sendmail_path'),' -'));
|
|
|
337 |
if (empty($cfg['maxlogs'])) $cfg['maxlogs']=0;
|
338 |
if (empty($cfg['dirtemp'])) {
|
339 |
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
340 |
+
$cfg['dirtemp']=backwpup_get_upload_dir();
|
341 |
}
|
342 |
if (empty($cfg['dirlogs'])) {
|
343 |
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
400 |
if (empty($jobid))
|
401 |
return false;
|
402 |
require_once('backwpup_dojob.php');
|
403 |
+
$backwpup_dojob= new backwpup_dojob($jobid);
|
404 |
+
unset($backwpup_dojob);
|
405 |
return $backwpup_logfile;
|
406 |
}
|
407 |
|
549 |
echo "<meta http-equiv=\"cache-control\" content=\"no-cache\" />\n";
|
550 |
}
|
551 |
|
|
|
552 |
function backwpup_send_no_cache_header() {
|
553 |
header("Expires: 0");
|
554 |
header("Cache-Control: no-cache, must-revalidate");
|
556 |
header("Cache-Control: post-check=0, pre-check=0");
|
557 |
}
|
558 |
|
559 |
+
function backwpup_get_upload_dir() {
|
560 |
+
global $switched;
|
561 |
+
$upload_path = get_option( 'upload_path' );
|
562 |
+
$upload_path = trim($upload_path);
|
563 |
+
$main_override = defined( 'MULTISITE' ) && is_main_site();
|
564 |
+
if ( empty($upload_path) ) {
|
565 |
+
$dir = WP_CONTENT_DIR . '/uploads';
|
566 |
+
} else {
|
567 |
+
$dir = $upload_path;
|
568 |
+
if ( 'wp-content/uploads' == $upload_path ) {
|
569 |
+
$dir = WP_CONTENT_DIR . '/uploads';
|
570 |
+
} elseif ( 0 !== strpos($dir, ABSPATH) ) {
|
571 |
+
// $dir is absolute, $upload_path is (maybe) relative to ABSPATH
|
572 |
+
$dir = path_join( ABSPATH, $dir );
|
573 |
+
}
|
574 |
+
}
|
575 |
+
if ( defined('UPLOADS') && !$main_override && ( !isset( $switched ) || $switched === false ) ) {
|
576 |
+
$dir = ABSPATH . UPLOADS;
|
577 |
+
}
|
578 |
+
if ( is_multisite() && !$main_override && ( !isset( $switched ) || $switched === false ) ) {
|
579 |
+
if ( defined( 'BLOGUPLOADDIR' ) )
|
580 |
+
$dir = untrailingslashit(BLOGUPLOADDIR);
|
581 |
+
}
|
582 |
+
return str_replace('\\','/',trailingslashit($dir));
|
583 |
+
}
|
584 |
+
|
585 |
+
function backwpup_get_exclude_wp_dirs($folder) {
|
586 |
+
$folder=trailingslashit(str_replace('\\','/',$folder));
|
587 |
+
$excludedir=array();
|
588 |
+
if (false !== stripos(trailingslashit(str_replace('\\','/',ABSPATH)),$folder) and trailingslashit(str_replace('\\','/',ABSPATH))!=$folder)
|
589 |
+
$excludedir[]=trailingslashit(str_replace('\\','/',ABSPATH));
|
590 |
+
if (false !== stripos(trailingslashit(str_replace('\\','/',WP_CONTENT_DIR)),$folder) and trailingslashit(str_replace('\\','/',WP_CONTENT_DIR))!=$folder)
|
591 |
+
$excludedir[]=trailingslashit(str_replace('\\','/',WP_CONTENT_DIR));
|
592 |
+
if (false !== stripos(trailingslashit(str_replace('\\','/',WP_PLUGIN_DIR)),$folder) and trailingslashit(str_replace('\\','/',WP_PLUGIN_DIR))!=$folder)
|
593 |
+
$excludedir[]=trailingslashit(str_replace('\\','/',WP_PLUGIN_DIR));
|
594 |
+
if (false !== stripos(str_replace('\\','/',trailingslashit(WP_CONTENT_DIR).'themes/'),$folder) and str_replace('\\','/',trailingslashit(WP_CONTENT_DIR).'themes/')!=$folder)
|
595 |
+
$excludedir[]=str_replace('\\','/',trailingslashit(WP_CONTENT_DIR).'themes/');
|
596 |
+
if (false !== stripos(backwpup_get_upload_dir(),$folder) and backwpup_get_upload_dir()!=$folder)
|
597 |
+
$excludedir[]=backwpup_get_upload_dir();
|
598 |
+
//Exclude Backup dirs
|
599 |
+
$jobs=get_option('backwpup_jobs');
|
600 |
+
foreach($jobs as $jobsvale) {
|
601 |
+
if (!empty($jobsvale['backupdir']) and $jobsvale['backupdir']!='/')
|
602 |
+
$excludedir[]=trailingslashit(str_replace('\\','/',$jobsvale['backupdir']));
|
603 |
+
}
|
604 |
+
return $excludedir;
|
605 |
+
}
|
606 |
+
|
607 |
+
//ajax/normal get buckests select box
|
608 |
+
function backwpup_get_aws_buckets($args='') {
|
609 |
+
if (is_array($args)) {
|
610 |
+
extract($args);
|
611 |
+
$ajax=false;
|
612 |
+
} else {
|
613 |
+
$awsAccessKey=$_POST['awsAccessKey'];
|
614 |
+
$awsSecretKey=$_POST['awsSecretKey'];
|
615 |
+
$selected=$_POST['selected'];
|
616 |
+
$ajax=true;
|
617 |
+
}
|
618 |
+
require_once(plugin_dir_path(__FILE__).'libs/s3.php');
|
619 |
+
if (empty($awsAccessKey)) {
|
620 |
echo '<span id="awsBucket" style="color:red;">'.__('Missing Access Key ID!','backwpup').'</span>';
|
621 |
die();
|
622 |
}
|
623 |
+
if (empty($awsSecretKey)) {
|
624 |
echo '<span id="awsBucket" style="color:red;">'.__('Missing Secret Access Key!','backwpup').'</span>';
|
625 |
die();
|
626 |
}
|
627 |
+
$s3 = new S3($awsAccessKey, $awsSecretKey, false);
|
628 |
$buckets=@$s3->listBuckets();
|
629 |
if (!is_array($buckets)) {
|
630 |
echo '<span id="awsBucket" style="color:red;">'.__('No Buckets found! Or wrong Keys!','backwpup').'</span>';
|
632 |
}
|
633 |
echo '<select name="awsBucket" id="awsBucket">';
|
634 |
foreach ($buckets as $bucket) {
|
635 |
+
echo "<option ".selected(strtolower($selected),strtolower($bucket),false).">".$bucket."</option>";
|
636 |
}
|
637 |
echo '</select>';
|
638 |
+
if ($ajax)
|
639 |
+
die();
|
640 |
}
|
641 |
|
642 |
// add all action and so on only if plugin loaded.
|
app/js/options.js
CHANGED
@@ -61,7 +61,6 @@ jQuery(document).ready( function($) {
|
|
61 |
});
|
62 |
}
|
63 |
|
64 |
-
awsgetbucket();
|
65 |
$('#awsAccessKey').change(function() {awsgetbucket();});
|
66 |
$('#awsSecretKey').change(function() {awsgetbucket();});
|
67 |
|
61 |
});
|
62 |
}
|
63 |
|
|
|
64 |
$('#awsAccessKey').change(function() {awsgetbucket();});
|
65 |
$('#awsSecretKey').change(function() {awsgetbucket();});
|
66 |
|
app/options-jobs.php
CHANGED
@@ -12,9 +12,7 @@ if ( !defined('ABSPATH') )
|
|
12 |
<input type="hidden" name="jobid" value="<?PHP echo $jobid;?>" />
|
13 |
<?php
|
14 |
wp_nonce_field('edit-job');
|
15 |
-
|
16 |
-
$jobs[$jobid]['type']='DB+FILE';
|
17 |
-
|
18 |
$todo=explode('+',$jobs[$jobid]['type']);
|
19 |
?>
|
20 |
|
@@ -51,21 +49,17 @@ $todo=explode('+',$jobs[$jobid]['type']);
|
|
51 |
<?php
|
52 |
_e('Run Every:', 'backwpup');
|
53 |
echo '<select name="scheduleintervalteimes">';
|
54 |
-
for ($i=1;$i<=
|
55 |
echo '<option value="'.$i.'"'.selected($i,$jobs[$jobid]['scheduleintervalteimes'],false).'>'.$i.'</option>';
|
56 |
}
|
57 |
echo '</select>';
|
58 |
-
if (empty($jobs[$jobid]['scheduleintervaltype']))
|
59 |
-
$jobs[$jobid]['scheduleintervaltype']=3600;
|
60 |
echo '<select name="scheduleintervaltype">';
|
61 |
-
echo '<option value="60"'.selected('
|
62 |
echo '<option value="3600"'.selected('3600',$jobs[$jobid]['scheduleintervaltype'],false).'>'.__('Hour(s)','backwpup').'</option>';
|
63 |
echo '<option value="86400"'.selected('86400',$jobs[$jobid]['scheduleintervaltype'],false).'>'.__('Day(s)','backwpup').'</option>';
|
64 |
echo '</select><br />';
|
65 |
|
66 |
_e('Start Date/Time:', 'backwpup');echo "<br />";
|
67 |
-
if (empty($jobs[$jobid]['scheduletime']))
|
68 |
-
$jobs[$jobid]['scheduletime']=current_time('timestamp');
|
69 |
|
70 |
echo '<select name="scheduleday">';
|
71 |
for ($i=1;$i<=31;$i++) {
|
@@ -106,8 +100,6 @@ $todo=explode('+',$jobs[$jobid]['type']);
|
|
106 |
<h3 class="hndle"><span><?PHP _e('Backup File Format','backwpup'); ?></span></h3>
|
107 |
<div class="inside">
|
108 |
<?PHP
|
109 |
-
if (!isset($jobs[$jobid]['fileformart']))
|
110 |
-
$jobs[$jobid]['fileformart']='.zip';
|
111 |
if (function_exists('gzopen') or class_exists('ZipArchive'))
|
112 |
echo '<input class="radio" type="radio"'.checked('.zip',$jobs[$jobid]['fileformart'],false).' name="fileformart" value=".zip" />'.__('ZIP (.zip)','backwpup').'<br />';
|
113 |
else
|
@@ -128,12 +120,7 @@ $todo=explode('+',$jobs[$jobid]['type']);
|
|
128 |
<div id="logmail" class="postbox">
|
129 |
<h3 class="hndle"><span><?PHP _e('Send log','backwpup'); ?></span></h3>
|
130 |
<div class="inside">
|
131 |
-
<?PHP _e('E-Mail-Adress:','backwpup');
|
132 |
-
if (!isset($jobs[$jobid]['mailaddresslog']))
|
133 |
-
$jobs[$jobid]['mailaddresslog']=get_option('admin_email');
|
134 |
-
if (!isset($jobs[$jobid]['mailerroronly']))
|
135 |
-
$jobs[$jobid]['mailerroronly']=true;
|
136 |
-
?>
|
137 |
<input name="mailaddresslog" id="mailaddresslog" type="text" value="<?PHP echo $jobs[$jobid]['mailaddresslog'];?>" class="large-text" /><br />
|
138 |
<input class="checkbox" value="1" type="checkbox" <?php checked($jobs[$jobid]['mailerroronly'],true); ?> name="mailerroronly" /> <?PHP _e('Send only E-Mail on errors.','backwpup'); ?>
|
139 |
</div>
|
@@ -160,12 +147,6 @@ $todo=explode('+',$jobs[$jobid]['type']);
|
|
160 |
<div id="dbexclude-pop" style="border-color:#CEE1EF; border-style:solid; border-width:2px; height:10em; width:50%; margin:5px 0px 5px 40px; overflow:auto; padding:0.5em 0.5em;">
|
161 |
<?php
|
162 |
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
163 |
-
if (!isset($jobs[$jobid]['dbexclude'])) { //def.
|
164 |
-
foreach ($tables as $table) {
|
165 |
-
if (substr($table,0,strlen($wpdb->prefix))!=$wpdb->prefix)
|
166 |
-
$jobs[$jobid]['dbexclude'][]=$table;
|
167 |
-
}
|
168 |
-
}
|
169 |
foreach ($tables as $table) {
|
170 |
if ($wpdb->backwpup_logs<>$table) {
|
171 |
echo ' <input class="checkbox" type="checkbox"'.checked(in_array($table,(array)$jobs[$jobid]['dbexclude']),true,false).' name="dbexclude[]" value="'.$table.'"/> '.$table.'<br />';
|
@@ -181,20 +162,90 @@ $todo=explode('+',$jobs[$jobid]['type']);
|
|
181 |
<div id="filebackup" class="postbox" <?PHP if (!in_array("FILE",$todo)) echo 'style="display:none;"';?>>
|
182 |
<h3 class="hndle"><span><?PHP _e('File Backup','backwpup'); ?></span></h3>
|
183 |
<div class="inside">
|
184 |
-
<b><?PHP _e('Blog Folders to Backup:','backwpup'); ?></b
|
185 |
-
<div
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
$
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
<b><?PHP _e('Include Folders to Backup:','backwpup'); ?></b><br />
|
199 |
<?PHP _e('Example:','backwpup'); ?> <?PHP echo str_replace('\\','/',ABSPATH); ?>,...<br />
|
200 |
<input name="dirinclude" id="dirinclude" type="text" value="<?PHP echo $jobs[$jobid]['dirinclude'];?>" class="large-text" /><br />
|
@@ -208,14 +259,6 @@ $todo=explode('+',$jobs[$jobid]['type']);
|
|
208 |
<div id="todir" class="postbox" <?PHP if (!in_array("FILE",$todo) and !in_array("DB",$todo) and !in_array("WPEXP",$todo)) echo 'style="display:none;"';?>>
|
209 |
<h3 class="hndle"><span><?PHP _e('Backup to Directory','backwpup'); ?></span></h3>
|
210 |
<div class="inside">
|
211 |
-
<?PHP
|
212 |
-
if (empty($jobs[$jobid]['backupdir'])) {
|
213 |
-
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
214 |
-
$jobs[$jobid]['backupdir']=str_replace('\\','/',trailingslashit(WP_CONTENT_DIR)).'/backwpup-'.$rand;
|
215 |
-
}
|
216 |
-
if (!is_numeric($jobs[$jobid]['maxbackups']))
|
217 |
-
$jobs[$jobid]['maxbackups']=0;
|
218 |
-
?>
|
219 |
<b><?PHP _e('Full Path to Folder for Backup Files:','backwpup'); ?></b><br />
|
220 |
<input name="backupdir" id="backupdir" type="text" value="<?PHP echo $jobs[$jobid]['backupdir'];?>" class="large-text" /><br />
|
221 |
<?PHP _e('Max. Backup Files in Folder:','backwpup'); ?> <input name="maxbackups" id="maxbackups" type="text" size="3" value="<?PHP echo $jobs[$jobid]['maxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will deleted first.)','backwpup');?></span>
|
@@ -250,7 +293,7 @@ $todo=explode('+',$jobs[$jobid]['type']);
|
|
250 |
<input id="awsSecretKey" name="awsSecretKey" type="text" value="<?PHP echo $jobs[$jobid]['awsSecretKey'];?>" class="large-text" /><br />
|
251 |
<b><?PHP _e('Bucket:','backwpup'); ?></b><br />
|
252 |
<input id="awsBucketselected" name="awsBucketselected" type="hidden" value="<?PHP echo $jobs[$jobid]['awsBucket'];?>" />
|
253 |
-
|
254 |
<?PHP _e('Create Bucket:','backwpup'); ?><input name="newawsBucket" type="text" value="" class="text" /> <select name="awsRegion" title="<?php _e('Bucket Region', 'backwpup'); ?>"><option value=""><?php _e('US', 'backwpup'); ?></option><option value="EU"><?php _e('EU', 'backwpup'); ?></option></select><br />
|
255 |
<b><?PHP _e('Directory in Bucket:','backwpup'); ?></b><br />
|
256 |
<input name="awsdir" type="text" value="<?PHP echo $jobs[$jobid]['awsdir'];?>" class="large-text" /><br />
|
12 |
<input type="hidden" name="jobid" value="<?PHP echo $jobid;?>" />
|
13 |
<?php
|
14 |
wp_nonce_field('edit-job');
|
15 |
+
$jobs[$jobid]=backwpup_check_job_vars($jobs[$jobid]);
|
|
|
|
|
16 |
$todo=explode('+',$jobs[$jobid]['type']);
|
17 |
?>
|
18 |
|
49 |
<?php
|
50 |
_e('Run Every:', 'backwpup');
|
51 |
echo '<select name="scheduleintervalteimes">';
|
52 |
+
for ($i=1;$i<=100;$i++) {
|
53 |
echo '<option value="'.$i.'"'.selected($i,$jobs[$jobid]['scheduleintervalteimes'],false).'>'.$i.'</option>';
|
54 |
}
|
55 |
echo '</select>';
|
|
|
|
|
56 |
echo '<select name="scheduleintervaltype">';
|
57 |
+
echo '<option value="60"'.selected('60',$jobs[$jobid]['scheduleintervaltype'],false).'>'.__('Min(s)','backwpup').'</option>';
|
58 |
echo '<option value="3600"'.selected('3600',$jobs[$jobid]['scheduleintervaltype'],false).'>'.__('Hour(s)','backwpup').'</option>';
|
59 |
echo '<option value="86400"'.selected('86400',$jobs[$jobid]['scheduleintervaltype'],false).'>'.__('Day(s)','backwpup').'</option>';
|
60 |
echo '</select><br />';
|
61 |
|
62 |
_e('Start Date/Time:', 'backwpup');echo "<br />";
|
|
|
|
|
63 |
|
64 |
echo '<select name="scheduleday">';
|
65 |
for ($i=1;$i<=31;$i++) {
|
100 |
<h3 class="hndle"><span><?PHP _e('Backup File Format','backwpup'); ?></span></h3>
|
101 |
<div class="inside">
|
102 |
<?PHP
|
|
|
|
|
103 |
if (function_exists('gzopen') or class_exists('ZipArchive'))
|
104 |
echo '<input class="radio" type="radio"'.checked('.zip',$jobs[$jobid]['fileformart'],false).' name="fileformart" value=".zip" />'.__('ZIP (.zip)','backwpup').'<br />';
|
105 |
else
|
120 |
<div id="logmail" class="postbox">
|
121 |
<h3 class="hndle"><span><?PHP _e('Send log','backwpup'); ?></span></h3>
|
122 |
<div class="inside">
|
123 |
+
<?PHP _e('E-Mail-Adress:','backwpup'); ?>
|
|
|
|
|
|
|
|
|
|
|
124 |
<input name="mailaddresslog" id="mailaddresslog" type="text" value="<?PHP echo $jobs[$jobid]['mailaddresslog'];?>" class="large-text" /><br />
|
125 |
<input class="checkbox" value="1" type="checkbox" <?php checked($jobs[$jobid]['mailerroronly'],true); ?> name="mailerroronly" /> <?PHP _e('Send only E-Mail on errors.','backwpup'); ?>
|
126 |
</div>
|
147 |
<div id="dbexclude-pop" style="border-color:#CEE1EF; border-style:solid; border-width:2px; height:10em; width:50%; margin:5px 0px 5px 40px; overflow:auto; padding:0.5em 0.5em;">
|
148 |
<?php
|
149 |
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
foreach ($tables as $table) {
|
151 |
if ($wpdb->backwpup_logs<>$table) {
|
152 |
echo ' <input class="checkbox" type="checkbox"'.checked(in_array($table,(array)$jobs[$jobid]['dbexclude']),true,false).' name="dbexclude[]" value="'.$table.'"/> '.$table.'<br />';
|
162 |
<div id="filebackup" class="postbox" <?PHP if (!in_array("FILE",$todo)) echo 'style="display:none;"';?>>
|
163 |
<h3 class="hndle"><span><?PHP _e('File Backup','backwpup'); ?></span></h3>
|
164 |
<div class="inside">
|
165 |
+
<b><?PHP _e('Blog Folders to Backup:','backwpup'); ?></b><br /> <br />
|
166 |
+
<div>
|
167 |
+
<div style="width:20%; float: left;">
|
168 |
+
<b><input class="checkbox" type="checkbox"<?php checked($jobs[$jobid]['backuproot'],true,true);?> name="backuproot" value="1"/> <?php _e('root','backwpup');?></b><br />
|
169 |
+
<div style="border-color:#CEE1EF; border-style:solid; border-width:2px; height:10em; width:90%; margin:2px; overflow:auto;">
|
170 |
+
<?PHP
|
171 |
+
echo '<i>'.__('Exclude:','backwpup').'</i><br />';
|
172 |
+
$folder=untrailingslashit(str_replace('\\','/',ABSPATH));
|
173 |
+
if ( $dir = @opendir( $folder ) ) {
|
174 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
175 |
+
if ( !in_array($file, array('.', '..','.svn')) and is_dir($folder.'/'.$file) and !in_array($folder.'/'.$file.'/',backwpup_get_exclude_wp_dirs($folder)))
|
176 |
+
echo '<nobr><input class="checkbox" type="checkbox"'.checked(in_array($folder.'/'.$file.'/',$jobs[$jobid]['backuprootexcludedirs']),true,false).' name="backuprootexcludedirs[]" value="'.$folder.'/'.$file.'/"/> '.$file.'</nobr><br />';
|
177 |
+
}
|
178 |
+
@closedir( $dir );
|
179 |
+
}
|
180 |
+
?>
|
181 |
+
</div>
|
182 |
+
</div>
|
183 |
+
<div style="width:20%;float: left;">
|
184 |
+
<b><input class="checkbox" type="checkbox"<?php checked($jobs[$jobid]['backupcontent'],true,true);?> name="backupcontent" value="1"/> <?php _e('Content','backwpup');?></b><br />
|
185 |
+
<div style="border-color:#CEE1EF; border-style:solid; border-width:2px; height:10em; width:90%; margin:2px; overflow:auto;">
|
186 |
+
<?PHP
|
187 |
+
echo '<i>'.__('Exclude:','backwpup').'</i><br />';
|
188 |
+
$folder=untrailingslashit(str_replace('\\','/',WP_CONTENT_DIR));
|
189 |
+
if ( $dir = @opendir( $folder ) ) {
|
190 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
191 |
+
if ( !in_array($file, array('.', '..','.svn')) and is_dir($folder.'/'.$file) and !in_array($folder.'/'.$file.'/',backwpup_get_exclude_wp_dirs($folder)))
|
192 |
+
echo '<nobr><input class="checkbox" type="checkbox"'.checked(in_array($folder.'/'.$file.'/',$jobs[$jobid]['backupcontentexcludedirs']),true,false).' name="backupcontentexcludedirs[]" value="'.$folder.'/'.$file.'/"/> '.$file.'</nobr><br />';
|
193 |
+
}
|
194 |
+
@closedir( $dir );
|
195 |
+
}
|
196 |
+
?>
|
197 |
+
</div>
|
198 |
+
</div>
|
199 |
+
<div style="width:20%; float: left;">
|
200 |
+
<b><input class="checkbox" type="checkbox"<?php checked($jobs[$jobid]['backupplugins'],true,true);?> name="backupplugins" value="1"/> <?php _e('Plugins','backwpup');?></b><br />
|
201 |
+
<div style="border-color:#CEE1EF; border-style:solid; border-width:2px; height:10em; width:90%; margin:2px; overflow:auto;">
|
202 |
+
<?PHP
|
203 |
+
echo '<i>'.__('Exclude:','backwpup').'</i><br />';
|
204 |
+
$folder=untrailingslashit(str_replace('\\','/',WP_PLUGIN_DIR));
|
205 |
+
if ( $dir = @opendir( $folder ) ) {
|
206 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
207 |
+
if ( !in_array($file, array('.', '..','.svn')) and is_dir($folder.'/'.$file) and !in_array($folder.'/'.$file.'/',backwpup_get_exclude_wp_dirs($folder)))
|
208 |
+
echo '<nobr><input class="checkbox" type="checkbox"'.checked(in_array($folder.'/'.$file.'/',$jobs[$jobid]['backuppluginsexcludedirs']),true,false).' name="backuppluginsexcludedirs[]" value="'.$folder.'/'.$file.'/"/> '.$file.'</nobr><br />';
|
209 |
+
}
|
210 |
+
@closedir( $dir );
|
211 |
+
}
|
212 |
+
?>
|
213 |
+
</div>
|
214 |
+
</div>
|
215 |
+
<div style="width:20%; float: left;">
|
216 |
+
<b><input class="checkbox" type="checkbox"<?php checked($jobs[$jobid]['backupthemes'],true,true);?> name="backupthemes" value="1"/> <?php _e('Themes','backwpup');?></b><br />
|
217 |
+
<div style="border-color:#CEE1EF; border-style:solid; border-width:2px; height:10em; width:90%; margin:2px; overflow:auto;">
|
218 |
+
<?PHP
|
219 |
+
echo '<i>'.__('Exclude:','backwpup').'</i><br />';
|
220 |
+
$folder=untrailingslashit(str_replace('\\','/',trailingslashit(WP_CONTENT_DIR).'themes'));
|
221 |
+
if ( $dir = @opendir( $folder ) ) {
|
222 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
223 |
+
if ( !in_array($file, array('.', '..','.svn')) and is_dir($folder.'/'.$file) and !in_array($folder.'/'.$file.'/',backwpup_get_exclude_wp_dirs($folder)))
|
224 |
+
echo '<nobr><input class="checkbox" type="checkbox"'.checked(in_array($folder.'/'.$file.'/',$jobs[$jobid]['backupthemesexcludedirs']),true,false).' name="backupthemesexcludedirs[]" value="'.$folder.'/'.$file.'/"/> '.$file.'</nobr><br />';
|
225 |
+
}
|
226 |
+
@closedir( $dir );
|
227 |
+
}
|
228 |
+
?>
|
229 |
+
</div>
|
230 |
+
</div>
|
231 |
+
<div style="width:20%; float: left;">
|
232 |
+
<b><input class="checkbox" type="checkbox"<?php checked($jobs[$jobid]['backupuploads'],true,true);?> name="backupuploads" value="1"/> <?php _e('Blog Uploads','backwpup');?></b><br />
|
233 |
+
<div style="border-color:#CEE1EF; border-style:solid; border-width:2px; height:10em; width:90%; margin:2px; overflow:auto;">
|
234 |
+
<?PHP
|
235 |
+
echo '<i>'.__('Exclude:','backwpup').'</i><br />';
|
236 |
+
$folder=untrailingslashit(backwpup_get_upload_dir());
|
237 |
+
if ( $dir = @opendir( $folder ) ) {
|
238 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
239 |
+
if ( !in_array($file, array('.', '..','.svn')) and is_dir($folder.'/'.$file) and !in_array($folder.'/'.$file,backwpup_get_exclude_wp_dirs($folder)))
|
240 |
+
echo '<nobr><input class="checkbox" type="checkbox"'.checked(in_array($folder.'/'.$file.'/',$jobs[$jobid]['backupuploadsexcludedirs']),true,false).' name="backupuploadsexcludedirs[]" value="'.$folder.'/'.$file.'/"/> '.$file.'</nobr><br />';
|
241 |
+
}
|
242 |
+
@closedir( $dir );
|
243 |
+
}
|
244 |
+
?>
|
245 |
+
</div>
|
246 |
+
</div>
|
247 |
+
</div>
|
248 |
+
<br /> <br />
|
249 |
<b><?PHP _e('Include Folders to Backup:','backwpup'); ?></b><br />
|
250 |
<?PHP _e('Example:','backwpup'); ?> <?PHP echo str_replace('\\','/',ABSPATH); ?>,...<br />
|
251 |
<input name="dirinclude" id="dirinclude" type="text" value="<?PHP echo $jobs[$jobid]['dirinclude'];?>" class="large-text" /><br />
|
259 |
<div id="todir" class="postbox" <?PHP if (!in_array("FILE",$todo) and !in_array("DB",$todo) and !in_array("WPEXP",$todo)) echo 'style="display:none;"';?>>
|
260 |
<h3 class="hndle"><span><?PHP _e('Backup to Directory','backwpup'); ?></span></h3>
|
261 |
<div class="inside">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
<b><?PHP _e('Full Path to Folder for Backup Files:','backwpup'); ?></b><br />
|
263 |
<input name="backupdir" id="backupdir" type="text" value="<?PHP echo $jobs[$jobid]['backupdir'];?>" class="large-text" /><br />
|
264 |
<?PHP _e('Max. Backup Files in Folder:','backwpup'); ?> <input name="maxbackups" id="maxbackups" type="text" size="3" value="<?PHP echo $jobs[$jobid]['maxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will deleted first.)','backwpup');?></span>
|
293 |
<input id="awsSecretKey" name="awsSecretKey" type="text" value="<?PHP echo $jobs[$jobid]['awsSecretKey'];?>" class="large-text" /><br />
|
294 |
<b><?PHP _e('Bucket:','backwpup'); ?></b><br />
|
295 |
<input id="awsBucketselected" name="awsBucketselected" type="hidden" value="<?PHP echo $jobs[$jobid]['awsBucket'];?>" />
|
296 |
+
<?PHP if (!empty($jobs[$jobid]['awsAccessKey']) and !empty($jobs[$jobid]['awsSecretKey'])) backwpup_get_aws_buckets(array('awsAccessKey'=>$jobs[$jobid]['awsAccessKey'],'awsSecretKey'=>$jobs[$jobid]['awsSecretKey'],'selected'=>$jobs[$jobid]['awsBucket'])); ?>
|
297 |
<?PHP _e('Create Bucket:','backwpup'); ?><input name="newawsBucket" type="text" value="" class="text" /> <select name="awsRegion" title="<?php _e('Bucket Region', 'backwpup'); ?>"><option value=""><?php _e('US', 'backwpup'); ?></option><option value="EU"><?php _e('EU', 'backwpup'); ?></option></select><br />
|
298 |
<b><?PHP _e('Directory in Bucket:','backwpup'); ?></b><br />
|
299 |
<input name="awsdir" type="text" value="<?PHP echo $jobs[$jobid]['awsdir'];?>" class="large-text" /><br />
|
app/options-runnow-iframe.php
CHANGED
@@ -3,11 +3,9 @@ if (file_exists($_GET['wpabs'].'wp-load.php') and is_numeric(trim($_GET['jobid']
|
|
3 |
require_once($_GET['wpabs'].'wp-load.php'); /** Setup WordPress environment */
|
4 |
check_admin_referer('dojob-now_' . (int)$_GET['jobid']);
|
5 |
backwpup_send_no_cache_header();
|
6 |
-
ignore_user_abort(true);
|
7 |
// flush any buffers and send the headers
|
8 |
@flush();
|
9 |
@ob_flush();
|
10 |
-
|
11 |
?>
|
12 |
<html>
|
13 |
<head>
|
3 |
require_once($_GET['wpabs'].'wp-load.php'); /** Setup WordPress environment */
|
4 |
check_admin_referer('dojob-now_' . (int)$_GET['jobid']);
|
5 |
backwpup_send_no_cache_header();
|
|
|
6 |
// flush any buffers and send the headers
|
7 |
@flush();
|
8 |
@ob_flush();
|
|
|
9 |
?>
|
10 |
<html>
|
11 |
<head>
|
app/options-save.php
CHANGED
@@ -67,7 +67,7 @@ case 'savecfg': //Save config form Setings page
|
|
67 |
$cfg['dirtemp']=trailingslashit(str_replace('//','/',str_replace('\\','/',stripslashes(trim($_POST['dirtemp'])))));
|
68 |
//set def. folders
|
69 |
if (empty($cfg['dirtemp']) or $cfg['dirtemp']=='/')
|
70 |
-
$cfg['dirtemp']=str_replace('\\','/',trailingslashit(
|
71 |
if (empty($cfg['dirlogs']) or $cfg['dirlogs']=='/') {
|
72 |
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
73 |
$cfg['dirlogs']=str_replace('\\','/',trailingslashit(WP_CONTENT_DIR)).'backwpup-'.$rand.'-logs/';
|
@@ -138,37 +138,43 @@ case 'saveeditjob': //Save Job settings
|
|
138 |
$jobs[$jobid]['name']= esc_html($_POST['name']);
|
139 |
$jobs[$jobid]['activated']= $_POST['activated']==1 ? true : false;
|
140 |
$jobs[$jobid]['scheduletime']=mktime($_POST['schedulehour'],$_POST['scheduleminute'],0,$_POST['schedulemonth'],$_POST['scheduleday'],$_POST['scheduleyear']);
|
141 |
-
$jobs[$jobid]['scheduleintervaltype']
|
142 |
-
$jobs[$jobid]['scheduleintervalteimes']
|
143 |
-
$jobs[$jobid]['scheduleinterval']=$_POST['scheduleintervaltype']*$_POST['scheduleintervalteimes'];
|
144 |
$jobs[$jobid]['mailaddresslog']=sanitize_email($_POST['mailaddresslog']);
|
145 |
$jobs[$jobid]['mailerroronly']= $_POST['mailerroronly']==1 ? true : false;
|
146 |
-
$jobs[$jobid]['dbexclude']
|
147 |
$jobs[$jobid]['dbshortinsert']=$_POST['dbshortinsert']==1 ? true : false;
|
148 |
$jobs[$jobid]['maintenance']= $_POST['maintenance']==1 ? true : false;
|
149 |
-
$jobs[$jobid]['fileexclude']=
|
150 |
-
$jobs[$jobid]['dirinclude']=
|
151 |
$jobs[$jobid]['backuproot']= $_POST['backuproot']==1 ? true : false;
|
|
|
152 |
$jobs[$jobid]['backupcontent']= $_POST['backupcontent']==1 ? true : false;
|
|
|
153 |
$jobs[$jobid]['backupplugins']= $_POST['backupplugins']==1 ? true : false;
|
|
|
|
|
|
|
|
|
|
|
154 |
$jobs[$jobid]['fileformart']=$_POST['fileformart'];
|
155 |
$jobs[$jobid]['mailefilesize']=(float)$_POST['mailefilesize'];
|
156 |
-
$jobs[$jobid]['backupdir']=
|
157 |
-
$jobs[$jobid]['maxbackups']=
|
158 |
$jobs[$jobid]['ftphost']=$_POST['ftphost'];
|
159 |
$jobs[$jobid]['ftpuser']=$_POST['ftpuser'];
|
160 |
$jobs[$jobid]['ftppass']=base64_encode($_POST['ftppass']);
|
161 |
-
$jobs[$jobid]['ftpdir']=
|
162 |
-
$jobs[$jobid]['ftpmaxbackups']=
|
163 |
$jobs[$jobid]['awsAccessKey']=$_POST['awsAccessKey'];
|
164 |
$jobs[$jobid]['awsSecretKey']=$_POST['awsSecretKey'];
|
165 |
$jobs[$jobid]['awsSSL']= $_POST['awsSSL']==1 ? true : false;
|
166 |
$jobs[$jobid]['awsBucket']=$_POST['awsBucket'];
|
167 |
-
$jobs[$jobid]['awsdir']=
|
168 |
-
if (substr($jobs[$jobid]['awsdir'],0,1)=='/')
|
169 |
-
$jobs[$jobid]['awsdir']=substr($jobs[$jobid]['awsdir'],1);
|
170 |
$jobs[$jobid]['mailaddress']=sanitize_email($_POST['mailaddress']);
|
171 |
-
$jobs[$jobid]['awsmaxbackups']=
|
|
|
|
|
172 |
|
173 |
if (!empty($_POST['newawsBucket']) and !empty($_POST['awsAccessKey']) and !empty($_POST['awsSecretKey'])) { //create new s3 bucket if needed
|
174 |
if (!class_exists('S3'))
|
67 |
$cfg['dirtemp']=trailingslashit(str_replace('//','/',str_replace('\\','/',stripslashes(trim($_POST['dirtemp'])))));
|
68 |
//set def. folders
|
69 |
if (empty($cfg['dirtemp']) or $cfg['dirtemp']=='/')
|
70 |
+
$cfg['dirtemp']=str_replace('\\','/',trailingslashit(backwpup_get_upload_dir()));
|
71 |
if (empty($cfg['dirlogs']) or $cfg['dirlogs']=='/') {
|
72 |
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
73 |
$cfg['dirlogs']=str_replace('\\','/',trailingslashit(WP_CONTENT_DIR)).'backwpup-'.$rand.'-logs/';
|
138 |
$jobs[$jobid]['name']= esc_html($_POST['name']);
|
139 |
$jobs[$jobid]['activated']= $_POST['activated']==1 ? true : false;
|
140 |
$jobs[$jobid]['scheduletime']=mktime($_POST['schedulehour'],$_POST['scheduleminute'],0,$_POST['schedulemonth'],$_POST['scheduleday'],$_POST['scheduleyear']);
|
141 |
+
$jobs[$jobid]['scheduleintervaltype']=(int)$_POST['scheduleintervaltype'];
|
142 |
+
$jobs[$jobid]['scheduleintervalteimes']=(int)$_POST['scheduleintervalteimes'];
|
|
|
143 |
$jobs[$jobid]['mailaddresslog']=sanitize_email($_POST['mailaddresslog']);
|
144 |
$jobs[$jobid]['mailerroronly']= $_POST['mailerroronly']==1 ? true : false;
|
145 |
+
$jobs[$jobid]['dbexclude']=(array)$_POST['dbexclude'];
|
146 |
$jobs[$jobid]['dbshortinsert']=$_POST['dbshortinsert']==1 ? true : false;
|
147 |
$jobs[$jobid]['maintenance']= $_POST['maintenance']==1 ? true : false;
|
148 |
+
$jobs[$jobid]['fileexclude']=stripslashes($_POST['fileexclude']);
|
149 |
+
$jobs[$jobid]['dirinclude']=stripslashes($_POST['dirinclude']);
|
150 |
$jobs[$jobid]['backuproot']= $_POST['backuproot']==1 ? true : false;
|
151 |
+
$jobs[$jobid]['backuprootexcludedirs']=(array)$_POST['backuprootexcludedirs'];
|
152 |
$jobs[$jobid]['backupcontent']= $_POST['backupcontent']==1 ? true : false;
|
153 |
+
$jobs[$jobid]['backupcontentexcludedirs']=(array)$_POST['backupcontentexcludedirs'];
|
154 |
$jobs[$jobid]['backupplugins']= $_POST['backupplugins']==1 ? true : false;
|
155 |
+
$jobs[$jobid]['backuppluginsexcludedirs']=(array)$_POST['backuppluginsexcludedirs'];
|
156 |
+
$jobs[$jobid]['backupthemes']= $_POST['backupthemes']==1 ? true : false;
|
157 |
+
$jobs[$jobid]['backupthemesexcludedirs']=(array)$_POST['backupthemesexcludedirs'];
|
158 |
+
$jobs[$jobid]['backupuploads']= $_POST['backupuploads']==1 ? true : false;
|
159 |
+
$jobs[$jobid]['backupuploadsexcludedirs']=(array)$_POST['backupuploadsexcludedirs'];
|
160 |
$jobs[$jobid]['fileformart']=$_POST['fileformart'];
|
161 |
$jobs[$jobid]['mailefilesize']=(float)$_POST['mailefilesize'];
|
162 |
+
$jobs[$jobid]['backupdir']=stripslashes($_POST['backupdir']);
|
163 |
+
$jobs[$jobid]['maxbackups']=(int)$_POST['maxbackups'];
|
164 |
$jobs[$jobid]['ftphost']=$_POST['ftphost'];
|
165 |
$jobs[$jobid]['ftpuser']=$_POST['ftpuser'];
|
166 |
$jobs[$jobid]['ftppass']=base64_encode($_POST['ftppass']);
|
167 |
+
$jobs[$jobid]['ftpdir']=stripslashes($_POST['ftpdir']);
|
168 |
+
$jobs[$jobid]['ftpmaxbackups']=(int)$_POST['ftpmaxbackups'];
|
169 |
$jobs[$jobid]['awsAccessKey']=$_POST['awsAccessKey'];
|
170 |
$jobs[$jobid]['awsSecretKey']=$_POST['awsSecretKey'];
|
171 |
$jobs[$jobid]['awsSSL']= $_POST['awsSSL']==1 ? true : false;
|
172 |
$jobs[$jobid]['awsBucket']=$_POST['awsBucket'];
|
173 |
+
$jobs[$jobid]['awsdir']=stripslashes($_POST['awsdir']);
|
|
|
|
|
174 |
$jobs[$jobid]['mailaddress']=sanitize_email($_POST['mailaddress']);
|
175 |
+
$jobs[$jobid]['awsmaxbackups']=(int)$_POST['awsmaxbackups'];
|
176 |
+
|
177 |
+
$jobs[$jobid]=backwpup_check_job_vars($jobs[$jobid]); //check vars and set def.
|
178 |
|
179 |
if (!empty($_POST['newawsBucket']) and !empty($_POST['awsAccessKey']) and !empty($_POST['awsSecretKey'])) { //create new s3 bucket if needed
|
180 |
if (!class_exists('S3'))
|
app/options-settings.php
CHANGED
@@ -27,25 +27,7 @@ if ( !defined('ABSPATH') )
|
|
27 |
</div>
|
28 |
<div class="has-sidebar" >
|
29 |
<div id="post-body-content" class="has-sidebar-content">
|
30 |
-
|
31 |
-
<div id="memory" class="postbox">
|
32 |
-
<h3 class="hndle"><span><?PHP _e('Max Memory Usage','backwpup'); ?></span></h3>
|
33 |
-
<div class="inside">
|
34 |
-
<?php
|
35 |
-
echo __('PHP.ini Memory Limit:','backwpup').' '.ini_get('memory_limit').'<br />';
|
36 |
-
|
37 |
-
if (empty($cfg['memorylimit']))
|
38 |
-
$cfg['memorylimit']='128M';
|
39 |
|
40 |
-
if (!function_exists('memory_get_usage'))
|
41 |
-
echo __('Set Memory limit:','backwpup').'<input name="memorylimit" type="text" value="'.$cfg['memorylimit'].'" class="small-text" />';
|
42 |
-
else
|
43 |
-
echo '<span class="description">'.__('Memory will be automatically increased!!!','backwpup').'</span><input name="memorylimit" type="hidden" value="'.$cfg['memorylimit'].'" />';
|
44 |
-
|
45 |
-
?>
|
46 |
-
</div>
|
47 |
-
</div>
|
48 |
-
|
49 |
<div id="mailtype" class="postbox">
|
50 |
<h3 class="hndle"><span><?PHP _e('Send Mail','backwpup'); ?></span></h3>
|
51 |
<div class="inside">
|
27 |
</div>
|
28 |
<div class="has-sidebar" >
|
29 |
<div id="post-body-content" class="has-sidebar-content">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
<div id="mailtype" class="postbox">
|
32 |
<h3 class="hndle"><span><?PHP _e('Send Mail','backwpup'); ?></span></h3>
|
33 |
<div class="inside">
|
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.0
|
8 |
Author URI: http://danielhuesken.de
|
9 |
Text Domain: backwpup
|
10 |
Domain Path: /lang/
|
@@ -35,7 +35,7 @@ if ( !defined('ABSPATH') )
|
|
35 |
//Set plugin dirname
|
36 |
define('BACKWPUP_PLUGIN_BASEDIR', dirname(plugin_basename(__FILE__)));
|
37 |
//Set Plugin Version
|
38 |
-
define('BACKWPUP_VERSION', '1.0
|
39 |
//load Text Domain
|
40 |
load_plugin_textdomain('backwpup', false, BACKWPUP_PLUGIN_BASEDIR.'/lang');
|
41 |
//Load functions file
|
@@ -49,7 +49,7 @@ register_uninstall_hook(__FILE__, 'backwpup_plugin_uninstall');
|
|
49 |
|
50 |
//Version check
|
51 |
if (version_compare($wp_version, '2.8', '<') and version_compare(phpversion(), '5.0.0', '<')) { // Let only Activate on WordPress Version 2.8 or heiger
|
52 |
-
add_action('admin_notices', create_function('', 'echo \'<div id="message" class="error fade"><p><strong>' . __('Sorry, BackWPup works only with WordPress 2.8 and PHP 5 or heigher!!!','backwpup') . '</strong></p></div>\';'));
|
53 |
} else {
|
54 |
//Plugin init
|
55 |
add_action('plugins_loaded', 'backwpup_init');
|
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.1.0
|
8 |
Author URI: http://danielhuesken.de
|
9 |
Text Domain: backwpup
|
10 |
Domain Path: /lang/
|
35 |
//Set plugin dirname
|
36 |
define('BACKWPUP_PLUGIN_BASEDIR', dirname(plugin_basename(__FILE__)));
|
37 |
//Set Plugin Version
|
38 |
+
define('BACKWPUP_VERSION', '1.1.0');
|
39 |
//load Text Domain
|
40 |
load_plugin_textdomain('backwpup', false, BACKWPUP_PLUGIN_BASEDIR.'/lang');
|
41 |
//Load functions file
|
49 |
|
50 |
//Version check
|
51 |
if (version_compare($wp_version, '2.8', '<') and version_compare(phpversion(), '5.0.0', '<')) { // Let only Activate on WordPress Version 2.8 or heiger
|
52 |
+
add_action('admin_notices', create_function('', 'echo \'<div id="message" class="error fade"><p><strong>' . __('Sorry, BackWPup works only with WordPress 2.8 and PHP 5.0.0 or heigher!!!','backwpup') . '</strong></p></div>\';'));
|
53 |
} else {
|
54 |
//Plugin init
|
55 |
add_action('plugins_loaded', 'backwpup_init');
|
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
|
5 |
Requires at least: 2.8
|
6 |
Tested up to: 3.0.0
|
7 |
-
Stable tag: 1.0
|
8 |
|
9 |
Backup and more of your WordPress Blog Database and Files
|
10 |
|
@@ -35,7 +35,7 @@ I can give no WARRANTY to any backups...
|
|
35 |
|
36 |
== Frequently Asked Questions ==
|
37 |
= Requires =
|
38 |
-
* PHP 5
|
39 |
* Wordpress 2.8
|
40 |
* curl (for Amazon S3 Support)
|
41 |
* gzip (for PCLZIP and gzip archives)
|
@@ -81,6 +81,19 @@ Pleace mail only littele archives
|
|
81 |
1. Job Page
|
82 |
|
83 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
= 1.0.9 =
|
85 |
* change s3 class to hide warnigs
|
86 |
* add option to make MySQL INSERTs shorter (smaler dump file size.)
|
4 |
Tags: backup, admin, file, Database, mysql, cron, ftp, S3, export
|
5 |
Requires at least: 2.8
|
6 |
Tested up to: 3.0.0
|
7 |
+
Stable tag: 1.1.0
|
8 |
|
9 |
Backup and more of your WordPress Blog Database and Files
|
10 |
|
35 |
|
36 |
== Frequently Asked Questions ==
|
37 |
= Requires =
|
38 |
+
* PHP 5.0.0
|
39 |
* Wordpress 2.8
|
40 |
* curl (for Amazon S3 Support)
|
41 |
* gzip (for PCLZIP and gzip archives)
|
81 |
1. Job Page
|
82 |
|
83 |
== Changelog ==
|
84 |
+
= 1.1.0 =
|
85 |
+
* added fuction to check/update job settings
|
86 |
+
* added no ajax bucket list to job page
|
87 |
+
* changed error handling a bit and remove PHP errors that can't handeld
|
88 |
+
* fixed problem with not compiled --enable-memory-limit in php
|
89 |
+
* removed setting for memory limit use WP filter and default now (256M)
|
90 |
+
* now a time limit of 5 mins is set again for job execution but it will be resettet on every message. (prevent never ending jobs.)
|
91 |
+
* added a shutdown function if __destruct not called for job
|
92 |
+
* added more flexible Backup file selection
|
93 |
+
|
94 |
+
= 1.0.10 =
|
95 |
+
* fix "Undefined index: dbshortinsert"
|
96 |
+
|
97 |
= 1.0.9 =
|
98 |
* change s3 class to hide warnigs
|
99 |
* add option to make MySQL INSERTs shorter (smaler dump file size.)
|