WP-DBManager - Version 2.80.9

Version Description

Download this release

Release Info

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

Code changes from version 2.80.8 to 2.80.9

Files changed (3) hide show
  1. database-manage.php +1 -1
  2. readme.txt +6 -3
  3. wp-dbmanager.php +26 -25
database-manage.php CHANGED
@@ -123,7 +123,7 @@ if( !empty( $_POST['do'] ) ) {
123
  <?php
124
  $no = 0;
125
  $totalsize = 0;
126
- if ( ! is_emtpy_folder( $backup['path'] ) && $handle = opendir( $backup['path'] ) ) {
127
  $database_files = array();
128
  while ( false !== ( $file = readdir( $handle ) ) ) {
129
  if ( $file !== '.' && $file !== '..' && $file !== '.htaccess' && ( file_ext( $file ) === 'sql' || file_ext( $file ) === 'gz' ) ) {
123
  <?php
124
  $no = 0;
125
  $totalsize = 0;
126
+ if ( dbmanager_is_folder_valid( $backup['path'] ) && $handle = opendir( $backup['path'] ) ) {
127
  $database_files = array();
128
  while ( false !== ( $file = readdir( $handle ) ) ) {
129
  if ( $file !== '.' && $file !== '..' && $file !== '.htaccess' && ( file_ext( $file ) === 'sql' || file_ext( $file ) === 'gz' ) ) {
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: 4.0
6
- Tested up to: 6.0
7
- Stable tag: 2.80.8
8
 
9
  Manages your WordPress database.
10
 
@@ -42,7 +42,10 @@ Allows you to optimize database, repair database, backup database, restore datab
42
  * 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/).
43
 
44
  ## Changelog
45
- ### Versio 2.80.8
 
 
 
46
  * FIXED: Miss out database-backup.php.
47
 
48
  ### Version 2.80.7
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: 4.0
6
+ Tested up to: 6.1
7
+ Stable tag: 2.80.9
8
 
9
  Manages your WordPress database.
10
 
42
  * 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/).
43
 
44
  ## Changelog
45
+ ### Version 2.80.9
46
+ * FIXED: Handle folder permissions properly
47
+
48
+ ### Version 2.80.8
49
  * FIXED: Miss out database-backup.php.
50
 
51
  ### Version 2.80.7
wp-dbmanager.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP-DBManager
4
  Plugin URI: https://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.80.8
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: https://lesterchan.net
9
  Text Domain: wp-dbmanager
@@ -68,7 +68,12 @@ add_action('dbmanager_cron_optimize', 'cron_dbmanager_optimize');
68
  add_action('dbmanager_cron_repair', 'cron_dbmanager_repair');
69
  function cron_dbmanager_backup() {
70
  $backup_options = get_option('dbmanager_options');
71
- $backup_email = stripslashes($backup_options['backup_email']);
 
 
 
 
 
72
  if ( (int) $backup_options['backup_period'] > 0 ) {
73
  $backup = array();
74
  $backup['date'] = current_time('timestamp');
@@ -104,6 +109,7 @@ function cron_dbmanager_backup() {
104
  execute_backup( $backup['command'] );
105
  $new_filepath = $backup['path'] . '/' . md5_file( $backup['filepath'] ) . '_-_' . $backup['filename'];
106
  rename( $backup['filepath'], $new_filepath );
 
107
  if ( ! empty( $backup_email ) ) {
108
  dbmanager_email_backup( $backup_email, $new_filepath );
109
  }
@@ -383,29 +389,24 @@ if(!function_exists('file_ext')) {
383
  }
384
 
385
 
386
- ### Function: Check Folder Whether There Is Any File Inside
387
- if(!function_exists('is_emtpy_folder')) {
388
- function is_emtpy_folder($folder){
389
- if(is_dir($folder) ){
390
- $folder_content = '';
391
- $handle = opendir($folder);
392
- while( (gettype( $name = readdir($handle)) != 'boolean')){
393
- if($name != '.htaccess') {
394
- $name_array[] = $name;
395
- }
396
- }
397
- foreach($name_array as $temp)
398
- $folder_content .= $temp;
399
-
400
- if($folder_content == '...')
401
- return true;
402
- else
403
- return false;
404
- closedir($handle);
405
- }
406
- else
407
- return true;
408
  }
 
 
409
  }
410
 
411
 
@@ -413,7 +414,7 @@ if(!function_exists('is_emtpy_folder')) {
413
  function check_backup_files() {
414
  $backup_options = get_option( 'dbmanager_options' );
415
  $database_files = array();
416
- if ( ! is_emtpy_folder( $backup_options['path'] ) ) {
417
  if ( $handle = opendir($backup_options['path'] ) ) {
418
  while ( false !== ( $file = readdir( $handle ) ) ) {
419
  if ( $file !== '.' && $file !== '..' && ( file_ext( $file ) === 'sql' || file_ext( $file ) === 'gz' ) ) {
3
  Plugin Name: WP-DBManager
4
  Plugin URI: https://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.80.9
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: https://lesterchan.net
9
  Text Domain: wp-dbmanager
68
  add_action('dbmanager_cron_repair', 'cron_dbmanager_repair');
69
  function cron_dbmanager_backup() {
70
  $backup_options = get_option('dbmanager_options');
71
+
72
+ // Enesure that backup path is valid before proceeding
73
+ if ( empty( $backup_options['path'] ) || ! dbmanager_is_folder_valid( $backup_options['path'] ) ) {
74
+ return;
75
+ }
76
+
77
  if ( (int) $backup_options['backup_period'] > 0 ) {
78
  $backup = array();
79
  $backup['date'] = current_time('timestamp');
109
  execute_backup( $backup['command'] );
110
  $new_filepath = $backup['path'] . '/' . md5_file( $backup['filepath'] ) . '_-_' . $backup['filename'];
111
  rename( $backup['filepath'], $new_filepath );
112
+ $backup_email = stripslashes( $backup_options['backup_email'] );
113
  if ( ! empty( $backup_email ) ) {
114
  dbmanager_email_backup( $backup_email, $new_filepath );
115
  }
389
  }
390
 
391
 
392
+ ### Function: Check Folder Whether There Are Any Files Inside
393
+ function dbmanager_is_folder_valid( $folder ){
394
+ // Check folder whether it is readable
395
+ if ( ! is_readable( $folder ) ) {
396
+ return false;
397
+ }
398
+
399
+ // Ensure folder is a directory
400
+ if ( ! is_dir( $folder ) ) {
401
+ return false;
402
+ }
403
+
404
+ // Ensure folder is not empty. 2 because it includes '.' and '..'
405
+ if ( scandir( $folder ) <= 2 ) {
406
+ return false;
 
 
 
 
 
 
 
407
  }
408
+
409
+ return true;
410
  }
411
 
412
 
414
  function check_backup_files() {
415
  $backup_options = get_option( 'dbmanager_options' );
416
  $database_files = array();
417
+ if ( dbmanager_is_folder_valid( $backup_options['path'] ) ) {
418
  if ( $handle = opendir($backup_options['path'] ) ) {
419
  while ( false !== ( $file = readdir( $handle ) ) ) {
420
  if ( $file !== '.' && $file !== '..' && ( file_ext( $file ) === 'sql' || file_ext( $file ) === 'gz' ) ) {