WP-DBManager - Version 2.75

Version Description

N/A

Download this release

Release Info

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

Code changes from version 2.74 to 2.75

Files changed (5) hide show
  1. Web.config.txt +11 -0
  2. database-backup.php +38 -16
  3. index.php +0 -0
  4. readme.txt +13 -5
  5. wp-dbmanager.php +75 -23
Web.config.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <configuration>
2
+ <system.webServer>
3
+ <security>
4
+ <requestFiltering>
5
+ <hiddenSegments>
6
+ <add segment="." />
7
+ </hiddenSegments>
8
+ </requestFiltering>
9
+ </security>
10
+ </system.webServer>
11
+ </configuration>
database-backup.php CHANGED
@@ -63,10 +63,9 @@ if(!empty($_POST['do'])) {
63
  }
64
  }
65
 
66
-
67
  ### Backup File Name
68
  $backup['filename'] = $backup['date'].'_-_'.DB_NAME.'.sql';
69
-
70
 
71
  ### MYSQL Base Dir
72
  $status_count = 0;
@@ -76,21 +75,44 @@ $stats_function_disabled = 0;
76
  <!-- Checking Backup Status -->
77
  <div class="wrap">
78
  <h2><?php _e('Backup Database', 'wp-dbmanager'); ?></h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  <h3><?php _e('Checking Backup Status', 'wp-dbmanager'); ?></h3>
80
  <p>
81
- <?php _e('Checking Backup Folder', 'wp-dbmanager'); ?> <span dir="ltr">(<strong><?php echo stripslashes($backup['path']); ?></strong>)</span> ...<br />
82
  <?php
