WP-DBManager - Version 2.78

Version Description

N/A

Download this release

Release Info

Developer GamerZ
Plugin Icon WP-DBManager
Version 2.78
Comparing to
See all releases

Code changes from version 2.76 to 2.78

database-backup.php CHANGED
@@ -43,12 +43,12 @@ if(!empty($_POST['do'])) {
43
  $backup['filename'] = $backup['date'].'_-_'.DB_NAME.'.sql.gz';
44
  $backup['filepath'] = $backup['path'].'/'.$backup['filename'];
45
  do_action( 'wp_dbmanager_before_escapeshellcmd' );
46
- $backup['command'] = escapeshellcmd( $brace . $backup['mysqldumppath'] . $brace ) . ' --force --host=' . escapeshellarg( $backup['host'] ) . ' --user=' . escapeshellarg( DB_USER ) . ' --password=' . escapeshellarg( DB_PASSWORD ) . $backup['port'] . $backup['sock'] . $backup['charset'] . ' --add-drop-table --skip-lock-tables ' . DB_NAME . ' | gzip > ' . escapeshellcmd( $brace . $backup['filepath'] . $brace );
47
  } else {
48
  $backup['filename'] = $backup['date'].'_-_'.DB_NAME.'.sql';
49
  $backup['filepath'] = $backup['path'].'/'.$backup['filename'];
50
  do_action( 'wp_dbmanager_before_escapeshellcmd' );
51
- $backup['command'] = escapeshellcmd( $brace . $backup['mysqldumppath'] . $brace ) . ' --force --host=' . escapeshellarg( $backup['host'] ) . ' --user=' . escapeshellarg( DB_USER ) . ' --password=' . escapeshellarg( DB_PASSWORD ) . $backup['port'] . $backup['sock'] . $backup['charset'] . ' --add-drop-table --skip-lock-tables ' . DB_NAME . ' > ' . escapeshellcmd( $brace . $backup['filepath'] . $brace );
52
  }
53
  $error = execute_backup( $backup['command'] );
54
  if(!is_writable( $backup['path'] ) ) {
43
  $backup['filename'] = $backup['date'].'_-_'.DB_NAME.'.sql.gz';
44
  $backup['filepath'] = $backup['path'].'/'.$backup['filename'];
45
  do_action( 'wp_dbmanager_before_escapeshellcmd' );
46
+ $backup['command'] = $brace . escapeshellcmd( $backup['mysqldumppath'] ) . $brace . ' --force --host=' . escapeshellarg( $backup['host'] ) . ' --user=' . escapeshellarg( DB_USER ) . ' --password=' . escapeshellarg( DB_PASSWORD ) . $backup['port'] . $backup['sock'] . $backup['charset'] . ' --add-drop-table --skip-lock-tables ' . DB_NAME . ' | gzip > ' . $brace . escapeshellcmd( $backup['filepath'] ) . $brace;
47
  } else {
48
  $backup['filename'] = $backup['date'].'_-_'.DB_NAME.'.sql';
49
  $backup['filepath'] = $backup['path'].'/'.$backup['filename'];
50
  do_action( 'wp_dbmanager_before_escapeshellcmd' );
51
+ $backup['command'] = $brace . escapeshellcmd( $backup['mysqldumppath'] ) . $brace . ' --force --host=' . escapeshellarg( $backup['host'] ) . ' --user=' . escapeshellarg( DB_USER ) . ' --password=' . escapeshellarg( DB_PASSWORD ) . $backup['port'] . $backup['sock'] . $backup['charset'] . ' --add-drop-table --skip-lock-tables ' . DB_NAME . ' > ' . $brace . escapeshellcmd( $backup['filepath'] ) . $brace;
52
  }
53
  $error = execute_backup( $backup['command'] );
