| @@ -1,2170 +1,2985 @@ | ||
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * Backup admin. | |
| 4 | - * | |
| 5 | - * @package wpdbbkp | |
| 6 | - */ | |
| 7 | - | |
| 8 | -ob_start(); | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | - exit; // Exit if accessed directly. | |
| 11 | -} | |
| 12 | - | |
| 13 | -/** | |
| 14 | - * Main class wpdb_admin. | |
| 15 | - * | |
| 16 | - * @class Wpdb_Admin | |
| 17 | - */ | |
| 18 | -class Wpdb_Admin { | |
| 19 | - | |
| 20 | - /** | |
| 21 | - * Construct. | |
| 22 | - */ | |
| 23 | - public function __construct() { | |
| 24 | - add_action( 'admin_init', array( $this, 'wp_db_backup_admin_init' ) ); | |
| 25 | - add_action( 'admin_init', array( $this, 'admin_scripts_style' ) ); | |
| 26 | - add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 ); | |
| 27 | - add_filter( 'cron_schedules', array( $this, 'wp_db_backup_cron_schedules' ) ); | |
| 28 | - add_action( 'wp_db_backup_event', array( $this, 'wp_db_backup_event_process' ) ); | |
| 29 | - add_action( 'wp', array( $this, 'wp_db_backup_scheduler_activation' ) ); | |
| 30 | - add_action( 'wp_logout', array( $this, 'wp_db_cookie_expiration' ) ); // Fixed Vulnerability 22-06-2016 for prevent direct download. | |
| 31 | - add_action( 'wp_db_backup_completed', array( $this, 'wp_db_backup_completed_local' ), 12 ); | |
| 32 | - } | |
| 33 | - | |
| 34 | - /** | |
| 35 | - * Backup Menu. | |
| 36 | - */ | |
| 37 | - public function admin_menu() { | |
| 38 | - $page = add_management_page( 'WP-DB Backup', 'WP-DB Backup ', 'manage_options', 'wp-database-backup', array( $this, 'wp_db_backup_settings_page' ) ); | |
| 39 | - } | |
| 40 | - | |
| 41 | - /** | |
| 42 | - * Start Fixed Vulnerability 22-06-2016 for prevent direct download. | |
| 43 | - */ | |
| 44 | - public function wp_db_cookie_expiration() { | |
| 45 | - setcookie( 'can_download', 0, time() - 300, COOKIEPATH, COOKIE_DOMAIN ); | |
| 46 | - if ( SITECOOKIEPATH !== COOKIEPATH ) { | |
| 47 | - setcookie( 'can_download', 0, time() - 300, SITECOOKIEPATH, COOKIE_DOMAIN ); | |
| 48 | - } | |
| 49 | - } | |
| 50 | - | |
| 51 | - /** | |
| 52 | - * If Checked then it will remove local backup after uploading to destination. | |
| 53 | - * | |
| 54 | - * @param array $args - backup details. | |
| 55 | - */ | |
| 56 | - public function wp_db_backup_completed_local( &$args ) { | |
| 57 | - $wp_db_remove_local_backup = get_option( 'wp_db_remove_local_backup' ); | |
| 58 | - if ( 1 === $wp_db_remove_local_backup ) { | |
| 59 | - if ( file_exists( $args[1] ) ) { | |
| 60 | - unlink( $args[1] );// File path. | |
| 61 | - } | |
| 62 | - } | |
| 63 | - } | |
| 64 | - | |
| 65 | - /** | |
| 66 | - * Admin init. | |
| 67 | - */ | |
| 68 | - public function wp_db_backup_admin_init() { | |
| 69 | - // Start Fixed Vulnerability 04-08-2016 for data save in options. | |
| 70 | - if ( isset( $_GET['page'] ) && 'wp-database-backup' === $_GET['page'] ) { | |
| 71 | - if ( ! empty( $_POST ) && ! ( isset( $_POST['option_page'] ) && 'wp_db_backup_options' === $_POST['option_page'] ) ) { | |
| 72 | - if ( false === isset( $_REQUEST['_wpnonce'] ) || false === wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'wp-database-backup' ) ) { | |
| 73 | - die( 'WPDB :: Invalid Access' ); | |
| 74 | - } | |
| 75 | - } | |
| 76 | - | |
| 77 | - // End Fixed Vulnerability 04-08-2016 for data save in options. | |
| 78 | - if ( isset( $_GET['page'] ) && 'wp-database-backup' === $_GET['page'] && current_user_can( 'manage_options' ) ) { | |
| 79 | - setcookie( 'can_download', 1, 0, COOKIEPATH, COOKIE_DOMAIN ); | |
| 80 | - if ( SITECOOKIEPATH !== COOKIEPATH ) { | |
| 81 | - setcookie( 'can_download', 1, 0, SITECOOKIEPATH, COOKIE_DOMAIN ); | |
| 82 | - } | |
| 83 | - } else { | |
| 84 | - setcookie( 'can_download', 0, time() - 300, COOKIEPATH, COOKIE_DOMAIN ); | |
| 85 | - if ( SITECOOKIEPATH !== COOKIEPATH ) { | |
| 86 | - setcookie( 'can_download', 0, time() - 300, SITECOOKIEPATH, COOKIE_DOMAIN ); | |
| 87 | - } | |
| 88 | - } | |
| 89 | - // End Fixed Vulnerability 22-06-2016 for prevent direct download. | |
| 90 | - if ( is_admin() && current_user_can( 'manage_options' ) ) { | |
| 91 | - if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'wp-database-backup' ) ) { | |
| 92 | - if ( isset( $_POST['wpsetting_search'] ) ) { | |
| 93 | - if ( isset( $_POST['wp_db_backup_search_text'] ) ) { | |
| 94 | - update_option( 'wp_db_backup_search_text', sanitize_text_field( wp_unslash( $_POST['wp_db_backup_search_text'] ) ) ); | |
| 95 | - } | |
| 96 | - if ( isset( $_POST['wp_db_backup_replace_text'] ) ) { | |
| 97 | - update_option( 'wp_db_backup_replace_text', sanitize_text_field( wp_unslash( $_POST['wp_db_backup_replace_text'] ) ) ); | |
| 98 | - } | |
| 99 | - $nonce = wp_create_nonce( 'wp-database-backup' ); | |
| 100 | - wp_safe_redirect( esc_url( site_url() . '/wp-admin/tools.php?page=wp-database-backup¬ification=save&tab=searchreplace&_wpnonce=' . $nonce ) ); | |
| 101 | - } | |
| 102 | - | |
| 103 | - if ( isset( $_POST['wpsetting'] ) ) { | |
| 104 | - if ( isset( $_POST['wp_local_db_backup_count'] ) ) { | |
| 105 | - update_option( 'wp_local_db_backup_count', wp_db_filter_data( sanitize_text_field( wp_unslash( $_POST['wp_local_db_backup_count'] ) ) ) ); | |
| 106 | - } | |
| 107 | - | |
| 108 | - if ( isset( $_POST['wp_db_log'] ) ) { | |
| 109 | - update_option( 'wp_db_log', 1 ); | |
| 110 | - } else { | |
| 111 | - update_option( 'wp_db_log', 0 ); | |
| 112 | - } | |
| 113 | - if ( isset( $_POST['wp_db_remove_local_backup'] ) ) { | |
| 114 | - update_option( 'wp_db_remove_local_backup', 1 ); | |
| 115 | - } else { | |
| 116 | - update_option( 'wp_db_remove_local_backup', 0 ); | |
| 117 | - } | |
| 118 | - | |
| 119 | - if ( isset( $_POST['wp_db_backup_enable_auto_upgrade'] ) ) { | |
| 120 | - update_option( 'wp_db_backup_enable_auto_upgrade', 1 ); | |
| 121 | - } else { | |
| 122 | - update_option( 'wp_db_backup_enable_auto_upgrade', 0 ); | |
| 123 | - } | |
| 124 | - | |
| 125 | - if ( isset( $_POST['wp_db_backup_enable_htaccess'] ) ) { | |
| 126 | - update_option( 'wp_db_backup_enable_htaccess', 1 ); | |
| 127 | - } else { | |
| 128 | - update_option( 'wp_db_backup_enable_htaccess', 0 ); | |
| 129 | - $path_info = wp_upload_dir(); | |
| 130 | - if ( file_exists( $path_info['basedir'] . '/db-backup/.htaccess' ) ) { | |
| 131 | - unlink( $path_info['basedir'] . '/db-backup/.htaccess' ); | |
| 132 | - } | |
| 133 | - } | |
| 134 | - | |
| 135 | - if ( isset( $_POST['wp_db_exclude_table'] ) ) { | |
| 136 | - update_option( 'wp_db_exclude_table', $this->recursive_sanitize_text_field( wp_unslash( $_POST['wp_db_exclude_table'] ) ) ); // phpcs:ignore | |
| 137 | - } else { | |
| 138 | - update_option( 'wp_db_exclude_table', '' ); | |
| 139 | - } | |
| 140 | - $nonce = wp_create_nonce( 'wp-database-backup' ); | |
| 141 | - wp_safe_redirect( site_url() . '/wp-admin/tools.php?page=wp-database-backup¬ification=save&_wpnonce=' . $nonce ); | |
| 142 | - } | |
| 143 | - | |
| 144 | - if ( true === isset( $_POST['wp_db_local_backup_path'] ) ) { | |
| 145 | - update_option( 'wp_db_local_backup_path', wp_db_filter_data( sanitize_text_field( wp_unslash( $_POST['wp_db_local_backup_path'] ) ) ) ); | |
| 146 | - } | |
| 147 | - | |
| 148 | - if ( isset( $_POST['wp_db_backup_email_id'] ) ) { | |
| 149 | - update_option( 'wp_db_backup_email_id', wp_db_filter_data( sanitize_email( wp_unslash( $_POST['wp_db_backup_email_id'] ) ) ) ); | |
| 150 | - } | |
| 151 | - | |
| 152 | - if ( isset( $_POST['wp_db_backup_email_attachment'] ) ) { | |
| 153 | - $email_attachment = sanitize_text_field( wp_unslash( $_POST['wp_db_backup_email_attachment'] ) ); | |
| 154 | - update_option( 'wp_db_backup_email_attachment', $email_attachment ); | |
| 155 | - } | |
| 156 | - if ( isset( $_POST['Submit'] ) && 'Save Settings' === $_POST['Submit'] ) { | |
| 157 | - if ( isset( $_POST['wp_db_backup_destination_Email'] ) ) { | |
| 158 | - update_option( 'wp_db_backup_destination_Email', 1 ); | |
| 159 | - } else { | |
| 160 | - update_option( 'wp_db_backup_destination_Email', 0 ); | |
| 161 | - } | |
| 162 | - | |
| 163 | - if ( true === isset( $_POST['wp_db_local_backup'] ) ) { | |
| 164 | - update_option( 'wp_db_local_backup', 1 ); | |
| 165 | - } else { | |
| 166 | - update_option( 'wp_db_local_backup', 0 ); | |
| 167 | - } | |
| 168 | - } | |
| 169 | - } | |
| 170 | - $wp_db_backup_destination_email = get_option( 'wp_db_backup_destination_Email' ); | |
| 171 | - | |
| 172 | - if ( isset( $_GET['page'] ) && 'wp-database-backup' === $_GET['page'] && isset( $_GET['action'] ) && 'unlink' === $_GET['action'] ) { | |
| 173 | - // Specify the target directory and add forward slash. | |
| 174 | - $dir = plugin_dir_path( __FILE__ ) . 'Destination/Dropbox/tokens/'; | |
| 175 | - | |
| 176 | - // Open the directory. | |
| 177 | - $dir_handle = opendir( $dir ); | |
| 178 | - // Loop over all of the files in the folder. | |
| 179 | - $file = readdir( $dir_handle ); | |
| 180 | - while ( $file ) { | |
| 181 | - // If $file is NOT a directory remove it. | |
| 182 | - if ( ! is_dir( $file ) ) { | |
| 183 | - unlink( $dir . $file ); | |
| 184 | - } | |
| 185 | - } | |
| 186 | - // Close the directory. | |
| 187 | - closedir( $dir_handle ); | |
| 188 | - wp_safe_redirect( site_url() . '/wp-admin/tools.php?page=wp-database-backup' ); | |
| 189 | - } | |
| 190 | - $nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : ''; | |
| 191 | - if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $nonce, 'wp-database-backup' ) ) { | |
| 192 | - if ( isset( $_GET['action'] ) && current_user_can( 'manage_options' ) ) { | |
| 193 | - switch ( (string) $_GET['action'] ) { | |
| 194 | - case 'createdbbackup': | |
| 195 | - $this->wp_db_backup_event_process(); | |
| 196 | - wp_safe_redirect( site_url() . '/wp-admin/tools.php?page=wp-database-backup¬ification=create&_wpnonce=' . $nonce ); | |
| 197 | - break; | |
| 198 | - case 'removebackup': | |
| 199 | - if ( true === isset( $_GET['index'] ) ) { | |
| 200 | - $index = (int) $_GET['index']; | |
| 201 | - $options = get_option( 'wp_db_backup_backups' ); | |
| 202 | - $newoptions = array(); | |
| 203 | - $count = 0; | |
| 204 | - foreach ( $options as $option ) { | |
| 205 | - if ( $count !== $index ) { | |
| 206 | - $newoptions[] = $option; | |
| 207 | - } | |
| 208 | - $count++; | |
| 209 | - } | |
| 210 | - if ( file_exists( $options[ $index ]['dir'] ) ) { | |
| 211 | - unlink( $options[ $index ]['dir'] ); | |
| 212 | - } | |
| 213 | - $file_sql = explode( '.', $options[ $index ]['dir'] ); | |
| 214 | - if ( file_exists( $file_sql[0] . '.sql' ) ) { | |
| 215 | - unlink( $file_sql[0] . '.sql' ); | |
| 216 | - } | |
| 217 | - update_option( 'wp_db_backup_backups', $newoptions ); | |
| 218 | - $nonce = wp_create_nonce( 'wp-database-backup' ); | |
| 219 | - wp_safe_redirect( site_url() . '/wp-admin/tools.php?page=wp-database-backup¬ification=delete&_wpnonce=' . $nonce ); | |
| 220 | - } | |
| 221 | - break; | |
| 222 | - case 'clear_temp_db_backup_file': | |
| 223 | - $options = get_option( 'wp_db_backup_backups' ); | |
| 224 | - $newoptions = array(); | |
| 225 | - $backup_check_list = array( '.htaccess', 'index.php' ); | |
| 226 | - $delete_message = 'WPDB : Deleted Files:'; | |
| 227 | - foreach ( $options as $option ) { | |
| 228 | - $backup_check_list[] = $option['filename']; | |
| 229 | - } | |
| 230 | - $path_info = wp_upload_dir(); | |
| 231 | - $wp_db_backup_path = $path_info['basedir'] . '/db-backup'; | |
| 232 | - // Open a directory, and read its contents. | |
| 233 | - if ( is_dir( $wp_db_backup_path ) ) { | |
| 234 | - $dh = opendir( $wp_db_backup_path ); | |
| 235 | - if ( $dh ) { | |
| 236 | - $file = readdir( $dh ); | |
| 237 | - while ( false !== $file ) { | |
| 238 | - if ( ! ( in_array( $file, $backup_check_list, true ) ) ) { | |
| 239 | - if ( file_exists( $wp_db_backup_path . '/' . $file ) ) { | |
| 240 | - unlink( $wp_db_backup_path . '/' . $file ); | |
| 241 | - } | |
| 242 | - $delete_message .= ' ' . $file; | |
| 243 | - } | |
| 244 | - } | |
| 245 | - closedir( $dh ); | |
| 246 | - } | |
| 247 | - } | |
| 248 | - wp_safe_redirect( site_url() . '/wp-admin/tools.php?page=wp-database-backup¬ification=clear_temp_db_backup_file&_wpnonce=' . $nonce ); | |
| 249 | - break; | |
| 250 | - case 'restorebackup': | |
| 251 | - $index = (int) $_GET['index']; | |
| 252 | - $options = get_option( 'wp_db_backup_backups' ); | |
| 253 | - $newoptions = array(); | |
| 254 | - $count = 0; | |
| 255 | - foreach ( $options as $option ) { | |
| 256 | - if ( $count !== $index ) { | |
| 257 | - $newoptions[] = $option; | |
| 258 | - } | |
| 259 | - $count++; | |
| 260 | - } | |
| 261 | - if ( isset( $options[ $index ]['sqlfile'] ) ) { // Added for extract zip file V.3.3.0. | |
| 262 | - $database_file = ( $options[ $index ]['sqlfile'] ); | |
| 263 | - } else { | |
| 264 | - $database_file = ( $options[ $index ]['dir'] ); | |
| 265 | - $file_sql = explode( '.', $options[ $index ]['dir'] ); | |
| 266 | - $database_file = ( $file_sql[0] . '.sql' ); | |
| 267 | - } | |
| 268 | - $database_name = $this->wp_backup_get_config_db_name(); | |
| 269 | - $database_user = $this->wp_backup_get_config_data( 'DB_USER' ); | |
| 270 | - $datadase_password = $this->wp_backup_get_config_data( 'DB_PASSWORD' ); | |
| 271 | - $database_host = $this->wp_backup_get_config_data( 'DB_HOST' ); | |
| 272 | - $path_info = wp_upload_dir(); | |
| 273 | - // Added for extract zip file V.3.3.0. | |
| 274 | - $ext_path_info = $path_info['basedir'] . '/db-backup'; | |
| 275 | - $database_zip_file = $options[ $index ]['dir']; | |
| 276 | - | |
| 277 | - if ( class_exists( 'ZipArchive' ) ) { | |
| 278 | - $zip = new ZipArchive(); | |
| 279 | - if ( $zip->open( $database_zip_file ) === true ) { | |
| 280 | - $zip->extractTo( $ext_path_info ); | |
| 281 | - $zip->close(); | |
| 282 | - } | |
| 283 | - } else { | |
| 284 | - require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; | |
| 285 | - $archive = new PclZip( $database_zip_file ); | |
| 286 | - $dir = $path_info['basedir'] . '/db-backup/'; | |
| 287 | - | |
| 288 | - if ( ! $archive->extract( PCLZIP_OPT_PATH, $dir ) ) { | |
| 289 | - wp_die( 'Unable to extract zip file. Please check that zlib php extension is enabled.', 'ZIP Error' ); | |
| 290 | - } | |
| 291 | - } | |
| 292 | - | |
| 293 | - // End for extract zip file V.3.3.0. | |
| 294 | - set_time_limit( 0 ); | |
| 295 | - if ( '' !== ( trim( (string) $database_name ) ) && '' !== ( trim( (string) $database_user ) ) && '' !== ( trim( (string) $datadase_password ) ) && '' !== ( trim( (string) $database_host ) ) ) { | |
| 296 | - $conn = mysqli_connect( (string) $database_host, (string) $database_user, (string) $datadase_password ); // phpcs:ignore | |
| 297 | - if ( $conn ) { | |
| 298 | - // Start Select the database. | |
| 299 | - if ( ! mysqli_select_db( (string) $database_name, $conn ) ) { // phpcs:ignore | |
| 300 | - $sql = 'CREATE DATABASE IF NOT EXISTS `' . (string) $database_name . '`'; | |
| 301 | - mysqli_query( $sql, $conn ); // phpcs:ignore | |
| 302 | - mysqli_select_db( (string) $database_name, $conn ); // phpcs:ignore | |
| 303 | - } | |
| 304 | - /* END: Select the Database */ | |
| 305 | - | |
| 306 | - /* BEGIN: Remove All Tables from the Database */ | |
| 307 | - $found_tables = null; | |
| 308 | - $result = mysqli_query( 'SHOW TABLES FROM `{' . (string) $database_name . '}`', $conn ); // phpcs:ignore | |
| 309 | - if ( $result ) { | |
| 310 | - $row = mysqli_fetch_row( $result ); // phpcs:ignore | |
| 311 | - while ( $row ) { | |
| 312 | - $found_tables[] = $row[0]; | |
| 313 | - } | |
| 314 | - if ( count( $found_tables ) > 0 ) { | |
| 315 | - foreach ( $found_tables as $table_name ) { | |
| 316 | - mysqli_query( 'DROP TABLE `{' . (string) $database_name . "}`.{$table_name}", $conn ); // phpcs:ignore | |
| 317 | - } | |
| 318 | - } | |
| 319 | - } | |
| 320 | - /* END: Remove All Tables from the Database */ | |
| 321 | - | |
| 322 | - /* BEGIN: Restore Database Content */ | |
| 323 | - if ( isset( $database_file ) ) { | |
| 324 | - $database_file = $database_file; | |
| 325 | - if ( file_exists( $database_file ) ) { | |
| 326 | - $sql_file = file_get_contents( $database_file, true ); | |
| 327 | - | |
| 328 | - $sql_queries = explode( ";\n", $sql_file ); | |
| 329 | - $sql_queries_count = count( $sql_queries ); | |
| 330 | - for ( $i = 0; $i < $sql_queries_count; $i++ ) { | |
| 331 | - mysqli_query( $sql_queries[ $i ], $conn ); // phpcs:ignore | |
| 332 | - } | |
| 333 | - } | |
| 334 | - } | |
| 335 | - } | |
| 336 | - } | |
| 337 | - if ( isset( $options[ $index ]['sqlfile'] ) && file_exists( $options[ $index ]['sqlfile'] ) ) { // Added for extract zip file V.3.3.0. | |
| 338 | - if ( file_exists( $options[ $index ]['sqlfile'] ) ) { | |
| 339 | - unlink( $options[ $index ]['sqlfile'] ); | |
| 340 | - } | |
| 341 | - } else { | |
| 342 | - $database_file = ( $options[ $index ]['dir'] ); | |
| 343 | - $file_sql = explode( '.', $options[ $index ]['dir'] ); | |
| 344 | - $database_file = ( $file_sql[0] . '.sql' ); | |
| 345 | - if ( file_exists( $database_file ) ) { | |
| 346 | - unlink( $database_file ); | |
| 347 | - } | |
| 348 | - } | |
| 349 | - wp_safe_redirect( site_url() . '/wp-admin/tools.php?page=wp-database-backup¬ification=restore&_wpnonce=' . $nonce ); | |
| 350 | - break; | |
| 351 | - | |
| 352 | - /* END: Restore Database Content */ | |
| 353 | - } | |
| 354 | - } | |
| 355 | - } | |
| 356 | - } | |
| 357 | - } | |
| 358 | - | |
| 359 | - if ( is_admin() && current_user_can( 'manage_options' ) ) { | |
| 360 | - register_setting( 'wp_db_backup_options', 'wp_db_backup_options', array( $this, 'wp_db_backup_validate' ) ); | |
| 361 | - add_settings_section( 'wp_db_backup_main', 'WP-Database-Backup', array( $this, 'wp_db_backup_section_text' ), 'manage_options' ); | |
| 362 | - } | |
| 363 | - } | |
| 364 | - | |
| 365 | - /** | |
| 366 | - * Validate data. | |
| 367 | - * | |
| 368 | - * @param string $input - Input data. | |
| 369 | - */ | |
| 370 | - public function wp_db_backup_validate( $input ) { | |
| 371 | - return $input; | |
| 372 | - } | |
| 373 | - | |
| 374 | - /** | |
| 375 | - * Setting page. | |
| 376 | - */ | |
| 377 | - public function wp_db_backup_settings_page() { | |
| 378 | - $options = get_option( 'wp_db_backup_backups' ); | |
| 379 | - $settings = get_option( 'wp_db_backup_options' ); ?> | |
| 380 | - <div class="bootstrap-wrapper"> | |
| 381 | - <?php | |
| 382 | - include_once 'admin-header-notification.php'; | |
| 383 | - $wp_db_local_backup_path = get_option( 'wp_db_local_backup_path' ); | |
| 384 | - if ( false === empty( $wp_db_local_backup_path ) && false === file_exists( $wp_db_local_backup_path ) ) { | |
| 385 | - echo '<div class="alert alert-warning alert-dismissible fade in" role="alert"> | |
| 386 | - <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> | |
| 387 | - <a href="#db_destination" data-toggle="tab">'; | |
| 388 | - esc_attr_e( 'Invalid Local Backup Path : ', 'wp-database-backup' ); | |
| 389 | - echo esc_attr( $wp_db_local_backup_path ); | |
| 390 | - echo '</a></div>'; | |
| 391 | - } | |
| 392 | - | |
| 393 | - $upload_dir = wp_upload_dir(); | |
| 394 | - $dir = $upload_dir['basedir'] . '/db-backup'; | |
| 395 | - if ( ! is_dir( $dir ) ) { | |
| 396 | - $dir = $upload_dir['basedir']; | |
| 397 | - } | |
| 398 | - if ( is_dir( $dir ) && ! is_writable( $dir ) ) { | |
| 399 | - ?> | |
| 400 | - <div class="row"> | |
| 401 | - <div class="col-xs-12 col-sm-12 col-md-12"> | |
| 402 | - <div class="alert alert-danger alert-dismissible fade in" role="alert"> | |
| 403 | - <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
| 404 | - <span aria-hidden="true">×</span></button> | |
| 405 | - <h4>WP Database Backup</h4> | |
| 406 | - <p>Error: Permission denied, make sure you have write permission for <?php echo esc_attr( $dir ); ?> | |
| 407 | - folder</p> | |
| 408 | - </div> | |
| 409 | - </button> | |
| 410 | - </div> | |
| 411 | - </div> | |
| 412 | - <?php | |
| 413 | - } | |
| 414 | - ?> | |
| 415 | - <div class="panel panel-default"> | |
| 416 | - <div class="panel-heading"> | |
| 417 | - <h3><a href="http://www.wpseeds.com/documentation/docs/wp-database-backup/" target="blank"><img | |
| 418 | - src="<?php echo esc_attr( WPDB_PLUGIN_URL ); ?>/assets/images/wp-database-backup.png"></a>Database | |
| 419 | - Backup Settings <a href="https://www.wpseeds.com/product/wp-all-backup/" target="_blank"><span | |
| 420 | - style='float:right' | |
| 421 | - class="label label-success">Get Pro 'WP All Backup' Plugin</span></a> | |
| 422 | - </h3> | |
| 423 | - </div> | |
| 424 | - <div class="panel-body"> | |
| 425 | - <ul class="nav nav-tabs"> | |
| 426 | - <li class=""><a href="#db_home" data-toggle="tab">Database Backups</a></li> | |
| 427 | - <li><a href="#db_schedul" data-toggle="tab">Scheduler</a></li> | |
| 428 | - <li><a href="#db_setting" data-toggle="tab">Settings</a></li> | |
| 429 | - <li><a href="#searchreplace" data-toggle="tab">Search and Replace</a></li> | |
| 430 | - <li><a href="#db_destination" data-toggle="tab">Destination</a></li> | |
| 431 | - <li><a href="#db_info" data-toggle="tab">System Information</a></li> | |
| 432 | - <li><a href="#db_help" data-toggle="tab">Help</a></li> | |
| 433 | - <li><a href="#db_advanced" data-toggle="tab">Pro Feature</a></li> | |
| 434 | - </ul> | |
| 435 | - | |
| 436 | - <?php | |
| 437 | - echo '<div class="tab-content">'; | |
| 438 | - echo '<div class="tab-pane active" id="db_home">'; | |
| 439 | - echo '<p class="submit">'; | |
| 440 | - $nonce = wp_create_nonce( 'wp-database-backup' ); | |
| 441 | - $wp_db_backup_search_text = get_option( 'wp_db_backup_search_text' ); | |
| 442 | - $wp_db_backup_replace_text = get_option( 'wp_db_backup_replace_text' ); | |
| 443 | - if ( ( false === empty( $wp_db_backup_search_text ) ) && ( false === empty( $wp_db_backup_replace_text ) ) ) { | |
| 444 | - echo '<a href="' . esc_url( site_url() ) . '/wp-admin/tools.php?page=wp-database-backup&action=createdbbackup&_wpnonce=' . esc_attr( $nonce ) . '" id="create_backup" class="btn btn-primary"> <span class="glyphicon glyphicon-plus-sign"></span> Create New Database Backup with Search/Replace</a>'; | |
| 445 | - echo '<p>Backup file will replace <b>' . esc_attr( $wp_db_backup_search_text ) . '</b> text with <b>' . esc_attr( $wp_db_backup_replace_text ) . '</b>. For Regular Database Backup without replace then Go to Dashboard=>Tool=>WP-DB Backup > Settings > Search and Replace - Set Blank Fields </p>'; | |
| 446 | - } else { | |
| 447 | - echo '<a href="' . esc_url( site_url() ) . '/wp-admin/tools.php?page=wp-database-backup&action=createdbbackup&_wpnonce=' . esc_attr( $nonce ) . '" id="create_backup" class="btn btn-primary"> <span class="glyphicon glyphicon-plus-sign"></span> Create New Database Backup</a>'; | |
| 448 | - } | |
| 449 | - echo '</p>'; | |
| 450 | - ?> | |
| 451 | - | |
| 452 | - <?php | |
| 453 | - if ( $options ) { | |
| 454 | - echo ' <div class="table-responsive"> | |
| 455 | - <div id="dataTables-example_wrapper" class="dataTables_wrapper form-inline" role="grid"> | |
| 456 | - | |
| 457 | - <table class="table table-striped table-bordered table-hover display" id="example"> | |
| 458 | - <thead>'; | |
| 459 | - echo '<tr class="wpdb-header">'; | |
| 460 | - echo '<th class="manage-column" scope="col" width="10%" style="text-align: center;">SL No</th>'; | |
| 461 | - echo '<th class="manage-column" scope="col" width="30%">Date</th>'; | |
| 462 | - echo '<th class="manage-column" scope="col" width="5%"></th>'; | |
| 463 | - echo '<th class="manage-column" scope="col" width="15%">Destination</th>'; | |
| 464 | - echo '<th class="manage-column" scope="col" width="10%">Backup File</th>'; | |
| 465 | - echo '<th class="manage-column" scope="col" width="10%">Size</th>'; | |
| 466 | - echo '<th class="manage-column" scope="col" width="20%">Action</th>'; | |
| 467 | - echo '</tr>'; | |
| 468 | - echo '</thead>'; | |
| 469 | - | |
| 470 | - echo '<tbody>'; | |
| 471 | - $count = 1; | |
| 472 | - $destination_icon = array( | |
| 473 | - 'Local' => 'glyphicon glyphicon-home', | |
| 474 | - 'Local Path' => 'glyphicon glyphicon-folder-open', | |
| 475 | - 'Email' => 'glyphicon glyphicon-envelope', | |
| 476 | - 'FTP' => 'glyphicon glyphicon-folder-open', | |
| 477 | - 'S3' => 'glyphicon glyphicon-cloud-upload', | |
| 478 | - 'Drive' => 'glyphicon glyphicon-hdd', | |
| 479 | - 'DropBox' => 'glyphicon glyphicon-inbox', | |
| 480 | - ); | |
| 481 | - foreach ( $options as $option ) { | |
| 482 | - $str_class = ( 0 === (int) $option['size'] ) ? 'text-danger' : 'wpdb_download'; | |
| 483 | - echo '<tr class="' . ( ( 0 === ( $count % 2 ) ) ? esc_attr( $str_class ) . ' alternate' : esc_attr( $str_class ) ) . '">'; | |
| 484 | - echo '<td style="text-align: center;">' . esc_attr( $count ) . '</td>'; | |
| 485 | - echo '<td><span style="display:none">' . esc_attr( gmdate( 'Y M jS h:i:s A', $option['date'] ) ) . '</span>' . esc_attr( gmdate( 'jS, F Y h:i:s A', $option['date'] ) ) . '</td>'; | |
| 486 | - echo '<td class="wpdb_log">'; | |
| 487 | - if ( false === empty( $option['log'] ) ) { | |
| 488 | - echo '<button id="popoverid" type="button" class="popoverid btn" data-toggle="popover" title="Log" data-content="' . wp_kses_post( $option['log'] ) . '"><span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span></button>'; | |
| 489 | - } | |
| 490 | - echo '</td>'; | |
| 491 | - echo '<td>'; | |
| 492 | - if ( ! empty( $option['destination'] ) ) { | |
| 493 | - $destination = ( explode( ',', $option['destination'] ) ); | |
| 494 | - foreach ( $destination as $dest ) { | |
| 495 | - $key = trim( $dest ); | |
| 496 | - if ( ! empty( $dest ) && array_key_exists( $key, $destination_icon ) ) { | |
| 497 | - echo '<span class="' . esc_attr( $destination_icon[ $key ] ) . '" title="' . esc_attr( $dest ) . '"></span> '; | |
| 498 | - } | |
| 499 | - } | |
| 500 | - } | |
| 501 | - echo '</td>'; | |
| 502 | - echo '<td>'; | |
| 503 | - echo '<a href="' . esc_url( $option['url'] ) . '" style="color: #21759B;">'; | |
| 504 | - echo '<span class="glyphicon glyphicon-download-alt"></span> Download</a></td>'; | |
| 505 | - echo '<td>' . esc_attr( $this->wp_db_backup_format_bytes( $option['size'] ) ) . '</td>'; | |
| 506 | - echo '<td><a title="Remove Database Backup" onclick="return confirm(\'Are you sure you want to delete database backup?\')" href="' . esc_url( site_url() ) . '/wp-admin/tools.php?page=wp-database-backup&action=removebackup&_wpnonce=' . esc_attr( $nonce ) . '&index=' . esc_attr( ( $count - 1 ) ) . '" class="btn btn-default"><span style="color:red" class="glyphicon glyphicon-trash"></span> Remove <a/> '; | |
| 507 | - if ( isset( $option['search_replace'] ) && 1 === (int) $option['search_replace'] ) { | |
| 508 | - echo '<span style="margin-left:15px" title="' . esc_html( $option['log'] ) . '" class="glyphicon glyphicon-search"></span>'; | |
| 509 | - } else { | |
| 510 | - echo '<a title="Restore Database Backup" onclick="return confirm(\'Are you sure you want to restore database backup?\')" href="' . esc_url( site_url() ) . '/wp-admin/tools.php?page=wp-database-backup&action=restorebackup&_wpnonce=' . esc_attr( $nonce ) . '&index=' . esc_attr( ( $count - 1 ) ) . '" class="btn btn-default"><span class="glyphicon glyphicon-refresh" style="color:blue"></span> Restore <a/>'; | |
| 511 | - } | |
| 512 | - echo '</td></tr>'; | |
| 513 | - $count++; | |
| 514 | - } | |
| 515 | - echo '</tbody>'; | |
| 516 | - | |
| 517 | - echo ' </table> | |
| 518 | - </div> | |
| 519 | - </div>'; | |
| 520 | - } else { | |
| 521 | - echo '<p>No Database Backups Created!</p>'; | |
| 522 | - } | |
| 523 | - echo "<div class='alert alert-success' role='alert'><h4>" . wp_kses_post( $coupon ) . '</h4></div>'; | |
| 524 | - echo "<div class=''><p><a target='_blank' href='https://www.wpseeds.com/product/wp-all-backup/'>WP All Backup</a> - Creates a Backup of your entire website: that's your Database, current WP Core, all your Themes, Plugins and Uploads.</p></div>"; | |
| 525 | - echo "<div class=''><p>Use <b>WPDBSPECIAL40</b> Coupon and get Pro version in just <a target='_blank' href='https://www.wpseeds.com/product/wp-all-backup/'><b>$13.20</b></a> - Lifetime License, 1 Year Support, 1 Year Updates.</p></div>"; | |
| 526 | - echo '<p>If you like <b>WP Database Backup</b> please leave us a <a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/wp-database-backup" title="Rating" sl-processed="1"> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> rating </a>. Many thanks in advance! | |
| 527 | - <a target="_blank" class="text-right" href="https://www.wpseeds.com/support/"><button style="float:right" type="button" class="btn btn-default">Support</button></a> | |
| 528 | - <a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/"><button style="float:right" type="button" class="btn btn-default">Documentation</button></a> | |
| 529 | - <a target="_blank" href="https://www.wpseeds.com/product/wp-all-backup/"><button style="float:right" type="button" class="btn btn-default">Premium</button></a> | |
| 530 | - <a target="_blank" href="http://www.wpseeds.com"><button style="float:right" type="button" class="btn btn-default">More plugins</button></a></p> | |
| 531 | - '; | |
| 532 | - echo '</div>'; | |
| 533 | - | |
| 534 | - echo '<div class="tab-pane" id="db_schedul">'; | |
| 535 | - echo '<form method="post" action="options.php" name="wp_auto_commenter_form">'; | |
| 536 | - wp_nonce_field( 'wp-database-backup' ); | |
| 537 | - settings_fields( 'wp_db_backup_options' ); | |
| 538 | - do_settings_sections( 'wp-database-backup' ); | |
| 539 | - | |
| 540 | - $enable_autobackups = '0'; | |
| 541 | - if ( isset( $settings['enable_autobackups'] ) ) { | |
| 542 | - $enable_autobackups = $settings['enable_autobackups']; | |
| 543 | - } | |
| 544 | - | |
| 545 | - $autobackup_frequency = '0'; | |
| 546 | - if ( isset( $settings['autobackup_frequency'] ) ) { | |
| 547 | - $autobackup_frequency = $settings['autobackup_frequency']; | |
| 548 | - } | |
| 549 | - | |
| 550 | - echo '<div class="row form-group"><label class="col-sm-2" for="enable_autobackups">Enable Auto Backups</label>'; | |
| 551 | - echo '<div class="col-sm-2"><input type="checkbox" id="enable_autobackups" name="wp_db_backup_options[enable_autobackups]" value="1" ' . checked( 1, $enable_autobackups, false ) . '/></div>'; | |
| 552 | - echo '</div>'; | |
| 553 | - echo '<div class="row form-group"><label class="col-sm-2" for="wp_db_backup_options">Auto Database Backup Frequency</label>'; | |
| 554 | - echo '<div class="col-sm-2"><select id="wp_db_backup_options" class="form-control" name="wp_db_backup_options[autobackup_frequency]">'; | |
| 555 | - echo '<option value="hourly" ' . selected( 'hourly', $autobackup_frequency, false ) . '>Hourly</option>'; | |
| 556 | - echo '<option value="twicedaily" ' . selected( 'twicedaily', $autobackup_frequency, false ) . '>Twice Daily</option>'; | |
| 557 | - echo '<option value="daily" ' . selected( 'daily', $autobackup_frequency, false ) . '>Daily</option>'; | |
| 558 | - echo '<option value="weekly" ' . selected( 'weekly', $autobackup_frequency, false ) . '>Weekly</option>'; | |
| 559 | - echo '<option value="monthly" ' . selected( 'monthly', $autobackup_frequency, false ) . '>Monthly</option>'; | |
| 560 | - echo '</select>'; | |
| 561 | - echo '</div></div>'; | |
| 562 | - | |
| 563 | - echo '<p class="submit">'; | |
| 564 | - echo '<input type="submit" name="Submit" class="btn btn-primary" value="Save Settings" />'; | |
| 565 | - echo '</p>'; | |
| 566 | - echo '</form>'; | |
| 567 | - echo '</div>'; | |
| 568 | - | |
| 569 | - echo '<div class="tab-pane" id="db_help">'; | |
| 570 | - echo '<p>'; | |
| 571 | - ?> | |
| 572 | - | |
| 573 | - <script> | |
| 574 | - var $j = jQuery.noConflict(); | |
| 575 | - $j(document).ready(function () { | |
| 576 | - $j('.popoverid').popover(); | |
| 577 | - var table = $j('#example').DataTable(); | |
| 578 | - $j("#create_backup").click(function() { | |
| 579 | - $j("#backup_process").show(); | |
| 580 | - $j("#create_backup").attr("disabled", true); | |
| 581 | - }); | |
| 582 | - }); | |
| 583 | - | |
| 584 | - function excludetableall(){ | |
| 585 | - var checkboxes = document.getElementsByClassName('wp_db_exclude_table'); | |
| 586 | - var checked = ''; | |
| 587 | - if($j('#wp_db_exclude_table_all').prop("checked") == true){ | |
| 588 | - checked = 'checked'; | |
| 589 | - } | |
| 590 | - $j('.wp_db_exclude_table').each(function() { | |
| 591 | - this.checked = checked; | |
| 592 | - }); | |
| 593 | - } | |
| 594 | - | |
| 595 | - </script> | |
| 596 | - <div class="panel-group" id="accordion"> | |
| 597 | - | |
| 598 | - <div class="panel panel-default"> | |
| 599 | - <div class="panel-heading"> | |
| 600 | - <h4 class="panel-title"> | |
| 601 | - <a data-toggle="collapse" data-parent="#accordion" href="#collapseDocumentation"> | |
| 602 | - Documentation links | |
| 603 | - </a> | |
| 604 | - </h4> | |
| 605 | - </div> | |
| 606 | - <div id="collapseDocumentation" class="panel-collapse collapse in"> | |
| 607 | - <div class="panel-body"> | |
| 608 | - <p> | |
| 609 | - <ul> | |
| 610 | - <li class="page_item page-item-257 page_item_has_children"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/setup/">Setup</a> | |
| 611 | - <ul class="children"> | |
| 612 | - <li class="page_item page-item-258"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/setup/installation/">Installation</a> | |
| 613 | - </li> | |
| 614 | - </ul> | |
| 615 | - </li> | |
| 616 | - <li class="page_item page-item-295 page_item_has_children"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/how-to/">How | |
| 617 | - To</a> | |
| 618 | - <ul class="children"> | |
| 619 | - <li class="page_item page-item-299"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/how-to/restore-database-backup/">Restore | |
| 620 | - Database Backup</a></li> | |
| 621 | - <li class="page_item page-item-301"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/how-to/backup-your-wordpress-site-database/">Backup | |
| 622 | - Your WordPress Site Database</a></li> | |
| 623 | - </ul> | |
| 624 | - </li> | |
| 625 | - <li class="page_item page-item-340 page_item_has_children"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/setting/">Setting</a> | |
| 626 | - <ul class="children"> | |
| 627 | - <li class="page_item page-item-342"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/setting/number-of-backups/">Number | |
| 628 | - of backups</a></li> | |
| 629 | - <li class="page_item page-item-349"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/setting/exclude-tables/">Exclude | |
| 630 | - Tables</a></li> | |
| 631 | - <li class="page_item page-item-358"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/setting/log-setting/">Log | |
| 632 | - Setting</a></li> | |
| 633 | - <li class="page_item page-item-363"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/setting/schedule-settings/">Schedule | |
| 634 | - Settings</a></li> | |
| 635 | - </ul> | |
| 636 | - </li> | |
| 637 | - <li class="page_item page-item-306 page_item_has_children"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/destination/">Destination</a> | |
| 638 | - <ul class="children"> | |
| 639 | - <li class="page_item page-item-310"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/destination/email-notification/">Email Notification</a></li> | |
| 640 | - <li class="page_item page-item-319"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/destination/store-database-backup-on-ftp/">Storedatabase backup on FTP</a></li> | |
| 641 | - <li class="page_item page-item-326"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/destination/store-database-backup-on-google-drive/">Store database backup on Google drive</a></li> | |
| 642 | - <li class="page_item page-item-334"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/destination/store-database-backup-on-dropbox/">Store database backup on Dropbox</a></li> | |
| 643 | - <li class="page_item page-item-336"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/destination/store-database-backup-on-amazon-s3/">Store database backup on Amazon S3</a></li> | |
| 644 | - </ul> | |
| 645 | - </li> | |
| 646 | - <li class="page_item page-item-264 page_item_has_children"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/faq/">FAQ</a> | |
| 647 | - <ul class="children"> | |
| 648 | - <li class="page_item page-item-265"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/faq/on-click-create-new-database-backup-it-goes-to-blank-page/">On Click Create New Database Backup it goes to blank page</a></li> | |
| 649 | - <li class="page_item page-item-267"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/faq/always-get-an-empty-0-bits-backup-file/">Always get an empty (0 bits) backup file?</a></li> | |
| 650 | - <li class="page_item page-item-269"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/faq/how-to-restore-database-backup/">How to restore database backup?</a></li> | |
| 651 | - <li class="page_item page-item-271"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/faq/how-to-create-database-backup/">How to create database Backup?</a></li> | |
| 652 | - </ul> | |
| 653 | - </li> | |
| 654 | - <li class="page_item page-item-273"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/features/">Features</a></li> | |
| 655 | - <li class="page_item page-item-277"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/changelog/">Changelog</a></li> | |
| 656 | - <li class="page_item page-item-279"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/reviews/">Reviews</a></li> | |
| 657 | - <li class="page_item page-item-373"><a target="_blank" href="http://www.wpseeds.com/documentation/docs/wp-database-backup/pricing/">Pricing</a></li> | |
| 658 | - </ul> | |
| 659 | - | |
| 660 | - </p> | |
| 661 | - </div> | |
| 662 | - </div> | |
| 663 | - </div> | |
| 664 | - | |
| 665 | - <div class="panel panel-default"> | |
| 666 | - <div class="panel-heading"> | |
| 667 | - <h4 class="panel-title"> | |
| 668 | - <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne"> | |
| 669 | - Create Backup | |
| 670 | - </a> | |
| 671 | - </h4> | |
| 672 | - </div> | |
| 673 | - <div id="collapseOne" class="panel-collapse collapse in"> | |
| 674 | - <div class="panel-body"> | |
| 675 | - <p>Step 1) Click on Create New Database Backup</p> | |
| 676 | - <p>Step 2) Download Database Backup file.</p> | |
| 677 | - </div> | |
| 678 | - </div> | |
| 679 | - </div> | |
| 680 | - | |
| 681 | - <div class="panel-group" id="accordion"> | |
| 682 | - <div class="panel panel-default"> | |
| 683 | - <div class="panel-heading"> | |
| 684 | - <h4 class="panel-title"> | |
| 685 | - <a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo"> | |
| 686 | - Restore Backup | |
| 687 | - </a> | |
| 688 | - </h4> | |
| 689 | - </div> | |
| 690 | - <div id="collapseTwo" class="panel-collapse collapse in"> | |
| 691 | - <div class="panel-body"> | |
| 692 | - <p>Click on Restore Database Backup </p> | |
| 693 | - <p>OR</p> | |
| 694 | - | |
| 695 | - <p>Step 1) Login to phpMyAdmin.</p> | |
| 696 | - <p>Step 2) Click Databases and select the database that you will be importing | |
| 697 | - your | |
| 698 | - data into.</p> | |
| 699 | - <p>Step 3) Across the top of the screen will be a row of tabs. Click the Import | |
| 700 | - tab.</p> | |
| 701 | - <p>Step 4) On the next screen will be a location of text file box, and next to | |
| 702 | - that | |
| 703 | - a button named Browse.</p> | |
| 704 | - <p>Step 5) Click Browse. Locate the backup file stored on your computer.</p> | |
| 705 | - <p>Step 6) Click the Go button.</p> | |
| 706 | - </div> | |
| 707 | - </div> | |
| 708 | - </div> | |
| 709 | - | |
| 710 | - <div class="panel-group" id="accordion"> | |
| 711 | - <div class="panel panel-default"> | |
| 712 | - <div class="panel-heading"> | |
| 713 | - <h4 class="panel-title"> | |
| 714 | - <a data-toggle="collapse" data-parent="#accordion" href="#collapseThree"> | |
| 715 | - Support | |
| 716 | - </a> | |
| 717 | - </h4> | |
| 718 | - </div> | |
| 719 | - <div id="collapseThree" class="panel-collapse collapse in"> | |
| 720 | - <div class="panel-body"> | |
| 721 | - <button type="button" class="btn btn-default"><a | |
| 722 | - href='https://wpallbackup.com/support/'>Support</a></button> | |
| 723 | - <button type="button" class="btn btn-default"><a | |
| 724 | - href='http://www.wpseeds.com/documentation/docs/wp-database-backup'>Documentation</a> | |
| 725 | - </button> | |
| 726 | - <p>If you want more feature or any suggestion then drop me mail we are try | |
| 727 | - to | |
| 728 | - implement in our wp-database-backup plugin and also try to make it more | |
| 729 | - user | |
| 730 | - friendly</p> | |
| 731 | - <p><span class="glyphicon glyphicon-envelope"></span> Drop Mail | |
| 732 | - :walke.prashant28@gmail.com</p> | |
| 733 | - If you like this plugin then Give <a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/wp-database-backup" title="Rating" sl-processed="1">rating </a>on | |
| 734 | - <a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/wp-database-backup" title="Rating" sl-processed="1">WordPress.org</a></p> | |
| 735 | - <p></br><a title="WP-DB-Backup" href="http://www.wpseeds.com/documentation/docs/wp-database-backup" target="_blank">More Information</a></p> | |
| 736 | - <p>Support us to improve plugin. your idea and support are always welcome. | |
| 737 | - </p> | |
| 738 | - | |
| 739 | - | |
| 740 | - </div> | |
| 741 | - </div> | |
| 742 | - </div> | |
| 743 | - | |
| 744 | - </div> | |
| 745 | - </div> | |
| 746 | - </div> | |
| 747 | - | |
| 748 | - | |
| 749 | - </div> | |
| 750 | - | |
| 751 | - <div class="tab-pane" id="db_info"> | |
| 752 | - | |
| 753 | - <div class="panel panel-default"> | |
| 754 | - <div class="panel-heading"> | |
| 755 | - <h4 class="panel-title"> | |
| 756 | - <a data-toggle="collapse" data-parent="#accordion" href="#collapsedb"> | |
| 757 | - <?php esc_attr_e( 'System Check', 'wpdbbk' ); ?> | |
| 758 | - | |
| 759 | - </a> | |
| 760 | - </h4> | |
| 761 | - </div> | |
| 762 | - <div id="collapsedb" class="panel-collapse collapse in"> | |
| 763 | - <div class="panel-body list-group"> | |
| 764 | - | |
| 765 | - <div class="row list-group-item"> | |
| 766 | - <?php | |
| 767 | - /* get disk space free (in bytes) */ | |
| 768 | - $df = disk_free_space( WPDB_ROOTPATH ); | |
| 769 | - /* and get disk space total (in bytes) */ | |
| 770 | - $dt = disk_total_space( WPDB_ROOTPATH ); | |
| 771 | - /* now we calculate the disk space used (in bytes) */ | |
| 772 | - $du = $dt - $df; | |
| 773 | - /* percentage of disk used - this will be used to also set the width % of the progress bar */ | |
| 774 | - $dp = sprintf( '%.2f', ( $du / $dt ) * 100 ); | |
| 775 | - | |
| 776 | - /* and we formate the size from bytes to MB, GB, etc. */ | |
| 777 | - $df = $this->wp_db_backup_format_bytes( $df ); | |
| 778 | - $du = $this->wp_db_backup_format_bytes( $du ); | |
| 779 | - $dt = $this->wp_db_backup_format_bytes( $dt ); | |
| 780 | - ?> | |
| 781 | - <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 782 | - class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 783 | - </div> | |
| 784 | - <div class="col-md-3">Disk Space</div> | |
| 785 | - <div class="col-md-5"> | |
| 786 | - <div class="progress"> | |
| 787 | - <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="<?php echo esc_attr( trim( $dp ) ); ?>" aria-valuemin="0" aria-valuemax="100" style="width:<?php echo esc_attr( trim( $dp ) ); ?>%"> <?php echo esc_attr( $dp ); ?>% | |
| 788 | - </div> | |
| 789 | - </div> | |
| 790 | - </div> | |
| 791 | - <div class="col-md-1"></div> | |
| 792 | - <div class="col-md-4"></div> | |
| 793 | - <div class="col-md-5"> | |
| 794 | - <div class='prginfo'> | |
| 795 | - <p><?php echo esc_attr( $du ) . ' of ' . esc_attr( $dt ) . ' used '; ?></p> | |
| 796 | - <p><?php echo esc_attr( $df ) . ' of ' . esc_attr( $dt ) . ' free '; ?></p> | |
| 797 | - <p> | |
| 798 | - <small> | |
| 799 | - <?php esc_attr_e( 'Note: This value is the physical servers hard-drive allocation.', 'wpdbbkp' ); ?> | |
| 800 | - <br/> | |
| 801 | - <?php esc_attr_e( "On shared hosts check your control panel for the 'TRUE' disk space quota value.", 'wpdbbkp' ); ?> | |
| 802 | - </small> | |
| 803 | - </p> | |
| 804 | - </div> | |
| 805 | - | |
| 806 | - </div> | |
| 807 | - </div> | |
| 808 | - | |
| 809 | - <div class=""><br> | |
| 810 | - <a type="button" href="<?php echo esc_url( site_url() ); ?>/wp-admin/tools.php?page=wp-database-backup&action=clear_temp_db_backup_file&_wpnonce=<?php echo esc_attr( $nonce ); ?>" class="btn btn-warning"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Clear all old/temp database backup files</a> | |
| 811 | - <p>Click above button to clear all your old or temporary created database backup | |
| 812 | - files. | |
| 813 | - It only delete file from backup directory which is not in 'Database Backups' | |
| 814 | - listing(all other file excluding backup files listed in 'Database Backups' ). | |
| 815 | - Before | |
| 816 | - using this option make sure that you have save your database backup on safe | |
| 817 | - place.</p> | |
| 818 | - <p>The disk that your backup is saved on doesn’t have enough free space? Backup disk | |
| 819 | - is | |
| 820 | - almost full? Low disk space for backup? Backup failed due to lack of space? As | |
| 821 | - you | |
| 822 | - may set up a schedule to automatically do backup daily or weekly, and the size | |
| 823 | - of | |
| 824 | - disk space is limited, so your backup disk will run out of space quickly or | |
| 825 | - someday. | |
| 826 | - It is a real pain to manually delete old backups. Don’t worry about it. WP | |
| 827 | - Database | |
| 828 | - Backup makes it easy to delete old/temparary backup files using this option.</p> | |
| 829 | - | |
| 830 | - </div> | |
| 831 | - | |
| 832 | - <div class="row list-group-item"> | |
| 833 | - <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 834 | - class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 835 | - </div> | |
| 836 | - <?php if ( true === isset( $_SERVER['DOCUMENT_ROOT'] ) ) { ?> | |
| 837 | - <div class="col-md-3">Root Path</div> | |
| 838 | - <div class="col-md-5"><?php echo esc_attr( sanitize_text_field( wp_unslash( $_SERVER['DOCUMENT_ROOT'] ) ) ); ?></div> | |
| 839 | - <?php } ?> | |
| 840 | - </div> | |
| 841 | - | |
| 842 | - | |
| 843 | - <div class="row list-group-item"> | |
| 844 | - <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 845 | - class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 846 | - </div> | |
| 847 | - <div class="col-md-3">ABSPATH</div> | |
| 848 | - <div class="col-md-5"><?php echo esc_attr( ABSPATH ); ?></div> | |
| 849 | - </div> | |
| 850 | - | |
| 851 | - <div class="row list-group-item"> | |
| 852 | - <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 853 | - class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 854 | - </div> | |
| 855 | - <div class="col-md-3"><?php esc_attr_e( 'Upload directory URL', 'wpdbbk' ); ?></div> | |
| 856 | - <div class="col-md-5"> | |
| 857 | - <?php | |
| 858 | - $upload_dir = wp_upload_dir(); | |
| 859 | - echo esc_url( $upload_dir['baseurl'] ) | |
| 860 | - ?> | |
| 861 | - </div> | |
| 862 | - <div class="col-md-3"></div> | |
| 863 | - </div> | |
| 864 | - | |
| 865 | - <div class="row list-group-item"> | |
| 866 | - <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 867 | - class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 868 | - </div> | |
| 869 | - <div class="col-md-3"><?php esc_attr_e( 'Upload directory', 'wpdbbk' ); ?></div> | |
| 870 | - <div class="col-md-5"><?php echo esc_attr( $upload_dir['basedir'] ); ?></div> | |
| 871 | - <div class="col-md-1"> | |
| 872 | - <?php echo esc_attr( substr( sprintf( '%o', fileperms( $upload_dir['basedir'] ) ), -4 ) ); ?></div> | |
| 873 | - <div | |
| 874 | - class="col-md-2"><?php echo ( ! is_writable( $upload_dir['basedir'] ) ) ? '<p class="text-danger"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Not writable </p>' : '<p class="text-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span> writable</p>'; ?> | |
| 875 | - </div> | |
| 876 | - </div> | |
| 877 | - | |
| 878 | - <div class="row list-group-item"> | |
| 879 | - <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 880 | - class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 881 | - </div> | |
| 882 | - <div class="col-md-3">Loaded PHP INI</div> | |
| 883 | - <div class="col-md-5"><?php echo esc_attr( php_ini_loaded_file() ); ?></div> | |
| 884 | - </div> | |
| 885 | - <div class="row list-group-item"> | |
| 886 | - <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 887 | - class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 888 | - </div> | |
| 889 | - <div class="col-md-3">Memory Limit</div> | |
| 890 | - <div class="col-md-5"> | |
| 891 | - <?php | |
| 892 | - echo esc_attr( WP_MEMORY_LIMIT ); | |
| 893 | - echo '(Max ' . esc_attr( WP_MAX_MEMORY_LIMIT ); | |
| 894 | - ?> | |
| 895 | - ) | |
| 896 | - </div> | |
| 897 | - </div> | |
| 898 | - | |
| 899 | - | |
| 900 | - <div class="row list-group-item"> | |
| 901 | - <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 902 | - class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 903 | - </div> | |
| 904 | - <div class="col-md-3"><?php esc_attr_e( 'Max Execution Time', 'wpdbbk' ); ?></div> | |
| 905 | - <div class="col-md-5"> <?php echo esc_attr( ini_get( 'max_execution_time' ) ); ?></div> | |
| 906 | - <div class="col-md-1"></div> | |
| 907 | - <div | |
| 908 | - class="col-md-2"><?php echo esc_attr( ini_get( 'max_execution_time' ) ) < 60 ? '<p class="text-danger" data-toggle="tooltip" data-placement="left" title="For large site set high"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Low </p>' : ''; ?></div> | |
| 909 | - </div> | |
| 910 | - <div class="row list-group-item"> | |
| 911 | - <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 912 | - class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 913 | - </div> | |
| 914 | - <div class="col-md-3"><?php esc_attr_e( 'Database backup directory', 'wpdbbk' ); ?></div> | |
| 915 | - <div | |
| 916 | - class="col-md-5"> <?php echo esc_attr( $upload_dir['basedir'] . '/db-backup' ); ?></div> | |
| 917 | - <div | |
| 918 | - class="col-md-1"><?php echo esc_attr( substr( sprintf( '%o', fileperms( esc_attr( $upload_dir['basedir'] ) . '/db-backup' ) ), -4 ) ); ?></div> | |
| 919 | - <div | |
| 920 | - class="col-md-2"><?php echo ( ! is_writable( $upload_dir['basedir'] . '/db-backup' ) ) ? '<p class="text-danger"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Not writable </p>' : '<p class="text-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span> writable</p>'; ?></div> | |
| 921 | - </div> | |
| 922 | - | |
| 923 | - <div class="row list-group-item"> | |
| 924 | - <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 925 | - class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 926 | - </div> | |
| 927 | - <div class="col-md-3"><?php esc_attr_e( 'Class ZipArchive Present : ', 'wpdbbk' ); ?></div> | |
| 928 | - <div class="col-md-5"> | |
| 929 | - <?php | |
| 930 | - echo ( class_exists( 'ZipArchive' ) ) ? 'Yes </p>' : '<p class="">No</p>'; | |
| 931 | - ?> | |
| 932 | - </div> | |
| 933 | - <div class="col-md-3"></div> | |
| 934 | - </div> | |
| 935 | - | |
| 936 | - <div class="row list-group-item"> | |
| 937 | - <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 938 | - class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 939 | - </div> | |
| 940 | - <div class="col-md-3"><?php esc_attr_e( 'mysqldump (cmd) Present : ', 'wpdbbk' ); ?></div> | |
| 941 | - <div class="col-md-5"> | |
| 942 | - <?php | |
| 943 | - $wpdb_admin = new Wpdb_Admin(); | |
| 944 | - echo ( $wpdb_admin->get_mysqldump_command_path() ) ? 'Yes </p>' : '<p class="">No</p>'; | |
| 945 | - ?> | |
| 946 | - </div> | |
| 947 | - <div class="col-md-3"></div> | |
| 948 | - </div> | |
| 949 | - | |
| 950 | - </div> | |
| 951 | - </div> | |
| 952 | - </div> | |
| 953 | - | |
| 954 | - <div class="panel panel-default"> | |
| 955 | - <div class="panel-heading"> | |
| 956 | - <h4 class="panel-title"> | |
| 957 | - <a data-toggle="collapse" data-parent="#accordion" href="#collapsedb"> | |
| 958 | - Database Information | |
| 959 | - | |
| 960 | - </a> | |
| 961 | - </h4> | |
| 962 | - </div> | |
| 963 | - | |
| 964 | - <div id="collapsedb" class="panel-collapse collapse in"> | |
| 965 | - <div class="panel-body"> | |
| 966 | - <table class="table table-condensed"> | |
| 967 | - <tr class="success"> | |
| 968 | - <th>Setting</th> | |
| 969 | - <th>Value</th> | |
| 970 | - </tr> | |
| 971 | - <tr> | |
| 972 | - <td>Database Host</td> | |
| 973 | - <td><?php echo esc_attr( DB_HOST ); ?></td> | |
| 974 | - </tr> | |
| 975 | - <tr class="default"> | |
| 976 | - <td>Database Name</td> | |
| 977 | - <td> <?php echo esc_attr( DB_NAME ); ?></td> | |
| 978 | - </tr> | |
| 979 | - <tr> | |
| 980 | - <td>Database User</td> | |
| 981 | - <td><?php echo esc_attr( DB_USER ); ?></td> | |
| 982 | - </td> | |
| 983 | - </tr> | |
| 984 | - <tr> | |
| 985 | - <td>Database Type</td> | |
| 986 | - <td>MYSQL</td> | |
| 987 | - </tr> | |
| 988 | - <tr> | |
| 989 | - <?php | |
| 990 | - // Get MYSQL Version. | |
| 991 | - global $wpdb; | |
| 992 | - $mysqlversion = wp_cache_get( 'wpdb_mysqlversion' ); | |
| 993 | - if ( true === empty( $mysqlversion ) ) { | |
| 994 | - $mysqlversion = $wpdb->get_var( 'SELECT VERSION() AS version' ); // phpcs:ignore | |
| 995 | - wp_cache_set( 'wpdb_mysqlversion', $mysqlversion, '', 18000 ); | |
| 996 | - } | |
| 997 | - ?> | |
| 998 | - <td>Database Version</td> | |
| 999 | - <td>v<?php echo esc_attr( $mysqlversion ); ?></td> | |
| 1000 | - </tr> | |
| 1001 | - </table> | |
| 1002 | - | |
| 1003 | - </div> | |
| 1004 | - </div> | |
| 1005 | - </div> | |
| 1006 | - | |
| 1007 | - <div class="panel panel-default"> | |
| 1008 | - <div class="panel-heading"> | |
| 1009 | - <h4 class="panel-title"> | |
| 1010 | - <a data-toggle="collapse" data-parent="#accordion" href="#collapsedbtable"> | |
| 1011 | - Tables Information | |
| 1012 | - | |
| 1013 | - </a> | |
| 1014 | - </h4> | |
| 1015 | - </div> | |
| 1016 | - <div id="collapsedbtable" class="panel-collapse collapse"> | |
| 1017 | - <div class="panel-body"> | |
| 1018 | - <table class="table table-condensed"> | |
| 1019 | - <tr class="success"> | |
| 1020 | - <th>No.</th> | |
| 1021 | - <th>Tables</th> | |
| 1022 | - <th>Records</th> | |
| 1023 | - | |
| 1024 | - </tr> | |
| 1025 | - <?php | |
| 1026 | - $no = 0; | |
| 1027 | - $row_usage = 0; | |
| 1028 | - $data_usage = 0; | |
| 1029 | - $tablesstatus = $wpdb->get_results( 'SHOW TABLE STATUS' ); // phpcs:ignore | |
| 1030 | - foreach ( $tablesstatus as $tablestatus ) { | |
| 1031 | - $tablestatus_arr = (array) $tablestatus; | |
| 1032 | - if ( 0 === ( $no % 2 ) ) { | |
| 1033 | - $style = ''; | |
| 1034 | - } else { | |
| 1035 | - $style = ' class="alternate"'; | |
| 1036 | - } | |
| 1037 | - $no++; | |
| 1038 | - echo '<tr' . esc_attr( $style ) . '>'; | |
| 1039 | - echo '<td>' . esc_attr( number_format_i18n( $no ) ) . '</td>'; | |
| 1040 | - echo '<td>' . esc_attr( $tablestatus_arr['Name'] ) . '</td>'; | |
| 1041 | - echo '<td>' . esc_attr( number_format_i18n( $tablestatus_arr['Rows'] ) ) . '</td>'; | |
| 1042 | - | |
| 1043 | - $row_usage += $tablestatus_arr['Rows']; | |
| 1044 | - | |
| 1045 | - echo '</tr>'; | |
| 1046 | - } | |
| 1047 | - echo '<tr class="thead">'; | |
| 1048 | - echo '<th> Total:</th>'; | |
| 1049 | - echo '<th>' . esc_attr( number_format_i18n( $no ) ) . ' Table </th>'; | |
| 1050 | - echo '<th>' . esc_attr( number_format_i18n( $row_usage ) ) . ' Records</th>'; | |
| 1051 | - | |
| 1052 | - echo '</tr>'; | |
| 1053 | - ?> | |
| 1054 | - </table> | |
| 1055 | - | |
| 1056 | - </div> | |
| 1057 | - </div> | |
| 1058 | - </div> | |
| 1059 | - <div class="panel panel-default"> | |
| 1060 | - <div class="panel-heading"> | |
| 1061 | - <h4 class="panel-title"> | |
| 1062 | - <a data-toggle="collapse" data-parent="#accordion" href="#collapsewp"> | |
| 1063 | - WordPress Information | |
| 1064 | - | |
| 1065 | - </a> | |
| 1066 | - </h4> | |
| 1067 | - </div> | |
| 1068 | - <div id="collapsewp" class="panel-collapse collapse"> | |
| 1069 | - <div class="panel-body"> | |
| 1070 | - <table class="table table-condensed"> | |
| 1071 | - <tr class="success"> | |
| 1072 | - <th>Setting</th> | |
| 1073 | - <th>Value</th> | |
| 1074 | - | |
| 1075 | - </tr> | |
| 1076 | - <tr> | |
| 1077 | - <td>WordPress Version</td> | |
| 1078 | - <td><?php bloginfo( 'version' ); ?></td> | |
| 1079 | - </tr> | |
| 1080 | - <tr> | |
| 1081 | - <td>Home URL</td> | |
| 1082 | - <td> <?php echo esc_url( home_url() ); ?></td> | |
| 1083 | - </tr> | |
| 1084 | - <tr> | |
| 1085 | - <td>Site URL</td> | |
| 1086 | - <td><?php echo esc_url( site_url() ); ?></td> | |
| 1087 | - </tr> | |
| 1088 | - <tr> | |
| 1089 | - <td>Upload directory URL</td> | |
| 1090 | - <td><?php $upload_dir = wp_upload_dir(); ?> | |
| 1091 | - <?php echo esc_url( $upload_dir['baseurl'] ); ?></td> | |
| 1092 | - </tr> | |
| 1093 | - </table> | |
| 1094 | - | |
| 1095 | - </div> | |
| 1096 | - </div> | |
| 1097 | - </div> | |
| 1098 | - | |
| 1099 | - <div class="panel panel-default"> | |
| 1100 | - <div class="panel-heading"> | |
| 1101 | - <h4 class="panel-title"> | |
| 1102 | - <a data-toggle="collapse" data-parent="#accordion" href="#collapsewpsetting"> | |
| 1103 | - WordPress Settings | |
| 1104 | - | |
| 1105 | - </a> | |
| 1106 | - </h4> | |
| 1107 | - </div> | |
| 1108 | - <div id="collapsewpsetting" class="panel-collapse collapse"> | |
| 1109 | - <div class="panel-body"> | |
| 1110 | - <table class="table table-condensed"> | |
| 1111 | - <tr class="success"> | |
| 1112 | - <th>Plugin Name</th> | |
| 1113 | - <th>Version</th> | |
| 1114 | - </tr> | |
| 1115 | - <?php | |
| 1116 | - $plugins = get_plugins(); | |
| 1117 | - foreach ( $plugins as $plugin ) { | |
| 1118 | - echo '<tr> | |
| 1119 | - <td>' . esc_attr( $plugin['Name'] ) . '</td> | |
| 1120 | - <td>' . esc_attr( $plugin['Version'] ) . '</td> | |
| 1121 | - </tr>'; | |
| 1122 | - } | |
| 1123 | - ?> | |
| 1124 | - </table> | |
| 1125 | - <table class="table table-condensed"> | |
| 1126 | - <tr class="success"> | |
| 1127 | - <th>Active Theme Name</th> | |
| 1128 | - <th>Version</th> | |
| 1129 | - </tr> | |
| 1130 | - <?php | |
| 1131 | - $my_theme = wp_get_theme(); | |
| 1132 | - | |
| 1133 | - echo '<tr> | |
| 1134 | - <td>' . esc_attr( $my_theme->get( 'Name' ) ) . '</td> | |
| 1135 | - <td>' . esc_attr( $my_theme->get( 'Version' ) ) . '</td> | |
| 1136 | - </tr>'; | |
| 1137 | - ?> | |
| 1138 | - </table> | |
| 1139 | - <div class="row"> | |
| 1140 | - <button class="btn btn-primary" type="button"> | |
| 1141 | - Drafts Post Count <span class="badge"> | |
| 1142 | - <?php | |
| 1143 | - $count_posts = wp_count_posts(); | |
| 1144 | - echo esc_attr( $count_posts->draft ); | |
| 1145 | - ?> | |
| 1146 | - </span> | |
| 1147 | - </button> | |
| 1148 | - <button class="btn btn-primary" type="button"> | |
| 1149 | - Publish Post Count <span class="badge"> | |
| 1150 | - <?php | |
| 1151 | - | |
| 1152 | - echo esc_attr( $count_posts->publish ); | |
| 1153 | - ?> | |
| 1154 | - </span> | |
| 1155 | - </button> | |
| 1156 | - <button class="btn btn-primary" type="button"> | |
| 1157 | - Drafts Pages Count <span class="badge"> | |
| 1158 | - <?php | |
| 1159 | - $count_pages = wp_count_posts( 'page' ); | |
| 1160 | - echo esc_attr( $count_pages->draft ); | |
| 1161 | - ?> | |
| 1162 | - </span> | |
| 1163 | - </button> | |
| 1164 | - <button class="btn btn-primary" type="button"> | |
| 1165 | - Publish Pages Count <span class="badge"> | |
| 1166 | - <?php | |
| 1167 | - | |
| 1168 | - echo esc_attr( $count_pages->publish ); | |
| 1169 | - ?> | |
| 1170 | - </span> | |
| 1171 | - </button> | |
| 1172 | - <button class="btn btn-primary" type="button"> | |
| 1173 | - Approved Comments Count <span class="badge"> | |
| 1174 | - <?php | |
| 1175 | - $comments_count = wp_count_comments(); | |
| 1176 | - echo esc_attr( $comments_count->approved ); | |
| 1177 | - ?> | |
| 1178 | - </span> | |
| 1179 | - </button> | |
| 1180 | - </div> | |
| 1181 | - </div> | |
| 1182 | - </div> | |
| 1183 | - </div> | |
| 1184 | - | |
| 1185 | - | |
| 1186 | - </div> | |
| 1187 | - <div class="tab-pane" id="db_advanced"> | |
| 1188 | - <h4>A 'WP ALL Backup' Plugin will backup and restore your entire site at will, | |
| 1189 | - complete with Dropbox,FTP,Email,Google drive, Amazon S3 integration.</h4> | |
| 1190 | - <h2>Pro Features </h2><h4><?php echo wp_kses_post( $coupon ); ?></h4> | |
| 1191 | - <div class="row"> | |
| 1192 | - <div class="col-md-3"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> | |
| 1193 | - Complete | |
| 1194 | - Backup | |
| 1195 | - </div> | |
| 1196 | - <div class="col-md-3"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> Only | |
| 1197 | - Selected file Backup | |
| 1198 | - </div> | |
| 1199 | - <div class="col-md-3"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> | |
| 1200 | - ZipArchive | |
| 1201 | - </div> | |
| 1202 | - <div class="col-md-3"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> | |
| 1203 | - PclZip | |
| 1204 | - </div> | |
| 1205 | - <div class="col-md-3"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> | |
| 1206 | - Scheduled | |
| 1207 | - backups | |
| 1208 | - </div> | |
| 1209 | - <div class="col-md-3"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> Set | |
| 1210 | - backup interval | |
| 1211 | - </div> | |
| 1212 | - <div class="col-md-3"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> | |
| 1213 | - Manual | |
| 1214 | - backup | |
| 1215 | - </div> | |
| 1216 | - <div class="col-md-3"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> | |
| 1217 | - Multisite | |
| 1218 | - compatible | |
| 1219 | - </div> | |
| 1220 | - <div class="col-md-3"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> | |
| 1221 | - Backup | |
| 1222 | - entire site | |
| 1223 | - </div> | |
| 1224 | - <div class="col-md-3"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> | |
| 1225 | - Include | |
| 1226 | - media files | |
| 1227 | - </div> | |
| 1228 | - <div class="col-md-3"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> | |
| 1229 | - Exclude | |
| 1230 | - specific files | |
| 1231 | - </div> | |
| 1232 | - <div class="col-md-3"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> | |
| 1233 | - Downloadable log files | |
| 1234 | - </div> | |
| 1235 | - <div class="col-md-3"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> | |
| 1236 | - Simple | |
| 1237 | - one-click restore | |
| 1238 | - </div> | |
| 1239 | - <div class="col-md-3"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> Set | |
| 1240 | - number of backups to store | |
| 1241 | - </div> | |
| 1242 | - <div class="col-md-3"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> | |
| 1243 | - Automatically remove oldest backup | |
| 1244 | - </div> | |
| 1245 | - <div class="col-md-3"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> | |
| 1246 | - Dropbox | |
| 1247 | - integration | |
| 1248 | - </div> | |
| 1249 | - <div class="col-md-3"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> FTP | |
| 1250 | - and | |
| 1251 | - SFTP integration | |
| 1252 | - </div> | |
| 1253 | - <div class="col-md-3"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> | |
| 1254 | - Server | |
| 1255 | - info quick view | |
| 1256 | - </div> | |
| 1257 | - <div class="col-md-3"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> | |
| 1258 | - Support | |
| 1259 | - </div> | |
| 1260 | - </div> | |
| 1261 | - <h3>Key Features</h3> | |
| 1262 | - <div class="row"> | |
| 1263 | - | |
| 1264 | - <div class="col-md-3"> | |
| 1265 | - <h4>Fast</h4> | |
| 1266 | - <p class="bg-success"> | |
| 1267 | - This plugin can help you to rapidly create site backup. | |
| 1268 | - Capture your entire site, including media files, or pick and choose specific files and | |
| 1269 | - tables. | |
| 1270 | - </p> | |
| 1271 | - </div> | |
| 1272 | - <div class="col-md-3"> | |
| 1273 | - <h4>Scheduled Backups</h4> | |
| 1274 | - <p class="bg-info"> | |
| 1275 | - Create manual backups, as needed, or schedule automated backups. | |
| 1276 | - Trigger monthly, daily or hourly backups that are there when you need them most. | |
| 1277 | - </p> | |
| 1278 | - </div> | |
| 1279 | - <div class="col-md-3"> | |
| 1280 | - <h4>Essay to use</h4> | |
| 1281 | - <p class="bg-info"> | |
| 1282 | - Create and store as many backups of your site as you want. | |
| 1283 | - Get added protection and convenience with one-click restoration. | |
| 1284 | - Delete old backups options. | |
| 1285 | - </p> | |
| 1286 | - </div> | |
| 1287 | - <div class="col-md-3"> | |
| 1288 | - <h4>Integration</h4> | |
| 1289 | - <p class="bg-success"> | |
| 1290 | - Tie directly into other destination. | |
| 1291 | - Save directly to your favorite cloud services including Dropbox, | |
| 1292 | - by FTP/SFTP for added security. | |
| 1293 | - </p> | |
| 1294 | - </div> | |
| 1295 | - </div> | |
| 1296 | - | |
| 1297 | - | |
| 1298 | - <a href="https://www.wpseeds.com/product/wp-all-backup/" target="_blank"><h4><span | |
| 1299 | - class="label label-success">Get Pro 'WP All Backup' Plugin</span></h4></a> | |
| 1300 | - </div> | |
| 1301 | - <div class="tab-pane" id="db_setting"> | |
| 1302 | - <div class="panel panel-default"> | |
| 1303 | - <div class="panel-body"> | |
| 1304 | - <?php | |
| 1305 | - $wp_local_db_backup_count = get_option( 'wp_local_db_backup_count' ); | |
| 1306 | - $wp_db_log = get_option( 'wp_db_log' ); | |
| 1307 | - $wp_db_exclude_table = array(); | |
| 1308 | - $wp_db_exclude_table = get_option( 'wp_db_exclude_table' ); | |
| 1309 | - $wp_db_backup_enable_auto_upgrade = get_option( 'wp_db_backup_enable_auto_upgrade' ); | |
| 1310 | - if ( 1 === (int) $wp_db_backup_enable_auto_upgrade ) { | |
| 1311 | - $wp_db_backup_enable_auto_upgrade_checked = 'checked'; | |
| 1312 | - } else { | |
| 1313 | - $wp_db_backup_enable_auto_upgrade_checked = ''; | |
| 1314 | - } | |
| 1315 | - if ( 1 === (int) $wp_db_log ) { | |
| 1316 | - $checked = 'checked'; | |
| 1317 | - } else { | |
| 1318 | - $checked = ''; | |
| 1319 | - } | |
| 1320 | - $wp_db_remove_local_backup = get_option( 'wp_db_remove_local_backup' ); | |
| 1321 | - if ( 1 === (int) $wp_db_remove_local_backup ) { | |
| 1322 | - $remove_local_backup = 'checked'; | |
| 1323 | - } else { | |
| 1324 | - $remove_local_backup = ''; | |
| 1325 | - } | |
| 1326 | - ?> | |
| 1327 | - <form action="" method="post"> | |
| 1328 | - <?php wp_nonce_field( 'wp-database-backup' ); ?> | |
| 1329 | - <div class="input-group"> | |
| 1330 | - <span class="input-group-addon" id="sizing-addon2">Maximum Local Backups</span> | |
| 1331 | - <input type="number" name="wp_local_db_backup_count" value="<?php echo esc_html( $wp_local_db_backup_count ); ?>" class="form-control" placeholder="Maximum Local Backups" aria-describedby="sizing-addon2"> | |
| 1332 | - | |
| 1333 | - </div> | |
| 1334 | - <div class="alert alert-default" role="alert"> | |
| 1335 | - <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> The maximum | |
| 1336 | - number of Local Database Backups that should be kept, regardless of their size.</br> | |
| 1337 | - Leave blank for keep unlimited database backups. | |
| 1338 | - </div> | |
| 1339 | - <hr> | |
| 1340 | - <div class="input-group"> | |
| 1341 | - <input type="checkbox" <?php echo esc_attr( $checked ); ?> name="wp_db_log"> Enable Log. | |
| 1342 | - </div> | |
| 1343 | - <hr> | |
| 1344 | - <div class="input-group"> | |
| 1345 | - <input type="checkbox" <?php echo esc_attr( $wp_db_backup_enable_auto_upgrade_checked ); ?> name="wp_db_backup_enable_auto_upgrade"> Enable Auto Backups Before Upgrade. | |
| 1346 | - <p><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> | |
| 1347 | - If checked then it will create database backup on(before) upgrade/update plugin, theme, WordPress. | |
| 1348 | - <br>Leave blank/un-checked for disable this feature. | |
| 1349 | - </p> | |
| 1350 | - </div> | |
| 1351 | - <hr> | |
| 1352 | - <div class="input-group"> | |
| 1353 | - <input type="checkbox" <?php echo esc_attr( $remove_local_backup ); ?> name="wp_db_remove_local_backup"> Remove local backup. | |
| 1354 | - <p><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> | |
| 1355 | - If Checked then it will remove local backup. | |
| 1356 | - <br>Use this option only when you have set any destination. | |
| 1357 | - <br>If somesites you need only external backup. | |
| 1358 | - </p> | |
| 1359 | - </div> | |
| 1360 | - <hr> | |
| 1361 | - <div class="input-group"> | |
| 1362 | - <input type="checkbox" <?php checked( get_option( 'wp_db_backup_enable_htaccess' ), '1' ); ?> name="wp_db_backup_enable_htaccess"> Enable .htaccess File In Storage Directory | |
| 1363 | - <p>Disable if issues occur when downloading backup/archive files.</p> | |
| 1364 | - </div> | |
| 1365 | - <hr> | |
| 1366 | - | |
| 1367 | - <div class="panel panel-default"> | |
| 1368 | - <div class="panel-heading"> | |
| 1369 | - <h4 class="panel-title"> | |
| 1370 | - <a data-toggle="collapse" data-parent="#accordion" href="#collapseExclude"> | |
| 1371 | - Exclude Table From Database Backup. | |
| 1372 | - </a> | |
| 1373 | - </h4> | |
| 1374 | - </div> | |
| 1375 | - <div id="collapseExclude" class="panel-collapse collapse in"> | |
| 1376 | - <div class="panel-body"> | |
| 1377 | - <table class="table table-condensed"> | |
| 1378 | - <tr class="success"> | |
| 1379 | - <th>No.</th> | |
| 1380 | - <th>Tables</th> | |
| 1381 | - <th>Records</th> | |
| 1382 | - <th><input type="checkbox" value="" onclick="excludetableall()" name="wp_db_exclude_table_all" id="wp_db_exclude_table_all">Exclude Table</th> | |
| 1383 | - </tr> | |
| 1384 | - <?php | |
| 1385 | - $no = 0; | |
| 1386 | - $row_usage = 0; | |
| 1387 | - $data_usage = 0; | |
| 1388 | - $tablesstatus = $wpdb->get_results( 'SHOW TABLE STATUS' ); // phpcs:ignore | |
| 1389 | - foreach ( $tablesstatus as $tablestatus ) { | |
| 1390 | - $tablestatus_arr = (array) $tablestatus; | |
| 1391 | - if ( 0 === ( $no % 2 ) ) { | |
| 1392 | - $style = ''; | |
| 1393 | - } else { | |
| 1394 | - $style = ' class="alternate"'; | |
| 1395 | - } | |
| 1396 | - $no++; | |
| 1397 | - echo '<tr' . esc_attr( $style ) . '>'; | |
| 1398 | - echo '<td>' . esc_attr( number_format_i18n( $no ) ) . '</td>'; | |
| 1399 | - echo '<td>' . esc_attr( $tablestatus_arr['Name'] ) . '</td>'; | |
| 1400 | - echo '<td>' . esc_attr( number_format_i18n( $tablestatus_arr['Rows'] ) ) . '</td>'; | |
| 1401 | - if ( false === empty( $wp_db_exclude_table ) && in_array( $tablestatus_arr['Name'], $wp_db_exclude_table, true ) ) { | |
| 1402 | - $checked = 'checked'; | |
| 1403 | - } else { | |
| 1404 | - $checked = ''; | |
| 1405 | - } | |
| 1406 | - echo '<td> <input class="wp_db_exclude_table" type="checkbox" ' . esc_attr( $checked ) . ' value="' . esc_attr( $tablestatus_arr['Name'] ) . '" name="wp_db_exclude_table[' . esc_attr( $tablestatus_arr['Name'] ) . ']"></td>'; | |
| 1407 | - | |
| 1408 | - $row_usage += $tablestatus_arr['Rows']; | |
| 1409 | - | |
| 1410 | - echo '</tr>'; | |
| 1411 | - } | |
| 1412 | - echo '<tr class="thead">'; | |
| 1413 | - echo '<th>Total:</th>'; | |
| 1414 | - echo '<th>' . esc_attr( number_format_i18n( $no ) ) . ' Table</th>'; | |
| 1415 | - echo '<th>' . esc_attr( number_format_i18n( $row_usage ) ) . ' Records</th>'; | |
| 1416 | - echo '<th></th>'; | |
| 1417 | - echo '</tr>'; | |
| 1418 | - ?> | |
| 1419 | - </table> | |
| 1420 | - </div> | |
| 1421 | - </div> | |
| 1422 | - </div> | |
| 1423 | - <hr> | |
| 1424 | - <input class="btn btn-primary" type="submit" name="wpsetting" value="Save"> | |
| 1425 | - </form> | |
| 1426 | - </div> | |
| 1427 | - </div> | |
| 1428 | - | |
| 1429 | - </div> | |
| 1430 | - <div class="tab-pane" id="searchreplace"> | |
| 1431 | - <div class="panel panel-default"> | |
| 1432 | - <div class="panel-body"> | |
| 1433 | - <?php | |
| 1434 | - $wp_db_backup_search_text = get_option( 'wp_db_backup_search_text' ); | |
| 1435 | - $wp_db_backup_replace_text = get_option( 'wp_db_backup_replace_text' ); | |
| 1436 | - ?> | |
| 1437 | - <form action="" method="post"> | |
| 1438 | - <?php wp_nonce_field( 'wp-database-backup' ); ?> | |
| 1439 | - <br> | |
| 1440 | - <p>If you even need to migrate your WordPress site to a different domain name, or add an SSL certificate to it, you must update the URLs in your database backup file then you can use this feature. <br> This feature allow you to Search and Replace text in your database backup file. <br> if you want only exclude tables from search and replace text then Go to Dashboard=>Tool=>WP-DB Backup > Setting > Exclude Table From Database Backup setting. The tables you selected will be skipped over for each backup you make. | |
| 1441 | - </p> | |
| 1442 | - <br> | |
| 1443 | - <div class="input-group"> | |
| 1444 | - <span class="input-group-addon" id="wp_db_backup_search_text">Search For</span> | |
| 1445 | - <input type="text" name="wp_db_backup_search_text" value="<?php echo esc_html( $wp_db_backup_search_text ); ?>" class="form-control" placeholder="http://localhost/wordpress" aria-describedby="wp_db_backup_search_text"> | |
| 1446 | - | |
| 1447 | - </div> | |
| 1448 | - <br> | |
| 1449 | - <div class="input-group"> | |
| 1450 | - <span class="input-group-addon" id="wp_db_backup_replace_text">Replace With</span> | |
| 1451 | - <input type="text" name="wp_db_backup_replace_text" value="<?php echo esc_html( $wp_db_backup_replace_text ); ?>" class="form-control" placeholder="http://site.com" aria-describedby="wp_db_backup_replace_text"> | |
| 1452 | - | |
| 1453 | - </div> | |
| 1454 | - | |
| 1455 | - <div class="alert alert-default" role="alert"> | |
| 1456 | - <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> | |
| 1457 | - Leave blank those fields if you don't want use this feature and want only regular Database backup. | |
| 1458 | - <br> | |
| 1459 | - Ex: | |
| 1460 | - <br>Search For: http://localhost/wordpress/ | |
| 1461 | - <br>Replace With: http://domain.com/ | |
| 1462 | - | |
| 1463 | - <br><br> | |
| 1464 | - Note - This is Search & Replace data in your WordPress Database Backup File not in current Database installation. | |
| 1465 | - <p> <a href="https://www.wpseeds.com/documentation/docs/wp-database-backup/search-and-replace/" target="_blank">Documentation</a></p> | |
| 1466 | - </div> | |
| 1467 | - | |
| 1468 | - <input class="btn btn-primary" type="submit" name="wpsetting_search" value="Save"> | |
| 1469 | - </form> | |
| 1470 | - </div> | |
| 1471 | - </div> | |
| 1472 | - | |
| 1473 | - | |
| 1474 | - </div> | |
| 1475 | - <div class="tab-pane" id="db_destination"> | |
| 1476 | - <?php | |
| 1477 | - include plugin_dir_path( __FILE__ ) . 'Destination/wp-backup-destination.php'; | |
| 1478 | - ?> | |
| 1479 | - </div> | |
| 1480 | - | |
| 1481 | - | |
| 1482 | - </div> | |
| 1483 | - | |
| 1484 | - </div> | |
| 1485 | - </div> | |
| 1486 | - | |
| 1487 | - <?php | |
| 1488 | - } | |
| 1489 | - | |
| 1490 | - /** | |
| 1491 | - * Run after complete backup. | |
| 1492 | - * | |
| 1493 | - * @param bool $bytes - bytes details. | |
| 1494 | - * @param int $precision - precision details. | |
| 1495 | - */ | |
| 1496 | - public function wp_db_backup_format_bytes( $bytes, $precision = 2 ) { | |
| 1497 | - $units = array( 'B', 'KB', 'MB', 'GB', 'TB' ); | |
| 1498 | - $bytes = max( $bytes, 0 ); | |
| 1499 | - $pow = floor( ( $bytes ? log( $bytes ) : 0 ) / log( 1024 ) ); | |
| 1500 | - $pow = min( $pow, count( $units ) - 1 ); | |
| 1501 | - $bytes /= pow( 1024, $pow ); | |
| 1502 | - return round( $bytes, $precision ) . ' ' . $units[ $pow ]; | |
| 1503 | - } | |
| 1504 | - | |
| 1505 | - /** | |
| 1506 | - * Create database bakup function. | |
| 1507 | - */ | |
| 1508 | - public function wp_db_backup_create_mysql_backup() { | |
| 1509 | - global $wpdb; | |
| 1510 | - /* BEGIN : Prevent saving backup plugin settings in the database dump */ | |
| 1511 | - $options_backup = get_option( 'wp_db_backup_backups' ); | |
| 1512 | - $settings_backup = get_option( 'wp_db_backup_options' ); | |
| 1513 | - delete_option( 'wp_db_backup_backups' ); | |
| 1514 | - delete_option( 'wp_db_backup_options' ); | |
| 1515 | - /* END : Prevent saving backup plugin settings in the database dump */ | |
| 1516 | - $wp_db_exclude_table = array(); | |
| 1517 | - $wp_db_exclude_table = get_option( 'wp_db_exclude_table' ); | |
| 1518 | - $tables = $wpdb->get_col( 'SHOW TABLES' ); // phpcs:ignore | |
| 1519 | - $output = ''; | |
| 1520 | - foreach ( $tables as $table ) { | |
| 1521 | - if ( empty( $wp_db_exclude_table ) || ( ! ( in_array( $table, $wp_db_exclude_table, true ) ) ) ) { | |
| 1522 | - $result = $wpdb->get_results( "SELECT * FROM {$table}", ARRAY_N ); // phpcs:ignore | |
| 1523 | - $row2 = $wpdb->get_row( 'SHOW CREATE TABLE ' . $table, ARRAY_N ); // phpcs:ignore | |
| 1524 | - $output .= "\n\n" . $row2[1] . ";\n\n"; | |
| 1525 | - $result_count = count( $result ); | |
| 1526 | - for ( $i = 0; $i < $result_count; $i++ ) { | |
| 1527 | - $row = $result[ $i ]; | |
| 1528 | - $output .= 'INSERT INTO ' . $table . ' VALUES('; | |
| 1529 | - $result_o_index = count( $result[0] ); | |
| 1530 | - for ( $j = 0; $j < $result_o_index; $j++ ) { | |
| 1531 | - $row[ $j ] = $wpdb->_real_escape( $row[ $j ] ); | |
| 1532 | - $output .= ( isset( $row[ $j ] ) ) ? '"' . $row[ $j ] . '"' : '""'; | |
| 1533 | - if ( $j < ( $result_o_index - 1 ) ) { | |
| 1534 | - $output .= ','; | |
| 1535 | - } | |
| 1536 | - } | |
| 1537 | - $output .= ");\n"; | |
| 1538 | - } | |
| 1539 | - $output .= "\n"; | |
| 1540 | - } | |
| 1541 | - } | |
| 1542 | - $wpdb->flush(); | |
| 1543 | - /* BEGIN : Prevent saving backup plugin settings in the database dump */ | |
| 1544 | - add_option( 'wp_db_backup_backups', $options_backup ); | |
| 1545 | - add_option( 'wp_db_backup_options', $settings_backup ); | |
| 1546 | - /* END : Prevent saving backup plugin settings in the database dump */ | |
| 1547 | - return $output; | |
| 1548 | - } | |
| 1549 | - | |
| 1550 | - /** | |
| 1551 | - * Mysql Dump set path. | |
| 1552 | - * | |
| 1553 | - * @param string $path - Path. | |
| 1554 | - */ | |
| 1555 | - public function set_mysqldump_command_path( $path ) { | |
| 1556 | - $this->mysqldump_command_path = $path; | |
| 1557 | - } | |
| 1558 | - | |
| 1559 | - /** | |
| 1560 | - * Mysql Dump get path. | |
| 1561 | - */ | |
| 1562 | - public function get_mysqldump_command_path() { | |
| 1563 | - | |
| 1564 | - // Check shell_exec is available. | |
| 1565 | - if ( ! self::is_shell_exec_available() ) { | |
| 1566 | - return ''; | |
| 1567 | - } | |
| 1568 | - | |
| 1569 | - // Return now if it's already been set. | |
| 1570 | - if ( isset( $this->mysqldump_command_path ) ) { | |
| 1571 | - return $this->mysqldump_command_path; | |
| 1572 | - } | |
| 1573 | - | |
| 1574 | - $this->mysqldump_command_path = ''; | |
| 1575 | - | |
| 1576 | - // Does mysqldump work. | |
| 1577 | - if ( is_null( shell_exec( 'hash mysqldump 2>&1' ) ) ) { // phpcs:ignore | |
| 1578 | - | |
| 1579 | - // If so store it for later. | |
| 1580 | - $this->set_mysqldump_command_path( 'mysqldump' ); | |
| 1581 | - | |
| 1582 | - // And return now. | |
| 1583 | - return $this->mysqldump_command_path; | |
| 1584 | - } | |
| 1585 | - | |
| 1586 | - // List of possible mysqldump locations. | |
| 1587 | - $mysqldump_locations = array( | |
| 1588 | - '/usr/local/bin/mysqldump', | |
| 1589 | - '/usr/local/mysql/bin/mysqldump', | |
| 1590 | - '/usr/mysql/bin/mysqldump', | |
| 1591 | - '/usr/bin/mysqldump', | |
| 1592 | - '/opt/local/lib/mysql6/bin/mysqldump', | |
| 1593 | - '/opt/local/lib/mysql5/bin/mysqldump', | |
| 1594 | - '/opt/local/lib/mysql4/bin/mysqldump', | |
| 1595 | - '/xampp/mysql/bin/mysqldump', | |
| 1596 | - '/Program Files/xampp/mysql/bin/mysqldump', | |
| 1597 | - '/Program Files/MySQL/MySQL Server 6.0/bin/mysqldump', | |
| 1598 | - '/Program Files/MySQL/MySQL Server 5.5/bin/mysqldump', | |
| 1599 | - '/Program Files/MySQL/MySQL Server 5.4/bin/mysqldump', | |
| 1600 | - '/Program Files/MySQL/MySQL Server 5.1/bin/mysqldump', | |
| 1601 | - '/Program Files/MySQL/MySQL Server 5.0/bin/mysqldump', | |
| 1602 | - '/Program Files/MySQL/MySQL Server 4.1/bin/mysqldump', | |
| 1603 | - ); | |
| 1604 | - | |
| 1605 | - // Find the one which works. | |
| 1606 | - foreach ( $mysqldump_locations as $location ) { | |
| 1607 | - if ( is_executable( self::conform_dir( $location ) ) ) { | |
| 1608 | - $this->set_mysqldump_command_path( $location ); | |
| 1609 | - } | |
| 1610 | - } | |
| 1611 | - | |
| 1612 | - return $this->mysqldump_command_path; | |
| 1613 | - } | |
| 1614 | - | |
| 1615 | - /** | |
| 1616 | - * Check dir. | |
| 1617 | - * | |
| 1618 | - * @param string $dir - Dir Details. | |
| 1619 | - * @param bool $recursive - Recursive. | |
| 1620 | - */ | |
| 1621 | - public static function conform_dir( $dir, $recursive = false ) { | |
| 1622 | - | |
| 1623 | - // Assume empty dir is root. | |
| 1624 | - if ( ! $dir ) { | |
| 1625 | - $dir = '/'; | |
| 1626 | - } | |
| 1627 | - | |
| 1628 | - // Replace single forward slash (looks like double slash because we have to escape it). | |
| 1629 | - $dir = str_replace( '\\', '/', $dir ); | |
| 1630 | - $dir = str_replace( '//', '/', $dir ); | |
| 1631 | - | |
| 1632 | - // Remove the trailing slash. | |
| 1633 | - if ( '/' !== $dir ) { | |
| 1634 | - $dir = untrailingslashit( $dir ); | |
| 1635 | - } | |
| 1636 | - | |
| 1637 | - // Carry on until completely normalized. | |
| 1638 | - if ( ! $recursive && self::conform_dir( $dir, true ) !== $dir ) { | |
| 1639 | - return self::conform_dir( $dir ); | |
| 1640 | - } | |
| 1641 | - | |
| 1642 | - return (string) $dir; | |
| 1643 | - } | |
| 1644 | - | |
| 1645 | - /** | |
| 1646 | - * Check Shell. | |
| 1647 | - */ | |
| 1648 | - public static function is_shell_exec_available() { | |
| 1649 | - | |
| 1650 | - // Are we in Safe Mode. | |
| 1651 | - if ( self::is_safe_mode_active() ) { | |
| 1652 | - return false; | |
| 1653 | - } | |
| 1654 | - | |
| 1655 | - // Is shell_exec or escapeshellcmd or escapeshellarg disabled? | |
| 1656 | - if ( array_intersect( array( 'shell_exec', 'escapeshellarg', 'escapeshellcmd' ), array_map( 'trim', explode( ',', ini_get( 'disable_functions' ) ) ) ) ) { | |
| 1657 | - return false; | |
| 1658 | - } | |
| 1659 | - | |
| 1660 | - // Can we issue a simple echo command? | |
| 1661 | - if ( ! shell_exec( 'echo WP Backup' ) ) { // phpcs:ignore | |
| 1662 | - return false; | |
| 1663 | - } | |
| 1664 | - | |
| 1665 | - return true; | |
| 1666 | - } | |
| 1667 | - | |
| 1668 | - /** | |
| 1669 | - * Check Safe mode active. | |
| 1670 | - * | |
| 1671 | - * @param string $ini_get_callback - String cmd. | |
| 1672 | - * @return bool | |
| 1673 | - */ | |
| 1674 | - public static function is_safe_mode_active( $ini_get_callback = 'ini_get' ) { | |
| 1675 | - $safe_mode = call_user_func( $ini_get_callback, 'safe_mode' ); | |
| 1676 | - if ( ( $safe_mode ) && 'off' !== strtolower( $safe_mode ) ) { | |
| 1677 | - return true; | |
| 1678 | - } | |
| 1679 | - | |
| 1680 | - return false; | |
| 1681 | - } | |
| 1682 | - | |
| 1683 | - /** | |
| 1684 | - * Database dump. | |
| 1685 | - * | |
| 1686 | - * @param string $sql_filename - File name. | |
| 1687 | - */ | |
| 1688 | - public function mysqldump( $sql_filename ) { | |
| 1689 | - $this->mysqldump_method = 'mysqldump'; | |
| 1690 | - | |
| 1691 | - $host = explode( ':', DB_HOST ); | |
| 1692 | - | |
| 1693 | - $host = reset( $host ); | |
| 1694 | - $port = strpos( DB_HOST, ':' ) ? end( explode( ':', DB_HOST ) ) : ''; | |
| 1695 | - | |
| 1696 | - // Path to the mysqldump executable. | |
| 1697 | - $cmd = escapeshellarg( $this->get_mysqldump_command_path() ); | |
| 1698 | - | |
| 1699 | - // We don't want to create a new DB. | |
| 1700 | - $cmd .= ' --no-create-db'; | |
| 1701 | - | |
| 1702 | - // Allow lock-tables to be overridden. | |
| 1703 | - if ( ! defined( 'WPDB_MYSQLDUMP_SINGLE_TRANSACTION' ) || WPDB_MYSQLDUMP_SINGLE_TRANSACTION !== false ) { | |
| 1704 | - $cmd .= ' --single-transaction'; | |
| 1705 | - } | |
| 1706 | - | |
| 1707 | - // Make sure binary data is exported properly. | |
| 1708 | - $cmd .= ' --hex-blob'; | |
| 1709 | - | |
| 1710 | - // Username. | |
| 1711 | - $cmd .= ' -u ' . escapeshellarg( DB_USER ); | |
| 1712 | - | |
| 1713 | - // Don't pass the password if it's blank. | |
| 1714 | - if ( DB_PASSWORD ) { | |
| 1715 | - $cmd .= ' -p' . escapeshellarg( DB_PASSWORD ); | |
| 1716 | - } | |
| 1717 | - | |
| 1718 | - // Set the host. | |
| 1719 | - $cmd .= ' -h ' . escapeshellarg( $host ); | |
| 1720 | - | |
| 1721 | - // Set the port if it was set. | |
| 1722 | - if ( ! empty( $port ) && is_numeric( $port ) ) { | |
| 1723 | - $cmd .= ' -P ' . $port; | |
| 1724 | - } | |
| 1725 | - | |
| 1726 | - // The file we're saving too. | |
| 1727 | - $cmd .= ' -r ' . escapeshellarg( $sql_filename ); | |
| 1728 | - | |
| 1729 | - $wp_db_exclude_table = array(); | |
| 1730 | - $wp_db_exclude_table = get_option( 'wp_db_exclude_table' ); | |
| 1731 | - if ( ! empty( $wp_db_exclude_table ) ) { | |
| 1732 | - foreach ( $wp_db_exclude_table as $wp_db_exclude_table ) { | |
| 1733 | - $cmd .= ' --ignore-table=' . DB_NAME . '.' . $wp_db_exclude_table; | |
| 1734 | - } | |
| 1735 | - } | |
| 1736 | - | |
| 1737 | - // The database we're dumping. | |
| 1738 | - $cmd .= ' ' . escapeshellarg( DB_NAME ); | |
| 1739 | - | |
| 1740 | - // Pipe STDERR to STDOUT. | |
| 1741 | - $cmd .= ' 2>&1'; | |
| 1742 | - // Store any returned data in an error. | |
| 1743 | - $stderr = shell_exec( $cmd ); // phpcs:ignore | |
| 1744 | - | |
| 1745 | - // Skip the new password warning that is output in mysql > 5.6. | |
| 1746 | - if ( trim( $stderr ) === 'Warning: Using a password on the command line interface can be insecure.' ) { | |
| 1747 | - $stderr = ''; | |
| 1748 | - } | |
| 1749 | - | |
| 1750 | - if ( $stderr ) { | |
| 1751 | - $this->error( $this->get_mysqldump_method(), $stderr ); | |
| 1752 | - } | |
| 1753 | - | |
| 1754 | - return $this->verify_mysqldump( $sql_filename ); | |
| 1755 | - } | |
| 1756 | - | |
| 1757 | - /** | |
| 1758 | - * Error. | |
| 1759 | - * | |
| 1760 | - * @param string $context - Data. | |
| 1761 | - * @param object $error - Error data. | |
| 1762 | - */ | |
| 1763 | - public function error( $context, $error ) { | |
| 1764 | - if ( empty( $context ) || empty( $error ) ) { | |
| 1765 | - return; | |
| 1766 | - } | |
| 1767 | - $error_str = implode( ':', (array) $error ); | |
| 1768 | - $_key = md5( $error_str ); | |
| 1769 | - $this->errors[ $context ][ $_key ] = $error; | |
| 1770 | - } | |
| 1771 | - | |
| 1772 | - /** | |
| 1773 | - * Verify Dump. | |
| 1774 | - * | |
| 1775 | - * @param string $sql_filename - Sql file. | |
| 1776 | - * @return bool | |
| 1777 | - */ | |
| 1778 | - public function verify_mysqldump( $sql_filename ) { | |
| 1779 | - | |
| 1780 | - // If we've already passed then no need to check again. | |
| 1781 | - if ( ! empty( $this->mysqldump_verified ) ) { | |
| 1782 | - return true; | |
| 1783 | - } | |
| 1784 | - | |
| 1785 | - // If there are mysqldump errors delete the database dump file as mysqldump will still have written one. | |
| 1786 | - if ( $this->get_errors( $this->get_mysqldump_method() ) && file_exists( $sql_filename ) ) { | |
| 1787 | - if ( file_exists( $database_file ) ) { | |
| 1788 | - unlink( $database_file ); | |
| 1789 | - } | |
| 1790 | - } | |
| 1791 | - | |
| 1792 | - // If we have an empty file delete it. | |
| 1793 | - if ( 0 === filesize( $sql_filename ) ) { | |
| 1794 | - if ( file_exists( $sql_filename ) ) { | |
| 1795 | - unlink( $sql_filename ); | |
| 1796 | - } | |
| 1797 | - } | |
| 1798 | - | |
| 1799 | - // If the file still exists then it must be good. | |
| 1800 | - if ( file_exists( $sql_filename ) ) { | |
| 1801 | - $this->mysqldump_verified = true; | |
| 1802 | - return $this->mysqldump_verified; | |
| 1803 | - } | |
| 1804 | - | |
| 1805 | - return false; | |
| 1806 | - } | |
| 1807 | - | |
| 1808 | - /** | |
| 1809 | - * Get error. | |
| 1810 | - * | |
| 1811 | - * @param string $context - Data. | |
| 1812 | - * @return string | |
| 1813 | - */ | |
| 1814 | - public function get_errors( $context = null ) { | |
| 1815 | - if ( ! empty( $context ) ) { | |
| 1816 | - return isset( $this->errors[ $context ] ) ? $this->errors[ $context ] : array(); | |
| 1817 | - } | |
| 1818 | - | |
| 1819 | - return $this->errors; | |
| 1820 | - } | |
| 1821 | - | |
| 1822 | - /** | |
| 1823 | - * Get mysql dump method. | |
| 1824 | - * | |
| 1825 | - * @return string | |
| 1826 | - */ | |
| 1827 | - public function get_mysqldump_method() { | |
| 1828 | - return $this->mysqldump_method; | |
| 1829 | - } | |
| 1830 | - | |
| 1831 | - // End : Generate SQL DUMP using cmd 06-03-2016. | |
| 1832 | - | |
| 1833 | - /** | |
| 1834 | - * Create zip. | |
| 1835 | - */ | |
| 1836 | - public function wp_db_backup_create_archive() { | |
| 1837 | - // Begin : Setup Upload Directory, Secure it and generate a random file name. | |
| 1838 | - | |
| 1839 | - $source_directory = $this->wp_db_backup_wp_config_path(); | |
| 1840 | - | |
| 1841 | - $path_info = wp_upload_dir(); | |
| 1842 | - $htasses_text = ''; | |
| 1843 | - wp_mkdir_p( $path_info['basedir'] . '/db-backup' ); | |
| 1844 | - fclose( fopen( $path_info['basedir'] . '/db-backup/index.php', 'w' ) ); // phpcs:ignore | |
| 1845 | - // Added htaccess file 08-05-2015 for prevent directory listing. | |
| 1846 | - // Fixed Vulnerability 22-06-2016 for prevent direct download. | |
| 1847 | - if ( 1 === (int) get_option( 'wp_db_backup_enable_htaccess' ) ) { | |
| 1848 | - $f = fopen( $path_info['basedir'] . '/db-backup/.htaccess', 'w' ); // phpcs:ignore | |
| 1849 | - fwrite( // phpcs:ignore | |
| 1850 | - $f, | |
| 1851 | - '#These next two lines will already exist in your .htaccess file | |
| 1852 | - RewriteEngine On | |
| 1853 | - RewriteBase / | |
| 1854 | - # Add these lines right after the preceding two | |
| 1855 | - RewriteCond %{REQUEST_FILENAME} ^.*(.zip)$ | |
| 1856 | - RewriteCond %{HTTP_COOKIE} !^.*can_download.*$ [NC] | |
| 1857 | - RewriteRule . - [R=403,L]' | |
| 1858 | - ); // phpcs:ignore | |
| 1859 | - fclose( $f ); // phpcs:ignore | |
| 1860 | - } | |
| 1861 | - // Begin : Generate SQL DUMP and save to file database.sql. | |
| 1862 | - $wp_site_name = preg_replace( '/[^A-Za-z0-9\_]/', '_', get_bloginfo( 'name' ) ); | |
| 1863 | - $wp_db_file_name = $wp_site_name . '_' . gmdate( 'Y_m_d' ) . '_' . time() . '_' . substr( md5( AUTH_KEY ), 0, 7 ) . '_wpdb'; | |
| 1864 | - $sql_filename = $wp_db_file_name . '.sql'; | |
| 1865 | - $filename = $wp_db_file_name . '.zip'; | |
| 1866 | - | |
| 1867 | - // Begin : Generate SQL DUMP using cmd 06-03-2016. | |
| 1868 | - $my_sql_dump = 0; | |
| 1869 | - if ( $this->get_mysqldump_command_path() ) { | |
| 1870 | - if ( ! $this->mysqldump( $path_info['basedir'] . '/db-backup/' . $sql_filename ) ) { | |
| 1871 | - $my_sql_dump = 1; | |
| 1872 | - } | |
| 1873 | - } else { | |
| 1874 | - $my_sql_dump = 1; | |
| 1875 | - } | |
| 1876 | - if ( 1 === (int) $my_sql_dump ) { | |
| 1877 | - $handle = fopen( $path_info['basedir'] . '/db-backup/' . $sql_filename, 'w+' ); // phpcs:ignore | |
| 1878 | - fwrite( $handle, $this->wp_db_backup_create_mysql_backup() ); // phpcs:ignore | |
| 1879 | - fclose( $handle ); // phpcs:ignore | |
| 1880 | - } | |
| 1881 | - /* End : Generate SQL DUMP using cmd 06-03-2016 */ | |
| 1882 | - | |
| 1883 | - $wp_db_backup_search_text = get_option( 'wp_db_backup_search_text' ); | |
| 1884 | - $wp_db_backup_replace_text = get_option( 'wp_db_backup_replace_text' ); | |
| 1885 | - if ( ( false === empty( $wp_db_backup_search_text ) ) && ( false === empty( $wp_db_backup_replace_text ) ) ) { | |
| 1886 | - $backup_str = file_get_contents( $path_info['basedir'] . '/db-backup/' . $sql_filename ); // phpcs:ignore | |
| 1887 | - $filecontent = wp_remote_get( $path_info['basedir'] . '/db-backup/' . $sql_filename ); | |
| 1888 | - $backup_str = str_replace( $wp_db_backup_search_text, $wp_db_backup_replace_text, $backup_str ); // phpcs:ignore | |
| 1889 | - file_put_contents( $path_info['basedir'] . '/db-backup/' . $sql_filename, $backup_str ); // phpcs:ignore | |
| 1890 | - } | |
| 1891 | - | |
| 1892 | - /* End : Generate SQL DUMP and save to file database.sql */ | |
| 1893 | - $upload_path = array( | |
| 1894 | - 'filename' => ( $filename ), | |
| 1895 | - 'dir' => ( $path_info['basedir'] . '/db-backup/' . $filename ), | |
| 1896 | - 'url' => ( $path_info['baseurl'] . '/db-backup/' . $filename ), | |
| 1897 | - 'size' => 0, | |
| 1898 | - ); | |
| 1899 | - $arcname = $path_info['basedir'] . '/db-backup/' . $wp_db_file_name . '.zip'; | |
| 1900 | - if ( class_exists( 'ZipArchive' ) ) { | |
| 1901 | - $zip = new ZipArchive(); | |
| 1902 | - $zip->open( $arcname, ZipArchive::CREATE ); | |
| 1903 | - $zip->addFile( $path_info['basedir'] . '/db-backup/' . $sql_filename, $sql_filename ); | |
| 1904 | - $zip->close(); | |
| 1905 | - } else { | |
| 1906 | - require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; | |
| 1907 | - $archive = new PclZip( $arcname ); | |
| 1908 | - $v_dir = $path_info['basedir'] . '/db-backup/' . $sql_filename; | |
| 1909 | - $v_remove = $path_info['basedir'] . '/db-backup'; | |
| 1910 | - // Create the archive. | |
| 1911 | - $v_list = $archive->create( $v_dir, PCLZIP_OPT_REMOVE_PATH, $v_remove ); | |
| 1912 | - } | |
| 1913 | - | |
| 1914 | - global $wpdb; | |
| 1915 | - $mysqlversion = wp_cache_get( 'wpdb_mysqlversion' ); | |
| 1916 | - if ( true === empty( $mysqlversion ) ) { | |
| 1917 | - $mysqlversion = $wpdb->get_var( 'SELECT VERSION() AS version' ); // phpcs:ignore | |
| 1918 | - wp_cache_set( 'wpdb_mysqlversion', $mysqlversion, '', 18000 ); | |
| 1919 | - } | |
| 1920 | - $my_theme = wp_get_theme(); | |
| 1921 | - $log_message = 'WordPress Version :' . get_bloginfo( 'version' ); | |
| 1922 | - $log_message .= ', Database Version :' . $mysqlversion; | |
| 1923 | - $log_message .= ', Active Theme Name :' . $my_theme->get( 'Name' ); | |
| 1924 | - $log_message .= ', Theme Version :' . $my_theme->get( 'Version' ); | |
| 1925 | - | |
| 1926 | - $upload_path['size'] = filesize( $upload_path['dir'] ); | |
| 1927 | - $upload_path['sqlfile'] = $path_info['basedir'] . '/db-backup/' . $sql_filename; | |
| 1928 | - $wp_db_log = get_option( 'wp_db_log' ); | |
| 1929 | - if ( 1 === (int) $wp_db_log ) { | |
| 1930 | - $wp_db_exclude_table = get_option( 'wp_db_exclude_table' ); | |
| 1931 | - if ( ! empty( $wp_db_exclude_table ) ) { | |
| 1932 | - $log_message .= '<br> Exclude Table : ' . implode( ', ', $wp_db_exclude_table ); | |
| 1933 | - } | |
| 1934 | - $upload_path['log'] = $log_message; | |
| 1935 | - } | |
| 1936 | - $options = get_option( 'wp_db_backup_backups' ); | |
| 1937 | - $newoptions = array(); | |
| 1938 | - $number_of_existing_backups = count( (array) $options ); | |
| 1939 | - $number_of_backups_from_user = get_option( 'wp_local_db_backup_count' ); | |
| 1940 | - if ( ! empty( $number_of_backups_from_user ) ) { | |
| 1941 | - if ( ! ( $number_of_existing_backups < $number_of_backups_from_user ) ) { | |
| 1942 | - $diff = $number_of_existing_backups - $number_of_backups_from_user; | |
| 1943 | - for ( $i = 0; $i <= $diff; $i++ ) { | |
| 1944 | - $index = $i; | |
| 1945 | - if ( file_exists( $options[ $index ]['dir'] ) ) { | |
| 1946 | - unlink( $options[ $index ]['dir'] ); | |
| 1947 | - } | |
| 1948 | - $file_sql = explode( '.', $options[ $index ]['dir'] ); | |
| 1949 | - if ( file_exists( $file_sql[0] . '.sql' ) ) { | |
| 1950 | - unlink( $file_sql[0] . '.sql' ); | |
| 1951 | - } | |
| 1952 | - } | |
| 1953 | - for ( $i = ( $diff + 1 ); $i < $number_of_existing_backups; $i++ ) { | |
| 1954 | - $index = $i; | |
| 1955 | - | |
| 1956 | - $newoptions[] = $options[ $index ]; | |
| 1957 | - } | |
| 1958 | - | |
| 1959 | - update_option( 'wp_db_backup_backups', $newoptions ); | |
| 1960 | - } | |
| 1961 | - } | |
| 1962 | - if ( file_exists( $path_info['basedir'] . '/db-backup/' . $sql_filename ) ) { | |
| 1963 | - unlink( $path_info['basedir'] . '/db-backup/' . $sql_filename ); | |
| 1964 | - } | |
| 1965 | - return $upload_path; | |
| 1966 | - } | |
| 1967 | - | |
| 1968 | - /** | |
| 1969 | - * Config Path. | |
| 1970 | - */ | |
| 1971 | - public function wp_db_backup_wp_config_path() { | |
| 1972 | - $base = dirname( __FILE__ ); | |
| 1973 | - $path = false; | |
| 1974 | - if ( file_exists( dirname( dirname( $base ) ) . '/wp-config.php' ) ) { | |
| 1975 | - $path = dirname( dirname( $base ) ); | |
| 1976 | - } else { | |
| 1977 | - if ( file_exists( dirname( dirname( dirname( $base ) ) ) . '/wp-config.php' ) ) { | |
| 1978 | - $path = dirname( dirname( dirname( $base ) ) ); | |
| 1979 | - } else { | |
| 1980 | - $path = false; | |
| 1981 | - } | |
| 1982 | - } | |
| 1983 | - if ( false !== $path ) { | |
| 1984 | - $path = str_replace( '\\', '/', $path ); | |
| 1985 | - } | |
| 1986 | - return $path; | |
| 1987 | - } | |
| 1988 | - | |
| 1989 | - /** | |
| 1990 | - * Backup Process. | |
| 1991 | - */ | |
| 1992 | - public function wp_db_backup_event_process() { | |
| 1993 | - // Added in v.3.9.5! | |
| 1994 | - set_time_limit( 0 ); | |
| 1995 | - | |
| 1996 | - $details = $this->wp_db_backup_create_archive(); | |
| 1997 | - $options = get_option( 'wp_db_backup_backups' ); | |
| 1998 | - | |
| 1999 | - if ( ! $options ) { | |
| 2000 | - $options = array(); | |
| 2001 | - } | |
| 2002 | - $is_search_replace_flag = 0; | |
| 2003 | - $wp_db_log = get_option( 'wp_db_log' ); | |
| 2004 | - if ( 1 === (int) $wp_db_log ) { | |
| 2005 | - $log_message = $details['log']; | |
| 2006 | - $wp_db_backup_search_text = get_option( 'wp_db_backup_search_text' ); | |
| 2007 | - $wp_db_backup_replace_text = get_option( 'wp_db_backup_replace_text' ); | |
| 2008 | - if ( ( false === empty( $wp_db_backup_search_text ) ) && ( false === empty( $wp_db_backup_replace_text ) ) ) { | |
| 2009 | - $log_message .= ' Replaced/Search text - ' . $wp_db_backup_search_text . ' With -' . $wp_db_backup_replace_text; | |
| 2010 | - $is_search_replace_flag = 1; | |
| 2011 | - } | |
| 2012 | - } else { | |
| 2013 | - $log_message = ''; | |
| 2014 | - } | |
| 2015 | - | |
| 2016 | - $options[] = array( | |
| 2017 | - 'date' => time(), | |
| 2018 | - 'filename' => $details['filename'], | |
| 2019 | - 'url' => $details['url'], | |
| 2020 | - 'dir' => $details['dir'], | |
| 2021 | - 'log' => $log_message, | |
| 2022 | - 'search_replace' => $is_search_replace_flag, | |
| 2023 | - 'sqlfile' => $details['sqlfile'], | |
| 2024 | - 'size' => $details['size'], | |
| 2025 | - ); | |
| 2026 | - $wp_db_remove_local_backup = get_option( 'wp_db_remove_local_backup' ); | |
| 2027 | - if ( 1 !== (int) $wp_db_remove_local_backup ) { | |
| 2028 | - update_option( 'wp_db_backup_backups', $options ); | |
| 2029 | - } | |
| 2030 | - $wp_db_remove_local_backup = get_option( 'wp_db_remove_local_backup' ); | |
| 2031 | - $destination = ( 1 === (int) $wp_db_remove_local_backup ) ? '' : 'Local, '; | |
| 2032 | - | |
| 2033 | - $args = array( $details['filename'], $details['dir'], $log_message, $details['size'], $destination ); | |
| 2034 | - do_action_ref_array( 'wp_db_backup_completed', array( &$args ) ); | |
| 2035 | - } | |
| 2036 | - | |
| 2037 | - /** | |
| 2038 | - * Cron schedule. | |
| 2039 | - * | |
| 2040 | - * @param array $schedules - Schedules details. | |
| 2041 | - */ | |
| 2042 | - public function wp_db_backup_cron_schedules( $schedules ) { | |
| 2043 | - $schedules['hourly'] = array( | |
| 2044 | - 'interval' => 3600, | |
| 2045 | - 'display' => 'hourly', | |
| 2046 | - ); | |
| 2047 | - $schedules['twicedaily'] = array( | |
| 2048 | - 'interval' => 43200, | |
| 2049 | - 'display' => 'twicedaily', | |
| 2050 | - ); | |
| 2051 | - $schedules['daily'] = array( | |
| 2052 | - 'interval' => 86400, | |
| 2053 | - 'display' => 'daily', | |
| 2054 | - ); | |
| 2055 | - $schedules['weekly'] = array( | |
| 2056 | - 'interval' => 604800, | |
| 2057 | - 'display' => 'Once Weekly', | |
| 2058 | - ); | |
| 2059 | - $schedules['monthly'] = array( | |
| 2060 | - 'interval' => 2635200, | |
| 2061 | - 'display' => 'Once a month', | |
| 2062 | - ); | |
| 2063 | - return $schedules; | |
| 2064 | - } | |
| 2065 | - | |
| 2066 | - /** | |
| 2067 | - * Schedular activation. | |
| 2068 | - */ | |
| 2069 | - public function wp_db_backup_scheduler_activation() { | |
| 2070 | - $options = get_option( 'wp_db_backup_options' ); | |
| 2071 | - if ( ( ! wp_next_scheduled( 'wp_db_backup_event' ) ) && ( true === isset( $options['enable_autobackups'] ) ) ) { | |
| 2072 | - wp_schedule_event( time(), $options['autobackup_frequency'], 'wp_db_backup_event' ); | |
| 2073 | - } | |
| 2074 | - } | |
| 2075 | - | |
| 2076 | - /** | |
| 2077 | - * Config data. | |
| 2078 | - * | |
| 2079 | - * @param string $key - key name. | |
| 2080 | - */ | |
| 2081 | - public function wp_backup_get_config_data( $key ) { | |
| 2082 | - $filepath = get_home_path() . '/wp-config.php'; | |
| 2083 | - $config_file = file_get_contents( "$filepath", true ); | |
| 2084 | - switch ( $key ) { | |
| 2085 | - case 'DB_NAME': | |
| 2086 | - preg_match( "/'DB_NAME',\s*'(.*)?'/", $config_file, $matches ); | |
| 2087 | - break; | |
| 2088 | - case 'DB_USER': | |
| 2089 | - preg_match( "/'DB_USER',\s*'(.*)?'/", $config_file, $matches ); | |
| 2090 | - break; | |
| 2091 | - case 'DB_PASSWORD': | |
| 2092 | - preg_match( "/'DB_PASSWORD',\s*'(.*)?'/", $config_file, $matches ); | |
| 2093 | - break; | |
| 2094 | - case 'DB_HOST': | |
| 2095 | - preg_match( "/'DB_HOST',\s*'(.*)?'/", $config_file, $matches ); | |
| 2096 | - break; | |
| 2097 | - } | |
| 2098 | - return $matches[1]; | |
| 2099 | - } | |
| 2100 | - | |
| 2101 | - /** | |
| 2102 | - * Get db name from config. | |
| 2103 | - */ | |
| 2104 | - public function wp_backup_get_config_db_name() { | |
| 2105 | - $filepath = get_home_path() . '/wp-config.php'; | |
| 2106 | - $config_file = file_get_contents( "$filepath", true ); | |
| 2107 | - preg_match( "/'DB_NAME',\s*'(.*)?'/", $config_file, $matches ); | |
| 2108 | - return $matches[1]; | |
| 2109 | - } | |
| 2110 | - | |
| 2111 | - /** | |
| 2112 | - * Recursive sanitation for an array | |
| 2113 | - * | |
| 2114 | - * @param array $array - Array data to sanitize. | |
| 2115 | - * | |
| 2116 | - * @return mixed | |
| 2117 | - */ | |
| 2118 | - public function recursive_sanitize_text_field( $array ) { | |
| 2119 | - foreach ( $array as $key => &$value ) { | |
| 2120 | - if ( is_array( $value ) ) { | |
| 2121 | - $value = $this->recursive_sanitize_text_field( $value ); | |
| 2122 | - } else { | |
| 2123 | - $value = sanitize_text_field( $value ); | |
| 2124 | - } | |
| 2125 | - } | |
| 2126 | - | |
| 2127 | - return $array; | |
| 2128 | - } | |
| 2129 | - | |
| 2130 | - /** | |
| 2131 | - * Enqueue scripts and style | |
| 2132 | - */ | |
| 2133 | - public function admin_scripts_style() { | |
| 2134 | - if ( true === $this->is_wpdb_page() ) { | |
| 2135 | - wp_enqueue_script( 'jquery' ); | |
| 2136 | - | |
| 2137 | - wp_register_script( 'bootstrapjs', WPDB_PLUGIN_URL . '/assets/js/bootstrap.min.js', array( 'jquery' ), WPDB_VERSION, true ); | |
| 2138 | - wp_enqueue_script( 'bootstrapjs' ); | |
| 2139 | - | |
| 2140 | - wp_register_style( 'bootstrapcss', WPDB_PLUGIN_URL . '/assets/css/bootstrap.min.css', array(), WPDB_VERSION ); | |
| 2141 | - wp_enqueue_style( 'bootstrapcss' ); | |
| 2142 | - | |
| 2143 | - wp_register_script( 'dataTables', WPDB_PLUGIN_URL . '/assets/js/jquery.dataTables.js', array( 'jquery' ), WPDB_VERSION, true ); | |
| 2144 | - wp_enqueue_script( 'dataTables' ); | |
| 2145 | - | |
| 2146 | - wp_register_style( 'dataTablescss', WPDB_PLUGIN_URL . '/assets/css/jquery.dataTables.css', array(), WPDB_VERSION ); | |
| 2147 | - wp_enqueue_style( 'dataTablescss' ); | |
| 2148 | - | |
| 2149 | - wp_register_style( 'wpdbcss', WPDB_PLUGIN_URL . '/assets/css/wpdb_admin.css', array(), WPDB_VERSION ); | |
| 2150 | - wp_enqueue_style( 'wpdbcss' ); | |
| 2151 | - } | |
| 2152 | - } | |
| 2153 | - | |
| 2154 | - /** | |
| 2155 | - * Check is plugin page. | |
| 2156 | - */ | |
| 2157 | - public function is_wpdb_page() { | |
| 2158 | - | |
| 2159 | - if ( is_admin() ) { | |
| 2160 | - | |
| 2161 | - return isset( $_REQUEST['page'] ) && preg_match( '/wp-database-backup/', $_REQUEST['page'] ) ? true : false; // phpcs:ignore | |
| 2162 | - | |
| 2163 | - } else { | |
| 2164 | - | |
| 2165 | - return true; | |
| 2166 | - } | |
| 2167 | - } | |
| 2168 | -} | |
| 2169 | - | |
| 2170 | -new Wpdb_Admin(); | |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Backup admin. | |
| 4 | + * | |
| 5 | + * @package wpdbbkp | |
| 6 | + */ | |
| 7 | +ob_start(); | |
| 8 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 9 | + exit; // Exit if accessed directly. | |
| 10 | +} | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * Main class wpdb_admin. | |
| 14 | + * | |
| 15 | + * @class Wpdb_Admin | |
| 16 | + */ | |
| 17 | +class Wpdb_Admin { | |
| 18 | + | |
| 19 | + public $mysqldump_command_path; | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * Construct. | |
| 23 | + */ | |
| 24 | + public function __construct() { | |
| 25 | + add_action( 'admin_init', array( $this, 'wp_db_backup_admin_init' ) ); | |
| 26 | + add_action( 'admin_init', array( $this, 'admin_scripts_style' ) ); | |
| 27 | + add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 ); | |
| 28 | + add_filter( 'cron_schedules', array( $this, 'wp_db_backup_cron_schedules' ) ); | |
| 29 | + add_action( 'wp_db_backup_event', array( $this, 'wp_db_backup_event_process' ) ); | |
| 30 | + add_action( 'init', array( $this, 'wp_db_backup_scheduler_activation' ) ); | |
| 31 | + add_action( 'wp_logout', array( $this, 'wp_db_cookie_expiration' ) ); // Fixed Vulnerability 22-06-2016 for prevent direct download. | |
| 32 | + add_action( 'wp_db_backup_completed', array( $this, 'wp_db_backup_completed_local' ), 12 ); | |
| 33 | + add_action('admin_enqueue_scripts', array( $this, 'wpdbbkp_admin_style')); | |
| 34 | + add_action('admin_enqueue_scripts', array( $this, 'wpdbbkp_admin_newsletter_script')); | |
| 35 | + add_action('wp_ajax_wpdbbkp_send_query_message', array( $this, 'wpdbbkp_send_query_message')); | |
| 36 | + add_filter( 'plugin_action_links_' . plugin_basename( WP_BACKUP_PLUGIN_FILE ), array( $this, 'add_settings_plugin_action_wp' ), 10, 4 ); | |
| 37 | + add_action( 'admin_notices', array($this, 'check_ziparchive_avalable_admin_notice' )); | |
| 38 | + | |
| 39 | + } | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * admin Notice. | |
| 43 | + */ | |
| 44 | + public function check_ziparchive_avalable_admin_notice() { | |
| 45 | + if (!class_exists( 'ZipArchive' ) ) { ?> | |
| 46 | + <div class="notice notice-info is-dismissible"><p><strong><?php echo esc_html__('Info!', 'wpdbbkp') ?></strong> <?php echo esc_html__(' Enable Zip Extension in php.ini to work BackupForWP all functionality smoothly.', 'wpdbbkp') ?> </p></div> | |
| 47 | + <?php } | |
| 48 | + } | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * Backup Menu. | |
| 52 | + */ | |
| 53 | + public function admin_menu() { | |
| 54 | + add_menu_page( | |
| 55 | + 'Backups', | |
| 56 | + 'Backups', | |
| 57 | + 'manage_options', | |
| 58 | + 'wp-database-backup', | |
| 59 | + array( $this, 'wp_db_backup_settings_page' ), | |
| 60 | + 'dashicons-database-view', | |
| 61 | + 99 | |
| 62 | + ); | |
| 63 | + | |
| 64 | + add_submenu_page( | |
| 65 | + 'wp-database-backup', | |
| 66 | + 'Auto Scheduler', | |
| 67 | + 'Auto Scheduler', | |
| 68 | + 'manage_options', | |
| 69 | + 'wp-database-backup#tab_db_schedul', | |
| 70 | + array($this, 'wp_db_backup_settings_page' )); | |
| 71 | + | |
| 72 | + add_submenu_page( | |
| 73 | + 'wp-database-backup', | |
| 74 | + 'Save Backups to', | |
| 75 | + 'Save Backups to', | |
| 76 | + 'manage_options', | |
| 77 | + 'wp-database-backup#tab_db_destination', | |
| 78 | + array($this, 'wp_db_backup_settings_page' )); | |
| 79 | + | |
| 80 | + add_submenu_page( | |
| 81 | + 'wp-database-backup', | |
| 82 | + 'Settings', | |
| 83 | + 'Settings', | |
| 84 | + 'manage_options', | |
| 85 | + 'wp-database-backup#tab_db_setting', | |
| 86 | + array($this, 'wp_db_backup_settings_page' )); | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + add_submenu_page( | |
| 91 | + 'wp-database-backup', | |
| 92 | + 'Help & Support', | |
| 93 | + 'Help & Support', | |
| 94 | + 'manage_options', | |
| 95 | + 'wp-database-backup#tab_db_help', | |
| 96 | + array($this, 'wp_db_backup_settings_page' )); | |
| 97 | + | |
| 98 | + if(!defined('BKPFORWP_VERSION')){ | |
| 99 | + add_submenu_page( | |
| 100 | + 'wp-database-backup', | |
| 101 | + 'Upgrade to Premium', | |
| 102 | + 'Upgrade to Premium', | |
| 103 | + 'manage_options', | |
| 104 | + 'wp-database-backup#tab_db_upgrade', | |
| 105 | + array($this, 'wp_db_backup_settings_page' )); | |
| 106 | + } | |
| 107 | + else{ | |
| 108 | + add_submenu_page( | |
| 109 | + 'wp-database-backup', | |
| 110 | + 'Modules', | |
| 111 | + 'Modules', | |
| 112 | + 'manage_options', | |
| 113 | + 'wp-database-backup#tab_db_features', | |
| 114 | + array($this, 'wp_db_backup_settings_page' )); | |
| 115 | + add_submenu_page( | |
| 116 | + 'wp-database-backup', | |
| 117 | + 'Licence', | |
| 118 | + 'Licence', | |
| 119 | + 'manage_options', | |
| 120 | + 'wp-database-backup#tab_db_licence', | |
| 121 | + array($this, 'wp_db_backup_settings_page' )); | |
| 122 | + } | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + } | |
| 127 | + | |
| 128 | + /** | |
| 129 | + * Start Fixed Vulnerability 22-06-2016 for prevent direct download. | |
| 130 | + */ | |
| 131 | + public function wp_db_cookie_expiration() { | |
| 132 | + setcookie( 'can_download', 0, time() - 300, COOKIEPATH, COOKIE_DOMAIN ); | |
| 133 | + if ( SITECOOKIEPATH !== COOKIEPATH ) { | |
| 134 | + setcookie( 'can_download', 0, time() - 300, SITECOOKIEPATH, COOKIE_DOMAIN ); | |
| 135 | + } | |
| 136 | + } | |
| 137 | + | |
| 138 | + /** | |
| 139 | + * If Checked then it will remove local backup after uploading to destination. | |
| 140 | + * | |
| 141 | + * @param array $args - backup details. | |
| 142 | + */ | |
| 143 | + public function wp_db_backup_completed_local( &$args ) { | |
| 144 | + $wp_db_remove_local_backup = get_option( 'wp_db_remove_local_backup' ); | |
| 145 | + if ( 1 === $wp_db_remove_local_backup ) { | |
| 146 | + if ( file_exists( $args[1] ) ) { | |
| 147 | + unlink( $args[1] );// File path. | |
| 148 | + } | |
| 149 | + } | |
| 150 | + } | |
| 151 | + | |
| 152 | + /** | |
| 153 | + * Admin init. | |
| 154 | + */ | |
| 155 | + public function wp_db_backup_admin_init() { | |
| 156 | + //redirect to plugin page on activation | |
| 157 | + if (get_option('wpdbbkp_activation_redirect', false)) { | |
| 158 | + delete_option('wpdbbkp_activation_redirect'); | |
| 159 | + if(!isset($_GET['activate-multi'])) | |
| 160 | + { | |
| 161 | + wp_redirect("admin.php?page=wp-database-backup"); | |
| 162 | + } | |
| 163 | + } | |
| 164 | + | |
| 165 | + // Start Fixed Vulnerability 04-08-2016 for data save in options. | |
| 166 | + if ( isset( $_GET['page'] ) && 'wp-database-backup' === $_GET['page'] ) { | |
| 167 | + if ( ! empty( $_POST ) && ! ( isset( $_POST['option_page'] ) && 'wp_db_backup_options' === $_POST['option_page'] ) ) { | |
| 168 | + if ( false === isset( $_REQUEST['_wpnonce'] ) || false === wp_verify_nonce( $_REQUEST['_wpnonce'] , 'wp-database-backup' ) ) { | |
| 169 | + wp_die( esc_html__('WPDB :: Invalid Access', 'wpdbbkp' ) ); | |
| 170 | + } | |
| 171 | + } | |
| 172 | + | |
| 173 | + // End Fixed Vulnerability 04-08-2016 for data save in options. | |
| 174 | + if ( isset( $_GET['page'] ) && 'wp-database-backup' === $_GET['page'] && current_user_can( 'manage_options' ) ) { | |
| 175 | + setcookie( 'can_download', 1, 0, COOKIEPATH, COOKIE_DOMAIN ); | |
| 176 | + if ( SITECOOKIEPATH !== COOKIEPATH ) { | |
| 177 | + setcookie( 'can_download', 1, 0, SITECOOKIEPATH, COOKIE_DOMAIN ); | |
| 178 | + } | |
| 179 | + } else { | |
| 180 | + setcookie( 'can_download', 0, time() - 300, COOKIEPATH, COOKIE_DOMAIN ); | |
| 181 | + if ( SITECOOKIEPATH !== COOKIEPATH ) { | |
| 182 | + setcookie( 'can_download', 0, time() - 300, SITECOOKIEPATH, COOKIE_DOMAIN ); | |
| 183 | + } | |
| 184 | + } | |
| 185 | + // End Fixed Vulnerability 22-06-2016 for prevent direct download. | |
| 186 | + if ( is_admin() && current_user_can( 'manage_options' ) ) { | |
| 187 | + if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'] , 'wp-database-backup' ) ) { | |
| 188 | + if ( isset( $_POST['wpsetting_search'] ) ) { | |
| 189 | + if ( isset( $_POST['wp_db_backup_search_text'] ) ) { | |
| 190 | + update_option( 'wp_db_backup_search_text', sanitize_text_field( wp_unslash( $_POST['wp_db_backup_search_text'] ) ), false ); | |
| 191 | + } | |
| 192 | + | |
| 193 | + $nonce = wp_create_nonce( 'wp-database-backup' ); | |
| 194 | + wp_safe_redirect( esc_url( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=save&tab=searchreplace&_wpnonce=' . $nonce ) ); | |
| 195 | + } | |
| 196 | + | |
| 197 | + if ( isset( $_POST['wpsetting'] ) ) { | |
| 198 | + if ( isset( $_POST['wp_local_db_backup_count'] ) ) { | |
| 199 | + update_option( 'wp_local_db_backup_count', wp_db_filter_data( sanitize_text_field( wp_unslash( $_POST['wp_local_db_backup_count'] ) ) ) , false); | |
| 200 | + } | |
| 201 | + | |
| 202 | + if ( isset( $_POST['wp_db_log'] ) ) { | |
| 203 | + update_option( 'wp_db_log', 1 , false); | |
| 204 | + } else { | |
| 205 | + update_option( 'wp_db_log', 0 , false); | |
| 206 | + } | |
| 207 | + if ( isset( $_POST['wp_db_remove_on_uninstall'] ) ) { | |
| 208 | + update_option( 'wp_db_remove_on_uninstall', 1 , false); | |
| 209 | + } else { | |
| 210 | + update_option( 'wp_db_remove_on_uninstall', 0 , false); | |
| 211 | + } | |
| 212 | + if ( isset( $_POST['wp_db_remove_local_backup'] ) ) { | |
| 213 | + update_option( 'wp_db_remove_local_backup', 1 , false); | |
| 214 | + } else { | |
| 215 | + update_option( 'wp_db_remove_local_backup', 0 , false); | |
| 216 | + } | |
| 217 | + if ( isset( $_POST['wp_db_backup_enable_auto_upgrade'] ) ) { | |
| 218 | + update_option( 'wp_db_backup_enable_auto_upgrade', 1 , false); | |
| 219 | + } else { | |
| 220 | + update_option( 'wp_db_backup_enable_auto_upgrade', 0 , false); | |
| 221 | + } | |
| 222 | + | |
| 223 | + if ( isset( $_POST['wp_db_backup_enable_htaccess'] ) ) { | |
| 224 | + update_option( 'wp_db_backup_enable_htaccess', 1 , false); | |
| 225 | + } else { | |
| 226 | + update_option( 'wp_db_backup_enable_htaccess', 0 , false); | |
| 227 | + $path_info = wp_upload_dir(); | |
| 228 | + if ( file_exists( $path_info['basedir'] . '/db-backup/.htaccess' ) ) { | |
| 229 | + unlink( $path_info['basedir'] . '/db-backup/.htaccess' ); | |
| 230 | + } | |
| 231 | + } | |
| 232 | + | |
| 233 | + if ( isset( $_POST['wp_db_exclude_table'] ) ) { | |
| 234 | + update_option( 'wp_db_exclude_table', $this->recursive_sanitize_text_field( wp_unslash( $_POST['wp_db_exclude_table'] ) ) , false); // phpcs:ignore | |
| 235 | + } else { | |
| 236 | + update_option( 'wp_db_exclude_table', '', false ); | |
| 237 | + } | |
| 238 | + $nonce = wp_create_nonce( 'wp-database-backup' ); | |
| 239 | + wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=save&_wpnonce=' . $nonce ); | |
| 240 | + } | |
| 241 | + | |
| 242 | + if ( true === isset( $_POST['wp_db_local_backup_path'] ) ) { | |
| 243 | + update_option( 'wp_db_local_backup_path', wp_db_filter_data( sanitize_text_field( wp_unslash( $_POST['wp_db_local_backup_path'] ) ) ) ); | |
| 244 | + } | |
| 245 | + | |
| 246 | + if ( isset( $_POST['wp_db_backup_email_id'] ) ) { | |
| 247 | + update_option( 'wp_db_backup_email_id', wp_db_filter_data( sanitize_email( wp_unslash( $_POST['wp_db_backup_email_id'] ) ) ) , false); | |
| 248 | + } | |
| 249 | + | |
| 250 | + if ( isset( $_POST['wp_db_backup_email_attachment'] ) ) { | |
| 251 | + $email_attachment = sanitize_text_field( wp_unslash( $_POST['wp_db_backup_email_attachment'] ) , false); | |
| 252 | + update_option( 'wp_db_backup_email_attachment', $email_attachment ); | |
| 253 | + } | |
| 254 | + if ( isset( $_POST['local_backup_submit'] ) && 'Save Settings' === $_POST['local_backup_submit'] ) { | |
| 255 | + if ( true === isset( $_POST['wp_db_local_backup'] ) ) { | |
| 256 | + update_option( 'wp_db_local_backup', 1 , false); | |
| 257 | + } else { | |
| 258 | + update_option( 'wp_db_local_backup', 0 , false); | |
| 259 | + } | |
| 260 | + } | |
| 261 | + | |
| 262 | + if ( isset( $_POST['wp_db_backup_options'] ) ) { | |
| 263 | + update_option( 'wp_db_backup_options', $_POST['wp_db_backup_options'], false); | |
| 264 | + } | |
| 265 | + | |
| 266 | + do_action('wpdbbkp_save_pro_options'); | |
| 267 | + } | |
| 268 | + $wp_db_backup_destination_email = get_option( 'wp_db_backup_destination_Email' , false); | |
| 269 | + | |
| 270 | + if ( isset( $_GET['page'] ) && 'wp-database-backup' === $_GET['page'] && isset( $_GET['action'] ) && 'unlink' === $_GET['action'] ) { | |
| 271 | + // Specify the target directory and add forward slash. | |
| 272 | + $dir = plugin_dir_path( __FILE__ ) . 'Destination/Dropbox/tokens/'; | |
| 273 | + | |
| 274 | + // Open the directory. | |
| 275 | + $dir_handle = opendir( $dir ); | |
| 276 | + // Loop over all of the files in the folder. | |
| 277 | + $file = readdir( $dir_handle ); | |
| 278 | + while ( $file ) { | |
| 279 | + // If $file is NOT a directory remove it. | |
| 280 | + if ( ! is_dir( $file ) ) { | |
| 281 | + unlink( $dir . $file ); | |
| 282 | + } | |
| 283 | + } | |
| 284 | + // Close the directory. | |
| 285 | + closedir( $dir_handle ); | |
| 286 | + wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup' ); | |
| 287 | + } | |
| 288 | + $nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : ''; | |
| 289 | + if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $nonce, 'wp-database-backup' ) ) { | |
| 290 | + if ( isset( $_GET['action'] ) && current_user_can( 'manage_options' ) ) { | |
| 291 | + switch ( (string) $_GET['action'] ) { | |
| 292 | + case 'createdbbackup': | |
| 293 | + $this->wp_db_backup_event_process(); | |
| 294 | + wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=create&_wpnonce=' . $nonce ); | |
| 295 | + break; | |
| 296 | + case 'removebackup': | |
| 297 | + if ( true === isset( $_GET['index'] ) ) { | |
| 298 | + $index = (int) $_GET['index']; | |
| 299 | + $options = get_option( 'wp_db_backup_backups' ); | |
| 300 | + $newoptions = array(); | |
| 301 | + $count = 0; | |
| 302 | + foreach ( $options as $option ) { | |
| 303 | + if ( $count !== $index ) { | |
| 304 | + $newoptions[] = $option; | |
| 305 | + } | |
| 306 | + $count++; | |
| 307 | + } | |
| 308 | + $upload_dir = wp_upload_dir(); | |
| 309 | + $actual_working_directory = getcwd(); | |
| 310 | + $file_directory = $upload_dir['basedir'].'/db-backup/'; | |
| 311 | + /* | |
| 312 | + Fix for when you try to delete a file thats in a folder | |
| 313 | + higher in the hierarchy to your working directory */ | |
| 314 | + chdir($file_directory); | |
| 315 | + if ( file_exists( $options[ $index ]['filename'] ) ) { | |
| 316 | + unlink( $options[ $index ]['filename'] ); | |
| 317 | + } | |
| 318 | + $file_sql = explode( '.', $options[ $index ]['filename'] ); | |
| 319 | + if ( file_exists( $file_sql[0] . '.sql' ) ) { | |
| 320 | + unlink( $file_sql[0] . '.sql' ); | |
| 321 | + } | |
| 322 | + chdir($actual_working_directory); | |
| 323 | + update_option( 'wp_db_backup_backups', $newoptions , false); | |
| 324 | + $nonce = wp_create_nonce( 'wp-database-backup' ); | |
| 325 | + wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=delete&_wpnonce=' . $nonce ); | |
| 326 | + exit; | |
| 327 | + | |
| 328 | + } | |
| 329 | + break; | |
| 330 | + case 'removeallbackup': | |
| 331 | + | |
| 332 | + $upload_dir = wp_upload_dir(); | |
| 333 | + $actual_working_directory = getcwd(); | |
| 334 | + $file_directory = $upload_dir['basedir']; | |
| 335 | + /* | |
| 336 | + Fix for when you try to delete a file thats in a folder | |
| 337 | + higher in the hierarchy to your working directory | |
| 338 | + */ | |
| 339 | + chdir($file_directory); | |
| 340 | + $files = glob($file_directory.'/db-backup'.'/*'); | |
| 341 | + | |
| 342 | + // Deleting all the files in the list | |
| 343 | + foreach($files as $file) { | |
| 344 | + if(is_file($file)){ | |
| 345 | + unlink($file); | |
| 346 | + } | |
| 347 | + } | |
| 348 | + chdir($actual_working_directory); | |
| 349 | + update_option( 'wp_db_backup_backups', array() , false); | |
| 350 | + $nonce = wp_create_nonce( 'wp-database-backup' ); | |
| 351 | + wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=deleteall&_wpnonce=' . $nonce ); | |
| 352 | + exit; | |
| 353 | + | |
| 354 | + | |
| 355 | + break; | |
| 356 | + case 'clear_temp_db_backup_file': | |
| 357 | + $options = get_option( 'wp_db_backup_backups' ); | |
| 358 | + $newoptions = array(); | |
| 359 | + $backup_check_list = array( '.htaccess', 'index.php' ); | |
| 360 | + $delete_message = 'WPDB : Deleted Files:'; | |
| 361 | + foreach ( $options as $option ) { | |
| 362 | + $backup_check_list[] = $option['filename']; | |
| 363 | + } | |
| 364 | + $path_info = wp_upload_dir(); | |
| 365 | + $wp_db_backup_path = $path_info['basedir'] . '/db-backup'; | |
| 366 | + | |
| 367 | + // Open a directory, and read its contents. | |
| 368 | + if ( is_dir( $wp_db_backup_path ) ) { | |
| 369 | + $dh = opendir( $wp_db_backup_path ); | |
| 370 | + if ( $dh ) { | |
| 371 | + while ( false !== ($file = readdir( $dh )) ) { | |
| 372 | + if ( ! ( in_array( $file, $backup_check_list, true ) ) ) { | |
| 373 | + if ( file_exists( $wp_db_backup_path . '/' . $file ) ) { | |
| 374 | + unlink( $wp_db_backup_path . '/' . $file ); | |
| 375 | + } | |
| 376 | + $delete_message .= ' ' . $file; | |
| 377 | + } | |
| 378 | + } | |
| 379 | + closedir( $dh ); | |
| 380 | + } | |
| 381 | + } | |
| 382 | + wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=clear_temp_db_backup_file&_wpnonce=' . $nonce ); | |
| 383 | + exit; | |
| 384 | + break; | |
| 385 | + case 'restorebackup': | |
| 386 | + $index = (int) $_GET['index']; | |
| 387 | + $options = get_option( 'wp_db_backup_backups' ); | |
| 388 | + $restore_limit = get_option( 'wp_db_restore_limit'); | |
| 389 | + $newoptions = array(); | |
| 390 | + $count = 0; | |
| 391 | + foreach ( $options as $option ) { | |
| 392 | + if ( $count !== $index ) { | |
| 393 | + $newoptions[] = $option; | |
| 394 | + } | |
| 395 | + $count++; | |
| 396 | + } | |
| 397 | + if ( isset( $options[ $index ]['restore_limit'] ) && $options[ $index ]['restore_limit']==1) { | |
| 398 | + include_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
| 399 | + if ( !is_plugin_active( 'wp-database-backup-pro/wp-database-backup-pro.php' ) ) { | |
| 400 | + wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=restore_limit&_wpnonce=' . $nonce ); | |
| 401 | + } | |
| 402 | + } | |
| 403 | + if(!empty($options[ $index ]['restore_limit'])){ | |
| 404 | + $options[ $index ]['restore_limit']=1; | |
| 405 | + } | |
| 406 | + | |
| 407 | + if ( isset( $options[ $index ]['sqlfile'] ) ) { // Added for extract zip file V.3.3.0. | |
| 408 | + $database_file = ( $options[ $index ]['sqlfile'] ); | |
| 409 | + } else { | |
| 410 | + $database_file = ( $options[ $index ]['dir'] ); | |
| 411 | + $file_sql = explode( '.', $options[ $index ]['dir'] ); | |
| 412 | + $database_file = ( $file_sql[0] . '.sql' ); | |
| 413 | + } | |
| 414 | + $database_name = $this->wp_backup_get_config_db_name(); | |
| 415 | + $database_user = $this->wp_backup_get_config_data( 'DB_USER' ); | |
| 416 | + $datadase_password = $this->wp_backup_get_config_data( 'DB_PASSWORD' ); | |
| 417 | + $database_host = $this->wp_backup_get_config_data( 'DB_HOST' ); | |
| 418 | + $path_info = wp_upload_dir(); | |
| 419 | + // Added for extract zip file V.3.3.0. | |
| 420 | + $ext_path_info = $path_info['basedir'] . '/db-backup'; | |
| 421 | + $database_zip_file = $options[ $index ]['dir']; | |
| 422 | + | |
| 423 | + if ( class_exists( 'ZipArchive' ) ) { | |
| 424 | + $zip = new ZipArchive(); | |
| 425 | + if ( $zip->open( $database_zip_file ) === true ) { | |
| 426 | + $zip->extractTo( $ext_path_info ); | |
| 427 | + $zip->close(); | |
| 428 | + } | |
| 429 | + } else { | |
| 430 | + require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; | |
| 431 | + $archive = new PclZip( $database_zip_file ); | |
| 432 | + $dir = $path_info['basedir'] . '/db-backup/'; | |
| 433 | + | |
| 434 | + if ( ! $archive->extract( PCLZIP_OPT_PATH, $dir ) ) { | |
| 435 | + wp_die( esc_html__('Unable to extract zip file. Please check that zlib php extension is enabled.','wpdbbkp').'<button onclick="history.go(-1);">'.esc_html__('Go Back','wpdbbkp').'</button>', esc_html__('ZIP Error','wpdbbkp') ); | |
| 436 | + } | |
| 437 | + } | |
| 438 | + | |
| 439 | + // End for extract zip file V.3.3.0. | |
| 440 | + set_time_limit( 0 ); | |
| 441 | + ignore_user_abort(true); | |
| 442 | + if ( '' !== ( trim( (string) $database_name ) ) && '' !== ( trim( (string) $database_user ) ) && '' !== ( trim( (string) $database_host ) ) ) { | |
| 443 | + $conn = mysqli_connect( (string) $database_host, (string) $database_user, (string) $datadase_password ); // phpcs:ignore | |
| 444 | + if ( $conn ) { | |
| 445 | + // Start Select the database. | |
| 446 | + if ( ! mysqli_select_db( $conn, (string) $database_name) ) { // phpcs:ignore | |
| 447 | + $sql = 'CREATE DATABASE IF NOT EXISTS `' . (string) $database_name . '`'; | |
| 448 | + mysqli_query($conn, $sql); // phpcs:ignore | |
| 449 | + mysqli_select_db($conn, (string) $database_name ); // phpcs:ignore | |
| 450 | + } | |
| 451 | + /* END: Select the Database */ | |
| 452 | + | |
| 453 | + /* BEGIN: Remove All Tables from the Database */ | |
| 454 | + $found_tables = null; | |
| 455 | + $result = mysqli_query( $conn, 'SHOW TABLES FROM `' . (string) $database_name . '`' ); // phpcs:ignore | |
| 456 | + | |
| 457 | + if ( $result ) { | |
| 458 | + while ($row = mysqli_fetch_row($result)) { | |
| 459 | + $found_tables[] = $row[0]; | |
| 460 | + } | |
| 461 | + | |
| 462 | + if ( count( $found_tables ) > 0 ) { | |
| 463 | + foreach ( $found_tables as $table_name ) { | |
| 464 | + mysqli_query( $conn, "DROP TABLE " . (string) $database_name . ".".$table_name ); // phpcs:ignore | |
| 465 | + } | |
| 466 | + } | |
| 467 | + } | |
| 468 | + | |
| 469 | + /* END: Remove All Tables from the Database */ | |
| 470 | + | |
| 471 | + /* BEGIN: Restore Database Content */ | |
| 472 | + if ( isset( $database_file ) ) { | |
| 473 | + if ( file_exists( $database_file ) ) { | |
| 474 | + $sql_file = file_get_contents( $database_file, true ); | |
| 475 | + if($sql_file){ | |
| 476 | + $sql_queries = explode( ";\n", $sql_file ); | |
| 477 | + $sql_queries_count = count( $sql_queries ); | |
| 478 | + | |
| 479 | + mysqli_query($conn, "SET sql_mode = ''"); | |
| 480 | + | |
| 481 | + for ( $i = 0; $i < $sql_queries_count; $i++ ) { | |
| 482 | + $sql_query_=apply_filters( 'wpdbbkp_sql_query_restore', $sql_queries[ $i ] ); | |
| 483 | + mysqli_query($conn, $sql_query_ ); // phpcs:ignore | |
| 484 | + } | |
| 485 | + } | |
| 486 | + | |
| 487 | + } | |
| 488 | + } | |
| 489 | + } | |
| 490 | + } | |
| 491 | + | |
| 492 | + if ( isset( $options[ $index ]['sqlfile'] ) && file_exists( $options[ $index ]['sqlfile'] ) ) { // Added for extract zip file V.3.3.0. | |
| 493 | + if ( file_exists( $options[ $index ]['sqlfile'] ) ) { | |
| 494 | + unlink( $options[ $index ]['sqlfile'] ); | |
| 495 | + } | |
| 496 | + } else { | |
| 497 | + $database_file = ( $options[ $index ]['dir'] ); | |
| 498 | + $file_sql = explode( '.', $options[ $index ]['dir'] ); | |
| 499 | + $database_file = ( $file_sql[0] . '.sql' ); | |
| 500 | + if ( file_exists( $database_file ) ) { | |
| 501 | + unlink( $database_file ); | |
| 502 | + } | |
| 503 | + } | |
| 504 | + wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=restore&_wpnonce=' . $nonce ); | |
| 505 | + exit; | |
| 506 | + break; | |
| 507 | + | |
| 508 | + case 'wpdbbkrestorefullbackup': | |
| 509 | + $index = (int) $_GET['index']; | |
| 510 | + require_once( 'class-restore.php' ); | |
| 511 | + $restore = new Wpbp_Restore(); | |
| 512 | + $restore->start($index); | |
| 513 | + if (get_option('wp_db_log') == 1) { | |
| 514 | + $options = get_option('wp_db_backup_backups'); | |
| 515 | + $path_info = wp_upload_dir(); | |
| 516 | + $logFileName = explode(".", $options[$index]['filename']); | |
| 517 | + $logfile = $path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/log/' . $logFileName[0] . '.txt'; | |
| 518 | + $message = "\n\n Restore Backup at " . date("Y-m-d h:i:sa"); | |
| 519 | + $this->write_log($logfile, $message); | |
| 520 | + } | |
| 521 | + $nonce = wp_create_nonce( 'wp-database-backup' ); | |
| 522 | + wp_safe_redirect( site_url() . '/wp-admin/admin.php?page=wp-database-backup¬ification=restore&_wpnonce=' . $nonce ); | |
| 523 | + exit; | |
| 524 | + break; | |
| 525 | + | |
| 526 | + /* END: Restore Database Content */ | |
| 527 | + } | |
| 528 | + } | |
| 529 | + } | |
| 530 | + } | |
| 531 | + } | |
| 532 | + | |
| 533 | + if ( is_admin() && current_user_can( 'manage_options' ) ) { | |
| 534 | + register_setting( 'wp_db_backup_options', 'wp_db_backup_options', array( $this, 'wp_db_backup_validate' ) ); | |
| 535 | + add_settings_section( 'wp_db_backup_main', 'WP-Database-Backup', array( $this, 'wp_db_backup_section_text' ), 'manage_options' ); | |
| 536 | + } | |
| 537 | + } | |
| 538 | + | |
| 539 | + /** | |
| 540 | + * Validate data. | |
| 541 | + * | |
| 542 | + * @param string $input - Input data. | |
| 543 | + */ | |
| 544 | + public function wp_db_backup_validate( $input ) { | |
| 545 | + return $input; | |
| 546 | + } | |
| 547 | + | |
| 548 | + /** | |
| 549 | + * Setting page. | |
| 550 | + */ | |
| 551 | + public function wp_db_backup_settings_page() { | |
| 552 | + | |
| 553 | + $options = get_option( 'wp_db_backup_backups' ); | |
| 554 | + $settings = get_option( 'wp_db_backup_options' ); | |
| 555 | + $wp_db_log = get_option( 'wp_db_log' ); ?> | |
| 556 | + <div class="bootstrap-wrapper"> | |
| 557 | + <?php | |
| 558 | + $wp_db_local_backup_path = get_option( 'wp_db_local_backup_path' ); | |
| 559 | + if ( false === empty( $wp_db_local_backup_path ) && false === file_exists( $wp_db_local_backup_path ) ) { | |
| 560 | + echo '<div class="alert alert-warning alert-dismissible fade in" role="alert"> | |
| 561 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> | |
| 562 | + <a href="#db_destination" data-toggle="tab">'; | |
| 563 | + esc_attr_e( 'Invalid Local Backup Path : ', 'wp-database-backup' ); | |
| 564 | + echo esc_attr( $wp_db_local_backup_path ); | |
| 565 | + echo '</a></div>'; | |
| 566 | + } | |
| 567 | + | |
| 568 | + $upload_dir = wp_upload_dir(); | |
| 569 | + $dir = $upload_dir['basedir'] . '/db-backup'; | |
| 570 | + if ( ! is_dir( $dir ) ) { | |
| 571 | + $dir = $upload_dir['basedir']; | |
| 572 | + } | |
| 573 | + if ( is_dir( $dir ) && ! is_writable( $dir ) ) { | |
| 574 | + ?> | |
| 575 | + <div class="row"> | |
| 576 | + <div class="col-xs-12 col-sm-12 col-md-12"> | |
| 577 | + <div class="alert alert-danger alert-dismissible fade in" role="alert"> | |
| 578 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
| 579 | + <span aria-hidden="true">×</span></button> | |
| 580 | + <h4>WP Database Backup</h4> | |
| 581 | + <p>Error: Permission denied, make sure you have write permission for <?php echo esc_attr( $dir ); ?> | |
| 582 | + folder</p> | |
| 583 | + </div> | |
| 584 | + </button> | |
| 585 | + </div> | |
| 586 | + </div> | |
| 587 | + <?php | |
| 588 | + } | |
| 589 | + ?> | |
| 590 | + | |
| 591 | + <div id="wpdbbkpModal" class="modal"> | |
| 592 | + <div class="wpdbbkpmodal-content"> | |
| 593 | + <div class="wpdbbkp-modal-header"> | |
| 594 | + <span class="wpdbbkp-close">×</span> | |
| 595 | + <h2><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> <span id="wpdbbkp-modal-header-title"></span></h2> | |
| 596 | + </div> | |
| 597 | + <div class="wpdbbkp-modal-body"> | |
| 598 | + <p id="wpdbbkp-modal-body-text"></p> | |
| 599 | + </div> | |
| 600 | + <div class="wpdbbkp-modal-footer"> | |
| 601 | + <a class="btn btn-primary" onclick="return confirm('Are you sure you want to restore backup?')" id="wpdbbkp-proceed-btn">Continue Anyway</a> <a class="btn btn-default wpdbbkp-close">Close</a> | |
| 602 | + </div> | |
| 603 | + </div> | |
| 604 | + </div> | |
| 605 | + | |
| 606 | + <div class="panel panel-default"> | |
| 607 | + <div class="panel-heading head-logo"> | |
| 608 | + <a href="https://backupforwp.com/" target="blank"><img | |
| 609 | + src="<?php echo esc_attr( WPDB_PLUGIN_URL ); ?>/assets/images/wp-database-backup.png" width="230px"></a> | |
| 610 | + </div> | |
| 611 | + <div class="panel-body"> | |
| 612 | + <ul class="nav nav-tabs wbdbbkp_has_nav"> | |
| 613 | + <li class="active"><a href="#db_home" data-toggle="tab"><?php echo esc_html__('Backups', 'wpdbbkp') ?></a></li> | |
| 614 | + <li><a href="#db_schedul" data-toggle="tab"><?php echo esc_html__('Auto Scheduler', 'wpdbbkp') ?></a></li> | |
| 615 | + <li><a href="#db_destination" data-toggle="tab"><?php echo esc_html__('Save Backups to', 'wpdbbkp') ?></a></li> | |
| 616 | + <li><a href="#db_setting" data-toggle="tab"><?php echo esc_html__('Settings', 'wpdbbkp') ?></a></li> | |
| 617 | + <li><a href="#searchreplace" data-toggle="tab"><?php echo esc_html__('Search and Replace', 'wpdbbkp') ?></a></li> | |
| 618 | + <li style="display:none"><a href="#db_upgrade" data-toggle="tab"><?php echo esc_html__('Upgrade', 'wpdbbkp') ?></a></li> | |
| 619 | + <?php do_action( 'wpdbbkp_pro_tab_links' ); ?> | |
| 620 | + <li><a href="#db_help" data-toggle="tab"><?php echo esc_html__('Help & Support', 'wpdbbkp') ?></a></li> | |
| 621 | + <li id="db_info_link" title="System Info"><a href="#db_info" data-toggle="tab"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a></li> | |
| 622 | + | |
| 623 | + </ul> | |
| 624 | + | |
| 625 | + <?php | |
| 626 | + echo '<div class="tab-content">'; | |
| 627 | + echo '<div class="tab-pane active" id="db_home">'; | |
| 628 | + | |
| 629 | + $nonce = wp_create_nonce( 'wp-database-backup' ); | |
| 630 | + $wp_db_backup_search_text = get_option( 'wp_db_backup_search_text' ); | |
| 631 | + $wp_db_backup_replace_text = get_option( 'wp_db_backup_replace_text' ); | |
| 632 | + if ( ( false === empty( $wp_db_backup_search_text ) ) && ( false === empty( $wp_db_backup_replace_text ) ) ) { | |
| 633 | + echo '<a href="' . esc_url( site_url() ) . '/wp-admin/admin.php?page=wp-database-backup&action=createdbbackup&_wpnonce=' . esc_attr( $nonce ) . '" id="create_backup" class="btn btn-primary"> <span class="glyphicon glyphicon-plus-sign"></span> '.esc_html__('Create Database Backup with Search/Replace', 'wpdbbkp').'</a>'; | |
| 634 | + echo '<p>Backup file will replace <b>' . esc_attr( $wp_db_backup_search_text ) . '</b> text with <b>' . esc_attr( $wp_db_backup_replace_text ) . '</b>. For Regular Database Backup without replace then Go to Dashboard=>Tool=>WP-DB Backup > Settings > '.esc_html__('Search and Replace - Set Blank Fields', 'wpdbbkp').' </p>'; | |
| 635 | + } else { | |
| 636 | + echo '<a href="' . esc_url( site_url() ) . '/wp-admin/admin.php?page=wp-database-backup&action=createdbbackup&_wpnonce=' . esc_attr( $nonce ) . '" id="create_backup" class="btn btn-primary"> <span class="glyphicon glyphicon-plus-sign"></span> '.esc_html__('Create Database Backup', 'wpdbbkp').'</a>'; | |
| 637 | + echo '<a href="#" id="wpdbbkp-create-full-backup" class="btn btn-primary"> <span class="glyphicon glyphicon-plus-sign"></span> '.esc_html__('Create Full Backup', 'wpdbbkp').'</a>'; | |
| 638 | + echo '<a href="#" id="wpdbbkp-stop-full-backup" class="btn btn-danger wpdbbkp-cancel-btn" style="display:none;margin-bottom: 20px;margin-left: 10px;" > <span class="glyphicon glyphicon-ban"></span> '.esc_html__('Stop Backup Process', 'wpdbbkp').'</a>'; | |
| 639 | + } | |
| 640 | + include_once 'admin-header-notification.php'; ?> | |
| 641 | + | |
| 642 | + <?php | |
| 643 | + if ( $options ) { | |
| 644 | + | |
| 645 | + echo ' <script> | |
| 646 | + var $j = jQuery.noConflict(); | |
| 647 | + $j(document).ready(function () { | |
| 648 | + | |
| 649 | + var table = $j("#wpdbbkp_table").DataTable({ | |
| 650 | + order: [[0, "desc"]], | |
| 651 | + }); | |
| 652 | + $j(".popoverid").popover(); | |
| 653 | + $j("#create_backup").click(function() { | |
| 654 | + $j(".wpdbbkp_notification").hide(); | |
| 655 | + $j("#backup_process").show(); | |
| 656 | + $j("#create_backup").attr("disabled", true); | |
| 657 | + | |
| 658 | + }); | |
| 659 | + }); | |
| 660 | + | |
| 661 | + function excludetableall(){ | |
| 662 | + var checkboxes = document.getElementsByClassName("wp_db_exclude_table"); | |
| 663 | + var checked = ""; | |
| 664 | + if($j("#wp_db_exclude_table_all").prop("checked") == true){ | |
| 665 | + checked = "checked"; | |
| 666 | + } | |
| 667 | + $j(".wp_db_exclude_table").each(function() { | |
| 668 | + this.checked = checked; | |
| 669 | + }); | |
| 670 | + } | |
| 671 | + | |
| 672 | + </script>'; | |
| 673 | + echo ' <div class="table-responsive"> | |
| 674 | + <div id="wpdbbkp_dataTables" class="dataTables_wrapper form-inline" role="grid"> | |
| 675 | + | |
| 676 | + <table class="table table-striped table-bordered table-hover display" id="wpdbbkp_table"> | |
| 677 | + <thead>'; | |
| 678 | + echo '<tr class="wpdb-header">'; | |
| 679 | + echo '<th class="manage-column" scope="col" width="5%" style="text-align: center;">#</th>'; | |
| 680 | + echo '<th class="manage-column" scope="col" width="25%">Date</th>'; | |
| 681 | + if($wp_db_log==1){ | |
| 682 | + echo '<th class="manage-column" scope="col" width="5%">Log</th>'; | |
| 683 | + } | |
| 684 | + echo '<th class="manage-column" scope="col" width="10%">Destination</th>'; | |
| 685 | + echo '<th class="manage-column" scope="col" width="15%">Type</th>'; | |
| 686 | + echo '<th class="manage-column" scope="col" width="10%">Backup File</th>'; | |
| 687 | + echo '<th class="manage-column" scope="col" width="10%">Size</th>'; | |
| 688 | + echo '<th class="manage-column" scope="col" width="20%">Action</th>'; | |
| 689 | + echo '</tr>'; | |
| 690 | + echo '</thead>'; | |
| 691 | + | |
| 692 | + echo '<tbody>'; | |
| 693 | + $count = 1; | |
| 694 | + $destination_icon = array( | |
| 695 | + 'Local' => 'glyphicon glyphicon-home', | |
| 696 | + 'Local Path' => 'glyphicon glyphicon-folder-open', | |
| 697 | + 'Email' => 'glyphicon glyphicon-envelope', | |
| 698 | + 'FTP' => 'glyphicon glyphicon-tasks', | |
| 699 | + 'SFTP' => 'glyphicon glyphicon-tasks', | |
| 700 | + 'S3' => 'glyphicon glyphicon-cloud-upload', | |
| 701 | + 'Drive' => 'glyphicon glyphicon-hdd', | |
| 702 | + 'DropBox' => 'glyphicon glyphicon-inbox', | |
| 703 | + 'Backblaze' => 'glyphicon glyphicon-cloud-upload', | |
| 704 | + ); | |
| 705 | + foreach ( $options as $option ) { | |
| 706 | + $str_class = ( 0 === (int) $option['size'] ) ? 'text-danger' : 'wpdb_download'; | |
| 707 | + echo '<tr class="' . ( ( 0 === ( $count % 2 ) ) ? esc_attr( $str_class ) . ' alternate' : esc_attr( $str_class ) ) . '">'; | |
| 708 | + echo '<td style="text-align: center;">' . esc_attr( $count ) . '</td>'; | |
| 709 | + $curr_date = new DateTime(date( 'Y-m-d H:i:s', $option['date'] )); | |
| 710 | + $curr_date->setTimezone(new DateTimeZone(wp_timezone_string())); | |
| 711 | + echo '<td><span style="display:none">' . esc_attr( $curr_date->format('Y-m-d H:i:s') ) . '</span><span title="'.esc_attr( $curr_date->format('jS, F Y h:i:s A') ) .'">' .$this->wpdbbkp_get_timeago($option['date']).'</span>'; | |
| 712 | + echo '</td>'; | |
| 713 | + if($wp_db_log==1){ | |
| 714 | + echo '<td class="wpdb_log" align="center">'; | |
| 715 | + if (!empty($option['log'])) { | |
| 716 | + if(isset($option['type']) && ($option['type'] == 'complete' || $option['type'] == 'database')){ | |
| 717 | + echo '<a href="' . $option['log'] . '" target="_blank" class="label label-warning" title="There might be partial backup. Please check Log File for verify backup.">'; | |
| 718 | + echo '<span class="glyphicon glyphicon-list-alt"></span>'; | |
| 719 | + echo '</a>'; | |
| 720 | + }else{ | |
| 721 | + echo '<a class="popoverid btn" role="button" data-toggle="popover" data-html="true" title="There might be partial backup. Please check Log file to verify backup." data-content="' . wp_kses_post( $option['log'] ) . '"><span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span></a>'; | |
| 722 | + } | |
| 723 | + } | |
| 724 | + echo '</td>'; | |
| 725 | + } | |
| 726 | + echo '<td>'; | |
| 727 | + if ( ! empty( $option['destination'] ) ) { | |
| 728 | + $destination = ( explode( ',', $option['destination'] ) ); | |
| 729 | + foreach ( $destination as $dest ) { | |
| 730 | + $key = trim( $dest ); | |
| 731 | + if ( ! empty( $dest ) && array_key_exists( $key, $destination_icon ) ) { | |
| 732 | + echo '<span class="' . esc_attr( $destination_icon[ $key ] ) . '" title="' . esc_attr( $dest ) . '"></span> '; | |
| 733 | + } | |
| 734 | + } | |
| 735 | + } | |
| 736 | + echo '</td>'; | |
| 737 | + if(isset($option['type']) && !empty($option['type'])){ | |
| 738 | + if($option['type'] == 'complete'){ | |
| 739 | + echo '<td>'.esc_html__('Full Backup', 'wpdbbkp').'</td>'; | |
| 740 | + } | |
| 741 | + if($option['type'] == 'database'){ | |
| 742 | + echo '<td>'.esc_html__('Database', 'wpdbbkp').'</td>'; | |
| 743 | + } | |
| 744 | + }else{ | |
| 745 | + echo '<td>Database</td>'; | |
| 746 | + } | |
| 747 | + echo '<td>'; | |
| 748 | + echo '<a class="btn btn-default" href="' . esc_url( $option['url'] ) . '" style="color: #21759B;border-color:#337ab7;">'; | |
| 749 | + echo '<span class="glyphicon glyphicon-download-alt"></span> Download</a></td>'; | |
| 750 | + echo '<td>' . esc_attr( $this->wp_db_backup_format_bytes( $option['size'] ) ) . '</td>'; | |
| 751 | + $remove_backup_href = esc_url( site_url() ) . '/wp-admin/admin.php?page=wp-database-backup&action=removebackup&_wpnonce=' . esc_attr( $nonce ) . '&index=' . esc_attr( ( $count - 1 ) ); | |
| 752 | + echo '<td><a title="Remove Database Backup" onclick="return confirm(\'Are you sure you want to delete database backup?\')" href="' . $remove_backup_href . '" class="btn btn-default"><span style="color:red" class="glyphicon glyphicon-trash"></span> Remove <a/> '; | |
| 753 | + if ( isset( $option['search_replace'] ) && 1 === (int) $option['search_replace'] ) { | |
| 754 | + echo '<span style="margin-left:15px" title="' . esc_html( $option['log'] ) . '" class="glyphicon glyphicon-search"></span>'; | |
| 755 | + } else { | |
| 756 | + $restore_url_href = esc_url( site_url() ) . '/wp-admin/admin.php?page=wp-database-backup&action=restorebackup&_wpnonce=' . esc_attr( $nonce ) . '&index=' . esc_attr( ( $count - 1 ) ); | |
| 757 | + if(isset($option['type']) && !empty($option['type'])){ | |
| 758 | + if($option['type'] == 'complete'){ | |
| 759 | + $restore_url_href = esc_url( site_url() ) . '/wp-admin/admin.php?page=wp-database-backup&action=wpdbbkrestorefullbackup&_wpnonce=' . esc_attr( $nonce ) . '&index=' . esc_attr( ( $count - 1 ) ); | |
| 760 | + } | |
| 761 | + | |
| 762 | + } | |
| 763 | + echo '<a title="Restore Database Backup" onclick="wpdbbkp_restore_backup(this);" href="javascript:void(0);" data-msg="Are you sure you want to restore database backup? It will overwrite all data /files with the respective backup and all recent changes would be lost. Are you sure you want to continue?" data-title="Restore Backup" data-href="'.$restore_url_href.'" class="btn btn-default"><span class="glyphicon glyphicon-refresh" style="color:blue"></span> Restore <a/>'; | |
| 764 | + } | |
| 765 | + echo '</td></tr>'; | |
| 766 | + $count++; | |
| 767 | + } | |
| 768 | + echo '</tbody>'; | |
| 769 | + | |
| 770 | + echo ' </table> | |
| 771 | + </div> | |
| 772 | + </div>'; | |
| 773 | + } else { | |
| 774 | + echo '<p>No Database Backups Created!</p>'; | |
| 775 | + } | |
| 776 | + | |
| 777 | + echo '<p>If you like <b>WP Database Backup</b> please leave us a <a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/wp-database-backup" title="Rating" sl-processed="1"> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> <span class="glyphicon glyphicon-star" aria-hidden="true"></span> rating </a>. Many thanks in advance!</p>'; | |
| 778 | + echo '</div>'; | |
| 779 | + | |
| 780 | + echo '<div class="tab-pane" id="db_schedul">'; | |
| 781 | + echo '<div class="panel-group">'; | |
| 782 | + echo '<form method="post" action="" name="wp_auto_commenter_form">'; | |
| 783 | + wp_nonce_field( 'wp-database-backup' ); | |
| 784 | + $enable_autobackups = '0'; | |
| 785 | + if ( isset( $settings['enable_autobackups'] ) ) { | |
| 786 | + $enable_autobackups = $settings['enable_autobackups']; | |
| 787 | + } | |
| 788 | + | |
| 789 | + $autobackup_frequency = '0'; | |
| 790 | + if ( isset( $settings['autobackup_frequency'] ) ) { | |
| 791 | + $autobackup_frequency = $settings['autobackup_frequency']; | |
| 792 | + } | |
| 793 | + $full_autobackup_frequency = 'disabled'; | |
| 794 | + if ( isset( $settings['full_autobackup_frequency'] ) ) { | |
| 795 | + $full_autobackup_frequency = $settings['full_autobackup_frequency']; | |
| 796 | + } | |
| 797 | + $autobackup_type = ''; | |
| 798 | + if ( isset( $settings['autobackup_type'] ) ) { | |
| 799 | + $autobackup_type = $settings['autobackup_type']; | |
| 800 | + } | |
| 801 | + | |
| 802 | + echo '<div class="row form-group"><label class="col-sm-3" for="enable_autobackups">Enable Auto Backups</label>'; | |
| 803 | + echo '<div class="col-sm-9"><input type="checkbox" id="enable_autobackups" name="wp_db_backup_options[enable_autobackups]" value="1" ' . checked( 1, $enable_autobackups, false ) . '/>'; | |
| 804 | + echo '<div class="alert alert-default" role="alert"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> AutoBackups will be based on Wordpress Cron so it can have execution delay of +/- 30 mins . If you have disabled Wordpress Cron then autobackup will not work until you have set Server Cron for wordpress.</div>'; | |
| 805 | + echo '</div>'; | |
| 806 | + echo '</div>'; | |
| 807 | + | |
| 808 | + echo '<div class="row form-group autobackup_type" style="display:none"><label class="col-sm-3" for="autobackup_frequency">Which part should we backup for you ?</label>'; | |
| 809 | + echo '<div class="col-sm-9"><select id="autobackup_type" class="form-control" name="wp_db_backup_options[autobackup_type]">'; | |
| 810 | + echo '<option value="">Select Backup Type</option>'; | |
| 811 | + echo '<option value="full" ' . selected( 'full', $autobackup_type, false ) . '>Full(Files + DB)</option>'; | |
| 812 | + echo '<option value="files" ' . selected( 'files', $autobackup_type, false ) . '>Files Only</option>'; | |
| 813 | + echo '<option value="db" ' . selected( 'db', $autobackup_type, false ) . '>Database Only</option>'; | |
| 814 | + echo '</select>'; | |
| 815 | + echo '</div></div>'; | |
| 816 | + | |
| 817 | + echo '<div class="row form-group autobackup_frequency" style="display:none"><label class="col-sm-3" for="autobackup_frequency">How often should we run Automatically?</label>'; | |
| 818 | + echo '<div class="col-sm-9"><select id="autobackup_frequency" class="form-control" name="wp_db_backup_options[autobackup_frequency]">'; | |
| 819 | + echo '<option value="daily" ' . selected( 'daily', $autobackup_frequency, false ) . '>Daily</option>'; | |
| 820 | + echo '<option value="weekly" ' . selected( 'weekly', $autobackup_frequency, false ) . '>Weekly</option>'; | |
| 821 | + echo '<option value="monthly" ' . selected( 'monthly', $autobackup_frequency, false ) . '>Monthly</option>'; | |
| 822 | + echo '</select>'; | |
| 823 | + echo '</div></div>'; | |
| 824 | + | |
| 825 | + echo '<div class="row form-group autobackup_frequency_lite" style="display:none"><label class="col-sm-12 autobackup_daily_lite" >We will automatically backup at 00:00 AM daily. <b><a href="javascript:modify_backup_frequency();">Change Back Frequency Timings</a></b></label></div>'; | |
| 826 | + echo '<div class="row form-group autobackup_frequency_lite" style="display:none"><label class="col-sm-12 autobackup_weekly_lite" >We will automatically backup every Sunday on weekly basis. <b><a href="javascript:modify_backup_frequency();">Change Back Frequency Timings</a></b></label></div>'; | |
| 827 | + echo '<div class="row form-group autobackup_frequency_lite" style="display:none"><label class="col-sm-12 autobackup_monthly_lite" >We will automatically backup on 1st on Monday on monthly basis. <b><a href="javascript:modify_backup_frequency();">Change Back Frequency Timings</a></b></label></div>'; | |
| 828 | + | |
| 829 | + do_action('wpdbbkp_database_backup_options'); | |
| 830 | + echo '<p class="submit">'; | |
| 831 | + echo '<input type="submit" name="Submit" class="btn btn-primary" value="Save Settings" />'; | |
| 832 | + echo '</p>'; | |
| 833 | + echo '</form>'; | |
| 834 | + echo '</div>'; | |
| 835 | + echo '</div>'; | |
| 836 | + | |
| 837 | + do_action('wpdbbkp_pro_tab_content'); | |
| 838 | + | |
| 839 | + ?> | |
| 840 | + | |
| 841 | + <div class="tab-pane" id="db_upgrade"> | |
| 842 | + <div class="panel-group "> | |
| 843 | + <div class="gn-flex-container row"> | |
| 844 | + <div class=" col-md-12"> | |
| 845 | + <div class="wpdbbkp-wrapper"> | |
| 846 | + <div class="wpdbbkp-wr"> | |
| 847 | + <div class="bkp-wpdbbkp-img"> | |
| 848 | + <span class="sp_ov"></span> | |
| 849 | + </div> | |
| 850 | + <div class="bkp-wpdbbkp-cnt"> | |
| 851 | + <h1><?php esc_html_e('UPGRADE to PRO Version','wpdbbkp');?></h1> | |
| 852 | + <a class="buy" href="https://backupforwp.com/pricing/#pricings" target="_blank">Purchase Now</a> | |
| 853 | + </div> | |
| 854 | + <div class="pvf"> | |
| 855 | + <div class="pvf-cnt"> | |
| 856 | + <div class="pvf-tlt"> | |
| 857 | + <h2><?php esc_html_e('Compare Pro vs. Free Version','wpdbbkp');?></h2> | |
| 858 | + <span><?php esc_html_e('See what you\'ll get with the professional version','wpdbbkp');?></span> | |
| 859 | + </div> | |
| 860 | + <div class="pvf-cmp"> | |
| 861 | + <div class="fr"> | |
| 862 | + <h1><?php esc_html_e('FREE','wpdbbkp');?></h1> | |
| 863 | + <div class="fr-fe"> | |
| 864 | + <div class="fe-1"> | |
| 865 | + <h4><?php esc_html_e('Continious Development','wpdbbkp');?></h4> | |
| 866 | + <p><?php esc_html_e('We take bug reports and feature requests seriously. We\'re continiously developing & improve this product for last 2 years with passion and love.','wpdbbkp');?></p> | |
| 867 | + </div> | |
| 868 | + <div class="fe-1"> | |
| 869 | + <h4><?php esc_html_e('10+ Features','wpdbbkp');?></h4> | |
| 870 | + <p><?php esc_html_e('We\'re constantly expanding the plugin and make it more useful. We have wide variety of features which will fit any use-case.','wpdbbkp');?></p> | |
| 871 | + </div> | |
| 872 | + </div><!-- /. fr-fe --> | |
| 873 | + </div><!-- /. fr --> | |
| 874 | + <div class="pr"> | |
| 875 | + <h1>PRO</h1> | |
| 876 | + <div class="pr-fe"> | |
| 877 | + <span><?php esc_html_e('Everything in Free, and:','wpdbbkp');?></span> | |
| 878 | + <div class="fet"> | |
| 879 | + <div class="fe-2"> | |
| 880 | + <div class="fe-t"> | |
| 881 | + <img src="<?php echo WPDB_PLUGIN_URL;?>/assets/images/right-tick.png" alt="right-tick"> | |
| 882 | + <h4><?php esc_html_e('Anonymization Function','wpdbbkp');?></h4> | |
| 883 | + </div> | |
| 884 | + <p><?php esc_html_e('Anonymization you critical data during backup with three methods','wpdbbkp');?> </p> | |
| 885 | + </div> | |
| 886 | + <div class="fe-2"> | |
| 887 | + <div class="fe-t"> | |
| 888 | + <img src="<?php echo WPDB_PLUGIN_URL;?>/assets/images/right-tick.png" alt="right-tick"> | |
| 889 | + <h4><?php esc_html_e('Pre-update backups','wpdbbkp');?></h4> | |
| 890 | + </div> | |
| 891 | + <p> <?php esc_html_e('Automatically backs up your website before any updates to plugins, themes and WordPress core.','wpdbbkp');?></p> | |
| 892 | + </div> | |
| 893 | + | |
| 894 | + <div class="fe-2"> | |
| 895 | + <div class="fe-t"> | |
| 896 | + <img src="<?php echo WPDB_PLUGIN_URL;?>/assets/images/right-tick.png" alt="right-tick"> | |
| 897 | + <h4><?php esc_html_e('Backup time and scheduling','wpdbbkp'); ?></h4> | |
| 898 | + </div> | |
| 899 | + <p><?php esc_html_e('Set exact times to create or delete backups.','wpdbbkp');?></p> | |
| 900 | + </div> | |
| 901 | + | |
| 902 | + | |
| 903 | + <div class="fe-2"> | |
| 904 | + <div class="fe-t"> | |
| 905 | + <img src="<?php echo WPDB_PLUGIN_URL;?>/assets/images/right-tick.png" alt="right-tick"> | |
| 906 | + <h4><?php esc_html_e('Fast, personal support','wpdbbkp'); ?></h4> | |
| 907 | + </div> | |
| 908 | + <p><?php esc_html_e('Provides expert help and support from the developers whenever you need it.','wpdbbkp'); ?></p> | |
| 909 | + </div> | |
| 910 | + <div class="fe-2"> | |
| 911 | + <div class="fe-t"> | |
| 912 | + <img src="<?php echo WPDB_PLUGIN_URL;?>/assets/images/right-tick.png" alt="right-tick"> | |
| 913 | + <h4><?php esc_html_e('Continuous Updates','wpdbbkp'); ?></h4> | |
| 914 | + </div> | |
| 915 | + <p><?php esc_html_e('We\'re continuously updating our premium features and releasing them.','wpdbbkp'); ?></p> | |
| 916 | + </div> | |
| 917 | + <div class="fe-2"> | |
| 918 | + <div class="fe-t"> | |
| 919 | + <img src="<?php echo WPDB_PLUGIN_URL;?>/assets/images/right-tick.png" alt="right-tick"> | |
| 920 | + <h4><?php esc_html_e('Documentation','wpdbbkp'); ?></h4> | |
| 921 | + </div> | |
| 922 | + <p><?php esc_html_e('We create tutorials for every possible feature and keep it updated for you.','wpdbbkp'); ?></p> | |
| 923 | + </div> | |
| 924 | + </div><!-- /. fet --> | |
| 925 | + <div class="pr-btn"> | |
| 926 | + <a href="https://backupforwp.com/pricing/#pricings" target="_blank"><?php esc_html_e('Upgrade to Pro','wpdbbkp'); ?></a> | |
| 927 | + </div><!-- /. pr-btn --> | |
| 928 | + </div><!-- /. pr-fe --> | |
| 929 | + </div><!-- /.pr --> | |
| 930 | + </div><!-- /. pvf-cmp --> | |
| 931 | + </div><!-- /. pvf-cnt --> | |
| 932 | + | |
| 933 | + <div class="wpdbbkpfaq"> | |
| 934 | + <h2><?php esc_html_e('Frequently Asked Questions','wpdbbkp'); ?></h2> | |
| 935 | + <div class="faq-lst"> | |
| 936 | + <div class="lt"> | |
| 937 | + <ul> | |
| 938 | + <li> | |
| 939 | + <span><?php esc_html_e('Is there a setup fee?','wpdbbkp'); ?></span> | |
| 940 | + <p><?php esc_html_e('No. There are no setup fees on any of our plans','wpdbbkp'); ?></p> | |
| 941 | + </li> | |
| 942 | + <li> | |
| 943 | + <span><?php esc_html_e('What\'s the time span for your contracts?','wpdbbkp'); ?></span> | |
| 944 | + <p><?php esc_html_e('All the plans are year-to-year which are subscribed annually except for lifetime plan.','wpdbbkp'); ?></p> | |
| 945 | + </li> | |
| 946 | + <li> | |
| 947 | + <span><?php esc_html_e('What payment methods are accepted?','wpdbbkp'); ?></span> | |
| 948 | + <p><?php esc_html_e('We accepts PayPal and Credit Card payments.','wpdbbkp'); ?></p> | |
| 949 | + </li> | |
| 950 | + <li> | |
| 951 | + <span><?php esc_html_e('Do you offer support if I need help?','wpdbbkp'); ?></span> | |
| 952 | + <p><?php esc_html_e('Yes! Top-notch customer support for our paid customers is key for a quality product, so we\'ll do our very best to resolve any issues you encounter via our support page.','wpdbbkp'); ?></p> | |
| 953 | + </li> | |
| 954 | + <li> | |
| 955 | + <span><?php esc_html_e('Can I use the plugins after my subscription is expired?','wpdbbkp'); ?></span> | |
| 956 | + <p><?php esc_html_e('Yes, you can use the plugins, but you will not get future updates for those plugins.','wpdbbkp'); ?></p> | |
| 957 | + </li> | |
| 958 | + </ul> | |
| 959 | + </div> | |
| 960 | + <div class="rt"> | |
| 961 | + <ul> | |
| 962 | + <li> | |
| 963 | + <span><?php esc_html_e('Can I cancel my membership at any time?','wpdbbkp'); ?></span> | |
| 964 | + <p><?php esc_html_e('Yes. You can cancel your membership by contacting us.','wpdbbkp'); ?></p> | |
| 965 | + </li> | |
| 966 | + <li> | |
| 967 | + <span><?php esc_html_e('Can I change my plan later on?','wpdbbkp'); ?></span> | |
| 968 | + <p><?php esc_html_e('Yes. You can upgrade your plan by contacting us.','wpdbbkp'); ?></p> | |
| 969 | + </li> | |
| 970 | + <li> | |
| 971 | + <span><?php esc_html_e('Do you offer refunds?','wpdbbkp'); ?></span> | |
| 972 | + <p><?php esc_html_e('You are fully protected by our 100% Money-Back Guarantee Unconditional. If during the next 14 days you experience an issue that makes the plugin unusable, and we are unable to resolve it, we\'ll happily offer a full refund.','wpdbbkp'); ?></p> | |
| 973 | + </li> | |
| 974 | + <li> | |
| 975 | + <span><?php esc_html_e('Do I get updates for the premium plugin?','wpdbbkp'); ?></span> | |
| 976 | + <p><?php esc_html_e('Yes, you will get updates for all the premium plugins until your subscription is active.','wpdbbkp'); ?></p> | |
| 977 | + </li> | |
| 978 | + </ul> | |
| 979 | + </div> | |
| 980 | + </div><!-- /.faq-lst --> | |
| 981 | + </div><!-- /.faq --> | |
| 982 | + </div><!-- /. pvf --> | |
| 983 | + </div> | |
| 984 | + </div> | |
| 985 | + | |
| 986 | + </div> | |
| 987 | + </div> | |
| 988 | + </div> | |
| 989 | + </div> | |
| 990 | + | |
| 991 | + | |
| 992 | + <div class="tab-pane" id="db_help"> | |
| 993 | + <div class="panel-group "> | |
| 994 | + <div class="gn-flex-container row"> | |
| 995 | + <div class="wpdbbkp-left-side col-md-8"> | |
| 996 | + <p> <?php echo esc_html__('We are dedicated to provide Technical support & Help to our users. Use the below form for sending your questions. ', 'wpdbbkp') ?> </p> | |
| 997 | + <div class="wpdbbkp_support_div_form" id="technical-form"> | |
| 998 | + <ul> | |
| 999 | + <li> | |
| 1000 | + <label class="wpdbbkp-support-label"> <?php echo esc_html__('Email', 'wpdbbkp') ?> <span class="wpdbbkp-star-mark">*</span> | |
| 1001 | + </label> | |
| 1002 | + <div class="support-input"> | |
| 1003 | + <input type="text" id="wpdbbkp_query_email" name="wpdbbkp_query_email" size="47" placeholder="Enter your Email" required=""> | |
| 1004 | + </div> | |
| 1005 | + </li> | |
| 1006 | + <li> | |
| 1007 | + <label class="wpdbbkp-support-label"> <?php echo esc_html__('Query', 'wpdbbkp') ?> <span class="wpdbbkp-star-mark">*</span> | |
| 1008 | + </label> | |
| 1009 | + <div class="support-input"> | |
| 1010 | + <textarea rows="5" cols="50" id="wpdbbkp_query_message" name="wpdbbkp_query_message" placeholder="Write your query"></textarea> | |
| 1011 | + </div> | |
| 1012 | + </li> | |
| 1013 | + <li> | |
| 1014 | + <button class="button button-primary wpdbbkp-send-query"> <?php echo esc_html__('Send Support Request', 'wpdbbkp') ?> </button> | |
| 1015 | + </li> | |
| 1016 | + </ul> | |
| 1017 | + <div class="clear"></div> | |
| 1018 | + <span class="wpdbbkp-query-success wpdbbkp-result wpdbbkp-hide"> <?php echo esc_html__('Message sent successfully, Please wait we will get back to you shortly', 'wpdbbkp') ?> </span> | |
| 1019 | + <span class="wpdbbkp-query-error wpdbbkp-result wpdbbkp-hide"> <?php echo esc_html__('Message not sent. please check your network connection', 'wpdbbkp') ?> </span> | |
| 1020 | + </div> | |
| 1021 | + </div> | |
| 1022 | + <div class="wpdbbkp-right-side col-md-4"> | |
| 1023 | + <div class="wpdbbkp-bio-box" id="wpdbbkp_Bio"> | |
| 1024 | + <h3><?php echo esc_html__('Vision & Mission', 'wpdbbkp') ?></h3> | |
| 1025 | + <p class="wpdbbkp-p"><?php echo esc_html__('We strive to provide the best Backup Plugin in the world.', 'wpdbbkp') ?></p> | |
| 1026 | + <p class="wpdbbkp_boxdesk"> <?php echo esc_html__(' Delivering a good user experience means a lot to us, so we try our best to reply each and every question.', 'wpdbbkp') ?></p> | |
| 1027 | + </div> | |
| 1028 | + </div> | |
| 1029 | + </div> | |
| 1030 | + </div> | |
| 1031 | + </div> | |
| 1032 | + | |
| 1033 | + <div class="tab-pane" id="db_info"> | |
| 1034 | + | |
| 1035 | + <div class="panel panel-group panel-default"> | |
| 1036 | + <div class="panel-heading"> | |
| 1037 | + <a class="toggle_anchor" data-toggle="collapse" data-parent="#accordion" href="#collapsedb"> | |
| 1038 | + <h4 class="panel-title"> | |
| 1039 | + <?php esc_attr_e( 'System Check', 'wpdbbk' ); ?> | |
| 1040 | + </h4> | |
| 1041 | + </a> | |
| 1042 | + </div> | |
| 1043 | + <div id="collapsedb" class="panel-collapse collapse in"> | |
| 1044 | + <div class="panel-body list-group"> | |
| 1045 | + | |
| 1046 | + <div class="row list-group-item"> | |
| 1047 | + <?php | |
| 1048 | + if(function_exists('disk_free_space')){ | |
| 1049 | + /* get disk space free (in bytes) */ | |
| 1050 | + $df = disk_free_space( WPDB_ROOTPATH ); | |
| 1051 | + /* and get disk space total (in bytes) */ | |
| 1052 | + $dt = disk_total_space( WPDB_ROOTPATH ); | |
| 1053 | + /* now we calculate the disk space used (in bytes) */ | |
| 1054 | + $du = $dt - $df; | |
| 1055 | + /* percentage of disk used - this will be used to also set the width % of the progress bar */ | |
| 1056 | + $dp = sprintf( '%.2f', ( $du / $dt ) * 100 ); | |
| 1057 | + $dp = isset( $dp )? $dp : 'NA'; | |
| 1058 | + /* and we formate the size from bytes to MB, GB, etc. */ | |
| 1059 | + $df = $this->wp_db_backup_format_bytes( $df ); | |
| 1060 | + $du = $this->wp_db_backup_format_bytes( $du ); | |
| 1061 | + $dt = $this->wp_db_backup_format_bytes( $dt ); | |
| 1062 | + } | |
| 1063 | + $du=$dp=$df=$dt='NA'; | |
| 1064 | + ?> | |
| 1065 | + <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 1066 | + class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 1067 | + </div> | |
| 1068 | + <div class="col-md-3">Disk Space</div> | |
| 1069 | + <div class="col-md-5"> | |
| 1070 | + <div class="progress"> | |
| 1071 | + <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="<?php echo esc_attr( trim( $dp ) ); ?>" aria-valuemin="0" aria-valuemax="100" style="width:<?php echo esc_attr( trim( $dp ) ); ?>%"> <?php echo esc_attr( $dp ); ?>% | |
| 1072 | + </div> | |
| 1073 | + </div> | |
| 1074 | + </div> | |
| 1075 | + <div class="col-md-1"></div> | |
| 1076 | + <div class="col-md-4"></div> | |
| 1077 | + <div class="col-md-5"> | |
| 1078 | + <div class='prginfo'> | |
| 1079 | + <p><?php echo esc_attr( $du ) . ' of ' . esc_attr( $dt ) . ' used '; ?></p> | |
| 1080 | + <p><?php echo esc_attr( $df ) . ' of ' . esc_attr( $dt ) . ' free '; ?></p> | |
| 1081 | + <p> | |
| 1082 | + <small> | |
| 1083 | + <?php esc_attr_e( 'Note: This value is the physical servers hard-drive allocation.', 'wpdbbkp' ); ?> | |
| 1084 | + <br/> | |
| 1085 | + <?php esc_attr_e( "On shared hosts check your control panel for the 'TRUE' disk space quota value.", 'wpdbbkp' ); ?> | |
| 1086 | + </small> | |
| 1087 | + </p> | |
| 1088 | + </div> | |
| 1089 | + | |
| 1090 | + </div> | |
| 1091 | + </div> | |
| 1092 | + | |
| 1093 | + <div class=""><br> | |
| 1094 | + <a type="button" href="<?php echo esc_url( site_url() ); ?>/wp-admin/admin.php?page=wp-database-backup&action=clear_temp_db_backup_file&_wpnonce=<?php echo esc_attr( $nonce ); ?>" class="btn btn-warning"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Clear all old/temp database backup files</a> | |
| 1095 | + <p><?php echo esc_html__("Click above button to clear all your old or temporary created database backup | |
| 1096 | + files. | |
| 1097 | + It only delete file from backup directory which is not in 'Database Backups' | |
| 1098 | + listing(all other file excluding backup files listed in 'Database Backups' ). | |
| 1099 | + Before | |
| 1100 | + using this option make sure that you have save your database backup on safe | |
| 1101 | + place.", 'wpdbbkp') ?></p> | |
| 1102 | + <p><?php echo esc_html__("The disk that your backup is saved on doesn't have enough free space? Backup disk | |
| 1103 | + is | |
| 1104 | + almost full? Low disk space for backup? Backup failed due to lack of space? As | |
| 1105 | + you | |
| 1106 | + may set up a schedule to automatically do backup daily or weekly, and the size | |
| 1107 | + of | |
| 1108 | + disk space is limited, so your backup disk will run out of space quickly or | |
| 1109 | + someday. | |
| 1110 | + It is a real pain to manually delete old backups. Don't worry about it. WP | |
| 1111 | + Database | |
| 1112 | + Backup makes it easy to delete old/temparary backup files using this option.", 'wpdbbkp') ?></p> | |
| 1113 | + | |
| 1114 | + </div> | |
| 1115 | + | |
| 1116 | + <div class="row list-group-item"> | |
| 1117 | + <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 1118 | + class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 1119 | + </div> | |
| 1120 | + <?php if ( true === isset( $_SERVER['DOCUMENT_ROOT'] ) ) { ?> | |
| 1121 | + <div class="col-md-3"><?php echo esc_html__('Root Path', 'wpdbbkp') ?></div> | |
| 1122 | + <div class="col-md-5"><?php echo esc_attr( sanitize_text_field( wp_unslash( $_SERVER['DOCUMENT_ROOT'] ) ) ); ?></div> | |
| 1123 | + <?php } ?> | |
| 1124 | + </div> | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + <div class="row list-group-item"> | |
| 1128 | + <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 1129 | + class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 1130 | + </div> | |
| 1131 | + <div class="col-md-3"><?php echo esc_html__('ABSPATH', 'wpdbbkp') ?></div> | |
| 1132 | + <div class="col-md-5"><?php echo esc_attr( ABSPATH ); ?></div> | |
| 1133 | + </div> | |
| 1134 | + | |
| 1135 | + <div class="row list-group-item"> | |
| 1136 | + <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 1137 | + class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 1138 | + </div> | |
| 1139 | + <div class="col-md-3"><?php esc_attr_e( 'Upload directory URL', 'wpdbbk' ); ?></div> | |
| 1140 | + <div class="col-md-5"> | |
| 1141 | + <?php | |
| 1142 | + $upload_dir = wp_upload_dir(); | |
| 1143 | + echo esc_url( $upload_dir['baseurl'] ) | |
| 1144 | + ?> | |
| 1145 | + </div> | |
| 1146 | + <div class="col-md-3"></div> | |
| 1147 | + </div> | |
| 1148 | + | |
| 1149 | + <div class="row list-group-item"> | |
| 1150 | + <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 1151 | + class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 1152 | + </div> | |
| 1153 | + <div class="col-md-3"><?php esc_attr_e( 'Upload directory', 'wpdbbk' ); ?></div> | |
| 1154 | + <div class="col-md-5"><?php echo esc_attr( $upload_dir['basedir'] ); ?></div> | |
| 1155 | + <div class="col-md-1"> | |
| 1156 | + <?php echo esc_attr( substr( sprintf( '%o', fileperms( $upload_dir['basedir'] ) ), -4 ) ); ?></div> | |
| 1157 | + <div | |
| 1158 | + class="col-md-2"><?php echo ( ! is_writable( $upload_dir['basedir'] ) ) ? '<p class="text-danger"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Not writable </p>' : '<p class="text-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span> writable</p>'; ?> | |
| 1159 | + </div> | |
| 1160 | + </div> | |
| 1161 | + | |
| 1162 | + <div class="row list-group-item"> | |
| 1163 | + <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 1164 | + class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 1165 | + </div> | |
| 1166 | + <div class="col-md-3"><?php echo esc_html__('Loaded PHP INI', 'wpdbbkp') ?></div> | |
| 1167 | + <div class="col-md-5"><?php echo esc_attr( php_ini_loaded_file() ); ?></div> | |
| 1168 | + </div> | |
| 1169 | + <div class="row list-group-item"> | |
| 1170 | + <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 1171 | + class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 1172 | + </div> | |
| 1173 | + <div class="col-md-3"><?php echo esc_html__('Memory Limit', 'wpdbbkp') ?></div> | |
| 1174 | + <div class="col-md-5"> | |
| 1175 | + <?php | |
| 1176 | + echo esc_attr( WP_MEMORY_LIMIT ); | |
| 1177 | + echo '(Max ' . esc_attr( WP_MAX_MEMORY_LIMIT ); | |
| 1178 | + ?> | |
| 1179 | + ) | |
| 1180 | + </div> | |
| 1181 | + </div> | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + <div class="row list-group-item"> | |
| 1185 | + <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 1186 | + class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 1187 | + </div> | |
| 1188 | + <div class="col-md-3"><?php esc_attr_e( 'Max Execution Time', 'wpdbbk' ); ?></div> | |
| 1189 | + <div class="col-md-5"> <?php echo esc_attr( ini_get( 'max_execution_time' ) ); ?></div> | |
| 1190 | + <div class="col-md-1"></div> | |
| 1191 | + <div | |
| 1192 | + class="col-md-2"><?php echo esc_attr( ini_get( 'max_execution_time' ) ) < 60 ? '<p class="text-danger" data-toggle="tooltip" data-placement="left" title="For large site set high"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Low </p>' : ''; ?></div> | |
| 1193 | + </div> | |
| 1194 | + <div class="row list-group-item"> | |
| 1195 | + <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 1196 | + class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 1197 | + </div> | |
| 1198 | + <div class="col-md-3"><?php esc_attr_e( 'Database backup directory', 'wpdbbk' ); ?></div> | |
| 1199 | + <div | |
| 1200 | + class="col-md-5"> <?php echo esc_attr( $upload_dir['basedir'] . '/db-backup' ); ?></div> | |
| 1201 | + <div | |
| 1202 | + class="col-md-1"><?php echo esc_attr( substr( sprintf( '%o', @fileperms( esc_attr( $upload_dir['basedir'] ) . '/db-backup' ) ), -4 ) ); ?></div> | |
| 1203 | + <div | |
| 1204 | + class="col-md-2"><?php echo ( ! is_writable( $upload_dir['basedir'] . '/db-backup' ) ) ? '<p class="text-danger"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Not writable </p>' : '<p class="text-success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span> writable</p>'; ?></div> | |
| 1205 | + </div> | |
| 1206 | + | |
| 1207 | + <div class="row list-group-item"> | |
| 1208 | + <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 1209 | + class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 1210 | + </div> | |
| 1211 | + <div class="col-md-3"><?php esc_attr_e( 'Class ZipArchive Present : ', 'wpdbbk' ); ?></div> | |
| 1212 | + <div class="col-md-5"> | |
| 1213 | + <?php | |
| 1214 | + echo ( class_exists( 'ZipArchive' ) ) ? 'Yes </p>' : '<p class="">No</p>'; | |
| 1215 | + ?> | |
| 1216 | + </div> | |
| 1217 | + <div class="col-md-3"></div> | |
| 1218 | + </div> | |
| 1219 | + | |
| 1220 | + <div class="row list-group-item"> | |
| 1221 | + <div class="col-md-1"><a href="" target="_blank" title="Help"><span | |
| 1222 | + class="glyphicon glyphicon-question-sign" aria-hidden="true"></span></a> | |
| 1223 | + </div> | |
| 1224 | + <div class="col-md-3"><?php esc_attr_e( 'mysqldump (cmd) Present : ', 'wpdbbk' ); ?></div> | |
| 1225 | + <div class="col-md-5"> | |
| 1226 | + <?php | |
| 1227 | + $wpdb_admin = new Wpdb_Admin(); | |
| 1228 | + echo ( $wpdb_admin->get_mysqldump_command_path() ) ? 'Yes </p>' : '<p class="">No</p>'; | |
| 1229 | + ?> | |
| 1230 | + </div> | |
| 1231 | + <div class="col-md-3"></div> | |
| 1232 | + </div> | |
| 1233 | + | |
| 1234 | + </div> | |
| 1235 | + </div> | |
| 1236 | + </div> | |
| 1237 | + | |
| 1238 | + <div class="panel panel-default"> | |
| 1239 | + <div class="panel-heading"> | |
| 1240 | + <a class="toggle_anchor" data-toggle="collapse" data-parent="#accordion" href="#collapsedbinfo"> | |
| 1241 | + <h4 class="panel-title"><?php echo esc_html__('Database Information', 'wpdbbkp') ?></h4> | |
| 1242 | + </a> | |
| 1243 | + </div> | |
| 1244 | + | |
| 1245 | + <div id="collapsedbinfo" class="panel-collapse collapse in"> | |
| 1246 | + <div class="panel-body"> | |
| 1247 | + <table class="table table-condensed"> | |
| 1248 | + <tr class="success"> | |
| 1249 | + <th><?php echo esc_html__('Setting', 'wpdbbkp') ?></th> | |
| 1250 | + <th><?php echo esc_html__('Value', 'wpdbbkp') ?></th> | |
| 1251 | + </tr> | |
| 1252 | + <tr> | |
| 1253 | + <td><?php echo esc_html__('Database Host', 'wpdbbkp') ?></td> | |
| 1254 | + <td><?php echo esc_attr( DB_HOST ); ?></td> | |
| 1255 | + </tr> | |
| 1256 | + <tr class="default"> | |
| 1257 | + <td><?php echo esc_html__('Database Name', 'wpdbbkp') ?></td> | |
| 1258 | + <td> <?php echo esc_attr( DB_NAME ); ?></td> | |
| 1259 | + </tr> | |
| 1260 | + <tr> | |
| 1261 | + <td><?php echo esc_html__('Database User', 'wpdbbkp') ?></td> | |
| 1262 | + <td><?php echo esc_attr( DB_USER ); ?></td> | |
| 1263 | + </td> | |
| 1264 | + </tr> | |
| 1265 | + <tr> | |
| 1266 | + <td><?php echo esc_html__('Database Type', 'wpdbbkp') ?></td> | |
| 1267 | + <td><?php echo esc_html__('MYSQL', 'wpdbbkp') ?></td> | |
| 1268 | + </tr> | |
| 1269 | + <tr> | |
| 1270 | + <?php | |
| 1271 | + // Get MYSQL Version. | |
| 1272 | + global $wpdb; | |
| 1273 | + $mysqlversion = wp_cache_get( 'wpdb_mysqlversion' ); | |
| 1274 | + if ( true === empty( $mysqlversion ) ) { | |
| 1275 | + $mysqlversion = $wpdb->get_var( 'SELECT VERSION() AS version' ); // phpcs:ignore | |
| 1276 | + wp_cache_set( 'wpdb_mysqlversion', $mysqlversion, '', 18000 ); | |
| 1277 | + } | |
| 1278 | + ?> | |
| 1279 | + <td><?php echo esc_html__('Database Version', 'wpdbbkp') ?></td> | |
| 1280 | + <td>v<?php echo esc_attr( $mysqlversion ); ?></td> | |
| 1281 | + </tr> | |
| 1282 | + </table> | |
| 1283 | + | |
| 1284 | + </div> | |
| 1285 | + </div> | |
| 1286 | + </div> | |
| 1287 | + | |
| 1288 | + <div class="panel panel-default"> | |
| 1289 | + <div class="panel-heading"> | |
| 1290 | + | |
| 1291 | + <a class="toggle_anchor" data-toggle="collapse" data-parent="#accordion" href="#collapsedbtable"> | |
| 1292 | + <h4 class="panel-title"> | |
| 1293 | + <?php echo esc_html__('Tables Information', 'wpdbbkp') ?> | |
| 1294 | + </h4> | |
| 1295 | + </a> | |
| 1296 | + | |
| 1297 | + </div> | |
| 1298 | + <div id="collapsedbtable" class="panel-collapse collapse in"> | |
| 1299 | + <div class="panel-body"> | |
| 1300 | + <table class="table table-condensed"> | |
| 1301 | + <tr class="success"> | |
| 1302 | + <th><?php echo esc_html__('No.', 'wpdbbkp') ?></th> | |
| 1303 | + <th><?php echo esc_html__('Tables', 'wpdbbkp') ?></th> | |
| 1304 | + <th><?php echo esc_html__('Records', 'wpdbbkp') ?></th> | |
| 1305 | + | |
| 1306 | + </tr> | |
| 1307 | + <?php | |
| 1308 | + $no = 0; | |
| 1309 | + $row_usage = 0; | |
| 1310 | + $data_usage = 0; | |
| 1311 | + $tablesstatus = $wpdb->get_results( 'SHOW TABLE STATUS' ); // phpcs:ignore | |
| 1312 | + if($tablesstatus != null && !empty($tablesstatus)){ | |
| 1313 | + foreach ( $tablesstatus as $tablestatus ) { | |
| 1314 | + $tablestatus_arr = (array) $tablestatus; | |
| 1315 | + if ( 0 === ( $no % 2 ) ) { | |
| 1316 | + $style = ''; | |
| 1317 | + } else { | |
| 1318 | + $style = ' class="alternate"'; | |
| 1319 | + } | |
| 1320 | + $no++; | |
| 1321 | + echo '<tr' . esc_attr( $style ) . '>'; | |
| 1322 | + echo '<td>' . esc_attr( number_format_i18n( $no ) ) . '</td>'; | |
| 1323 | + echo '<td>' . esc_attr( $tablestatus_arr['Name'] ) . '</td>'; | |
| 1324 | + echo '<td>' . esc_attr( number_format_i18n( isset($tablestatus_arr['Rows'])?$tablestatus_arr['Rows']:0 ) ) . '</td>'; | |
| 1325 | + | |
| 1326 | + $row_usage += $tablestatus_arr['Rows']; | |
| 1327 | + | |
| 1328 | + echo '</tr>'; | |
| 1329 | + } | |
| 1330 | + } | |
| 1331 | + echo '<tr class="thead">'; | |
| 1332 | + echo '<th> Total:</th>'; | |
| 1333 | + echo '<th>' . esc_attr( number_format_i18n( $no ) ) . ' Table </th>'; | |
| 1334 | + echo '<th>' . esc_attr( number_format_i18n( $row_usage ) ) . ' Records</th>'; | |
| 1335 | + | |
| 1336 | + echo '</tr>'; | |
| 1337 | + ?> | |
| 1338 | + </table> | |
| 1339 | + | |
| 1340 | + </div> | |
| 1341 | + </div> | |
| 1342 | + </div> | |
| 1343 | + <div class="panel panel-default"> | |
| 1344 | + <div class="panel-heading"> | |
| 1345 | + | |
| 1346 | + <a class="toggle_anchor" data-toggle="collapse" data-parent="#accordion" href="#collapsewp"> | |
| 1347 | + <h4 class="panel-title"> | |
| 1348 | + <?php echo esc_html__('WordPress Information', 'wpdbbkp') ?> | |
| 1349 | + </h4> | |
| 1350 | + </a> | |
| 1351 | + | |
| 1352 | + </div> | |
| 1353 | + <div id="collapsewp" class="panel-collapse collapse in"> | |
| 1354 | + <div class="panel-body"> | |
| 1355 | + <table class="table table-condensed"> | |
| 1356 | + <tr class="success"> | |
| 1357 | + <th><?php echo esc_html__('Setting', 'wpdbbkp') ?></th> | |
| 1358 | + <th><?php echo esc_html__('Value', 'wpdbbkp') ?></th> | |
| 1359 | + | |
| 1360 | + </tr> | |
| 1361 | + <tr> | |
| 1362 | + <td><?php echo esc_html__('WordPress Version', 'wpdbbkp') ?></td> | |
| 1363 | + <td><?php bloginfo( 'version' ); ?></td> | |
| 1364 | + </tr> | |
| 1365 | + <tr> | |
| 1366 | + <td><?php echo esc_html__('Home URL', 'wpdbbkp') ?></td> | |
| 1367 | + <td> <?php echo esc_url( home_url() ); ?></td> | |
| 1368 | + </tr> | |
| 1369 | + <tr> | |
| 1370 | + <td><?php echo esc_html__('Site URL', 'wpdbbkp') ?></td> | |
| 1371 | + <td><?php echo esc_url( site_url() ); ?></td> | |
| 1372 | + </tr> | |
| 1373 | + <tr> | |
| 1374 | + <td><?php echo esc_html__('Upload directory URL', 'wpdbbkp') ?></td> | |
| 1375 | + <td><?php $upload_dir = wp_upload_dir(); ?> | |
| 1376 | + <?php echo esc_url( $upload_dir['baseurl'] ); ?></td> | |
| 1377 | + </tr> | |
| 1378 | + </table> | |
| 1379 | + | |
| 1380 | + </div> | |
| 1381 | + </div> | |
| 1382 | + </div> | |
| 1383 | + | |
| 1384 | + <div class="panel panel-default"> | |
| 1385 | + <div class="panel-heading"> | |
| 1386 | + | |
| 1387 | + <a class="toggle_anchor" data-toggle="collapse" data-parent="#accordion" href="#collapsewpsetting"> | |
| 1388 | + <h4 class="panel-title"> | |
| 1389 | + <?php echo esc_html__('WordPress Settings', 'wpdbbkp') ?> | |
| 1390 | + </h4> | |
| 1391 | + </a> | |
| 1392 | + | |
| 1393 | + </div> | |
| 1394 | + <div id="collapsewpsetting" class="panel-collapse collapse in"> | |
| 1395 | + <div class="panel-body"> | |
| 1396 | + <table class="table table-condensed"> | |
| 1397 | + <tr class="success"> | |
| 1398 | + <th><?php echo esc_html__('Plugin Name', 'wpdbbkp') ?></th> | |
| 1399 | + <th><?php echo esc_html__('Version', 'wpdbbkp') ?></th> | |
| 1400 | + </tr> | |
| 1401 | + <?php | |
| 1402 | + $plugins = get_plugins(); | |
| 1403 | + foreach ( $plugins as $plugin ) { | |
| 1404 | + echo '<tr> | |
| 1405 | + <td>' . esc_attr( $plugin['Name'] ) . '</td> | |
| 1406 | + <td>' . esc_attr( $plugin['Version'] ) . '</td> | |
| 1407 | + </tr>'; | |
| 1408 | + } | |
| 1409 | + ?> | |
| 1410 | + </table> | |
| 1411 | + <table class="table table-condensed"> | |
| 1412 | + <tr class="success"> | |
| 1413 | + <th><?php echo esc_html__('Active Theme Name', 'wpdbbkp') ?></th> | |
| 1414 | + <th><?php echo esc_html__('Version', 'wpdbbkp') ?></th> | |
| 1415 | + </tr> | |
| 1416 | + <?php | |
| 1417 | + $my_theme = wp_get_theme(); | |
| 1418 | + | |
| 1419 | + echo '<tr> | |
| 1420 | + <td>' . esc_attr( $my_theme->get( 'Name' ) ) . '</td> | |
| 1421 | + <td>' . esc_attr( $my_theme->get( 'Version' ) ) . '</td> | |
| 1422 | + </tr>'; | |
| 1423 | + ?> | |
| 1424 | + </table> | |
| 1425 | + <div class="row"> | |
| 1426 | + <button class="btn btn-primary" type="button"> | |
| 1427 | + <?php echo esc_html__('Drafts Post Count', 'wpdbbkp') ?> <span class="badge"> | |
| 1428 | + <?php | |
| 1429 | + $count_posts = wp_count_posts(); | |
| 1430 | + echo esc_attr( $count_posts->draft ); | |
| 1431 | + ?> | |
| 1432 | + </span> | |
| 1433 | + </button> | |
| 1434 | + <button class="btn btn-primary" type="button"> | |
| 1435 | + <?php echo esc_html__('Publish Post Count', 'wpdbbkp') ?> <span class="badge"> | |
| 1436 | + <?php | |
| 1437 | + | |
| 1438 | + echo esc_attr( $count_posts->publish ); | |
| 1439 | + ?> | |
| 1440 | + </span> | |
| 1441 | + </button> | |
| 1442 | + <button class="btn btn-primary" type="button"> | |
| 1443 | + <?php echo esc_html__('Drafts Pages Count', 'wpdbbkp') ?> <span class="badge"> | |
| 1444 | + <?php | |
| 1445 | + $count_pages = wp_count_posts( 'page' ); | |
| 1446 | + echo esc_attr( $count_pages->draft ); | |
| 1447 | + ?> | |
| 1448 | + </span> | |
| 1449 | + </button> | |
| 1450 | + <button class="btn btn-primary" type="button"> | |
| 1451 | + <?php echo esc_html__('Publish Pages Count', 'wpdbbkp') ?> <span class="badge"> | |
| 1452 | + <?php | |
| 1453 | + | |
| 1454 | + echo esc_attr( $count_pages->publish ); | |
| 1455 | + ?> | |
| 1456 | + </span> | |
| 1457 | + </button> | |
| 1458 | + <button class="btn btn-primary" type="button"> | |
| 1459 | + <?php echo esc_html__('Approved Comments Count', 'wpdbbkp') ?> <span class="badge"> | |
| 1460 | + <?php | |
| 1461 | + $comments_count = wp_count_comments(); | |
| 1462 | + echo esc_attr( $comments_count->approved ); | |
| 1463 | + ?> | |
| 1464 | + </span> | |
| 1465 | + </button> | |
| 1466 | + </div> | |
| 1467 | + </div> | |
| 1468 | + </div> | |
| 1469 | + </div> | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + </div> | |
| 1473 | + | |
| 1474 | + <div class="tab-pane" id="db_setting"> | |
| 1475 | + | |
| 1476 | + <div class="panel-group"> | |
| 1477 | + <?php | |
| 1478 | + $wp_local_db_backup_count = get_option( 'wp_local_db_backup_count' ); | |
| 1479 | + $wp_db_log = get_option( 'wp_db_log' ); | |
| 1480 | + $wp_db_exclude_table = array(); | |
| 1481 | + $wp_db_exclude_table = get_option( 'wp_db_exclude_table' ); | |
| 1482 | + $wp_db_backup_enable_auto_upgrade = get_option( 'wp_db_backup_enable_auto_upgrade' ); | |
| 1483 | + if ( 1 === (int) $wp_db_backup_enable_auto_upgrade ) { | |
| 1484 | + $wp_db_backup_enable_auto_upgrade_checked = 'checked'; | |
| 1485 | + } else { | |
| 1486 | + $wp_db_backup_enable_auto_upgrade_checked = ''; | |
| 1487 | + } | |
| 1488 | + if ( 1 === (int) $wp_db_log ) { | |
| 1489 | + $checked = 'checked'; | |
| 1490 | + } else { | |
| 1491 | + $checked = ''; | |
| 1492 | + } | |
| 1493 | + $wp_db_remove_local_backup = get_option( 'wp_db_remove_local_backup' ); | |
| 1494 | + $wp_db_remove_on_uninstall = get_option( 'wp_db_remove_on_uninstall'); | |
| 1495 | + if ( 1 === (int) $wp_db_remove_local_backup ) { | |
| 1496 | + $remove_local_backup = 'checked'; | |
| 1497 | + } else { | |
| 1498 | + $remove_local_backup = ''; | |
| 1499 | + } | |
| 1500 | + if ( 1 === (int) $wp_db_remove_on_uninstall ) { | |
| 1501 | + $remove_on_uninstall = 'checked'; | |
| 1502 | + } else { | |
| 1503 | + $remove_on_uninstall = ''; | |
| 1504 | + } | |
| 1505 | + ?> | |
| 1506 | + <form action="" method="post"> | |
| 1507 | + <?php wp_nonce_field( 'wp-database-backup' ); ?> | |
| 1508 | + <div class="input-group"> | |
| 1509 | + <span class="input-group-addon" id="sizing-addon2"><?php echo esc_html__('Maximum Local Backups', 'wpdbbkp') ?></span> | |
| 1510 | + <input type="number" name="wp_local_db_backup_count" value="<?php echo esc_html( $wp_local_db_backup_count ); ?>" class="form-control" placeholder="Maximum Local Backups" aria-describedby="sizing-addon2"> | |
| 1511 | + | |
| 1512 | + </div> | |
| 1513 | + <div class="alert alert-default" role="alert"> | |
| 1514 | + <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span><?php echo esc_html__(' The maximum | |
| 1515 | + number of Local Database Backups that should be kept, regardless of their size.', 'wpdbbkp') ?></br> | |
| 1516 | + <?php echo esc_html__('Leave blank for keep unlimited database backups.', 'wpdbbkp') ?> | |
| 1517 | + </div> | |
| 1518 | + <hr> | |
| 1519 | + <div class="input-group"> | |
| 1520 | + <label><input type="checkbox" <?php echo esc_attr( $checked ); ?> name="wp_db_log"> <?php echo esc_html__('Enable Log', 'wpdbbkp') ?></label> | |
| 1521 | + </div> | |
| 1522 | + <hr> | |
| 1523 | + <div class="input-group"> | |
| 1524 | + <label><input type="checkbox" <?php echo esc_attr( $wp_db_backup_enable_auto_upgrade_checked ); ?> name="wp_db_backup_enable_auto_upgrade"> <?php echo esc_html__('Enable Auto Backups Before Upgrade', 'wpdbbkp') ?></label> | |
| 1525 | + <p><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> | |
| 1526 | + <?php echo esc_html__('If checked then it will create database backup on(before) upgrade/update plugin, theme, WordPress.', 'wpdbbkp') ?> | |
| 1527 | + <br><?php echo esc_html__('Leave blank/un-checked for disable this feature.', 'wpdbbkp') ?> | |
| 1528 | + </p> | |
| 1529 | + </div> | |
| 1530 | + <hr> | |
| 1531 | + <div class="input-group"> | |
| 1532 | + <label><input type="checkbox" <?php echo esc_attr( $remove_local_backup ); ?> name="wp_db_remove_local_backup"> <?php echo esc_html__('Remove local backup', 'wpdbbkp') ?></label> | |
| 1533 | + <p><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> | |
| 1534 | + <?php echo esc_html__('If Checked then it will remove local backup.', 'wpdbbkp') ?> | |
| 1535 | + <br><?php echo esc_html__('Use this option only when you have set any destination.', 'wpdbbkp') ?> | |
| 1536 | + <br><?php echo esc_html__('If somesites you need only external backup.', 'wpdbbkp') ?> | |
| 1537 | + </p> | |
| 1538 | + </div> | |
| 1539 | + <hr> | |
| 1540 | + <div class="input-group"> | |
| 1541 | + <label><input type="checkbox" <?php echo esc_attr( $remove_on_uninstall ); ?> name="wp_db_remove_on_uninstall"> <?php echo esc_html__('Delete Data and options on uninstall', 'wpdbbkp') ?></label> | |
| 1542 | + <p><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> | |
| 1543 | + <?php echo esc_html__('If Checked then it will delete all backup files and options when plugin is uninstalled', 'wpdbbkp') ?> | |
| 1544 | + | |
| 1545 | + </p> | |
| 1546 | + </div> | |
| 1547 | + <hr> | |
| 1548 | + <?php | |
| 1549 | + $remove_backup_href = esc_url( site_url() ) . '/wp-admin/admin.php?page=wp-database-backup&action=removeallbackup&_wpnonce=' . esc_attr( $nonce ); ?> | |
| 1550 | + | |
| 1551 | + <div class="input-group"> | |
| 1552 | + <a title="Remove Database Backup" onclick="return confirm('Are you sure you want to delete all the backups? Deleted backups can not be recovered.')" href="<?php echo esc_url($remove_backup_href)?>" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span> <?php esc_html_e('Delete all Backups', 'wpdbbkp')?></a> | |
| 1553 | + <br><?php echo esc_html__('Warning :This is will delete all the backups on the website. Once deleted backups can not be recovered.', 'wpdbbkp') ?> | |
| 1554 | + | |
| 1555 | + </div> | |
| 1556 | + <hr> | |
| 1557 | + <div class="panel panel-default"> | |
| 1558 | + <div class="panel-heading"> | |
| 1559 | + <a data-toggle="collapse" data-parent="#accordion" href="#collapseExclude"> | |
| 1560 | + <h4 class="panel-title"> | |
| 1561 | + <?php echo esc_html__('Exclude Table From Database Backup', 'wpdbbkp') ?> | |
| 1562 | + </h4> | |
| 1563 | + </a> | |
| 1564 | + </div> | |
| 1565 | + <div id="collapseExclude" class="panel-collapse collapse in"> | |
| 1566 | + <div class="panel-body"> | |
| 1567 | + <table class="table table-condensed"> | |
| 1568 | + <tr class="success"> | |
| 1569 | + <th><?php echo esc_html__('No.', 'wpdbbkp') ?></th> | |
| 1570 | + <th><?php echo esc_html__('Tables', 'wpdbbkp') ?></th> | |
| 1571 | + <th><?php echo esc_html__('Records', 'wpdbbkp') ?></th> | |
| 1572 | + <th><?php echo esc_html__('Exclude Table', 'wpdbbkp') ?></th> | |
| 1573 | + </tr> | |
| 1574 | + <?php | |
| 1575 | + $no = 0; | |
| 1576 | + $row_usage = 0; | |
| 1577 | + $data_usage = 0; | |
| 1578 | + $tablesstatus = $wpdb->get_results( 'SHOW TABLE STATUS' ); // phpcs:ignore | |
| 1579 | + if($tablesstatus != null && !empty($tablesstatus)){ | |
| 1580 | + foreach ( $tablesstatus as $tablestatus ) { | |
| 1581 | + $tablestatus_arr = (array) $tablestatus; | |
| 1582 | + if ( 0 === ( $no % 2 ) ) { | |
| 1583 | + $style = ''; | |
| 1584 | + } else { | |
| 1585 | + $style = ' class="alternate"'; | |
| 1586 | + } | |
| 1587 | + $no++; | |
| 1588 | + echo '<tr' . esc_attr( $style ) . '>'; | |
| 1589 | + echo '<td>' . esc_attr( number_format_i18n( $no ) ) . '</td>'; | |
| 1590 | + echo '<td>' . esc_attr( $tablestatus_arr['Name'] ) . '</td>'; | |
| 1591 | + echo '<td>' . esc_attr( number_format_i18n( isset($tablestatus_arr['Rows'])?$tablestatus_arr['Rows']:0 ) ) . '</td>'; | |
| 1592 | + if ( false === empty( $wp_db_exclude_table ) && in_array( $tablestatus_arr['Name'], $wp_db_exclude_table, true ) ) { | |
| 1593 | + $checked = 'checked'; | |
| 1594 | + } else { | |
| 1595 | + $checked = ''; | |
| 1596 | + } | |
| 1597 | + echo '<td> <input class="wp_db_exclude_table" type="checkbox" ' . esc_attr( $checked ) . ' value="' . esc_attr( $tablestatus_arr['Name'] ) . '" name="wp_db_exclude_table[' . esc_attr( $tablestatus_arr['Name'] ) . ']"></td>'; | |
| 1598 | + | |
| 1599 | + $row_usage += $tablestatus_arr['Rows']; | |
| 1600 | + | |
| 1601 | + echo '</tr>'; | |
| 1602 | + } | |
| 1603 | + } | |
| 1604 | + echo '<tr class="thead">'; | |
| 1605 | + echo '<th>Total:</th>'; | |
| 1606 | + echo '<th>' . esc_attr( number_format_i18n( $no ) ) . ' Table</th>'; | |
| 1607 | + echo '<th>' . esc_attr( number_format_i18n( $row_usage ) ) . ' Records</th>'; | |
| 1608 | + echo '<th></th>'; | |
| 1609 | + echo '</tr>'; | |
| 1610 | + ?> | |
| 1611 | + </table> | |
| 1612 | + </div> | |
| 1613 | + </div> | |
| 1614 | + </div> | |
| 1615 | + <hr> | |
| 1616 | + <input class="btn btn-primary" type="submit" name="wpsetting" value="Save"> | |
| 1617 | + </form> | |
| 1618 | + </div> | |
| 1619 | + </div> | |
| 1620 | + | |
| 1621 | + <div class="tab-pane" id="searchreplace"> | |
| 1622 | + <div class="panel-group"> | |
| 1623 | + <?php | |
| 1624 | + $wp_db_backup_search_text = get_option( 'wp_db_backup_search_text' ); | |
| 1625 | + $wp_db_backup_replace_text = get_option( 'wp_db_backup_replace_text' ); | |
| 1626 | + ?> | |
| 1627 | + <form action="" method="post"> | |
| 1628 | + <?php wp_nonce_field( 'wp-database-backup' ); ?> | |
| 1629 | + | |
| 1630 | + <p><?php echo esc_html__('If you even need to migrate your WordPress site to a different domain name, | |
| 1631 | + or add an SSL certificate to it, you must update the URLs in your database backup file | |
| 1632 | + then you can use this feature.','wpdbbkp'); ?> <br> | |
| 1633 | + <?php echo esc_html__(' This feature allow you to Search and Replace text in your database backup file. ','wpdbbkp'); ?> | |
| 1634 | + <br> <?php echo esc_html__('if you want only exclude tables from search and replace text then Go to Dashboard=>Tool=>WP-DB Backup > Setting > Exclude Table From Database Backup setting. The tables you selected will be skipped over for each backup you make.', 'wpdbbkp') ?> | |
| 1635 | + </p> | |
| 1636 | + <br> | |
| 1637 | + <div class="input-group"> | |
| 1638 | + <span class="input-group-addon" id="wp_db_backup_search_text"><?php echo esc_html__('Search For', 'wpdbbkp') ?></span> | |
| 1639 | + <input type="text" name="wp_db_backup_search_text" value="<?php echo esc_html( $wp_db_backup_search_text ); ?>" class="form-control" placeholder="http://localhost/wordpress" aria-describedby="wp_db_backup_search_text"> | |
| 1640 | + | |
| 1641 | + </div> | |
| 1642 | + <br> | |
| 1643 | + <div class="input-group"> | |
| 1644 | + <span class="input-group-addon" id="wp_db_backup_replace_text"><?php echo esc_html__('Replace With', 'wpdbbkp') ?></span> | |
| 1645 | + <input type="text" name="wp_db_backup_replace_text" value="<?php echo esc_html( $wp_db_backup_replace_text ); ?>" class="form-control" placeholder="http://site.com" aria-describedby="wp_db_backup_replace_text"> | |
| 1646 | + | |
| 1647 | + </div> | |
| 1648 | + | |
| 1649 | + <div class="alert alert-default" role="alert"> | |
| 1650 | + <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> | |
| 1651 | + <?php echo esc_html__("Leave blank those fields if you don't want use this feature and want only regular Database backup.", 'wpdbbkp') ?> | |
| 1652 | + <br> | |
| 1653 | + <?php echo esc_html__('Ex:', 'wpdbbkp') ?> | |
| 1654 | + <br><?php echo esc_html__('Search For:', 'wpdbbkp') ?> http://localhost/wordpress/ | |
| 1655 | + <br><?php echo esc_html__('Replace With:', 'wpdbbkp') ?> http://domain.com/ | |
| 1656 | + | |
| 1657 | + <br><br> | |
| 1658 | + <?php echo esc_html__('Note - This is Search & Replace data in your WordPress Database Backup File not in current Database installation.', 'wpdbbkp') ?> | |
| 1659 | + | |
| 1660 | + </div> | |
| 1661 | + | |
| 1662 | + <input class="btn btn-primary" type="submit" name="wpsetting_search" value="Save"> | |
| 1663 | + </form> | |
| 1664 | + </div> | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + </div> | |
| 1669 | + <div class="tab-pane panel-group" id="db_destination"> | |
| 1670 | + <?php | |
| 1671 | + include plugin_dir_path( __FILE__ ) . 'Destination/wp-backup-destination.php'; | |
| 1672 | + ?> | |
| 1673 | + </div> | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + </div> | |
| 1677 | + </div> | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + </div> | |
| 1681 | + <a aria-label="Open Support" aria-expanded="false" class="wpdbbkp-support-button" href="https://backupforwp.com/support/" target="_blank"> | |
| 1682 | + <span class="wpdbbkp-support-icon"> | |
| 1683 | + <svg width="24" height="22" xmlns="http://www.w3.org/2000/svg"><path d="M20.347 20.871l-.003-.05c0 .017.001.034.003.05zm-.243-4.278a2 2 0 0 1 .513-1.455c1.11-1.226 1.383-2.212 1.383-4.74C22 5.782 18.046 2 13.125 2h-2.25C5.954 2 2 5.78 2 10.399c0 4.675 4.01 8.626 8.875 8.626h2.25c.834 0 1.606-.207 3.212-.798a2 2 0 0 1 1.575.083l2.355 1.161-.163-2.878zM10.875 0h2.25C19.13 0 24 4.656 24 10.399c0 2.6-.25 4.257-1.9 6.08l.243 4.279c.072.845-.807 1.471-1.633 1.162l-3.682-1.816c-1.212.446-2.527.921-3.903.921h-2.25C4.869 21.025 0 16.142 0 10.4 0 4.656 4.869 0 10.875 0z" fill="#FFF"></path></svg> | |
| 1684 | + </span> | |
| 1685 | + </a> | |
| 1686 | + <?php | |
| 1687 | + } | |
| 1688 | + | |
| 1689 | + /** | |
| 1690 | + * Redirect to premium website | |
| 1691 | + */ | |
| 1692 | + public function wp_db_backup_premium_interface_render() | |
| 1693 | + { | |
| 1694 | + wp_redirect("https://backupforwp.com/pricing/"); | |
| 1695 | + exit; | |
| 1696 | + } | |
| 1697 | + | |
| 1698 | + /** | |
| 1699 | + * Run after complete backup. | |
| 1700 | + * | |
| 1701 | + * @param bool $bytes - bytes details. | |
| 1702 | + * @param int $precision - precision details. | |
| 1703 | + */ | |
| 1704 | + public function wp_db_backup_format_bytes( $bytes, $precision = 2 ) { | |
| 1705 | + $units = array( 'B', 'KB', 'MB', 'GB', 'TB' ); | |
| 1706 | + $bytes = max( $bytes, 0 ); | |
| 1707 | + $pow = floor( ( $bytes ? log( $bytes ) : 0 ) / log( 1024 ) ); | |
| 1708 | + $pow = min( $pow, count( $units ) - 1 ); | |
| 1709 | + $bytes /= pow( 1024, $pow ); | |
| 1710 | + return round( $bytes, $precision ) . ' ' . $units[ $pow ]; | |
| 1711 | + } | |
| 1712 | + | |
| 1713 | + /** | |
| 1714 | + * Create database bakup function. | |
| 1715 | + */ | |
| 1716 | + public function wp_db_backup_create_mysql_backup() { | |
| 1717 | + global $wpdb; | |
| 1718 | + /* BEGIN : Prevent saving backup plugin settings in the database dump */ | |
| 1719 | + $options_backup = get_option( 'wp_db_backup_backups' ); | |
| 1720 | + $settings_backup = get_option( 'wp_db_backup_options' ); | |
| 1721 | + delete_option( 'wp_db_backup_backups' ); | |
| 1722 | + delete_option( 'wp_db_backup_options' ); | |
| 1723 | + /* END : Prevent saving backup plugin settings in the database dump */ | |
| 1724 | + $wp_db_exclude_table = array(); | |
| 1725 | + $wp_db_exclude_table = get_option( 'wp_db_exclude_table' ); | |
| 1726 | + $tables = $wpdb->get_col( 'SHOW TABLES' ); // phpcs:ignore | |
| 1727 | + $output = ''; | |
| 1728 | + foreach ( $tables as $table ) { | |
| 1729 | + if ( empty( $wp_db_exclude_table ) || ( ! ( in_array( $table, $wp_db_exclude_table, true ) ) ) ) { | |
| 1730 | + | |
| 1731 | + $check_count = $wpdb->get_var( "SELECT count(*) FROM {$table}"); // phpcs:ignore | |
| 1732 | + $check_count = intval($check_count); | |
| 1733 | + $sub_limit =500; | |
| 1734 | + if(isset($check_count) && $check_count>$sub_limit){ | |
| 1735 | + $result =array(); | |
| 1736 | + $t_sub_queries= ceil($check_count/$sub_limit); | |
| 1737 | + for($sub_i=0;$sub_i<$t_sub_queries;$sub_i++) | |
| 1738 | + { | |
| 1739 | + $sub_offset = $sub_i*$sub_limit; | |
| 1740 | + $sub_result = $wpdb->get_results( $wpdb->prepare("SELECT * FROM %i LIMIT %d OFFSET %d",array($table,$sub_limit,$sub_offset)), ARRAY_A ); | |
| 1741 | + if($sub_result){ | |
| 1742 | + $result = array_merge($result,$sub_result); | |
| 1743 | + } | |
| 1744 | + sleep(1); | |
| 1745 | + } | |
| 1746 | + } | |
| 1747 | + else{ | |
| 1748 | + $result = $wpdb->get_results( $wpdb->prepare("SELECT * FROM %i",array($table)), ARRAY_A ); // phpcs:ignore | |
| 1749 | + } | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + $row2 = $wpdb->get_row( 'SHOW CREATE TABLE ' . $table, ARRAY_N ); // phpcs:ignore | |
| 1753 | + $output .= "\n\n" . $row2[1] . ";\n\n"; | |
| 1754 | + $result_count = count( $result ); | |
| 1755 | + for ( $i = 0; $i < $result_count; $i++ ) { | |
| 1756 | + $row = $result[ $i ]; | |
| 1757 | + $output .= 'INSERT INTO ' . $table . ' VALUES('; | |
| 1758 | + $result_o_index = count( $result[0] ); | |
| 1759 | + $j=0; | |
| 1760 | + foreach ($row as $key => $value) { | |
| 1761 | + $row[ $key] = $wpdb->_real_escape( apply_filters( 'wpdbbkp_process_db_fields', $row[$key],$table,$key) ); | |
| 1762 | + $output .= ( isset( $row[ $key ] ) ) ? '"' . $row[ $key ] . '"' : '""'; | |
| 1763 | + if ( $j < ( $result_o_index - 1 ) ) { | |
| 1764 | + $output .= ','; | |
| 1765 | + } | |
| 1766 | + $j++; | |
| 1767 | + } | |
| 1768 | + $output .= ");\n"; | |
| 1769 | + } | |
| 1770 | + $output .= "\n"; | |
| 1771 | + } | |
| 1772 | + sleep(1); | |
| 1773 | + } | |
| 1774 | + $wpdb->flush(); | |
| 1775 | + /* BEGIN : Prevent saving backup plugin settings in the database dump */ | |
| 1776 | + add_option( 'wp_db_backup_backups', $options_backup ); | |
| 1777 | + add_option( 'wp_db_backup_options', $settings_backup ); | |
| 1778 | + /* END : Prevent saving backup plugin settings in the database dump */ | |
| 1779 | + return $output; | |
| 1780 | + } | |
| 1781 | + | |
| 1782 | + /** | |
| 1783 | + * Create database backup new function. | |
| 1784 | + */ | |
| 1785 | + public function wp_db_backup_create_mysql_backup_new($table) { | |
| 1786 | + global $wpdb; | |
| 1787 | + $output = ''; | |
| 1788 | + | |
| 1789 | + $check_count = $wpdb->get_var( "SELECT count(*) FROM {$table}"); // phpcs:ignore | |
| 1790 | + $check_count = intval($check_count); | |
| 1791 | + $sub_limit =500; | |
| 1792 | + if(isset($check_count) && $check_count>$sub_limit){ | |
| 1793 | + $result =array(); | |
| 1794 | + $t_sub_queries= ceil($check_count/$sub_limit); | |
| 1795 | + for($sub_i=0;$sub_i<$t_sub_queries;$sub_i++) | |
| 1796 | + { | |
| 1797 | + $sub_offset = $sub_i*$sub_limit; | |
| 1798 | + $sub_result = $wpdb->get_results( $wpdb->prepare("SELECT * FROM %i LIMIT %d OFFSET %d",array($table,$sub_limit,$sub_offset)), ARRAY_A ); | |
| 1799 | + if($sub_result){ | |
| 1800 | + $result = array_merge($result,$sub_result); | |
| 1801 | + } | |
| 1802 | + sleep(1); | |
| 1803 | + } | |
| 1804 | + } | |
| 1805 | + else{ | |
| 1806 | + $result = $wpdb->get_results( $wpdb->prepare("SELECT * FROM %i",array($table)), ARRAY_A ); // phpcs:ignore | |
| 1807 | + } | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + $row2 = $wpdb->get_row( 'SHOW CREATE TABLE ' . $table, ARRAY_N ); // phpcs:ignore | |
| 1811 | + $output .= "\n\n" . $row2[1] . ";\n\n"; | |
| 1812 | + $result_count = count( $result ); | |
| 1813 | + for ( $i = 0; $i < $result_count; $i++ ) { | |
| 1814 | + $row = $result[ $i ]; | |
| 1815 | + $output .= 'INSERT INTO ' . $table . ' VALUES('; | |
| 1816 | + $result_o_index = count( $result[0] ); | |
| 1817 | + $j=0; | |
| 1818 | + if(!empty($row)){ | |
| 1819 | + foreach ($row as $key => $value) { | |
| 1820 | + $row[ $key] = $wpdb->_real_escape( apply_filters( 'wpdbbkp_process_db_fields', $row[$key],$table,$key) ); | |
| 1821 | + $output .= ( isset( $row[ $key ] ) ) ? '"' . $row[ $key ] . '"' : '""'; | |
| 1822 | + if ( $j < ( $result_o_index - 1 ) ) { | |
| 1823 | + $output .= ','; | |
| 1824 | + } | |
| 1825 | + $j++; | |
| 1826 | + } | |
| 1827 | + } | |
| 1828 | + $output .= ");\n"; | |
| 1829 | + } | |
| 1830 | + $output .= "\n"; | |
| 1831 | + | |
| 1832 | + sleep(1); | |
| 1833 | + | |
| 1834 | + $wpdb->flush(); | |
| 1835 | + | |
| 1836 | + return $output; | |
| 1837 | + } | |
| 1838 | + | |
| 1839 | + /** | |
| 1840 | + * Mysql Dump set path. | |
| 1841 | + * | |
| 1842 | + * @param string $path - Path. | |
| 1843 | + */ | |
| 1844 | + public function set_mysqldump_command_path( $path ) { | |
| 1845 | + $this->mysqldump_command_path = $path; | |
| 1846 | + } | |
| 1847 | + | |
| 1848 | + /** | |
| 1849 | + * Mysql Dump get path. | |
| 1850 | + */ | |
| 1851 | + public function get_mysqldump_command_path() { | |
| 1852 | + | |
| 1853 | + // Check shell_exec is available. | |
| 1854 | + if ( ! self::is_shell_exec_available() ) { | |
| 1855 | + return ''; | |
| 1856 | + } | |
| 1857 | + | |
| 1858 | + // Return now if it's already been set. | |
| 1859 | + if ( isset( $this->mysqldump_command_path ) ) { | |
| 1860 | + return $this->mysqldump_command_path; | |
| 1861 | + } | |
| 1862 | + | |
| 1863 | + $this->mysqldump_command_path = ''; | |
| 1864 | + | |
| 1865 | + // Does mysqldump work. | |
| 1866 | + if ( is_null( shell_exec( 'hash mysqldump 2>&1' ) ) ) { // phpcs:ignore | |
| 1867 | + | |
| 1868 | + // If so store it for later. | |
| 1869 | + $this->set_mysqldump_command_path( 'mysqldump' ); | |
| 1870 | + | |
| 1871 | + // And return now. | |
| 1872 | + return $this->mysqldump_command_path; | |
| 1873 | + } | |
| 1874 | + | |
| 1875 | + // List of possible mysqldump locations. | |
| 1876 | + $mysqldump_locations = array( | |
| 1877 | + '/usr/local/bin/mysqldump', | |
| 1878 | + '/usr/local/mysql/bin/mysqldump', | |
| 1879 | + '/usr/mysql/bin/mysqldump', | |
| 1880 | + '/usr/bin/mysqldump', | |
| 1881 | + '/opt/local/lib/mysql6/bin/mysqldump', | |
| 1882 | + '/opt/local/lib/mysql5/bin/mysqldump', | |
| 1883 | + '/opt/local/lib/mysql4/bin/mysqldump', | |
| 1884 | + '/xwpdbbkpp/mysql/bin/mysqldump', | |
| 1885 | + '/Program Files/xwpdbbkpp/mysql/bin/mysqldump', | |
| 1886 | + '/Program Files/MySQL/MySQL Server 6.0/bin/mysqldump', | |
| 1887 | + '/Program Files/MySQL/MySQL Server 5.5/bin/mysqldump', | |
| 1888 | + '/Program Files/MySQL/MySQL Server 5.4/bin/mysqldump', | |
| 1889 | + '/Program Files/MySQL/MySQL Server 5.1/bin/mysqldump', | |
| 1890 | + '/Program Files/MySQL/MySQL Server 5.0/bin/mysqldump', | |
| 1891 | + '/Program Files/MySQL/MySQL Server 4.1/bin/mysqldump', | |
| 1892 | + ); | |
| 1893 | + | |
| 1894 | + // Find the one which works. | |
| 1895 | + foreach ( $mysqldump_locations as $location ) { | |
| 1896 | + if ( is_executable( self::conform_dir( $location ) ) ) { | |
| 1897 | + $this->set_mysqldump_command_path( $location ); | |
| 1898 | + } | |
| 1899 | + } | |
| 1900 | + | |
| 1901 | + return $this->mysqldump_command_path; | |
| 1902 | + } | |
| 1903 | + | |
| 1904 | + /** | |
| 1905 | + * Check dir. | |
| 1906 | + * | |
| 1907 | + * @param string $dir - Dir Details. | |
| 1908 | + * @param bool $recursive - Recursive. | |
| 1909 | + */ | |
| 1910 | + public static function conform_dir( $dir, $recursive = false ) { | |
| 1911 | + | |
| 1912 | + // Assume empty dir is root. | |
| 1913 | + if ( ! $dir ) { | |
| 1914 | + $dir = '/'; | |
| 1915 | + } | |
| 1916 | + | |
| 1917 | + // Replace single forward slash (looks like double slash because we have to escape it). | |
| 1918 | + $dir = str_replace( '\\', '/', $dir ); | |
| 1919 | + $dir = str_replace( '//', '/', $dir ); | |
| 1920 | + | |
| 1921 | + // Remove the trailing slash. | |
| 1922 | + if ( '/' !== $dir ) { | |
| 1923 | + $dir = untrailingslashit( $dir ); | |
| 1924 | + } | |
| 1925 | + | |
| 1926 | + // Carry on until completely normalized. | |
| 1927 | + if ( ! $recursive && self::conform_dir( $dir, true ) !== $dir ) { | |
| 1928 | + return self::conform_dir( $dir ); | |
| 1929 | + } | |
| 1930 | + | |
| 1931 | + return (string) $dir; | |
| 1932 | + } | |
| 1933 | + | |
| 1934 | + /** | |
| 1935 | + * Check Shell. | |
| 1936 | + */ | |
| 1937 | + public static function is_shell_exec_available() { | |
| 1938 | + | |
| 1939 | + // Are we in Safe Mode. | |
| 1940 | + if ( self::is_safe_mode_active() ) { | |
| 1941 | + return false; | |
| 1942 | + } | |
| 1943 | + | |
| 1944 | + // Is shell_exec or escapeshellcmd or escapeshellarg disabled? | |
| 1945 | + if ( array_intersect( array( 'shell_exec', 'escapeshellarg', 'escapeshellcmd' ), array_map( 'trim', explode( ',', ini_get( 'disable_functions' ) ) ) ) ) { | |
| 1946 | + return false; | |
| 1947 | + } | |
| 1948 | + | |
| 1949 | + // Can we issue a simple echo command? | |
| 1950 | + if ( ! shell_exec( 'echo WP Backup' ) ) { // phpcs:ignore | |
| 1951 | + return false; | |
| 1952 | + } | |
| 1953 | + | |
| 1954 | + return true; | |
| 1955 | + } | |
| 1956 | + | |
| 1957 | + /** | |
| 1958 | + * Check Safe mode active. | |
| 1959 | + * | |
| 1960 | + * @param string $ini_get_callback - String cmd. | |
| 1961 | + * @return bool | |
| 1962 | + */ | |
| 1963 | + public static function is_safe_mode_active( $ini_get_callback = 'ini_get' ) { | |
| 1964 | + $safe_mode = call_user_func( $ini_get_callback, 'safe_mode' ); | |
| 1965 | + if ( ( $safe_mode ) && 'off' !== strtolower( $safe_mode ) ) { | |
| 1966 | + return true; | |
| 1967 | + } | |
| 1968 | + | |
| 1969 | + return false; | |
| 1970 | + } | |
| 1971 | + | |
| 1972 | + /** | |
| 1973 | + * Database dump. | |
| 1974 | + * | |
| 1975 | + * @param string $sql_filename - File name. | |
| 1976 | + */ | |
| 1977 | + public function mysqldump( $sql_filename ) { | |
| 1978 | + $this->mysqldump_method = 'mysqldump'; | |
| 1979 | + | |
| 1980 | + $host = explode( ':', DB_HOST ); | |
| 1981 | + | |
| 1982 | + $host = reset( $host ); | |
| 1983 | + $port = strpos( DB_HOST, ':' ) ? end( explode( ':', DB_HOST ) ) : ''; | |
| 1984 | + | |
| 1985 | + // Path to the mysqldump executable. | |
| 1986 | + $cmd = escapeshellarg( $this->get_mysqldump_command_path() ); | |
| 1987 | + | |
| 1988 | + // We don't want to create a new DB. | |
| 1989 | + $cmd .= ' --no-create-db'; | |
| 1990 | + | |
| 1991 | + // Allow lock-tables to be overridden. | |
| 1992 | + if ( ! defined( 'WPDB_MYSQLDUMP_SINGLE_TRANSACTION' ) || WPDB_MYSQLDUMP_SINGLE_TRANSACTION !== false ) { | |
| 1993 | + $cmd .= ' --single-transaction'; | |
| 1994 | + } | |
| 1995 | + | |
| 1996 | + // Make sure binary data is exported properly. | |
| 1997 | + $cmd .= ' --hex-blob'; | |
| 1998 | + | |
| 1999 | + // Username. | |
| 2000 | + $cmd .= ' -u ' . escapeshellarg( DB_USER ); | |
| 2001 | + | |
| 2002 | + // Don't pass the password if it's blank. | |
| 2003 | + if ( DB_PASSWORD ) { | |
| 2004 | + $cmd .= ' -p' . escapeshellarg( DB_PASSWORD ); | |
| 2005 | + } | |
| 2006 | + | |
| 2007 | + // Set the host. | |
| 2008 | + $cmd .= ' -h ' . escapeshellarg( $host ); | |
| 2009 | + | |
| 2010 | + // Set the port if it was set. | |
| 2011 | + if ( ! empty( $port ) && is_numeric( $port ) ) { | |
| 2012 | + $cmd .= ' -P ' . $port; | |
| 2013 | + } | |
| 2014 | + | |
| 2015 | + // The file we're saving too. | |
| 2016 | + $cmd .= ' -r ' . escapeshellarg( $sql_filename ); | |
| 2017 | + | |
| 2018 | + $wp_db_exclude_table = array(); | |
| 2019 | + $wp_db_exclude_table = get_option( 'wp_db_exclude_table' ); | |
| 2020 | + if ( ! empty( $wp_db_exclude_table ) ) { | |
| 2021 | + foreach ( $wp_db_exclude_table as $wp_db_exclude_table ) { | |
| 2022 | + $cmd .= ' --ignore-table=' . DB_NAME . '.' . $wp_db_exclude_table; | |
| 2023 | + } | |
| 2024 | + } | |
| 2025 | + | |
| 2026 | + // The database we're dumping. | |
| 2027 | + $cmd .= ' ' . escapeshellarg( DB_NAME ); | |
| 2028 | + | |
| 2029 | + // Pipe STDERR to STDOUT. | |
| 2030 | + $cmd .= ' 2>&1'; | |
| 2031 | + // Store any returned data in an error. | |
| 2032 | + $stderr = shell_exec( $cmd ); // phpcs:ignore | |
| 2033 | + | |
| 2034 | + // Skip the new password warning that is output in mysql > 5.6. | |
| 2035 | + if ( trim( $stderr ) === 'Warning: Using a password on the command line interface can be insecure.' ) { | |
| 2036 | + $stderr = ''; | |
| 2037 | + } | |
| 2038 | + | |
| 2039 | + if ( $stderr ) { | |
| 2040 | + $this->error( $this->get_mysqldump_method(), $stderr ); | |
| 2041 | + } | |
| 2042 | + | |
| 2043 | + return $this->verify_mysqldump( $sql_filename ); | |
| 2044 | + } | |
| 2045 | + | |
| 2046 | + /** | |
| 2047 | + * Error. | |
| 2048 | + * | |
| 2049 | + * @param string $context - Data. | |
| 2050 | + * @param object $error - Error data. | |
| 2051 | + */ | |
| 2052 | + public function error( $context, $error ) { | |
| 2053 | + if ( empty( $context ) || empty( $error ) ) { | |
| 2054 | + return; | |
| 2055 | + } | |
| 2056 | + $error_str = implode( ':', (array) $error ); | |
| 2057 | + $_key = md5( $error_str ); | |
| 2058 | + $this->errors[ $context ][ $_key ] = $error; | |
| 2059 | + } | |
| 2060 | + | |
| 2061 | + /** | |
| 2062 | + * Verify Dump. | |
| 2063 | + * | |
| 2064 | + * @param string $sql_filename - Sql file. | |
| 2065 | + * @return bool | |
| 2066 | + */ | |
| 2067 | + public function verify_mysqldump( $sql_filename ) { | |
| 2068 | + | |
| 2069 | + // If we've already passed then no need to check again. | |
| 2070 | + if ( ! empty( $this->mysqldump_verified ) ) { | |
| 2071 | + return true; | |
| 2072 | + } | |
| 2073 | + | |
| 2074 | + // If there are mysqldump errors delete the database dump file as mysqldump will still have written one. | |
| 2075 | + if ( $this->get_errors( $this->get_mysqldump_method() ) && file_exists( $sql_filename ) ) { | |
| 2076 | + if ( file_exists( $sql_filename ) ) { | |
| 2077 | + unlink( $sql_filename ); | |
| 2078 | + } | |
| 2079 | + } | |
| 2080 | + | |
| 2081 | + // If we have an empty file delete it. | |
| 2082 | + if ( 0 === filesize( $sql_filename ) ) { | |
| 2083 | + if ( file_exists( $sql_filename ) ) { | |
| 2084 | + unlink( $sql_filename ); | |
| 2085 | + } | |
| 2086 | + } | |
| 2087 | + | |
| 2088 | + // If the file still exists then it must be good. | |
| 2089 | + if ( file_exists( $sql_filename ) ) { | |
| 2090 | + $this->mysqldump_verified = true; | |
| 2091 | + return $this->mysqldump_verified; | |
| 2092 | + } | |
| 2093 | + | |
| 2094 | + return false; | |
| 2095 | + } | |
| 2096 | + | |
| 2097 | + /** | |
| 2098 | + * Get error. | |
| 2099 | + * | |
| 2100 | + * @param string $context - Data. | |
| 2101 | + * @return string | |
| 2102 | + */ | |
| 2103 | + public function get_errors( $context = null ) { | |
| 2104 | + if ( ! empty( $context ) ) { | |
| 2105 | + return isset( $this->errors[ $context ] ) ? $this->errors[ $context ] : array(); | |
| 2106 | + } | |
| 2107 | + | |
| 2108 | + return $this->errors; | |
| 2109 | + } | |
| 2110 | + | |
| 2111 | + /** | |
| 2112 | + * Get mysql dump method. | |
| 2113 | + * | |
| 2114 | + * @return string | |
| 2115 | + */ | |
| 2116 | + public function get_mysqldump_method() { | |
| 2117 | + return $this->mysqldump_method; | |
| 2118 | + } | |
| 2119 | + | |
| 2120 | + // End : Generate SQL DUMP using cmd 06-03-2016. | |
| 2121 | + | |
| 2122 | + /** | |
| 2123 | + * Create zip. | |
| 2124 | + */ | |
| 2125 | + public function wp_db_backup_create_archive() { | |
| 2126 | + // Begin : Setup Upload Directory, Secure it and generate a random file name. | |
| 2127 | + | |
| 2128 | + $source_directory = $this->wp_db_backup_wp_config_path(); | |
| 2129 | + | |
| 2130 | + $path_info = wp_upload_dir(); | |
| 2131 | + $htasses_text = ''; | |
| 2132 | + wp_mkdir_p($path_info['basedir'] . '/' . WPDB_BACKUPS_DIR); | |
| 2133 | + wp_mkdir_p($path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/log'); | |
| 2134 | + fclose(fopen($path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/index.php', 'w')); | |
| 2135 | + fclose(fopen($path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/log/index.php', 'w')); | |
| 2136 | + // Added htaccess file 08-05-2015 for prevent directory listing. | |
| 2137 | + // Fixed Vulnerability 22-06-2016 for prevent direct download. | |
| 2138 | + if ( 1 === (int) get_option( 'wp_db_backup_enable_htaccess' ) ) { | |
| 2139 | + $f = fopen( $path_info['basedir'] . '/db-backup/.htaccess', 'w' ); // phpcs:ignore | |
| 2140 | + fwrite( // phpcs:ignore | |
| 2141 | + $f, | |
| 2142 | + '#These next two lines will already exist in your .htaccess file | |
| 2143 | + RewriteEngine On | |
| 2144 | + RewriteBase / | |
| 2145 | + # Add these lines right after the preceding two | |
| 2146 | + RewriteCond %{REQUEST_FILENAME} ^.*(.zip)$ | |
| 2147 | + RewriteCond %{HTTP_COOKIE} !^.*can_download.*$ [NC] | |
| 2148 | + RewriteRule . - [R=403,L]' | |
| 2149 | + ); // phpcs:ignore | |
| 2150 | + fclose( $f ); // phpcs:ignore | |
| 2151 | + } | |
| 2152 | + // Begin : Generate SQL DUMP and save to file database.sql. | |
| 2153 | + $wp_site_name = preg_replace('/[^\p{L}\p{M}]+/u', '_', get_bloginfo('name')); | |
| 2154 | + $wp_db_file_name = $wp_site_name . '_' . date( 'Y_m_d' ) . '_' . time() . '_' . substr( md5( AUTH_KEY ), 0, 7 ) . '_wpdb'; | |
| 2155 | + $sql_filename = $wp_db_file_name . '.sql'; | |
| 2156 | + $filename = $wp_db_file_name . '.zip'; | |
| 2157 | + $logname = $wp_db_file_name . '.txt'; | |
| 2158 | + | |
| 2159 | + // Begin : Generate SQL DUMP using cmd 06-03-2016. | |
| 2160 | + $my_sql_dump = 0; | |
| 2161 | + if ( $this->get_mysqldump_command_path() ) { | |
| 2162 | + if ( ! $this->mysqldump( $path_info['basedir'] . '/db-backup/' . $sql_filename ) ) { | |
| 2163 | + $my_sql_dump = 1; | |
| 2164 | + } | |
| 2165 | + } else { | |
| 2166 | + $my_sql_dump = 1; | |
| 2167 | + } | |
| 2168 | + | |
| 2169 | + if ( 1 === (int) $my_sql_dump ) { | |
| 2170 | + /* BEGIN : Prevent saving backup plugin settings in the database dump */ | |
| 2171 | + $options_backup = get_option( 'wp_db_backup_backups' ); | |
| 2172 | + $settings_backup = get_option( 'wp_db_backup_options' ); | |
| 2173 | + delete_option( 'wp_db_backup_backups' ); | |
| 2174 | + delete_option( 'wp_db_backup_options' ); | |
| 2175 | + /* END : Prevent saving backup plugin settings in the database dump */ | |
| 2176 | + global $wpdb; | |
| 2177 | + $tables = $wpdb->get_col( 'SHOW TABLES' ); | |
| 2178 | + $wp_db_exclude_table = get_option( 'wp_db_exclude_table',array()); | |
| 2179 | + if(!empty($tables)){ | |
| 2180 | + foreach($tables as $table){ | |
| 2181 | + if ( empty( $wp_db_exclude_table ) || ( ! ( in_array( $table, $wp_db_exclude_table, true ) ) ) ) { | |
| 2182 | + $handle = fopen( $path_info['basedir'] . '/db-backup/' . $sql_filename, 'a' ); // phpcs:ignore | |
| 2183 | + fwrite( $handle, $this->wp_db_backup_create_mysql_backup_new($table) ); // phpcs:ignore | |
| 2184 | + fclose( $handle ); // phpcs:ignore | |
| 2185 | + | |
| 2186 | + } | |
| 2187 | + } | |
| 2188 | + } | |
| 2189 | + /* BEGIN : Prevent saving backup plugin settings in the database dump */ | |
| 2190 | + add_option( 'wp_db_backup_backups', $options_backup ); | |
| 2191 | + add_option( 'wp_db_backup_options', $settings_backup ); | |
| 2192 | + /* END : Prevent saving backup plugin settings in the database dump */ | |
| 2193 | + } | |
| 2194 | + /* End : Generate SQL DUMP using cmd 06-03-2016 */ | |
| 2195 | + | |
| 2196 | + $wp_db_backup_search_text = get_option( 'wp_db_backup_search_text' ); | |
| 2197 | + $wp_db_backup_replace_text = get_option( 'wp_db_backup_replace_text' ); | |
| 2198 | + if ( ( false === empty( $wp_db_backup_search_text ) ) && ( false === empty( $wp_db_backup_replace_text ) ) ) { | |
| 2199 | + $filecontent = wp_remote_get( $path_info['basedir'] . '/db-backup/' . $sql_filename ); | |
| 2200 | + if (! is_wp_error( $filecontent ) && isset($filecontent['body']) ) { | |
| 2201 | + $backup_str = str_replace( $wp_db_backup_search_text, $wp_db_backup_replace_text, $filecontent['body'] ); // phpcs:ignore | |
| 2202 | + file_put_contents( $path_info['basedir'] . '/db-backup/' . $sql_filename, $backup_str ); // phpcs:ignore | |
| 2203 | + } | |
| 2204 | + } | |
| 2205 | + | |
| 2206 | + /* End : Generate SQL DUMP and save to file database.sql */ | |
| 2207 | + $upload_path = array( | |
| 2208 | + 'filename' => ( $filename ), | |
| 2209 | + 'dir' => ( $path_info['basedir'] . '/db-backup/' . $filename ), | |
| 2210 | + 'url' => ( $path_info['baseurl'] . '/db-backup/' . $filename ), | |
| 2211 | + 'log_dir' => ( $path_info['basedir'] . '/db-backup/log/' . $logname ), | |
| 2212 | + 'log_url' => ( $path_info['baseurl'] . '/db-backup/log/' . $logname ), | |
| 2213 | + 'size' => 0, | |
| 2214 | + ); | |
| 2215 | + $arcname = $path_info['basedir'] . '/db-backup/' . $wp_db_file_name . '.zip'; | |
| 2216 | + if ( class_exists( 'ZipArchive' ) ) { | |
| 2217 | + $zip = new ZipArchive(); | |
| 2218 | + $zip->open( $arcname, ZipArchive::CREATE ); | |
| 2219 | + $zip->addFile( $path_info['basedir'] . '/db-backup/' . $sql_filename, $sql_filename ); | |
| 2220 | + $zip->close(); | |
| 2221 | + } else { | |
| 2222 | + require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; | |
| 2223 | + $archive = new PclZip( $arcname ); | |
| 2224 | + $v_dir = $path_info['basedir'] . '/db-backup/' . $sql_filename; | |
| 2225 | + $v_remove = $path_info['basedir'] . '/db-backup'; | |
| 2226 | + // Create the archive. | |
| 2227 | + $v_list = $archive->create( $v_dir, PCLZIP_OPT_REMOVE_PATH, $v_remove ); | |
| 2228 | + } | |
| 2229 | + | |
| 2230 | + global $wpdb; | |
| 2231 | + $mysqlversion = wp_cache_get( 'wpdb_mysqlversion' ); | |
| 2232 | + if ( true === empty( $mysqlversion ) ) { | |
| 2233 | + $mysqlversion = $wpdb->get_var( 'SELECT VERSION() AS version' ); // phpcs:ignore | |
| 2234 | + wp_cache_set( 'wpdb_mysqlversion', $mysqlversion, '', 18000 ); | |
| 2235 | + } | |
| 2236 | + if ( ! function_exists( 'get_plugins' ) ) { | |
| 2237 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
| 2238 | + } | |
| 2239 | + $my_theme = wp_get_theme(); | |
| 2240 | + $active_plugin = count(get_option('active_plugins')); | |
| 2241 | + $total_plugin = count(get_plugins()); | |
| 2242 | + $log_message = '<b>WordPress Version</b> : ' . get_bloginfo( 'version' ); | |
| 2243 | + $log_message .= '<br> <b>Database Version</b> : ' . $mysqlversion; | |
| 2244 | + $log_message .= '<br> <b>Active Theme Name</b> : ' . $my_theme->get( 'Name' ); | |
| 2245 | + $log_message .= '<br> <b>Theme Version</b> : ' . $my_theme->get( 'Version' ); | |
| 2246 | + $log_message .= '<br> <b>Plugin Count</b> : ' . $total_plugin; | |
| 2247 | + $log_message .= '<br> <b>Active Plugins</b> : ' . $active_plugin; | |
| 2248 | + | |
| 2249 | + $upload_path['size'] = filesize( $upload_path['dir'] ); | |
| 2250 | + $upload_path['sqlfile'] = $path_info['basedir'] . '/db-backup/' . $sql_filename; | |
| 2251 | + $wp_db_log = get_option( 'wp_db_log' ); | |
| 2252 | + if ( 1 === (int) $wp_db_log ) { | |
| 2253 | + $wp_db_exclude_table = get_option( 'wp_db_exclude_table' ); | |
| 2254 | + if ( ! empty( $wp_db_exclude_table ) ) { | |
| 2255 | + $log_message .= '<br> <b>Exclude Table</b> : ' . implode( ', ', $wp_db_exclude_table ); | |
| 2256 | + } | |
| 2257 | + $upload_path['log'] = $log_message; | |
| 2258 | + } | |
| 2259 | + $options = get_option( 'wp_db_backup_backups' ); | |
| 2260 | + $newoptions = array(); | |
| 2261 | + $number_of_existing_backups = count( (array) $options ); | |
| 2262 | + $number_of_backups_from_user = get_option( 'wp_local_db_backup_count' ); | |
| 2263 | + if ( ! empty( $number_of_backups_from_user ) ) { | |
| 2264 | + if ( ! ( $number_of_existing_backups < $number_of_backups_from_user ) ) { | |
| 2265 | + $diff = $number_of_existing_backups - $number_of_backups_from_user; | |
| 2266 | + for ( $i = 0; $i <= $diff; $i++ ) { | |
| 2267 | + $index = $i; | |
| 2268 | + if ( file_exists( $options[ $index ]['dir'] ) ) { | |
| 2269 | + unlink( $options[ $index ]['dir'] ); | |
| 2270 | + } | |
| 2271 | + $file_sql = explode( '.', $options[ $index ]['dir'] ); | |
| 2272 | + if ( file_exists( $file_sql[0] . '.sql' ) ) { | |
| 2273 | + unlink( $file_sql[0] . '.sql' ); | |
| 2274 | + } | |
| 2275 | + } | |
| 2276 | + for ( $i = ( $diff + 1 ); $i < $number_of_existing_backups; $i++ ) { | |
| 2277 | + $index = $i; | |
| 2278 | + | |
| 2279 | + $newoptions[] = $options[ $index ]; | |
| 2280 | + } | |
| 2281 | + | |
| 2282 | + update_option( 'wp_db_backup_backups', $newoptions , false); | |
| 2283 | + } | |
| 2284 | + } | |
| 2285 | + | |
| 2286 | + if ( file_exists( $path_info['basedir'] . '/db-backup/' . $sql_filename ) ) { | |
| 2287 | + unlink( $path_info['basedir'] . '/db-backup/' . $sql_filename ); | |
| 2288 | + } | |
| 2289 | + return $upload_path; | |
| 2290 | + } | |
| 2291 | + | |
| 2292 | + /** | |
| 2293 | + * Config Path. | |
| 2294 | + */ | |
| 2295 | + public function wp_db_backup_wp_config_path() { | |
| 2296 | + $base = dirname( __FILE__ ); | |
| 2297 | + $path = false; | |
| 2298 | + if ( file_exists( dirname( dirname( $base ) ) . '/wp-config.php' ) ) { | |
| 2299 | + $path = dirname( dirname( $base ) ); | |
| 2300 | + } else { | |
| 2301 | + if ( file_exists( dirname( dirname( dirname( $base ) ) ) . '/wp-config.php' ) ) { | |
| 2302 | + $path = dirname( dirname( dirname( $base ) ) ); | |
| 2303 | + } else { | |
| 2304 | + $path = false; | |
| 2305 | + } | |
| 2306 | + } | |
| 2307 | + if ( false !== $path ) { | |
| 2308 | + $path = str_replace( '\\', '/', $path ); | |
| 2309 | + } | |
| 2310 | + return $path; | |
| 2311 | + } | |
| 2312 | + | |
| 2313 | + /** | |
| 2314 | + * Backup Process. | |
| 2315 | + */ | |
| 2316 | + public function wp_db_backup_event_process() { | |
| 2317 | + // Added in v.3.9.5! | |
| 2318 | + | |
| 2319 | + $cron_condition = apply_filters('wpdbbkp_dbback_cron_condition',true ); | |
| 2320 | + if(wp_doing_cron() && !$cron_condition){ | |
| 2321 | + wp_die(); | |
| 2322 | + } | |
| 2323 | + | |
| 2324 | + set_time_limit( 0 ); | |
| 2325 | + ignore_user_abort(true); | |
| 2326 | + | |
| 2327 | + $details = $this->wp_db_backup_create_archive(); | |
| 2328 | + $options = get_option( 'wp_db_backup_backups' ); | |
| 2329 | + | |
| 2330 | + if ( ! $options ) { | |
| 2331 | + $options = array(); | |
| 2332 | + } | |
| 2333 | + $is_search_replace_flag = 0; | |
| 2334 | + $wp_db_log = get_option( 'wp_db_log' ); | |
| 2335 | + if ( 1 === (int) $wp_db_log ) { | |
| 2336 | + $log_message = $details['log']; | |
| 2337 | + $wp_db_backup_search_text = get_option( 'wp_db_backup_search_text' ); | |
| 2338 | + $wp_db_backup_replace_text = get_option( 'wp_db_backup_replace_text' ); | |
| 2339 | + if ( ( false === empty( $wp_db_backup_search_text ) ) && ( false === empty( $wp_db_backup_replace_text ) ) ) { | |
| 2340 | + $log_message .= ' Replaced/Search text - ' . $wp_db_backup_search_text . ' With -' . $wp_db_backup_replace_text; | |
| 2341 | + $is_search_replace_flag = 1; | |
| 2342 | + } | |
| 2343 | + } else { | |
| 2344 | + $log_message = ''; | |
| 2345 | + } | |
| 2346 | + $wp_db_remove_local_backup = get_option( 'wp_db_remove_local_backup' ); | |
| 2347 | + $destination = ( 1 === (int) $wp_db_remove_local_backup ) ? '' : 'Local, '; | |
| 2348 | + | |
| 2349 | + $args = array( $details['filename'], $details['dir'], $log_message, $details['size'], $destination ); | |
| 2350 | + do_action_ref_array( 'wp_db_backup_completed', array( &$args ) ); | |
| 2351 | + | |
| 2352 | + $options[] = array( | |
| 2353 | + 'date' => time(), | |
| 2354 | + 'filename' => $details['filename'], | |
| 2355 | + 'url' => $details['url'], | |
| 2356 | + 'dir' => $details['dir'], | |
| 2357 | + 'log' => $details['log_url'], | |
| 2358 | + 'search_replace' => $is_search_replace_flag, | |
| 2359 | + 'sqlfile' => $details['sqlfile'], | |
| 2360 | + 'size' => $details['size'], | |
| 2361 | + 'type' =>'database', | |
| 2362 | + 'destination' => $args[4] | |
| 2363 | + ); | |
| 2364 | + if ( 1 !== (int) $wp_db_remove_local_backup ) { | |
| 2365 | + update_option( 'wp_db_backup_backups', $options , false); | |
| 2366 | + } | |
| 2367 | + if(isset($details['log_dir']) && !empty($details['log_dir'])) | |
| 2368 | + { | |
| 2369 | + if (is_writable($details['log_dir']) || !file_exists($details['log_dir'])) { | |
| 2370 | + | |
| 2371 | + if ($handle = @fopen($details['log_dir'], 'a')) | |
| 2372 | + { | |
| 2373 | + if (fwrite($handle, str_replace(array("<br>","<b>","</b>"), array("\n","",""), $args[2]))) | |
| 2374 | + { | |
| 2375 | + fclose($handle); | |
| 2376 | + } | |
| 2377 | + } | |
| 2378 | + | |
| 2379 | + } | |
| 2380 | + } | |
| 2381 | + } | |
| 2382 | + | |
| 2383 | + /** | |
| 2384 | + * Cron schedule. | |
| 2385 | + * | |
| 2386 | + * @param array $schedules - Schedules details. | |
| 2387 | + */ | |
| 2388 | + public function wp_db_backup_cron_schedules( $schedules ) { | |
| 2389 | + $schedules['hourly'] = array( | |
| 2390 | + 'interval' => 3600, | |
| 2391 | + 'display' => 'hourly', | |
| 2392 | + ); | |
| 2393 | + $schedules['twicedaily'] = array( | |
| 2394 | + 'interval' => 43200, | |
| 2395 | + 'display' => 'twicedaily', | |
| 2396 | + ); | |
| 2397 | + $schedules['daily'] = array( | |
| 2398 | + 'interval' => 86400, | |
| 2399 | + 'display' => 'daily', | |
| 2400 | + ); | |
| 2401 | + $schedules['weekly'] = array( | |
| 2402 | + 'interval' => 604800, | |
| 2403 | + 'display' => 'Once Weekly', | |
| 2404 | + ); | |
| 2405 | + $schedules['monthly'] = array( | |
| 2406 | + 'interval' => 2635200, | |
| 2407 | + 'display' => 'Once a month', | |
| 2408 | + ); | |
| 2409 | + return $schedules; | |
| 2410 | + } | |
| 2411 | + | |
| 2412 | + /** | |
| 2413 | + * Schedular activation. | |
| 2414 | + */ | |
| 2415 | + public function wp_db_backup_scheduler_activation() { | |
| 2416 | + $options = get_option( 'wp_db_backup_options' ); | |
| 2417 | + if ( ( ! wp_next_scheduled( 'wp_db_backup_event' ) ) && ( true === isset( $options['enable_autobackups'] ) ) ) { | |
| 2418 | + $cron_freq = apply_filters( 'wpdbbkp_dbback_cron_frequency',$options['autobackup_frequency']); | |
| 2419 | + wp_schedule_event( time(), $cron_freq, 'wp_db_backup_event' ); | |
| 2420 | + } | |
| 2421 | + } | |
| 2422 | + | |
| 2423 | + /** | |
| 2424 | + * Config data. | |
| 2425 | + * | |
| 2426 | + * @param string $key - key name. | |
| 2427 | + */ | |
| 2428 | + public function wp_backup_get_config_data( $key ) { | |
| 2429 | + $filepath = get_home_path() . '/wp-config.php'; | |
| 2430 | + $config_file = file_get_contents( "$filepath", true ); | |
| 2431 | + if($config_file){ | |
| 2432 | + switch ( $key ) { | |
| 2433 | + case 'DB_NAME': | |
| 2434 | + preg_match( "/'DB_NAME',\s*'(.*)?'/", $config_file, $matches ); | |
| 2435 | + break; | |
| 2436 | + case 'DB_USER': | |
| 2437 | + preg_match( "/'DB_USER',\s*'(.*)?'/", $config_file, $matches ); | |
| 2438 | + break; | |
| 2439 | + case 'DB_PASSWORD': | |
| 2440 | + preg_match( "/'DB_PASSWORD',\s*'(.*)?'/", $config_file, $matches ); | |
| 2441 | + break; | |
| 2442 | + case 'DB_HOST': | |
| 2443 | + preg_match( "/'DB_HOST',\s*'(.*)?'/", $config_file, $matches ); | |
| 2444 | + break; | |
| 2445 | + } | |
| 2446 | + return $matches[1]; | |
| 2447 | + } | |
| 2448 | + | |
| 2449 | + return ''; | |
| 2450 | + | |
| 2451 | + } | |
| 2452 | + | |
| 2453 | + /** | |
| 2454 | + * Get db name from config. | |
| 2455 | + */ | |
| 2456 | + public function wp_backup_get_config_db_name() { | |
| 2457 | + $filepath = get_home_path() . '/wp-config.php'; | |
| 2458 | + $config_file = file_get_contents( "$filepath", true ); | |
| 2459 | + if($config_file){ | |
| 2460 | + preg_match( "/'DB_NAME',\s*'(.*)?'/", $config_file, $matches ); | |
| 2461 | + return $matches[1]; | |
| 2462 | + } | |
| 2463 | + return ''; | |
| 2464 | + } | |
| 2465 | + | |
| 2466 | + /** | |
| 2467 | + * Recursive sanitation for an array | |
| 2468 | + * | |
| 2469 | + * @param array $array - Array data to sanitize. | |
| 2470 | + * | |
| 2471 | + * @return mixed | |
| 2472 | + */ | |
| 2473 | + public function recursive_sanitize_text_field( $array ) { | |
| 2474 | + foreach ( $array as $key => &$value ) { | |
| 2475 | + if ( is_array( $value ) ) { | |
| 2476 | + $value = $this->recursive_sanitize_text_field( $value ); | |
| 2477 | + } else { | |
| 2478 | + $value = sanitize_text_field( $value ); | |
| 2479 | + } | |
| 2480 | + } | |
| 2481 | + | |
| 2482 | + return $array; | |
| 2483 | + } | |
| 2484 | + | |
| 2485 | + /** | |
| 2486 | + * Enqueue scripts and style | |
| 2487 | + */ | |
| 2488 | + public function admin_scripts_style() { | |
| 2489 | + if ( true === $this->is_wpdb_page() ) { | |
| 2490 | + wp_enqueue_script( 'jquery' ); | |
| 2491 | + | |
| 2492 | + wp_register_script( 'bootstrapjs', WPDB_PLUGIN_URL . '/assets/js/bootstrap.min.js', array( 'jquery' ), WPDB_VERSION, false ); | |
| 2493 | + wp_enqueue_script( 'bootstrapjs' ); | |
| 2494 | + | |
| 2495 | + wp_register_style( 'bootstrapcss', WPDB_PLUGIN_URL . '/assets/css/bootstrap.min.css', array(), WPDB_VERSION ); | |
| 2496 | + wp_enqueue_style( 'bootstrapcss' ); | |
| 2497 | + | |
| 2498 | + wp_register_script( 'dataTablesjs', WPDB_PLUGIN_URL . '/assets/js/jquery.dataTables.js', array( 'jquery' ), WPDB_VERSION, false ); | |
| 2499 | + wp_enqueue_script( 'dataTablesjs' ); | |
| 2500 | + | |
| 2501 | + wp_register_style( 'dataTablescss', WPDB_PLUGIN_URL . '/assets/css/jquery.dataTables.css', array(), WPDB_VERSION ); | |
| 2502 | + wp_enqueue_style( 'dataTablescss' ); | |
| 2503 | + | |
| 2504 | + wp_register_style( 'wpdbcss', WPDB_PLUGIN_URL . '/assets/css/wpdb_admin.css', array(), WPDB_VERSION ); | |
| 2505 | + wp_enqueue_style( 'wpdbcss' ); | |
| 2506 | + } | |
| 2507 | + } | |
| 2508 | + | |
| 2509 | + /** | |
| 2510 | + * Check is plugin page. | |
| 2511 | + */ | |
| 2512 | + public function is_wpdb_page() { | |
| 2513 | + | |
| 2514 | + if ( is_admin() ) { | |
| 2515 | + | |
| 2516 | + return isset( $_REQUEST['page'] ) && preg_match( '/wp-database-backup/', $_REQUEST['page'] ) ? true : false; // phpcs:ignore | |
| 2517 | + | |
| 2518 | + } else { | |
| 2519 | + | |
| 2520 | + return true; | |
| 2521 | + } | |
| 2522 | + } | |
| 2523 | + | |
| 2524 | + // loading admin scripts/styles on admin page only | |
| 2525 | + | |
| 2526 | + public function wpdbbkp_admin_style($hook_suffix) | |
| 2527 | + { | |
| 2528 | + if($hook_suffix=="tools_page_wp-database-backup" || $hook_suffix=="toplevel_page_wp-database-backup") | |
| 2529 | + { | |
| 2530 | + wp_register_script('wpdbbkp-admin-script', WPDB_PLUGIN_URL . '/assets/js/wpdbbkp-admin.js', array('jquery'), WPDB_VERSION, 'true' ); | |
| 2531 | + wp_localize_script('wpdbbkp-admin-script', 'wpdbbkp_script_vars', array( | |
| 2532 | + 'nonce' => wp_create_nonce( 'wpdbbkp-admin-nonce' ), | |
| 2533 | + )); | |
| 2534 | + wp_enqueue_script('wpdbbkp-admin-script'); | |
| 2535 | + | |
| 2536 | + // Adding custom js | |
| 2537 | + $local = array( | |
| 2538 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), | |
| 2539 | + 'wpdbbkp_admin_security_nonce' => wp_create_nonce('wpdbbkp_ajax_check_nonce'), | |
| 2540 | + ); | |
| 2541 | + wp_register_script('wpdbbkp-admin-fb', WPDB_PLUGIN_URL . '/assets/js/wpdbbkp-admin-cron-backup.js', array(), WPDB_VERSION , true ); | |
| 2542 | + | |
| 2543 | + wp_localize_script('wpdbbkp-admin-fb', 'wpdbbkp_localize_admin_data', $local ); | |
| 2544 | + wp_enqueue_script('wpdbbkp-admin-fb'); | |
| 2545 | + // Custom Js ends | |
| 2546 | + } | |
| 2547 | + } | |
| 2548 | + | |
| 2549 | + public function wpdbbkp_admin_newsletter_script($hook_suffix ) { | |
| 2550 | + if($hook_suffix=="tools_page_wp-database-backup" || $hook_suffix=="toplevel_page_wp-database-backup") | |
| 2551 | + { | |
| 2552 | + wp_enqueue_script('wpdbbkp-admin-newsletter-script', WPDB_PLUGIN_URL . '/assets/js/wpdbbkp-admin-newsletter.js', array('jquery'), WPDB_VERSION, 'true' ); | |
| 2553 | + | |
| 2554 | + $current_screen = get_current_screen(); | |
| 2555 | + | |
| 2556 | + if(isset($current_screen->post_type)){ | |
| 2557 | + $post_type = $current_screen->post_type; | |
| 2558 | + } | |
| 2559 | + | |
| 2560 | + $post_id = get_the_ID(); | |
| 2561 | + if(isset($_GET['tag_ID'])){ | |
| 2562 | + $post_id = intval($_GET['tag_ID']); | |
| 2563 | + } | |
| 2564 | + | |
| 2565 | + | |
| 2566 | + | |
| 2567 | + $data = array( | |
| 2568 | + 'current_url' => wpdbbkp_get_current_url(), | |
| 2569 | + 'post_id' => $post_id, | |
| 2570 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), | |
| 2571 | + 'post_type' => $post_type, | |
| 2572 | + 'page_now' => $hook_suffix, | |
| 2573 | + 'wpdbbkp_security_nonce' => wp_create_nonce('wpdbbkp_ajax_check_nonce'), | |
| 2574 | + ); | |
| 2575 | + | |
| 2576 | + $data = apply_filters('wpdbbkp_localize_filter',$data,'wpdbbkp_localize_data'); | |
| 2577 | + | |
| 2578 | + wp_localize_script( 'wpdbbkp-admin-newsletter-script', 'wpdbbkp_localize_data', $data ); | |
| 2579 | + | |
| 2580 | + } | |
| 2581 | + | |
| 2582 | + } | |
| 2583 | + | |
| 2584 | + public function wpdbbkp_sanitize_textarea_field( $str ) { | |
| 2585 | + | |
| 2586 | + if ( is_object( $str ) || is_array( $str ) ) { | |
| 2587 | + return ''; | |
| 2588 | + } | |
| 2589 | + | |
| 2590 | + $str = (string) $str; | |
| 2591 | + | |
| 2592 | + $filtered = wp_check_invalid_utf8( $str ); | |
| 2593 | + | |
| 2594 | + if ( strpos( $filtered, '<' ) !== false ) { | |
| 2595 | + $filtered = wp_pre_kses_less_than( $filtered ); | |
| 2596 | + // This will strip extra whitespace for us. | |
| 2597 | + $filtered = wp_strip_all_tags( $filtered, false ); | |
| 2598 | + | |
| 2599 | + // Use HTML entities in a special case to make sure no later | |
| 2600 | + // newline stripping stage could lead to a functional tag. | |
| 2601 | + $filtered = str_replace( "<\n", "<\n", $filtered ); | |
| 2602 | + } | |
| 2603 | + | |
| 2604 | + $filtered = trim( $filtered ); | |
| 2605 | + | |
| 2606 | + $found = false; | |
| 2607 | + while ( preg_match( '/%[a-f0-9]{2}/i', $filtered, $match ) ) { | |
| 2608 | + $filtered = str_replace( $match[0], '', $filtered ); | |
| 2609 | + $found = true; | |
| 2610 | + } | |
| 2611 | + | |
| 2612 | + if ( $found ) { | |
| 2613 | + // Strip out the whitespace that may now exist after removing the octets. | |
| 2614 | + $filtered = trim( preg_replace( '/ +/', ' ', $filtered ) ); | |
| 2615 | + } | |
| 2616 | + | |
| 2617 | + return $filtered; | |
| 2618 | + } | |
| 2619 | + | |
| 2620 | + public function wpdbbkp_send_query_message(){ | |
| 2621 | + | |
| 2622 | + if ( ! isset( $_POST['wpdbbkp_security_nonce'] ) ){ | |
| 2623 | + return; | |
| 2624 | + } | |
| 2625 | + if ( !wp_verify_nonce( $_POST['wpdbbkp_security_nonce'], 'wpdbbkp-admin-nonce' ) ){ | |
| 2626 | + return; | |
| 2627 | + } | |
| 2628 | + | |
| 2629 | + if( ! current_user_can( 'manage_options' ) ) { | |
| 2630 | + return; | |
| 2631 | + } | |
| 2632 | + | |
| 2633 | + $message = $this->wpdbbkp_sanitize_textarea_field($_POST['message']); | |
| 2634 | + $email = $this->wpdbbkp_sanitize_textarea_field($_POST['email']); | |
| 2635 | + | |
| 2636 | + if(function_exists('wp_get_current_user')){ | |
| 2637 | + | |
| 2638 | + $user = wp_get_current_user(); | |
| 2639 | + | |
| 2640 | + $message = '<p>'.$message.'</p><br><br>'.'Query from BackupforWP plugin support tab'; | |
| 2641 | + | |
| 2642 | + $user_data = $user->data; | |
| 2643 | + $user_email = $user_data->user_email; | |
| 2644 | + | |
| 2645 | + if($email){ | |
| 2646 | + $user_email = $email; | |
| 2647 | + } | |
| 2648 | + //php mailer variables | |
| 2649 | + $sendto = 'team@magazine3.in'; | |
| 2650 | + $subject = "BackupforWP Query"; | |
| 2651 | + | |
| 2652 | + $headers[] = 'Content-Type: text/html; charset=UTF-8'; | |
| 2653 | + $headers[] = 'From: '. esc_attr($user_email); | |
| 2654 | + $headers[] = 'Reply-To: ' . esc_attr($user_email); | |
| 2655 | + // Load WP components, no themes. | |
| 2656 | + | |
| 2657 | + $sent = wp_mail($sendto, $subject, $message, $headers); | |
| 2658 | + | |
| 2659 | + if($sent){ | |
| 2660 | + | |
| 2661 | + echo wp_json_encode(array('status'=>'t')); | |
| 2662 | + | |
| 2663 | + }else{ | |
| 2664 | + | |
| 2665 | + echo wp_json_encode(array('status'=>'f')); | |
| 2666 | + | |
| 2667 | + } | |
| 2668 | + | |
| 2669 | + } | |
| 2670 | + | |
| 2671 | + wp_die(); | |
| 2672 | + } | |
| 2673 | + public function add_settings_plugin_action_wp( $actions, $plugin_file, $plugin_data, $context ) { | |
| 2674 | + $plugin_actions['settings'] = sprintf( | |
| 2675 | + '<a href="%s">' . _x( 'Settings', 'wpdbbkp' ) . '</a>', | |
| 2676 | + admin_url( 'options-general.php?page=wp-database-backup' ) | |
| 2677 | + ); | |
| 2678 | + $actions = array_merge( $actions, $plugin_actions ); | |
| 2679 | + return $actions; | |
| 2680 | + } | |
| 2681 | + | |
| 2682 | + public function wpdbbkp_update_backup_info($FileName, $logFile, $logMessage = '') { | |
| 2683 | + $path_info = wp_upload_dir(); | |
| 2684 | + $filename = $FileName . '.sql'; | |
| 2685 | + $WPDBFileName = $FileName . '.zip'; | |
| 2686 | + @unlink($this->wp_db_backup_wp_config_path() . '/' . $filename); | |
| 2687 | + @unlink($this->wp_db_backup_wp_config_path() . '/wp_installer.php'); | |
| 2688 | + @$filesize = filesize($path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/' . $WPDBFileName); | |
| 2689 | + | |
| 2690 | + $upload_path = array( | |
| 2691 | + 'filename' => ($WPDBFileName), | |
| 2692 | + 'dir' => ($path_info['basedir'] . '/' . WPDB_BACKUPS_DIR . '/' . $WPDBFileName), | |
| 2693 | + 'url' => ($path_info['baseurl'] . '/' . WPDB_BACKUPS_DIR . '/' . $WPDBFileName), | |
| 2694 | + 'size' => ($filesize), | |
| 2695 | + 'type' => get_option('wp_db_backup_backup_type') | |
| 2696 | + ); | |
| 2697 | + | |
| 2698 | + | |
| 2699 | + if (get_option('wp_db_log') == 1) { | |
| 2700 | + $this->write_log($logFile, $logMessage); | |
| 2701 | + $upload_path['logfile'] = $path_info['baseurl'] . '/' . WPDB_BACKUPS_DIR . '/log/' . $FileName . '.txt'; | |
| 2702 | + $upload_path['logfileDir'] = $logFile; | |
| 2703 | + } else { | |
| 2704 | + $upload_path['logfile'] = ""; | |
| 2705 | + } | |
| 2706 | + $args = array($FileName, $logFile, $logMessage); | |
| 2707 | + do_action_ref_array('wpdbbkp_backup_completed', array(&$args)); | |
| 2708 | + return $upload_path; | |
| 2709 | + } | |
| 2710 | + | |
| 2711 | + private function write_log($logFile, $logMessage) { | |
| 2712 | + // Actually write the log file | |
| 2713 | + if (is_writable($logFile) || !file_exists($logFile)) { | |
| 2714 | + | |
| 2715 | + if (!$handle = @fopen($logFile, 'a')) | |
| 2716 | + return; | |
| 2717 | + | |
| 2718 | + if (!fwrite($handle, $logMessage)) | |
| 2719 | + return; | |
| 2720 | + | |
| 2721 | + fclose($handle); | |
| 2722 | + | |
| 2723 | + return true; | |
| 2724 | + } | |
| 2725 | + } | |
| 2726 | + | |
| 2727 | + public function get_zip_command_path() { | |
| 2728 | + | |
| 2729 | + // Check shell_exec is available | |
| 2730 | + if (!self::is_shell_exec_available()) | |
| 2731 | + return ''; | |
| 2732 | + | |
| 2733 | + // Return now if it's already been set | |
| 2734 | + if (isset($this->zip_command_path)) | |
| 2735 | + return $this->zip_command_path; | |
| 2736 | + | |
| 2737 | + $this->zip_command_path = ''; | |
| 2738 | + | |
| 2739 | + // Does zip work | |
| 2740 | + if (is_null(shell_exec('hash zip 2>&1'))) { | |
| 2741 | + | |
| 2742 | + // If so store it for later | |
| 2743 | + $this->set_zip_command_path('zip'); | |
| 2744 | + | |
| 2745 | + // And return now | |
| 2746 | + return $this->zip_command_path; | |
| 2747 | + } | |
| 2748 | + | |
| 2749 | + // List of possible zip locations | |
| 2750 | + $zip_locations = array( | |
| 2751 | + '/usr/bin/zip' | |
| 2752 | + ); | |
| 2753 | + | |
| 2754 | + // Find the one which works | |
| 2755 | + foreach ($zip_locations as $location) | |
| 2756 | + if (@is_executable(self::conform_dir($location))) | |
| 2757 | + $this->set_zip_command_path($location); | |
| 2758 | + | |
| 2759 | + return $this->zip_command_path; | |
| 2760 | + } | |
| 2761 | + | |
| 2762 | + public function set_zip_command_path($path) { | |
| 2763 | + | |
| 2764 | + $this->zip_command_path = $path; | |
| 2765 | + } | |
| 2766 | + | |
| 2767 | + /* Begin : Generate Zip using cmd 06-03-2016 V.3.9 */ | |
| 2768 | + | |
| 2769 | + public function zip($WPDBFileName) { | |
| 2770 | + | |
| 2771 | + $this->archive_method = 'zip'; | |
| 2772 | + $wp_all_backup_exclude_dir = get_option('wp_db_backup_exclude_dir'); | |
| 2773 | + if (empty($wp_all_backup_exclude_dir)) { | |
| 2774 | + $excludes = WPDB_BACKUPS_DIR; | |
| 2775 | + } else { | |
| 2776 | + $excludes = WPDB_BACKUPS_DIR . '|' . $wp_all_backup_exclude_dir; | |
| 2777 | + } | |
| 2778 | + // Zip up $this->root with excludes | |
| 2779 | + if (!empty($excludes)) { | |
| 2780 | + $stderr = shell_exec('cd ' . escapeshellarg($this->get_root()) . ' && ' . escapeshellcmd($this->get_zip_command_path()) . ' -rq ' . escapeshellarg($WPDBFileName) . ' ./' . ' -x ' . $this->exclude_string('zip') . ' 2>&1'); | |
| 2781 | + } | |
| 2782 | + | |
| 2783 | + // Zip up $this->root without excludes | |
| 2784 | + else { | |
| 2785 | + // error_log('without exclude rule'); | |
| 2786 | + $stderr = shell_exec('cd ' . escapeshellarg($this->get_root()) . ' && ' . escapeshellcmd($this->get_zip_command_path()) . ' -rq ' . escapeshellarg($WPDBFileName) . ' ./' . ' 2>&1'); | |
| 2787 | + } | |
| 2788 | + error_log($stderr); | |
| 2789 | + if (!empty($stderr)) | |
| 2790 | + $this->warning($this->get_archive_method(), $stderr); | |
| 2791 | + | |
| 2792 | + return $this->verify_archive($WPDBFileName); | |
| 2793 | + } | |
| 2794 | + | |
| 2795 | + public function get_root() { | |
| 2796 | + | |
| 2797 | + if (empty($this->root)) | |
| 2798 | + $this->set_root(self::conform_dir(self::get_home_path())); | |
| 2799 | + | |
| 2800 | + return $this->root; | |
| 2801 | + } | |
| 2802 | + | |
| 2803 | + public function set_root($path) { | |
| 2804 | + | |
| 2805 | + if (empty($path) || !is_string($path) || !is_dir($path)) | |
| 2806 | + throw new Exception('Invalid root path <code>' . $path . '</code> must be a valid directory path'); | |
| 2807 | + | |
| 2808 | + $this->root = self::conform_dir($path); | |
| 2809 | + } | |
| 2810 | + | |
| 2811 | + public static function get_home_path() { | |
| 2812 | + | |
| 2813 | + $home_url = home_url(); | |
| 2814 | + $site_url = site_url(); | |
| 2815 | + | |
| 2816 | + $home_path = ABSPATH; | |
| 2817 | + | |
| 2818 | + // If site_url contains home_url and they differ then assume WordPress is installed in a sub directory | |
| 2819 | + if ($home_url !== $site_url && strpos($site_url, $home_url) === 0) | |
| 2820 | + $home_path = trailingslashit(substr(self::conform_dir(ABSPATH), 0, strrpos(self::conform_dir(ABSPATH), str_replace($home_url, '', $site_url)))); | |
| 2821 | + | |
| 2822 | + return self::conform_dir($home_path); | |
| 2823 | + } | |
| 2824 | + | |
| 2825 | + private function warning($context, $warning) { | |
| 2826 | + | |
| 2827 | + if (empty($context) || empty($warning)) | |
| 2828 | + return; | |
| 2829 | + $this->warnings[$context][$_key = md5(implode(':', (array) $warning))] = $warning; | |
| 2830 | + } | |
| 2831 | + | |
| 2832 | + public function exclude_string($context = 'zip') { | |
| 2833 | + | |
| 2834 | + // Return a comma separated list by default | |
| 2835 | + $separator = ', '; | |
| 2836 | + $wildcard = ''; | |
| 2837 | + | |
| 2838 | + // The zip command | |
| 2839 | + if ($context === 'zip') { | |
| 2840 | + $wildcard = '*'; | |
| 2841 | + $separator = ' -x '; | |
| 2842 | + | |
| 2843 | + // The PclZip fallback library | |
| 2844 | + } elseif ($context === 'regex') { | |
| 2845 | + $wildcard = '([\s\S]*?)'; | |
| 2846 | + $separator = '|'; | |
| 2847 | + } | |
| 2848 | + | |
| 2849 | + $wp_all_backup_exclude_dir = get_option('wp_db_backup_exclude_dir'); | |
| 2850 | + if (empty($wp_all_backup_exclude_dir)) { | |
| 2851 | + $excludes = WPDB_BACKUPS_DIR; | |
| 2852 | + } else { | |
| 2853 | + $excludes = WPDB_BACKUPS_DIR . '|' . $wp_all_backup_exclude_dir; | |
| 2854 | + } | |
| 2855 | + | |
| 2856 | + $excludes = explode("|", $excludes); | |
| 2857 | + foreach ($excludes as $key => &$rule) { | |
| 2858 | + | |
| 2859 | + $file = $absolute = $fragment = false; | |
| 2860 | + | |
| 2861 | + // Files don't end with / | |
| 2862 | + if (!in_array(substr($rule, -1), array('\\', '/'))) | |
| 2863 | + $file = true; | |
| 2864 | + | |
| 2865 | + // If rule starts with a / then treat as absolute path | |
| 2866 | + elseif (in_array(substr($rule, 0, 1), array('\\', '/'))) | |
| 2867 | + $absolute = true; | |
| 2868 | + | |
| 2869 | + // Otherwise treat as dir fragment | |
| 2870 | + else | |
| 2871 | + $fragment = true; | |
| 2872 | + | |
| 2873 | + // Strip $this->root and conform | |
| 2874 | + $rule = str_ireplace($this->get_root(), '', untrailingslashit(self::conform_dir($rule))); | |
| 2875 | + | |
| 2876 | + // Strip the preceeding slash | |
| 2877 | + if (in_array(substr($rule, 0, 1), array('\\', '/'))) | |
| 2878 | + $rule = substr($rule, 1); | |
| 2879 | + | |
| 2880 | + // Escape string for regex | |
| 2881 | + if ($context === 'regex') | |
| 2882 | + $rule = str_replace('.', '\.', $rule); | |
| 2883 | + | |
| 2884 | + // Convert any existing wildcards | |
| 2885 | + if ($wildcard !== '*' && strpos($rule, '*') !== false) | |
| 2886 | + $rule = str_replace('*', $wildcard, $rule); | |
| 2887 | + | |
| 2888 | + // Wrap directory fragments and files in wildcards for zip | |
| 2889 | + if ($context === 'zip' && ( $fragment || $file )) | |
| 2890 | + $rule = $wildcard . $rule . $wildcard; | |
| 2891 | + | |
| 2892 | + // Add a wildcard to the end of absolute url for zips | |
| 2893 | + if ($context === 'zip' && $absolute) | |
| 2894 | + $rule .= $wildcard; | |
| 2895 | + | |
| 2896 | + // Add and end carrot to files for pclzip but only if it doesn't end in a wildcard | |
| 2897 | + if ($file && $context === 'regex') | |
| 2898 | + $rule .= '$'; | |
| 2899 | + | |
| 2900 | + // Add a start carrot to absolute urls for pclzip | |
| 2901 | + if ($absolute && $context === 'regex') | |
| 2902 | + $rule = '^' . $rule; | |
| 2903 | + } | |
| 2904 | + | |
| 2905 | + // Escape shell args for zip command | |
| 2906 | + if ($context === 'zip') | |
| 2907 | + $excludes = array_map('escapeshellarg', array_unique($excludes)); | |
| 2908 | + | |
| 2909 | + return implode($separator, $excludes); | |
| 2910 | + } | |
| 2911 | + | |
| 2912 | + public function get_archive_method() { | |
| 2913 | + return $this->archive_method; | |
| 2914 | + } | |
| 2915 | + | |
| 2916 | + public function verify_archive($WPDBFileName) { | |
| 2917 | + // If we've already passed then no need to check again | |
| 2918 | + if (!empty($this->archive_verified)) | |
| 2919 | + return true; | |
| 2920 | + | |
| 2921 | + // If there are errors delete the backup file. | |
| 2922 | + if ($this->get_errors($this->get_archive_method()) && file_exists($WPDBFileName)) | |
| 2923 | + unlink($WPDBFileName); | |
| 2924 | + | |
| 2925 | + // If the archive file still exists assume it's good | |
| 2926 | + if (file_exists($WPDBFileName)) | |
| 2927 | + return $this->archive_verified = true; | |
| 2928 | + | |
| 2929 | + return false; | |
| 2930 | + } | |
| 2931 | + | |
| 2932 | + public function get_files() { | |
| 2933 | + | |
| 2934 | + if (!empty($this->files)) | |
| 2935 | + return $this->files; | |
| 2936 | + | |
| 2937 | + $this->files = array(); | |
| 2938 | + | |
| 2939 | + // We only want to use the RecursiveDirectoryIterator if the FOLLOW_SYMLINKS flag is available | |
| 2940 | + if (defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS')) { | |
| 2941 | + | |
| 2942 | + $this->files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->get_root(), RecursiveDirectoryIterator::FOLLOW_SYMLINKS), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD); | |
| 2943 | + | |
| 2944 | + // Skip dot files if the SKIP_Dots flag is available | |
| 2945 | + if (defined('RecursiveDirectoryIterator::SKIP_DOTS')) | |
| 2946 | + $this->files->setFlags(RecursiveDirectoryIterator::SKIP_DOTS + RecursiveDirectoryIterator::FOLLOW_SYMLINKS); | |
| 2947 | + | |
| 2948 | + | |
| 2949 | + // If RecursiveDirectoryIterator::FOLLOW_SYMLINKS isn't available then fallback to a less memory efficient method | |
| 2950 | + } else { | |
| 2951 | + | |
| 2952 | + $this->files = $this->get_files_fallback($this->get_root()); | |
| 2953 | + } | |
| 2954 | + | |
| 2955 | + return $this->files; | |
| 2956 | + } | |
| 2957 | + | |
| 2958 | + public function wpdbbkp_get_timeago( $time ) | |
| 2959 | + { | |
| 2960 | + $time_difference = time() - $time; | |
| 2961 | + | |
| 2962 | + if( $time_difference < 1 ) { return 'less than 1 second ago'; } | |
| 2963 | + $condition = array( 12 * 30 * 24 * 60 * 60 => 'year', | |
| 2964 | + 30 * 24 * 60 * 60 => 'month', | |
| 2965 | + 24 * 60 * 60 => 'day', | |
| 2966 | + 60 * 60 => 'hour', | |
| 2967 | + 60 => 'minute', | |
| 2968 | + 1 => 'second' | |
| 2969 | + ); | |
| 2970 | + | |
| 2971 | + foreach( $condition as $secs => $str ) | |
| 2972 | + { | |
| 2973 | + $d = $time_difference / $secs; | |
| 2974 | + | |
| 2975 | + if( $d >= 1 ) | |
| 2976 | + { | |
| 2977 | + $t = floor( $d ); | |
| 2978 | + return 'About ' . $t . ' ' . $str . ( $t > 1 ? 's' : '' ) . ' ago'; | |
| 2979 | + } | |
| 2980 | + } | |
| 2981 | + } | |
| 2982 | + | |
| 2983 | + } | |
| 2984 | + | |
| 2985 | +new Wpdb_Admin(); | |