Version Description
- fixed problem with folder include
- added option to deactivate FTP passive mode
- fixed bug for prasing errors because PHP 5 move PHP 5 functions in a seperate file
Download this release
Release Info
Developer | danielhuesken |
Plugin | BackWPup – WordPress Backup Plugin |
Version | 1.3.5 |
Comparing to | |
See all releases |
Code changes from version 1.3.4 to 1.3.5
- app/backwpup_dojob.php +7 -5
- app/functions.php +2 -492
- app/functions5.php +499 -0
- app/options-edit-job.php +1 -0
- app/options-save.php +1 -0
- backwpup.php +2 -2
- readme.txt +9 -1
app/backwpup_dojob.php
CHANGED
@@ -699,7 +699,7 @@ class backwpup_dojob {
|
|
699 |
//Crate file list for includes
|
700 |
foreach($dirinclude as $dirincludevalue) {
|
701 |
if (is_dir($dirincludevalue))
|
702 |
-
$this->_file_list_folder(
|
703 |
}
|
704 |
}
|
705 |
|
@@ -940,10 +940,12 @@ class backwpup_dojob {
|
|
940 |
$this->_ftp_raw_helper($ftp_conn_id,'SYST');
|
941 |
//PASV
|
942 |
trigger_error(__('FTP Client command:','backwpup').' PASV',E_USER_NOTICE);
|
943 |
-
if (
|
944 |
-
|
945 |
-
|
946 |
-
|
|
|
|
|
947 |
//ALLO show no erros in log if do not work
|
948 |
trigger_error(__('FTP Client command:','backwpup').' ALLO',E_USER_NOTICE);
|
949 |
ftp_alloc($ftp_conn_id,filesize($this->backupdir.$this->backupfile),$result);
|
699 |
//Crate file list for includes
|
700 |
foreach($dirinclude as $dirincludevalue) {
|
701 |
if (is_dir($dirincludevalue))
|
702 |
+
$this->_file_list_folder(trailingslashit($dirincludevalue),100,$backwpup_exclude);
|
703 |
}
|
704 |
}
|
705 |
|
940 |
$this->_ftp_raw_helper($ftp_conn_id,'SYST');
|
941 |
//PASV
|
942 |
trigger_error(__('FTP Client command:','backwpup').' PASV',E_USER_NOTICE);
|
943 |
+
if ($this->job['ftppasv']) {
|
944 |
+
if (ftp_pasv($ftp_conn_id, true))
|
945 |
+
trigger_error(__('Server Completion reply: 227 Entering Passive Mode','backwpup'),E_USER_NOTICE);
|
946 |
+
else
|
947 |
+
trigger_error(__('FTP Server reply:','backwpup').' '.__('Can not Entering Passive Mode','backwpup'),E_USER_WARNING);
|
948 |
+
}
|
949 |
//ALLO show no erros in log if do not work
|
950 |
trigger_error(__('FTP Client command:','backwpup').' ALLO',E_USER_NOTICE);
|
951 |
ftp_alloc($ftp_conn_id,filesize($this->backupdir.$this->backupfile),$result);
|
app/functions.php
CHANGED
@@ -192,244 +192,6 @@ if ( !defined('ABSPATH') )
|
|
192 |
echo "<li><a href=\"admin.php?page=BackWPup&subpage=settings\"$settingscurrent>".__('Settings','backwpup')."</a></li>";
|
193 |
echo "</ul>";
|
194 |
}
|
195 |
-
|
196 |
-
|
197 |
-
//Checking,upgrade and default job setting
|
198 |
-
function backwpup_check_job_vars($jobsettings,$jobid='') {
|
199 |
-
global $wpdb;
|
200 |
-
//check job type
|
201 |
-
if (!isset($jobsettings['type']) or !is_string($jobsettings['type']))
|
202 |
-
$jobsettings['type']='DB+FILE';
|
203 |
-
$todo=explode('+',strtoupper($jobsettings['type']));
|
204 |
-
foreach($todo as $key => $value) {
|
205 |
-
if (!in_array($value,backwpup_backup_types()))
|
206 |
-
unset($todo[$key]);
|
207 |
-
}
|
208 |
-
$jobsettings['type']=implode('+',$todo);
|
209 |
-
if (empty($jobsettings['type']))
|
210 |
-
$jobsettings['type']='DB+FILE';
|
211 |
-
|
212 |
-
if (empty($jobsettings['name']) or !is_string($jobsettings['name']))
|
213 |
-
$jobsettings['name']= __('New');
|
214 |
-
|
215 |
-
if (!isset($jobsettings['activated']) or !is_bool($jobsettings['activated']))
|
216 |
-
$jobsettings['activated']=false;
|
217 |
-
|
218 |
-
//upgrade old schedule
|
219 |
-
if (!isset($jobsettings['cron']) and isset($jobsettings['scheduletime']) and isset($jobsettings['scheduleintervaltype']) and isset($jobsettings['scheduleintervalteimes'])) { //Upgrade to cron string
|
220 |
-
if ($jobsettings['scheduleintervaltype']==60) { //Min
|
221 |
-
$jobsettings['cron']='*/'.$jobsettings['scheduleintervalteimes'].' * * * *';
|
222 |
-
}
|
223 |
-
if ($jobsettings['scheduleintervaltype']==3600) { //Houer
|
224 |
-
$jobsettings['cron']=(date('i',$jobsettings['scheduletime'])*1).' */'.$jobsettings['scheduleintervalteimes'].' * * *';
|
225 |
-
}
|
226 |
-
if ($jobsettings['scheduleintervaltype']==86400) { //Days
|
227 |
-
$jobsettings['cron']=(date('i',$jobsettings['scheduletime'])*1).' '.date('G',$jobsettings['scheduletime']).' */'.$jobsettings['scheduleintervalteimes'].' * *';
|
228 |
-
}
|
229 |
-
}
|
230 |
-
|
231 |
-
if (!isset($jobsettings['cron']) or !is_string($jobsettings['cron']))
|
232 |
-
$jobsettings['cron']='0 3 * * *';
|
233 |
-
|
234 |
-
if (!isset($jobsettings['cronnextrun']) or !is_numeric($jobsettings['cronnextrun']))
|
235 |
-
$jobsettings['cronnextrun']=backwpup_cron_next($jobs[$jobid]['cron']);;
|
236 |
-
|
237 |
-
if (!is_string($jobsettings['mailaddresslog']) or false === $pos=strpos($jobsettings['mailaddresslog'],'@') or false === strpos($jobsettings['mailaddresslog'],'.',$pos))
|
238 |
-
$jobsettings['mailaddresslog']=get_option('admin_email');
|
239 |
-
|
240 |
-
if (!isset($jobsettings['mailerroronly']) or !is_bool($jobsettings['mailerroronly']))
|
241 |
-
$jobsettings['mailerroronly']=true;
|
242 |
-
|
243 |
-
if (!isset($jobsettings['dbexclude']) or !is_array($jobsettings['dbexclude'])) {
|
244 |
-
$jobsettings['dbexclude']=array();
|
245 |
-
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
246 |
-
foreach ($tables as $table) {
|
247 |
-
if (substr($table,0,strlen($wpdb->prefix))!=$wpdb->prefix)
|
248 |
-
$jobsettings['dbexclude'][]=$table;
|
249 |
-
}
|
250 |
-
}
|
251 |
-
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
252 |
-
foreach($jobsettings['dbexclude'] as $key => $value) {
|
253 |
-
if (empty($jobsettings['dbexclude'][$key]) or !in_array($value,$tables))
|
254 |
-
unset($jobsettings['dbexclude'][$key]);
|
255 |
-
}
|
256 |
-
sort($jobsettings['dbexclude']);
|
257 |
-
|
258 |
-
if (!isset($jobsettings['dbshortinsert']) or !is_bool($jobsettings['dbshortinsert']))
|
259 |
-
$jobsettings['dbshortinsert']=false;
|
260 |
-
|
261 |
-
if (!isset($jobsettings['maintenance']) or !is_bool($jobsettings['maintenance']))
|
262 |
-
$jobsettings['maintenance']=false;
|
263 |
-
|
264 |
-
if (!isset($jobsettings['fileexclude']) or !is_string($jobsettings['fileexclude']))
|
265 |
-
$jobsettings['fileexclude']='';
|
266 |
-
$fileexclude=explode(',',$jobsettings['fileexclude']);
|
267 |
-
foreach($fileexclude as $key => $value) {
|
268 |
-
$fileexclude[$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
269 |
-
if (empty($fileexclude[$key]))
|
270 |
-
unset($fileexclude[$key]);
|
271 |
-
}
|
272 |
-
sort($fileexclude);
|
273 |
-
$jobsettings['fileexclude']=implode(',',$fileexclude);
|
274 |
-
|
275 |
-
if (!isset($jobsettings['dirinclude']) or !is_string($jobsettings['dirinclude']))
|
276 |
-
$jobsettings['dirinclude']='';
|
277 |
-
$dirinclude=explode(',',$jobsettings['dirinclude']);
|
278 |
-
foreach($dirinclude as $key => $value) {
|
279 |
-
$dirinclude[$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
280 |
-
if (empty($dirinclude[$key]) or !is_dir($dirinclude[$key]))
|
281 |
-
unset($dirinclude[$key]);
|
282 |
-
}
|
283 |
-
sort($dirinclude);
|
284 |
-
$jobsettings['dirinclude']=implode(',',$dirinclude);
|
285 |
-
|
286 |
-
if (!isset($jobsettings['backuproot']) or !is_bool($jobsettings['backuproot']))
|
287 |
-
$jobsettings['backuproot']=true;
|
288 |
-
|
289 |
-
if (!isset($jobsettings['backupcontent']) or !is_bool($jobsettings['backupcontent']))
|
290 |
-
$jobsettings['backupcontent']=true;
|
291 |
-
|
292 |
-
if (!isset($jobsettings['backupplugins']) or !is_bool($jobsettings['backupplugins']))
|
293 |
-
$jobsettings['backupplugins']=true;
|
294 |
-
|
295 |
-
if (!isset($jobsettings['backupthemes']) or !is_bool($jobsettings['backupthemes']))
|
296 |
-
$jobsettings['backupthemes']=true;
|
297 |
-
|
298 |
-
if (!isset($jobsettings['backupuploads']) or !is_bool($jobsettings['backupuploads']))
|
299 |
-
$jobsettings['backupuploads']=true;
|
300 |
-
|
301 |
-
if (!isset($jobsettings['backuprootexcludedirs']) or !is_array($jobsettings['backuprootexcludedirs']))
|
302 |
-
$jobsettings['backuprootexcludedirs']=array();
|
303 |
-
foreach($jobsettings['backuprootexcludedirs'] as $key => $value) {
|
304 |
-
$jobsettings['backuprootexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
305 |
-
if (empty($jobsettings['backuprootexcludedirs'][$key]) or $jobsettings['backuprootexcludedirs'][$key]=='/' or !is_dir($jobsettings['backuprootexcludedirs'][$key]))
|
306 |
-
unset($jobsettings['backuprootexcludedirs'][$key]);
|
307 |
-
}
|
308 |
-
sort($jobsettings['backuprootexcludedirs']);
|
309 |
-
|
310 |
-
if (!isset($jobsettings['backupcontentexcludedirs']) or !is_array($jobsettings['backupcontentexcludedirs']))
|
311 |
-
$jobsettings['backupcontentexcludedirs']=array();
|
312 |
-
foreach($jobsettings['backupcontentexcludedirs'] as $key => $value) {
|
313 |
-
$jobsettings['backupcontentexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
314 |
-
if (empty($jobsettings['backupcontentexcludedirs'][$key]) or $jobsettings['backupcontentexcludedirs'][$key]=='/' or !is_dir($jobsettings['backupcontentexcludedirs'][$key]))
|
315 |
-
unset($jobsettings['backupcontentexcludedirs'][$key]);
|
316 |
-
}
|
317 |
-
sort($jobsettings['backupcontentexcludedirs']);
|
318 |
-
|
319 |
-
if (!isset($jobsettings['backuppluginsexcludedirs']) or !is_array($jobsettings['backuppluginsexcludedirs']))
|
320 |
-
$jobsettings['backuppluginsexcludedirs']=array();
|
321 |
-
foreach($jobsettings['backuppluginsexcludedirs'] as $key => $value) {
|
322 |
-
$jobsettings['backuppluginsexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
323 |
-
if (empty($jobsettings['backuppluginsexcludedirs'][$key]) or $jobsettings['backuppluginsexcludedirs'][$key]=='/' or !is_dir($jobsettings['backuppluginsexcludedirs'][$key]))
|
324 |
-
unset($jobsettings['backuppluginsexcludedirs'][$key]);
|
325 |
-
}
|
326 |
-
sort($jobsettings['backuppluginsexcludedirs']);
|
327 |
-
|
328 |
-
if (!isset($jobsettings['backupthemesexcludedirs']) or !is_array($jobsettings['backupthemesexcludedirs']))
|
329 |
-
$jobsettings['backupthemesexcludedirs']=array();
|
330 |
-
foreach($jobsettings['backupthemesexcludedirs'] as $key => $value) {
|
331 |
-
$jobsettings['backupthemesexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
332 |
-
if (empty($jobsettings['backupthemesexcludedirs'][$key]) or $jobsettings['backupthemesexcludedirs'][$key]=='/' or !is_dir($jobsettings['backupthemesexcludedirs'][$key]))
|
333 |
-
unset($jobsettings['backupthemesexcludedirs'][$key]);
|
334 |
-
}
|
335 |
-
sort($jobsettings['backupthemesexcludedirs']);
|
336 |
-
|
337 |
-
if (!isset($jobsettings['backupuploadsexcludedirs']) or !is_array($jobsettings['backupuploadsexcludedirs']))
|
338 |
-
$jobsettings['backupuploadsexcludedirs']=array();
|
339 |
-
foreach($jobsettings['backupuploadsexcludedirs'] as $key => $value) {
|
340 |
-
$jobsettings['backupuploadsexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
341 |
-
if (empty($jobsettings['backupuploadsexcludedirs'][$key]) or $jobsettings['backupuploadsexcludedirs'][$key]=='/' or !is_dir($jobsettings['backupuploadsexcludedirs'][$key]))
|
342 |
-
unset($jobsettings['backupuploadsexcludedirs'][$key]);
|
343 |
-
}
|
344 |
-
sort($jobsettings['backupuploadsexcludedirs']);
|
345 |
-
|
346 |
-
$fileformarts=array('.zip','.tar.gz','.tar.bz2','.tar');
|
347 |
-
if (!isset($jobsettings['fileformart']) or !in_array($jobsettings['fileformart'],$fileformarts))
|
348 |
-
$jobsettings['fileformart']='.zip';
|
349 |
-
|
350 |
-
if (!isset($jobsettings['fileprefix']) or !is_string($jobsettings['fileprefix']))
|
351 |
-
$jobsettings['fileprefix']='backwpup_'.$jobid.'_';
|
352 |
-
|
353 |
-
if (!isset($jobsettings['mailefilesize']) or !is_float($jobsettings['mailefilesize']))
|
354 |
-
$jobsettings['mailefilesize']=0;
|
355 |
-
|
356 |
-
if (!isset($jobsettings['backupdir']) or (!is_dir($jobsettings['backupdir']) and !empty($jobsettings['backupdir']))) {
|
357 |
-
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
358 |
-
$jobsettings['backupdir']=str_replace('\\','/',trailingslashit(WP_CONTENT_DIR)).'backwpup-'.$rand.'/';
|
359 |
-
}
|
360 |
-
$jobsettings['backupdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['backupdir']))));
|
361 |
-
if ($jobsettings['backupdir']=='/')
|
362 |
-
$jobsettings['backupdir']='';
|
363 |
-
|
364 |
-
if (!isset($jobsettings['maxbackups']) or !is_int($jobsettings['maxbackups']))
|
365 |
-
$jobsettings['maxbackups']=0;
|
366 |
-
|
367 |
-
if (!isset($jobsettings['ftphost']) or !is_string($jobsettings['ftphost']))
|
368 |
-
$jobsettings['ftphost']='';
|
369 |
-
|
370 |
-
if (!isset($jobsettings['ftpuser']) or !is_string($jobsettings['ftpuser']))
|
371 |
-
$jobsettings['ftpuser']='';
|
372 |
-
|
373 |
-
if (!isset($jobsettings['ftppass']) or !is_string($jobsettings['ftppass']))
|
374 |
-
$jobsettings['ftppass']='';
|
375 |
-
|
376 |
-
if (!isset($jobsettings['ftpdir']) or !is_string($jobsettings['ftpdir']) or $jobsettings['ftpdir']=='/')
|
377 |
-
$jobsettings['ftpdir']='';
|
378 |
-
$jobsettings['ftpdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['ftpdir']))));
|
379 |
-
if (substr($jobsettings['ftpdir'],0,1)!='/')
|
380 |
-
$jobsettings['ftpdir']='/'.$jobsettings['ftpdir'];
|
381 |
-
|
382 |
-
if (!isset($jobsettings['ftpmaxbackups']) or !is_int($jobsettings['ftpmaxbackups']))
|
383 |
-
$jobsettings['ftpmaxbackups']=0;
|
384 |
-
|
385 |
-
if (!isset($jobsettings['awsAccessKey']) or !is_string($jobsettings['awsAccessKey']))
|
386 |
-
$jobsettings['awsAccessKey']='';
|
387 |
-
|
388 |
-
if (!isset($jobsettings['awsSecretKey']) or !is_string($jobsettings['awsSecretKey']))
|
389 |
-
$jobsettings['awsSecretKey']='';
|
390 |
-
|
391 |
-
if (!isset($jobsettings['awsSSL']) or !is_bool($jobsettings['awsSSL']))
|
392 |
-
$jobsettings['awsSSL']=true;
|
393 |
-
|
394 |
-
if (!isset($jobsettings['awsrrs']) or !is_bool($jobsettings['awsrrs']))
|
395 |
-
$jobsettings['awsrrs']=false;
|
396 |
-
|
397 |
-
if (!isset($jobsettings['awsBucket']) or !is_string($jobsettings['awsBucket']))
|
398 |
-
$jobsettings['awsBucket']='';
|
399 |
-
|
400 |
-
if (!isset($jobsettings['awsdir']) or !is_string($jobsettings['awsdir']) or $jobsettings['awsdir']=='/')
|
401 |
-
$jobsettings['awsdir']='';
|
402 |
-
$jobsettings['awsdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['awsdir']))));
|
403 |
-
if (substr($jobsettings['awsdir'],0,1)=='/')
|
404 |
-
$jobsettings['awsdir']=substr($jobsettings['awsdir'],1);
|
405 |
-
|
406 |
-
if (!isset($jobsettings['awsmaxbackups']) or !is_int($jobsettings['awsmaxbackups']))
|
407 |
-
$jobsettings['awsmaxbackups']=0;
|
408 |
-
|
409 |
-
if (!isset($jobsettings['rscUsername']) or !is_string($jobsettings['rscUsername']))
|
410 |
-
$jobsettings['rscUsername']='';
|
411 |
-
|
412 |
-
if (!isset($jobsettings['rscAPIKey']) or !is_string($jobsettings['rscAPIKey']))
|
413 |
-
$jobsettings['rscAPIKey']='';
|
414 |
-
|
415 |
-
if (!isset($jobsettings['rscContainer']) or !is_string($jobsettings['rscContainer']))
|
416 |
-
$jobsettings['rscContainer']='';
|
417 |
-
|
418 |
-
if (!isset($jobsettings['rscdir']) or !is_string($jobsettings['rscdir']) or $jobsettings['rscdir']=='/')
|
419 |
-
$jobsettings['rscdir']='';
|
420 |
-
$jobsettings['rscdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['rscdir']))));
|
421 |
-
if (substr($jobsettings['rscdir'],0,1)=='/')
|
422 |
-
$jobsettings['rscdir']=substr($jobsettings['rscdir'],1);
|
423 |
-
|
424 |
-
if (!isset($jobsettings['rscmaxbackups']) or !is_int($jobsettings['rscmaxbackups']))
|
425 |
-
$jobsettings['rscmaxbackups']=0;
|
426 |
-
|
427 |
-
if (!is_string($jobsettings['mailaddress']) or false === $pos=strpos($jobsettings['mailaddress'],'@') or false === strpos($jobsettings['mailaddress'],'.',$pos))
|
428 |
-
$jobsettings['mailaddress']='';
|
429 |
-
|
430 |
-
return $jobsettings;
|
431 |
-
}
|
432 |
-
|
433 |
|
434 |
//On Plugin activate
|
435 |
function backwpup_plugin_activate() {
|
@@ -794,260 +556,6 @@ if ( !defined('ABSPATH') )
|
|
794 |
|
795 |
}
|
796 |
|
797 |
-
//ajax/normal get backup files and infos
|
798 |
-
function backwpup_get_backup_files() {
|
799 |
-
$jobs=(array)get_option('backwpup_jobs'); //Load jobs
|
800 |
-
$filecounter=0;
|
801 |
-
$files=array();
|
802 |
-
$donefolders=array();
|
803 |
-
if (extension_loaded('curl') or @dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll')) {
|
804 |
-
if (!class_exists('S3'))
|
805 |
-
include_once('libs/S3.php');
|
806 |
-
if (!class_exists('CF_Authentication'))
|
807 |
-
include_once('libs/rackspace/cloudfiles.php');
|
808 |
-
}
|
809 |
-
|
810 |
-
foreach ($jobs as $jobid => $jobvalue) { //go job by job
|
811 |
-
$jobvalue=backwpup_check_job_vars($jobvalue,$jobid); //Check job values
|
812 |
-
$todo=explode('+',$jobvalue['type']); //only for backup jobs
|
813 |
-
if (!in_array('FILE',$todo) and !in_array('DB',$todo) and !in_array('WPEXP',$todo))
|
814 |
-
continue;
|
815 |
-
|
816 |
-
//Get files/filinfo in backup folder
|
817 |
-
if (!empty($jobvalue['backupdir']) and !in_array($jobvalue['backupdir'],$donefolders)) {
|
818 |
-
if ( $dir = @opendir( $jobvalue['backupdir'] ) ) {
|
819 |
-
while (($file = readdir( $dir ) ) !== false ) {
|
820 |
-
if (substr($file,0,1)=='.' or !(strtolower(substr($file,-4))=='.zip' or strtolower(substr($file,-4))=='.tar' or strtolower(substr($file,-7))=='.tar.gz' or strtolower(substr($file,-8))=='.tar.bz2'))
|
821 |
-
continue;
|
822 |
-
if (is_file($jobvalue['backupdir'].$file)) {
|
823 |
-
$files[$filecounter]['type']='FOLDER';
|
824 |
-
$files[$filecounter]['jobid']=$jobid;
|
825 |
-
$files[$filecounter]['file']=$jobvalue['backupdir'].$file;
|
826 |
-
$files[$filecounter]['filename']=$file;
|
827 |
-
$files[$filecounter]['downloadurl']=wp_nonce_url('admin.php?page=BackWPup&subpage=backups&action=download&file='.$jobvalue['backupdir'].$file, 'download-backup_'.$file);
|
828 |
-
$files[$filecounter]['filesize']=filesize($jobvalue['backupdir'].$file);
|
829 |
-
$files[$filecounter]['time']=filemtime($jobvalue['backupdir'].$file);
|
830 |
-
$filecounter++;
|
831 |
-
}
|
832 |
-
}
|
833 |
-
closedir( $dir );
|
834 |
-
$donefolders[]=$jobvalue['backupdir'];
|
835 |
-
}
|
836 |
-
}
|
837 |
-
//Get files/filinfo from S3
|
838 |
-
if (class_exists('S3') and !in_array($jobvalue['awsAccessKey'].'|'.$jobvalue['awsBucket'].'|'.$jobvalue['awsdir'],$donefolders)) {
|
839 |
-
if (!empty($jobvalue['awsAccessKey']) and !empty($jobvalue['awsSecretKey']) and !empty($jobvalue['awsBucket'])) {
|
840 |
-
$s3 = new S3($jobvalue['awsAccessKey'], $jobvalue['awsSecretKey'], $jobvalue['awsSSL']);
|
841 |
-
if (($contents = $s3->getBucket($jobvalue['awsBucket'],$jobvalue['awsdir'])) !== false) {
|
842 |
-
foreach ($contents as $object) {
|
843 |
-
if (strtolower(substr($object['name'],-4))=='.zip' or strtolower(substr($object['name'],-4))=='.tar' or strtolower(substr($object['name'],-7))=='.tar.gz' or strtolower(substr($object['name'],-8))=='.tar.bz2') {
|
844 |
-
$files[$filecounter]['type']='S3';
|
845 |
-
$files[$filecounter]['jobid']=$jobid;
|
846 |
-
$files[$filecounter]['file']=$object['name'];
|
847 |
-
$files[$filecounter]['filename']=basename($object['name']);
|
848 |
-
$files[$filecounter]['downloadurl']=wp_nonce_url('admin.php?page=BackWPup&subpage=backups&action=downloads3&file='.$object['name'].'&jobid='.$jobid, 'downloads3-backup_'.$object['name']);
|
849 |
-
$files[$filecounter]['filesize']=$object['size'];
|
850 |
-
$files[$filecounter]['time']=$object['time'];
|
851 |
-
$filecounter++;
|
852 |
-
}
|
853 |
-
}
|
854 |
-
}
|
855 |
-
$donefolders[]=$jobvalue['awsAccessKey'].'|'.$jobvalue['awsBucket'].'|'.$jobvalue['awsdir'];
|
856 |
-
}
|
857 |
-
}
|
858 |
-
//Get files/filinfo from RSC
|
859 |
-
if (class_exists('CF_Authentication') and !in_array($jobvalue['rscUsername'].'|'.$jobvalue['rscContainer'].'|'.$jobvalue['rscdir'],$donefolders)) {
|
860 |
-
if (!empty($jobvalue['rscUsername']) and !empty($jobvalue['rscAPIKey']) and !empty($jobvalue['rscContainer'])) {
|
861 |
-
$auth = new CF_Authentication($jobvalue['rscUsername'], $jobvalue['rscAPIKey']);
|
862 |
-
$auth->ssl_use_cabundle();
|
863 |
-
if ($auth->authenticate()) {
|
864 |
-
$conn = new CF_Connection($auth);
|
865 |
-
$conn->ssl_use_cabundle();
|
866 |
-
$backwpupcontainer = $conn->get_container($jobvalue['rscContainer']);
|
867 |
-
$contents = $backwpupcontainer->get_objects(0,NULL,NULL,$jobvalue['rscdir']);
|
868 |
-
foreach ($contents as $object) {
|
869 |
-
if (strtolower(substr($object->name,-4))=='.zip' or strtolower(substr($object->name,-4))=='.tar' or strtolower(substr($object->name,-7))=='.tar.gz' or strtolower(substr($object->name,-8))=='.tar.bz2') {
|
870 |
-
$files[$filecounter]['type']='RSC';
|
871 |
-
$files[$filecounter]['jobid']=$jobid;
|
872 |
-
$files[$filecounter]['file']=$object->name;
|
873 |
-
$files[$filecounter]['filename']=basename($object->name);
|
874 |
-
$files[$filecounter]['downloadurl']=wp_nonce_url('admin.php?page=BackWPup&subpage=backups&action=downloadrsc&file='.$object->name.'&jobid='.$jobid, 'downloadrsc-backup_'.$object->name);
|
875 |
-
$files[$filecounter]['filesize']=$object->content_length;
|
876 |
-
$files[$filecounter]['time']=$object->last_modified;
|
877 |
-
$filecounter++;
|
878 |
-
}
|
879 |
-
}
|
880 |
-
$donefolders[]=$jobvalue['rscUsername'].'|'.$jobvalue['rscContainer'].'|'.$jobvalue['rscdir'];
|
881 |
-
}
|
882 |
-
}
|
883 |
-
}
|
884 |
-
//Get files/filinfo from FTP
|
885 |
-
if (!empty($jobvalue['ftphost']) and !empty($jobvalue['ftpuser']) and !empty($jobvalue['ftppass']) and !in_array($jobvalue['ftphost'].'|'.$jobvalue['ftpuser'].'|'.$jobvalue['ftpdir'],$donefolders)) {
|
886 |
-
$ftpport=21;
|
887 |
-
$ftphost=$jobvalue['ftphost'];
|
888 |
-
if (false !== strpos($jobvalue['ftphost'],':')) //look for port
|
889 |
-
list($ftphost,$ftpport)=explode(':',$jobvalue,2);
|
890 |
-
|
891 |
-
$SSL=false;
|
892 |
-
if (function_exists('ftp_ssl_connect')) { //make SSL FTP connection
|
893 |
-
$ftp_conn_id = ftp_ssl_connect($ftphost,$ftpport,10);
|
894 |
-
if ($ftp_conn_id)
|
895 |
-
$SSL=true;
|
896 |
-
}
|
897 |
-
if (!$ftp_conn_id) { //make normal FTP conection if SSL not work
|
898 |
-
$ftp_conn_id = ftp_connect($ftphost,$ftpport,10);
|
899 |
-
}
|
900 |
-
if ($ftp_conn_id) {
|
901 |
-
//FTP Login
|
902 |
-
$loginok=false;
|
903 |
-
if (@ftp_login($ftp_conn_id, $jobvalue['ftpuser'], base64_decode($jobvalue['ftppass']))) {
|
904 |
-
$loginok=true;
|
905 |
-
} else { //if PHP ftp login don't work use raw login
|
906 |
-
if (substr(trim(ftp_raw($ftp_conn_id,'USER '.$jobvalue['ftpuser'])),0,3)<400) {
|
907 |
-
if (substr(trim(ftp_raw($ftp_conn_id,'PASS '.base64_decode($jobvalue['ftppass']))),0,3)<400) {
|
908 |
-
$loginok=true;
|
909 |
-
}
|
910 |
-
}
|
911 |
-
}
|
912 |
-
}
|
913 |
-
if ($loginok) {
|
914 |
-
ftp_pasv($ftp_conn_id, true);
|
915 |
-
if ($ftpfilelist=ftp_nlist($ftp_conn_id, $jobvalue['ftpdir'])) {
|
916 |
-
foreach($ftpfilelist as $ftpfiles) {
|
917 |
-
if (substr(basename($ftpfiles),0,1)=='.' or !(strtolower(substr($ftpfiles,-4))=='.zip' or strtolower(substr($ftpfiles,-4))=='.tar' or strtolower(substr($ftpfiles,-7))=='.tar.gz' or strtolower(substr($ftpfiles,-8))=='.tar.bz2'))
|
918 |
-
continue;
|
919 |
-
$files[$filecounter]['type']='FTP';
|
920 |
-
$files[$filecounter]['jobid']=$jobid;
|
921 |
-
$files[$filecounter]['file']=$ftpfiles;
|
922 |
-
$files[$filecounter]['filename']=basename($ftpfiles);
|
923 |
-
$files[$filecounter]['downloadurl']="ftp://".$jobvalue['ftpuser'].":".base64_decode($jobvalue['ftppass'])."@".$jobvalue['ftphost'].$ftpfiles;
|
924 |
-
$files[$filecounter]['filesize']=ftp_size($ftp_conn_id,$ftpfiles);
|
925 |
-
if ('backwpup_log_' == substr(basename($ftpfiles),0,strlen('backwpup_log_'))) {
|
926 |
-
$filnameparts=explode('_',substr(basename($ftpfiles),0,strpos(basename($ftpfiles),'.')));
|
927 |
-
$files[$filecounter]['time']=strtotime($filnameparts[2].' '.str_replace('-',':',$filnameparts[3]));
|
928 |
-
}
|
929 |
-
$filecounter++;
|
930 |
-
}
|
931 |
-
}
|
932 |
-
}
|
933 |
-
$donefolders[]=$jobvalue['ftphost'].'|'.$jobvalue['ftpuser'].'|'.$jobvalue['ftpdir'];
|
934 |
-
}
|
935 |
-
}
|
936 |
-
//Sort list
|
937 |
-
$tmp = Array();
|
938 |
-
foreach($files as $ma)
|
939 |
-
$tmp[] = $ma["time"];
|
940 |
-
array_multisort($tmp, SORT_DESC, $files);
|
941 |
-
return $files;
|
942 |
-
}
|
943 |
-
|
944 |
-
//ajax/normal get buckests select box
|
945 |
-
function backwpup_get_aws_buckets($args='') {
|
946 |
-
if (is_array($args)) {
|
947 |
-
extract($args);
|
948 |
-
$ajax=false;
|
949 |
-
} else {
|
950 |
-
$awsAccessKey=$_POST['awsAccessKey'];
|
951 |
-
$awsSecretKey=$_POST['awsSecretKey'];
|
952 |
-
$awsselected=$_POST['awsselected'];
|
953 |
-
$ajax=true;
|
954 |
-
}
|
955 |
-
if (!class_exists('S3'))
|
956 |
-
include_once('libs/S3.php');
|
957 |
-
if (empty($awsAccessKey)) {
|
958 |
-
echo '<span id="awsBucket" style="color:red;">'.__('Missing Access Key ID!','backwpup').'</span>';
|
959 |
-
if ($ajax)
|
960 |
-
die();
|
961 |
-
else
|
962 |
-
return;
|
963 |
-
}
|
964 |
-
if (empty($awsSecretKey)) {
|
965 |
-
echo '<span id="awsBucket" style="color:red;">'.__('Missing Secret Access Key!','backwpup').'</span>';
|
966 |
-
if ($ajax)
|
967 |
-
die();
|
968 |
-
else
|
969 |
-
return;
|
970 |
-
}
|
971 |
-
$s3 = new S3($awsAccessKey, $awsSecretKey, false);
|
972 |
-
$buckets=@$s3->listBuckets();
|
973 |
-
if (!is_array($buckets)) {
|
974 |
-
echo '<span id="awsBucket" style="color:red;">'.__('No Buckets found! Or wrong Keys!','backwpup').'</span>';
|
975 |
-
if ($ajax)
|
976 |
-
die();
|
977 |
-
else
|
978 |
-
return;
|
979 |
-
}
|
980 |
-
echo '<select name="awsBucket" id="awsBucket">';
|
981 |
-
foreach ($buckets as $bucket) {
|
982 |
-
echo "<option ".selected(strtolower($awsselected),strtolower($bucket),false).">".$bucket."</option>";
|
983 |
-
}
|
984 |
-
echo '</select>';
|
985 |
-
if ($ajax)
|
986 |
-
die();
|
987 |
-
else
|
988 |
-
return;
|
989 |
-
}
|
990 |
-
|
991 |
-
//ajax/normal get Container for RSC select box
|
992 |
-
function backwpup_get_rsc_container($args='') {
|
993 |
-
if (is_array($args)) {
|
994 |
-
extract($args);
|
995 |
-
$ajax=false;
|
996 |
-
} else {
|
997 |
-
$rscUsername=$_POST['rscUsername'];
|
998 |
-
$rscAPIKey=$_POST['rscAPIKey'];
|
999 |
-
$rscselected=$_POST['rscselected'];
|
1000 |
-
$ajax=true;
|
1001 |
-
}
|
1002 |
-
if (!class_exists('CF_Authentication'))
|
1003 |
-
include_once('libs/rackspace/cloudfiles.php');
|
1004 |
-
|
1005 |
-
if (empty($rscUsername)) {
|
1006 |
-
echo '<span id="rscContainer" style="color:red;">'.__('Missing Username!','backwpup').'</span>';
|
1007 |
-
if ($ajax)
|
1008 |
-
die();
|
1009 |
-
else
|
1010 |
-
return;
|
1011 |
-
}
|
1012 |
-
if (empty($rscAPIKey)) {
|
1013 |
-
echo '<span id="rscContainer" style="color:red;">'.__('Missing API Key!','backwpup').'</span>';
|
1014 |
-
if ($ajax)
|
1015 |
-
die();
|
1016 |
-
else
|
1017 |
-
return;
|
1018 |
-
}
|
1019 |
-
$auth = new CF_Authentication($rscUsername, $rscAPIKey);
|
1020 |
-
|
1021 |
-
try {
|
1022 |
-
$auth->authenticate();
|
1023 |
-
$conn = new CF_Connection($auth);
|
1024 |
-
$containers=$conn->get_containers();
|
1025 |
-
} catch (Exception $e) {
|
1026 |
-
echo '<span id="rscContainer" style="color:red;">'.__($e->getMessage(),'backwpup').'</span>';
|
1027 |
-
if ($ajax)
|
1028 |
-
die();
|
1029 |
-
else
|
1030 |
-
return;
|
1031 |
-
}
|
1032 |
-
|
1033 |
-
if (!is_array($containers)) {
|
1034 |
-
echo '<span id="rscContainer" style="color:red;">'.__('No Containerss found!','backwpup').'</span>';
|
1035 |
-
if ($ajax)
|
1036 |
-
die();
|
1037 |
-
else
|
1038 |
-
return;
|
1039 |
-
}
|
1040 |
-
echo '<select name="rscContainer" id="rscContainer">';
|
1041 |
-
foreach ($containers as $container) {
|
1042 |
-
echo "<option ".selected(strtolower($rscselected),strtolower($container->name),false).">".$container->name."</option>";
|
1043 |
-
}
|
1044 |
-
echo '</select>';
|
1045 |
-
if ($ajax)
|
1046 |
-
die();
|
1047 |
-
else
|
1048 |
-
return;
|
1049 |
-
}
|
1050 |
-
|
1051 |
//Calcs next run for a cron string as timestamp
|
1052 |
function backwpup_cron_next($cronstring) {
|
1053 |
//Cronstring zerlegen
|
@@ -1222,6 +730,8 @@ if ( !defined('ABSPATH') )
|
|
1222 |
function backwpup_plugins_loaded() {
|
1223 |
if (!backwpup_env_checks())
|
1224 |
return;
|
|
|
|
|
1225 |
//Disabele WP_Corn
|
1226 |
$cfg=get_option('backwpup');
|
1227 |
if ($cfg['disablewpcron'])
|
192 |
echo "<li><a href=\"admin.php?page=BackWPup&subpage=settings\"$settingscurrent>".__('Settings','backwpup')."</a></li>";
|
193 |
echo "</ul>";
|
194 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
|
196 |
//On Plugin activate
|
197 |
function backwpup_plugin_activate() {
|
556 |
|
557 |
}
|
558 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
559 |
//Calcs next run for a cron string as timestamp
|
560 |
function backwpup_cron_next($cronstring) {
|
561 |
//Cronstring zerlegen
|
730 |
function backwpup_plugins_loaded() {
|
731 |
if (!backwpup_env_checks())
|
732 |
return;
|
733 |
+
//iclude php5 functions
|
734 |
+
include_once('functions5.php');
|
735 |
//Disabele WP_Corn
|
736 |
$cfg=get_option('backwpup');
|
737 |
if ($cfg['disablewpcron'])
|
app/functions5.php
ADDED
@@ -0,0 +1,499 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?PHP
|
2 |
+
// don't load directly
|
3 |
+
if ( !defined('ABSPATH') )
|
4 |
+
die('-1');
|
5 |
+
|
6 |
+
//Checking,upgrade and default job setting
|
7 |
+
function backwpup_check_job_vars($jobsettings,$jobid='') {
|
8 |
+
global $wpdb;
|
9 |
+
//check job type
|
10 |
+
if (!isset($jobsettings['type']) or !is_string($jobsettings['type']))
|
11 |
+
$jobsettings['type']='DB+FILE';
|
12 |
+
$todo=explode('+',strtoupper($jobsettings['type']));
|
13 |
+
foreach($todo as $key => $value) {
|
14 |
+
if (!in_array($value,backwpup_backup_types()))
|
15 |
+
unset($todo[$key]);
|
16 |
+
}
|
17 |
+
$jobsettings['type']=implode('+',$todo);
|
18 |
+
if (empty($jobsettings['type']))
|
19 |
+
$jobsettings['type']='DB+FILE';
|
20 |
+
|
21 |
+
if (empty($jobsettings['name']) or !is_string($jobsettings['name']))
|
22 |
+
$jobsettings['name']= __('New');
|
23 |
+
|
24 |
+
if (!isset($jobsettings['activated']) or !is_bool($jobsettings['activated']))
|
25 |
+
$jobsettings['activated']=false;
|
26 |
+
|
27 |
+
//upgrade old schedule
|
28 |
+
if (!isset($jobsettings['cron']) and isset($jobsettings['scheduletime']) and isset($jobsettings['scheduleintervaltype']) and isset($jobsettings['scheduleintervalteimes'])) { //Upgrade to cron string
|
29 |
+
if ($jobsettings['scheduleintervaltype']==60) { //Min
|
30 |
+
$jobsettings['cron']='*/'.$jobsettings['scheduleintervalteimes'].' * * * *';
|
31 |
+
}
|
32 |
+
if ($jobsettings['scheduleintervaltype']==3600) { //Houer
|
33 |
+
$jobsettings['cron']=(date('i',$jobsettings['scheduletime'])*1).' */'.$jobsettings['scheduleintervalteimes'].' * * *';
|
34 |
+
}
|
35 |
+
if ($jobsettings['scheduleintervaltype']==86400) { //Days
|
36 |
+
$jobsettings['cron']=(date('i',$jobsettings['scheduletime'])*1).' '.date('G',$jobsettings['scheduletime']).' */'.$jobsettings['scheduleintervalteimes'].' * *';
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
if (!isset($jobsettings['cron']) or !is_string($jobsettings['cron']))
|
41 |
+
$jobsettings['cron']='0 3 * * *';
|
42 |
+
|
43 |
+
if (!isset($jobsettings['cronnextrun']) or !is_numeric($jobsettings['cronnextrun']))
|
44 |
+
$jobsettings['cronnextrun']=backwpup_cron_next($jobs[$jobid]['cron']);;
|
45 |
+
|
46 |
+
if (!is_string($jobsettings['mailaddresslog']) or false === $pos=strpos($jobsettings['mailaddresslog'],'@') or false === strpos($jobsettings['mailaddresslog'],'.',$pos))
|
47 |
+
$jobsettings['mailaddresslog']=get_option('admin_email');
|
48 |
+
|
49 |
+
if (!isset($jobsettings['mailerroronly']) or !is_bool($jobsettings['mailerroronly']))
|
50 |
+
$jobsettings['mailerroronly']=true;
|
51 |
+
|
52 |
+
if (!isset($jobsettings['dbexclude']) or !is_array($jobsettings['dbexclude'])) {
|
53 |
+
$jobsettings['dbexclude']=array();
|
54 |
+
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
55 |
+
foreach ($tables as $table) {
|
56 |
+
if (substr($table,0,strlen($wpdb->prefix))!=$wpdb->prefix)
|
57 |
+
$jobsettings['dbexclude'][]=$table;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
$tables=$wpdb->get_col('SHOW TABLES FROM `'.DB_NAME.'`');
|
61 |
+
foreach($jobsettings['dbexclude'] as $key => $value) {
|
62 |
+
if (empty($jobsettings['dbexclude'][$key]) or !in_array($value,$tables))
|
63 |
+
unset($jobsettings['dbexclude'][$key]);
|
64 |
+
}
|
65 |
+
sort($jobsettings['dbexclude']);
|
66 |
+
|
67 |
+
if (!isset($jobsettings['dbshortinsert']) or !is_bool($jobsettings['dbshortinsert']))
|
68 |
+
$jobsettings['dbshortinsert']=false;
|
69 |
+
|
70 |
+
if (!isset($jobsettings['maintenance']) or !is_bool($jobsettings['maintenance']))
|
71 |
+
$jobsettings['maintenance']=false;
|
72 |
+
|
73 |
+
if (!isset($jobsettings['fileexclude']) or !is_string($jobsettings['fileexclude']))
|
74 |
+
$jobsettings['fileexclude']='';
|
75 |
+
$fileexclude=explode(',',$jobsettings['fileexclude']);
|
76 |
+
foreach($fileexclude as $key => $value) {
|
77 |
+
$fileexclude[$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
78 |
+
if (empty($fileexclude[$key]))
|
79 |
+
unset($fileexclude[$key]);
|
80 |
+
}
|
81 |
+
sort($fileexclude);
|
82 |
+
$jobsettings['fileexclude']=implode(',',$fileexclude);
|
83 |
+
|
84 |
+
if (!isset($jobsettings['dirinclude']) or !is_string($jobsettings['dirinclude']))
|
85 |
+
$jobsettings['dirinclude']='';
|
86 |
+
$dirinclude=explode(',',$jobsettings['dirinclude']);
|
87 |
+
foreach($dirinclude as $key => $value) {
|
88 |
+
$dirinclude[$key]=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($value))));
|
89 |
+
if ($dirinclude[$key]=='/' or empty($dirinclude[$key]) or !is_dir($dirinclude[$key]))
|
90 |
+
unset($dirinclude[$key]);
|
91 |
+
}
|
92 |
+
sort($dirinclude);
|
93 |
+
$jobsettings['dirinclude']=implode(',',$dirinclude);
|
94 |
+
|
95 |
+
if (!isset($jobsettings['backuproot']) or !is_bool($jobsettings['backuproot']))
|
96 |
+
$jobsettings['backuproot']=true;
|
97 |
+
|
98 |
+
if (!isset($jobsettings['backupcontent']) or !is_bool($jobsettings['backupcontent']))
|
99 |
+
$jobsettings['backupcontent']=true;
|
100 |
+
|
101 |
+
if (!isset($jobsettings['backupplugins']) or !is_bool($jobsettings['backupplugins']))
|
102 |
+
$jobsettings['backupplugins']=true;
|
103 |
+
|
104 |
+
if (!isset($jobsettings['backupthemes']) or !is_bool($jobsettings['backupthemes']))
|
105 |
+
$jobsettings['backupthemes']=true;
|
106 |
+
|
107 |
+
if (!isset($jobsettings['backupuploads']) or !is_bool($jobsettings['backupuploads']))
|
108 |
+
$jobsettings['backupuploads']=true;
|
109 |
+
|
110 |
+
if (!isset($jobsettings['backuprootexcludedirs']) or !is_array($jobsettings['backuprootexcludedirs']))
|
111 |
+
$jobsettings['backuprootexcludedirs']=array();
|
112 |
+
foreach($jobsettings['backuprootexcludedirs'] as $key => $value) {
|
113 |
+
$jobsettings['backuprootexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
114 |
+
if (empty($jobsettings['backuprootexcludedirs'][$key]) or $jobsettings['backuprootexcludedirs'][$key]=='/' or !is_dir($jobsettings['backuprootexcludedirs'][$key]))
|
115 |
+
unset($jobsettings['backuprootexcludedirs'][$key]);
|
116 |
+
}
|
117 |
+
sort($jobsettings['backuprootexcludedirs']);
|
118 |
+
|
119 |
+
if (!isset($jobsettings['backupcontentexcludedirs']) or !is_array($jobsettings['backupcontentexcludedirs']))
|
120 |
+
$jobsettings['backupcontentexcludedirs']=array();
|
121 |
+
foreach($jobsettings['backupcontentexcludedirs'] as $key => $value) {
|
122 |
+
$jobsettings['backupcontentexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
123 |
+
if (empty($jobsettings['backupcontentexcludedirs'][$key]) or $jobsettings['backupcontentexcludedirs'][$key]=='/' or !is_dir($jobsettings['backupcontentexcludedirs'][$key]))
|
124 |
+
unset($jobsettings['backupcontentexcludedirs'][$key]);
|
125 |
+
}
|
126 |
+
sort($jobsettings['backupcontentexcludedirs']);
|
127 |
+
|
128 |
+
if (!isset($jobsettings['backuppluginsexcludedirs']) or !is_array($jobsettings['backuppluginsexcludedirs']))
|
129 |
+
$jobsettings['backuppluginsexcludedirs']=array();
|
130 |
+
foreach($jobsettings['backuppluginsexcludedirs'] as $key => $value) {
|
131 |
+
$jobsettings['backuppluginsexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
132 |
+
if (empty($jobsettings['backuppluginsexcludedirs'][$key]) or $jobsettings['backuppluginsexcludedirs'][$key]=='/' or !is_dir($jobsettings['backuppluginsexcludedirs'][$key]))
|
133 |
+
unset($jobsettings['backuppluginsexcludedirs'][$key]);
|
134 |
+
}
|
135 |
+
sort($jobsettings['backuppluginsexcludedirs']);
|
136 |
+
|
137 |
+
if (!isset($jobsettings['backupthemesexcludedirs']) or !is_array($jobsettings['backupthemesexcludedirs']))
|
138 |
+
$jobsettings['backupthemesexcludedirs']=array();
|
139 |
+
foreach($jobsettings['backupthemesexcludedirs'] as $key => $value) {
|
140 |
+
$jobsettings['backupthemesexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
141 |
+
if (empty($jobsettings['backupthemesexcludedirs'][$key]) or $jobsettings['backupthemesexcludedirs'][$key]=='/' or !is_dir($jobsettings['backupthemesexcludedirs'][$key]))
|
142 |
+
unset($jobsettings['backupthemesexcludedirs'][$key]);
|
143 |
+
}
|
144 |
+
sort($jobsettings['backupthemesexcludedirs']);
|
145 |
+
|
146 |
+
if (!isset($jobsettings['backupuploadsexcludedirs']) or !is_array($jobsettings['backupuploadsexcludedirs']))
|
147 |
+
$jobsettings['backupuploadsexcludedirs']=array();
|
148 |
+
foreach($jobsettings['backupuploadsexcludedirs'] as $key => $value) {
|
149 |
+
$jobsettings['backupuploadsexcludedirs'][$key]=str_replace('//','/',str_replace('\\','/',trim($value)));
|
150 |
+
if (empty($jobsettings['backupuploadsexcludedirs'][$key]) or $jobsettings['backupuploadsexcludedirs'][$key]=='/' or !is_dir($jobsettings['backupuploadsexcludedirs'][$key]))
|
151 |
+
unset($jobsettings['backupuploadsexcludedirs'][$key]);
|
152 |
+
}
|
153 |
+
sort($jobsettings['backupuploadsexcludedirs']);
|
154 |
+
|
155 |
+
$fileformarts=array('.zip','.tar.gz','.tar.bz2','.tar');
|
156 |
+
if (!isset($jobsettings['fileformart']) or !in_array($jobsettings['fileformart'],$fileformarts))
|
157 |
+
$jobsettings['fileformart']='.zip';
|
158 |
+
|
159 |
+
if (!isset($jobsettings['fileprefix']) or !is_string($jobsettings['fileprefix']))
|
160 |
+
$jobsettings['fileprefix']='backwpup_'.$jobid.'_';
|
161 |
+
|
162 |
+
if (!isset($jobsettings['mailefilesize']) or !is_float($jobsettings['mailefilesize']))
|
163 |
+
$jobsettings['mailefilesize']=0;
|
164 |
+
|
165 |
+
if (!isset($jobsettings['backupdir']) or (!is_dir($jobsettings['backupdir']) and !empty($jobsettings['backupdir']))) {
|
166 |
+
$rand = substr( md5( md5( SECURE_AUTH_KEY ) ), -5 );
|
167 |
+
$jobsettings['backupdir']=str_replace('\\','/',trailingslashit(WP_CONTENT_DIR)).'backwpup-'.$rand.'/';
|
168 |
+
}
|
169 |
+
$jobsettings['backupdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['backupdir']))));
|
170 |
+
if ($jobsettings['backupdir']=='/')
|
171 |
+
$jobsettings['backupdir']='';
|
172 |
+
|
173 |
+
if (!isset($jobsettings['maxbackups']) or !is_int($jobsettings['maxbackups']))
|
174 |
+
$jobsettings['maxbackups']=0;
|
175 |
+
|
176 |
+
if (!isset($jobsettings['ftphost']) or !is_string($jobsettings['ftphost']))
|
177 |
+
$jobsettings['ftphost']='';
|
178 |
+
|
179 |
+
if (!isset($jobsettings['ftpuser']) or !is_string($jobsettings['ftpuser']))
|
180 |
+
$jobsettings['ftpuser']='';
|
181 |
+
|
182 |
+
if (!isset($jobsettings['ftppass']) or !is_string($jobsettings['ftppass']))
|
183 |
+
$jobsettings['ftppass']='';
|
184 |
+
|
185 |
+
if (!isset($jobsettings['ftpdir']) or !is_string($jobsettings['ftpdir']) or $jobsettings['ftpdir']=='/')
|
186 |
+
$jobsettings['ftpdir']='';
|
187 |
+
$jobsettings['ftpdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['ftpdir']))));
|
188 |
+
if (substr($jobsettings['ftpdir'],0,1)!='/')
|
189 |
+
$jobsettings['ftpdir']='/'.$jobsettings['ftpdir'];
|
190 |
+
|
191 |
+
if (!isset($jobsettings['ftpmaxbackups']) or !is_int($jobsettings['ftpmaxbackups']))
|
192 |
+
$jobsettings['ftpmaxbackups']=0;
|
193 |
+
|
194 |
+
if (!isset($jobsettings['ftppasv']) or !is_bool($jobsettings['ftppasv']))
|
195 |
+
$jobsettings['ftppasv']=true;
|
196 |
+
|
197 |
+
if (!isset($jobsettings['awsAccessKey']) or !is_string($jobsettings['awsAccessKey']))
|
198 |
+
$jobsettings['awsAccessKey']='';
|
199 |
+
|
200 |
+
if (!isset($jobsettings['awsSecretKey']) or !is_string($jobsettings['awsSecretKey']))
|
201 |
+
$jobsettings['awsSecretKey']='';
|
202 |
+
|
203 |
+
if (!isset($jobsettings['awsSSL']) or !is_bool($jobsettings['awsSSL']))
|
204 |
+
$jobsettings['awsSSL']=true;
|
205 |
+
|
206 |
+
if (!isset($jobsettings['awsrrs']) or !is_bool($jobsettings['awsrrs']))
|
207 |
+
$jobsettings['awsrrs']=false;
|
208 |
+
|
209 |
+
if (!isset($jobsettings['awsBucket']) or !is_string($jobsettings['awsBucket']))
|
210 |
+
$jobsettings['awsBucket']='';
|
211 |
+
|
212 |
+
if (!isset($jobsettings['awsdir']) or !is_string($jobsettings['awsdir']) or $jobsettings['awsdir']=='/')
|
213 |
+
$jobsettings['awsdir']='';
|
214 |
+
$jobsettings['awsdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['awsdir']))));
|
215 |
+
if (substr($jobsettings['awsdir'],0,1)=='/')
|
216 |
+
$jobsettings['awsdir']=substr($jobsettings['awsdir'],1);
|
217 |
+
|
218 |
+
if (!isset($jobsettings['awsmaxbackups']) or !is_int($jobsettings['awsmaxbackups']))
|
219 |
+
$jobsettings['awsmaxbackups']=0;
|
220 |
+
|
221 |
+
if (!isset($jobsettings['rscUsername']) or !is_string($jobsettings['rscUsername']))
|
222 |
+
$jobsettings['rscUsername']='';
|
223 |
+
|
224 |
+
if (!isset($jobsettings['rscAPIKey']) or !is_string($jobsettings['rscAPIKey']))
|
225 |
+
$jobsettings['rscAPIKey']='';
|
226 |
+
|
227 |
+
if (!isset($jobsettings['rscContainer']) or !is_string($jobsettings['rscContainer']))
|
228 |
+
$jobsettings['rscContainer']='';
|
229 |
+
|
230 |
+
if (!isset($jobsettings['rscdir']) or !is_string($jobsettings['rscdir']) or $jobsettings['rscdir']=='/')
|
231 |
+
$jobsettings['rscdir']='';
|
232 |
+
$jobsettings['rscdir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['rscdir']))));
|
233 |
+
if (substr($jobsettings['rscdir'],0,1)=='/')
|
234 |
+
$jobsettings['rscdir']=substr($jobsettings['rscdir'],1);
|
235 |
+
|
236 |
+
if (!isset($jobsettings['rscmaxbackups']) or !is_int($jobsettings['rscmaxbackups']))
|
237 |
+
$jobsettings['rscmaxbackups']=0;
|
238 |
+
|
239 |
+
if (!is_string($jobsettings['mailaddress']) or false === $pos=strpos($jobsettings['mailaddress'],'@') or false === strpos($jobsettings['mailaddress'],'.',$pos))
|
240 |
+
$jobsettings['mailaddress']='';
|
241 |
+
|
242 |
+
return $jobsettings;
|
243 |
+
}
|
244 |
+
|
245 |
+
|
246 |
+
//ajax/normal get backup files and infos
|
247 |
+
function backwpup_get_backup_files() {
|
248 |
+
$jobs=(array)get_option('backwpup_jobs'); //Load jobs
|
249 |
+
$filecounter=0;
|
250 |
+
$files=array();
|
251 |
+
$donefolders=array();
|
252 |
+
if (extension_loaded('curl') or @dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll')) {
|
253 |
+
if (!class_exists('S3'))
|
254 |
+
include_once('libs/S3.php');
|
255 |
+
if (!class_exists('CF_Authentication'))
|
256 |
+
include_once('libs/rackspace/cloudfiles.php');
|
257 |
+
}
|
258 |
+
|
259 |
+
foreach ($jobs as $jobid => $jobvalue) { //go job by job
|
260 |
+
$jobvalue=backwpup_check_job_vars($jobvalue,$jobid); //Check job values
|
261 |
+
$todo=explode('+',$jobvalue['type']); //only for backup jobs
|
262 |
+
if (!in_array('FILE',$todo) and !in_array('DB',$todo) and !in_array('WPEXP',$todo))
|
263 |
+
continue;
|
264 |
+
|
265 |
+
//Get files/filinfo in backup folder
|
266 |
+
if (!empty($jobvalue['backupdir']) and !in_array($jobvalue['backupdir'],$donefolders)) {
|
267 |
+
if ( $dir = @opendir( $jobvalue['backupdir'] ) ) {
|
268 |
+
while (($file = readdir( $dir ) ) !== false ) {
|
269 |
+
if (substr($file,0,1)=='.' or !(strtolower(substr($file,-4))=='.zip' or strtolower(substr($file,-4))=='.tar' or strtolower(substr($file,-7))=='.tar.gz' or strtolower(substr($file,-8))=='.tar.bz2'))
|
270 |
+
continue;
|
271 |
+
if (is_file($jobvalue['backupdir'].$file)) {
|
272 |
+
$files[$filecounter]['type']='FOLDER';
|
273 |
+
$files[$filecounter]['jobid']=$jobid;
|
274 |
+
$files[$filecounter]['file']=$jobvalue['backupdir'].$file;
|
275 |
+
$files[$filecounter]['filename']=$file;
|
276 |
+
$files[$filecounter]['downloadurl']=wp_nonce_url('admin.php?page=BackWPup&subpage=backups&action=download&file='.$jobvalue['backupdir'].$file, 'download-backup_'.$file);
|
277 |
+
$files[$filecounter]['filesize']=filesize($jobvalue['backupdir'].$file);
|
278 |
+
$files[$filecounter]['time']=filemtime($jobvalue['backupdir'].$file);
|
279 |
+
$filecounter++;
|
280 |
+
}
|
281 |
+
}
|
282 |
+
closedir( $dir );
|
283 |
+
$donefolders[]=$jobvalue['backupdir'];
|
284 |
+
}
|
285 |
+
}
|
286 |
+
//Get files/filinfo from S3
|
287 |
+
if (class_exists('S3') and !in_array($jobvalue['awsAccessKey'].'|'.$jobvalue['awsBucket'].'|'.$jobvalue['awsdir'],$donefolders)) {
|
288 |
+
if (!empty($jobvalue['awsAccessKey']) and !empty($jobvalue['awsSecretKey']) and !empty($jobvalue['awsBucket'])) {
|
289 |
+
$s3 = new S3($jobvalue['awsAccessKey'], $jobvalue['awsSecretKey'], $jobvalue['awsSSL']);
|
290 |
+
if (($contents = $s3->getBucket($jobvalue['awsBucket'],$jobvalue['awsdir'])) !== false) {
|
291 |
+
foreach ($contents as $object) {
|
292 |
+
if (strtolower(substr($object['name'],-4))=='.zip' or strtolower(substr($object['name'],-4))=='.tar' or strtolower(substr($object['name'],-7))=='.tar.gz' or strtolower(substr($object['name'],-8))=='.tar.bz2') {
|
293 |
+
$files[$filecounter]['type']='S3';
|
294 |
+
$files[$filecounter]['jobid']=$jobid;
|
295 |
+
$files[$filecounter]['file']=$object['name'];
|
296 |
+
$files[$filecounter]['filename']=basename($object['name']);
|
297 |
+
$files[$filecounter]['downloadurl']=wp_nonce_url('admin.php?page=BackWPup&subpage=backups&action=downloads3&file='.$object['name'].'&jobid='.$jobid, 'downloads3-backup_'.$object['name']);
|
298 |
+
$files[$filecounter]['filesize']=$object['size'];
|
299 |
+
$files[$filecounter]['time']=$object['time'];
|
300 |
+
$filecounter++;
|
301 |
+
}
|
302 |
+
}
|
303 |
+
}
|
304 |
+
$donefolders[]=$jobvalue['awsAccessKey'].'|'.$jobvalue['awsBucket'].'|'.$jobvalue['awsdir'];
|
305 |
+
}
|
306 |
+
}
|
307 |
+
//Get files/filinfo from RSC
|
308 |
+
if (class_exists('CF_Authentication') and !in_array($jobvalue['rscUsername'].'|'.$jobvalue['rscContainer'].'|'.$jobvalue['rscdir'],$donefolders)) {
|
309 |
+
if (!empty($jobvalue['rscUsername']) and !empty($jobvalue['rscAPIKey']) and !empty($jobvalue['rscContainer'])) {
|
310 |
+
$auth = new CF_Authentication($jobvalue['rscUsername'], $jobvalue['rscAPIKey']);
|
311 |
+
$auth->ssl_use_cabundle();
|
312 |
+
if ($auth->authenticate()) {
|
313 |
+
$conn = new CF_Connection($auth);
|
314 |
+
$conn->ssl_use_cabundle();
|
315 |
+
$backwpupcontainer = $conn->get_container($jobvalue['rscContainer']);
|
316 |
+
$contents = $backwpupcontainer->get_objects(0,NULL,NULL,$jobvalue['rscdir']);
|
317 |
+
foreach ($contents as $object) {
|
318 |
+
if (strtolower(substr($object->name,-4))=='.zip' or strtolower(substr($object->name,-4))=='.tar' or strtolower(substr($object->name,-7))=='.tar.gz' or strtolower(substr($object->name,-8))=='.tar.bz2') {
|
319 |
+
$files[$filecounter]['type']='RSC';
|
320 |
+
$files[$filecounter]['jobid']=$jobid;
|
321 |
+
$files[$filecounter]['file']=$object->name;
|
322 |
+
$files[$filecounter]['filename']=basename($object->name);
|
323 |
+
$files[$filecounter]['downloadurl']=wp_nonce_url('admin.php?page=BackWPup&subpage=backups&action=downloadrsc&file='.$object->name.'&jobid='.$jobid, 'downloadrsc-backup_'.$object->name);
|
324 |
+
$files[$filecounter]['filesize']=$object->content_length;
|
325 |
+
$files[$filecounter]['time']=$object->last_modified;
|
326 |
+
$filecounter++;
|
327 |
+
}
|
328 |
+
}
|
329 |
+
$donefolders[]=$jobvalue['rscUsername'].'|'.$jobvalue['rscContainer'].'|'.$jobvalue['rscdir'];
|
330 |
+
}
|
331 |
+
}
|
332 |
+
}
|
333 |
+
//Get files/filinfo from FTP
|
334 |
+
if (!empty($jobvalue['ftphost']) and !empty($jobvalue['ftpuser']) and !empty($jobvalue['ftppass']) and !in_array($jobvalue['ftphost'].'|'.$jobvalue['ftpuser'].'|'.$jobvalue['ftpdir'],$donefolders)) {
|
335 |
+
$ftpport=21;
|
336 |
+
$ftphost=$jobvalue['ftphost'];
|
337 |
+
if (false !== strpos($jobvalue['ftphost'],':')) //look for port
|
338 |
+
list($ftphost,$ftpport)=explode(':',$jobvalue,2);
|
339 |
+
|
340 |
+
$SSL=false;
|
341 |
+
if (function_exists('ftp_ssl_connect')) { //make SSL FTP connection
|
342 |
+
$ftp_conn_id = ftp_ssl_connect($ftphost,$ftpport,10);
|
343 |
+
if ($ftp_conn_id)
|
344 |
+
$SSL=true;
|
345 |
+
}
|
346 |
+
if (!$ftp_conn_id) { //make normal FTP conection if SSL not work
|
347 |
+
$ftp_conn_id = ftp_connect($ftphost,$ftpport,10);
|
348 |
+
}
|
349 |
+
if ($ftp_conn_id) {
|
350 |
+
//FTP Login
|
351 |
+
$loginok=false;
|
352 |
+
if (@ftp_login($ftp_conn_id, $jobvalue['ftpuser'], base64_decode($jobvalue['ftppass']))) {
|
353 |
+
$loginok=true;
|
354 |
+
} else { //if PHP ftp login don't work use raw login
|
355 |
+
if (substr(trim(ftp_raw($ftp_conn_id,'USER '.$jobvalue['ftpuser'])),0,3)<400) {
|
356 |
+
if (substr(trim(ftp_raw($ftp_conn_id,'PASS '.base64_decode($jobvalue['ftppass']))),0,3)<400) {
|
357 |
+
$loginok=true;
|
358 |
+
}
|
359 |
+
}
|
360 |
+
}
|
361 |
+
}
|
362 |
+
if ($loginok) {
|
363 |
+
ftp_pasv($ftp_conn_id, true);
|
364 |
+
if ($ftpfilelist=ftp_nlist($ftp_conn_id, $jobvalue['ftpdir'])) {
|
365 |
+
foreach($ftpfilelist as $ftpfiles) {
|
366 |
+
if (substr(basename($ftpfiles),0,1)=='.' or !(strtolower(substr($ftpfiles,-4))=='.zip' or strtolower(substr($ftpfiles,-4))=='.tar' or strtolower(substr($ftpfiles,-7))=='.tar.gz' or strtolower(substr($ftpfiles,-8))=='.tar.bz2'))
|
367 |
+
continue;
|
368 |
+
$files[$filecounter]['type']='FTP';
|
369 |
+
$files[$filecounter]['jobid']=$jobid;
|
370 |
+
$files[$filecounter]['file']=$ftpfiles;
|
371 |
+
$files[$filecounter]['filename']=basename($ftpfiles);
|
372 |
+
$files[$filecounter]['downloadurl']="ftp://".$jobvalue['ftpuser'].":".base64_decode($jobvalue['ftppass'])."@".$jobvalue['ftphost'].$ftpfiles;
|
373 |
+
$files[$filecounter]['filesize']=ftp_size($ftp_conn_id,$ftpfiles);
|
374 |
+
if ('backwpup_log_' == substr(basename($ftpfiles),0,strlen('backwpup_log_'))) {
|
375 |
+
$filnameparts=explode('_',substr(basename($ftpfiles),0,strpos(basename($ftpfiles),'.')));
|
376 |
+
$files[$filecounter]['time']=strtotime($filnameparts[2].' '.str_replace('-',':',$filnameparts[3]));
|
377 |
+
}
|
378 |
+
$filecounter++;
|
379 |
+
}
|
380 |
+
}
|
381 |
+
}
|
382 |
+
$donefolders[]=$jobvalue['ftphost'].'|'.$jobvalue['ftpuser'].'|'.$jobvalue['ftpdir'];
|
383 |
+
}
|
384 |
+
}
|
385 |
+
//Sort list
|
386 |
+
$tmp = Array();
|
387 |
+
foreach($files as &$ma)
|
388 |
+
$tmp[] = &$ma["time"];
|
389 |
+
array_multisort($tmp, SORT_DESC, $files);
|
390 |
+
return $files;
|
391 |
+
}
|
392 |
+
|
393 |
+
//ajax/normal get buckests select box
|
394 |
+
function backwpup_get_aws_buckets($args='') {
|
395 |
+
if (is_array($args)) {
|
396 |
+
extract($args);
|
397 |
+
$ajax=false;
|
398 |
+
} else {
|
399 |
+
$awsAccessKey=$_POST['awsAccessKey'];
|
400 |
+
$awsSecretKey=$_POST['awsSecretKey'];
|
401 |
+
$awsselected=$_POST['awsselected'];
|
402 |
+
$ajax=true;
|
403 |
+
}
|
404 |
+
if (!class_exists('S3'))
|
405 |
+
include_once('libs/S3.php');
|
406 |
+
if (empty($awsAccessKey)) {
|
407 |
+
echo '<span id="awsBucket" style="color:red;">'.__('Missing Access Key ID!','backwpup').'</span>';
|
408 |
+
if ($ajax)
|
409 |
+
die();
|
410 |
+
else
|
411 |
+
return;
|
412 |
+
}
|
413 |
+
if (empty($awsSecretKey)) {
|
414 |
+
echo '<span id="awsBucket" style="color:red;">'.__('Missing Secret Access Key!','backwpup').'</span>';
|
415 |
+
if ($ajax)
|
416 |
+
die();
|
417 |
+
else
|
418 |
+
return;
|
419 |
+
}
|
420 |
+
$s3 = new S3($awsAccessKey, $awsSecretKey, false);
|
421 |
+
$buckets=@$s3->listBuckets();
|
422 |
+
if (!is_array($buckets)) {
|
423 |
+
echo '<span id="awsBucket" style="color:red;">'.__('No Buckets found! Or wrong Keys!','backwpup').'</span>';
|
424 |
+
if ($ajax)
|
425 |
+
die();
|
426 |
+
else
|
427 |
+
return;
|
428 |
+
}
|
429 |
+
echo '<select name="awsBucket" id="awsBucket">';
|
430 |
+
foreach ($buckets as $bucket) {
|
431 |
+
echo "<option ".selected(strtolower($awsselected),strtolower($bucket),false).">".$bucket."</option>";
|
432 |
+
}
|
433 |
+
echo '</select>';
|
434 |
+
if ($ajax)
|
435 |
+
die();
|
436 |
+
else
|
437 |
+
return;
|
438 |
+
}
|
439 |
+
|
440 |
+
//ajax/normal get Container for RSC select box
|
441 |
+
function backwpup_get_rsc_container($args='') {
|
442 |
+
if (is_array($args)) {
|
443 |
+
extract($args);
|
444 |
+
$ajax=false;
|
445 |
+
} else {
|
446 |
+
$rscUsername=$_POST['rscUsername'];
|
447 |
+
$rscAPIKey=$_POST['rscAPIKey'];
|
448 |
+
$rscselected=$_POST['rscselected'];
|
449 |
+
$ajax=true;
|
450 |
+
}
|
451 |
+
if (!class_exists('CF_Authentication'))
|
452 |
+
include_once('libs/rackspace/cloudfiles.php');
|
453 |
+
|
454 |
+
if (empty($rscUsername)) {
|
455 |
+
echo '<span id="rscContainer" style="color:red;">'.__('Missing Username!','backwpup').'</span>';
|
456 |
+
if ($ajax)
|
457 |
+
die();
|
458 |
+
else
|
459 |
+
return;
|
460 |
+
}
|
461 |
+
if (empty($rscAPIKey)) {
|
462 |
+
echo '<span id="rscContainer" style="color:red;">'.__('Missing API Key!','backwpup').'</span>';
|
463 |
+
if ($ajax)
|
464 |
+
die();
|
465 |
+
else
|
466 |
+
return;
|
467 |
+
}
|
468 |
+
$auth = new CF_Authentication($rscUsername, $rscAPIKey);
|
469 |
+
|
470 |
+
try {
|
471 |
+
$auth->authenticate();
|
472 |
+
$conn = new CF_Connection($auth);
|
473 |
+
$containers=$conn->get_containers();
|
474 |
+
} catch (Exception $e) {
|
475 |
+
echo '<span id="rscContainer" style="color:red;">'.__($e->getMessage(),'backwpup').'</span>';
|
476 |
+
if ($ajax)
|
477 |
+
die();
|
478 |
+
else
|
479 |
+
return;
|
480 |
+
}
|
481 |
+
|
482 |
+
if (!is_array($containers)) {
|
483 |
+
echo '<span id="rscContainer" style="color:red;">'.__('No Containerss found!','backwpup').'</span>';
|
484 |
+
if ($ajax)
|
485 |
+
die();
|
486 |
+
else
|
487 |
+
return;
|
488 |
+
}
|
489 |
+
echo '<select name="rscContainer" id="rscContainer">';
|
490 |
+
foreach ($containers as $container) {
|
491 |
+
echo "<option ".selected(strtolower($rscselected),strtolower($container->name),false).">".$container->name."</option>";
|
492 |
+
}
|
493 |
+
echo '</select>';
|
494 |
+
if ($ajax)
|
495 |
+
die();
|
496 |
+
else
|
497 |
+
return;
|
498 |
+
}
|
499 |
+
?>
|
app/options-edit-job.php
CHANGED
@@ -345,6 +345,7 @@ $todo=explode('+',$jobvalue['type']);
|
|
345 |
<input name="ftpdir" type="text" value="<?PHP echo $jobvalue['ftpdir'];?>" class="large-text" /><br />
|
346 |
<?PHP if (!is_numeric($jobvalue['ftpmaxbackups'])) $jobvalue['ftpmaxbackups']=0; ?>
|
347 |
<?PHP _e('Max. Backup Files in FTP Folder:','backwpup'); ?> <input name="ftpmaxbackups" type="text" size="3" value="<?PHP echo $jobvalue['ftpmaxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will deleted first.)','backwpup');?></span><br />
|
|
|
348 |
</div>
|
349 |
</div>
|
350 |
|
345 |
<input name="ftpdir" type="text" value="<?PHP echo $jobvalue['ftpdir'];?>" class="large-text" /><br />
|
346 |
<?PHP if (!is_numeric($jobvalue['ftpmaxbackups'])) $jobvalue['ftpmaxbackups']=0; ?>
|
347 |
<?PHP _e('Max. Backup Files in FTP Folder:','backwpup'); ?> <input name="ftpmaxbackups" type="text" size="3" value="<?PHP echo $jobvalue['ftpmaxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will deleted first.)','backwpup');?></span><br />
|
348 |
+
<input class="checkbox" value="1" type="checkbox" <?php checked($jobvalue['ftppasv'],true); ?> name="ftppasv" /> <?PHP _e('Use FTP Passiv mode.','backwpup'); ?><br />
|
349 |
</div>
|
350 |
</div>
|
351 |
|
app/options-save.php
CHANGED
@@ -379,6 +379,7 @@ function backwpup_save_job() { //Save Job settings
|
|
379 |
$jobs[$jobid]['ftppass']=base64_encode($_POST['ftppass']);
|
380 |
$jobs[$jobid]['ftpdir']=stripslashes($_POST['ftpdir']);
|
381 |
$jobs[$jobid]['ftpmaxbackups']=(int)$_POST['ftpmaxbackups'];
|
|
|
382 |
$jobs[$jobid]['awsAccessKey']=$_POST['awsAccessKey'];
|
383 |
$jobs[$jobid]['awsSecretKey']=$_POST['awsSecretKey'];
|
384 |
$jobs[$jobid]['awsSSL']= $_POST['awsSSL']==1 ? true : false;
|
379 |
$jobs[$jobid]['ftppass']=base64_encode($_POST['ftppass']);
|
380 |
$jobs[$jobid]['ftpdir']=stripslashes($_POST['ftpdir']);
|
381 |
$jobs[$jobid]['ftpmaxbackups']=(int)$_POST['ftpmaxbackups'];
|
382 |
+
$jobs[$jobid]['ftppasv']= $_POST['ftppasv']==1 ? true : false;
|
383 |
$jobs[$jobid]['awsAccessKey']=$_POST['awsAccessKey'];
|
384 |
$jobs[$jobid]['awsSecretKey']=$_POST['awsSecretKey'];
|
385 |
$jobs[$jobid]['awsSSL']= $_POST['awsSSL']==1 ? true : false;
|
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.3.
|
8 |
Author URI: http://danielhuesken.de
|
9 |
Text Domain: backwpup
|
10 |
Domain Path: /lang/
|
@@ -34,7 +34,7 @@ if ( !defined('ABSPATH') )
|
|
34 |
//Set plugin dirname
|
35 |
define('BACKWPUP_PLUGIN_BASEDIR', dirname(plugin_basename(__FILE__)));
|
36 |
//Set Plugin Version
|
37 |
-
define('BACKWPUP_VERSION', '1.3.
|
38 |
//load Text Domain
|
39 |
load_plugin_textdomain('backwpup', false, BACKWPUP_PLUGIN_BASEDIR.'/lang');
|
40 |
//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.3.5
|
8 |
Author URI: http://danielhuesken.de
|
9 |
Text Domain: backwpup
|
10 |
Domain Path: /lang/
|
34 |
//Set plugin dirname
|
35 |
define('BACKWPUP_PLUGIN_BASEDIR', dirname(plugin_basename(__FILE__)));
|
36 |
//Set Plugin Version
|
37 |
+
define('BACKWPUP_VERSION', '1.3.5');
|
38 |
//load Text Domain
|
39 |
load_plugin_textdomain('backwpup', false, BACKWPUP_PLUGIN_BASEDIR.'/lang');
|
40 |
//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, xml, Rackspase, cloud, webdav
|
5 |
Requires at least: 2.8
|
6 |
Tested up to: 3.1.0
|
7 |
-
Stable tag: 1.3.
|
8 |
|
9 |
Backup and more of your WordPress Blog Database and Files
|
10 |
|
@@ -77,11 +77,19 @@ PHP normally abort Script that works longer then 30s but the Plugin try too swit
|
|
77 |
I have build in many options to Optimize the Mailing but the mailing lib uses high Memory.
|
78 |
Place mail only little archives
|
79 |
|
|
|
|
|
|
|
80 |
== Screenshots ==
|
81 |
|
82 |
1. Job Page
|
83 |
|
84 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
85 |
= 1.3.4 =
|
86 |
* fixed warning in send mail
|
87 |
* bug fixes
|
4 |
Tags: backup, admin, file, Database, mysql, cron, ftp, S3, export, xml, Rackspase, cloud, webdav
|
5 |
Requires at least: 2.8
|
6 |
Tested up to: 3.1.0
|
7 |
+
Stable tag: 1.3.5
|
8 |
|
9 |
Backup and more of your WordPress Blog Database and Files
|
10 |
|
77 |
I have build in many options to Optimize the Mailing but the mailing lib uses high Memory.
|
78 |
Place mail only little archives
|
79 |
|
80 |
+
= FTP Warnings =
|
81 |
+
Please deactivate Pasive Mode and try it again.
|
82 |
+
|
83 |
== Screenshots ==
|
84 |
|
85 |
1. Job Page
|
86 |
|
87 |
== Changelog ==
|
88 |
+
= 1.3.5 =
|
89 |
+
* fixed problem with folder include
|
90 |
+
* added option to deactivate FTP passive mode
|
91 |
+
* fixed bug for prasing errors because PHP 5 move PHP 5 functions in a seperate file
|
92 |
+
|
93 |
= 1.3.4 =
|
94 |
* fixed warning in send mail
|
95 |
* bug fixes
|