54
  if(!is_writable( $backup['path'] ) ) {
database-manage.php CHANGED
@@ -44,10 +44,10 @@ if( !empty( $_POST['do'] ) ) {
44
  }
45
  if(stristr($database_file, '.gz')) {
46
  do_action( 'wp_dbmanager_before_escapeshellcmd' );
47
- $backup['command'] = 'gunzip < ' . escapeshellcmd( $brace . $backup['path'] . '/' . $database_file . $brace ) .' | '. escapeshellcmd( $brace . $backup['mysqlpath'] . $brace ) . ' --host=' . escapeshellarg( $backup['host'] ) . ' --user=' . escapeshellarg( DB_USER ) . ' --password=' . escapeshellarg( DB_PASSWORD ) . $backup['port'] . $backup['sock'] . $backup['charset'] . ' ' . DB_NAME;
48
  } else {
49
  do_action( 'wp_dbmanager_before_escapeshellcmd' );
50
- $backup['command'] = escapeshellcmd( $brace . $backup['mysqlpath'] . $brace ) . ' --host=' . escapeshellarg( $backup['host'] ) . ' --user=' . escapeshellarg( DB_USER ) . ' --password=' . escapeshellarg( DB_PASSWORD ) . $backup['port'] . $backup['sock'] . $backup['charset'] . ' ' . DB_NAME . ' < '.escapeshellcmd( $brace . $backup['path'] . '/' . $database_file . $brace );
51
  }
52
  if( realpath( $backup['path'] ) === false ) {
53
  $text = '<p style="color: red;">' . sprintf(__('%s is not a valid backup path', 'wp-dbmanager'), stripslashes( $backup['path'] ) ) . '</p>';
44
  }
45
  if(stristr($database_file, '.gz')) {
46
  do_action( 'wp_dbmanager_before_escapeshellcmd' );
47
+ $backup['command'] = 'gunzip < ' . $brace . escapeshellcmd( $backup['path'] . '/' . $database_file ) . $brace . ' | ' . $brace . escapeshellcmd( $backup['mysqlpath'] ) . $brace . ' --host=' . escapeshellarg( $backup['host'] ) . ' --user=' . escapeshellarg( DB_USER ) . ' --password=' . escapeshellarg( DB_PASSWORD ) . $backup['port'] . $backup['sock'] . $backup['charset'] . ' ' . DB_NAME;
48
  } else {
49
  do_action( 'wp_dbmanager_before_escapeshellcmd' );
50
+ $backup['command'] = $brace . escapeshellcmd( $backup['mysqlpath'] ) . $brace . ' --host=' . escapeshellarg( $backup['host'] ) . ' --user=' . escapeshellarg( DB_USER ) . ' --password=' . escapeshellarg( DB_PASSWORD ) . $backup['port'] . $backup['sock'] . $backup['charset'] . ' ' . DB_NAME . ' < ' . $brace . escapeshellcmd( $backup['path'] . '/' . $database_file ) . $brace;
51
  }
52
  if( realpath( $backup['path'] ) === false ) {
53
  $text = '<p style="color: red;">' . sprintf(__('%s is not a valid backup path', 'wp-dbmanager'), stripslashes( $backup['path'] ) ) . '</p>';
database-manager.php CHANGED
@@ -70,46 +70,41 @@ $sqlversion = $wpdb->get_var("SELECT VERSION() AS version");
70
  <th><?php _e('Overhead', 'wp-dbmanager'); ?></th>
71
  </tr>
72
  </thead>
73
- <?php
74
- // If MYSQL Version More Than 3.23, Get More Info
75
- if($sqlversion >= '3.23') {
76
- $no = 0;
77
- $row_usage = 0;
78
- $data_usage = 0;
79
- $index_usage = 0;
80
- $overhead_usage = 0;
81
- $tablesstatus = $wpdb->get_results("SHOW TABLE STATUS");
82
- foreach($tablesstatus as $tablestatus) {
83
- if($no%2 == 0) {
84
- $style = '';
85
- } else {
86
- $style = ' class="alternate"';
87
- }
88
- $no++;
89
- echo "<tr$style>\n";
90
- echo '<td>'.number_format_i18n($no).'</td>'."\n";
91
- echo "<td>$tablestatus->Name</td>\n";
92
- echo '<td>'.number_format_i18n($tablestatus->Rows).'</td>'."\n";
93
- echo '<td>'.format_size($tablestatus->Data_length).'</td>'."\n";
94
- echo '<td>'.format_size($tablestatus->Index_length).'</td>'."\n";;
95
- echo '<td>'.format_size($tablestatus->Data_free).'</td>'."\n";
96
- $row_usage += $tablestatus->Rows;
97
- $data_usage += $tablestatus->Data_length;
98
- $index_usage += $tablestatus->Index_length;
99
- $overhead_usage += $tablestatus->Data_free;
100
- echo '</tr>'."\n";
101
- }
102
- echo '<tr class="thead">'."\n";
103
- echo '<th>'.__('Total:', 'wp-dbmanager').'</th>'."\n";
104
- echo '<th>'.sprintf(_n('%s Table', '%s Tables', $no, 'wp-dbmanager'), number_format_i18n($no)).'</th>'."\n";
105
- echo '<th>'.sprintf(_n('%s Record', '%s Records', $row_usage, 'wp-dbmanager'), number_format_i18n($row_usage)).'</th>'."\n";
106
- echo '<th>'.format_size($data_usage).'</th>'."\n";
107
- echo '<th>'.format_size($index_usage).'</th>'."\n";
108
- echo '<th>'.format_size($overhead_usage).'</th>'."\n";
109
- echo '</tr>';
110
- } else {
111
- echo '<tr><td colspan="6" align="center"><strong>'.__('Could Not Show Table Status Due To Your MYSQL Version Is Lower Than 3.23.', 'wp-dbmanager').'</strong></td></tr>';
112
- }
113
- ?>
114
  </table>
115
  </div>
70
  <th><?php _e('Overhead', 'wp-dbmanager'); ?></th>
71
  </tr>
72
  </thead>
73
+ <?php
74
+ $no = 0;
75
+ $row_usage = 0;
76
+ $data_usage = 0;
77
+ $index_usage = 0;
78
+ $overhead_usage = 0;
79
+ $tablesstatus = $wpdb->get_results("SHOW TABLE STATUS");
80
+ foreach($tablesstatus as $tablestatus) {
81
+ if($no%2 == 0) {
82
+ $style = '';
83
+ } else {
84
+ $style = ' class="alternate"';
85
+ }
86
+ $no++;
87
+ echo "<tr$style>\n";
88
+ echo '<td>'.number_format_i18n($no).'</td>'."\n";
89
+ echo "<td>$tablestatus->Name</td>\n";
90
+ echo '<td>'.number_format_i18n($tablestatus->Rows).'</td>'."\n";
91
+ echo '<td>'.format_size($tablestatus->Data_length).'</td>'."\n";
92
+ echo '<td>'.format_size($tablestatus->Index_length).'</td>'."\n";;
93
+ echo '<td>'.format_size($tablestatus->Data_free).'</td>'."\n";
94
+ $row_usage += $tablestatus->Rows;
95
+ $data_usage += $tablestatus->Data_length;
96
+ $index_usage += $tablestatus->Index_length;
97
+ $overhead_usage += $tablestatus->Data_free;
98
+ echo '</tr>'."\n";
99
+ }
100
+ echo '<tr class="thead">'."\n";
101
+ echo '<th>'.__('Total:', 'wp-dbmanager').'</th>'."\n";
102
+ echo '<th>'.sprintf(_n('%s Table', '%s Tables', $no, 'wp-dbmanager'), number_format_i18n($no)).'</th>'."\n";
103
+ echo '<th>'.sprintf(_n('%s Record', '%s Records', $row_usage, 'wp-dbmanager'), number_format_i18n($row_usage)).'</th>'."\n";
104
+ echo '<th>'.format_size($data_usage).'</th>'."\n";
105
+ echo '<th>'.format_size($index_usage).'</th>'."\n";
106
+ echo '<th>'.format_size($overhead_usage).'</th>'."\n";
107
+ echo '</tr>';
108
+ ?>
 
 
 
 
 
109
  </table>
110
  </div>
database-optimize.php CHANGED
@@ -74,11 +74,11 @@ $tables = $wpdb->get_col("SHOW TABLES");
74
  }
75
  ?>
76
  <tr>
77
- <td colspan="2" align="center"><?php _e('Database should be optimize once every month.', 'wp-dbmanager'); ?></td>
78
  </tr>
79
  <tr>
80
  <td colspan="2" align="center"><input type="submit" name="do" value="<?php _e('Optimize', 'wp-dbmanager'); ?>" class="button" />&nbsp;&nbsp;<input type="button" name="cancel" value="<?php _e('Cancel', 'wp-dbmanager'); ?>" class="button" onclick="javascript:history.go(-1)" /></td>
81
  </tr>
82
  </table>
83
  </div>
84
- </form>
74
  }
