WP-DB-Backup - Version 2.1.4

Version Description

Download this release

Release Info

Developer filosofo
Plugin Icon 128x128 WP-DB-Backup
Version 2.1.4
Comparing to
See all releases

Code changes from version 2.1.3 to 2.1.4

Files changed (2) hide show
  1. readme.txt +4 -1
  2. wp-db-backup.php +18 -21
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.ilfilosofo.com/blog/wp-db-backup/
4
  Tags: mysql, database, backup, cron
5
  Requires at least: 2.0.3
6
  Tested up to: 2.3
7
- Stable tag: 2.1.3
8
 
9
  On-demand backup of your WordPress database.
10
 
@@ -80,6 +80,9 @@ If you are using WordPress version 2.1 or newer, you can schedule automated back
80
  of your choice.
81
 
82
  == Changelog ==
 
 
 
83
  2.0
84
  Support for WordPress 2.1's built-in cron, for automated scheduled backups.
85
 
4
  Tags: mysql, database, backup, cron
5
  Requires at least: 2.0.3
6
  Tested up to: 2.3
7
+ Stable tag: 2.1.4
8
 
9
  On-demand backup of your WordPress database.
10
 
80
  of your choice.
81
 
82
  == Changelog ==
83
+ 2.1
84
+ Major security upgrade
85
+
86
  2.0
87
  Support for WordPress 2.1's built-in cron, for automated scheduled backups.
88
 
wp-db-backup.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.ilfilosofo.com/blog/wp-db-backup
5
  Description: On-demand backup of your WordPress database. Navigate to <a href="edit.php?page=wp-db-backup">Manage &rarr; Backup</a> to get started.
6
  Author: Austin Matzko
7
  Author URI: http://www.ilfilosofo.com/blog/
8
- Version: 2.1.3
9
 
