@@ -26,6 +26,6 @@ |
||
26 | 26 | */ |
27 | 27 | |
28 | 28 | // If uninstall not called from WordPress, then exit. |
29 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
29 | +if (!defined('WP_UNINSTALL_PLUGIN')) { |
|
30 | 30 | exit; |
31 | 31 | } |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!isset($argv)) |
|
3 | +if (!isset($argv)) |
|
4 | 4 | die('Access denied from web.'); |
5 | 5 | |
6 | 6 | $file = 'restore/vendor.phar'; |
7 | 7 | |
8 | -if(file_exists($file)) |
|
8 | +if (file_exists($file)) |
|
9 | 9 | unlink($file); |
10 | 10 | $phar2 = new Phar($file, 0, 'vendor.phar'); |
11 | 11 |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param string $plugin_name The name of the plugin. |
48 | 48 | * @param string $version The version of this plugin. |
49 | 49 | */ |
50 | - public function __construct( $plugin_name, $version ) { |
|
50 | + public function __construct($plugin_name, $version) { |
|
51 | 51 | |
52 | 52 | $this->plugin_name = $plugin_name; |
53 | 53 | $this->version = $version; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * class. |
74 | 74 | */ |
75 | 75 | |
76 | - wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/xcloner-public.css', array(), $this->version, 'all' ); |
|
76 | + wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__).'css/xcloner-public.css', array(), $this->version, 'all'); |
|
77 | 77 | |
78 | 78 | } |
79 | 79 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * class. |
97 | 97 | */ |
98 | 98 | |
99 | - wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/xcloner-public.js', array( 'jquery' ), $this->version, false ); |
|
99 | + wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__).'js/xcloner-public.js', array('jquery'), $this->version, false); |
|
100 | 100 | |
101 | 101 | } |
102 | 102 |
@@ -22,14 +22,14 @@ |
||
22 | 22 | { |
23 | 23 | $path = filter_var($option, FILTER_SANITIZE_URL); |
24 | 24 | |
25 | - try{ |
|
25 | + try { |
|
26 | 26 | $option = Util::normalizePath($path); |
27 | - }catch(Exception $e){ |
|
27 | + }catch (Exception $e) { |
|
28 | 28 | add_settings_error('xcloner_error_message', '', __($e->getMessage()), 'error'); |
29 | 29 | } |
30 | 30 | |
31 | - if($path and !is_dir($path)){ |
|
32 | - add_settings_error('xcloner_error_message', '', __(sprintf('Invalid Server Path %s',$option)), 'error'); |
|
31 | + if ($path and !is_dir($path)) { |
|
32 | + add_settings_error('xcloner_error_message', '', __(sprintf('Invalid Server Path %s', $option)), 'error'); |
|
33 | 33 | return false; |
34 | 34 | } |
35 | 35 |
@@ -35,22 +35,22 @@ discard block |
||
35 | 35 | |
36 | 36 | global $wpdb; |
37 | 37 | |
38 | - if(version_compare(phpversion(), Xcloner_Activator::xcloner_minimum_version, '<')) |
|
38 | + if (version_compare(phpversion(), Xcloner_Activator::xcloner_minimum_version, '<')) |
|
39 | 39 | { |
40 | - wp_die('<p>'.sprintf(__("XCloner requires minimum PHP version %s in order to run correctly. We have detected your version as %s"),Xcloner_Activator::xcloner_minimum_version, phpversion()).'</p>', __("XCloner Activation Error"), array( 'response'=>500, 'back_link'=>TRUE ) ); |
|
40 | + wp_die('<p>'.sprintf(__("XCloner requires minimum PHP version %s in order to run correctly. We have detected your version as %s"), Xcloner_Activator::xcloner_minimum_version, phpversion()).'</p>', __("XCloner Activation Error"), array('response'=>500, 'back_link'=>TRUE)); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | $charset_collate = $wpdb->get_charset_collate(); |
44 | 44 | |
45 | - $installed_ver = get_option( "xcloner_db_version" ); |
|
45 | + $installed_ver = get_option("xcloner_db_version"); |
|
46 | 46 | |
47 | 47 | $xcloner_db_version = Xcloner_Activator::xcloner_db_version; |
48 | 48 | |
49 | - if($installed_ver != $xcloner_db_version) |
|
49 | + if ($installed_ver != $xcloner_db_version) |
|
50 | 50 | { |
51 | - $table_name = $wpdb->prefix . "xcloner_scheduler"; |
|
51 | + $table_name = $wpdb->prefix."xcloner_scheduler"; |
|
52 | 52 | |
53 | - $xcloner_schedule_sql="CREATE TABLE IF NOT EXISTS `".$table_name."` ( |
|
53 | + $xcloner_schedule_sql = "CREATE TABLE IF NOT EXISTS `".$table_name."` ( |
|
54 | 54 | `id` int(11) NOT NULL AUTO_INCREMENT, |
55 | 55 | `name` varchar(255) NOT NULL, |
56 | 56 | `recurrence` varchar(10) NOT NULL, |
@@ -63,49 +63,49 @@ discard block |
||
63 | 63 | PRIMARY KEY (`id`) |
64 | 64 | ) ".$charset_collate."; |
65 | 65 | "; |
66 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
67 | - dbDelta( $xcloner_schedule_sql ); |
|
66 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
67 | + dbDelta($xcloner_schedule_sql); |
|
68 | 68 | |
69 | - update_option( "xcloner_db_version", $xcloner_db_version ); |
|
69 | + update_option("xcloner_db_version", $xcloner_db_version); |
|
70 | 70 | } |
71 | 71 | |
72 | - if(!get_option('xcloner_backup_compression_level')) |
|
72 | + if (!get_option('xcloner_backup_compression_level')) |
|
73 | 73 | update_option('xcloner_backup_compression_level', 0); |
74 | 74 | |
75 | - if(!get_option('xcloner_enable_log')) |
|
75 | + if (!get_option('xcloner_enable_log')) |
|
76 | 76 | update_option('xcloner_enable_log', 1); |
77 | 77 | |
78 | - if(!get_option('xcloner_enable_mysql_backup')) |
|
78 | + if (!get_option('xcloner_enable_mysql_backup')) |
|
79 | 79 | update_option('xcloner_enable_mysql_backup', 1); |
80 | 80 | |
81 | - if(!get_option('xcloner_system_settings_page')) |
|
81 | + if (!get_option('xcloner_system_settings_page')) |
|
82 | 82 | update_option('xcloner_system_settings_page', 100); |
83 | 83 | |
84 | - if(!get_option('xcloner_files_to_process_per_request')) |
|
84 | + if (!get_option('xcloner_files_to_process_per_request')) |
|
85 | 85 | update_option('xcloner_files_to_process_per_request', 250); |
86 | 86 | |
87 | - if(!get_option('xcloner_database_records_per_request')) |
|
87 | + if (!get_option('xcloner_database_records_per_request')) |
|
88 | 88 | update_option('xcloner_database_records_per_request', 10000); |
89 | 89 | |
90 | - if(!get_option('xcloner_exclude_files_larger_than_mb')) |
|
90 | + if (!get_option('xcloner_exclude_files_larger_than_mb')) |
|
91 | 91 | update_option('xcloner_exclude_files_larger_than_mb', 0); |
92 | 92 | |
93 | - if(!get_option('xcloner_split_backup_limit')) |
|
93 | + if (!get_option('xcloner_split_backup_limit')) |
|
94 | 94 | update_option('xcloner_split_backup_limit', 2048); |
95 | 95 | |
96 | - if(!get_option('xcloner_size_limit_per_request')) |
|
96 | + if (!get_option('xcloner_size_limit_per_request')) |
|
97 | 97 | update_option('xcloner_size_limit_per_request', 50); |
98 | 98 | |
99 | - if(!get_option('xcloner_cleanup_retention_limit_days')) |
|
99 | + if (!get_option('xcloner_cleanup_retention_limit_days')) |
|
100 | 100 | update_option('xcloner_cleanup_retention_limit_days', 60); |
101 | 101 | |
102 | - if(!get_option('xcloner_cleanup_retention_limit_archives')) |
|
102 | + if (!get_option('xcloner_cleanup_retention_limit_archives')) |
|
103 | 103 | update_option('xcloner_cleanup_retention_limit_archives', 100); |
104 | 104 | |
105 | - if(!get_option('xcloner_directories_to_scan_per_request')) |
|
105 | + if (!get_option('xcloner_directories_to_scan_per_request')) |
|
106 | 106 | update_option('xcloner_directories_to_scan_per_request', 25); |
107 | 107 | |
108 | - if(!get_option('xcloner_regex_exclude')) |
|
108 | + if (!get_option('xcloner_regex_exclude')) |
|
109 | 109 | update_option('xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$".PHP_EOL."(.*)\.(svn|git)(.*)$".PHP_EOL."wp-content\/cache(.*)$"); |
110 | 110 | |
111 | 111 | } |
@@ -4,17 +4,17 @@ discard block |
||
4 | 4 | { |
5 | 5 | private $logger_file = "xcloner_main_%s.log"; |
6 | 6 | private $logger_file_hash = "xcloner%s.log"; |
7 | - private $hash ; |
|
7 | + private $hash; |
|
8 | 8 | |
9 | 9 | public function __construct($hash = "") |
10 | 10 | { |
11 | - if(isset($hash)) |
|
11 | + if (isset($hash)) |
|
12 | 12 | $this->set_hash($hash); |
13 | 13 | } |
14 | 14 | |
15 | 15 | public function get_logger_filename($include_hash = 0) |
16 | 16 | { |
17 | - if($include_hash) |
|
17 | + if ($include_hash) |
|
18 | 18 | $filename = sprintf($this->logger_file_hash, $this->get_hash()); |
19 | 19 | else |
20 | 20 | $filename = sprintf($this->logger_file, $this->get_server_unique_hash(5)); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | public function get_xcloner_start_path() |
26 | 26 | { |
27 | - if(!get_option('xcloner_start_path') or !is_dir(get_option('xcloner_start_path'))) |
|
27 | + if (!get_option('xcloner_start_path') or !is_dir(get_option('xcloner_start_path'))) |
|
28 | 28 | $path = realpath(ABSPATH); |
29 | 29 | else |
30 | 30 | $path = get_option('xcloner_start_path'); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | public function get_xcloner_store_path() |
43 | 43 | { |
44 | - if(!get_option('xcloner_store_path') or !is_dir(get_option('xcloner_store_path'))) |
|
44 | + if (!get_option('xcloner_store_path') or !is_dir(get_option('xcloner_store_path'))) |
|
45 | 45 | $path = realpath(XCLONER_STORAGE_PATH); |
46 | 46 | else |
47 | 47 | $path = get_option('xcloner_store_path'); |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | public function get_xcloner_tmp_path() |
59 | 59 | { |
60 | 60 | $path = sys_get_temp_dir().DS.".".$this->get_xcloner_tmp_path_suffix(); |
61 | - if(!is_dir($path)) |
|
61 | + if (!is_dir($path)) |
|
62 | 62 | { |
63 | 63 | @mkdir($path); |
64 | 64 | @chmod($path, 0777); |
65 | 65 | } |
66 | 66 | |
67 | - if(!is_dir($path) or !is_writeable($path) or get_option('xcloner_force_tmp_path_site_root')) |
|
67 | + if (!is_dir($path) or !is_writeable($path) or get_option('xcloner_force_tmp_path_site_root')) |
|
68 | 68 | $path = $this->get_xcloner_store_path().DS.".".$this->get_xcloner_tmp_path_suffix(); |
69 | 69 | |
70 | 70 | return $path; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | public function get_enable_mysql_backup() |
74 | 74 | { |
75 | - if(get_option('xcloner_enable_mysql_backup')) |
|
75 | + if (get_option('xcloner_enable_mysql_backup')) |
|
76 | 76 | return true; |
77 | 77 | |
78 | 78 | return false; |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | |
81 | 81 | public function get_backup_extension_name($ext = "") |
82 | 82 | { |
83 | - if(!$ext) |
|
83 | + if (!$ext) |
|
84 | 84 | { |
85 | - if(get_option('xcloner_backup_compression_level')) |
|
85 | + if (get_option('xcloner_backup_compression_level')) |
|
86 | 86 | $ext = ".tgz"; |
87 | 87 | else |
88 | 88 | $ext = ".tar"; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | public function get_hash() |
94 | 94 | { |
95 | - if(!$this->hash){ |
|
95 | + if (!$this->hash) { |
|
96 | 96 | $this->set_hash("-".$this->get_server_unique_hash(5)); |
97 | 97 | } |
98 | 98 | |
@@ -104,17 +104,17 @@ discard block |
||
104 | 104 | { |
105 | 105 | $hash = "-".md5(rand()); |
106 | 106 | |
107 | - $this->set_hash(substr( $hash, 0, 6)); |
|
107 | + $this->set_hash(substr($hash, 0, 6)); |
|
108 | 108 | |
109 | 109 | return $hash; |
110 | 110 | } |
111 | 111 | |
112 | 112 | public function set_hash($hash = "") |
113 | 113 | { |
114 | - if(substr($hash, 0, 1) != "-" and strlen($hash)) |
|
114 | + if (substr($hash, 0, 1) != "-" and strlen($hash)) |
|
115 | 115 | $hash = "-".$hash; |
116 | 116 | |
117 | - $this->hash = substr( $hash, 0, 6); |
|
117 | + $this->hash = substr($hash, 0, 6); |
|
118 | 118 | |
119 | 119 | return $this; |
120 | 120 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | { |
124 | 124 | $data = parse_url(get_site_url()); |
125 | 125 | |
126 | - $backup_name = "backup_[domain]".(isset($data['port'])?":".$data['port']:"")."-[time]-".($this->get_enable_mysql_backup()?"sql":"nosql"); |
|
126 | + $backup_name = "backup_[domain]".(isset($data['port']) ? ":".$data['port'] : "")."-[time]-".($this->get_enable_mysql_backup() ? "sql" : "nosql"); |
|
127 | 127 | |
128 | 128 | return $backup_name; |
129 | 129 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | { |
133 | 133 | global $wpdb; |
134 | 134 | |
135 | - if(!$data = get_option('xcloner_mysql_hostname')) |
|
135 | + if (!$data = get_option('xcloner_mysql_hostname')) |
|
136 | 136 | $data = $wpdb->dbhost; |
137 | 137 | |
138 | 138 | return $data; |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | { |
143 | 143 | global $wpdb; |
144 | 144 | |
145 | - if(!$data = get_option('xcloner_mysql_username')) |
|
145 | + if (!$data = get_option('xcloner_mysql_username')) |
|
146 | 146 | $data = $wpdb->dbuser; |
147 | 147 | |
148 | 148 | return $data; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | { |
153 | 153 | global $wpdb; |
154 | 154 | |
155 | - if(!$data = get_option('xcloner_mysql_password')) |
|
155 | + if (!$data = get_option('xcloner_mysql_password')) |
|
156 | 156 | $data = $wpdb->dbpassword; |
157 | 157 | |
158 | 158 | return $data; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | { |
163 | 163 | global $wpdb; |
164 | 164 | |
165 | - if(!$data = get_option('xcloner_mysql_database')) |
|
165 | + if (!$data = get_option('xcloner_mysql_database')) |
|
166 | 166 | $data = $wpdb->dbname; |
167 | 167 | |
168 | 168 | return $data; |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | { |
187 | 187 | $hash = md5(get_home_url().__DIR__); |
188 | 188 | |
189 | - if($strlen) |
|
189 | + if ($strlen) |
|
190 | 190 | $hash = substr($hash, 0, $strlen); |
191 | 191 | |
192 | 192 | return $hash; |
@@ -198,20 +198,20 @@ discard block |
||
198 | 198 | $this->xcloner_sanitization = new Xcloner_Sanitization(); |
199 | 199 | |
200 | 200 | //ADDING MISSING OPTIONS |
201 | - if( false == get_option( 'xcloner_mysql_settings_page' ) ) { |
|
202 | - add_option( 'xcloner_mysql_settings_page' ); |
|
201 | + if (false == get_option('xcloner_mysql_settings_page')) { |
|
202 | + add_option('xcloner_mysql_settings_page'); |
|
203 | 203 | } // end if |
204 | 204 | |
205 | - if( false == get_option( 'xcloner_cron_settings_page' ) ) { |
|
206 | - add_option( 'xcloner_cron_settings_page' ); |
|
205 | + if (false == get_option('xcloner_cron_settings_page')) { |
|
206 | + add_option('xcloner_cron_settings_page'); |
|
207 | 207 | } // end if |
208 | 208 | |
209 | - if( false == get_option( 'xcloner_system_settings_page' ) ) { |
|
210 | - add_option( 'xcloner_system_settings_page' ); |
|
209 | + if (false == get_option('xcloner_system_settings_page')) { |
|
210 | + add_option('xcloner_system_settings_page'); |
|
211 | 211 | } // end if |
212 | 212 | |
213 | - if( false == get_option( 'xcloner_cleanup_settings_page' ) ) { |
|
214 | - add_option( 'xcloner_cleanup_settings_page' ); |
|
213 | + if (false == get_option('xcloner_cleanup_settings_page')) { |
|
214 | + add_option('xcloner_cleanup_settings_page'); |
|
215 | 215 | } // end if |
216 | 216 | |
217 | 217 | |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | //SYSTEM section |
235 | 235 | add_settings_section( |
236 | 236 | 'xcloner_system_settings_group', |
237 | - __('These are advanced options recommended for developers!','xcloner-backup-and-restore'), |
|
237 | + __('These are advanced options recommended for developers!', 'xcloner-backup-and-restore'), |
|
238 | 238 | array($this, 'xcloner_settings_section_cb'), |
239 | 239 | 'xcloner_system_settings_page' |
240 | 240 | ); |
@@ -262,12 +262,12 @@ discard block |
||
262 | 262 | register_setting('xcloner_general_settings_group', 'xcloner_backup_compression_level', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
263 | 263 | add_settings_field( |
264 | 264 | 'xcloner_backup_compression_level', |
265 | - __('Backup Compression Level','xcloner-backup-and-restore'), |
|
265 | + __('Backup Compression Level', 'xcloner-backup-and-restore'), |
|
266 | 266 | array($this, 'do_form_range_field'), |
267 | 267 | 'xcloner_settings_page', |
268 | 268 | 'xcloner_general_settings_group', |
269 | 269 | array('xcloner_backup_compression_level', |
270 | - __('Options between [0-9]. Value 0 means no compression, while 9 is maximum compression affecting cpu load','xcloner-backup-and-restore'), |
|
270 | + __('Options between [0-9]. Value 0 means no compression, while 9 is maximum compression affecting cpu load', 'xcloner-backup-and-restore'), |
|
271 | 271 | 0, |
272 | 272 | 9 |
273 | 273 | ) |
@@ -276,12 +276,12 @@ discard block |
||
276 | 276 | register_setting('xcloner_general_settings_group', 'xcloner_start_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path")); |
277 | 277 | add_settings_field( |
278 | 278 | 'xcloner_start_path', |
279 | - __('Backup Start Location','xcloner-backup-and-restore'), |
|
279 | + __('Backup Start Location', 'xcloner-backup-and-restore'), |
|
280 | 280 | array($this, 'do_form_text_field'), |
281 | 281 | 'xcloner_settings_page', |
282 | 282 | 'xcloner_general_settings_group', |
283 | 283 | array('xcloner_start_path', |
284 | - __('Base path location from where XCloner can start the Backup.','xcloner-backup-and-restore'), |
|
284 | + __('Base path location from where XCloner can start the Backup.', 'xcloner-backup-and-restore'), |
|
285 | 285 | $this->get_xcloner_start_path(), |
286 | 286 | //'disabled' |
287 | 287 | ) |
@@ -290,12 +290,12 @@ discard block |
||
290 | 290 | register_setting('xcloner_general_settings_group', 'xcloner_store_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path")); |
291 | 291 | add_settings_field( |
292 | 292 | 'xcloner_store_path', |
293 | - __('Backup Storage Location','xcloner-backup-and-restore'), |
|
293 | + __('Backup Storage Location', 'xcloner-backup-and-restore'), |
|
294 | 294 | array($this, 'do_form_text_field'), |
295 | 295 | 'xcloner_settings_page', |
296 | 296 | 'xcloner_general_settings_group', |
297 | 297 | array('xcloner_store_path', |
298 | - __('Location where XCloner will store the Backup archives.','xcloner-backup-and-restore'), |
|
298 | + __('Location where XCloner will store the Backup archives.', 'xcloner-backup-and-restore'), |
|
299 | 299 | $this->get_xcloner_store_path(), |
300 | 300 | //'disabled' |
301 | 301 | ) |
@@ -304,24 +304,24 @@ discard block |
||
304 | 304 | register_setting('xcloner_general_settings_group', 'xcloner_enable_log', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
305 | 305 | add_settings_field( |
306 | 306 | 'xcloner_enable_log', |
307 | - __('Enable XCloner Backup Log','xcloner-backup-and-restore'), |
|
307 | + __('Enable XCloner Backup Log', 'xcloner-backup-and-restore'), |
|
308 | 308 | array($this, 'do_form_switch_field'), |
309 | 309 | 'xcloner_settings_page', |
310 | 310 | 'xcloner_general_settings_group', |
311 | 311 | array('xcloner_enable_log', |
312 | - sprintf(__('Enable the XCloner Backup log. You will find it stored unde the Backup Storage Location, file %s','xcloner-backup-and-restore'), $this->get_logger_filename()) |
|
312 | + sprintf(__('Enable the XCloner Backup log. You will find it stored unde the Backup Storage Location, file %s', 'xcloner-backup-and-restore'), $this->get_logger_filename()) |
|
313 | 313 | ) |
314 | 314 | ); |
315 | 315 | |
316 | 316 | register_setting('xcloner_general_settings_group', 'xcloner_regex_exclude', array($this->xcloner_sanitization, "sanitize_input_as_raw")); |
317 | 317 | add_settings_field( |
318 | 318 | 'xcloner_regex_exclude', |
319 | - __('Regex Exclude Files','xcloner-backup-and-restore'), |
|
319 | + __('Regex Exclude Files', 'xcloner-backup-and-restore'), |
|
320 | 320 | array($this, 'do_form_textarea_field'), |
321 | 321 | 'xcloner_settings_page', |
322 | 322 | 'xcloner_general_settings_group', |
323 | 323 | array('xcloner_regex_exclude', |
324 | - __('Regular expression match to exclude files and folders, example patterns provided below, one pattern per line','xcloner-backup-and-restore'), |
|
324 | + __('Regular expression match to exclude files and folders, example patterns provided below, one pattern per line', 'xcloner-backup-and-restore'), |
|
325 | 325 | //$this->get_xcloner_store_path(), |
326 | 326 | //'disabled' |
327 | 327 | ) |
@@ -331,36 +331,36 @@ discard block |
||
331 | 331 | register_setting('xcloner_mysql_settings_group', 'xcloner_enable_mysql_backup', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
332 | 332 | add_settings_field( |
333 | 333 | 'xcloner_enable_mysql_backup', |
334 | - __('Enable Mysql Backup','xcloner-backup-and-restore'), |
|
334 | + __('Enable Mysql Backup', 'xcloner-backup-and-restore'), |
|
335 | 335 | array($this, 'do_form_switch_field'), |
336 | 336 | 'xcloner_mysql_settings_page', |
337 | 337 | 'xcloner_mysql_settings_group', |
338 | 338 | array('xcloner_enable_mysql_backup', |
339 | - __('Enable Mysql Backup Option. If you don\'t want to backup the database, you can disable this.','xcloner-backup-and-restore') |
|
339 | + __('Enable Mysql Backup Option. If you don\'t want to backup the database, you can disable this.', 'xcloner-backup-and-restore') |
|
340 | 340 | ) |
341 | 341 | ); |
342 | 342 | |
343 | 343 | register_setting('xcloner_mysql_settings_group', 'xcloner_backup_only_wp_tables'); |
344 | 344 | add_settings_field( |
345 | 345 | 'xcloner_backup_only_wp_tables', |
346 | - __('Backup only WP tables','xcloner-backup-and-restore'), |
|
346 | + __('Backup only WP tables', 'xcloner-backup-and-restore'), |
|
347 | 347 | array($this, 'do_form_switch_field'), |
348 | 348 | 'xcloner_mysql_settings_page', |
349 | 349 | 'xcloner_mysql_settings_group', |
350 | 350 | array('xcloner_backup_only_wp_tables', |
351 | - sprintf(__('Enable this if you only want to Backup only tables starting with \'%s\' prefix','xcloner-backup-and-restore'), $this->get_table_prefix()) |
|
351 | + sprintf(__('Enable this if you only want to Backup only tables starting with \'%s\' prefix', 'xcloner-backup-and-restore'), $this->get_table_prefix()) |
|
352 | 352 | ) |
353 | 353 | ); |
354 | 354 | |
355 | 355 | register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_hostname', array($this->xcloner_sanitization, "sanitize_input_as_raw")); |
356 | 356 | add_settings_field( |
357 | 357 | 'xcloner_mysql_hostname', |
358 | - __('Mysql Hostname','xcloner-backup-and-restore'), |
|
358 | + __('Mysql Hostname', 'xcloner-backup-and-restore'), |
|
359 | 359 | array($this, 'do_form_text_field'), |
360 | 360 | 'xcloner_mysql_settings_page', |
361 | 361 | 'xcloner_mysql_settings_group', |
362 | 362 | array('xcloner_mysql_hostname', |
363 | - __('Wordpress mysql hostname','xcloner-backup-and-restore'), |
|
363 | + __('Wordpress mysql hostname', 'xcloner-backup-and-restore'), |
|
364 | 364 | $this->get_db_hostname(), |
365 | 365 | 'disabled' |
366 | 366 | ) |
@@ -369,12 +369,12 @@ discard block |
||
369 | 369 | register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_username', array($this->xcloner_sanitization, "sanitize_input_as_raw")); |
370 | 370 | add_settings_field( |
371 | 371 | 'xcloner_mysql_username', |
372 | - __('Mysql Username','xcloner-backup-and-restore'), |
|
372 | + __('Mysql Username', 'xcloner-backup-and-restore'), |
|
373 | 373 | array($this, 'do_form_text_field'), |
374 | 374 | 'xcloner_mysql_settings_page', |
375 | 375 | 'xcloner_mysql_settings_group', |
376 | 376 | array('xcloner_mysql_username', |
377 | - __('Wordpress mysql username','xcloner-backup-and-restore'), |
|
377 | + __('Wordpress mysql username', 'xcloner-backup-and-restore'), |
|
378 | 378 | $this->get_db_username(), |
379 | 379 | 'disabled' |
380 | 380 | ) |
@@ -383,12 +383,12 @@ discard block |
||
383 | 383 | register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_database', array($this->xcloner_sanitization, "sanitize_input_as_raw")); |
384 | 384 | add_settings_field( |
385 | 385 | 'xcloner_mysql_database', |
386 | - __('Mysql Database','xcloner-backup-and-restore'), |
|
386 | + __('Mysql Database', 'xcloner-backup-and-restore'), |
|
387 | 387 | array($this, 'do_form_text_field'), |
388 | 388 | 'xcloner_mysql_settings_page', |
389 | 389 | 'xcloner_mysql_settings_group', |
390 | 390 | array('xcloner_mysql_database', |
391 | - __('Wordpress mysql database','xcloner-backup-and-restore'), |
|
391 | + __('Wordpress mysql database', 'xcloner-backup-and-restore'), |
|
392 | 392 | $this->get_db_database(), |
393 | 393 | 'disabled' |
394 | 394 | ) |
@@ -398,12 +398,12 @@ discard block |
||
398 | 398 | register_setting('xcloner_system_settings_group', 'xcloner_size_limit_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
399 | 399 | add_settings_field( |
400 | 400 | 'xcloner_size_limit_per_request', |
401 | - __('Data Size Limit Per Request','xcloner-backup-and-restore'), |
|
401 | + __('Data Size Limit Per Request', 'xcloner-backup-and-restore'), |
|
402 | 402 | array($this, 'do_form_range_field'), |
403 | 403 | 'xcloner_system_settings_page', |
404 | 404 | 'xcloner_system_settings_group', |
405 | 405 | array('xcloner_size_limit_per_request', |
406 | - __('Use this option to set how much file data can XCloner backup in one AJAX request. Range 0-1024 MB','xcloner-backup-and-restore'), |
|
406 | + __('Use this option to set how much file data can XCloner backup in one AJAX request. Range 0-1024 MB', 'xcloner-backup-and-restore'), |
|
407 | 407 | 0, |
408 | 408 | 1024 |
409 | 409 | ) |
@@ -412,12 +412,12 @@ discard block |
||
412 | 412 | register_setting('xcloner_system_settings_group', 'xcloner_files_to_process_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
413 | 413 | add_settings_field( |
414 | 414 | 'xcloner_files_to_process_per_request', |
415 | - __('Files To Process Per Request','xcloner-backup-and-restore'), |
|
415 | + __('Files To Process Per Request', 'xcloner-backup-and-restore'), |
|
416 | 416 | array($this, 'do_form_range_field'), |
417 | 417 | 'xcloner_system_settings_page', |
418 | 418 | 'xcloner_system_settings_group', |
419 | 419 | array('xcloner_files_to_process_per_request', |
420 | - __('Use this option to set how many files XCloner should process at one time before doing another AJAX call','xcloner-backup-and-restore'), |
|
420 | + __('Use this option to set how many files XCloner should process at one time before doing another AJAX call', 'xcloner-backup-and-restore'), |
|
421 | 421 | 0, |
422 | 422 | 1000 |
423 | 423 | ) |
@@ -426,12 +426,12 @@ discard block |
||
426 | 426 | register_setting('xcloner_system_settings_group', 'xcloner_directories_to_scan_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
427 | 427 | add_settings_field( |
428 | 428 | 'xcloner_directories_to_scan_per_request', |
429 | - __('Directories To Scan Per Request','xcloner-backup-and-restore'), |
|
429 | + __('Directories To Scan Per Request', 'xcloner-backup-and-restore'), |
|
430 | 430 | array($this, 'do_form_range_field'), |
431 | 431 | 'xcloner_system_settings_page', |
432 | 432 | 'xcloner_system_settings_group', |
433 | 433 | array('xcloner_directories_to_scan_per_request', |
434 | - __('Use this option to set how many directories XCloner should scan at one time before doing another AJAX call','xcloner-backup-and-restore'), |
|
434 | + __('Use this option to set how many directories XCloner should scan at one time before doing another AJAX call', 'xcloner-backup-and-restore'), |
|
435 | 435 | 0, |
436 | 436 | 1000 |
437 | 437 | ) |
@@ -440,12 +440,12 @@ discard block |
||
440 | 440 | register_setting('xcloner_system_settings_group', 'xcloner_database_records_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
441 | 441 | add_settings_field( |
442 | 442 | 'xcloner_database_records_per_request', |
443 | - __('Database Records Per Request','xcloner-backup-and-restore'), |
|
443 | + __('Database Records Per Request', 'xcloner-backup-and-restore'), |
|
444 | 444 | array($this, 'do_form_range_field'), |
445 | 445 | 'xcloner_system_settings_page', |
446 | 446 | 'xcloner_system_settings_group', |
447 | 447 | array('xcloner_database_records_per_request', |
448 | - __('Use this option to set how many database table records should be fetched per AJAX request, or set to 0 to fetch all. Range 0-100000 records','xcloner-backup-and-restore'), |
|
448 | + __('Use this option to set how many database table records should be fetched per AJAX request, or set to 0 to fetch all. Range 0-100000 records', 'xcloner-backup-and-restore'), |
|
449 | 449 | 0, |
450 | 450 | 100000 |
451 | 451 | ) |
@@ -454,36 +454,36 @@ discard block |
||
454 | 454 | register_setting('xcloner_system_settings_group', 'xcloner_exclude_files_larger_than_mb', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
455 | 455 | add_settings_field( |
456 | 456 | 'xcloner_exclude_files_larger_than_mb', |
457 | - __('Exclude files larger than (MB)','xcloner-backup-and-restore'), |
|
457 | + __('Exclude files larger than (MB)', 'xcloner-backup-and-restore'), |
|
458 | 458 | array($this, 'do_form_number_field'), |
459 | 459 | 'xcloner_system_settings_page', |
460 | 460 | 'xcloner_system_settings_group', |
461 | 461 | array('xcloner_exclude_files_larger_than_mb', |
462 | - __('Use this option to automatically exclude files larger than a certain size in MB, or set to -1 to include all. Range 0-1000 MB','xcloner-backup-and-restore'), |
|
462 | + __('Use this option to automatically exclude files larger than a certain size in MB, or set to -1 to include all. Range 0-1000 MB', 'xcloner-backup-and-restore'), |
|
463 | 463 | ) |
464 | 464 | ); |
465 | 465 | |
466 | 466 | register_setting('xcloner_system_settings_group', 'xcloner_split_backup_limit', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
467 | 467 | add_settings_field( |
468 | 468 | 'xcloner_split_backup_limit', |
469 | - __('Split Backup Archive Limit (MB)','xcloner-backup-and-restore'), |
|
469 | + __('Split Backup Archive Limit (MB)', 'xcloner-backup-and-restore'), |
|
470 | 470 | array($this, 'do_form_number_field'), |
471 | 471 | 'xcloner_system_settings_page', |
472 | 472 | 'xcloner_system_settings_group', |
473 | 473 | array('xcloner_split_backup_limit', |
474 | - __('Use this option to automatically split the backup archive into smaller parts. Range 0-10000 MB','xcloner-backup-and-restore'), |
|
474 | + __('Use this option to automatically split the backup archive into smaller parts. Range 0-10000 MB', 'xcloner-backup-and-restore'), |
|
475 | 475 | ) |
476 | 476 | ); |
477 | 477 | |
478 | 478 | register_setting('xcloner_system_settings_group', 'xcloner_force_tmp_path_site_root'); |
479 | 479 | add_settings_field( |
480 | 480 | 'xcloner_force_tmp_path_site_root', |
481 | - __('Force Temporary Path Within XCloner Storage','xcloner-backup-and-restore'), |
|
481 | + __('Force Temporary Path Within XCloner Storage', 'xcloner-backup-and-restore'), |
|
482 | 482 | array($this, 'do_form_switch_field'), |
483 | 483 | 'xcloner_system_settings_page', |
484 | 484 | 'xcloner_system_settings_group', |
485 | 485 | array('xcloner_force_tmp_path_site_root', |
486 | - sprintf(__('Enable this option if you want the XCloner Temporary Path to be within your XCloner Storage Location','xcloner-backup-and-restore'), $this->get_table_prefix()) |
|
486 | + sprintf(__('Enable this option if you want the XCloner Temporary Path to be within your XCloner Storage Location', 'xcloner-backup-and-restore'), $this->get_table_prefix()) |
|
487 | 487 | ) |
488 | 488 | ); |
489 | 489 | |
@@ -491,36 +491,36 @@ discard block |
||
491 | 491 | register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_days', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
492 | 492 | add_settings_field( |
493 | 493 | 'xcloner_cleanup_retention_limit_days', |
494 | - __('Cleanup by Date(days)','xcloner-backup-and-restore'), |
|
494 | + __('Cleanup by Date(days)', 'xcloner-backup-and-restore'), |
|
495 | 495 | array($this, 'do_form_number_field'), |
496 | 496 | 'xcloner_cleanup_settings_page', |
497 | 497 | 'xcloner_cleanup_settings_group', |
498 | 498 | array('xcloner_cleanup_retention_limit_days', |
499 | - __('Specify the maximum number of days a backup archive can be kept on the server. 0 disables this option','xcloner-backup-and-restore') |
|
499 | + __('Specify the maximum number of days a backup archive can be kept on the server. 0 disables this option', 'xcloner-backup-and-restore') |
|
500 | 500 | ) |
501 | 501 | ); |
502 | 502 | |
503 | 503 | register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_archives', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
504 | 504 | add_settings_field( |
505 | 505 | 'xcloner_cleanup_retention_limit_archives', |
506 | - __('Cleanup by Quantity','xcloner-backup-and-restore'), |
|
506 | + __('Cleanup by Quantity', 'xcloner-backup-and-restore'), |
|
507 | 507 | array($this, 'do_form_number_field'), |
508 | 508 | 'xcloner_cleanup_settings_page', |
509 | 509 | 'xcloner_cleanup_settings_group', |
510 | 510 | array('xcloner_cleanup_retention_limit_archives', |
511 | - __('Specify the maximum number of backup archives to keep on the server. 0 disables this option','xcloner-backup-and-restore') |
|
511 | + __('Specify the maximum number of backup archives to keep on the server. 0 disables this option', 'xcloner-backup-and-restore') |
|
512 | 512 | ) |
513 | 513 | ); |
514 | 514 | |
515 | 515 | register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_capacity_limit', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
516 | 516 | add_settings_field( |
517 | 517 | 'xcloner_cleanup_capacity_limit', |
518 | - __('Cleanup by Capacity(MB)','xcloner-backup-and-restore'), |
|
518 | + __('Cleanup by Capacity(MB)', 'xcloner-backup-and-restore'), |
|
519 | 519 | array($this, 'do_form_number_field'), |
520 | 520 | 'xcloner_cleanup_settings_page', |
521 | 521 | 'xcloner_cleanup_settings_group', |
522 | 522 | array('xcloner_cleanup_capacity_limit', |
523 | - __('Remove oldest backups if all created backups exceed the configured limit in Megabytes. 0 disables this option','xcloner-backup-and-restore') |
|
523 | + __('Remove oldest backups if all created backups exceed the configured limit in Megabytes. 0 disables this option', 'xcloner-backup-and-restore') |
|
524 | 524 | ) |
525 | 525 | ); |
526 | 526 | |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | register_setting('xcloner_cron_settings_group', 'xcloner_cron_frequency'); |
529 | 529 | add_settings_field( |
530 | 530 | 'xcloner_cron_frequency', |
531 | - __('Cron frequency','xcloner-backup-and-restore'), |
|
531 | + __('Cron frequency', 'xcloner-backup-and-restore'), |
|
532 | 532 | array($this, 'do_form_text_field'), |
533 | 533 | 'xcloner_cron_settings_page', |
534 | 534 | 'xcloner_cron_settings_group', |
@@ -554,20 +554,20 @@ discard block |
||
554 | 554 | // text field content cb |
555 | 555 | public function do_form_text_field($params) |
556 | 556 | { |
557 | - if(!isset($params['3'])) |
|
557 | + if (!isset($params['3'])) |
|
558 | 558 | $params[3] = 0; |
559 | - if(!isset($params['2'])) |
|
559 | + if (!isset($params['2'])) |
|
560 | 560 | $params[2] = 0; |
561 | 561 | |
562 | 562 | list($fieldname, $label, $value, $disabled) = $params; |
563 | 563 | |
564 | - if(!$value) |
|
564 | + if (!$value) |
|
565 | 565 | $value = get_option($fieldname); |
566 | 566 | // output the field |
567 | 567 | ?> |
568 | 568 | <div class="row"> |
569 | 569 | <div class="input-field col s10 m10 l8"> |
570 | - <input class="validate" <?php echo ($disabled)?"disabled":""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="text" class="validate" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>"> |
|
570 | + <input class="validate" <?php echo ($disabled) ? "disabled" : ""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="text" class="validate" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>"> |
|
571 | 571 | </div> |
572 | 572 | <div class="col s2 m2 "> |
573 | 573 | <a class="btn-floating tooltipped btn-small" data-position="left" data-delay="50" data-tooltip="<?php echo $label?>" data-tooltip-id=""><i class="material-icons">help_outline</i></a> |
@@ -581,20 +581,20 @@ discard block |
||
581 | 581 | // textarea field content cb |
582 | 582 | public function do_form_textarea_field($params) |
583 | 583 | { |
584 | - if(!isset($params['3'])) |
|
584 | + if (!isset($params['3'])) |
|
585 | 585 | $params[3] = 0; |
586 | - if(!isset($params['2'])) |
|
586 | + if (!isset($params['2'])) |
|
587 | 587 | $params[2] = 0; |
588 | 588 | |
589 | 589 | list($fieldname, $label, $value, $disabled) = $params; |
590 | 590 | |
591 | - if(!$value) |
|
591 | + if (!$value) |
|
592 | 592 | $value = get_option($fieldname); |
593 | 593 | // output the field |
594 | 594 | ?> |
595 | 595 | <div class="row"> |
596 | 596 | <div class="input-field col s10 m10 l8"> |
597 | - <textarea class="validate" <?php echo ($disabled)?"disabled":""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="text" class="validate" value=""><?php echo isset($value) ? esc_attr($value) : ''; ?></textarea> |
|
597 | + <textarea class="validate" <?php echo ($disabled) ? "disabled" : ""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="text" class="validate" value=""><?php echo isset($value) ? esc_attr($value) : ''; ?></textarea> |
|
598 | 598 | </div> |
599 | 599 | <div class="col s2 m2 "> |
600 | 600 | <a class="btn-floating tooltipped btn-small" data-position="center" data-html="true" data-delay="50" data-tooltip="<?php echo $label?>" data-tooltip-id=""><i class="material-icons">help_outline</i></a> |
@@ -624,20 +624,20 @@ discard block |
||
624 | 624 | // number field content cb |
625 | 625 | public function do_form_number_field($params) |
626 | 626 | { |
627 | - if(!isset($params['3'])) |
|
627 | + if (!isset($params['3'])) |
|
628 | 628 | $params[3] = 0; |
629 | - if(!isset($params['2'])) |
|
629 | + if (!isset($params['2'])) |
|
630 | 630 | $params[2] = 0; |
631 | 631 | |
632 | 632 | list($fieldname, $label, $value, $disabled) = $params; |
633 | 633 | |
634 | - if(!$value) |
|
634 | + if (!$value) |
|
635 | 635 | $value = get_option($fieldname); |
636 | 636 | // output the field |
637 | 637 | ?> |
638 | 638 | <div class="row"> |
639 | 639 | <div class="input-field col s10 m5 l3"> |
640 | - <input class="validate" <?php echo ($disabled)?"disabled":""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="number" class="validate" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>"> |
|
640 | + <input class="validate" <?php echo ($disabled) ? "disabled" : ""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="number" class="validate" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>"> |
|
641 | 641 | </div> |
642 | 642 | <div class="col s2 m2 "> |
643 | 643 | <a class="btn-floating tooltipped btn-small" data-position="center" data-delay="50" data-tooltip="<?php echo $label?>" data-tooltip-id=""><i class="material-icons">help_outline</i></a> |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | |
651 | 651 | public function do_form_range_field($params) |
652 | 652 | { |
653 | - if(!isset($params['4'])) |
|
653 | + if (!isset($params['4'])) |
|
654 | 654 | $params[4] = 0; |
655 | 655 | |
656 | 656 | list($fieldname, $label, $range_start, $range_end, $disabled) = $params; |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | <div class="row"> |
660 | 660 | <div class="input-field col s10 m10 l8"> |
661 | 661 | <p class="range-field"> |
662 | - <input <?php echo ($disabled)?"disabled":""?> type="range" name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" min="<?php echo $range_start?>" max="<?php echo $range_end?>" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>" /> |
|
662 | + <input <?php echo ($disabled) ? "disabled" : ""?> type="range" name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" min="<?php echo $range_start?>" max="<?php echo $range_end?>" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>" /> |
|
663 | 663 | </p> |
664 | 664 | </div> |
665 | 665 | <div class="col s2 m2 "> |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | |
673 | 673 | public function do_form_switch_field($params) |
674 | 674 | { |
675 | - if(!isset($params['2'])) |
|
675 | + if (!isset($params['2'])) |
|
676 | 676 | $params[2] = 0; |
677 | 677 | list($fieldname, $label, $disabled) = $params; |
678 | 678 | $value = get_option($fieldname); |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | <div class="switch"> |
683 | 683 | <label> |
684 | 684 | Off |
685 | - <input <?php echo ($disabled)?"disabled":""?> type="checkbox" name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" value="1" <?php echo ($value) ? 'checked="checked"' : ''; ?>"> |
|
685 | + <input <?php echo ($disabled) ? "disabled" : ""?> type="checkbox" name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" value="1" <?php echo ($value) ? 'checked="checked"' : ''; ?>"> |
|
686 | 686 | <span class="lever"></span> |
687 | 687 | On |
688 | 688 | </label> |
@@ -88,15 +88,15 @@ discard block |
||
88 | 88 | |
89 | 89 | } |
90 | 90 | |
91 | - public function check_dependencies(){ |
|
91 | + public function check_dependencies() { |
|
92 | 92 | |
93 | 93 | $backup_storage_path = realpath(__DIR__.DS."..".DS."..".DS."..").DS."backups".DS; |
94 | 94 | |
95 | 95 | define("XCLONER_STORAGE_PATH", realpath($backup_storage_path)); |
96 | 96 | |
97 | - if(!is_dir($backup_storage_path)) |
|
97 | + if (!is_dir($backup_storage_path)) |
|
98 | 98 | { |
99 | - if(!@mkdir($backup_storage_path)) |
|
99 | + if (!@mkdir($backup_storage_path)) |
|
100 | 100 | { |
101 | 101 | $status = "error"; |
102 | 102 | $message = sprintf(__("Unable to create the Backup Storage Location Folder %s . Please fix this before starting the backup process."), $backup_storage_path); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | return; |
105 | 105 | } |
106 | 106 | } |
107 | - if(!is_writable($backup_storage_path)) |
|
107 | + if (!is_writable($backup_storage_path)) |
|
108 | 108 | { |
109 | 109 | $status = "error"; |
110 | 110 | $message = sprintf(__("Unable to write to the Backup Storage Location Folder %s . Please fix this before starting the backup process."), $backup_storage_path); |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | public function trigger_message($message, $status = "error", $message_param1 = "", $message_param2 = "", $message_param3 = "") |
119 | 119 | { |
120 | 120 | $message = sprintf(__($message), $message_param1, $message_param2, $message_param3); |
121 | - add_action( 'xcloner_admin_notices', array($this,"trigger_message_notice"), 10, 2); |
|
122 | - do_action( 'xcloner_admin_notices', $message, $status); |
|
121 | + add_action('xcloner_admin_notices', array($this, "trigger_message_notice"), 10, 2); |
|
122 | + do_action('xcloner_admin_notices', $message, $status); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | public function trigger_message_notice($message, $status = "success") |
126 | 126 | { |
127 | 127 | ?> |
128 | 128 | <div class="notice notice-<?php echo $status?> is-dismissible"> |
129 | - <p><?php _e( $message, 'xcloner-backup-and-restore' ); ?></p> |
|
129 | + <p><?php _e($message, 'xcloner-backup-and-restore'); ?></p> |
|
130 | 130 | </div> |
131 | 131 | <?php |
132 | 132 | } |
@@ -153,79 +153,79 @@ discard block |
||
153 | 153 | * The class responsible for orchestrating the actions and filters of the |
154 | 154 | * core plugin. |
155 | 155 | */ |
156 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-loader.php'; |
|
156 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-loader.php'; |
|
157 | 157 | |
158 | 158 | /** |
159 | 159 | * The class responsible for defining internationalization functionality |
160 | 160 | * of the plugin. |
161 | 161 | */ |
162 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-i18n.php'; |
|
162 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-i18n.php'; |
|
163 | 163 | |
164 | 164 | /** |
165 | 165 | * The class responsible for defining all actions that occur in the admin area. |
166 | 166 | */ |
167 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-xcloner-admin.php'; |
|
167 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-xcloner-admin.php'; |
|
168 | 168 | |
169 | 169 | /** |
170 | 170 | * The class responsible for debugging XCloner. |
171 | 171 | */ |
172 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-logger.php'; |
|
172 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-logger.php'; |
|
173 | 173 | |
174 | 174 | /** |
175 | 175 | * The class responsible for defining the admin settings area. |
176 | 176 | */ |
177 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-settings.php'; |
|
177 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-settings.php'; |
|
178 | 178 | |
179 | 179 | /** |
180 | 180 | * The class responsible for defining the Remote Storage settings area. |
181 | 181 | */ |
182 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-remote-storage.php'; |
|
182 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-remote-storage.php'; |
|
183 | 183 | |
184 | 184 | /** |
185 | 185 | * The class responsible for implementing the database backup methods. |
186 | 186 | */ |
187 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-database.php'; |
|
187 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-database.php'; |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * The class responsible for sanitization of users input. |
191 | 191 | */ |
192 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-sanitization.php'; |
|
192 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-sanitization.php'; |
|
193 | 193 | |
194 | 194 | /** |
195 | 195 | * The class responsible for XCloner system requirements validation. |
196 | 196 | */ |
197 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-requirements.php'; |
|
197 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-requirements.php'; |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * The class responsible for XCloner backup archive creation. |
201 | 201 | */ |
202 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-archive.php'; |
|
202 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-archive.php'; |
|
203 | 203 | |
204 | 204 | /** |
205 | 205 | * The class responsible for XCloner API requests. |
206 | 206 | */ |
207 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-api.php'; |
|
207 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-api.php'; |
|
208 | 208 | |
209 | 209 | /** |
210 | 210 | * The class responsible for the XCloner File System methods. |
211 | 211 | */ |
212 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-file-system.php'; |
|
212 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-file-system.php'; |
|
213 | 213 | |
214 | 214 | /** |
215 | 215 | * The class responsible for the XCloner File Transfer methods. |
216 | 216 | */ |
217 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-file-transfer.php'; |
|
217 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-file-transfer.php'; |
|
218 | 218 | |
219 | 219 | /** |
220 | 220 | * The class responsible for the XCloner Scheduler methods. |
221 | 221 | */ |
222 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-scheduler.php'; |
|
222 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-scheduler.php'; |
|
223 | 223 | |
224 | 224 | /** |
225 | 225 | * The class responsible for defining all actions that occur in the public-facing |
226 | 226 | * side of the site. |
227 | 227 | */ |
228 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-xcloner-public.php'; |
|
228 | + require_once plugin_dir_path(dirname(__FILE__)).'public/class-xcloner-public.php'; |
|
229 | 229 | |
230 | 230 | $this->loader = new Xcloner_Loader(); |
231 | 231 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | |
245 | 245 | $plugin_i18n = new Xcloner_i18n(); |
246 | 246 | |
247 | - $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
247 | + $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain'); |
|
248 | 248 | |
249 | 249 | //wp_localize_script( 'ajax-script', 'my_ajax_object', |
250 | 250 | // array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) ); |
@@ -260,11 +260,11 @@ discard block |
||
260 | 260 | */ |
261 | 261 | private function define_admin_hooks() { |
262 | 262 | |
263 | - $plugin_admin = new Xcloner_Admin( $this->get_plugin_name(), $this->get_version() ); |
|
263 | + $plugin_admin = new Xcloner_Admin($this->get_plugin_name(), $this->get_version()); |
|
264 | 264 | $this->plugin_admin = $plugin_admin; |
265 | 265 | |
266 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
267 | - $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
266 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles'); |
|
267 | + $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts'); |
|
268 | 268 | |
269 | 269 | } |
270 | 270 | |
@@ -273,13 +273,13 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @access private |
275 | 275 | */ |
276 | - private function define_admin_menu(){ |
|
276 | + private function define_admin_menu() { |
|
277 | 277 | |
278 | 278 | add_action('admin_menu', array($this->loader, 'xcloner_backup_add_admin_menu')); |
279 | 279 | |
280 | 280 | } |
281 | 281 | |
282 | - private function define_plugin_settings(){ |
|
282 | + private function define_plugin_settings() { |
|
283 | 283 | /** |
284 | 284 | * register wporg_settings_init to the admin_init action hook |
285 | 285 | */ |
@@ -296,10 +296,10 @@ discard block |
||
296 | 296 | */ |
297 | 297 | private function define_public_hooks() { |
298 | 298 | |
299 | - $plugin_public = new Xcloner_Public( $this->get_plugin_name(), $this->get_version() ); |
|
299 | + $plugin_public = new Xcloner_Public($this->get_plugin_name(), $this->get_version()); |
|
300 | 300 | |
301 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
302 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
301 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles'); |
|
302 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts'); |
|
303 | 303 | |
304 | 304 | } |
305 | 305 | |
@@ -308,20 +308,20 @@ discard block |
||
308 | 308 | $logger = new XCloner_Logger("php_system"); |
309 | 309 | $error = error_get_last(); |
310 | 310 | |
311 | - if($error['type'] and $logger) |
|
311 | + if ($error['type'] and $logger) |
|
312 | 312 | { |
313 | - $logger->info($this->friendly_error_type ($error['type']).": ".var_export($error, true)); |
|
313 | + $logger->info($this->friendly_error_type($error['type']).": ".var_export($error, true)); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | } |
317 | 317 | |
318 | 318 | function friendly_error_type($type) { |
319 | - static $levels=null; |
|
320 | - if ($levels===null) { |
|
321 | - $levels=[]; |
|
319 | + static $levels = null; |
|
320 | + if ($levels === null) { |
|
321 | + $levels = []; |
|
322 | 322 | foreach (get_defined_constants() as $key=>$value) { |
323 | - if (strpos($key,'E_')!==0) {continue;} |
|
324 | - $levels[$value]= $key; //substr($key,2); |
|
323 | + if (strpos($key, 'E_') !== 0) {continue; } |
|
324 | + $levels[$value] = $key; //substr($key,2); |
|
325 | 325 | } |
326 | 326 | } |
327 | 327 | return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}"); |
@@ -329,30 +329,30 @@ discard block |
||
329 | 329 | |
330 | 330 | private function define_ajax_hooks() |
331 | 331 | { |
332 | - $plugin_public = new Xcloner_Public( $this->get_plugin_name(), $this->get_version() ); |
|
332 | + $plugin_public = new Xcloner_Public($this->get_plugin_name(), $this->get_version()); |
|
333 | 333 | //$this->loader->add_action( 'wp_ajax_get_database_tables_action', $plugin_public, array('Xcloner_Api','get_database_tables_action') ); |
334 | 334 | |
335 | - if(is_admin()) |
|
335 | + if (is_admin()) |
|
336 | 336 | { |
337 | 337 | $xcloner_api = new Xcloner_Api(); |
338 | 338 | |
339 | - add_action( 'wp_ajax_get_database_tables_action' , array($xcloner_api,'get_database_tables_action') ); |
|
340 | - add_action( 'wp_ajax_get_file_system_action' , array($xcloner_api,'get_file_system_action') ); |
|
341 | - add_action( 'wp_ajax_scan_filesystem' , array($xcloner_api,'scan_filesystem') ); |
|
342 | - add_action( 'wp_ajax_backup_database' , array($xcloner_api,'backup_database') ); |
|
343 | - add_action( 'wp_ajax_backup_files' , array($xcloner_api,'backup_files') ); |
|
344 | - add_action( 'wp_ajax_save_schedule' , array($xcloner_api,'save_schedule') ); |
|
345 | - add_action( 'wp_ajax_get_schedule_by_id' , array($xcloner_api,'get_schedule_by_id') ); |
|
346 | - add_action( 'wp_ajax_get_scheduler_list' , array($xcloner_api,'get_scheduler_list') ); |
|
347 | - add_action( 'wp_ajax_delete_schedule_by_id' , array($xcloner_api,'delete_schedule_by_id') ); |
|
348 | - add_action( 'wp_ajax_delete_backup_by_name' , array($xcloner_api,'delete_backup_by_name') ); |
|
349 | - add_action( 'wp_ajax_download_backup_by_name' , array($xcloner_api,'download_backup_by_name') ); |
|
350 | - add_action( 'wp_ajax_remote_storage_save_status' , array($xcloner_api,'remote_storage_save_status') ); |
|
351 | - add_action( 'wp_ajax_upload_backup_to_remote' , array($xcloner_api,'upload_backup_to_remote') ); |
|
352 | - add_action( 'wp_ajax_list_backup_files' , array($xcloner_api,'list_backup_files') ); |
|
353 | - add_action( 'wp_ajax_restore_upload_backup' , array($xcloner_api,'restore_upload_backup') ); |
|
354 | - add_action( 'wp_ajax_download_restore_script' , array($xcloner_api,'download_restore_script') ); |
|
355 | - add_action( 'admin_notices', array($this, 'xcloner_error_admin_notices' )); |
|
339 | + add_action('wp_ajax_get_database_tables_action', array($xcloner_api, 'get_database_tables_action')); |
|
340 | + add_action('wp_ajax_get_file_system_action', array($xcloner_api, 'get_file_system_action')); |
|
341 | + add_action('wp_ajax_scan_filesystem', array($xcloner_api, 'scan_filesystem')); |
|
342 | + add_action('wp_ajax_backup_database', array($xcloner_api, 'backup_database')); |
|
343 | + add_action('wp_ajax_backup_files', array($xcloner_api, 'backup_files')); |
|
344 | + add_action('wp_ajax_save_schedule', array($xcloner_api, 'save_schedule')); |
|
345 | + add_action('wp_ajax_get_schedule_by_id', array($xcloner_api, 'get_schedule_by_id')); |
|
346 | + add_action('wp_ajax_get_scheduler_list', array($xcloner_api, 'get_scheduler_list')); |
|
347 | + add_action('wp_ajax_delete_schedule_by_id', array($xcloner_api, 'delete_schedule_by_id')); |
|
348 | + add_action('wp_ajax_delete_backup_by_name', array($xcloner_api, 'delete_backup_by_name')); |
|
349 | + add_action('wp_ajax_download_backup_by_name', array($xcloner_api, 'download_backup_by_name')); |
|
350 | + add_action('wp_ajax_remote_storage_save_status', array($xcloner_api, 'remote_storage_save_status')); |
|
351 | + add_action('wp_ajax_upload_backup_to_remote', array($xcloner_api, 'upload_backup_to_remote')); |
|
352 | + add_action('wp_ajax_list_backup_files', array($xcloner_api, 'list_backup_files')); |
|
353 | + add_action('wp_ajax_restore_upload_backup', array($xcloner_api, 'restore_upload_backup')); |
|
354 | + add_action('wp_ajax_download_restore_script', array($xcloner_api, 'download_restore_script')); |
|
355 | + add_action('admin_notices', array($this, 'xcloner_error_admin_notices')); |
|
356 | 356 | |
357 | 357 | //if (is_admin()) { |
358 | 358 | add_filter('plugin_action_links', array($this, 'add_plugin_action_links'), 10, 2); |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | } |
362 | 362 | |
363 | 363 | function add_plugin_action_links($links, $file) { |
364 | - if ($file == plugin_basename(dirname(dirname(__FILE__)) . '/xcloner.php')) |
|
364 | + if ($file == plugin_basename(dirname(dirname(__FILE__)).'/xcloner.php')) |
|
365 | 365 | { |
366 | 366 | $links[] = '<a href="admin.php?page=xcloner_settings_page">'.__('Settings', 'xcloner-backup-and-restore').'</a>'; |
367 | 367 | $links[] = '<a href="admin.php?page=xcloner_generate_backups_page">'.__('Generate Backup', 'xcloner-backup-and-restore').'</a>'; |
@@ -371,13 +371,13 @@ discard block |
||
371 | 371 | } |
372 | 372 | |
373 | 373 | public function xcloner_error_admin_notices() { |
374 | - settings_errors( 'xcloner_error_message' ); |
|
374 | + settings_errors('xcloner_error_message'); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | public function define_cron_hooks() |
378 | 378 | { |
379 | 379 | //registering new schedule intervals |
380 | - add_filter( 'cron_schedules', array($this, 'add_new_intervals')); |
|
380 | + add_filter('cron_schedules', array($this, 'add_new_intervals')); |
|
381 | 381 | |
382 | 382 | |
383 | 383 | $xcloner_scheduler = new Xcloner_Scheduler(); |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | |
452 | 452 | public function display($page) |
453 | 453 | { |
454 | - $plugin_admin = new Xcloner_Admin( $this->get_plugin_name(), $this->get_version() ); |
|
454 | + $plugin_admin = new Xcloner_Admin($this->get_plugin_name(), $this->get_version()); |
|
455 | 455 | $this->plugin_admin = $plugin_admin; |
456 | 456 | |
457 | 457 | $view = call_user_func_array(array($this->plugin_admin, $page), array()); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | use splitbrain\PHPArchive\FileInfo; |
12 | 12 | |
13 | 13 | |
14 | -class Xcloner_Api{ |
|
14 | +class Xcloner_Api { |
|
15 | 15 | |
16 | 16 | private $xcloner_database; |
17 | 17 | private $xcloner_settings; |
@@ -27,33 +27,33 @@ discard block |
||
27 | 27 | global $wpdb; |
28 | 28 | |
29 | 29 | error_reporting(0); |
30 | - if( ob_get_length() ) |
|
30 | + if (ob_get_length()) |
|
31 | 31 | ob_end_clean(); |
32 | 32 | ob_start(); |
33 | 33 | |
34 | - $wpdb->show_errors = false; |
|
34 | + $wpdb->show_errors = false; |
|
35 | 35 | |
36 | - $this->xcloner_settings = new Xcloner_Settings(); |
|
36 | + $this->xcloner_settings = new Xcloner_Settings(); |
|
37 | 37 | |
38 | 38 | //generating the hash suffix for tmp xcloner store folder |
39 | - if(isset($_POST['hash'])){ |
|
39 | + if (isset($_POST['hash'])) { |
|
40 | 40 | |
41 | - if($_POST['hash'] == "generate_hash") |
|
41 | + if ($_POST['hash'] == "generate_hash") |
|
42 | 42 | $this->xcloner_settings->generate_new_hash(); |
43 | 43 | else |
44 | 44 | $this->xcloner_settings->set_hash($_POST['hash']); |
45 | 45 | } |
46 | 46 | |
47 | - $this->logger = new XCloner_Logger("xcloner_api", $this->xcloner_settings->get_hash()); |
|
47 | + $this->logger = new XCloner_Logger("xcloner_api", $this->xcloner_settings->get_hash()); |
|
48 | 48 | $this->xcloner_file_system = new Xcloner_File_System($this->xcloner_settings->get_hash()); |
49 | 49 | $this->xcloner_sanitization = new Xcloner_Sanitization(); |
50 | 50 | $this->xcloner_requirements = new XCloner_Requirements(); |
51 | - $this->archive_system = new Xcloner_Archive($this->xcloner_settings->get_hash()); |
|
52 | - $this->xcloner_database = new XCloner_Database($this->xcloner_settings->get_hash()); |
|
51 | + $this->archive_system = new Xcloner_Archive($this->xcloner_settings->get_hash()); |
|
52 | + $this->xcloner_database = new XCloner_Database($this->xcloner_settings->get_hash()); |
|
53 | 53 | |
54 | 54 | |
55 | - if(isset($_POST['API_ID'])){ |
|
56 | - $this->logger->info("Processing ajax request ID ".substr($this->xcloner_sanitization->sanitize_input_as_string($_POST['API_ID']), 0 , 15)); |
|
55 | + if (isset($_POST['API_ID'])) { |
|
56 | + $this->logger->info("Processing ajax request ID ".substr($this->xcloner_sanitization->sanitize_input_as_string($_POST['API_ID']), 0, 15)); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | } |
@@ -69,16 +69,16 @@ discard block |
||
69 | 69 | $data['dbDatabase'] = $this->xcloner_settings->get_db_database(); |
70 | 70 | |
71 | 71 | |
72 | - $data['recordsPerSession'] = $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request'); |
|
73 | - $data['TEMP_DBPROCESS_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path().DS.".database"; |
|
74 | - $data['TEMP_DUMP_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path().DS."database-sql.sql"; |
|
72 | + $data['recordsPerSession'] = $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request'); |
|
73 | + $data['TEMP_DBPROCESS_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path().DS.".database"; |
|
74 | + $data['TEMP_DUMP_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path().DS."database-sql.sql"; |
|
75 | 75 | |
76 | 76 | try |
77 | 77 | { |
78 | 78 | //$xcloner_db = new XCloner_Database($data['dbUsername'], $data['dbPassword'], $data['dbDatabase'], $data['dbHostname']); |
79 | 79 | $this->xcloner_database->init($data); |
80 | 80 | |
81 | - }catch(Exception $e) |
|
81 | + }catch (Exception $e) |
|
82 | 82 | { |
83 | 83 | $this->send_response($e->getMessage()); |
84 | 84 | $this->logger->error($e->getMessage()); |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | $params = array(); |
107 | 107 | $schedule = array(); |
108 | 108 | |
109 | - if(isset($_POST['data'])) |
|
109 | + if (isset($_POST['data'])) |
|
110 | 110 | $params = json_decode(stripslashes($_POST['data'])); |
111 | 111 | |
112 | 112 | $this->process_params($params); |
113 | 113 | |
114 | - if(isset($_POST['id'])) |
|
114 | + if (isset($_POST['id'])) |
|
115 | 115 | { |
116 | 116 | |
117 | 117 | $this->form_params['backup_params']['backup_name'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['backup_name']); |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | $tables = explode(PHP_EOL, $this->form_params['database']); |
127 | 127 | $return = array(); |
128 | 128 | |
129 | - foreach($tables as $table) |
|
129 | + foreach ($tables as $table) |
|
130 | 130 | { |
131 | - $table = str_replace("\r","", $table); |
|
131 | + $table = str_replace("\r", "", $table); |
|
132 | 132 | $data = explode(".", $table); |
133 | - if(isset($data[1])) |
|
133 | + if (isset($data[1])) |
|
134 | 134 | $return[$data[0]][] = $data[1]; |
135 | 135 | } |
136 | 136 | |
@@ -139,10 +139,10 @@ discard block |
||
139 | 139 | $excluded_files = explode(PHP_EOL, $this->form_params['excluded_files']); |
140 | 140 | $return = array(); |
141 | 141 | |
142 | - foreach($excluded_files as $file) |
|
142 | + foreach ($excluded_files as $file) |
|
143 | 143 | { |
144 | - $file = str_replace("\r","", $file); |
|
145 | - if($file) |
|
144 | + $file = str_replace("\r", "", $file); |
|
145 | + if ($file) |
|
146 | 146 | $return[] = $file; |
147 | 147 | } |
148 | 148 | |
@@ -151,20 +151,20 @@ discard block |
||
151 | 151 | //print_r($this->form_params['database'] ); |
152 | 152 | //print_r($this->form_params['excluded_files']); |
153 | 153 | |
154 | - $schedule['start_at'] = $this->form_params['backup_params']['start_at'] ; |
|
154 | + $schedule['start_at'] = $this->form_params['backup_params']['start_at']; |
|
155 | 155 | |
156 | - if(!isset($_POST['status'])) |
|
156 | + if (!isset($_POST['status'])) |
|
157 | 157 | $schedule['status'] = 0; |
158 | 158 | else |
159 | 159 | $schedule['status'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['status']); |
160 | - }else{ |
|
160 | + } else { |
|
161 | 161 | |
162 | 162 | $schedule['status'] = 1; |
163 | - $schedule['start_at'] = strtotime($this->form_params['backup_params']['schedule_start_date'] . |
|
163 | + $schedule['start_at'] = strtotime($this->form_params['backup_params']['schedule_start_date']. |
|
164 | 164 | " ".$this->form_params['backup_params']['schedule_start_time']); |
165 | 165 | } |
166 | 166 | |
167 | - if(!$schedule['start_at']) |
|
167 | + if (!$schedule['start_at']) |
|
168 | 168 | $schedule['start_at'] = time(); |
169 | 169 | |
170 | 170 | $schedule['start_at'] = date('Y-m-d H:i:s', $schedule['start_at']); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | $schedule['params'] = json_encode($this->form_params); |
177 | 177 | |
178 | - if(!isset($_POST['id'])) |
|
178 | + if (!isset($_POST['id'])) |
|
179 | 179 | { |
180 | 180 | $insert = $wpdb->insert( |
181 | 181 | $wpdb->prefix.'xcloner_scheduler', |
@@ -185,21 +185,21 @@ discard block |
||
185 | 185 | '%s' |
186 | 186 | ) |
187 | 187 | ); |
188 | - }else { |
|
188 | + } else { |
|
189 | 189 | $insert = $wpdb->update( |
190 | 190 | $wpdb->prefix.'xcloner_scheduler', |
191 | 191 | $schedule, |
192 | - array( 'id' => $_POST['id'] ), |
|
192 | + array('id' => $_POST['id']), |
|
193 | 193 | array( |
194 | 194 | '%s', |
195 | 195 | '%s' |
196 | 196 | ) |
197 | 197 | ); |
198 | 198 | } |
199 | - if(isset($_POST['id'])) |
|
199 | + if (isset($_POST['id'])) |
|
200 | 200 | $scheduler->update_cron_hook($_POST['id']); |
201 | 201 | |
202 | - if( $wpdb->last_error ) { |
|
202 | + if ($wpdb->last_error) { |
|
203 | 203 | $response['error'] = 1; |
204 | 204 | $response['error_message'] = $wpdb->last_error/*."--".$wpdb->last_query*/; |
205 | 205 | |
@@ -224,19 +224,19 @@ discard block |
||
224 | 224 | |
225 | 225 | $params = json_decode(stripslashes($_POST['data'])); |
226 | 226 | |
227 | - $init = (int)$_POST['init']; |
|
227 | + $init = (int)$_POST['init']; |
|
228 | 228 | |
229 | - if($params === NULL) |
|
230 | - die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' ); |
|
229 | + if ($params === NULL) |
|
230 | + die('{"status":false,"msg":"The post_data parameter must be valid JSON"}'); |
|
231 | 231 | |
232 | 232 | $this->process_params($params); |
233 | 233 | |
234 | 234 | $return['finished'] = 1; |
235 | 235 | |
236 | 236 | //$return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], $this->form_params['extra'], $init); |
237 | - try{ |
|
237 | + try { |
|
238 | 238 | $return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], $this->form_params['extra'], $init); |
239 | - }catch(Exception $e) |
|
239 | + }catch (Exception $e) |
|
240 | 240 | { |
241 | 241 | $return = array(); |
242 | 242 | $return['error'] = true; |
@@ -245,25 +245,25 @@ discard block |
||
245 | 245 | return $this->send_response($return, $hash = 1); |
246 | 246 | } |
247 | 247 | |
248 | - if($return['finished']) |
|
248 | + if ($return['finished']) |
|
249 | 249 | { |
250 | 250 | $return['extra']['backup_parent'] = $this->archive_system->get_archive_name_with_extension(); |
251 | - if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension())) |
|
251 | + if ($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension())) |
|
252 | 252 | $return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart(); |
253 | 253 | } |
254 | 254 | |
255 | 255 | $data = $return; |
256 | 256 | |
257 | 257 | //check if backup is finished |
258 | - if($return['finished'] ) |
|
258 | + if ($return['finished']) |
|
259 | 259 | { |
260 | - if(isset($this->form_params['backup_params']['email_notification']) and $to=$this->form_params['backup_params']['email_notification']) |
|
260 | + if (isset($this->form_params['backup_params']['email_notification']) and $to = $this->form_params['backup_params']['email_notification']) |
|
261 | 261 | { |
262 | - try{ |
|
262 | + try { |
|
263 | 263 | $from = ""; |
264 | 264 | $subject = ""; |
265 | 265 | $this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'], $this->form_params); |
266 | - }catch(Exception $e) |
|
266 | + }catch (Exception $e) |
|
267 | 267 | { |
268 | 268 | $this->logger->error($e->getMessage()); |
269 | 269 | } |
@@ -287,17 +287,17 @@ discard block |
||
287 | 287 | |
288 | 288 | $params = json_decode(stripslashes($_POST['data'])); |
289 | 289 | |
290 | - $init = (int)$_POST['init']; |
|
290 | + $init = (int)$_POST['init']; |
|
291 | 291 | |
292 | - if($params === NULL) |
|
293 | - die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' ); |
|
292 | + if ($params === NULL) |
|
293 | + die('{"status":false,"msg":"The post_data parameter must be valid JSON"}'); |
|
294 | 294 | |
295 | 295 | $this->process_params($params); |
296 | 296 | |
297 | 297 | //$xcloner_database = $this->init_db(); |
298 | 298 | $return = $this->xcloner_database->start_database_recursion($this->form_params['database'], $this->form_params['extra'], $init); |
299 | 299 | |
300 | - if(isset($return['error']) and $return['error']) |
|
300 | + if (isset($return['error']) and $return['error']) |
|
301 | 301 | $data['finished'] = 1; |
302 | 302 | else |
303 | 303 | $data['finished'] = $return['finished']; |
@@ -319,10 +319,10 @@ discard block |
||
319 | 319 | } |
320 | 320 | |
321 | 321 | $params = json_decode(stripslashes($_POST['data'])); |
322 | - $init = (int)$_POST['init']; |
|
322 | + $init = (int)$_POST['init']; |
|
323 | 323 | |
324 | - if($params === NULL) |
|
325 | - die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' ); |
|
324 | + if ($params === NULL) |
|
325 | + die('{"status":false,"msg":"The post_data parameter must be valid JSON"}'); |
|
326 | 326 | |
327 | 327 | $hash = $this->process_params($params); |
328 | 328 | |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | $data["finished"] = !$return; |
334 | 334 | $data["total_files_num"] = $this->xcloner_file_system->get_scanned_files_num(); |
335 | 335 | $data["last_logged_file"] = $this->xcloner_file_system->last_logged_file(); |
336 | - $data["total_files_size"] = sprintf("%.2f",$this->xcloner_file_system->get_scanned_files_total_size()/(1024*1024)); |
|
336 | + $data["total_files_size"] = sprintf("%.2f", $this->xcloner_file_system->get_scanned_files_total_size() / (1024 * 1024)); |
|
337 | 337 | |
338 | 338 | return $this->send_response($data, $hash = 1); |
339 | 339 | } |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | */ |
346 | 346 | private function process_params($params) |
347 | 347 | { |
348 | - if(isset($params->hash)) |
|
348 | + if (isset($params->hash)) |
|
349 | 349 | $this->xcloner_settings->set_hash($params->hash); |
350 | 350 | |
351 | 351 | $this->form_params['extra'] = array(); |
@@ -353,9 +353,9 @@ discard block |
||
353 | 353 | |
354 | 354 | $this->form_params['database'] = array(); |
355 | 355 | |
356 | - if(isset($params->backup_params)) |
|
356 | + if (isset($params->backup_params)) |
|
357 | 357 | { |
358 | - foreach($params->backup_params as $param) |
|
358 | + foreach ($params->backup_params as $param) |
|
359 | 359 | { |
360 | 360 | $this->form_params['backup_params'][$param->name] = $this->xcloner_sanitization->sanitize_input_as_string($param->value); |
361 | 361 | $this->logger->debug("Adding form parameter ".$param->name.".".$param->value."\n", array('POST', 'fields filter')); |
@@ -364,28 +364,28 @@ discard block |
||
364 | 364 | |
365 | 365 | $this->form_params['database'] = array(); |
366 | 366 | |
367 | - if(isset($params->table_params)) |
|
367 | + if (isset($params->table_params)) |
|
368 | 368 | { |
369 | - foreach($params->table_params as $param) |
|
369 | + foreach ($params->table_params as $param) |
|
370 | 370 | { |
371 | 371 | $this->form_params['database'][$param->parent][] = $this->xcloner_sanitization->sanitize_input_as_raw($param->id); |
372 | 372 | $this->logger->debug("Adding database filter ".$param->parent.".".$param->id."\n", array('POST', 'database filter')); |
373 | 373 | } |
374 | 374 | } |
375 | 375 | |
376 | - $this->form_params['excluded_files'] = array(); |
|
377 | - if(isset($params->files_params)) |
|
376 | + $this->form_params['excluded_files'] = array(); |
|
377 | + if (isset($params->files_params)) |
|
378 | 378 | { |
379 | - foreach($params->files_params as $param) |
|
379 | + foreach ($params->files_params as $param) |
|
380 | 380 | { |
381 | 381 | $this->form_params['excluded_files'][] = $this->xcloner_sanitization->sanitize_input_as_relative_path($param->id); |
382 | 382 | } |
383 | 383 | |
384 | 384 | $unique_exclude_files = array(); |
385 | 385 | |
386 | - foreach($params->files_params as $key=>$param) |
|
386 | + foreach ($params->files_params as $key=>$param) |
|
387 | 387 | { |
388 | - if(!in_array($param->parent, $this->form_params['excluded_files'])){ |
|
388 | + if (!in_array($param->parent, $this->form_params['excluded_files'])) { |
|
389 | 389 | //$this->form_params['excluded_files'][] = $this->xcloner_sanitization->sanitize_input_as_relative_path($param->id); |
390 | 390 | $unique_exclude_files[] = $param->id; |
391 | 391 | $this->logger->debug("Adding file filter ".$param->id."\n", array('POST', 'exclude files filter')); |
@@ -397,9 +397,9 @@ discard block |
||
397 | 397 | |
398 | 398 | //$this->form_params['excluded_files'] = array_merge($this->form_params['excluded_files'], $this->exclude_files_by_default); |
399 | 399 | |
400 | - if(isset($params->extra)) |
|
400 | + if (isset($params->extra)) |
|
401 | 401 | { |
402 | - foreach($params->extra as $key=>$value) |
|
402 | + foreach ($params->extra as $key=>$value) |
|
403 | 403 | $this->form_params['extra'][$key] = $this->xcloner_sanitization->sanitize_input_as_raw($value); |
404 | 404 | } |
405 | 405 | |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | |
422 | 422 | $data = array(); |
423 | 423 | |
424 | - if($folder == "#"){ |
|
424 | + if ($folder == "#") { |
|
425 | 425 | |
426 | 426 | $folder = "/"; |
427 | 427 | //$list_directory = $this->xcloner_settings->get_xcloner_start_path(); |
@@ -435,9 +435,9 @@ discard block |
||
435 | 435 | ); |
436 | 436 | } |
437 | 437 | |
438 | - try{ |
|
438 | + try { |
|
439 | 439 | $files = $this->xcloner_file_system->list_directory($folder); |
440 | - }catch(Exception $e){ |
|
440 | + }catch (Exception $e) { |
|
441 | 441 | |
442 | 442 | print $e->getMessage(); |
443 | 443 | $this->logger->error($e->getMessage()); |
@@ -452,19 +452,19 @@ discard block |
||
452 | 452 | } |
453 | 453 | array_multisort($type, SORT_ASC, $files); |
454 | 454 | |
455 | - foreach($files as $file) |
|
455 | + foreach ($files as $file) |
|
456 | 456 | { |
457 | 457 | $children = false; |
458 | 458 | $text = $file['basename']; |
459 | 459 | |
460 | - if($file['type'] == "dir") |
|
460 | + if ($file['type'] == "dir") |
|
461 | 461 | $children = true; |
462 | 462 | else |
463 | - $text .= " (". $this->xcloner_requirements->file_format_size($file['size']).")"; |
|
463 | + $text .= " (".$this->xcloner_requirements->file_format_size($file['size']).")"; |
|
464 | 464 | |
465 | 465 | //if(in_array($file['path'], $this->xcloner_file_system->get_excluded_files())) |
466 | 466 | //echo $file['path']."--".$this->xcloner_file_system->is_excluded($file); |
467 | - if($excluded_pattern = $this->xcloner_file_system->is_excluded($file)) |
|
467 | + if ($excluded_pattern = $this->xcloner_file_system->is_excluded($file)) |
|
468 | 468 | $selected = true; |
469 | 469 | else |
470 | 470 | $selected = false; |
@@ -501,25 +501,25 @@ discard block |
||
501 | 501 | |
502 | 502 | $xcloner_backup_only_wp_tables = $this->xcloner_settings->get_xcloner_option('xcloner_backup_only_wp_tables'); |
503 | 503 | |
504 | - if($database == "#") |
|
504 | + if ($database == "#") |
|
505 | 505 | { |
506 | - try{ |
|
506 | + try { |
|
507 | 507 | $return = $this->xcloner_database->get_all_databases(); |
508 | - }catch(Exception $e){ |
|
508 | + }catch (Exception $e) { |
|
509 | 509 | $this->logger->error($e->getMessage()); |
510 | 510 | } |
511 | 511 | |
512 | - foreach($return as $database) |
|
512 | + foreach ($return as $database) |
|
513 | 513 | { |
514 | - if($xcloner_backup_only_wp_tables and $database['name'] != $this->xcloner_settings->get_db_database()) |
|
514 | + if ($xcloner_backup_only_wp_tables and $database['name'] != $this->xcloner_settings->get_db_database()) |
|
515 | 515 | continue; |
516 | 516 | |
517 | 517 | $state = array(); |
518 | 518 | |
519 | - if($database['name'] == $this->xcloner_settings->get_db_database()) |
|
519 | + if ($database['name'] == $this->xcloner_settings->get_db_database()) |
|
520 | 520 | { |
521 | 521 | $state['selected'] = true; |
522 | - if($database['num_tables'] < 25) |
|
522 | + if ($database['num_tables'] < 25) |
|
523 | 523 | $state['opened'] = false; |
524 | 524 | } |
525 | 525 | |
@@ -535,22 +535,22 @@ discard block |
||
535 | 535 | |
536 | 536 | } |
537 | 537 | |
538 | - else{ |
|
538 | + else { |
|
539 | 539 | |
540 | - try{ |
|
540 | + try { |
|
541 | 541 | $return = $this->xcloner_database->list_tables($database, "", 1); |
542 | - }catch(Exception $e){ |
|
542 | + }catch (Exception $e) { |
|
543 | 543 | $this->logger->error($e->getMessage()); |
544 | 544 | } |
545 | 545 | |
546 | - foreach($return as $table) |
|
546 | + foreach ($return as $table) |
|
547 | 547 | { |
548 | 548 | $state = array(); |
549 | 549 | |
550 | - if($xcloner_backup_only_wp_tables and !stristr($table['name'], $this->xcloner_settings->get_table_prefix())) |
|
550 | + if ($xcloner_backup_only_wp_tables and !stristr($table['name'], $this->xcloner_settings->get_table_prefix())) |
|
551 | 551 | continue; |
552 | 552 | |
553 | - if(isset($database['name']) and $database['name'] == $this->xcloner_settings->get_db_database()) |
|
553 | + if (isset($database['name']) and $database['name'] == $this->xcloner_settings->get_db_database()) |
|
554 | 554 | $state = array('selected' => true); |
555 | 555 | |
556 | 556 | $data[] = array( |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | |
581 | 581 | $schedule_id = $this->xcloner_sanitization->sanitize_input_as_int($_GET['id']); |
582 | 582 | $scheduler = new Xcloner_Scheduler(); |
583 | - $data = $scheduler->get_schedule_by_id($schedule_id); |
|
583 | + $data = $scheduler->get_schedule_by_id($schedule_id); |
|
584 | 584 | |
585 | 585 | return $this->send_response($data); |
586 | 586 | } |
@@ -597,14 +597,14 @@ discard block |
||
597 | 597 | } |
598 | 598 | |
599 | 599 | $scheduler = new Xcloner_Scheduler(); |
600 | - $data = $scheduler->get_scheduler_list(); |
|
600 | + $data = $scheduler->get_scheduler_list(); |
|
601 | 601 | $return['data'] = array(); |
602 | 602 | |
603 | - foreach($data as $res) |
|
603 | + foreach ($data as $res) |
|
604 | 604 | { |
605 | 605 | $action = "<a href=\"#".$res->id."\" class=\"edit\" title='Edit'> <i class=\"material-icons \">edit</i></a> |
606 | 606 | <a href=\"#".$res->id."\" class=\"delete\" title='Delete'><i class=\"material-icons \">delete</i></a>"; |
607 | - if($res->status) |
|
607 | + if ($res->status) |
|
608 | 608 | $status = '<i class="material-icons active status">timer</i>'; |
609 | 609 | else |
610 | 610 | $status = '<i class="material-icons status inactive">timer_off</i>'; |
@@ -615,14 +615,14 @@ discard block |
||
615 | 615 | |
616 | 616 | $remote_storage = $res->remote_storage; |
617 | 617 | |
618 | - if(!$next_run_time >= time()) |
|
618 | + if (!$next_run_time >= time()) |
|
619 | 619 | $next_run = " "; |
620 | 620 | |
621 | - if(trim($next_run)) |
|
621 | + if (trim($next_run)) |
|
622 | 622 | { |
623 | 623 | $date_text = $next_run; |
624 | 624 | |
625 | - if($next_run_time >= time()) |
|
625 | + if ($next_run_time >= time()) |
|
626 | 626 | $next_run = "in ".human_time_diff($next_run_time, time()); |
627 | 627 | else |
628 | 628 | $next_run = __("executed", 'xcloner-backup-and-restore'); |
@@ -635,9 +635,9 @@ discard block |
||
635 | 635 | $backup_size = ""; |
636 | 636 | $backup_time = ""; |
637 | 637 | |
638 | - if($res->last_backup) |
|
638 | + if ($res->last_backup) |
|
639 | 639 | { |
640 | - if( $this->xcloner_file_system->get_storage_filesystem()->has($res->last_backup)) |
|
640 | + if ($this->xcloner_file_system->get_storage_filesystem()->has($res->last_backup)) |
|
641 | 641 | { |
642 | 642 | $metadata = $this->xcloner_file_system->get_storage_filesystem()->getMetadata($res->last_backup); |
643 | 643 | $backup_size = size_format($metadata['size']); |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | $backup_text = "<span title='".$backup_time."' class='shorten_string'>".$res->last_backup." (".$backup_size.")</span>"; |
648 | 648 | } |
649 | 649 | |
650 | - $return['data'][] = array($res->id, $res->name, $res->recurrence,/*$res->start_at,*/ $next_run, $remote_storage, $backup_text, $status, $action); |
|
650 | + $return['data'][] = array($res->id, $res->name, $res->recurrence, /*$res->start_at,*/ $next_run, $remote_storage, $backup_text, $status, $action); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | return $this->send_response($return, 0); |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | |
667 | 667 | $schedule_id = $this->xcloner_sanitization->sanitize_input_as_int($_GET['id']); |
668 | 668 | $scheduler = new Xcloner_Scheduler(); |
669 | - $data['finished'] = $scheduler->delete_schedule_by_id($schedule_id); |
|
669 | + $data['finished'] = $scheduler->delete_schedule_by_id($schedule_id); |
|
670 | 670 | |
671 | 671 | return $this->send_response($data); |
672 | 672 | } |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | |
685 | 685 | $backup_name = $this->xcloner_sanitization->sanitize_input_as_string($_POST['name']); |
686 | 686 | |
687 | - $data['finished'] = $this->xcloner_file_system->delete_backup_by_name($backup_name); |
|
687 | + $data['finished'] = $this->xcloner_file_system->delete_backup_by_name($backup_name); |
|
688 | 688 | |
689 | 689 | return $this->send_response($data); |
690 | 690 | } |
@@ -701,32 +701,32 @@ discard block |
||
701 | 701 | |
702 | 702 | $backup_file = $source_backup_file; |
703 | 703 | |
704 | - if($this->xcloner_file_system->is_multipart($backup_file)) |
|
704 | + if ($this->xcloner_file_system->is_multipart($backup_file)) |
|
705 | 705 | { |
706 | 706 | $backup_parts = $this->xcloner_file_system->get_multipart_files($backup_file); |
707 | 707 | $backup_file = $backup_parts[$return['part']]; |
708 | 708 | } |
709 | 709 | |
710 | - try{ |
|
710 | + try { |
|
711 | 711 | $tar = new Tar(); |
712 | 712 | $tar->open($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file, $start); |
713 | 713 | |
714 | 714 | $data = $tar->contents(get_option('xcloner_files_to_process_per_request')); |
715 | - }catch(Exception $e) |
|
715 | + }catch (Exception $e) |
|
716 | 716 | { |
717 | 717 | $return['error'] = true; |
718 | 718 | $return['message'] = $e->getMessage(); |
719 | 719 | $this->send_response($return, 0); |
720 | 720 | } |
721 | 721 | |
722 | - $return['files'] = array(); |
|
723 | - $return['finished'] = 1; |
|
724 | - $return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file); |
|
722 | + $return['files'] = array(); |
|
723 | + $return['finished'] = 1; |
|
724 | + $return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file); |
|
725 | 725 | $i = 0; |
726 | 726 | |
727 | - if(isset($data['extracted_files']) and is_array($data['extracted_files'])) |
|
727 | + if (isset($data['extracted_files']) and is_array($data['extracted_files'])) |
|
728 | 728 | { |
729 | - foreach($data['extracted_files'] as $file) |
|
729 | + foreach ($data['extracted_files'] as $file) |
|
730 | 730 | { |
731 | 731 | $return['files'][$i]['path'] = $file->getPath(); |
732 | 732 | $return['files'][$i]['size'] = $file->getSize(); |
@@ -736,18 +736,18 @@ discard block |
||
736 | 736 | } |
737 | 737 | } |
738 | 738 | |
739 | - if(isset($data['start'])) |
|
739 | + if (isset($data['start'])) |
|
740 | 740 | { |
741 | 741 | $return['start'] = $data['start']; |
742 | 742 | $return['finished'] = 0; |
743 | - }else{ |
|
744 | - if($this->xcloner_file_system->is_multipart($source_backup_file)) |
|
743 | + } else { |
|
744 | + if ($this->xcloner_file_system->is_multipart($source_backup_file)) |
|
745 | 745 | { |
746 | 746 | $return['start'] = 0; |
747 | 747 | |
748 | 748 | ++$return['part']; |
749 | 749 | |
750 | - if($return['part'] < sizeof($backup_parts)) |
|
750 | + if ($return['part'] < sizeof($backup_parts)) |
|
751 | 751 | $return['finished'] = 0; |
752 | 752 | |
753 | 753 | } |
@@ -776,17 +776,17 @@ discard block |
||
776 | 776 | |
777 | 777 | try |
778 | 778 | { |
779 | - if(method_exists($xcloner_remote_storage, "upload_backup_to_storage")) |
|
779 | + if (method_exists($xcloner_remote_storage, "upload_backup_to_storage")) |
|
780 | 780 | { |
781 | 781 | $return = call_user_func_array(array($xcloner_remote_storage, "upload_backup_to_storage"), array($backup_file, $storage_type)); |
782 | 782 | } |
783 | - }catch(Exception $e){ |
|
783 | + }catch (Exception $e) { |
|
784 | 784 | |
785 | 785 | $return['error'] = 1; |
786 | 786 | $return['message'] = $e->getMessage(); |
787 | 787 | } |
788 | 788 | |
789 | - if(!$return) |
|
789 | + if (!$return) |
|
790 | 790 | { |
791 | 791 | $return['error'] = 1; |
792 | 792 | $return['message'] = "Upload failed, please check the error log for more information!"; |
@@ -824,7 +824,7 @@ discard block |
||
824 | 824 | |
825 | 825 | @ob_end_clean(); |
826 | 826 | |
827 | - $adapter = new Local(dirname(__DIR__) ,LOCK_EX, 'SKIP_LINKS'); |
|
827 | + $adapter = new Local(dirname(__DIR__), LOCK_EX, 'SKIP_LINKS'); |
|
828 | 828 | $xcloner_plugin_filesystem = new Filesystem($adapter, new Config([ |
829 | 829 | 'disable_asserts' => true, |
830 | 830 | ])); |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | //$tar->addFile(dirname(__DIR__)."/restore/vendor.tgz", "vendor.tgz"); |
839 | 839 | |
840 | 840 | $files = $xcloner_plugin_filesystem->listContents("vendor/", true); |
841 | - foreach($files as $file) |
|
841 | + foreach ($files as $file) |
|
842 | 842 | { |
843 | 843 | $tar->addFile(dirname(__DIR__).DS.$file['path'], $file['path']); |
844 | 844 | } |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | header('Expires: 0'); |
858 | 858 | header('Cache-Control: must-revalidate'); |
859 | 859 | header('Pragma: public'); |
860 | - header('Content-Length: ' . filesize($tmp_file)); |
|
860 | + header('Content-Length: '.filesize($tmp_file)); |
|
861 | 861 | readfile($tmp_file); |
862 | 862 | |
863 | 863 | } |
@@ -882,9 +882,9 @@ discard block |
||
882 | 882 | $backup_name = $this->xcloner_sanitization->sanitize_input_as_string($_GET['name']); |
883 | 883 | |
884 | 884 | |
885 | - $metadata = $this->xcloner_file_system->get_storage_filesystem()->getMetadata($backup_name); |
|
885 | + $metadata = $this->xcloner_file_system->get_storage_filesystem()->getMetadata($backup_name); |
|
886 | 886 | //$mimetype = $this->xcloner_file_system->get_storage_filesystem()->getMimetype($backup_name); |
887 | - $read_stream = $this->xcloner_file_system->get_storage_filesystem()->readStream($backup_name); |
|
887 | + $read_stream = $this->xcloner_file_system->get_storage_filesystem()->readStream($backup_name); |
|
888 | 888 | |
889 | 889 | |
890 | 890 | header('Pragma: public'); |
@@ -895,7 +895,7 @@ discard block |
||
895 | 895 | header('Content-Disposition: attachment; filename="'.$metadata['path'].'";'); |
896 | 896 | //header('Content-Type: ' . $mimetype); |
897 | 897 | header('Content-Type: application/octet-stream'); |
898 | - header('Content-Length: ' . $metadata['size']); |
|
898 | + header('Content-Length: '.$metadata['size']); |
|
899 | 899 | |
900 | 900 | @ob_end_clean(); |
901 | 901 | |
@@ -925,10 +925,10 @@ discard block |
||
925 | 925 | $file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']); |
926 | 926 | $hash = $this->xcloner_sanitization->sanitize_input_as_string($_POST['hash']); |
927 | 927 | |
928 | - if(isset($_POST['part'])) |
|
928 | + if (isset($_POST['part'])) |
|
929 | 929 | $return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']); |
930 | 930 | |
931 | - if(isset($_POST['uploaded_size'])) |
|
931 | + if (isset($_POST['uploaded_size'])) |
|
932 | 932 | $return['uploaded_size'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['uploaded_size']); |
933 | 933 | |
934 | 934 | $start = $this->xcloner_sanitization->sanitize_input_as_string($_POST['start']); |
@@ -936,46 +936,46 @@ discard block |
||
936 | 936 | |
937 | 937 | $return['total_size'] = $this->xcloner_file_system->get_backup_size($file); |
938 | 938 | |
939 | - if($this->xcloner_file_system->is_multipart($file)) |
|
939 | + if ($this->xcloner_file_system->is_multipart($file)) |
|
940 | 940 | { |
941 | 941 | $backup_parts = $this->xcloner_file_system->get_multipart_files($file); |
942 | 942 | |
943 | - $return['total_parts'] = sizeof($backup_parts)+1; |
|
943 | + $return['total_parts'] = sizeof($backup_parts) + 1; |
|
944 | 944 | |
945 | - if($return['part'] and isset($backup_parts[$return['part']-1])) |
|
945 | + if ($return['part'] and isset($backup_parts[$return['part'] - 1])) |
|
946 | 946 | { |
947 | - $file = $backup_parts[$return['part']-1]; |
|
947 | + $file = $backup_parts[$return['part'] - 1]; |
|
948 | 948 | } |
949 | 949 | |
950 | 950 | $is_multipart = 1; |
951 | 951 | } |
952 | 952 | |
953 | - try{ |
|
953 | + try { |
|
954 | 954 | |
955 | 955 | $xcloner_file_transfer = new Xcloner_File_Transfer(); |
956 | 956 | $xcloner_file_transfer->set_target($target_url); |
957 | 957 | $return['start'] = $xcloner_file_transfer->transfer_file($file, $start, $hash); |
958 | 958 | |
959 | - }catch(Exception $e){ |
|
959 | + }catch (Exception $e) { |
|
960 | 960 | |
961 | 961 | $return = array(); |
962 | 962 | $return['error'] = true; |
963 | 963 | $return['status'] = 500; |
964 | 964 | $return['message'] = "CURL communication error with the restore host. ".$e->getMessage(); |
965 | - $this->send_response( $return, 0); |
|
965 | + $this->send_response($return, 0); |
|
966 | 966 | |
967 | 967 | } |
968 | 968 | |
969 | 969 | $return['status'] = 200; |
970 | 970 | |
971 | 971 | //we have finished the upload |
972 | - if(!$return['start'] and $is_multipart) |
|
972 | + if (!$return['start'] and $is_multipart) |
|
973 | 973 | { |
974 | 974 | $return['part']++; |
975 | 975 | $return['uploaded_size'] += $this->xcloner_file_system->get_storage_filesystem()->getSize($file); |
976 | 976 | } |
977 | 977 | |
978 | - $this->send_response( $return, 0); |
|
978 | + $this->send_response($return, 0); |
|
979 | 979 | } |
980 | 980 | /* |
981 | 981 | * |
@@ -985,12 +985,12 @@ discard block |
||
985 | 985 | private function send_response($data, $attach_hash = 1) |
986 | 986 | { |
987 | 987 | |
988 | - if($attach_hash and null !== $this->xcloner_settings->get_hash()) |
|
988 | + if ($attach_hash and null !== $this->xcloner_settings->get_hash()) |
|
989 | 989 | { |
990 | 990 | $data['hash'] = $this->xcloner_settings->get_hash(); |
991 | 991 | } |
992 | 992 | |
993 | - if( ob_get_length() ) |
|
993 | + if (ob_get_length()) |
|
994 | 994 | ob_clean(); |
995 | 995 | wp_send_json($data); |
996 | 996 |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | */ |
22 | 22 | |
23 | 23 | |
24 | -class XCloner_Database extends wpdb{ |
|
24 | +class XCloner_Database extends wpdb { |
|
25 | 25 | |
26 | 26 | |
27 | - public $debug = 0; |
|
28 | - public $recordsPerSession = 10000; |
|
29 | - public $dbCompatibility = ""; |
|
27 | + public $debug = 0; |
|
28 | + public $recordsPerSession = 10000; |
|
29 | + public $dbCompatibility = ""; |
|
30 | 30 | public $dbDropSyntax = 1; |
31 | 31 | public $countRecords = 0; |
32 | 32 | |
@@ -38,22 +38,22 @@ discard block |
||
38 | 38 | private $TEMP_DBPROCESS_FILE = ".database"; |
39 | 39 | private $TEMP_DUMP_FILE = "database-backup.sql"; |
40 | 40 | |
41 | - public function __construct($hash="", $wp_user="", $wp_pass="", $wp_db="", $wp_host="") |
|
41 | + public function __construct($hash = "", $wp_user = "", $wp_pass = "", $wp_db = "", $wp_host = "") |
|
42 | 42 | { |
43 | - $this->logger = new XCloner_Logger("xcloner_database", $hash); |
|
44 | - $this->xcloner_settings = new Xcloner_Settings($hash); |
|
45 | - $this->fs = new Xcloner_File_System($hash); |
|
43 | + $this->logger = new XCloner_Logger("xcloner_database", $hash); |
|
44 | + $this->xcloner_settings = new Xcloner_Settings($hash); |
|
45 | + $this->fs = new Xcloner_File_System($hash); |
|
46 | 46 | |
47 | - if($this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request')) |
|
48 | - $this->recordsPerSession = $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request'); |
|
47 | + if ($this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request')) |
|
48 | + $this->recordsPerSession = $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request'); |
|
49 | 49 | |
50 | - if(!$this->recordsPerSession) |
|
50 | + if (!$this->recordsPerSession) |
|
51 | 51 | $this->recordsPerSession = 100; |
52 | 52 | |
53 | 53 | $wp_host = $this->xcloner_settings->get_db_hostname(); |
54 | 54 | $wp_user = $this->xcloner_settings->get_db_username(); |
55 | 55 | $wp_pass = $this->xcloner_settings->get_db_password(); |
56 | - $wp_db = $this->xcloner_settings->get_db_database(); |
|
56 | + $wp_db = $this->xcloner_settings->get_db_database(); |
|
57 | 57 | |
58 | 58 | parent::__construct($wp_user, $wp_pass, $wp_db, $wp_host); |
59 | 59 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function init($data, $start = 0) |
70 | 70 | { |
71 | - if($start and $this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)){ |
|
71 | + if ($start and $this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) { |
|
72 | 72 | $this->fs->get_tmp_filesystem()->delete($this->TEMP_DBPROCESS_FILE); |
73 | 73 | } |
74 | 74 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | "database_count"=>0, |
88 | 88 | ); |
89 | 89 | |
90 | - if(!$this->xcloner_settings->get_enable_mysql_backup()) |
|
90 | + if (!$this->xcloner_settings->get_enable_mysql_backup()) |
|
91 | 91 | { |
92 | 92 | $return['finished'] = 1; |
93 | 93 | return $return; |
@@ -97,44 +97,44 @@ discard block |
||
97 | 97 | |
98 | 98 | $this->init($params, $init); |
99 | 99 | |
100 | - if($init) |
|
100 | + if ($init) |
|
101 | 101 | { |
102 | 102 | $db_count = 0; |
103 | 103 | |
104 | - if(isset($params['#'])) |
|
104 | + if (isset($params['#'])) |
|
105 | 105 | { |
106 | - foreach($params['#'] as $database) |
|
106 | + foreach ($params['#'] as $database) |
|
107 | 107 | { |
108 | - if(!isset($params[$database]) or !is_array($params[$database])) |
|
108 | + if (!isset($params[$database]) or !is_array($params[$database])) |
|
109 | 109 | $params[$database] = array(); |
110 | 110 | } |
111 | 111 | $db_count = -1; |
112 | 112 | } |
113 | 113 | |
114 | - if(isset($params) and is_array($params)) |
|
115 | - foreach($params as $database=>$tables) |
|
114 | + if (isset($params) and is_array($params)) |
|
115 | + foreach ($params as $database=>$tables) |
|
116 | 116 | { |
117 | - if($database != "#") |
|
117 | + if ($database != "#") |
|
118 | 118 | { |
119 | 119 | $stats = $this->write_backup_process_list($database, $tables); |
120 | - $return['stats']['tables_count'] += $stats['tables_count']; |
|
121 | - $return['stats']['total_records'] += $stats['total_records']; |
|
120 | + $return['stats']['tables_count'] += $stats['tables_count']; |
|
121 | + $return['stats']['total_records'] += $stats['total_records']; |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
125 | - if(sizeof($params)) |
|
126 | - $return['stats']['database_count'] = sizeof($params)+$db_count; |
|
125 | + if (sizeof($params)) |
|
126 | + $return['stats']['database_count'] = sizeof($params) + $db_count; |
|
127 | 127 | else |
128 | 128 | $return['stats']['database_count'] = 0; |
129 | 129 | |
130 | 130 | return $return; |
131 | 131 | } |
132 | 132 | |
133 | - if(!isset($extra_params['startAtLine'])) |
|
133 | + if (!isset($extra_params['startAtLine'])) |
|
134 | 134 | $extra_params['startAtLine'] = 0; |
135 | - if(!isset($extra_params['startAtRecord'])) |
|
135 | + if (!isset($extra_params['startAtRecord'])) |
|
136 | 136 | $extra_params['startAtRecord'] = 0; |
137 | - if(!isset($extra_params['dumpfile'])) |
|
137 | + if (!isset($extra_params['dumpfile'])) |
|
138 | 138 | $extra_params['dumpfile'] = ""; |
139 | 139 | |
140 | 140 | $return = $this->process_incremental($extra_params['startAtLine'], $extra_params['startAtRecord'], $extra_params['dumpfile']); |
@@ -145,13 +145,13 @@ discard block |
||
145 | 145 | public function log($message = "") |
146 | 146 | { |
147 | 147 | |
148 | - if($message){ |
|
149 | - $this->logger->info( $message, array("")); |
|
150 | - }else{ |
|
151 | - if($this->last_query) |
|
152 | - $this->logger->debug( $this->last_query, array("")); |
|
153 | - if($this->last_error) |
|
154 | - $this->logger->error( $this->last_error, array("")); |
|
148 | + if ($message) { |
|
149 | + $this->logger->info($message, array("")); |
|
150 | + } else { |
|
151 | + if ($this->last_query) |
|
152 | + $this->logger->debug($this->last_query, array("")); |
|
153 | + if ($this->last_error) |
|
154 | + $this->logger->error($this->last_error, array("")); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function error($message) |
168 | 168 | { |
169 | - $this->logger->error( $message, array("")); |
|
169 | + $this->logger->error($message, array("")); |
|
170 | 170 | |
171 | 171 | return; |
172 | 172 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | |
200 | 200 | $query = "show tables in `".$database."`"; |
201 | 201 | |
202 | - $res = $this->get_results($query); |
|
202 | + $res = $this->get_results($query); |
|
203 | 203 | $this->log(); |
204 | 204 | |
205 | 205 | return count($res); |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | $databases_list[$i]['num_tables'] = $this->get_database_num_tables($this->dbname); |
223 | 223 | $i++; |
224 | 224 | |
225 | - if(is_array($databases)) |
|
226 | - foreach( $databases as $db){ |
|
227 | - if($db->Database != $this->dbname) |
|
225 | + if (is_array($databases)) |
|
226 | + foreach ($databases as $db) { |
|
227 | + if ($db->Database != $this->dbname) |
|
228 | 228 | { |
229 | 229 | $databases_list[$i]['name'] = $db->Database; |
230 | 230 | $databases_list[$i]['num_tables'] = $this->get_database_num_tables($db->Database); |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | $tablesList[0] = array( ); |
248 | 248 | $inc = 0; |
249 | 249 | |
250 | - if(!$database) |
|
250 | + if (!$database) |
|
251 | 251 | $database = $this->dbname; |
252 | 252 | |
253 | 253 | $this->logger->debug(sprintf(("Listing tables in %s database"), $database)); |
@@ -255,14 +255,14 @@ discard block |
||
255 | 255 | $tables = $this->get_results("SHOW TABLES in `".$database."`"); |
256 | 256 | $this->log(); |
257 | 257 | |
258 | - foreach ($tables as $table){ |
|
258 | + foreach ($tables as $table) { |
|
259 | 259 | |
260 | 260 | $table = array_values((array)$table)[0]; |
261 | 261 | |
262 | 262 | $tablesList[$inc]['name'] = $table; |
263 | 263 | $tablesList[$inc]['database'] = $database; |
264 | 264 | |
265 | - if($get_num_records) |
|
265 | + if ($get_num_records) |
|
266 | 266 | { |
267 | 267 | $records_num_result = $this->get_var("SELECT count(*) FROM `".$database."`.`".$table."`"); |
268 | 268 | $this->log(); |
@@ -272,8 +272,8 @@ discard block |
||
272 | 272 | |
273 | 273 | $tablesList[$inc]['excluded'] = 0; |
274 | 274 | |
275 | - if(sizeof($included) and is_array($included)) |
|
276 | - if(!in_array($table, $included) ) |
|
275 | + if (sizeof($included) and is_array($included)) |
|
276 | + if (!in_array($table, $included)) |
|
277 | 277 | { |
278 | 278 | $tablesList[$inc]['excluded'] = 1; |
279 | 279 | $this->log(sprintf(__("Excluding table %s.%s from backup"), $table, $database)); |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | |
295 | 295 | $tables = $this->list_tables($dbname, $incl_tables, 1); |
296 | 296 | |
297 | - if($this->dbname != $dbname) |
|
297 | + if ($this->dbname != $dbname) |
|
298 | 298 | $dumpfile = $dbname."-backup.sql"; |
299 | 299 | else |
300 | 300 | $dumpfile = $this->TEMP_DUMP_FILE; |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | $this->fs->get_tmp_filesystem_append()->write($this->TEMP_DBPROCESS_FILE, $line); |
304 | 304 | |
305 | 305 | // write this to the class and write to $TEMP_DBPROCESS_FILE file as database.table records |
306 | - foreach($tables as $key=>$table) |
|
307 | - if($table!= "" and !$tables[$key]['excluded']){ |
|
306 | + foreach ($tables as $key=>$table) |
|
307 | + if ($table != "" and !$tables[$key]['excluded']) { |
|
308 | 308 | |
309 | 309 | $line = sprintf("`%s`.`%s`\t%s\t%s\n", $dbname, $tables[$key]['name'], $tables[$key]['records'], $tables[$key]['excluded']); |
310 | 310 | $this->fs->get_tmp_filesystem_append()->write($this->TEMP_DBPROCESS_FILE, $line); |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | |
333 | 333 | $result = $this->get_var("SELECT count(*) FROM $table;"); |
334 | 334 | |
335 | - return intval($result) ;// not max limit on 32 bit systems 2147483647; on 64 bit 999999999999 |
|
335 | + return intval($result); // not max limit on 32 bit systems 2147483647; on 64 bit 999999999999 |
|
336 | 336 | |
337 | 337 | } |
338 | 338 | |
@@ -348,25 +348,25 @@ discard block |
||
348 | 348 | * int $dbDropSyntax - check if the DROP TABLE syntax should be added |
349 | 349 | * @return array $return |
350 | 350 | */ |
351 | - public function process_incremental($startAtLine= 0, $startAtRecord = 0, $dumpfile = "", $dbCompatibility= ""){ |
|
351 | + public function process_incremental($startAtLine = 0, $startAtRecord = 0, $dumpfile = "", $dbCompatibility = "") { |
|
352 | 352 | |
353 | 353 | $count = 0; |
354 | 354 | $return['finished'] = 0; |
355 | 355 | $lines = array(); |
356 | 356 | |
357 | - if($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) |
|
358 | - $lines = array_filter(explode("\n",$this->fs->get_tmp_filesystem()->read($this->TEMP_DBPROCESS_FILE))); |
|
357 | + if ($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) |
|
358 | + $lines = array_filter(explode("\n", $this->fs->get_tmp_filesystem()->read($this->TEMP_DBPROCESS_FILE))); |
|
359 | 359 | |
360 | - foreach ($lines as $buffer){ |
|
360 | + foreach ($lines as $buffer) { |
|
361 | 361 | |
362 | - if($count == $startAtLine) |
|
362 | + if ($count == $startAtLine) |
|
363 | 363 | { |
364 | 364 | |
365 | - $tableInfo =explode("\t", $buffer); |
|
365 | + $tableInfo = explode("\t", $buffer); |
|
366 | 366 | |
367 | - if($tableInfo[0] == "###newdump###"){ |
|
367 | + if ($tableInfo[0] == "###newdump###") { |
|
368 | 368 | // we create a new mysql dump file |
369 | - if($dumpfile != ""){ |
|
369 | + if ($dumpfile != "") { |
|
370 | 370 | // we finished a previous one and write the footers |
371 | 371 | $return['dumpsize'] = $this->data_footers($dumpfile); |
372 | 372 | } |
@@ -380,13 +380,13 @@ discard block |
||
380 | 380 | $startAtLine++; |
381 | 381 | $return['new_dump'] = 1; |
382 | 382 | //break; |
383 | - }else{ |
|
383 | + } else { |
|
384 | 384 | //we export the table |
385 | - if($tableInfo[0] == "###enddump###") |
|
385 | + if ($tableInfo[0] == "###enddump###") |
|
386 | 386 | $return['endDump'] = 1; |
387 | 387 | |
388 | 388 | //table is excluded |
389 | - if($tableInfo[2]) |
|
389 | + if ($tableInfo[2]) |
|
390 | 390 | continue; |
391 | 391 | |
392 | 392 | $next = $startAtRecord + $this->recordsPerSession; |
@@ -398,29 +398,29 @@ discard block |
||
398 | 398 | |
399 | 399 | //return something to the browser |
400 | 400 | $return['databaseName'] = $databaseName; |
401 | - $return['tableName'] = $tableName; |
|
401 | + $return['tableName'] = $tableName; |
|
402 | 402 | $return['totalRecords'] = $tableInfo[1]; |
403 | 403 | |
404 | 404 | //if(intval($return['totalRecords']) != 0) |
405 | 405 | //print_r($tableInfo); |
406 | 406 | |
407 | - if(trim($tableName) !="" and !$tableInfo[2]) |
|
407 | + if (trim($tableName) != "" and !$tableInfo[2]) |
|
408 | 408 | $processed_records = $this->export_table($databaseName, $tableName, $startAtRecord, $this->recordsPerSession, $dumpfile); |
409 | 409 | |
410 | - $return['processedRecords'] = $startAtRecord+$processed_records; |
|
410 | + $return['processedRecords'] = $startAtRecord + $processed_records; |
|
411 | 411 | |
412 | - if($next >= $tableInfo[1]) //we finished loading the records for next sessions, will go to the new record |
|
412 | + if ($next >= $tableInfo[1]) //we finished loading the records for next sessions, will go to the new record |
|
413 | 413 | { |
414 | - $startAtLine ++; |
|
414 | + $startAtLine++; |
|
415 | 415 | $startAtRecord = 0; |
416 | - }else{ |
|
416 | + } else { |
|
417 | 417 | $startAtRecord = $startAtRecord + $this->recordsPerSession; |
418 | 418 | } |
419 | 419 | |
420 | 420 | //$return['dbCompatibility'] = self::$dbCompatibility; |
421 | 421 | |
422 | - $return['startAtLine'] = $startAtLine; |
|
423 | - $return['startAtRecord'] = $startAtRecord; |
|
422 | + $return['startAtLine'] = $startAtLine; |
|
423 | + $return['startAtRecord'] = $startAtRecord; |
|
424 | 424 | $return['dumpfile'] = $dumpfile; |
425 | 425 | $return['dumpsize'] = $this->fs->get_tmp_filesystem_append()->getSize($dumpfile); |
426 | 426 | |
@@ -438,15 +438,15 @@ discard block |
||
438 | 438 | } |
439 | 439 | |
440 | 440 | //while is finished, lets go home... |
441 | - if($dumpfile != ""){ |
|
441 | + if ($dumpfile != "") { |
|
442 | 442 | // we finished a previous one and write the footers |
443 | 443 | $return['dumpsize'] = $this->data_footers($dumpfile); |
444 | 444 | $return['dumpfile'] = ($dumpfile); |
445 | 445 | } |
446 | 446 | $return['finished'] = 1; |
447 | - $return['startAtLine'] = $startAtLine; |
|
447 | + $return['startAtLine'] = $startAtLine; |
|
448 | 448 | |
449 | - if($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) |
|
449 | + if ($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) |
|
450 | 450 | $this->fs->get_tmp_filesystem()->delete($this->TEMP_DBPROCESS_FILE); |
451 | 451 | |
452 | 452 | $this->logger->debug(sprintf(("Database backup finished!"))); |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | |
476 | 476 | $records = 0; |
477 | 477 | |
478 | - if($start == 0) |
|
478 | + if ($start == 0) |
|
479 | 479 | $this->dump_structure($databaseName, $tableName, $dumpfile); |
480 | 480 | |
481 | 481 | $start = intval($start); |
@@ -483,20 +483,20 @@ discard block |
||
483 | 483 | //exporting the table content now |
484 | 484 | |
485 | 485 | $query = "SELECT * from `$databaseName`.`$tableName` Limit $start, $limit ;"; |
486 | - if($this->use_mysqli) |
|
486 | + if ($this->use_mysqli) |
|
487 | 487 | { |
488 | 488 | $result = mysqli_query($this->dbh, $query); |
489 | 489 | $mysql_fetch_function = "mysqli_fetch_array"; |
490 | 490 | |
491 | - }else{ |
|
491 | + } else { |
|
492 | 492 | $result = mysql_query($query, $this->dbh); |
493 | 493 | $mysql_fetch_function = "mysql_fetch_array"; |
494 | 494 | } |
495 | 495 | //$result = $this->get_results($query, ARRAY_N); |
496 | 496 | //print_r($result); exit; |
497 | 497 | |
498 | - if($result){ |
|
499 | - while($row = $mysql_fetch_function($result, MYSQLI_ASSOC)){ |
|
498 | + if ($result) { |
|
499 | + while ($row = $mysql_fetch_function($result, MYSQLI_ASSOC)) { |
|
500 | 500 | |
501 | 501 | $this->fs->get_tmp_filesystem_append()->write($dumpfile, "INSERT INTO `$tableName` VALUES ("); |
502 | 502 | $arr = $row; |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | $value = $this->_real_escape($value); |
508 | 508 | $buffer .= "'".$value."', "; |
509 | 509 | } |
510 | - $buffer = rtrim($buffer, ', ') . ");\n"; |
|
510 | + $buffer = rtrim($buffer, ', ').");\n"; |
|
511 | 511 | $this->fs->get_tmp_filesystem_append()->write($dumpfile, $buffer); |
512 | 512 | unset($buffer); |
513 | 513 | |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | |
523 | 523 | } |
524 | 524 | |
525 | - public function dump_structure($databaseName, $tableName ,$dumpfile) |
|
525 | + public function dump_structure($databaseName, $tableName, $dumpfile) |
|
526 | 526 | { |
527 | 527 | $this->log(sprintf(__("Dumping the structure for %s.%s table"), $databaseName, $tableName)); |
528 | 528 | |
@@ -537,14 +537,14 @@ discard block |
||
537 | 537 | |
538 | 538 | //$result = mysqli_query($this->dbh,"SHOW CREATE table `$databaseName`.`$tableName`;"); |
539 | 539 | $result = $this->get_row("SHOW CREATE table `$databaseName`.`$tableName`;", ARRAY_N); |
540 | - if($result){ |
|
540 | + if ($result) { |
|
541 | 541 | //$row = mysqli_fetch_row( $result); |
542 | 542 | $line = ($result[1].";\n"); |
543 | 543 | $this->fs->get_tmp_filesystem_append()->write($dumpfile, $line); |
544 | 544 | } |
545 | 545 | |
546 | - $line = ( "\n#\n# End Structure for table `$tableName`\n#\n\n"); |
|
547 | - $line .=("#\n# Dumping data for table `$tableName`\n#\n\n"); |
|
546 | + $line = ("\n#\n# End Structure for table `$tableName`\n#\n\n"); |
|
547 | + $line .= ("#\n# Dumping data for table `$tableName`\n#\n\n"); |
|
548 | 548 | $this->fs->get_tmp_filesystem_append()->write($dumpfile, $line); |
549 | 549 | |
550 | 550 | return; |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | |
568 | 568 | } |
569 | 569 | |
570 | - public function resetcountRecords(){ |
|
570 | + public function resetcountRecords() { |
|
571 | 571 | |
572 | 572 | $this->countRecords = 0; |
573 | 573 | |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | |
576 | 576 | } |
577 | 577 | |
578 | - public function getcountRecords(){ |
|
578 | + public function getcountRecords() { |
|
579 | 579 | |
580 | 580 | return $this->countRecords; |
581 | 581 | |
@@ -592,14 +592,14 @@ discard block |
||
592 | 592 | $return .= "# Powered by XCloner Site Backup\n"; |
593 | 593 | $return .= "# http://www.xcloner.com\n"; |
594 | 594 | $return .= "#\n"; |
595 | - $return .= "# Host: " . $_SERVER['HTTP_HOST'] . "\n"; |
|
596 | - $return .= "# Generation Time: " . date("M j, Y \a\\t H:i") . "\n"; |
|
597 | - $return .= "# PHP Version: " . phpversion() . "\n"; |
|
598 | - $return .= "# Database Charset: ". $this->charset . "\n"; |
|
595 | + $return .= "# Host: ".$_SERVER['HTTP_HOST']."\n"; |
|
596 | + $return .= "# Generation Time: ".date("M j, Y \a\\t H:i")."\n"; |
|
597 | + $return .= "# PHP Version: ".phpversion()."\n"; |
|
598 | + $return .= "# Database Charset: ".$this->charset."\n"; |
|
599 | 599 | |
600 | 600 | $results = $this->get_results("SHOW VARIABLES LIKE \"%version%\";", ARRAY_N); |
601 | - if(isset($results)){ |
|
602 | - foreach($results as $result){ |
|
601 | + if (isset($results)) { |
|
602 | + foreach ($results as $result) { |
|
603 | 603 | |
604 | 604 | $return .= "# MYSQL ".$result[0].": ".$result[1]."\n"; |
605 | 605 | |
@@ -609,13 +609,13 @@ discard block |
||
609 | 609 | $results = $this->get_results("SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME |
610 | 610 | FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '".$database."';"); |
611 | 611 | |
612 | - if(isset($results[0])){ |
|
612 | + if (isset($results[0])) { |
|
613 | 613 | |
614 | 614 | $return .= "# MYSQL DEFAULT_CHARACTER_SET_NAME: ".$results[0]->DEFAULT_CHARACTER_SET_NAME."\n"; |
615 | 615 | $return .= "# MYSQL SCHEMA_NAME: ".$results[0]->DEFAULT_COLLATION_NAME."\n"; |
616 | 616 | } |
617 | 617 | |
618 | - $return .= "#\n# Database : `" . $database . "`\n# --------------------------------------------------------\n\n"; |
|
618 | + $return .= "#\n# Database : `".$database."`\n# --------------------------------------------------------\n\n"; |
|
619 | 619 | |
620 | 620 | $this->log(sprintf(__("Writing %s database dump headers"), $database)); |
621 | 621 |