75
  ?>
76
  <tr>
77
+ <td colspan="2" align="center"><?php _e('Database should be optimized once every month.', 'wp-dbmanager'); ?></td>
78
  </tr>
79
  <tr>
80
  <td colspan="2" align="center"><input type="submit" name="do" value="<?php _e('Optimize', 'wp-dbmanager'); ?>" class="button" />&nbsp;&nbsp;<input type="button" name="cancel" value="<?php _e('Cancel', 'wp-dbmanager'); ?>" class="button" onclick="javascript:history.go(-1)" /></td>
81
  </tr>
82
  </table>
83
  </div>
84
+ </form>
database-run.php CHANGED
@@ -74,7 +74,7 @@ if(!empty($_POST['do'])) {
74
  <h2><?php _e('Run SQL Query', 'wp-dbmanager'); ?></h2>
75
  <br style="clear" />
76
  <div>
77
- <strong><?php _e('Seperate Multiple Queries With A New Line', 'wp-dbmanager'); ?></strong><br />
78
  <p style="color: green;"><?php _e('Use Only INSERT, UPDATE, REPLACE, DELETE, CREATE and ALTER statements.', 'wp-dbmanager'); ?></p>
79
  </div>
80
  <table class="form-table">
@@ -91,4 +91,4 @@ if(!empty($_POST['do'])) {
91
  <?php _e('3. ALTER statement will return an error because there is no value returned.', 'wp-dbmanager'); ?>
92
  </p>
93
  </div>
94
- </form>
74
  <h2><?php _e('Run SQL Query', 'wp-dbmanager'); ?></h2>
75
  <br style="clear" />
76
  <div>
77
+ <strong><?php _e('Separate Multiple Queries With A New Line', 'wp-dbmanager'); ?></strong><br />
78
  <p style="color: green;"><?php _e('Use Only INSERT, UPDATE, REPLACE, DELETE, CREATE and ALTER statements.', 'wp-dbmanager'); ?></p>
79
  </div>
80
  <table class="form-table">
91
  <?php _e('3. ALTER statement will return an error because there is no value returned.', 'wp-dbmanager'); ?>
92
  </p>
93
  </div>
94
+ </form>
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: GamerZ
3
  Donate link: http://lesterchan.net/site/donation/
4
  Tags: database, manage, wp-dbmanager, manager, table, optimize, backup, queries, query, drop, empty, tables, table, run, repair, cron, schedule, scheduling, automatic
5
  Requires at least: 3.9
6
- Tested up to: 4.2
7
- Stable tag: 2.76
8
 
9
  Manages your WordPress database.
10
 
@@ -33,6 +33,14 @@ Allows you to optimize database, repair database, backup database, restore datab
33
  * To know about the difference between WP-DBManager and WP-DB-backup, checkout __What is the difference between WP-DBManager and WP-DB-Backup?__ in the [FAQ section](https://wordpress.org/plugins/wp-dbmanager/faq/).
34
 
35
  == Changelog ==
 
 
 
 
 
 
 
 
36
  = Version 2.76 =
37
  * NEW: Add wp_dbmanager_before_escapeshellcmd action just before escapeshellcmd()
38
  * FIXED: Missing / for Windows
3
  Donate link: http://lesterchan.net/site/donation/
4
  Tags: database, manage, wp-dbmanager, manager, table, optimize, backup, queries, query, drop, empty, tables, table, run, repair, cron, schedule, scheduling, automatic
5
  Requires at least: 3.9
6
+ Tested up to: 4.4
7
+ Stable tag: 2.78
8
 
9
  Manages your WordPress database.
10
 
33
  * To know about the difference between WP-DBManager and WP-DB-backup, checkout __What is the difference between WP-DBManager and WP-DB-Backup?__ in the [FAQ section](https://wordpress.org/plugins/wp-dbmanager/faq/).
34
 
35
  == Changelog ==
36
+ = Version 2.78 =
37
+ * FIXED: escapeshellcmd on Windows. Props Gregory Karpinsky.
38
+ * FIXED: Move wp_mkdir_p() up before if check. Props Scott Allen.
39
+
40
+ = Version 2.77 =
41
+ * FIXED: Blank screen downloading backup
42
+ * FIXED: Remove MySQL Version check to display tables stats
43
+
44
  = Version 2.76 =
45
  * NEW: Add wp_dbmanager_before_escapeshellcmd action just before escapeshellcmd()
46
  * FIXED: Missing / for Windows
wp-dbmanager.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP-DBManager
4
  Plugin URI: http://lesterchan.net/portfolio/programming/php/
5
  Description: Manages your WordPress database. Allows you to optimize database, repair database, backup database, restore database, delete backup database , drop/empty tables and run selected queries. Supports automatic scheduling of backing up, optimizing and repairing of database.
6
- Version: 2.76
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
9
  Text Domain: wp-dbmanager
@@ -86,12 +86,12 @@ function cron_dbmanager_backup() {
86
  $backup['filename'] = $backup['date'].'_-_'.DB_NAME.'.sql.gz';
87
  $backup['filepath'] = $backup['path'].'/'.$backup['filename'];
88
  do_action( 'wp_dbmanager_before_escapeshellcmd' );
89
- $backup['command'] = escapeshellcmd( $brace . $backup['mysqldumppath'] . $brace ) . ' --force --host=' . escapeshellarg( $backup['host'] ).' --user=' . escapeshellarg( DB_USER ) . ' --password=' . escapeshellarg( DB_PASSWORD ) . $backup['port'] . $backup['sock'] . ' --add-drop-table --skip-lock-tables ' . DB_NAME . ' | gzip > '.escapeshellcmd( $brace . $backup['filepath'] . $brace );
90
  } else {
91
  $backup['filename'] = $backup['date'].'_-_'.DB_NAME.'.sql';
92
  $backup['filepath'] = $backup['path'].'/'.$backup['filename'];
93
  do_action( 'wp_dbmanager_before_escapeshellcmd' );
94
- $backup['command'] = escapeshellcmd( $brace . $backup['mysqldumppath'] . $brace ) . ' --force --host=' . escapeshellarg( $backup['host'] ).' --user=' . escapeshellarg( DB_USER ). ' --password=' . escapeshellarg( DB_PASSWORD ) . $backup['port'] . $backup['sock'] . ' --add-drop-table --skip-lock-tables ' . DB_NAME . ' > '.escapeshellcmd( $brace . $backup['filepath'] . $brace );
95
  }
96
  execute_backup($backup['command']);
97
  if( ! empty( $backup_email ) )
@@ -197,9 +197,9 @@ function detect_mysql() {
197
  if(substr(PHP_OS,0,3) == 'WIN') {
198
  $mysql_install = $wpdb->get_row("SHOW VARIABLES LIKE 'basedir'");
199
  if($mysql_install) {
200
- $install_path = str_replace('\\', '/', $mysql_install->Value);
201
- $paths['mysql'] = $install_path.'/bin/mysql.exe';
202
- $paths['mysqldump'] = $install_path.'/bin/mysqldump.exe';
203
  } else {
204
  $paths['mysql'] = 'mysql.exe';
205
  $paths['mysqldump'] = 'mysqldump.exe';
@@ -466,24 +466,21 @@ function dbmanager_create_backup_folder() {
466
  }
467
 
468
  // Create Backup Folder
469
- if( is_dir( $backup_path ) && wp_is_writable( $backup_path ) )
470
- {
471
- if( wp_mkdir_p( $backup_path ) )
472
- {
473
- if( is_iis() ) {
474
- if ( ! is_file( $backup_path . '/Web.config' ) ) {
475
- @copy( $plugin_path . 'Web.config.txt', $backup_path . '/Web.config' );
476
- }
477
- } else {
478
- if( ! is_file( $backup_path . '/.htaccess' ) ) {
479
- @copy( $plugin_path . 'htaccess.txt', $backup_path . '/.htaccess' );
480
- }
481
  }
482
- if( ! is_file( $backup_path . '/index.php' ) ) {
483
- @copy( $plugin_path . 'index.php', $backup_path . '/index.php' );
 
484
  }
485
- @chmod( $backup_path, 0750 );
486
  }
 
 
 
 
487
  }
488
  }
489
 
@@ -499,28 +496,26 @@ function dbmanager_try_fix() {
499
 
500
 
501
  ### Function: Download Database
502
- add_action('init', 'download_database');
503
  function download_database() {
504
- if(isset($_POST['do']) && $_POST['do'] == __('Download', 'wp-dbmanager') && !empty($_POST['database_file'])) {
505
- if(strpos($_SERVER['HTTP_REFERER'], admin_url('admin.php?page=wp-dbmanager/database-manage.php')) !== false) {
506
- $database_file = trim($_POST['database_file']);
507
- if(substr($database_file, strlen($database_file) - 4, 4) == '.sql' || substr($database_file, strlen($database_file) - 7, 7) == '.sql.gz') {
508
- check_admin_referer('wp-dbmanager_manage');
509
- $backup_options = get_option('dbmanager_options');
510
- $clean_file_name = sanitize_file_name($database_file);
511
- $clean_file_name = str_replace('sql_.gz', 'sql.gz', $clean_file_name);
512
- $file_path = $backup_options['path'].'/'.$clean_file_name;
513
- header("Pragma: public");
514
- header("Expires: 0");
515
- header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
516
- header("Content-Type: application/force-download");
517
- header("Content-Type: application/octet-stream");
518
- header("Content-Type: application/download");
519
- header("Content-Disposition: attachment; filename=".basename($file_path).";");
520
- header("Content-Transfer-Encoding: binary");
521
- header("Content-Length: ".filesize($file_path));
522
- @readfile($file_path);
523
- }
524
  }
525
  exit();
526
  }
@@ -643,7 +638,7 @@ function dbmanager_options() {
643
  <tr>
644
  <td valign="top"><strong><?php _e('Path To Backup:', 'wp-dbmanager'); ?></strong></td>
645
  <td>
646
- <input type="text" name="db_path" size="60" maxlength="100" value="<?php echo stripslashes($backup_options['path']); ?>" dir="ltr" />
647
  <p><?php _e('The absolute path to your database backup folder without trailing slash. Make sure the folder is writable.', 'wp-dbmanager'); ?></p>
648
  </td>
649
  </tr>
@@ -816,4 +811,4 @@ function dbmanager_options() {
816
  </form>
817
  <?php
818
  }
819
- ?>
3
  Plugin Name: WP-DBManager
4
  Plugin URI: http://lesterchan.net/portfolio/programming/php/
5
  Description: Manages your WordPress database. Allows you to optimize database, repair database, backup database, restore database, delete backup database , drop/empty tables and run selected queries. Supports automatic scheduling of backing up, optimizing and repairing of database.
6
+ Version: 2.78
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
9
  Text Domain: wp-dbmanager
86
  $backup['filename'] = $backup['date'].'_-_'.DB_NAME.'.sql.gz';
87
  $backup['filepath'] = $backup['path'].'/'.$backup['filename'];
88
  do_action( 'wp_dbmanager_before_escapeshellcmd' );
89
+ $backup['command'] = $brace . escapeshellcmd( $backup['mysqldumppath'] ) . $brace . ' --force --host=' . escapeshellarg( $backup['host'] ).' --user=' . escapeshellarg( DB_USER ) . ' --password=' . escapeshellarg( DB_PASSWORD ) . $backup['port'] . $backup['sock'] . ' --add-drop-table --skip-lock-tables ' . DB_NAME . ' | gzip > '. $brace . escapeshellcmd( $backup['filepath'] ) . $brace;
90
  } else {
91
  $backup['filename'] = $backup['date'].'_-_'.DB_NAME.'.sql';
92
  $backup['filepath'] = $backup['path'].'/'.$backup['filename'];
93
  do_action( 'wp_dbmanager_before_escapeshellcmd' );
94
+ $backup['command'] = $brace . escapeshellcmd( $backup['mysqldumppath'] ) . $brace . ' --force --host=' . escapeshellarg( $backup['host'] ).' --user=' . escapeshellarg( DB_USER ). ' --password=' . escapeshellarg( DB_PASSWORD ) . $backup['port'] . $backup['sock'] . ' --add-drop-table --skip-lock-tables ' . DB_NAME . ' > ' . $brace . escapeshellcmd( $backup['filepath'] ) . $brace;
95
  }
96
  execute_backup($backup['command']);
97
  if( ! empty( $backup_email ) )
197
  if(substr(PHP_OS,0,3) == 'WIN') {
198
  $mysql_install = $wpdb->get_row("SHOW VARIABLES LIKE 'basedir'");
199
  if($mysql_install) {
200
+ $install_path = trailingslashit( str_replace('\\', '/', $mysql_install->Value) );
201
+ $paths['mysql'] = $install_path.'bin/mysql.exe';
202
+ $paths['mysqldump'] = $install_path.'bin/mysqldump.exe';
203
  } else {
204
  $paths['mysql'] = 'mysql.exe';
205
  $paths['mysqldump'] = 'mysqldump.exe';
466
  }
467
 
468
  // Create Backup Folder
469
+ wp_mkdir_p( $backup_path );
470
+ if( is_dir( $backup_path ) && wp_is_writable( $backup_path ) ) {
471
+ if( is_iis() ) {
472
+ if ( ! is_file( $backup_path . '/Web.config' ) ) {
473
+ @copy( $plugin_path . 'Web.config.txt', $backup_path . '/Web.config' );
 
 
 
 
 
 
 
474
  }
475
+ } else {
476
+ if( ! is_file( $backup_path . '/.htaccess' ) ) {
477
+ @copy( $plugin_path . 'htaccess.txt', $backup_path . '/.htaccess' );
478
  }
 
479
  }
480
+ if( ! is_file( $backup_path . '/index.php' ) ) {
481
+ @copy( $plugin_path . 'index.php', $backup_path . '/index.php' );
482
+ }
483
+ @chmod( $backup_path, 0750 );
484
  }
485
  }
486
 
496
 
497
 
498
  ### Function: Download Database
499
+ add_action( 'init', 'download_database' );
500
  function download_database() {
501
+ if( isset( $_POST['do'] ) && $_POST['do'] === __( 'Download', 'wp-dbmanager' ) && ! empty( $_POST['database_file'] ) ) {
502
+ check_admin_referer( 'wp-dbmanager_manage' );
503
+ $database_file = trim( $_POST['database_file'] );
504
+ if( substr( $database_file, strlen( $database_file ) -4, 4 ) === '.sql' || substr( $database_file, strlen( $database_file ) -7, 7 ) === '.sql.gz' ) {
505
+ $backup_options = get_option( 'dbmanager_options' );
506
+ $clean_file_name = sanitize_file_name( $database_file );
507
+ $clean_file_name = str_replace( 'sql_.gz', 'sql.gz', $clean_file_name );
508
+ $file_path = $backup_options['path'].'/'.$clean_file_name;
509
+ header( 'Pragma: public' );
510
+ header( 'Expires: 0' );
511
+ header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
512
+ header( 'Content-Type: application/force-download' );
513
+ header( 'Content-Type: application/octet-stream' );
514
+ header( 'Content-Type: application/download' );
515
+ header( 'Content-Disposition: attachment; filename=' . basename( $file_path ) . ';' );
516
+ header( 'Content-Transfer-Encoding: binary' );
517
+ header( 'Content-Length: '.filesize( $file_path ) );
518
+ @readfile( $file_path );
 
 
519
  }
520
  exit();
521
  }
638
  <tr>
639
  <td valign="top"><strong><?php _e('Path To Backup:', 'wp-dbmanager'); ?></strong></td>
640
  <td>
641
+ <input type="text" name="db_path" size="60" maxlength="105" value="<?php echo stripslashes($backup_options['path']); ?>" dir="ltr" />
642
  <p><?php _e('The absolute path to your database backup folder without trailing slash. Make sure the folder is writable.', 'wp-dbmanager'); ?></p>
643
  </td>
644
  </tr>
811
  </form>
812
  <?php
813
  }
814
+ ?>