10
  Development continued from that done by Skippy (http://www.skippy.net/)
11
 
@@ -555,6 +555,7 @@ class wpdbBackup {
555
  }
556
 
557
  if(($segment == 'none') || ($segment >= 0)) {
 
558
  $ints = array();
559
  foreach ($table_structure as $struct) {
560
  if ( (0 === strpos($struct->Type, 'tinyint')) ||
@@ -563,6 +564,7 @@ class wpdbBackup {
563
  (0 === strpos(strtolower($struct->Type), 'int')) ||
564
  (0 === strpos(strtolower($struct->Type), 'bigint')) ||
565
  (0 === strpos(strtolower($struct->Type), 'timestamp')) ) {
 
566
  $ints[strtolower($struct->Field)] = "1";
567
  }
568
  }
@@ -582,14 +584,6 @@ class wpdbBackup {
582
  if ( !ini_get('safe_mode')) @set_time_limit(15*60);
583
  $table_data = $wpdb->get_results("SELECT * FROM $table LIMIT {$row_start}, {$row_inc}", ARRAY_A);
584
 
585
- /*
586
- if (FALSE === $table_data) {
587
- $err_msg = sprintf(__('Error getting table contents from %s','wp-db-backup'),$table);
588
- $this->error($err_msg);
589
- fwrite($fp, "#\n# $err_msg\n#\n");
590
- }
591
- */
592
-
593
  $entries = 'INSERT INTO ' . $this->backquote($table) . ' VALUES (';
594
  // \x08\\x09, not required
595
  $search = array("\x00", "\x0a", "\x0d", "\x1a");
@@ -599,7 +593,10 @@ class wpdbBackup {
599
  $values = array();
600
  foreach ($row as $key => $value) {
601
  if ($ints[strtolower($key)]) {
602
- $values[] = $value;
 
 
 
603
  } else {
604
  $values[] = "'" . str_replace($search, $replace, $this->sql_addslashes($value)) . "'";
605
  }
@@ -674,6 +671,10 @@ class wpdbBackup {
674
  */
675
  function setup_phpmailer(&$phpmailer) {
676
  if ( $this->useMailer ) :
 
 
 
 
677
  $phpmailer->AddAttachment($this->diskfile, $this->filename);
678
  $phpmailer->Body = $this->message;
679
  endif;
@@ -707,14 +708,14 @@ class wpdbBackup {
707
  $this->close($fp);
708
  $data = chunk_split(base64_encode($file));
709
  $headers = "MIME-Version: 1.0\n";
710
- $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\n";
711
  $headers .= 'From: ' . get_option('admin_email') . "\n";
712
 
713
  $this->message = $message = sprintf(__("Attached to this email is\n %1s\n Size:%2s kilobytes\n",'wp-db-backup'), $filename, round(filesize($this->diskfile)/1024));
714
  // Add a multipart boundary above the plain message
715
  $message .= "This is a multi-part message in MIME format.\n\n" .
716
  "--{$boundary}\n" .
717
- "Content-Type: text/plain; charset=\"utf-8\"\n" .
718
  "Content-Transfer-Encoding: 7bit\n\n" .
719
  $message . "\n\n";
720
 
@@ -728,21 +729,17 @@ class wpdbBackup {
728
  $data . "\n\n" .
729
  "--{$boundary}--\n";
730
 
731
- if (function_exists('wp_mail')) {
732
- $this->useMailer = true;
733
- $success = @wp_mail($recipient, get_bloginfo('name') . ' ' . __('Database Backup','wp-db-backup'), $message, $headers);
734
- $this->useMailer = false;
735
- } else {
736
- $success = @mail($recipient, get_bloginfo('name') . ' ' . __('Database Backup','wp-db-backup'), $message, $headers);
737
- }
738
 
739
  if ( false == $success ) {
740
  $msg = __('The following errors were reported:','wp-db-backup') . "\n ";
741
  $msg = ( function_exists('error_get_last') ) ? error_get_last('message') : __('ERROR: The mail application has failed to deliver the backup.','wp-db-backup');
742
  $this->error($msg);
 
 
743
  }
744
-
745
- unlink($this->diskfile);
746
  }
747
  return $success;
748
  }
5
  Description: On-demand backup of your WordPress database. Navigate to <a href="edit.php?page=wp-db-backup">Manage &rarr; Backup</a> to get started.
6
  Author: Austin Matzko
7
  Author URI: http://www.ilfilosofo.com/blog/
8
+ Version: 2.1.4
9
 
10
  Development continued from that done by Skippy (http://www.skippy.net/)
11
 
555
  }
556
 
557
  if(($segment == 'none') || ($segment >= 0)) {
558
+ $defs = array();
559
  $ints = array();
560
  foreach ($table_structure as $struct) {
561
  if ( (0 === strpos($struct->Type, 'tinyint')) ||
564
  (0 === strpos(strtolower($struct->Type), 'int')) ||
565
  (0 === strpos(strtolower($struct->Type), 'bigint')) ||
566
  (0 === strpos(strtolower($struct->Type), 'timestamp')) ) {
567
+ $defs[strtolower($struct->Field)] = $struct->Default;
568
  $ints[strtolower($struct->Field)] = "1";
569
  }
570
  }
584
  if ( !ini_get('safe_mode')) @set_time_limit(15*60);
585
  $table_data = $wpdb->get_results("SELECT * FROM $table LIMIT {$row_start}, {$row_inc}", ARRAY_A);
586
 
 
 
 
 
 
 
 
 
587
  $entries = 'INSERT INTO ' . $this->backquote($table) . ' VALUES (';
588
  // \x08\\x09, not required
589
  $search = array("\x00", "\x0a", "\x0d", "\x1a");
593
  $values = array();
594
  foreach ($row as $key => $value) {
595
  if ($ints[strtolower($key)]) {
596
+ // make sure there are no blank spots in the insert syntax,
597
+ // yet try to avoid quotation marks around integers
598
+ $value = ( '' === $value) ? $defs[strtolower($key)] : $value;
599
+ $values[] = ( '' === $value ) ? "''" : $value;
600
  } else {
601
  $values[] = "'" . str_replace($search, $replace, $this->sql_addslashes($value)) . "'";
602
  }
671
  */
672
  function setup_phpmailer(&$phpmailer) {
673
  if ( $this->useMailer ) :
674
+ if ( empty( $phpmailer->CharSet ) ) {
675
+ $phpmailer->CharSet = apply_filters( 'wp_mail_charset', get_bloginfo('charset') );
676
+ }
677
+ $phpmailer->ClearCustomHeaders();
678
  $phpmailer->AddAttachment($this->diskfile, $this->filename);
679
  $phpmailer->Body = $this->message;
680
  endif;
708
  $this->close($fp);
709
  $data = chunk_split(base64_encode($file));
710
  $headers = "MIME-Version: 1.0\n";
711
+ $headers .= "Content-Type: multipart/mixed; \nboundary=\"$boundary\"\n";
712
  $headers .= 'From: ' . get_option('admin_email') . "\n";
713
 
714
  $this->message = $message = sprintf(__("Attached to this email is\n %1s\n Size:%2s kilobytes\n",'wp-db-backup'), $filename, round(filesize($this->diskfile)/1024));
715
  // Add a multipart boundary above the plain message
716
  $message .= "This is a multi-part message in MIME format.\n\n" .
717
  "--{$boundary}\n" .
718
+ "Content-Type: text/plain; charset=\"" . get_bloginfo('charset') . "\"\n" .
719
  "Content-Transfer-Encoding: 7bit\n\n" .
720
  $message . "\n\n";
721
 
729
  $data . "\n\n" .
730
  "--{$boundary}--\n";
731
 
732
+ $this->useMailer = true;
733
+ $success = @wp_mail($recipient, get_bloginfo('name') . ' ' . __('Database Backup','wp-db-backup'), $message, $headers);
734
+ $this->useMailer = false;
 
 
 
 
735
 
736
  if ( false == $success ) {
737
  $msg = __('The following errors were reported:','wp-db-backup') . "\n ";
738
  $msg = ( function_exists('error_get_last') ) ? error_get_last('message') : __('ERROR: The mail application has failed to deliver the backup.','wp-db-backup');
739
  $this->error($msg);
740
+ } else {
741
+ unlink($this->diskfile);
742
  }
 
 
743
  }
744
  return $success;
745
  }