83
- if( realpath( $backup['path'] ) === false ) {
84
- echo '<p style="color: red;">' . sprintf( __( '%s is not a valid backup path', 'wp-dbmanager' ), stripslashes( $backup['path'] ) ) . '</p>';
85
  $status_count++;
86
  } else {
87
- if (@is_dir(stripslashes($backup['path']))) {
88
  echo '<p style="color: green;">' . __('Backup folder exists', 'wp-dbmanager') . '</p>';
89
  $status_count++;
90
  } else {
91
  echo '<p style="color: red;">' . sprintf(__('Backup folder does NOT exist. Please create \'backup-db\' folder in \'%s\' folder and CHMOD it to \'777\' or change the location of the backup folder under DB Option.', 'wp-dbmanager'), WP_CONTENT_DIR) . '</p>';
92
  }
93
- if (@is_writable(stripslashes($backup['path']))) {
94
  echo '<p style="color: green;">' . __('Backup folder is writable', 'wp-dbmanager') . '</p>';
95
  $status_count++;
96
  } else {
@@ -105,8 +127,8 @@ $stats_function_disabled = 0;
105
  echo '<p style="color: red;">' . sprintf( __( '%s is not a valid backup mysqldump path', 'wp-dbmanager' ), stripslashes( $backup['mysqldumppath'] ) ) . '</p>';
106
  $status_count++;
107
  } else {
108
- if (@file_exists(stripslashes($backup['mysqldumppath']))) {
109
- echo __('Checking MYSQL Dump Path', 'wp-dbmanager') . ' <span dir="ltr">(<strong>' . stripslashes($backup['mysqldumppath']) . '</strong>)</span> ...<br />';
110
  echo '<p style="color: green;">' . __('MYSQL dump path exists.', 'wp-dbmanager') . '</p>';
111
  $status_count++;
112
  } else {
@@ -122,7 +144,7 @@ $stats_function_disabled = 0;
122
  echo '<p style="color: red;">' . sprintf( __( '%s is not a valid backup mysql path', 'wp-dbmanager' ), stripslashes( $backup['mysqlpath'] ) ) . '</p>';
123
  $status_count++;
124
  } else {
125
- if (@file_exists(stripslashes($backup['mysqlpath']))) {
126
  echo __('Checking MYSQL Path', 'wp-dbmanager') . ' <span dir="ltr">(<strong>' . stripslashes($backup['mysqlpath']) . '</strong>)</span> ...<br />';
127
  echo '<p style="color: green;">' . __('MYSQL path exists.', 'wp-dbmanager') . '</p>';
128
  $status_count++;
@@ -136,20 +158,20 @@ $stats_function_disabled = 0;
136
  <p>
137
  <?php _e('Checking PHP Functions', 'wp-dbmanager'); ?> <span dir="ltr">(<strong>passthru()</strong>, <strong>system()</strong> <?php _e('and', 'wp-dbmanager'); ?> <strong>exec()</strong>)</span> ...<br />
138
  <?php
139
- if(function_exists('passthru')) {
140
  echo '<p style="color: green;"><span dir="ltr">passthru()</span> '.__('enabled', 'wp-dbmanager').'.</p>';
141
  $status_count++;
142
  } else {
143
  echo '<p style="color: red;"><span dir="ltr">passthru()</span> '.__('disabled', 'wp-dbmanager').'.</p>';
144
  $stats_function_disabled++;
145
  }
146
- if(function_exists('system')) {
147
  echo '<p style="color: green;"><span dir="ltr">system()</span> '.__('enabled', 'wp-dbmanager').'.</p>';
148
  } else {
149
  echo '<p style="color: red;"><span dir="ltr">system()</span> '.__('disabled', 'wp-dbmanager').'.</p>';
150
  $stats_function_disabled++;
151
  }
152
- if(function_exists('exec')) {
153
  echo '<p style="color: green;"><span dir="ltr">exec()</span> '.__('enabled', 'wp-dbmanager').'.</p>';
154
  } else {
155
  echo '<p style="color: red;"><span dir="ltr">exec()</span> '.__('disabled', 'wp-dbmanager').'.</p>';
@@ -159,9 +181,9 @@ $stats_function_disabled = 0;
159
  </p>
160
  <p>
161
  <?php
162
- if($status_count == 5) {
163
  echo '<strong><p style="color: green;">'.__('Excellent. You Are Good To Go.', 'wp-dbmanager').'</p></strong>';
164
- } else if($stats_function_disabled == 3) {
165
  echo '<strong><p style="color: red;">'.__('I\'m sorry, your server administrator has disabled passthru(), system() and exec(), thus you cannot use this backup script. You may consider using the default WordPress database backup script instead.', 'wp-dbmanager').'</p></strong>';
166
  } else {
167
  echo '<strong><p style="color: red;">'.__('Please Rectify The Error Highlighted In Red Before Proceeding On.', 'wp-dbmanager').'</p></strong>';
@@ -189,7 +211,7 @@ $stats_function_disabled = 0;
189
  </tr>
190
  <tr style="background-color: #eee;">
191
  <th><?php _e('Database Backup To:', 'wp-dbmanager'); ?></th>
192
- <td><span dir="ltr"><?php echo stripslashes($backup['path']); ?></span></td>
193
  </tr>
194
  <tr>
195
  <th><?php _e('Database Backup Date:', 'wp-dbmanager'); ?></th>
63
  }
64
  }
65
 
 
66
  ### Backup File Name
67
  $backup['filename'] = $backup['date'].'_-_'.DB_NAME.'.sql';
68
+ $backup_path = stripslashes( $backup['path'] );
69
 
70
  ### MYSQL Base Dir
71
  $status_count = 0;
75
  <!-- Checking Backup Status -->
76
  <div class="wrap">
77
  <h2><?php _e('Backup Database', 'wp-dbmanager'); ?></h2>
78
+ <h3><?php _e('Checking Security Status', 'wp-dbmanager'); ?></h3>
79
+ <p>
80
+ <?php
81
+ if( is_iis() ) {
82
+ if ( ! is_file( $backup_path . '/Web.config' ) ) {
83
+ echo '<p style="color: red;">' . sprintf( __( 'Web.config is missing from %s', 'wp-dbmanager' ), $backup_path ) . '</p>';
84
+ } else {
85
+ echo '<p style="color: green;">' . sprintf( __( 'Web.config is present in %s', 'wp-dbmanager' ), $backup_path ) . '</p>';
86
+ }
87
+ } else {
88
+ if( ! is_file( $backup_path . '/.htaccess' ) ) {
89
+ echo '<p style="color: red;">' . sprintf( __( '.htaccess is missing from %s', 'wp-dbmanager' ), $backup_path ) . '</p>';
90
+ } else {
91
+ echo '<p style="color: green;">' . sprintf( __( '.htaccess is present in %s', 'wp-dbmanager' ), $backup_path ) . '</p>';
92
+ }
93
+ }
94
+ if( ! is_file( $backup_path . '/index.php' ) ) {
95
+ echo '<p style="color: red;">' . sprintf( __( 'index.php is missing from %s', 'wp-dbmanager' ), $backup_path ) . '</p>';
96
+ } else {
97
+ echo '<p style="color: green;">' . sprintf( __( 'index.php is present in %s', 'wp-dbmanager' ), $backup_path ) . '</p>';
98
+ }
99
+ ?>
100
+ </p>
101
  <h3><?php _e('Checking Backup Status', 'wp-dbmanager'); ?></h3>
102
  <p>
103
+ <?php _e('Checking Backup Folder', 'wp-dbmanager'); ?> <span dir="ltr">(<strong><?php echo $backup_path; ?></strong>)</span> ...<br />
104
  <?php
105
+ if( realpath( $backup_path ) === false ) {
106
+ echo '<p style="color: red;">' . sprintf( __( '%s is not a valid backup path', 'wp-dbmanager' ), $backup_path ) . '</p>';
107
  $status_count++;
108
  } else {
109
+ if ( @is_dir( $backup_path ) ) {
110
  echo '<p style="color: green;">' . __('Backup folder exists', 'wp-dbmanager') . '</p>';
111
  $status_count++;
112
  } else {
113
  echo '<p style="color: red;">' . sprintf(__('Backup folder does NOT exist. Please create \'backup-db\' folder in \'%s\' folder and CHMOD it to \'777\' or change the location of the backup folder under DB Option.', 'wp-dbmanager'), WP_CONTENT_DIR) . '</p>';
114
  }
115
+ if ( @is_writable( $backup_path ) ) {
116
  echo '<p style="color: green;">' . __('Backup folder is writable', 'wp-dbmanager') . '</p>';
117
  $status_count++;
118
  } else {
127
  echo '<p style="color: red;">' . sprintf( __( '%s is not a valid backup mysqldump path', 'wp-dbmanager' ), stripslashes( $backup['mysqldumppath'] ) ) . '</p>';
128
  $status_count++;
129
  } else {
130
+ if ( @file_exists( stripslashes( $backup['mysqldumppath'] ) ) ) {
131
+ echo __('Checking MYSQL Dump Path', 'wp-dbmanager') . ' <span dir="ltr">(<strong>' . stripslashes( $backup['mysqldumppath'] ) . '</strong>)</span> ...<br />';
132
  echo '<p style="color: green;">' . __('MYSQL dump path exists.', 'wp-dbmanager') . '</p>';
133
  $status_count++;
134
  } else {
144
  echo '<p style="color: red;">' . sprintf( __( '%s is not a valid backup mysql path', 'wp-dbmanager' ), stripslashes( $backup['mysqlpath'] ) ) . '</p>';
145
  $status_count++;
146
  } else {
147
+ if ( @file_exists( stripslashes($backup['mysqlpath'] ) ) ) {
148
  echo __('Checking MYSQL Path', 'wp-dbmanager') . ' <span dir="ltr">(<strong>' . stripslashes($backup['mysqlpath']) . '</strong>)</span> ...<br />';
149
  echo '<p style="color: green;">' . __('MYSQL path exists.', 'wp-dbmanager') . '</p>';
150
  $status_count++;
158
  <p>
159
  <?php _e('Checking PHP Functions', 'wp-dbmanager'); ?> <span dir="ltr">(<strong>passthru()</strong>, <strong>system()</strong> <?php _e('and', 'wp-dbmanager'); ?> <strong>exec()</strong>)</span> ...<br />
160
  <?php
161
+ if( function_exists( 'passthru' ) ) {
162
  echo '<p style="color: green;"><span dir="ltr">passthru()</span> '.__('enabled', 'wp-dbmanager').'.</p>';
163
  $status_count++;
164
  } else {
165
  echo '<p style="color: red;"><span dir="ltr">passthru()</span> '.__('disabled', 'wp-dbmanager').'.</p>';
166
  $stats_function_disabled++;
167
  }
168
+ if( function_exists( 'system' ) ) {
169
  echo '<p style="color: green;"><span dir="ltr">system()</span> '.__('enabled', 'wp-dbmanager').'.</p>';
170
  } else {
171
  echo '<p style="color: red;"><span dir="ltr">system()</span> '.__('disabled', 'wp-dbmanager').'.</p>';
172
  $stats_function_disabled++;
173
  }
174
+ if( function_exists( 'exec' ) ) {
175
  echo '<p style="color: green;"><span dir="ltr">exec()</span> '.__('enabled', 'wp-dbmanager').'.</p>';
176
  } else {
177
  echo '<p style="color: red;"><span dir="ltr">exec()</span> '.__('disabled', 'wp-dbmanager').'.</p>';
181
  </p>
182
  <p>
183
  <?php
184
+ if( $status_count === 5 ) {
185
  echo '<strong><p style="color: green;">'.__('Excellent. You Are Good To Go.', 'wp-dbmanager').'</p></strong>';
186
+ } else if( $stats_function_disabled === 3 ) {
187
  echo '<strong><p style="color: red;">'.__('I\'m sorry, your server administrator has disabled passthru(), system() and exec(), thus you cannot use this backup script. You may consider using the default WordPress database backup script instead.', 'wp-dbmanager').'</p></strong>';
188
  } else {
189
  echo '<strong><p style="color: red;">'.__('Please Rectify The Error Highlighted In Red Before Proceeding On.', 'wp-dbmanager').'</p></strong>';
211
  </tr>
212
  <tr style="background-color: #eee;">
213
  <th><?php _e('Database Backup To:', 'wp-dbmanager'); ?></th>
214
+ <td><span dir="ltr"><?php echo $backup_path; ?></span></td>
215
  </tr>
216
  <tr>
217
  <th><?php _e('Database Backup Date:', 'wp-dbmanager'); ?></th>
index.php ADDED
File without changes
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.0
7
- Stable tag: 2.74
8
 
9
  Manages your WordPress database.
10
 
@@ -33,6 +33,12 @@ 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
  * FIXED: escapeshellarg() already escape $, no need to double escape it
37
 
38
  = Version 2.73 =
@@ -160,10 +166,12 @@ Allows you to optimize database, repair database, backup database, restore datab
160
  2. Put: `Folder: wp-dbmanager`
161
  3. Activate `WP-DBManager` Plugin
162
  4. Rename `htaccess.txt` to `.htaccess` file in `Folder: wp-content/plugins/wp-dbmanager`
163
- 5. The script will automatically create a folder called `backup-db` in the wp-content folder if that folder is writable. If it is not created, please create it and CHMOD it to 777
164
  6. Open `Folder: wp-content/backup-db`
165
- 7. Move the `.htaccess` file from `Folder: wp-content/plugins/wp-dbmanager` to `Folder: wp-content/backup-db`
166
- 8. Go to `WP-Admin -> Database -> DB Options` to configure the database options.
 
 
167
 
168
  == Upgrading ==
169
 
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.1
7
+ Stable tag: 2.75
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.75 =
37
+ * FIXED: When activating the plugin, copy index.php to the backup folder
38
+ * FIXED: If you are on Apache, .htaccess will be copied to the backup folder, if you are on IIS, Web.config will be copied to the backup folder
39
+ * FIXED: When choosing 1 Month(s) for Backup/Optimize/Repair, the next date calculation is wrong
40
+
41
+ = Version 2.74 =
42
  * FIXED: escapeshellarg() already escape $, no need to double escape it
43
 
44
  = Version 2.73 =
166
  2. Put: `Folder: wp-dbmanager`
167
  3. Activate `WP-DBManager` Plugin
168
  4. Rename `htaccess.txt` to `.htaccess` file in `Folder: wp-content/plugins/wp-dbmanager`
169
+ 5. The script will automatically create a folder called `backup-db` in the wp-content folder if that folder is writable. If it is not created, please create the folder and ensure that the folder is writable
170
  6. Open `Folder: wp-content/backup-db`
171
+ 7. If you are on Apache, move the `htaccess.txt` file from `Folder: wp-content/plugins/wp-dbmanager` to `Folder: wp-content/backup-db/.htaccess` if it is not there already
172
+ 8. If you are on IIS, move the `Web.config.txt` file from `Folder: wp-content/plugins/wp-dbmanager` to `Folder: wp-content/backup-db/Web.config` if it is not there already
173
+ 9. Move `index.php` file from `Folder: wp-content/plugins/wp-dbmanager` to `Folder: wp-content/backup-db/index.php` if it is not there already
174
+ 10. Go to `WP-Admin -> Database -> DB Options` to configure the database options
175
 
176
  == Upgrading ==
177
 
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.74
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
9
  Text Domain: wp-dbmanager
@@ -154,21 +154,34 @@ function dbmanager_admin_notices() {
154
  $backup_options = get_option( 'dbmanager_options' );
155
  $backup_folder_writable = ( is_dir( $backup_options['path'] ) && wp_is_writable( $backup_options['path'] ) );
156
  $htaccess_exists = ( file_exists( $backup_options['path'] . '/.htaccess' ) );
 
 
157
 
158
- if( !isset( $backup_options['hide_admin_notices'] ) || intval( $backup_options['hide_admin_notices'] ) === 0 )
159
  {
160
- if( !$backup_folder_writable || !$htaccess_exists ) {
161
- echo '<div class="error">';
162
 
 
163
  if( !$backup_folder_writable ) {
164
- echo '<p style="font-weight: bold;">'.__('Your backup folder is NOT writable', 'wp-postratings').'</p>';
165
- echo '<p>'.sprintf( __( 'To correct this issue, make the folder <strong>%s</strong> writable.', 'wp-dbmanager'), $backup_options['path'] ).'</p>';
166
  }
167
- if( !$htaccess_exists ) {
168
- echo '<p style="font-weight: bold;">'.__('Your backup folder MIGHT be visible to the public', 'wp-dbmanager').'</p>';
169
- echo '<p>'.sprintf( __( 'To correct this issue, move the file from <strong>%s</strong> to <strong>%s</strong>', 'wp-dbmanager'), plugin_dir_path( __FILE__ ) . 'htaccess.txt', $backup_options['path'] .'/.htaccess' ).'</p>';
170
  }
171
-
 
 
 
 
 
 
 
 
 
 
 
 
172
  echo '</div>';
173
  }
174
  }
@@ -201,6 +214,15 @@ function detect_mysql() {
201
  return $paths;
202
  }
203
 
 
 
 
 
 
 
 
 
 
204
 
205
  ### Executes OS-Dependent mysqldump Command (By: Vlad Sharanhovich)
206
  function execute_backup($command) {
@@ -422,24 +444,54 @@ function dbmanager_activation( $network_wide )
422
  }
423
 
424
  function dbmanager_activate() {
 
 
 
 
 
 
 
 
 
 
 
425
  $plugin_path = plugin_dir_path( __FILE__ );
426
- $default_backup_folder = WP_CONTENT_DIR . '/backup-db';
 
 
 
 
 
427
 
428
  // Create Backup Folder
429
- if( is_dir( $default_backup_folder ) && wp_is_writable( $default_backup_folder ) )
430
  {
431
- if( wp_mkdir_p( $default_backup_folder ) )
432
  {
433
- @copy( $plugin_path . 'htaccess.txt', $default_backup_folder . '/.htaccess' );
434
- @chmod( $default_backup_folder, 0750 );
 
 
 
 
 
 
 
 
 
 
 
435
  }
436
  }
 
437
 
438
- // Set 'manage_database' Capabilities To Administrator
439
- $role = get_role( 'administrator' );
440
- if( !$role->has_cap( 'manage_database') )
441
- {
442
- $role->add_cap( 'manage_database' );
 
 
443
  }
444
  }
445
 
@@ -647,7 +699,7 @@ function dbmanager_options() {
647
  <option value="3600"<?php selected('3600', $backup_options['backup_period']); ?>><?php _e('Hour(s)', 'wp-dbmanager'); ?></option>
648
  <option value="86400"<?php selected('86400', $backup_options['backup_period']); ?>><?php _e('Day(s)', 'wp-dbmanager'); ?></option>
649
  <option value="604800"<?php selected('604800', $backup_options['backup_period']); ?>><?php _e('Week(s)', 'wp-dbmanager'); ?></option>
650
- <option value="18144000"<?php selected('18144000', $backup_options['backup_period']); ?>><?php _e('Month(s)', 'wp-dbmanager'); ?></option>
651
  </select>&nbsp;&nbsp;&nbsp;
652
  <?php _e('Gzip', 'wp-dbmanager'); ?>
653
  <select name="db_backup_gzip" size="1">
@@ -677,7 +729,7 @@ function dbmanager_options() {
677
  <option value="3600"<?php selected('3600', $backup_options['optimize_period']); ?>><?php _e('Hour(s)', 'wp-dbmanager'); ?></option>
678
  <option value="86400"<?php selected('86400', $backup_options['optimize_period']); ?>><?php _e('Day(s)', 'wp-dbmanager'); ?></option>
679
  <option value="604800"<?php selected('604800', $backup_options['optimize_period']); ?>><?php _e('Week(s)', 'wp-dbmanager'); ?></option>
680
- <option value="18144000"<?php selected('18144000', $backup_options['optimize_period']); ?>><?php _e('Month(s)', 'wp-dbmanager'); ?></option>
681
  </select>
682
  </p>
683
  <p><?php _e('WP-DBManager can automatically optimize your database after a certain period.', 'wp-dbmanager'); ?></p>
@@ -702,7 +754,7 @@ function dbmanager_options() {
702
  <option value="3600"<?php selected('3600', $backup_options['repair_period']); ?>><?php _e('Hour(s)', 'wp-dbmanager'); ?></option>
703
  <option value="86400"<?php selected('86400', $backup_options['repair_period']); ?>><?php _e('Day(s)', 'wp-dbmanager'); ?></option>
704
  <option value="604800"<?php selected('604800', $backup_options['repair_period']); ?>><?php _e('Week(s)', 'wp-dbmanager'); ?></option>
705
- <option value="18144000"<?php selected('18144000', $backup_options['repair_period']); ?>><?php _e('Month(s)', 'wp-dbmanager'); ?></option>
706
  </select>
707
  </p>
708
  <p><?php _e('WP-DBManager can automatically repair your database after a certain period.', 'wp-dbmanager'); ?></p>
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.75
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: http://lesterchan.net
9
  Text Domain: wp-dbmanager
154
  $backup_options = get_option( 'dbmanager_options' );
155
  $backup_folder_writable = ( is_dir( $backup_options['path'] ) && wp_is_writable( $backup_options['path'] ) );
156
  $htaccess_exists = ( file_exists( $backup_options['path'] . '/.htaccess' ) );
157
+ $webconfig_exists = ( file_exists( $backup_options['path'] . '/Web.config' ) );
158
+ $index_exists = ( file_exists( $backup_options['path'] . '/index.php' ) );
159
 
160
+ if( ! isset( $backup_options['hide_admin_notices'] ) || intval( $backup_options['hide_admin_notices'] ) === 0 )
161
  {
162
+ if( ! $backup_folder_writable || ! $index_exists || ( is_iis() && ! $webconfig_exists ) || ( ! is_iis() && ! $htaccess_exists ) ) {
 
163
 
164
+ echo '<div class="error">';
165
  if( !$backup_folder_writable ) {
166
+ echo '<p style="font-weight: bold;">' . __( 'Your backup folder is NOT writable', 'wp-postratings') . '</p>';
167
+ echo '<p>'.sprintf( __( 'To correct this issue, make the folder <strong>%s</strong> writable.', 'wp-dbmanager' ), $backup_options['path'] ).'</p>';
168
  }
169
+ if( ! $index_exists || ( is_iis() && ! $webconfig_exists ) || ( ! is_iis() && ! $htaccess_exists ) ) {
170
+ echo '<p style="font-weight: bold;">'.__( 'Your backup folder MIGHT be visible to the public', 'wp-dbmanager' ).'</p>';
 
171
  }
172
+ if( is_iis() ) {
173
+ if( ! $webconfig_exists ) {
174
+ echo '<p>'.sprintf( __( 'To correct this issue, move the file from <strong>%s</strong> to <strong>%s</strong>', 'wp-dbmanager'), plugin_dir_path( __FILE__ ) . 'Web.config.txt', $backup_options['path'] .'/Web.config' ).'</p>';
175
+ }
176
+ } else {
177
+ if( ! $htaccess_exists ) {
178
+ echo '<p>'.sprintf( __( 'To correct this issue, move the file from <strong>%s</strong> to <strong>%s</strong>', 'wp-dbmanager'), plugin_dir_path( __FILE__ ) . 'htaccess.txt', $backup_options['path'] .'/.htaccess' ).'</p>';
179
+ }
180
+ }
181
+ if( ! $index_exists ) {
182
+ echo '<p>'.sprintf( __( 'To correct this issue, move the file from <strong>%s</strong> to <strong>%s</strong>', 'wp-dbmanager'), plugin_dir_path( __FILE__ ) . 'index.php', $backup_options['path'] .'/index.php' ).'</p>';
183
+ }
184
+ echo '<p>' . sprintf( __( '<a href="%s">Click here</a> to let WP-DBManager try to fix it', 'wp-dbmanager' ), wp_nonce_url( admin_url( 'admin.php?page=wp-dbmanager/database-backup.php&try_fix=1' ), 'wp-dbmanager_fix' ) ) . '</a></p>';
185
  echo '</div>';
186
  }
187
  }
214
  return $paths;
215
  }
216
 
217
+ ### Function: Check if WordPress is installed on IIS
218
+ function is_iis() {
219
+ $server_software = strtolower( $_SERVER['SERVER_SOFTWARE'] );
220
+ if ( strpos( $server_software, 'microsoft-iis') !== false ) {
221
+ return true;
222
+ }
223
+
224
+ return false;
225
+ }
226
 
227
  ### Executes OS-Dependent mysqldump Command (By: Vlad Sharanhovich)
228
  function execute_backup($command) {
444
  }
445
 
446
  function dbmanager_activate() {
447
+ dbmanager_create_backup_folder();
448
+
449
+ // Set 'manage_database' Capabilities To Administrator
450
+ $role = get_role( 'administrator' );
451
+ if( ! $role->has_cap( 'manage_database') )
452
+ {
453
+ $role->add_cap( 'manage_database' );
454
+ }
455
+ }
456
+
457
+ function dbmanager_create_backup_folder() {
458
  $plugin_path = plugin_dir_path( __FILE__ );
459
+ $backup_path = WP_CONTENT_DIR . '/backup-db';
460
+ $backup_options = get_option( 'dbmanager_options' );
461
+
462
+ if( ! empty( $backup_options['path'] ) ) {
463
+ $backup_path = $backup_options['path'];
464
+ }
465
 
466
  // Create Backup Folder
467
+ if( is_dir( $backup_path ) && wp_is_writable( $backup_path ) )
468
  {
469
+ if( wp_mkdir_p( $backup_path ) )
470
  {
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
+ }
487
 
488
+ add_action( 'init', 'dbmanager_try_fix' );
489
+ function dbmanager_try_fix() {
490
+ if ( ! empty( $_GET['try_fix'] ) ) {
491
+ if ( intval( $_GET['try_fix'] ) === 1 ) {
492
+ check_admin_referer( 'wp-dbmanager_fix' );
493
+ dbmanager_create_backup_folder();
494
+ }
495
  }
496
  }
497
 
699
  <option value="3600"<?php selected('3600', $backup_options['backup_period']); ?>><?php _e('Hour(s)', 'wp-dbmanager'); ?></option>
700
  <option value="86400"<?php selected('86400', $backup_options['backup_period']); ?>><?php _e('Day(s)', 'wp-dbmanager'); ?></option>
701
  <option value="604800"<?php selected('604800', $backup_options['backup_period']); ?>><?php _e('Week(s)', 'wp-dbmanager'); ?></option>
702
+ <option value="2592000"<?php selected('2592000', $backup_options['backup_period']); ?>><?php _e('Month(s)', 'wp-dbmanager'); ?></option>
703
  </select>&nbsp;&nbsp;&nbsp;
704
  <?php _e('Gzip', 'wp-dbmanager'); ?>
705
  <select name="db_backup_gzip" size="1">
729
  <option value="3600"<?php selected('3600', $backup_options['optimize_period']); ?>><?php _e('Hour(s)', 'wp-dbmanager'); ?></option>
730
  <option value="86400"<?php selected('86400', $backup_options['optimize_period']); ?>><?php _e('Day(s)', 'wp-dbmanager'); ?></option>
731
  <option value="604800"<?php selected('604800', $backup_options['optimize_period']); ?>><?php _e('Week(s)', 'wp-dbmanager'); ?></option>
732
+ <option value="2592000"<?php selected('2592000', $backup_options['optimize_period']); ?>><?php _e('Month(s)', 'wp-dbmanager'); ?></option>
733
  </select>
734
  </p>
735
  <p><?php _e('WP-DBManager can automatically optimize your database after a certain period.', 'wp-dbmanager'); ?></p>
754
  <option value="3600"<?php selected('3600', $backup_options['repair_period']); ?>><?php _e('Hour(s)', 'wp-dbmanager'); ?></option>
755
  <option value="86400"<?php selected('86400', $backup_options['repair_period']); ?>><?php _e('Day(s)', 'wp-dbmanager'); ?></option>
756
  <option value="604800"<?php selected('604800', $backup_options['repair_period']); ?>><?php _e('Week(s)', 'wp-dbmanager'); ?></option>
757
+ <option value="2592000"<?php selected('2592000', $backup_options['repair_period']); ?>><?php _e('Month(s)', 'wp-dbmanager'); ?></option>
758
  </select>
759
  </p>
760
  <p><?php _e('WP-DBManager can automatically repair your database after a certain period.', 'wp-dbmanager'); ?></p>