Version Description
- fix temp backup file not deleted if no destination folder
- some folder fixes
- removed some not used code
Download this release
Release Info
Developer | danielhuesken |
Plugin | BackWPup – WordPress Backup Plugin |
Version | 1.0.8 |
Comparing to | |
See all releases |
Code changes from version 1.0.7 to 1.0.8
- app/backwpup_dojob.php +48 -49
- app/functions.php +2 -9
- app/options-save.php +5 -5
- backwpup.php +2 -2
- readme.txt +6 -1
app/backwpup_dojob.php
CHANGED
@@ -117,13 +117,8 @@ class backwpup_dojob {
|
|
117 |
|
118 |
public function __construct($jobid) {
|
119 |
global $backwpup_logfile;
|
120 |
-
global $backwpup_pcl_log_level;
|
121 |
-
|
122 |
$this->jobid=$jobid; //set job id
|
123 |
$this->cfg=get_option('backwpup'); //load config
|
124 |
-
$backwpup_pcl_log_level=$this->cfg['pcl_log_level'];
|
125 |
-
if ($backwpup_pcl_log_level<1 or $backwpup_pcl_log_level>5) //set to 1 for false values
|
126 |
-
$backwpup_pcl_log_level=1;
|
127 |
$jobs=get_option('backwpup_jobs'); //load jobdata
|
128 |
$jobs[$this->jobid]['starttime']=current_time('timestamp'); //set start time for job
|
129 |
$jobs[$this->jobid]['stoptime']=''; //Set stop time for job
|
@@ -137,23 +132,25 @@ class backwpup_dojob {
|
|
137 |
if (!empty($this->job['fileformart']) or $this->job['fileformart']=='.zip' or $this->job['fileformart']=='.tar' or $this->job['fileformart']=='.tar.gz' or $this->job['fileformart']=='.tar.bz2')
|
138 |
$this->backupfileformat=$this->job['fileformart'];
|
139 |
//set Temp Dir
|
140 |
-
$this->tempdir=
|
141 |
-
if (empty($this->tempdir))
|
142 |
-
$
|
|
|
|
|
143 |
//set Backup Dir
|
144 |
-
$this->backupdir=
|
145 |
-
if (empty($this->backupdir))
|
146 |
$this->backupdir=$this->tempdir;
|
147 |
//set Logs Dir
|
148 |
-
$this->logdir=
|
149 |
-
if (empty($this->logdir))
|
150 |
-
$this->logdir
|
151 |
//set Backup file name only for jos that makes backups
|
152 |
if (in_array('FILE',$this->todo) or in_array('DB',$this->todo) or in_array('WPEXP',$this->todo))
|
153 |
$this->backupfile='backwpup_'.$this->jobid.'_'.date_i18n('Y-m-d_H-i-s').$this->backupfileformat;
|
154 |
//set Log file name
|
155 |
$this->logfile='backwpup_log_'.date_i18n('Y-m-d_H-i-s').'.html';
|
156 |
-
$backwpup_logfile=$this->logdir
|
157 |
//Create log file
|
158 |
if (!$this->_check_folders($this->logdir))
|
159 |
return false;
|
@@ -167,7 +164,7 @@ class backwpup_dojob {
|
|
167 |
@fputs($fd,"<meta name=\"backwpup_jobname\" content=\"".$this->job['name']."\" />\n");
|
168 |
@fputs($fd,"<meta name=\"backwpup_jobtype\" content=\"".$this->job['type']."\" />\n");
|
169 |
if (!empty($this->backupfile))
|
170 |
-
@fputs($fd,"<meta name=\"backwpup_backupfile\" content=\"".$this->backupdir
|
171 |
@fputs($fd,str_pad("<meta name=\"backwpup_jobruntime\" content=\"0\" />",100)."\n");
|
172 |
@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");
|
173 |
@fclose($fd);
|
@@ -213,7 +210,7 @@ class backwpup_dojob {
|
|
213 |
$this->tar_pack_files();
|
214 |
else
|
215 |
return;
|
216 |
-
if (!file_exists($this->backupdir
|
217 |
return;
|
218 |
$this->destination_mail();
|
219 |
$this->destination_ftp();
|
@@ -462,7 +459,7 @@ class backwpup_dojob {
|
|
462 |
$status[$statusdata['Name']]=$statusdata;
|
463 |
}
|
464 |
|
465 |
-
if ($file = @fopen($this->tempdir.
|
466 |
fwrite($file, "-- ---------------------------------------------------------\n");
|
467 |
fwrite($file, "-- Dump with BackWPup ver.: ".BACKWPUP_VERSION."\n");
|
468 |
fwrite($file, "-- Plugin for WordPress by Daniel Huesken\n");
|
@@ -514,21 +511,21 @@ class backwpup_dojob {
|
|
514 |
|
515 |
trigger_error(__('Database Dump done!','backwpup'),E_USER_NOTICE);
|
516 |
//add database file to backupfiles
|
517 |
-
trigger_error(__('Add Database Dump to Backup:','backwpup').' '.DB_NAME.'.sql '.backwpup_formatBytes(filesize($this->tempdir.
|
518 |
-
$this->allfilesize+=filesize($this->tempdir.
|
519 |
-
$this->filelist[]=array(79001=>$this->tempdir.
|
520 |
|
521 |
$this->maintenance_mode(false);
|
522 |
}
|
523 |
|
524 |
public function export_wp() {
|
525 |
trigger_error(__('Run Wordpress Export to XML file...','backwpup'),E_USER_NOTICE);
|
526 |
-
if (copy(plugins_url('wp_xml_export.php',__FILE__).'?wpabs='.trailingslashit(ABSPATH).'&_nonce='.substr(md5(md5(SECURE_AUTH_KEY)),10,10),$this->tempdir.'
|
527 |
trigger_error(__('Export to XML done!','backwpup'),E_USER_NOTICE);
|
528 |
//add database file to backupfiles
|
529 |
-
trigger_error(__('Add XML Export to Backup:','backwpup').' wordpress.' . date( 'Y-m-d' ) . '.xml '.backwpup_formatBytes(filesize($this->tempdir.'
|
530 |
-
$this->allfilesize+=filesize($this->tempdir.'
|
531 |
-
$this->filelist[]=array(79001=>$this->tempdir.'
|
532 |
} else {
|
533 |
trigger_error(__('Can not Export to XML!','backwpup'),E_USER_ERROR);
|
534 |
}
|
@@ -657,7 +654,7 @@ class backwpup_dojob {
|
|
657 |
if (class_exists('ZipArchive')) { //use php zip lib
|
658 |
trigger_error(__('Create Backup Zip file...','backwpup'),E_USER_NOTICE);
|
659 |
$zip = new ZipArchive;
|
660 |
-
if ($res=$zip->open($this->backupdir
|
661 |
foreach($this->filelist as $key => $files) {
|
662 |
if ($zip->addFile($files[79001], $files[79003])) {
|
663 |
trigger_error(__('Add File to ZIP file:','backwpup').' '.$files[79001].' '.backwpup_formatBytes(filesize($files[79001])),E_USER_NOTICE);
|
@@ -682,7 +679,7 @@ class backwpup_dojob {
|
|
682 |
foreach($this->filelist as $key => $files) {
|
683 |
trigger_error(__('Add File to ZIP file:','backwpup').' '.$files[79001].' '.backwpup_formatBytes(filesize($files[79001])),E_USER_NOTICE);
|
684 |
}
|
685 |
-
$zipbackupfile = new PclZip($this->backupdir
|
686 |
if (0==$zipbackupfile -> create($this->filelist,PCLZIP_OPT_ADD_TEMP_FILE_ON)) {
|
687 |
trigger_error(__('Zip file create:','backwpup').' '.$zipbackupfile->errorInfo(true),E_USER_ERROR);
|
688 |
} else {
|
@@ -695,11 +692,11 @@ class backwpup_dojob {
|
|
695 |
public function tar_pack_files() {
|
696 |
|
697 |
if ($this->backupfileformat=='.tar.gz') {
|
698 |
-
$tarbackup=gzopen($this->backupdir
|
699 |
} elseif ($this->backupfileformat=='.tar.bz2') {
|
700 |
-
$tarbackup=bzopen($this->backupdir
|
701 |
} else {
|
702 |
-
$tarbackup=fopen($this->backupdir
|
703 |
}
|
704 |
|
705 |
if (!$tarbackup) {
|
@@ -815,7 +812,7 @@ class backwpup_dojob {
|
|
815 |
|
816 |
|
817 |
public function destination_ftp() {
|
818 |
-
$this->job['ftpdir']=trailingslashit(
|
819 |
if ($this->job['ftpdir']=='/')
|
820 |
$this->job['ftpdir']='';
|
821 |
|
@@ -873,7 +870,7 @@ class backwpup_dojob {
|
|
873 |
trigger_error(__('FTP Server reply:','backwpup').' '.__('Can not Entering Passive Mode','backwpup'),E_USER_WARNING);
|
874 |
//ALLO show no erros in log if do not work
|
875 |
trigger_error(__('FTP Client command:','backwpup').' ALLO',E_USER_NOTICE);
|
876 |
-
ftp_alloc($ftp_conn_id,filesize($this->backupdir
|
877 |
trigger_error(__('FTP Server reply:','backwpup').' '.$result,E_USER_NOTICE);
|
878 |
|
879 |
//test ftp dir and create it f not exists
|
@@ -892,7 +889,7 @@ class backwpup_dojob {
|
|
892 |
}
|
893 |
}
|
894 |
|
895 |
-
if (ftp_put($ftp_conn_id, $this->job['ftpdir'].$this->backupfile, $this->backupdir
|
896 |
trigger_error(__('Backup File transferred to FTP Server:','backwpup').' '.$this->job['ftpdir'].$this->backupfile,E_USER_NOTICE);
|
897 |
else
|
898 |
trigger_error(__('Can not transfer backup to FTP server.','backwpup'),E_USER_ERROR);
|
@@ -928,7 +925,7 @@ class backwpup_dojob {
|
|
928 |
|
929 |
trigger_error(__('Prepare Sending backupfile with mail...','backwpup'),E_USER_NOTICE);
|
930 |
|
931 |
-
if (!is_file($this->backupdir
|
932 |
trigger_error(__('No file to send!','backwpup'),E_USER_ERROR);
|
933 |
return false;
|
934 |
}
|
@@ -973,15 +970,15 @@ class backwpup_dojob {
|
|
973 |
//check file Size
|
974 |
if (!empty($this->job['mailefilesize'])) {
|
975 |
$maxfilezise=abs($this->job['mailefilesize']*1024*1024);
|
976 |
-
if (filesize($this->backupdir
|
977 |
trigger_error(__('Backup Archive too big for sending by mail','backwpup'),E_USER_ERROR);
|
978 |
return false;
|
979 |
}
|
980 |
}
|
981 |
|
982 |
trigger_error(__('Adding Attachment to mail','backwpup'),E_USER_NOTICE);
|
983 |
-
$this->need_free_memory(filesize($this->backupdir
|
984 |
-
$phpmailer->AddAttachment($this->backupdir
|
985 |
|
986 |
trigger_error(__('Send mail....','backwpup'),E_USER_NOTICE);
|
987 |
if (false == $phpmailer->Send()) {
|
@@ -993,7 +990,7 @@ class backwpup_dojob {
|
|
993 |
}
|
994 |
|
995 |
public function destination_s3() {
|
996 |
-
$this->job['awsdir']=trailingslashit(
|
997 |
if ($this->job['awsdir']=='/')
|
998 |
$this->job['awsdir']='';
|
999 |
|
@@ -1012,7 +1009,7 @@ class backwpup_dojob {
|
|
1012 |
if (in_array($this->job['awsBucket'],$s3->listBuckets())) {
|
1013 |
trigger_error(__('Connected to S3 Bucket:','backwpup').' '.$this->job['awsBucket'],E_USER_NOTICE);
|
1014 |
//Transfer Backup to S3
|
1015 |
-
if ($s3->putObjectFile($this->backupdir
|
1016 |
trigger_error(__('Backup File transferred to S3://','backwpup').$this->job['awsBucket'].'/'.$this->job['awsdir'].$this->backupfile,E_USER_NOTICE);
|
1017 |
else
|
1018 |
trigger_error(__('Can not transfer backup to S3.','backwpup'),E_USER_ERROR);
|
@@ -1047,9 +1044,11 @@ class backwpup_dojob {
|
|
1047 |
}
|
1048 |
|
1049 |
public function destination_dir() {
|
|
|
|
|
1050 |
//Delete old Backupfiles
|
1051 |
$backupfilelist=array();
|
1052 |
-
if (!empty($this->job['maxbackups']) and
|
1053 |
if ( $dir = @opendir($this->job['backupdir']) ) { //make file list
|
1054 |
while (($file = readdir($dir)) !== false ) {
|
1055 |
if ('backwpup_'.$this->jobid.'_' == substr($file,0,strlen('backwpup_'.$this->jobid.'_')) and $this->backupfileformat == substr($file,-strlen($this->backupfileformat)))
|
@@ -1073,20 +1072,20 @@ class backwpup_dojob {
|
|
1073 |
public function __destruct() {
|
1074 |
global $backwpup_logfile;
|
1075 |
|
1076 |
-
if (is_file($this->backupdir
|
1077 |
-
trigger_error(sprintf(__('Backup Archive File size is %1s','backwpup'),backwpup_formatBytes(filesize($this->backupdir
|
1078 |
}
|
1079 |
|
1080 |
-
if (is_file($this->tempdir.
|
1081 |
-
unlink($this->tempdir.
|
1082 |
}
|
1083 |
|
1084 |
-
if (is_file($this->tempdir.'
|
1085 |
-
unlink($this->tempdir.'
|
1086 |
}
|
1087 |
|
1088 |
-
if (empty($this->job['backupdir'])
|
1089 |
-
unlink($this->backupdir
|
1090 |
}
|
1091 |
|
1092 |
//delete old logs
|
@@ -1102,7 +1101,7 @@ class backwpup_dojob {
|
|
1102 |
rsort($logfilelist);
|
1103 |
$numdeltefiles=0;
|
1104 |
for ($i=$this->cfg['maxlogs'];$i<sizeof($logfilelist);$i++) {
|
1105 |
-
unlink(
|
1106 |
$numdeltefiles++;
|
1107 |
}
|
1108 |
if ($numdeltefiles>0)
|
@@ -1148,7 +1147,7 @@ class backwpup_dojob {
|
|
1148 |
$mailbody.=__("Errors:","backwpup")." ".$logdata['errors']."\n";
|
1149 |
if (!empty($logdata['warnings']))
|
1150 |
$mailbody.=__("Warnings:","backwpup")." ".$logdata['warnings']."\n";
|
1151 |
-
wp_mail($this->job['mailaddresslog'],__('BackWPup Log File from','backwpup').' '.date_i18n('Y-m-d H:i',$this->job['starttime']).': '.$this->job['name'] ,$mailbody,'',array($this->logdir
|
1152 |
}
|
1153 |
}
|
1154 |
}
|
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
|
123 |
$jobs[$this->jobid]['starttime']=current_time('timestamp'); //set start time for job
|
124 |
$jobs[$this->jobid]['stoptime']=''; //Set stop time for job
|
132 |
if (!empty($this->job['fileformart']) or $this->job['fileformart']=='.zip' or $this->job['fileformart']=='.tar' or $this->job['fileformart']=='.tar.gz' or $this->job['fileformart']=='.tar.bz2')
|
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 |
+
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
138 |
+
$this->tempdir=str_replace('\\','/',get_temp_dir().'backwpup-'.$rand.'/');
|
139 |
+
}
|
140 |
//set Backup Dir
|
141 |
+
$this->backupdir=trailingslashit($this->job['backupdir']);
|
142 |
+
if (empty($this->backupdir) or $this->backupdir=='/')
|
143 |
$this->backupdir=$this->tempdir;
|
144 |
//set Logs Dir
|
145 |
+
$this->logdir=trailingslashit($this->cfg['dirlogs']);
|
146 |
+
if (empty($this->logdir) or $this->logdir=='/')
|
147 |
+
$this->logdir=$this->tempdir.'logs/';
|
148 |
//set Backup file name only for jos that makes backups
|
149 |
if (in_array('FILE',$this->todo) or in_array('DB',$this->todo) or in_array('WPEXP',$this->todo))
|
150 |
$this->backupfile='backwpup_'.$this->jobid.'_'.date_i18n('Y-m-d_H-i-s').$this->backupfileformat;
|
151 |
//set Log file name
|
152 |
$this->logfile='backwpup_log_'.date_i18n('Y-m-d_H-i-s').'.html';
|
153 |
+
$backwpup_logfile=$this->logdir.$this->logfile;
|
154 |
//Create log file
|
155 |
if (!$this->_check_folders($this->logdir))
|
156 |
return false;
|
164 |
@fputs($fd,"<meta name=\"backwpup_jobname\" content=\"".$this->job['name']."\" />\n");
|
165 |
@fputs($fd,"<meta name=\"backwpup_jobtype\" content=\"".$this->job['type']."\" />\n");
|
166 |
if (!empty($this->backupfile))
|
167 |
+
@fputs($fd,"<meta name=\"backwpup_backupfile\" content=\"".$this->backupdir.$this->backupfile."\" />\n");
|
168 |
@fputs($fd,str_pad("<meta name=\"backwpup_jobruntime\" content=\"0\" />",100)."\n");
|
169 |
@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");
|
170 |
@fclose($fd);
|
210 |
$this->tar_pack_files();
|
211 |
else
|
212 |
return;
|
213 |
+
if (!file_exists($this->backupdir.$this->backupfile))
|
214 |
return;
|
215 |
$this->destination_mail();
|
216 |
$this->destination_ftp();
|
459 |
$status[$statusdata['Name']]=$statusdata;
|
460 |
}
|
461 |
|
462 |
+
if ($file = @fopen($this->tempdir.DB_NAME.'.sql', 'w')) {
|
463 |
fwrite($file, "-- ---------------------------------------------------------\n");
|
464 |
fwrite($file, "-- Dump with BackWPup ver.: ".BACKWPUP_VERSION."\n");
|
465 |
fwrite($file, "-- Plugin for WordPress by Daniel Huesken\n");
|
511 |
|
512 |
trigger_error(__('Database Dump done!','backwpup'),E_USER_NOTICE);
|
513 |
//add database file to backupfiles
|
514 |
+
trigger_error(__('Add Database Dump to Backup:','backwpup').' '.DB_NAME.'.sql '.backwpup_formatBytes(filesize($this->tempdir.DB_NAME.'.sql')),E_USER_NOTICE);
|
515 |
+
$this->allfilesize+=filesize($this->tempdir.DB_NAME.'.sql');
|
516 |
+
$this->filelist[]=array(79001=>$this->tempdir.DB_NAME.'.sql',79003=>DB_NAME.'.sql');
|
517 |
|
518 |
$this->maintenance_mode(false);
|
519 |
}
|
520 |
|
521 |
public function export_wp() {
|
522 |
trigger_error(__('Run Wordpress Export to XML file...','backwpup'),E_USER_NOTICE);
|
523 |
+
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')) {
|
524 |
trigger_error(__('Export to XML done!','backwpup'),E_USER_NOTICE);
|
525 |
//add database file to backupfiles
|
526 |
+
trigger_error(__('Add XML Export to Backup:','backwpup').' wordpress.' . date( 'Y-m-d' ) . '.xml '.backwpup_formatBytes(filesize($this->tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml')),E_USER_NOTICE);
|
527 |
+
$this->allfilesize+=filesize($this->tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml');
|
528 |
+
$this->filelist[]=array(79001=>$this->tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml',79003=>'wordpress.' . date( 'Y-m-d' ) . '.xml');
|
529 |
} else {
|
530 |
trigger_error(__('Can not Export to XML!','backwpup'),E_USER_ERROR);
|
531 |
}
|
654 |
if (class_exists('ZipArchive')) { //use php zip lib
|
655 |
trigger_error(__('Create Backup Zip file...','backwpup'),E_USER_NOTICE);
|
656 |
$zip = new ZipArchive;
|
657 |
+
if ($res=$zip->open($this->backupdir.$this->backupfile,ZIPARCHIVE::CREATE) === TRUE) {
|
658 |
foreach($this->filelist as $key => $files) {
|
659 |
if ($zip->addFile($files[79001], $files[79003])) {
|
660 |
trigger_error(__('Add File to ZIP file:','backwpup').' '.$files[79001].' '.backwpup_formatBytes(filesize($files[79001])),E_USER_NOTICE);
|
679 |
foreach($this->filelist as $key => $files) {
|
680 |
trigger_error(__('Add File to ZIP file:','backwpup').' '.$files[79001].' '.backwpup_formatBytes(filesize($files[79001])),E_USER_NOTICE);
|
681 |
}
|
682 |
+
$zipbackupfile = new PclZip($this->backupdir.$this->backupfile);
|
683 |
if (0==$zipbackupfile -> create($this->filelist,PCLZIP_OPT_ADD_TEMP_FILE_ON)) {
|
684 |
trigger_error(__('Zip file create:','backwpup').' '.$zipbackupfile->errorInfo(true),E_USER_ERROR);
|
685 |
} else {
|
692 |
public function tar_pack_files() {
|
693 |
|
694 |
if ($this->backupfileformat=='.tar.gz') {
|
695 |
+
$tarbackup=gzopen($this->backupdir.$this->backupfile,'w9');
|
696 |
} elseif ($this->backupfileformat=='.tar.bz2') {
|
697 |
+
$tarbackup=bzopen($this->backupdir.$this->backupfile,'w');
|
698 |
} else {
|
699 |
+
$tarbackup=fopen($this->backupdir.$this->backupfile,'w');
|
700 |
}
|
701 |
|
702 |
if (!$tarbackup) {
|
812 |
|
813 |
|
814 |
public function destination_ftp() {
|
815 |
+
$this->job['ftpdir']=trailingslashit($this->job['ftpdir']);
|
816 |
if ($this->job['ftpdir']=='/')
|
817 |
$this->job['ftpdir']='';
|
818 |
|
870 |
trigger_error(__('FTP Server reply:','backwpup').' '.__('Can not Entering Passive Mode','backwpup'),E_USER_WARNING);
|
871 |
//ALLO show no erros in log if do not work
|
872 |
trigger_error(__('FTP Client command:','backwpup').' ALLO',E_USER_NOTICE);
|
873 |
+
ftp_alloc($ftp_conn_id,filesize($this->backupdir.$this->backupfile),$result);
|
874 |
trigger_error(__('FTP Server reply:','backwpup').' '.$result,E_USER_NOTICE);
|
875 |
|
876 |
//test ftp dir and create it f not exists
|
889 |
}
|
890 |
}
|
891 |
|
892 |
+
if (ftp_put($ftp_conn_id, $this->job['ftpdir'].$this->backupfile, $this->backupdir.$this->backupfile, FTP_BINARY)) //transfere file
|
893 |
trigger_error(__('Backup File transferred to FTP Server:','backwpup').' '.$this->job['ftpdir'].$this->backupfile,E_USER_NOTICE);
|
894 |
else
|
895 |
trigger_error(__('Can not transfer backup to FTP server.','backwpup'),E_USER_ERROR);
|
925 |
|
926 |
trigger_error(__('Prepare Sending backupfile with mail...','backwpup'),E_USER_NOTICE);
|
927 |
|
928 |
+
if (!is_file($this->backupdir.$this->backupfile)) {
|
929 |
trigger_error(__('No file to send!','backwpup'),E_USER_ERROR);
|
930 |
return false;
|
931 |
}
|
970 |
//check file Size
|
971 |
if (!empty($this->job['mailefilesize'])) {
|
972 |
$maxfilezise=abs($this->job['mailefilesize']*1024*1024);
|
973 |
+
if (filesize($this->backupdir.$this->backupfile)>$maxfilezise) {
|
974 |
trigger_error(__('Backup Archive too big for sending by mail','backwpup'),E_USER_ERROR);
|
975 |
return false;
|
976 |
}
|
977 |
}
|
978 |
|
979 |
trigger_error(__('Adding Attachment to mail','backwpup'),E_USER_NOTICE);
|
980 |
+
$this->need_free_memory(filesize($this->backupdir.$this->backupfile)*4);
|
981 |
+
$phpmailer->AddAttachment($this->backupdir.$this->backupfile);
|
982 |
|
983 |
trigger_error(__('Send mail....','backwpup'),E_USER_NOTICE);
|
984 |
if (false == $phpmailer->Send()) {
|
990 |
}
|
991 |
|
992 |
public function destination_s3() {
|
993 |
+
$this->job['awsdir']=trailingslashit($this->job['awsdir']);
|
994 |
if ($this->job['awsdir']=='/')
|
995 |
$this->job['awsdir']='';
|
996 |
|
1009 |
if (in_array($this->job['awsBucket'],$s3->listBuckets())) {
|
1010 |
trigger_error(__('Connected to S3 Bucket:','backwpup').' '.$this->job['awsBucket'],E_USER_NOTICE);
|
1011 |
//Transfer Backup to S3
|
1012 |
+
if ($s3->putObjectFile($this->backupdir.$this->backupfile, $this->job['awsBucket'], $this->job['awsdir'].$this->backupfile, S3::ACL_PRIVATE)) //transfere file to S3
|
1013 |
trigger_error(__('Backup File transferred to S3://','backwpup').$this->job['awsBucket'].'/'.$this->job['awsdir'].$this->backupfile,E_USER_NOTICE);
|
1014 |
else
|
1015 |
trigger_error(__('Can not transfer backup to S3.','backwpup'),E_USER_ERROR);
|
1044 |
}
|
1045 |
|
1046 |
public function destination_dir() {
|
1047 |
+
if (empty($this->job['backupdir']) or $this->job['backupdir']=='/') //Go back if no destination dir
|
1048 |
+
return;
|
1049 |
//Delete old Backupfiles
|
1050 |
$backupfilelist=array();
|
1051 |
+
if (!empty($this->job['maxbackups']) and is_dir($this->job['backupdir'])) {
|
1052 |
if ( $dir = @opendir($this->job['backupdir']) ) { //make file list
|
1053 |
while (($file = readdir($dir)) !== false ) {
|
1054 |
if ('backwpup_'.$this->jobid.'_' == substr($file,0,strlen('backwpup_'.$this->jobid.'_')) and $this->backupfileformat == substr($file,-strlen($this->backupfileformat)))
|
1072 |
public function __destruct() {
|
1073 |
global $backwpup_logfile;
|
1074 |
|
1075 |
+
if (is_file($this->backupdir.$this->backupfile)) {
|
1076 |
+
trigger_error(sprintf(__('Backup Archive File size is %1s','backwpup'),backwpup_formatBytes(filesize($this->backupdir.$this->backupfile))),E_USER_NOTICE);
|
1077 |
}
|
1078 |
|
1079 |
+
if (is_file($this->tempdir.DB_NAME.'.sql') ) { //delete sql temp file
|
1080 |
+
unlink($this->tempdir.DB_NAME.'.sql');
|
1081 |
}
|
1082 |
|
1083 |
+
if (is_file($this->tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml') ) { //delete WP XML Export temp file
|
1084 |
+
unlink($this->tempdir.'wordpress.' . date( 'Y-m-d' ) . '.xml');
|
1085 |
}
|
1086 |
|
1087 |
+
if ((empty($this->job['backupdir']) or $this->job['backupdir']=='/') and is_file($this->backupdir.$this->backupfile)) { //delete backup file in temp dir
|
1088 |
+
unlink($this->backupdir.$this->backupfile);
|
1089 |
}
|
1090 |
|
1091 |
//delete old logs
|
1101 |
rsort($logfilelist);
|
1102 |
$numdeltefiles=0;
|
1103 |
for ($i=$this->cfg['maxlogs'];$i<sizeof($logfilelist);$i++) {
|
1104 |
+
unlink($this->logdir.$logfilelist[$i]);
|
1105 |
$numdeltefiles++;
|
1106 |
}
|
1107 |
if ($numdeltefiles>0)
|
1147 |
$mailbody.=__("Errors:","backwpup")." ".$logdata['errors']."\n";
|
1148 |
if (!empty($logdata['warnings']))
|
1149 |
$mailbody.=__("Warnings:","backwpup")." ".$logdata['warnings']."\n";
|
1150 |
+
wp_mail($this->job['mailaddresslog'],__('BackWPup Log File from','backwpup').' '.date_i18n('Y-m-d H:i',$this->job['starttime']).': '.$this->job['name'] ,$mailbody,'',array($this->logdir.$this->logfile));
|
1151 |
}
|
1152 |
}
|
1153 |
}
|
app/functions.php
CHANGED
@@ -40,14 +40,7 @@ if ( !defined('ABSPATH') )
|
|
40 |
$help .= ' | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=daniel%40huesken-net%2ede&item_name=Daniel%20Huesken%20Plugin%20Donation&item_number=BackWPup&no_shipping=0&no_note=1&tax=0&currency_code=EUR&lc=DE&bn=PP%2dDonationsBF&charset=UTF%2d8" target="_blank">' . __('Donate') . '</a>';
|
41 |
$help .= " | <script type=\"text/javascript\">
|
42 |
var flattr_btn = 'compact';
|
43 |
-
var flattr_uid = '21883';
|
44 |
-
var flattr_tle = 'BackWPup';
|
45 |
-
var flattr_dsc = 'Backup and more for Wordpress';
|
46 |
-
var flattr_cat = 'software';
|
47 |
-
var flattr_lng = 'en_GB';
|
48 |
-
var flattr_tag = 'backwpup, backup, wordpress, file, mysql, check, optimize';
|
49 |
var flattr_url = 'http://danielhuesken.de/portfolio/backwpup/';
|
50 |
-
var flattr_hide = 'false';
|
51 |
</script><script src=\"http://api.flattr.com/button/load.js\" type=\"text/javascript\"></script>";
|
52 |
$help .= "</div>\n";
|
53 |
$help .= '<div class="metabox-prefs">';
|
@@ -142,11 +135,11 @@ if ( !defined('ABSPATH') )
|
|
142 |
if (empty($cfg['maxlogs'])) $cfg['maxlogs']=0;
|
143 |
if (empty($cfg['dirtemp'])) {
|
144 |
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
145 |
-
$cfg['dirtemp']=str_replace('\\','/',get_temp_dir().'backwpup-'.$rand);
|
146 |
}
|
147 |
if (empty($cfg['dirlogs'])) {
|
148 |
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
149 |
-
$cfg['dirlogs']=str_replace('\\','/',WP_CONTENT_DIR).'/backwpup-'.$rand.'/logs';
|
150 |
}
|
151 |
update_option('backwpup',$cfg);
|
152 |
}
|
40 |
$help .= ' | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=daniel%40huesken-net%2ede&item_name=Daniel%20Huesken%20Plugin%20Donation&item_number=BackWPup&no_shipping=0&no_note=1&tax=0&currency_code=EUR&lc=DE&bn=PP%2dDonationsBF&charset=UTF%2d8" target="_blank">' . __('Donate') . '</a>';
|
41 |
$help .= " | <script type=\"text/javascript\">
|
42 |
var flattr_btn = 'compact';
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
var flattr_url = 'http://danielhuesken.de/portfolio/backwpup/';
|
|
|
44 |
</script><script src=\"http://api.flattr.com/button/load.js\" type=\"text/javascript\"></script>";
|
45 |
$help .= "</div>\n";
|
46 |
$help .= '<div class="metabox-prefs">';
|
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']=str_replace('\\','/',get_temp_dir().'backwpup-'.$rand.'/');
|
139 |
}
|
140 |
if (empty($cfg['dirlogs'])) {
|
141 |
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
142 |
+
$cfg['dirlogs']=str_replace('\\','/',WP_CONTENT_DIR).'/backwpup-'.$rand.'/logs/';
|
143 |
}
|
144 |
update_option('backwpup',$cfg);
|
145 |
}
|
app/options-save.php
CHANGED
@@ -55,7 +55,7 @@ case 'savecfg': //Save config form Setings page
|
|
55 |
$cfg['mailsndemail']=sanitize_email($_POST['mailsndemail']);
|
56 |
$cfg['mailsndname']=$_POST['mailsndname'];
|
57 |
$cfg['mailmethod']=$_POST['mailmethod'];
|
58 |
-
$cfg['mailsendmail']=str_replace('\\','/',stripslashes($_POST['mailsendmail']));
|
59 |
$cfg['mailsecure']=$_POST['mailsecure'];
|
60 |
$cfg['mailhost']=$_POST['mailhost'];
|
61 |
$cfg['mailuser']=$_POST['mailuser'];
|
@@ -63,8 +63,8 @@ case 'savecfg': //Save config form Setings page
|
|
63 |
$cfg['memorylimit']=$_POST['memorylimit'];
|
64 |
$cfg['disablewpcron']=$_POST['disablewpcron']==1 ? true : false;
|
65 |
$cfg['maxlogs']=abs((int)$_POST['maxlogs']);
|
66 |
-
$cfg['dirlogs']=
|
67 |
-
$cfg['dirtemp']=
|
68 |
if (update_option('backwpup',$cfg))
|
69 |
$backwpup_message=__('Settings saved', 'backwpup');
|
70 |
$_REQUEST['action']='settings';
|
@@ -149,13 +149,13 @@ case 'saveeditjob': //Save Job settings
|
|
149 |
$jobs[$jobid]['ftphost']=$_POST['ftphost'];
|
150 |
$jobs[$jobid]['ftpuser']=$_POST['ftpuser'];
|
151 |
$jobs[$jobid]['ftppass']=base64_encode($_POST['ftppass']);
|
152 |
-
$jobs[$jobid]['ftpdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',stripslashes(trim(
|
153 |
$jobs[$jobid]['ftpmaxbackups']=abs((int)$_POST['ftpmaxbackups']);
|
154 |
$jobs[$jobid]['awsAccessKey']=$_POST['awsAccessKey'];
|
155 |
$jobs[$jobid]['awsSecretKey']=$_POST['awsSecretKey'];
|
156 |
$jobs[$jobid]['awsSSL']= $_POST['awsSSL']==1 ? true : false;
|
157 |
$jobs[$jobid]['awsBucket']=$_POST['awsBucket'];
|
158 |
-
$jobs[$jobid]['awsdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',stripslashes(trim(
|
159 |
if (substr($jobs[$jobid]['awsdir'],0,1)=='/')
|
160 |
$jobs[$jobid]['awsdir']=substr($jobs[$jobid]['awsdir'],1);
|
161 |
$jobs[$jobid]['mailaddress']=sanitize_email($_POST['mailaddress']);
|
55 |
$cfg['mailsndemail']=sanitize_email($_POST['mailsndemail']);
|
56 |
$cfg['mailsndname']=$_POST['mailsndname'];
|
57 |
$cfg['mailmethod']=$_POST['mailmethod'];
|
58 |
+
$cfg['mailsendmail']=untrailingslashit(str_replace('//','/',str_replace('\\','/',stripslashes($_POST['mailsendmail']))));
|
59 |
$cfg['mailsecure']=$_POST['mailsecure'];
|
60 |
$cfg['mailhost']=$_POST['mailhost'];
|
61 |
$cfg['mailuser']=$_POST['mailuser'];
|
63 |
$cfg['memorylimit']=$_POST['memorylimit'];
|
64 |
$cfg['disablewpcron']=$_POST['disablewpcron']==1 ? true : false;
|
65 |
$cfg['maxlogs']=abs((int)$_POST['maxlogs']);
|
66 |
+
$cfg['dirlogs']=trailingslashit(str_replace('//','/',str_replace('\\','/',stripslashes(trim($_POST['dirlogs'])))));
|
67 |
+
$cfg['dirtemp']=trailingslashit(str_replace('//','/',str_replace('\\','/',stripslashes(trim($_POST['dirtemp'])))));
|
68 |
if (update_option('backwpup',$cfg))
|
69 |
$backwpup_message=__('Settings saved', 'backwpup');
|
70 |
$_REQUEST['action']='settings';
|
149 |
$jobs[$jobid]['ftphost']=$_POST['ftphost'];
|
150 |
$jobs[$jobid]['ftpuser']=$_POST['ftpuser'];
|
151 |
$jobs[$jobid]['ftppass']=base64_encode($_POST['ftppass']);
|
152 |
+
$jobs[$jobid]['ftpdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',stripslashes(trim($_POST['ftpdir'])))));
|
153 |
$jobs[$jobid]['ftpmaxbackups']=abs((int)$_POST['ftpmaxbackups']);
|
154 |
$jobs[$jobid]['awsAccessKey']=$_POST['awsAccessKey'];
|
155 |
$jobs[$jobid]['awsSecretKey']=$_POST['awsSecretKey'];
|
156 |
$jobs[$jobid]['awsSSL']= $_POST['awsSSL']==1 ? true : false;
|
157 |
$jobs[$jobid]['awsBucket']=$_POST['awsBucket'];
|
158 |
+
$jobs[$jobid]['awsdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',stripslashes(trim($_POST['awsdir'])))));
|
159 |
if (substr($jobs[$jobid]['awsdir'],0,1)=='/')
|
160 |
$jobs[$jobid]['awsdir']=substr($jobs[$jobid]['awsdir'],1);
|
161 |
$jobs[$jobid]['mailaddress']=sanitize_email($_POST['mailaddress']);
|
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
|
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
|
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.0.8');
|
39 |
//load Text Domain
|
40 |
load_plugin_textdomain('backwpup', false, BACKWPUP_PLUGIN_BASEDIR.'/lang');
|
41 |
//Load functions file
|
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 |
|
@@ -81,6 +81,11 @@ Pleace mail only littele archives
|
|
81 |
1. Job Page
|
82 |
|
83 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
84 |
= 1.0.7 =
|
85 |
* added flattr button in Help
|
86 |
* Fixed bug on S3 File deletion
|
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
|
8 |
|
9 |
Backup and more of your WordPress Blog Database and Files
|
10 |
|
81 |
1. Job Page
|
82 |
|
83 |
== Changelog ==
|
84 |
+
= 1.0.8 =
|
85 |
+
* fix temp backup file not deleted if no destination folder
|
86 |
+
* some folder fixes
|
87 |
+
* removed some not used code
|
88 |
+
|
89 |
= 1.0.7 =
|
90 |
* added flattr button in Help
|
91 |
* Fixed bug on S3 File deletion
|