@@ -61,8 +61,9 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function enqueue_styles($hook) { |
63 | 63 | |
64 | - if(!stristr($hook, "page_".$this->plugin_name) || (isset($_GET['option']) and $_GET['option']=="com_cloner")) |
|
65 | - return; |
|
64 | + if(!stristr($hook, "page_".$this->plugin_name) || (isset($_GET['option']) and $_GET['option']=="com_cloner")) { |
|
65 | + return; |
|
66 | + } |
|
66 | 67 | |
67 | 68 | /** |
68 | 69 | * This function is provided for demonstration purposes only. |
@@ -93,8 +94,9 @@ discard block |
||
93 | 94 | */ |
94 | 95 | public function enqueue_scripts($hook) { |
95 | 96 | |
96 | - if(!stristr($hook, "page_".$this->plugin_name)) |
|
97 | - return; |
|
97 | + if(!stristr($hook, "page_".$this->plugin_name)) { |
|
98 | + return; |
|
99 | + } |
|
98 | 100 | |
99 | 101 | /** |
100 | 102 | * This function is provided for demonstration purposes only. |
@@ -234,15 +236,15 @@ discard block |
||
234 | 236 | settings_fields('xcloner_general_settings_group'); |
235 | 237 | do_settings_sections('xcloner_settings_page'); |
236 | 238 | |
237 | - }elseif( $active_tab == 'mysql_options' ) { |
|
239 | + } elseif( $active_tab == 'mysql_options' ) { |
|
238 | 240 | |
239 | 241 | settings_fields('xcloner_mysql_settings_group'); |
240 | 242 | do_settings_sections('xcloner_mysql_settings_page'); |
241 | - }elseif( $active_tab == 'system_options' ) { |
|
243 | + } elseif( $active_tab == 'system_options' ) { |
|
242 | 244 | |
243 | 245 | settings_fields('xcloner_system_settings_group'); |
244 | 246 | do_settings_sections('xcloner_system_settings_page'); |
245 | - }elseif( $active_tab == 'cleanup_options' ) { |
|
247 | + } elseif( $active_tab == 'cleanup_options' ) { |
|
246 | 248 | |
247 | 249 | settings_fields('xcloner_cleanup_settings_group'); |
248 | 250 | do_settings_sections('xcloner_cleanup_settings_page'); |
@@ -45,8 +45,6 @@ |
||
45 | 45 | * Initialize the class and set its properties. |
46 | 46 | * |
47 | 47 | * @since 1.0.0 |
48 | - * @param string $plugin_name The name of this plugin. |
|
49 | - * @param string $version The version of this plugin. |
|
50 | 48 | */ |
51 | 49 | public function __construct( Xcloner $xcloner_container) { |
52 | 50 |
@@ -221,28 +221,28 @@ discard block |
||
221 | 221 | |
222 | 222 | // add error/update messages |
223 | 223 | |
224 | - // check if the user have submitted the settings |
|
225 | - // wordpress will add the "settings-updated" $_GET parameter to the url |
|
226 | - if (isset($_GET['settings-updated'])) { |
|
227 | - // add settings saved message with the class of "updated" |
|
228 | - add_settings_error('wporg_messages', 'wporg_message', __('Settings Saved', 'wporg'), 'updated'); |
|
229 | - } |
|
224 | + // check if the user have submitted the settings |
|
225 | + // wordpress will add the "settings-updated" $_GET parameter to the url |
|
226 | + if (isset($_GET['settings-updated'])) { |
|
227 | + // add settings saved message with the class of "updated" |
|
228 | + add_settings_error('wporg_messages', 'wporg_message', __('Settings Saved', 'wporg'), 'updated'); |
|
229 | + } |
|
230 | 230 | |
231 | - // show error/update messages |
|
232 | - settings_errors('wporg_messages'); |
|
233 | - ?> |
|
231 | + // show error/update messages |
|
232 | + settings_errors('wporg_messages'); |
|
233 | + ?> |
|
234 | 234 | |
235 | 235 | <?php |
236 | 236 | $xcloner_sanitization = $this->get_xcloner_container()->get_xcloner_sanitization(); |
237 | 237 | |
238 | - if( isset( $_GET[ 'tab' ] ) ) { |
|
239 | - $active_tab = $xcloner_sanitization->sanitize_input_as_string($_GET[ 'tab' ]); |
|
240 | - } // end if |
|
241 | - else{ |
|
238 | + if( isset( $_GET[ 'tab' ] ) ) { |
|
239 | + $active_tab = $xcloner_sanitization->sanitize_input_as_string($_GET[ 'tab' ]); |
|
240 | + } // end if |
|
241 | + else{ |
|
242 | 242 | $active_tab = "general_options"; |
243 | 243 | } |
244 | 244 | |
245 | - ?> |
|
245 | + ?> |
|
246 | 246 | <h1><?= esc_html(get_admin_page_title()); ?></h1> |
247 | 247 | |
248 | 248 | <ul class="nav-tab-wrapper row"> |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | do_settings_sections('xcloner_cleanup_settings_page'); |
277 | 277 | } |
278 | 278 | |
279 | - // output save settings button |
|
280 | - submit_button('Save Settings'); |
|
281 | - ?> |
|
279 | + // output save settings button |
|
280 | + submit_button('Save Settings'); |
|
281 | + ?> |
|
282 | 282 | </form> |
283 | 283 | |
284 | 284 | </div> |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | * @param string $plugin_name The name of this plugin. |
49 | 49 | * @param string $version The version of this plugin. |
50 | 50 | */ |
51 | - public function __construct( Xcloner $xcloner_container) { |
|
51 | + public function __construct(Xcloner $xcloner_container) { |
|
52 | 52 | |
53 | - $this->plugin_name = $xcloner_container->get_plugin_name(); |
|
54 | - $this->version = $xcloner_container->get_version(); |
|
55 | - $this->xcloner_container = $xcloner_container; |
|
53 | + $this->plugin_name = $xcloner_container->get_plugin_name(); |
|
54 | + $this->version = $xcloner_container->get_version(); |
|
55 | + $this->xcloner_container = $xcloner_container; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | public function get_xcloner_container() |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function enqueue_styles($hook) { |
69 | 69 | |
70 | - if(!stristr($hook, "page_".$this->plugin_name) || (isset($_GET['option']) and $_GET['option']=="com_cloner")) |
|
70 | + if (!stristr($hook, "page_".$this->plugin_name) || (isset($_GET['option']) and $_GET['option'] == "com_cloner")) |
|
71 | 71 | return; |
72 | 72 | |
73 | 73 | /** |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | * class. |
83 | 83 | */ |
84 | 84 | |
85 | - wp_enqueue_style( $this->plugin_name."_materialize", plugin_dir_url( __FILE__ ) . 'css/materialize.min.css', array(), $this->version, 'all' ); |
|
86 | - wp_enqueue_style( $this->plugin_name."_materialize.clockpicker", plugin_dir_url( __FILE__ ) . 'css/materialize.clockpicker.css', array(), $this->version, 'all' ); |
|
87 | - wp_enqueue_style( $this->plugin_name."_materialize.icons", '//fonts.googleapis.com/icon?family=Material+Icons', array(), $this->version, 'all' ); |
|
88 | - wp_enqueue_style( $this->plugin_name."_jquery.datatables", plugin_dir_url( __FILE__ ) . 'css/jquery.dataTables.min.css', array(), $this->version, 'all' ); |
|
89 | - wp_enqueue_style( $this->plugin_name."_jquery.datatables.responsive", plugin_dir_url( __FILE__ ) . 'css/responsive.dataTables.css', array(), $this->version, 'all' ); |
|
90 | - wp_enqueue_style( $this->plugin_name."_jstree", dirname(plugin_dir_url( __FILE__ )) . '/vendor/vakata/jstree/dist/themes/default/style.min.css', array(), '3.3', 'all' ); |
|
91 | - wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/xcloner-admin.css', array(), $this->version, 'all' ); |
|
85 | + wp_enqueue_style($this->plugin_name."_materialize", plugin_dir_url(__FILE__).'css/materialize.min.css', array(), $this->version, 'all'); |
|
86 | + wp_enqueue_style($this->plugin_name."_materialize.clockpicker", plugin_dir_url(__FILE__).'css/materialize.clockpicker.css', array(), $this->version, 'all'); |
|
87 | + wp_enqueue_style($this->plugin_name."_materialize.icons", '//fonts.googleapis.com/icon?family=Material+Icons', array(), $this->version, 'all'); |
|
88 | + wp_enqueue_style($this->plugin_name."_jquery.datatables", plugin_dir_url(__FILE__).'css/jquery.dataTables.min.css', array(), $this->version, 'all'); |
|
89 | + wp_enqueue_style($this->plugin_name."_jquery.datatables.responsive", plugin_dir_url(__FILE__).'css/responsive.dataTables.css', array(), $this->version, 'all'); |
|
90 | + wp_enqueue_style($this->plugin_name."_jstree", dirname(plugin_dir_url(__FILE__)).'/vendor/vakata/jstree/dist/themes/default/style.min.css', array(), '3.3', 'all'); |
|
91 | + wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__).'css/xcloner-admin.css', array(), $this->version, 'all'); |
|
92 | 92 | |
93 | 93 | } |
94 | 94 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function enqueue_scripts($hook) { |
101 | 101 | |
102 | - if(!stristr($hook, "page_".$this->plugin_name)) |
|
102 | + if (!stristr($hook, "page_".$this->plugin_name)) |
|
103 | 103 | return; |
104 | 104 | |
105 | 105 | /** |
@@ -117,17 +117,17 @@ discard block |
||
117 | 117 | add_thickbox(); |
118 | 118 | wp_enqueue_script('plugin-install'); |
119 | 119 | wp_enqueue_script('updates'); |
120 | - wp_enqueue_script( $this->plugin_name."_materialize", plugin_dir_url( __FILE__ ) . 'js/materialize.min.js', array( 'jquery' ), $this->version, false ); |
|
121 | - wp_enqueue_script( $this->plugin_name."_materialize.clockpicker", plugin_dir_url( __FILE__ ) . 'js/materialize.clockpicker.js', array( 'jquery' ), $this->version, false ); |
|
122 | - wp_enqueue_script( $this->plugin_name."_jquery.datatables", plugin_dir_url( __FILE__ ) . 'js/jquery.dataTables.min.js', array( 'jquery' ), $this->version, false ); |
|
123 | - wp_enqueue_script( $this->plugin_name."_jquery.datatables.respnsive", plugin_dir_url( __FILE__ ) . 'js/dataTables.responsive.js', array( 'jquery' ), $this->version, false ); |
|
124 | - wp_enqueue_script( $this->plugin_name."_vakata", dirname(plugin_dir_url( __FILE__ )) . '/vendor/vakata/jstree/dist/jstree.min.js', array( 'jquery' ), '3.3', false ); |
|
125 | - wp_enqueue_script( $this->plugin_name."_xcloner-backup-class", plugin_dir_url( __FILE__ ) . 'js/xcloner-backup-class.js', array( 'jquery' ), $this->version, false ); |
|
126 | - wp_enqueue_script( $this->plugin_name."_xcloner-scheduler-class", plugin_dir_url( __FILE__ ) . 'js/xcloner-scheduler-class.js', array( 'jquery' ), $this->version, false ); |
|
127 | - wp_enqueue_script( $this->plugin_name."_xcloner-restore-class", plugin_dir_url( __FILE__ ) . 'js/xcloner-restore-class.js', array( 'jquery' ), $this->version, false ); |
|
128 | - wp_enqueue_script( $this->plugin_name."_xcloner-manage-backups-class", plugin_dir_url( __FILE__ ) . 'js/xcloner-manage-backups-class.js', array( 'jquery' ), $this->version, false ); |
|
129 | - wp_enqueue_script( $this->plugin_name."_xcloner-remote-storage-class", plugin_dir_url( __FILE__ ) . 'js/xcloner-remote-storage-class.js', array( 'jquery' ), $this->version, false ); |
|
130 | - wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/xcloner-admin.js', array( 'jquery' ), $this->version, false ); |
|
120 | + wp_enqueue_script($this->plugin_name."_materialize", plugin_dir_url(__FILE__).'js/materialize.min.js', array('jquery'), $this->version, false); |
|
121 | + wp_enqueue_script($this->plugin_name."_materialize.clockpicker", plugin_dir_url(__FILE__).'js/materialize.clockpicker.js', array('jquery'), $this->version, false); |
|
122 | + wp_enqueue_script($this->plugin_name."_jquery.datatables", plugin_dir_url(__FILE__).'js/jquery.dataTables.min.js', array('jquery'), $this->version, false); |
|
123 | + wp_enqueue_script($this->plugin_name."_jquery.datatables.respnsive", plugin_dir_url(__FILE__).'js/dataTables.responsive.js', array('jquery'), $this->version, false); |
|
124 | + wp_enqueue_script($this->plugin_name."_vakata", dirname(plugin_dir_url(__FILE__)).'/vendor/vakata/jstree/dist/jstree.min.js', array('jquery'), '3.3', false); |
|
125 | + wp_enqueue_script($this->plugin_name."_xcloner-backup-class", plugin_dir_url(__FILE__).'js/xcloner-backup-class.js', array('jquery'), $this->version, false); |
|
126 | + wp_enqueue_script($this->plugin_name."_xcloner-scheduler-class", plugin_dir_url(__FILE__).'js/xcloner-scheduler-class.js', array('jquery'), $this->version, false); |
|
127 | + wp_enqueue_script($this->plugin_name."_xcloner-restore-class", plugin_dir_url(__FILE__).'js/xcloner-restore-class.js', array('jquery'), $this->version, false); |
|
128 | + wp_enqueue_script($this->plugin_name."_xcloner-manage-backups-class", plugin_dir_url(__FILE__).'js/xcloner-manage-backups-class.js', array('jquery'), $this->version, false); |
|
129 | + wp_enqueue_script($this->plugin_name."_xcloner-remote-storage-class", plugin_dir_url(__FILE__).'js/xcloner-remote-storage-class.js', array('jquery'), $this->version, false); |
|
130 | + wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__).'js/xcloner-admin.js', array('jquery'), $this->version, false); |
|
131 | 131 | |
132 | 132 | |
133 | 133 | } |
@@ -144,20 +144,20 @@ discard block |
||
144 | 144 | $remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage(); |
145 | 145 | |
146 | 146 | |
147 | - if(isset($_POST['action'])) |
|
147 | + if (isset($_POST['action'])) |
|
148 | 148 | { |
149 | 149 | $_POST['action'] = $xcloner_sanitization->sanitize_input_as_string($_POST['action']); |
150 | 150 | $remote_storage->save($_POST['action']); |
151 | 151 | } |
152 | 152 | |
153 | - if(isset($_POST['authentification_code']) && $_POST['authentification_code'] != "") |
|
153 | + if (isset($_POST['authentification_code']) && $_POST['authentification_code'] != "") |
|
154 | 154 | { |
155 | 155 | $_POST['authentification_code'] = $xcloner_sanitization->sanitize_input_as_string($_POST['authentification_code']); |
156 | 156 | |
157 | 157 | $remote_storage->set_access_token($_POST['authentification_code']); |
158 | 158 | } |
159 | 159 | |
160 | - if(isset($_POST['connection_check']) && $_POST['connection_check']) |
|
160 | + if (isset($_POST['connection_check']) && $_POST['connection_check']) |
|
161 | 161 | { |
162 | 162 | $remote_storage->check($_POST['action']); |
163 | 163 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | { |
171 | 171 | $requirements = $this->xcloner_container->get_xcloner_requirements(); |
172 | 172 | |
173 | - if(!$requirements->check_backup_ready_status()) |
|
173 | + if (!$requirements->check_backup_ready_status()) |
|
174 | 174 | { |
175 | 175 | require_once("partials/xcloner_init_page.php"); |
176 | 176 | return false; |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | { |
203 | 203 | $requirements = $this->xcloner_container->get_xcloner_requirements(); |
204 | 204 | |
205 | - if(!$requirements->check_backup_ready_status()) |
|
205 | + if (!$requirements->check_backup_ready_status()) |
|
206 | 206 | { |
207 | 207 | require_once("partials/xcloner_init_page.php"); |
208 | 208 | return false; |
@@ -235,10 +235,10 @@ discard block |
||
235 | 235 | <?php |
236 | 236 | $xcloner_sanitization = $this->get_xcloner_container()->get_xcloner_sanitization(); |
237 | 237 | |
238 | - if( isset( $_GET[ 'tab' ] ) ) { |
|
239 | - $active_tab = $xcloner_sanitization->sanitize_input_as_string($_GET[ 'tab' ]); |
|
238 | + if (isset($_GET['tab'])) { |
|
239 | + $active_tab = $xcloner_sanitization->sanitize_input_as_string($_GET['tab']); |
|
240 | 240 | } // end if |
241 | - else{ |
|
241 | + else { |
|
242 | 242 | $active_tab = "general_options"; |
243 | 243 | } |
244 | 244 | |
@@ -257,20 +257,20 @@ discard block |
||
257 | 257 | <form action="options.php" method="post"> |
258 | 258 | <?php |
259 | 259 | |
260 | - if( $active_tab == 'general_options' ) { |
|
260 | + if ($active_tab == 'general_options') { |
|
261 | 261 | |
262 | 262 | settings_fields('xcloner_general_settings_group'); |
263 | 263 | do_settings_sections('xcloner_settings_page'); |
264 | 264 | |
265 | - }elseif( $active_tab == 'mysql_options' ) { |
|
265 | + }elseif ($active_tab == 'mysql_options') { |
|
266 | 266 | |
267 | 267 | settings_fields('xcloner_mysql_settings_group'); |
268 | 268 | do_settings_sections('xcloner_mysql_settings_page'); |
269 | - }elseif( $active_tab == 'system_options' ) { |
|
269 | + }elseif ($active_tab == 'system_options') { |
|
270 | 270 | |
271 | 271 | settings_fields('xcloner_system_settings_group'); |
272 | 272 | do_settings_sections('xcloner_system_settings_page'); |
273 | - }elseif( $active_tab == 'cleanup_options' ) { |
|
273 | + }elseif ($active_tab == 'cleanup_options') { |
|
274 | 274 | |
275 | 275 | settings_fields('xcloner_cleanup_settings_group'); |
276 | 276 | do_settings_sections('xcloner_cleanup_settings_page'); |
@@ -175,6 +175,9 @@ |
||
175 | 175 | return $wpdb->prefix; |
176 | 176 | } |
177 | 177 | |
178 | + /** |
|
179 | + * @param string $option |
|
180 | + */ |
|
178 | 181 | public function get_xcloner_option($option) |
179 | 182 | { |
180 | 183 | $data = get_option($option); |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | public function __construct(Xcloner $xcloner_container, $hash = "") |
12 | 12 | { |
13 | 13 | $this->xcloner_container = $xcloner_container; |
14 | - if(isset($hash)) |
|
15 | - $this->set_hash($hash); |
|
14 | + if(isset($hash)) { |
|
15 | + $this->set_hash($hash); |
|
16 | + } |
|
16 | 17 | } |
17 | 18 | |
18 | 19 | private function get_xcloner_container() |
@@ -22,20 +23,22 @@ discard block |
||
22 | 23 | |
23 | 24 | public function get_logger_filename($include_hash = 0) |
24 | 25 | { |
25 | - if($include_hash) |
|
26 | - $filename = sprintf($this->logger_file_hash, $this->get_hash()); |
|
27 | - else |
|
28 | - $filename = sprintf($this->logger_file, $this->get_server_unique_hash(5)); |
|
26 | + if($include_hash) { |
|
27 | + $filename = sprintf($this->logger_file_hash, $this->get_hash()); |
|
28 | + } else { |
|
29 | + $filename = sprintf($this->logger_file, $this->get_server_unique_hash(5)); |
|
30 | + } |
|
29 | 31 | |
30 | 32 | return $filename; |
31 | 33 | } |
32 | 34 | |
33 | 35 | public function get_xcloner_start_path() |
34 | 36 | { |
35 | - if(!get_option('xcloner_start_path') or !is_dir(get_option('xcloner_start_path'))) |
|
36 | - $path = realpath(ABSPATH); |
|
37 | - else |
|
38 | - $path = get_option('xcloner_start_path'); |
|
37 | + if(!get_option('xcloner_start_path') or !is_dir(get_option('xcloner_start_path'))) { |
|
38 | + $path = realpath(ABSPATH); |
|
39 | + } else { |
|
40 | + $path = get_option('xcloner_start_path'); |
|
41 | + } |
|
39 | 42 | |
40 | 43 | return $path; |
41 | 44 | } |
@@ -49,10 +52,11 @@ discard block |
||
49 | 52 | |
50 | 53 | public function get_xcloner_store_path() |
51 | 54 | { |
52 | - if(!get_option('xcloner_store_path') or !is_dir(get_option('xcloner_store_path'))) |
|
53 | - $path = realpath(XCLONER_STORAGE_PATH); |
|
54 | - else |
|
55 | - $path = get_option('xcloner_store_path'); |
|
55 | + if(!get_option('xcloner_store_path') or !is_dir(get_option('xcloner_store_path'))) { |
|
56 | + $path = realpath(XCLONER_STORAGE_PATH); |
|
57 | + } else { |
|
58 | + $path = get_option('xcloner_store_path'); |
|
59 | + } |
|
56 | 60 | |
57 | 61 | return $path; |
58 | 62 | } |
@@ -87,8 +91,9 @@ discard block |
||
87 | 91 | |
88 | 92 | public function get_enable_mysql_backup() |
89 | 93 | { |
90 | - if(get_option('xcloner_enable_mysql_backup')) |
|
91 | - return true; |
|
94 | + if(get_option('xcloner_enable_mysql_backup')) { |
|
95 | + return true; |
|
96 | + } |
|
92 | 97 | |
93 | 98 | return false; |
94 | 99 | } |
@@ -97,10 +102,11 @@ discard block |
||
97 | 102 | { |
98 | 103 | if(!$ext) |
99 | 104 | { |
100 | - if(get_option('xcloner_backup_compression_level')) |
|
101 | - $ext = ".tgz"; |
|
102 | - else |
|
103 | - $ext = ".tar"; |
|
105 | + if(get_option('xcloner_backup_compression_level')) { |
|
106 | + $ext = ".tgz"; |
|
107 | + } else { |
|
108 | + $ext = ".tar"; |
|
109 | + } |
|
104 | 110 | } |
105 | 111 | return ($this->get_hash()).$ext; |
106 | 112 | } |
@@ -126,8 +132,9 @@ discard block |
||
126 | 132 | |
127 | 133 | public function set_hash($hash = "") |
128 | 134 | { |
129 | - if(substr($hash, 0, 1) != "-" and strlen($hash)) |
|
130 | - $hash = "-".$hash; |
|
135 | + if(substr($hash, 0, 1) != "-" and strlen($hash)) { |
|
136 | + $hash = "-".$hash; |
|
137 | + } |
|
131 | 138 | |
132 | 139 | $this->hash = substr( $hash, 0, 6); |
133 | 140 | |
@@ -147,8 +154,9 @@ discard block |
||
147 | 154 | { |
148 | 155 | global $wpdb; |
149 | 156 | |
150 | - if(!$data = get_option('xcloner_mysql_hostname')) |
|
151 | - $data = $wpdb->dbhost; |
|
157 | + if(!$data = get_option('xcloner_mysql_hostname')) { |
|
158 | + $data = $wpdb->dbhost; |
|
159 | + } |
|
152 | 160 | |
153 | 161 | return $data; |
154 | 162 | } |
@@ -157,8 +165,9 @@ discard block |
||
157 | 165 | { |
158 | 166 | global $wpdb; |
159 | 167 | |
160 | - if(!$data = get_option('xcloner_mysql_username')) |
|
161 | - $data = $wpdb->dbuser; |
|
168 | + if(!$data = get_option('xcloner_mysql_username')) { |
|
169 | + $data = $wpdb->dbuser; |
|
170 | + } |
|
162 | 171 | |
163 | 172 | return $data; |
164 | 173 | } |
@@ -167,8 +176,9 @@ discard block |
||
167 | 176 | { |
168 | 177 | global $wpdb; |
169 | 178 | |
170 | - if(!$data = get_option('xcloner_mysql_password')) |
|
171 | - $data = $wpdb->dbpassword; |
|
179 | + if(!$data = get_option('xcloner_mysql_password')) { |
|
180 | + $data = $wpdb->dbpassword; |
|
181 | + } |
|
172 | 182 | |
173 | 183 | return $data; |
174 | 184 | } |
@@ -177,8 +187,9 @@ discard block |
||
177 | 187 | { |
178 | 188 | global $wpdb; |
179 | 189 | |
180 | - if(!$data = get_option('xcloner_mysql_database')) |
|
181 | - $data = $wpdb->dbname; |
|
190 | + if(!$data = get_option('xcloner_mysql_database')) { |
|
191 | + $data = $wpdb->dbname; |
|
192 | + } |
|
182 | 193 | |
183 | 194 | return $data; |
184 | 195 | } |
@@ -201,8 +212,9 @@ discard block |
||
201 | 212 | { |
202 | 213 | $hash = md5(get_home_url().__DIR__); |
203 | 214 | |
204 | - if($strlen) |
|
205 | - $hash = substr($hash, 0, $strlen); |
|
215 | + if($strlen) { |
|
216 | + $hash = substr($hash, 0, $strlen); |
|
217 | + } |
|
206 | 218 | |
207 | 219 | return $hash; |
208 | 220 | } |
@@ -581,15 +593,18 @@ discard block |
||
581 | 593 | // text field content cb |
582 | 594 | public function do_form_text_field($params) |
583 | 595 | { |
584 | - if(!isset($params['3'])) |
|
585 | - $params[3] = 0; |
|
586 | - if(!isset($params['2'])) |
|
587 | - $params[2] = 0; |
|
596 | + if(!isset($params['3'])) { |
|
597 | + $params[3] = 0; |
|
598 | + } |
|
599 | + if(!isset($params['2'])) { |
|
600 | + $params[2] = 0; |
|
601 | + } |
|
588 | 602 | |
589 | 603 | list($fieldname, $label, $value, $disabled) = $params; |
590 | 604 | |
591 | - if(!$value) |
|
592 | - $value = get_option($fieldname); |
|
605 | + if(!$value) { |
|
606 | + $value = get_option($fieldname); |
|
607 | + } |
|
593 | 608 | // output the field |
594 | 609 | ?> |
595 | 610 | <div class="row"> |
@@ -608,15 +623,18 @@ discard block |
||
608 | 623 | // textarea field content cb |
609 | 624 | public function do_form_textarea_field($params) |
610 | 625 | { |
611 | - if(!isset($params['3'])) |
|
612 | - $params[3] = 0; |
|
613 | - if(!isset($params['2'])) |
|
614 | - $params[2] = 0; |
|
626 | + if(!isset($params['3'])) { |
|
627 | + $params[3] = 0; |
|
628 | + } |
|
629 | + if(!isset($params['2'])) { |
|
630 | + $params[2] = 0; |
|
631 | + } |
|
615 | 632 | |
616 | 633 | list($fieldname, $label, $value, $disabled) = $params; |
617 | 634 | |
618 | - if(!$value) |
|
619 | - $value = get_option($fieldname); |
|
635 | + if(!$value) { |
|
636 | + $value = get_option($fieldname); |
|
637 | + } |
|
620 | 638 | // output the field |
621 | 639 | ?> |
622 | 640 | <div class="row"> |
@@ -652,15 +670,18 @@ discard block |
||
652 | 670 | // number field content cb |
653 | 671 | public function do_form_number_field($params) |
654 | 672 | { |
655 | - if(!isset($params['3'])) |
|
656 | - $params[3] = 0; |
|
657 | - if(!isset($params['2'])) |
|
658 | - $params[2] = 0; |
|
673 | + if(!isset($params['3'])) { |
|
674 | + $params[3] = 0; |
|
675 | + } |
|
676 | + if(!isset($params['2'])) { |
|
677 | + $params[2] = 0; |
|
678 | + } |
|
659 | 679 | |
660 | 680 | list($fieldname, $label, $value, $disabled) = $params; |
661 | 681 | |
662 | - if(!$value) |
|
663 | - $value = get_option($fieldname); |
|
682 | + if(!$value) { |
|
683 | + $value = get_option($fieldname); |
|
684 | + } |
|
664 | 685 | // output the field |
665 | 686 | ?> |
666 | 687 | <div class="row"> |
@@ -678,8 +699,9 @@ discard block |
||
678 | 699 | |
679 | 700 | public function do_form_range_field($params) |
680 | 701 | { |
681 | - if(!isset($params['4'])) |
|
682 | - $params[4] = 0; |
|
702 | + if(!isset($params['4'])) { |
|
703 | + $params[4] = 0; |
|
704 | + } |
|
683 | 705 | |
684 | 706 | list($fieldname, $label, $range_start, $range_end, $disabled) = $params; |
685 | 707 | $value = get_option($fieldname); |
@@ -700,8 +722,9 @@ discard block |
||
700 | 722 | |
701 | 723 | public function do_form_switch_field($params) |
702 | 724 | { |
703 | - if(!isset($params['2'])) |
|
704 | - $params[2] = 0; |
|
725 | + if(!isset($params['2'])) { |
|
726 | + $params[2] = 0; |
|
727 | + } |
|
705 | 728 | list($fieldname, $label, $disabled) = $params; |
706 | 729 | $value = get_option($fieldname); |
707 | 730 | ?> |
@@ -209,274 +209,274 @@ discard block |
||
209 | 209 | |
210 | 210 | public function settings_init() |
211 | 211 | { |
212 | - global $wpdb; |
|
213 | - $this->xcloner_sanitization = $this->get_xcloner_container()->get_xcloner_sanitization(); |
|
212 | + global $wpdb; |
|
213 | + $this->xcloner_sanitization = $this->get_xcloner_container()->get_xcloner_sanitization(); |
|
214 | 214 | |
215 | - //ADDING MISSING OPTIONS |
|
216 | - if( false == get_option( 'xcloner_mysql_settings_page' ) ) { |
|
215 | + //ADDING MISSING OPTIONS |
|
216 | + if( false == get_option( 'xcloner_mysql_settings_page' ) ) { |
|
217 | 217 | add_option( 'xcloner_mysql_settings_page' ); |
218 | 218 | } // end if |
219 | 219 | |
220 | - if( false == get_option( 'xcloner_cron_settings_page' ) ) { |
|
220 | + if( false == get_option( 'xcloner_cron_settings_page' ) ) { |
|
221 | 221 | add_option( 'xcloner_cron_settings_page' ); |
222 | 222 | } // end if |
223 | 223 | |
224 | - if( false == get_option( 'xcloner_system_settings_page' ) ) { |
|
224 | + if( false == get_option( 'xcloner_system_settings_page' ) ) { |
|
225 | 225 | add_option( 'xcloner_system_settings_page' ); |
226 | 226 | } // end if |
227 | 227 | |
228 | - if( false == get_option( 'xcloner_cleanup_settings_page' ) ) { |
|
228 | + if( false == get_option( 'xcloner_cleanup_settings_page' ) ) { |
|
229 | 229 | add_option( 'xcloner_cleanup_settings_page' ); |
230 | 230 | } // end if |
231 | 231 | |
232 | 232 | |
233 | - //ADDING SETTING SECTIONS |
|
234 | - //GENERAL section |
|
235 | - add_settings_section( |
|
236 | - 'xcloner_general_settings_group', |
|
237 | - __(' '), |
|
238 | - array($this, 'xcloner_settings_section_cb'), |
|
239 | - 'xcloner_settings_page' |
|
240 | - ); |
|
241 | - //MYSQL section |
|
242 | - add_settings_section( |
|
243 | - 'xcloner_mysql_settings_group', |
|
244 | - __(' '), |
|
245 | - array($this, 'xcloner_settings_section_cb'), |
|
246 | - 'xcloner_mysql_settings_page' |
|
247 | - ); |
|
233 | + //ADDING SETTING SECTIONS |
|
234 | + //GENERAL section |
|
235 | + add_settings_section( |
|
236 | + 'xcloner_general_settings_group', |
|
237 | + __(' '), |
|
238 | + array($this, 'xcloner_settings_section_cb'), |
|
239 | + 'xcloner_settings_page' |
|
240 | + ); |
|
241 | + //MYSQL section |
|
242 | + add_settings_section( |
|
243 | + 'xcloner_mysql_settings_group', |
|
244 | + __(' '), |
|
245 | + array($this, 'xcloner_settings_section_cb'), |
|
246 | + 'xcloner_mysql_settings_page' |
|
247 | + ); |
|
248 | 248 | |
249 | - //SYSTEM section |
|
250 | - add_settings_section( |
|
251 | - 'xcloner_system_settings_group', |
|
252 | - __('These are advanced options recommended for developers!','xcloner-backup-and-restore'), |
|
253 | - array($this, 'xcloner_settings_section_cb'), |
|
254 | - 'xcloner_system_settings_page' |
|
255 | - ); |
|
249 | + //SYSTEM section |
|
250 | + add_settings_section( |
|
251 | + 'xcloner_system_settings_group', |
|
252 | + __('These are advanced options recommended for developers!','xcloner-backup-and-restore'), |
|
253 | + array($this, 'xcloner_settings_section_cb'), |
|
254 | + 'xcloner_system_settings_page' |
|
255 | + ); |
|
256 | 256 | |
257 | - //CLEANUP section |
|
258 | - add_settings_section( |
|
259 | - 'xcloner_cleanup_settings_group', |
|
260 | - __(' '), |
|
261 | - array($this, 'xcloner_settings_section_cb'), |
|
262 | - 'xcloner_cleanup_settings_page' |
|
263 | - ); |
|
257 | + //CLEANUP section |
|
258 | + add_settings_section( |
|
259 | + 'xcloner_cleanup_settings_group', |
|
260 | + __(' '), |
|
261 | + array($this, 'xcloner_settings_section_cb'), |
|
262 | + 'xcloner_cleanup_settings_page' |
|
263 | + ); |
|
264 | 264 | |
265 | 265 | |
266 | 266 | //CRON section |
267 | - add_settings_section( |
|
268 | - 'xcloner_cron_settings_group', |
|
269 | - __(' '), |
|
270 | - array($this, 'xcloner_settings_section_cb'), |
|
271 | - 'xcloner_cron_settings_page' |
|
272 | - ); |
|
267 | + add_settings_section( |
|
268 | + 'xcloner_cron_settings_group', |
|
269 | + __(' '), |
|
270 | + array($this, 'xcloner_settings_section_cb'), |
|
271 | + 'xcloner_cron_settings_page' |
|
272 | + ); |
|
273 | 273 | |
274 | 274 | |
275 | 275 | |
276 | 276 | //REGISTERING THE 'GENERAL SECTION' FIELDS |
277 | 277 | register_setting('xcloner_general_settings_group', 'xcloner_backup_compression_level', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
278 | - add_settings_field( |
|
279 | - 'xcloner_backup_compression_level', |
|
280 | - __('Backup Compression Level','xcloner-backup-and-restore'), |
|
281 | - array($this, 'do_form_range_field'), |
|
282 | - 'xcloner_settings_page', |
|
283 | - 'xcloner_general_settings_group', |
|
284 | - array('xcloner_backup_compression_level', |
|
285 | - __('Options between [0-9]. Value 0 means no compression, while 9 is maximum compression affecting cpu load','xcloner-backup-and-restore'), |
|
286 | - 0, |
|
287 | - 9 |
|
288 | - ) |
|
289 | - ); |
|
278 | + add_settings_field( |
|
279 | + 'xcloner_backup_compression_level', |
|
280 | + __('Backup Compression Level','xcloner-backup-and-restore'), |
|
281 | + array($this, 'do_form_range_field'), |
|
282 | + 'xcloner_settings_page', |
|
283 | + 'xcloner_general_settings_group', |
|
284 | + array('xcloner_backup_compression_level', |
|
285 | + __('Options between [0-9]. Value 0 means no compression, while 9 is maximum compression affecting cpu load','xcloner-backup-and-restore'), |
|
286 | + 0, |
|
287 | + 9 |
|
288 | + ) |
|
289 | + ); |
|
290 | 290 | |
291 | - register_setting('xcloner_general_settings_group', 'xcloner_start_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path")); |
|
292 | - add_settings_field( |
|
293 | - 'xcloner_start_path', |
|
294 | - __('Backup Start Location','xcloner-backup-and-restore'), |
|
295 | - array($this, 'do_form_text_field'), |
|
296 | - 'xcloner_settings_page', |
|
297 | - 'xcloner_general_settings_group', |
|
298 | - array('xcloner_start_path', |
|
291 | + register_setting('xcloner_general_settings_group', 'xcloner_start_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path")); |
|
292 | + add_settings_field( |
|
293 | + 'xcloner_start_path', |
|
294 | + __('Backup Start Location','xcloner-backup-and-restore'), |
|
295 | + array($this, 'do_form_text_field'), |
|
296 | + 'xcloner_settings_page', |
|
297 | + 'xcloner_general_settings_group', |
|
298 | + array('xcloner_start_path', |
|
299 | 299 | __('Base path location from where XCloner can start the Backup.','xcloner-backup-and-restore'), |
300 | 300 | $this->get_xcloner_start_path(), |
301 | 301 | //'disabled' |
302 | 302 | ) |
303 | - ); |
|
303 | + ); |
|
304 | 304 | |
305 | - register_setting('xcloner_general_settings_group', 'xcloner_store_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path")); |
|
306 | - add_settings_field( |
|
307 | - 'xcloner_store_path', |
|
308 | - __('Backup Storage Location','xcloner-backup-and-restore'), |
|
309 | - array($this, 'do_form_text_field'), |
|
310 | - 'xcloner_settings_page', |
|
311 | - 'xcloner_general_settings_group', |
|
312 | - array('xcloner_store_path', |
|
305 | + register_setting('xcloner_general_settings_group', 'xcloner_store_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path")); |
|
306 | + add_settings_field( |
|
307 | + 'xcloner_store_path', |
|
308 | + __('Backup Storage Location','xcloner-backup-and-restore'), |
|
309 | + array($this, 'do_form_text_field'), |
|
310 | + 'xcloner_settings_page', |
|
311 | + 'xcloner_general_settings_group', |
|
312 | + array('xcloner_store_path', |
|
313 | 313 | __('Location where XCloner will store the Backup archives.','xcloner-backup-and-restore'), |
314 | 314 | $this->get_xcloner_store_path(), |
315 | 315 | //'disabled' |
316 | 316 | ) |
317 | - ); |
|
317 | + ); |
|
318 | 318 | |
319 | - register_setting('xcloner_general_settings_group', 'xcloner_enable_log', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
|
320 | - add_settings_field( |
|
321 | - 'xcloner_enable_log', |
|
322 | - __('Enable XCloner Backup Log','xcloner-backup-and-restore'), |
|
323 | - array($this, 'do_form_switch_field'), |
|
324 | - 'xcloner_settings_page', |
|
325 | - 'xcloner_general_settings_group', |
|
326 | - array('xcloner_enable_log', |
|
319 | + register_setting('xcloner_general_settings_group', 'xcloner_enable_log', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
|
320 | + add_settings_field( |
|
321 | + 'xcloner_enable_log', |
|
322 | + __('Enable XCloner Backup Log','xcloner-backup-and-restore'), |
|
323 | + array($this, 'do_form_switch_field'), |
|
324 | + 'xcloner_settings_page', |
|
325 | + 'xcloner_general_settings_group', |
|
326 | + array('xcloner_enable_log', |
|
327 | 327 | 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()) |
328 | 328 | ) |
329 | 329 | ); |
330 | 330 | |
331 | 331 | register_setting('xcloner_general_settings_group', 'xcloner_enable_pre_update_backup', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
332 | - add_settings_field( |
|
333 | - 'xcloner_enable_pre_update_backup', |
|
334 | - __('Generate Backups before Automatic WP Upgrades','xcloner-backup-and-restore'), |
|
335 | - array($this, 'do_form_switch_field'), |
|
336 | - 'xcloner_settings_page', |
|
337 | - 'xcloner_general_settings_group', |
|
338 | - array('xcloner_enable_pre_update_backup', |
|
332 | + add_settings_field( |
|
333 | + 'xcloner_enable_pre_update_backup', |
|
334 | + __('Generate Backups before Automatic WP Upgrades','xcloner-backup-and-restore'), |
|
335 | + array($this, 'do_form_switch_field'), |
|
336 | + 'xcloner_settings_page', |
|
337 | + 'xcloner_general_settings_group', |
|
338 | + array('xcloner_enable_pre_update_backup', |
|
339 | 339 | sprintf(__('Attempt to generate a core, plugins, themes or languages files backup before the automatic update of Wordpress core, plugins, themes or languages files.','xcloner-backup-and-restore'), $this->get_logger_filename()) |
340 | 340 | ) |
341 | 341 | ); |
342 | 342 | |
343 | 343 | register_setting('xcloner_general_settings_group', 'xcloner_regex_exclude', array($this->xcloner_sanitization, "sanitize_input_as_raw")); |
344 | - add_settings_field( |
|
345 | - 'xcloner_regex_exclude', |
|
346 | - __('Regex Exclude Files','xcloner-backup-and-restore'), |
|
347 | - array($this, 'do_form_textarea_field'), |
|
348 | - 'xcloner_settings_page', |
|
349 | - 'xcloner_general_settings_group', |
|
350 | - array('xcloner_regex_exclude', |
|
344 | + add_settings_field( |
|
345 | + 'xcloner_regex_exclude', |
|
346 | + __('Regex Exclude Files','xcloner-backup-and-restore'), |
|
347 | + array($this, 'do_form_textarea_field'), |
|
348 | + 'xcloner_settings_page', |
|
349 | + 'xcloner_general_settings_group', |
|
350 | + array('xcloner_regex_exclude', |
|
351 | 351 | __('Regular expression match to exclude files and folders, example patterns provided below, one pattern per line','xcloner-backup-and-restore'), |
352 | 352 | //$this->get_xcloner_store_path(), |
353 | 353 | //'disabled' |
354 | 354 | ) |
355 | - ); |
|
355 | + ); |
|
356 | 356 | |
357 | 357 | //REGISTERING THE 'MYSQL SECTION' FIELDS |
358 | 358 | register_setting('xcloner_mysql_settings_group', 'xcloner_enable_mysql_backup', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
359 | - add_settings_field( |
|
360 | - 'xcloner_enable_mysql_backup', |
|
361 | - __('Enable Mysql Backup','xcloner-backup-and-restore'), |
|
362 | - array($this, 'do_form_switch_field'), |
|
363 | - 'xcloner_mysql_settings_page', |
|
364 | - 'xcloner_mysql_settings_group', |
|
365 | - array('xcloner_enable_mysql_backup', |
|
359 | + add_settings_field( |
|
360 | + 'xcloner_enable_mysql_backup', |
|
361 | + __('Enable Mysql Backup','xcloner-backup-and-restore'), |
|
362 | + array($this, 'do_form_switch_field'), |
|
363 | + 'xcloner_mysql_settings_page', |
|
364 | + 'xcloner_mysql_settings_group', |
|
365 | + array('xcloner_enable_mysql_backup', |
|
366 | 366 | __('Enable Mysql Backup Option. If you don\'t want to backup the database, you can disable this.','xcloner-backup-and-restore') |
367 | 367 | ) |
368 | - ); |
|
368 | + ); |
|
369 | 369 | |
370 | - register_setting('xcloner_mysql_settings_group', 'xcloner_backup_only_wp_tables'); |
|
371 | - add_settings_field( |
|
372 | - 'xcloner_backup_only_wp_tables', |
|
373 | - __('Backup only WP tables','xcloner-backup-and-restore'), |
|
374 | - array($this, 'do_form_switch_field'), |
|
375 | - 'xcloner_mysql_settings_page', |
|
376 | - 'xcloner_mysql_settings_group', |
|
377 | - array('xcloner_backup_only_wp_tables', |
|
370 | + register_setting('xcloner_mysql_settings_group', 'xcloner_backup_only_wp_tables'); |
|
371 | + add_settings_field( |
|
372 | + 'xcloner_backup_only_wp_tables', |
|
373 | + __('Backup only WP tables','xcloner-backup-and-restore'), |
|
374 | + array($this, 'do_form_switch_field'), |
|
375 | + 'xcloner_mysql_settings_page', |
|
376 | + 'xcloner_mysql_settings_group', |
|
377 | + array('xcloner_backup_only_wp_tables', |
|
378 | 378 | sprintf(__('Enable this if you only want to Backup only tables starting with \'%s\' prefix','xcloner-backup-and-restore'), $this->get_table_prefix()) |
379 | 379 | ) |
380 | - ); |
|
380 | + ); |
|
381 | 381 | |
382 | - register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_hostname', array($this->xcloner_sanitization, "sanitize_input_as_raw")); |
|
383 | - add_settings_field( |
|
384 | - 'xcloner_mysql_hostname', |
|
385 | - __('Mysql Hostname','xcloner-backup-and-restore'), |
|
386 | - array($this, 'do_form_text_field'), |
|
387 | - 'xcloner_mysql_settings_page', |
|
388 | - 'xcloner_mysql_settings_group', |
|
389 | - array('xcloner_mysql_hostname', |
|
382 | + register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_hostname', array($this->xcloner_sanitization, "sanitize_input_as_raw")); |
|
383 | + add_settings_field( |
|
384 | + 'xcloner_mysql_hostname', |
|
385 | + __('Mysql Hostname','xcloner-backup-and-restore'), |
|
386 | + array($this, 'do_form_text_field'), |
|
387 | + 'xcloner_mysql_settings_page', |
|
388 | + 'xcloner_mysql_settings_group', |
|
389 | + array('xcloner_mysql_hostname', |
|
390 | 390 | __('Wordpress mysql hostname','xcloner-backup-and-restore'), |
391 | 391 | $this->get_db_hostname(), |
392 | 392 | 'disabled' |
393 | 393 | ) |
394 | - ); |
|
394 | + ); |
|
395 | 395 | |
396 | - register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_username', array($this->xcloner_sanitization, "sanitize_input_as_raw")); |
|
397 | - add_settings_field( |
|
398 | - 'xcloner_mysql_username', |
|
399 | - __('Mysql Username','xcloner-backup-and-restore'), |
|
400 | - array($this, 'do_form_text_field'), |
|
401 | - 'xcloner_mysql_settings_page', |
|
402 | - 'xcloner_mysql_settings_group', |
|
403 | - array('xcloner_mysql_username', |
|
396 | + register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_username', array($this->xcloner_sanitization, "sanitize_input_as_raw")); |
|
397 | + add_settings_field( |
|
398 | + 'xcloner_mysql_username', |
|
399 | + __('Mysql Username','xcloner-backup-and-restore'), |
|
400 | + array($this, 'do_form_text_field'), |
|
401 | + 'xcloner_mysql_settings_page', |
|
402 | + 'xcloner_mysql_settings_group', |
|
403 | + array('xcloner_mysql_username', |
|
404 | 404 | __('Wordpress mysql username','xcloner-backup-and-restore'), |
405 | 405 | $this->get_db_username(), |
406 | 406 | 'disabled' |
407 | 407 | ) |
408 | - ); |
|
408 | + ); |
|
409 | 409 | |
410 | - register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_database', array($this->xcloner_sanitization, "sanitize_input_as_raw")); |
|
411 | - add_settings_field( |
|
412 | - 'xcloner_mysql_database', |
|
413 | - __('Mysql Database','xcloner-backup-and-restore'), |
|
414 | - array($this, 'do_form_text_field'), |
|
415 | - 'xcloner_mysql_settings_page', |
|
416 | - 'xcloner_mysql_settings_group', |
|
417 | - array('xcloner_mysql_database', |
|
410 | + register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_database', array($this->xcloner_sanitization, "sanitize_input_as_raw")); |
|
411 | + add_settings_field( |
|
412 | + 'xcloner_mysql_database', |
|
413 | + __('Mysql Database','xcloner-backup-and-restore'), |
|
414 | + array($this, 'do_form_text_field'), |
|
415 | + 'xcloner_mysql_settings_page', |
|
416 | + 'xcloner_mysql_settings_group', |
|
417 | + array('xcloner_mysql_database', |
|
418 | 418 | __('Wordpress mysql database','xcloner-backup-and-restore'), |
419 | 419 | $this->get_db_database(), |
420 | 420 | 'disabled' |
421 | 421 | ) |
422 | - ); |
|
422 | + ); |
|
423 | 423 | |
424 | - //REGISTERING THE 'SYSTEM SECTION' FIELDS |
|
425 | - register_setting('xcloner_system_settings_group', 'xcloner_size_limit_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
|
426 | - add_settings_field( |
|
427 | - 'xcloner_size_limit_per_request', |
|
428 | - __('Data Size Limit Per Request','xcloner-backup-and-restore'), |
|
429 | - array($this, 'do_form_range_field'), |
|
430 | - 'xcloner_system_settings_page', |
|
431 | - 'xcloner_system_settings_group', |
|
432 | - array('xcloner_size_limit_per_request', |
|
433 | - __('Use this option to set how much file data can XCloner backup in one AJAX request. Range 0-1024 MB','xcloner-backup-and-restore'), |
|
434 | - 0, |
|
435 | - 1024 |
|
436 | - ) |
|
437 | - ); |
|
424 | + //REGISTERING THE 'SYSTEM SECTION' FIELDS |
|
425 | + register_setting('xcloner_system_settings_group', 'xcloner_size_limit_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
|
426 | + add_settings_field( |
|
427 | + 'xcloner_size_limit_per_request', |
|
428 | + __('Data Size Limit Per Request','xcloner-backup-and-restore'), |
|
429 | + array($this, 'do_form_range_field'), |
|
430 | + 'xcloner_system_settings_page', |
|
431 | + 'xcloner_system_settings_group', |
|
432 | + array('xcloner_size_limit_per_request', |
|
433 | + __('Use this option to set how much file data can XCloner backup in one AJAX request. Range 0-1024 MB','xcloner-backup-and-restore'), |
|
434 | + 0, |
|
435 | + 1024 |
|
436 | + ) |
|
437 | + ); |
|
438 | 438 | |
439 | 439 | register_setting('xcloner_system_settings_group', 'xcloner_files_to_process_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
440 | - add_settings_field( |
|
441 | - 'xcloner_files_to_process_per_request', |
|
442 | - __('Files To Process Per Request','xcloner-backup-and-restore'), |
|
443 | - array($this, 'do_form_range_field'), |
|
444 | - 'xcloner_system_settings_page', |
|
445 | - 'xcloner_system_settings_group', |
|
446 | - array('xcloner_files_to_process_per_request', |
|
447 | - __('Use this option to set how many files XCloner should process at one time before doing another AJAX call','xcloner-backup-and-restore'), |
|
448 | - 0, |
|
449 | - 1000 |
|
450 | - ) |
|
451 | - ); |
|
440 | + add_settings_field( |
|
441 | + 'xcloner_files_to_process_per_request', |
|
442 | + __('Files To Process Per Request','xcloner-backup-and-restore'), |
|
443 | + array($this, 'do_form_range_field'), |
|
444 | + 'xcloner_system_settings_page', |
|
445 | + 'xcloner_system_settings_group', |
|
446 | + array('xcloner_files_to_process_per_request', |
|
447 | + __('Use this option to set how many files XCloner should process at one time before doing another AJAX call','xcloner-backup-and-restore'), |
|
448 | + 0, |
|
449 | + 1000 |
|
450 | + ) |
|
451 | + ); |
|
452 | 452 | |
453 | 453 | register_setting('xcloner_system_settings_group', 'xcloner_directories_to_scan_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
454 | - add_settings_field( |
|
455 | - 'xcloner_directories_to_scan_per_request', |
|
456 | - __('Directories To Scan Per Request','xcloner-backup-and-restore'), |
|
457 | - array($this, 'do_form_range_field'), |
|
458 | - 'xcloner_system_settings_page', |
|
459 | - 'xcloner_system_settings_group', |
|
460 | - array('xcloner_directories_to_scan_per_request', |
|
461 | - __('Use this option to set how many directories XCloner should scan at one time before doing another AJAX call','xcloner-backup-and-restore'), |
|
462 | - 0, |
|
463 | - 1000 |
|
464 | - ) |
|
465 | - ); |
|
454 | + add_settings_field( |
|
455 | + 'xcloner_directories_to_scan_per_request', |
|
456 | + __('Directories To Scan Per Request','xcloner-backup-and-restore'), |
|
457 | + array($this, 'do_form_range_field'), |
|
458 | + 'xcloner_system_settings_page', |
|
459 | + 'xcloner_system_settings_group', |
|
460 | + array('xcloner_directories_to_scan_per_request', |
|
461 | + __('Use this option to set how many directories XCloner should scan at one time before doing another AJAX call','xcloner-backup-and-restore'), |
|
462 | + 0, |
|
463 | + 1000 |
|
464 | + ) |
|
465 | + ); |
|
466 | 466 | |
467 | 467 | register_setting('xcloner_system_settings_group', 'xcloner_database_records_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
468 | - add_settings_field( |
|
469 | - 'xcloner_database_records_per_request', |
|
470 | - __('Database Records Per Request','xcloner-backup-and-restore'), |
|
471 | - array($this, 'do_form_range_field'), |
|
472 | - 'xcloner_system_settings_page', |
|
473 | - 'xcloner_system_settings_group', |
|
474 | - array('xcloner_database_records_per_request', |
|
475 | - __('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'), |
|
476 | - 0, |
|
477 | - 100000 |
|
478 | - ) |
|
479 | - ); |
|
468 | + add_settings_field( |
|
469 | + 'xcloner_database_records_per_request', |
|
470 | + __('Database Records Per Request','xcloner-backup-and-restore'), |
|
471 | + array($this, 'do_form_range_field'), |
|
472 | + 'xcloner_system_settings_page', |
|
473 | + 'xcloner_system_settings_group', |
|
474 | + array('xcloner_database_records_per_request', |
|
475 | + __('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'), |
|
476 | + 0, |
|
477 | + 100000 |
|
478 | + ) |
|
479 | + ); |
|
480 | 480 | |
481 | 481 | /*register_setting('xcloner_system_settings_group', 'xcloner_diff_backup_recreate_period', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
482 | 482 | add_settings_field( |
@@ -491,102 +491,102 @@ discard block |
||
491 | 491 | );*/ |
492 | 492 | |
493 | 493 | register_setting('xcloner_system_settings_group', 'xcloner_exclude_files_larger_than_mb', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
494 | - add_settings_field( |
|
495 | - 'xcloner_exclude_files_larger_than_mb', |
|
496 | - __('Exclude files larger than (MB)','xcloner-backup-and-restore'), |
|
497 | - array($this, 'do_form_number_field'), |
|
498 | - 'xcloner_system_settings_page', |
|
499 | - 'xcloner_system_settings_group', |
|
500 | - array('xcloner_exclude_files_larger_than_mb', |
|
501 | - __('Use this option to automatically exclude files larger than a certain size in MB, or set to 0 to include all. Range 0-1000 MB','xcloner-backup-and-restore'), |
|
502 | - ) |
|
503 | - ); |
|
494 | + add_settings_field( |
|
495 | + 'xcloner_exclude_files_larger_than_mb', |
|
496 | + __('Exclude files larger than (MB)','xcloner-backup-and-restore'), |
|
497 | + array($this, 'do_form_number_field'), |
|
498 | + 'xcloner_system_settings_page', |
|
499 | + 'xcloner_system_settings_group', |
|
500 | + array('xcloner_exclude_files_larger_than_mb', |
|
501 | + __('Use this option to automatically exclude files larger than a certain size in MB, or set to 0 to include all. Range 0-1000 MB','xcloner-backup-and-restore'), |
|
502 | + ) |
|
503 | + ); |
|
504 | 504 | |
505 | 505 | register_setting('xcloner_system_settings_group', 'xcloner_split_backup_limit', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
506 | - add_settings_field( |
|
507 | - 'xcloner_split_backup_limit', |
|
508 | - __('Split Backup Archive Limit (MB)','xcloner-backup-and-restore'), |
|
509 | - array($this, 'do_form_number_field'), |
|
510 | - 'xcloner_system_settings_page', |
|
511 | - 'xcloner_system_settings_group', |
|
512 | - array('xcloner_split_backup_limit', |
|
513 | - __('Use this option to automatically split the backup archive into smaller parts. Range 0-10000 MB','xcloner-backup-and-restore'), |
|
514 | - ) |
|
515 | - ); |
|
506 | + add_settings_field( |
|
507 | + 'xcloner_split_backup_limit', |
|
508 | + __('Split Backup Archive Limit (MB)','xcloner-backup-and-restore'), |
|
509 | + array($this, 'do_form_number_field'), |
|
510 | + 'xcloner_system_settings_page', |
|
511 | + 'xcloner_system_settings_group', |
|
512 | + array('xcloner_split_backup_limit', |
|
513 | + __('Use this option to automatically split the backup archive into smaller parts. Range 0-10000 MB','xcloner-backup-and-restore'), |
|
514 | + ) |
|
515 | + ); |
|
516 | 516 | |
517 | - register_setting('xcloner_system_settings_group', 'xcloner_force_tmp_path_site_root'); |
|
518 | - add_settings_field( |
|
519 | - 'xcloner_force_tmp_path_site_root', |
|
520 | - __('Force Temporary Path Within XCloner Storage','xcloner-backup-and-restore'), |
|
521 | - array($this, 'do_form_switch_field'), |
|
522 | - 'xcloner_system_settings_page', |
|
523 | - 'xcloner_system_settings_group', |
|
524 | - array('xcloner_force_tmp_path_site_root', |
|
517 | + register_setting('xcloner_system_settings_group', 'xcloner_force_tmp_path_site_root'); |
|
518 | + add_settings_field( |
|
519 | + 'xcloner_force_tmp_path_site_root', |
|
520 | + __('Force Temporary Path Within XCloner Storage','xcloner-backup-and-restore'), |
|
521 | + array($this, 'do_form_switch_field'), |
|
522 | + 'xcloner_system_settings_page', |
|
523 | + 'xcloner_system_settings_group', |
|
524 | + array('xcloner_force_tmp_path_site_root', |
|
525 | 525 | 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()) |
526 | 526 | ) |
527 | - ); |
|
527 | + ); |
|
528 | 528 | |
529 | 529 | //REGISTERING THE 'CLEANUP SECTION' FIELDS |
530 | 530 | register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_days', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
531 | - add_settings_field( |
|
532 | - 'xcloner_cleanup_retention_limit_days', |
|
533 | - __('Cleanup by Date(days)','xcloner-backup-and-restore'), |
|
534 | - array($this, 'do_form_number_field'), |
|
535 | - 'xcloner_cleanup_settings_page', |
|
536 | - 'xcloner_cleanup_settings_group', |
|
537 | - array('xcloner_cleanup_retention_limit_days', |
|
531 | + add_settings_field( |
|
532 | + 'xcloner_cleanup_retention_limit_days', |
|
533 | + __('Cleanup by Date(days)','xcloner-backup-and-restore'), |
|
534 | + array($this, 'do_form_number_field'), |
|
535 | + 'xcloner_cleanup_settings_page', |
|
536 | + 'xcloner_cleanup_settings_group', |
|
537 | + array('xcloner_cleanup_retention_limit_days', |
|
538 | 538 | __('Specify the maximum number of days a backup archive can be kept on the server. 0 disables this option','xcloner-backup-and-restore') |
539 | 539 | ) |
540 | - ); |
|
540 | + ); |
|
541 | 541 | |
542 | 542 | register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_archives', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
543 | - add_settings_field( |
|
544 | - 'xcloner_cleanup_retention_limit_archives', |
|
545 | - __('Cleanup by Quantity','xcloner-backup-and-restore'), |
|
546 | - array($this, 'do_form_number_field'), |
|
547 | - 'xcloner_cleanup_settings_page', |
|
548 | - 'xcloner_cleanup_settings_group', |
|
549 | - array('xcloner_cleanup_retention_limit_archives', |
|
543 | + add_settings_field( |
|
544 | + 'xcloner_cleanup_retention_limit_archives', |
|
545 | + __('Cleanup by Quantity','xcloner-backup-and-restore'), |
|
546 | + array($this, 'do_form_number_field'), |
|
547 | + 'xcloner_cleanup_settings_page', |
|
548 | + 'xcloner_cleanup_settings_group', |
|
549 | + array('xcloner_cleanup_retention_limit_archives', |
|
550 | 550 | __('Specify the maximum number of backup archives to keep on the server. 0 disables this option','xcloner-backup-and-restore') |
551 | 551 | ) |
552 | - ); |
|
552 | + ); |
|
553 | 553 | |
554 | 554 | register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_capacity_limit', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
555 | - add_settings_field( |
|
556 | - 'xcloner_cleanup_capacity_limit', |
|
557 | - __('Cleanup by Capacity(MB)','xcloner-backup-and-restore'), |
|
558 | - array($this, 'do_form_number_field'), |
|
559 | - 'xcloner_cleanup_settings_page', |
|
560 | - 'xcloner_cleanup_settings_group', |
|
561 | - array('xcloner_cleanup_capacity_limit', |
|
555 | + add_settings_field( |
|
556 | + 'xcloner_cleanup_capacity_limit', |
|
557 | + __('Cleanup by Capacity(MB)','xcloner-backup-and-restore'), |
|
558 | + array($this, 'do_form_number_field'), |
|
559 | + 'xcloner_cleanup_settings_page', |
|
560 | + 'xcloner_cleanup_settings_group', |
|
561 | + array('xcloner_cleanup_capacity_limit', |
|
562 | 562 | __('Remove oldest backups if all created backups exceed the configured limit in Megabytes. 0 disables this option','xcloner-backup-and-restore') |
563 | 563 | ) |
564 | - ); |
|
564 | + ); |
|
565 | 565 | |
566 | - register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_delete_after_remote_transfer', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
|
567 | - add_settings_field( |
|
568 | - 'xcloner_cleanup_delete_after_remote_transfer', |
|
569 | - __('Delete Backup After Sending it to Remote Storage','xcloner-backup-and-restore'), |
|
570 | - array($this, 'do_form_switch_field'), |
|
571 | - 'xcloner_cleanup_settings_page', |
|
572 | - 'xcloner_cleanup_settings_group', |
|
573 | - array('xcloner_cleanup_delete_after_remote_transfer', |
|
566 | + register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_delete_after_remote_transfer', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
|
567 | + add_settings_field( |
|
568 | + 'xcloner_cleanup_delete_after_remote_transfer', |
|
569 | + __('Delete Backup After Sending it to Remote Storage','xcloner-backup-and-restore'), |
|
570 | + array($this, 'do_form_switch_field'), |
|
571 | + 'xcloner_cleanup_settings_page', |
|
572 | + 'xcloner_cleanup_settings_group', |
|
573 | + array('xcloner_cleanup_delete_after_remote_transfer', |
|
574 | 574 | __('Remove backups created automatically from local storage after sending the backup to remote storage','xcloner-backup-and-restore') |
575 | 575 | ) |
576 | - ); |
|
576 | + ); |
|
577 | 577 | |
578 | 578 | //REGISTERING THE 'CRON SECTION' FIELDS |
579 | 579 | register_setting('xcloner_cron_settings_group', 'xcloner_cron_frequency'); |
580 | - add_settings_field( |
|
581 | - 'xcloner_cron_frequency', |
|
582 | - __('Cron frequency','xcloner-backup-and-restore'), |
|
583 | - array($this, 'do_form_text_field'), |
|
584 | - 'xcloner_cron_settings_page', |
|
585 | - 'xcloner_cron_settings_group', |
|
586 | - array('xcloner_cron_frequency', |
|
580 | + add_settings_field( |
|
581 | + 'xcloner_cron_frequency', |
|
582 | + __('Cron frequency','xcloner-backup-and-restore'), |
|
583 | + array($this, 'do_form_text_field'), |
|
584 | + 'xcloner_cron_settings_page', |
|
585 | + 'xcloner_cron_settings_group', |
|
586 | + array('xcloner_cron_frequency', |
|
587 | 587 | __('Cron frequency') |
588 | 588 | ) |
589 | - ); |
|
589 | + ); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | // section content cb |
600 | 600 | public function xcloner_settings_section_cb() |
601 | 601 | { |
602 | - //echo '<p>WPOrg Section Introduction.</p>'; |
|
602 | + //echo '<p>WPOrg Section Introduction.</p>'; |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | // text field content cb |
@@ -614,8 +614,8 @@ discard block |
||
614 | 614 | |
615 | 615 | if(!$value) |
616 | 616 | $value = get_option($fieldname); |
617 | - // output the field |
|
618 | - ?> |
|
617 | + // output the field |
|
618 | + ?> |
|
619 | 619 | <div class="row"> |
620 | 620 | <div class="input-field col s10 m10 l8"> |
621 | 621 | <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) : ''; ?>"> |
@@ -641,8 +641,8 @@ discard block |
||
641 | 641 | |
642 | 642 | if(!$value) |
643 | 643 | $value = get_option($fieldname); |
644 | - // output the field |
|
645 | - ?> |
|
644 | + // output the field |
|
645 | + ?> |
|
646 | 646 | <div class="row"> |
647 | 647 | <div class="input-field col s10 m10 l8"> |
648 | 648 | <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> |
@@ -685,8 +685,8 @@ discard block |
||
685 | 685 | |
686 | 686 | if(!$value) |
687 | 687 | $value = get_option($fieldname); |
688 | - // output the field |
|
689 | - ?> |
|
688 | + // output the field |
|
689 | + ?> |
|
690 | 690 | <div class="row"> |
691 | 691 | <div class="input-field col s10 m5 l3"> |
692 | 692 | <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) : ''; ?>"> |
@@ -4,14 +4,14 @@ 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 | private $xcloner_sanitization; |
9 | 9 | private $xcloner_container; |
10 | 10 | |
11 | 11 | public function __construct(Xcloner $xcloner_container, $hash = "") |
12 | 12 | { |
13 | 13 | $this->xcloner_container = $xcloner_container; |
14 | - if(isset($hash)) |
|
14 | + if (isset($hash)) |
|
15 | 15 | $this->set_hash($hash); |
16 | 16 | } |
17 | 17 | |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | public function get_logger_filename($include_hash = 0) |
24 | 24 | { |
25 | - if($include_hash) |
|
25 | + if ($include_hash) |
|
26 | 26 | $filename = sprintf($this->logger_file_hash, $this->get_hash()); |
27 | 27 | else |
28 | 28 | $filename = sprintf($this->logger_file, $this->get_server_unique_hash(5)); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | public function get_xcloner_start_path() |
34 | 34 | { |
35 | - if(!get_option('xcloner_start_path') or !is_dir(get_option('xcloner_start_path'))) |
|
35 | + if (!get_option('xcloner_start_path') or !is_dir(get_option('xcloner_start_path'))) |
|
36 | 36 | $path = realpath(ABSPATH); |
37 | 37 | else |
38 | 38 | $path = get_option('xcloner_start_path'); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | public function get_xcloner_store_path() |
51 | 51 | { |
52 | - if(!get_option('xcloner_store_path') or !is_dir(get_option('xcloner_store_path'))) |
|
52 | + if (!get_option('xcloner_store_path') or !is_dir(get_option('xcloner_store_path'))) |
|
53 | 53 | $path = realpath(XCLONER_STORAGE_PATH); |
54 | 54 | else |
55 | 55 | $path = get_option('xcloner_store_path'); |
@@ -66,18 +66,18 @@ discard block |
||
66 | 66 | public function get_xcloner_tmp_path($suffix = true) |
67 | 67 | { |
68 | 68 | $path = sys_get_temp_dir(); |
69 | - if(!is_dir($path)) |
|
69 | + if (!is_dir($path)) |
|
70 | 70 | { |
71 | 71 | @mkdir($path); |
72 | 72 | @chmod($path, 0777); |
73 | 73 | } |
74 | 74 | |
75 | - if(!is_dir($path) or !is_writeable($path) or get_option('xcloner_force_tmp_path_site_root')) |
|
75 | + if (!is_dir($path) or !is_writeable($path) or get_option('xcloner_force_tmp_path_site_root')) |
|
76 | 76 | { |
77 | 77 | $path = $this->get_xcloner_store_path(); |
78 | 78 | } |
79 | 79 | |
80 | - if($suffix) |
|
80 | + if ($suffix) |
|
81 | 81 | { |
82 | 82 | $path = $path.DS.".".$this->get_xcloner_tmp_path_suffix(); |
83 | 83 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | public function get_enable_mysql_backup() |
89 | 89 | { |
90 | - if(get_option('xcloner_enable_mysql_backup')) |
|
90 | + if (get_option('xcloner_enable_mysql_backup')) |
|
91 | 91 | return true; |
92 | 92 | |
93 | 93 | return false; |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | |
96 | 96 | public function get_backup_extension_name($ext = "") |
97 | 97 | { |
98 | - if(!$ext) |
|
98 | + if (!$ext) |
|
99 | 99 | { |
100 | - if(get_option('xcloner_backup_compression_level')) |
|
100 | + if (get_option('xcloner_backup_compression_level')) |
|
101 | 101 | $ext = ".tgz"; |
102 | 102 | else |
103 | 103 | $ext = ".tar"; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | public function get_hash() |
109 | 109 | { |
110 | - if(!$this->hash){ |
|
110 | + if (!$this->hash) { |
|
111 | 111 | $this->set_hash("-".$this->get_server_unique_hash(5)); |
112 | 112 | } |
113 | 113 | |
@@ -119,17 +119,17 @@ discard block |
||
119 | 119 | { |
120 | 120 | $hash = "-".md5(rand()); |
121 | 121 | |
122 | - $this->set_hash(substr( $hash, 0, 6)); |
|
122 | + $this->set_hash(substr($hash, 0, 6)); |
|
123 | 123 | |
124 | 124 | return $hash; |
125 | 125 | } |
126 | 126 | |
127 | 127 | public function set_hash($hash = "") |
128 | 128 | { |
129 | - if(substr($hash, 0, 1) != "-" and strlen($hash)) |
|
129 | + if (substr($hash, 0, 1) != "-" and strlen($hash)) |
|
130 | 130 | $hash = "-".$hash; |
131 | 131 | |
132 | - $this->hash = substr( $hash, 0, 6); |
|
132 | + $this->hash = substr($hash, 0, 6); |
|
133 | 133 | |
134 | 134 | return $this; |
135 | 135 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | { |
139 | 139 | $data = parse_url(get_site_url()); |
140 | 140 | |
141 | - $backup_name = "backup_[domain]".(isset($data['port'])?"_".$data['port']:"")."-[time]-".($this->get_enable_mysql_backup()?"sql":"nosql"); |
|
141 | + $backup_name = "backup_[domain]".(isset($data['port']) ? "_".$data['port'] : "")."-[time]-".($this->get_enable_mysql_backup() ? "sql" : "nosql"); |
|
142 | 142 | |
143 | 143 | return $backup_name; |
144 | 144 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | { |
148 | 148 | global $wpdb; |
149 | 149 | |
150 | - if(!$data = get_option('xcloner_mysql_hostname')) |
|
150 | + if (!$data = get_option('xcloner_mysql_hostname')) |
|
151 | 151 | $data = $wpdb->dbhost; |
152 | 152 | |
153 | 153 | return $data; |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | { |
158 | 158 | global $wpdb; |
159 | 159 | |
160 | - if(!$data = get_option('xcloner_mysql_username')) |
|
160 | + if (!$data = get_option('xcloner_mysql_username')) |
|
161 | 161 | $data = $wpdb->dbuser; |
162 | 162 | |
163 | 163 | return $data; |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | { |
168 | 168 | global $wpdb; |
169 | 169 | |
170 | - if(!$data = get_option('xcloner_mysql_password')) |
|
170 | + if (!$data = get_option('xcloner_mysql_password')) |
|
171 | 171 | $data = $wpdb->dbpassword; |
172 | 172 | |
173 | 173 | return $data; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | { |
178 | 178 | global $wpdb; |
179 | 179 | |
180 | - if(!$data = get_option('xcloner_mysql_database')) |
|
180 | + if (!$data = get_option('xcloner_mysql_database')) |
|
181 | 181 | $data = $wpdb->dbname; |
182 | 182 | |
183 | 183 | return $data; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | { |
202 | 202 | $hash = md5(get_home_url().__DIR__); |
203 | 203 | |
204 | - if($strlen) |
|
204 | + if ($strlen) |
|
205 | 205 | $hash = substr($hash, 0, $strlen); |
206 | 206 | |
207 | 207 | return $hash; |
@@ -213,20 +213,20 @@ discard block |
||
213 | 213 | $this->xcloner_sanitization = $this->get_xcloner_container()->get_xcloner_sanitization(); |
214 | 214 | |
215 | 215 | //ADDING MISSING OPTIONS |
216 | - if( false == get_option( 'xcloner_mysql_settings_page' ) ) { |
|
217 | - add_option( 'xcloner_mysql_settings_page' ); |
|
216 | + if (false == get_option('xcloner_mysql_settings_page')) { |
|
217 | + add_option('xcloner_mysql_settings_page'); |
|
218 | 218 | } // end if |
219 | 219 | |
220 | - if( false == get_option( 'xcloner_cron_settings_page' ) ) { |
|
221 | - add_option( 'xcloner_cron_settings_page' ); |
|
220 | + if (false == get_option('xcloner_cron_settings_page')) { |
|
221 | + add_option('xcloner_cron_settings_page'); |
|
222 | 222 | } // end if |
223 | 223 | |
224 | - if( false == get_option( 'xcloner_system_settings_page' ) ) { |
|
225 | - add_option( 'xcloner_system_settings_page' ); |
|
224 | + if (false == get_option('xcloner_system_settings_page')) { |
|
225 | + add_option('xcloner_system_settings_page'); |
|
226 | 226 | } // end if |
227 | 227 | |
228 | - if( false == get_option( 'xcloner_cleanup_settings_page' ) ) { |
|
229 | - add_option( 'xcloner_cleanup_settings_page' ); |
|
228 | + if (false == get_option('xcloner_cleanup_settings_page')) { |
|
229 | + add_option('xcloner_cleanup_settings_page'); |
|
230 | 230 | } // end if |
231 | 231 | |
232 | 232 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | //SYSTEM section |
250 | 250 | add_settings_section( |
251 | 251 | 'xcloner_system_settings_group', |
252 | - __('These are advanced options recommended for developers!','xcloner-backup-and-restore'), |
|
252 | + __('These are advanced options recommended for developers!', 'xcloner-backup-and-restore'), |
|
253 | 253 | array($this, 'xcloner_settings_section_cb'), |
254 | 254 | 'xcloner_system_settings_page' |
255 | 255 | ); |
@@ -277,12 +277,12 @@ discard block |
||
277 | 277 | register_setting('xcloner_general_settings_group', 'xcloner_backup_compression_level', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
278 | 278 | add_settings_field( |
279 | 279 | 'xcloner_backup_compression_level', |
280 | - __('Backup Compression Level','xcloner-backup-and-restore'), |
|
280 | + __('Backup Compression Level', 'xcloner-backup-and-restore'), |
|
281 | 281 | array($this, 'do_form_range_field'), |
282 | 282 | 'xcloner_settings_page', |
283 | 283 | 'xcloner_general_settings_group', |
284 | 284 | array('xcloner_backup_compression_level', |
285 | - __('Options between [0-9]. Value 0 means no compression, while 9 is maximum compression affecting cpu load','xcloner-backup-and-restore'), |
|
285 | + __('Options between [0-9]. Value 0 means no compression, while 9 is maximum compression affecting cpu load', 'xcloner-backup-and-restore'), |
|
286 | 286 | 0, |
287 | 287 | 9 |
288 | 288 | ) |
@@ -291,12 +291,12 @@ discard block |
||
291 | 291 | register_setting('xcloner_general_settings_group', 'xcloner_start_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path")); |
292 | 292 | add_settings_field( |
293 | 293 | 'xcloner_start_path', |
294 | - __('Backup Start Location','xcloner-backup-and-restore'), |
|
294 | + __('Backup Start Location', 'xcloner-backup-and-restore'), |
|
295 | 295 | array($this, 'do_form_text_field'), |
296 | 296 | 'xcloner_settings_page', |
297 | 297 | 'xcloner_general_settings_group', |
298 | 298 | array('xcloner_start_path', |
299 | - __('Base path location from where XCloner can start the Backup.','xcloner-backup-and-restore'), |
|
299 | + __('Base path location from where XCloner can start the Backup.', 'xcloner-backup-and-restore'), |
|
300 | 300 | $this->get_xcloner_start_path(), |
301 | 301 | //'disabled' |
302 | 302 | ) |
@@ -305,12 +305,12 @@ discard block |
||
305 | 305 | register_setting('xcloner_general_settings_group', 'xcloner_store_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path")); |
306 | 306 | add_settings_field( |
307 | 307 | 'xcloner_store_path', |
308 | - __('Backup Storage Location','xcloner-backup-and-restore'), |
|
308 | + __('Backup Storage Location', 'xcloner-backup-and-restore'), |
|
309 | 309 | array($this, 'do_form_text_field'), |
310 | 310 | 'xcloner_settings_page', |
311 | 311 | 'xcloner_general_settings_group', |
312 | 312 | array('xcloner_store_path', |
313 | - __('Location where XCloner will store the Backup archives.','xcloner-backup-and-restore'), |
|
313 | + __('Location where XCloner will store the Backup archives.', 'xcloner-backup-and-restore'), |
|
314 | 314 | $this->get_xcloner_store_path(), |
315 | 315 | //'disabled' |
316 | 316 | ) |
@@ -319,36 +319,36 @@ discard block |
||
319 | 319 | register_setting('xcloner_general_settings_group', 'xcloner_enable_log', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
320 | 320 | add_settings_field( |
321 | 321 | 'xcloner_enable_log', |
322 | - __('Enable XCloner Backup Log','xcloner-backup-and-restore'), |
|
322 | + __('Enable XCloner Backup Log', 'xcloner-backup-and-restore'), |
|
323 | 323 | array($this, 'do_form_switch_field'), |
324 | 324 | 'xcloner_settings_page', |
325 | 325 | 'xcloner_general_settings_group', |
326 | 326 | array('xcloner_enable_log', |
327 | - 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()) |
|
327 | + 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()) |
|
328 | 328 | ) |
329 | 329 | ); |
330 | 330 | |
331 | 331 | register_setting('xcloner_general_settings_group', 'xcloner_enable_pre_update_backup', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
332 | 332 | add_settings_field( |
333 | 333 | 'xcloner_enable_pre_update_backup', |
334 | - __('Generate Backups before Automatic WP Upgrades','xcloner-backup-and-restore'), |
|
334 | + __('Generate Backups before Automatic WP Upgrades', 'xcloner-backup-and-restore'), |
|
335 | 335 | array($this, 'do_form_switch_field'), |
336 | 336 | 'xcloner_settings_page', |
337 | 337 | 'xcloner_general_settings_group', |
338 | 338 | array('xcloner_enable_pre_update_backup', |
339 | - sprintf(__('Attempt to generate a core, plugins, themes or languages files backup before the automatic update of Wordpress core, plugins, themes or languages files.','xcloner-backup-and-restore'), $this->get_logger_filename()) |
|
339 | + sprintf(__('Attempt to generate a core, plugins, themes or languages files backup before the automatic update of Wordpress core, plugins, themes or languages files.', 'xcloner-backup-and-restore'), $this->get_logger_filename()) |
|
340 | 340 | ) |
341 | 341 | ); |
342 | 342 | |
343 | 343 | register_setting('xcloner_general_settings_group', 'xcloner_regex_exclude', array($this->xcloner_sanitization, "sanitize_input_as_raw")); |
344 | 344 | add_settings_field( |
345 | 345 | 'xcloner_regex_exclude', |
346 | - __('Regex Exclude Files','xcloner-backup-and-restore'), |
|
346 | + __('Regex Exclude Files', 'xcloner-backup-and-restore'), |
|
347 | 347 | array($this, 'do_form_textarea_field'), |
348 | 348 | 'xcloner_settings_page', |
349 | 349 | 'xcloner_general_settings_group', |
350 | 350 | array('xcloner_regex_exclude', |
351 | - __('Regular expression match to exclude files and folders, example patterns provided below, one pattern per line','xcloner-backup-and-restore'), |
|
351 | + __('Regular expression match to exclude files and folders, example patterns provided below, one pattern per line', 'xcloner-backup-and-restore'), |
|
352 | 352 | //$this->get_xcloner_store_path(), |
353 | 353 | //'disabled' |
354 | 354 | ) |
@@ -358,36 +358,36 @@ discard block |
||
358 | 358 | register_setting('xcloner_mysql_settings_group', 'xcloner_enable_mysql_backup', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
359 | 359 | add_settings_field( |
360 | 360 | 'xcloner_enable_mysql_backup', |
361 | - __('Enable Mysql Backup','xcloner-backup-and-restore'), |
|
361 | + __('Enable Mysql Backup', 'xcloner-backup-and-restore'), |
|
362 | 362 | array($this, 'do_form_switch_field'), |
363 | 363 | 'xcloner_mysql_settings_page', |
364 | 364 | 'xcloner_mysql_settings_group', |
365 | 365 | array('xcloner_enable_mysql_backup', |
366 | - __('Enable Mysql Backup Option. If you don\'t want to backup the database, you can disable this.','xcloner-backup-and-restore') |
|
366 | + __('Enable Mysql Backup Option. If you don\'t want to backup the database, you can disable this.', 'xcloner-backup-and-restore') |
|
367 | 367 | ) |
368 | 368 | ); |
369 | 369 | |
370 | 370 | register_setting('xcloner_mysql_settings_group', 'xcloner_backup_only_wp_tables'); |
371 | 371 | add_settings_field( |
372 | 372 | 'xcloner_backup_only_wp_tables', |
373 | - __('Backup only WP tables','xcloner-backup-and-restore'), |
|
373 | + __('Backup only WP tables', 'xcloner-backup-and-restore'), |
|
374 | 374 | array($this, 'do_form_switch_field'), |
375 | 375 | 'xcloner_mysql_settings_page', |
376 | 376 | 'xcloner_mysql_settings_group', |
377 | 377 | array('xcloner_backup_only_wp_tables', |
378 | - sprintf(__('Enable this if you only want to Backup only tables starting with \'%s\' prefix','xcloner-backup-and-restore'), $this->get_table_prefix()) |
|
378 | + sprintf(__('Enable this if you only want to Backup only tables starting with \'%s\' prefix', 'xcloner-backup-and-restore'), $this->get_table_prefix()) |
|
379 | 379 | ) |
380 | 380 | ); |
381 | 381 | |
382 | 382 | register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_hostname', array($this->xcloner_sanitization, "sanitize_input_as_raw")); |
383 | 383 | add_settings_field( |
384 | 384 | 'xcloner_mysql_hostname', |
385 | - __('Mysql Hostname','xcloner-backup-and-restore'), |
|
385 | + __('Mysql Hostname', 'xcloner-backup-and-restore'), |
|
386 | 386 | array($this, 'do_form_text_field'), |
387 | 387 | 'xcloner_mysql_settings_page', |
388 | 388 | 'xcloner_mysql_settings_group', |
389 | 389 | array('xcloner_mysql_hostname', |
390 | - __('Wordpress mysql hostname','xcloner-backup-and-restore'), |
|
390 | + __('Wordpress mysql hostname', 'xcloner-backup-and-restore'), |
|
391 | 391 | $this->get_db_hostname(), |
392 | 392 | 'disabled' |
393 | 393 | ) |
@@ -396,12 +396,12 @@ discard block |
||
396 | 396 | register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_username', array($this->xcloner_sanitization, "sanitize_input_as_raw")); |
397 | 397 | add_settings_field( |
398 | 398 | 'xcloner_mysql_username', |
399 | - __('Mysql Username','xcloner-backup-and-restore'), |
|
399 | + __('Mysql Username', 'xcloner-backup-and-restore'), |
|
400 | 400 | array($this, 'do_form_text_field'), |
401 | 401 | 'xcloner_mysql_settings_page', |
402 | 402 | 'xcloner_mysql_settings_group', |
403 | 403 | array('xcloner_mysql_username', |
404 | - __('Wordpress mysql username','xcloner-backup-and-restore'), |
|
404 | + __('Wordpress mysql username', 'xcloner-backup-and-restore'), |
|
405 | 405 | $this->get_db_username(), |
406 | 406 | 'disabled' |
407 | 407 | ) |
@@ -410,12 +410,12 @@ discard block |
||
410 | 410 | register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_database', array($this->xcloner_sanitization, "sanitize_input_as_raw")); |
411 | 411 | add_settings_field( |
412 | 412 | 'xcloner_mysql_database', |
413 | - __('Mysql Database','xcloner-backup-and-restore'), |
|
413 | + __('Mysql Database', 'xcloner-backup-and-restore'), |
|
414 | 414 | array($this, 'do_form_text_field'), |
415 | 415 | 'xcloner_mysql_settings_page', |
416 | 416 | 'xcloner_mysql_settings_group', |
417 | 417 | array('xcloner_mysql_database', |
418 | - __('Wordpress mysql database','xcloner-backup-and-restore'), |
|
418 | + __('Wordpress mysql database', 'xcloner-backup-and-restore'), |
|
419 | 419 | $this->get_db_database(), |
420 | 420 | 'disabled' |
421 | 421 | ) |
@@ -425,12 +425,12 @@ discard block |
||
425 | 425 | register_setting('xcloner_system_settings_group', 'xcloner_size_limit_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
426 | 426 | add_settings_field( |
427 | 427 | 'xcloner_size_limit_per_request', |
428 | - __('Data Size Limit Per Request','xcloner-backup-and-restore'), |
|
428 | + __('Data Size Limit Per Request', 'xcloner-backup-and-restore'), |
|
429 | 429 | array($this, 'do_form_range_field'), |
430 | 430 | 'xcloner_system_settings_page', |
431 | 431 | 'xcloner_system_settings_group', |
432 | 432 | array('xcloner_size_limit_per_request', |
433 | - __('Use this option to set how much file data can XCloner backup in one AJAX request. Range 0-1024 MB','xcloner-backup-and-restore'), |
|
433 | + __('Use this option to set how much file data can XCloner backup in one AJAX request. Range 0-1024 MB', 'xcloner-backup-and-restore'), |
|
434 | 434 | 0, |
435 | 435 | 1024 |
436 | 436 | ) |
@@ -439,12 +439,12 @@ discard block |
||
439 | 439 | register_setting('xcloner_system_settings_group', 'xcloner_files_to_process_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
440 | 440 | add_settings_field( |
441 | 441 | 'xcloner_files_to_process_per_request', |
442 | - __('Files To Process Per Request','xcloner-backup-and-restore'), |
|
442 | + __('Files To Process Per Request', 'xcloner-backup-and-restore'), |
|
443 | 443 | array($this, 'do_form_range_field'), |
444 | 444 | 'xcloner_system_settings_page', |
445 | 445 | 'xcloner_system_settings_group', |
446 | 446 | array('xcloner_files_to_process_per_request', |
447 | - __('Use this option to set how many files XCloner should process at one time before doing another AJAX call','xcloner-backup-and-restore'), |
|
447 | + __('Use this option to set how many files XCloner should process at one time before doing another AJAX call', 'xcloner-backup-and-restore'), |
|
448 | 448 | 0, |
449 | 449 | 1000 |
450 | 450 | ) |
@@ -453,12 +453,12 @@ discard block |
||
453 | 453 | register_setting('xcloner_system_settings_group', 'xcloner_directories_to_scan_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
454 | 454 | add_settings_field( |
455 | 455 | 'xcloner_directories_to_scan_per_request', |
456 | - __('Directories To Scan Per Request','xcloner-backup-and-restore'), |
|
456 | + __('Directories To Scan Per Request', 'xcloner-backup-and-restore'), |
|
457 | 457 | array($this, 'do_form_range_field'), |
458 | 458 | 'xcloner_system_settings_page', |
459 | 459 | 'xcloner_system_settings_group', |
460 | 460 | array('xcloner_directories_to_scan_per_request', |
461 | - __('Use this option to set how many directories XCloner should scan at one time before doing another AJAX call','xcloner-backup-and-restore'), |
|
461 | + __('Use this option to set how many directories XCloner should scan at one time before doing another AJAX call', 'xcloner-backup-and-restore'), |
|
462 | 462 | 0, |
463 | 463 | 1000 |
464 | 464 | ) |
@@ -467,12 +467,12 @@ discard block |
||
467 | 467 | register_setting('xcloner_system_settings_group', 'xcloner_database_records_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
468 | 468 | add_settings_field( |
469 | 469 | 'xcloner_database_records_per_request', |
470 | - __('Database Records Per Request','xcloner-backup-and-restore'), |
|
470 | + __('Database Records Per Request', 'xcloner-backup-and-restore'), |
|
471 | 471 | array($this, 'do_form_range_field'), |
472 | 472 | 'xcloner_system_settings_page', |
473 | 473 | 'xcloner_system_settings_group', |
474 | 474 | array('xcloner_database_records_per_request', |
475 | - __('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'), |
|
475 | + __('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'), |
|
476 | 476 | 0, |
477 | 477 | 100000 |
478 | 478 | ) |
@@ -493,36 +493,36 @@ discard block |
||
493 | 493 | register_setting('xcloner_system_settings_group', 'xcloner_exclude_files_larger_than_mb', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
494 | 494 | add_settings_field( |
495 | 495 | 'xcloner_exclude_files_larger_than_mb', |
496 | - __('Exclude files larger than (MB)','xcloner-backup-and-restore'), |
|
496 | + __('Exclude files larger than (MB)', 'xcloner-backup-and-restore'), |
|
497 | 497 | array($this, 'do_form_number_field'), |
498 | 498 | 'xcloner_system_settings_page', |
499 | 499 | 'xcloner_system_settings_group', |
500 | 500 | array('xcloner_exclude_files_larger_than_mb', |
501 | - __('Use this option to automatically exclude files larger than a certain size in MB, or set to 0 to include all. Range 0-1000 MB','xcloner-backup-and-restore'), |
|
501 | + __('Use this option to automatically exclude files larger than a certain size in MB, or set to 0 to include all. Range 0-1000 MB', 'xcloner-backup-and-restore'), |
|
502 | 502 | ) |
503 | 503 | ); |
504 | 504 | |
505 | 505 | register_setting('xcloner_system_settings_group', 'xcloner_split_backup_limit', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
506 | 506 | add_settings_field( |
507 | 507 | 'xcloner_split_backup_limit', |
508 | - __('Split Backup Archive Limit (MB)','xcloner-backup-and-restore'), |
|
508 | + __('Split Backup Archive Limit (MB)', 'xcloner-backup-and-restore'), |
|
509 | 509 | array($this, 'do_form_number_field'), |
510 | 510 | 'xcloner_system_settings_page', |
511 | 511 | 'xcloner_system_settings_group', |
512 | 512 | array('xcloner_split_backup_limit', |
513 | - __('Use this option to automatically split the backup archive into smaller parts. Range 0-10000 MB','xcloner-backup-and-restore'), |
|
513 | + __('Use this option to automatically split the backup archive into smaller parts. Range 0-10000 MB', 'xcloner-backup-and-restore'), |
|
514 | 514 | ) |
515 | 515 | ); |
516 | 516 | |
517 | 517 | register_setting('xcloner_system_settings_group', 'xcloner_force_tmp_path_site_root'); |
518 | 518 | add_settings_field( |
519 | 519 | 'xcloner_force_tmp_path_site_root', |
520 | - __('Force Temporary Path Within XCloner Storage','xcloner-backup-and-restore'), |
|
520 | + __('Force Temporary Path Within XCloner Storage', 'xcloner-backup-and-restore'), |
|
521 | 521 | array($this, 'do_form_switch_field'), |
522 | 522 | 'xcloner_system_settings_page', |
523 | 523 | 'xcloner_system_settings_group', |
524 | 524 | array('xcloner_force_tmp_path_site_root', |
525 | - 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()) |
|
525 | + 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()) |
|
526 | 526 | ) |
527 | 527 | ); |
528 | 528 | |
@@ -530,48 +530,48 @@ discard block |
||
530 | 530 | register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_days', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
531 | 531 | add_settings_field( |
532 | 532 | 'xcloner_cleanup_retention_limit_days', |
533 | - __('Cleanup by Date(days)','xcloner-backup-and-restore'), |
|
533 | + __('Cleanup by Date(days)', 'xcloner-backup-and-restore'), |
|
534 | 534 | array($this, 'do_form_number_field'), |
535 | 535 | 'xcloner_cleanup_settings_page', |
536 | 536 | 'xcloner_cleanup_settings_group', |
537 | 537 | array('xcloner_cleanup_retention_limit_days', |
538 | - __('Specify the maximum number of days a backup archive can be kept on the server. 0 disables this option','xcloner-backup-and-restore') |
|
538 | + __('Specify the maximum number of days a backup archive can be kept on the server. 0 disables this option', 'xcloner-backup-and-restore') |
|
539 | 539 | ) |
540 | 540 | ); |
541 | 541 | |
542 | 542 | register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_archives', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
543 | 543 | add_settings_field( |
544 | 544 | 'xcloner_cleanup_retention_limit_archives', |
545 | - __('Cleanup by Quantity','xcloner-backup-and-restore'), |
|
545 | + __('Cleanup by Quantity', 'xcloner-backup-and-restore'), |
|
546 | 546 | array($this, 'do_form_number_field'), |
547 | 547 | 'xcloner_cleanup_settings_page', |
548 | 548 | 'xcloner_cleanup_settings_group', |
549 | 549 | array('xcloner_cleanup_retention_limit_archives', |
550 | - __('Specify the maximum number of backup archives to keep on the server. 0 disables this option','xcloner-backup-and-restore') |
|
550 | + __('Specify the maximum number of backup archives to keep on the server. 0 disables this option', 'xcloner-backup-and-restore') |
|
551 | 551 | ) |
552 | 552 | ); |
553 | 553 | |
554 | 554 | register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_capacity_limit', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
555 | 555 | add_settings_field( |
556 | 556 | 'xcloner_cleanup_capacity_limit', |
557 | - __('Cleanup by Capacity(MB)','xcloner-backup-and-restore'), |
|
557 | + __('Cleanup by Capacity(MB)', 'xcloner-backup-and-restore'), |
|
558 | 558 | array($this, 'do_form_number_field'), |
559 | 559 | 'xcloner_cleanup_settings_page', |
560 | 560 | 'xcloner_cleanup_settings_group', |
561 | 561 | array('xcloner_cleanup_capacity_limit', |
562 | - __('Remove oldest backups if all created backups exceed the configured limit in Megabytes. 0 disables this option','xcloner-backup-and-restore') |
|
562 | + __('Remove oldest backups if all created backups exceed the configured limit in Megabytes. 0 disables this option', 'xcloner-backup-and-restore') |
|
563 | 563 | ) |
564 | 564 | ); |
565 | 565 | |
566 | 566 | register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_delete_after_remote_transfer', array($this->xcloner_sanitization, "sanitize_input_as_int")); |
567 | 567 | add_settings_field( |
568 | 568 | 'xcloner_cleanup_delete_after_remote_transfer', |
569 | - __('Delete Backup After Sending it to Remote Storage','xcloner-backup-and-restore'), |
|
569 | + __('Delete Backup After Sending it to Remote Storage', 'xcloner-backup-and-restore'), |
|
570 | 570 | array($this, 'do_form_switch_field'), |
571 | 571 | 'xcloner_cleanup_settings_page', |
572 | 572 | 'xcloner_cleanup_settings_group', |
573 | 573 | array('xcloner_cleanup_delete_after_remote_transfer', |
574 | - __('Remove backups created automatically from local storage after sending the backup to remote storage','xcloner-backup-and-restore') |
|
574 | + __('Remove backups created automatically from local storage after sending the backup to remote storage', 'xcloner-backup-and-restore') |
|
575 | 575 | ) |
576 | 576 | ); |
577 | 577 | |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | register_setting('xcloner_cron_settings_group', 'xcloner_cron_frequency'); |
580 | 580 | add_settings_field( |
581 | 581 | 'xcloner_cron_frequency', |
582 | - __('Cron frequency','xcloner-backup-and-restore'), |
|
582 | + __('Cron frequency', 'xcloner-backup-and-restore'), |
|
583 | 583 | array($this, 'do_form_text_field'), |
584 | 584 | 'xcloner_cron_settings_page', |
585 | 585 | 'xcloner_cron_settings_group', |
@@ -605,20 +605,20 @@ discard block |
||
605 | 605 | // text field content cb |
606 | 606 | public function do_form_text_field($params) |
607 | 607 | { |
608 | - if(!isset($params['3'])) |
|
608 | + if (!isset($params['3'])) |
|
609 | 609 | $params[3] = 0; |
610 | - if(!isset($params['2'])) |
|
610 | + if (!isset($params['2'])) |
|
611 | 611 | $params[2] = 0; |
612 | 612 | |
613 | 613 | list($fieldname, $label, $value, $disabled) = $params; |
614 | 614 | |
615 | - if(!$value) |
|
615 | + if (!$value) |
|
616 | 616 | $value = get_option($fieldname); |
617 | 617 | // output the field |
618 | 618 | ?> |
619 | 619 | <div class="row"> |
620 | 620 | <div class="input-field col s10 m10 l8"> |
621 | - <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) : ''; ?>"> |
|
621 | + <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) : ''; ?>"> |
|
622 | 622 | </div> |
623 | 623 | <div class="col s2 m2 "> |
624 | 624 | <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> |
@@ -632,20 +632,20 @@ discard block |
||
632 | 632 | // textarea field content cb |
633 | 633 | public function do_form_textarea_field($params) |
634 | 634 | { |
635 | - if(!isset($params['3'])) |
|
635 | + if (!isset($params['3'])) |
|
636 | 636 | $params[3] = 0; |
637 | - if(!isset($params['2'])) |
|
637 | + if (!isset($params['2'])) |
|
638 | 638 | $params[2] = 0; |
639 | 639 | |
640 | 640 | list($fieldname, $label, $value, $disabled) = $params; |
641 | 641 | |
642 | - if(!$value) |
|
642 | + if (!$value) |
|
643 | 643 | $value = get_option($fieldname); |
644 | 644 | // output the field |
645 | 645 | ?> |
646 | 646 | <div class="row"> |
647 | 647 | <div class="input-field col s10 m10 l8"> |
648 | - <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> |
|
648 | + <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> |
|
649 | 649 | </div> |
650 | 650 | <div class="col s2 m2 "> |
651 | 651 | <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> |
@@ -676,20 +676,20 @@ discard block |
||
676 | 676 | // number field content cb |
677 | 677 | public function do_form_number_field($params) |
678 | 678 | { |
679 | - if(!isset($params['3'])) |
|
679 | + if (!isset($params['3'])) |
|
680 | 680 | $params[3] = 0; |
681 | - if(!isset($params['2'])) |
|
681 | + if (!isset($params['2'])) |
|
682 | 682 | $params[2] = 0; |
683 | 683 | |
684 | 684 | list($fieldname, $label, $value, $disabled) = $params; |
685 | 685 | |
686 | - if(!$value) |
|
686 | + if (!$value) |
|
687 | 687 | $value = get_option($fieldname); |
688 | 688 | // output the field |
689 | 689 | ?> |
690 | 690 | <div class="row"> |
691 | 691 | <div class="input-field col s10 m5 l3"> |
692 | - <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) : ''; ?>"> |
|
692 | + <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) : ''; ?>"> |
|
693 | 693 | </div> |
694 | 694 | <div class="col s2 m2 "> |
695 | 695 | <a class="btn-floating tooltipped btn-small" data-html="true" data-position="center" data-delay="50" data-tooltip="<?php echo $label?>" data-tooltip-id=""><i class="material-icons">help_outline</i></a> |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | |
703 | 703 | public function do_form_range_field($params) |
704 | 704 | { |
705 | - if(!isset($params['4'])) |
|
705 | + if (!isset($params['4'])) |
|
706 | 706 | $params[4] = 0; |
707 | 707 | |
708 | 708 | list($fieldname, $label, $range_start, $range_end, $disabled) = $params; |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | <div class="row"> |
712 | 712 | <div class="input-field col s10 m10 l8"> |
713 | 713 | <p class="range-field"> |
714 | - <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) : ''; ?>" /> |
|
714 | + <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) : ''; ?>" /> |
|
715 | 715 | </p> |
716 | 716 | </div> |
717 | 717 | <div class="col s2 m2 "> |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | |
725 | 725 | public function do_form_switch_field($params) |
726 | 726 | { |
727 | - if(!isset($params['2'])) |
|
727 | + if (!isset($params['2'])) |
|
728 | 728 | $params[2] = 0; |
729 | 729 | list($fieldname, $label, $disabled) = $params; |
730 | 730 | $value = get_option($fieldname); |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | <div class="switch"> |
735 | 735 | <label> |
736 | 736 | Off |
737 | - <input <?php echo ($disabled)?"disabled":""?> type="checkbox" name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" value="1" <?php echo ($value) ? 'checked="checked"' : ''; ?>"> |
|
737 | + <input <?php echo ($disabled) ? "disabled" : ""?> type="checkbox" name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" value="1" <?php echo ($value) ? 'checked="checked"' : ''; ?>"> |
|
738 | 738 | <span class="lever"></span> |
739 | 739 | On |
740 | 740 | </label> |
@@ -198,6 +198,9 @@ |
||
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
201 | + /** |
|
202 | + * @param string $storage_type |
|
203 | + */ |
|
201 | 204 | public function verify_filesystem($storage_type) |
202 | 205 | { |
203 | 206 | $method = "get_".$storage_type."_filesystem"; |
@@ -385,9 +385,9 @@ discard block |
||
385 | 385 | } |
386 | 386 | |
387 | 387 | $endpoint = sprintf( |
388 | - 'DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s', |
|
389 | - get_option("xcloner_azure_account_name"), |
|
390 | - get_option("xcloner_azure_api_key") |
|
388 | + 'DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s', |
|
389 | + get_option("xcloner_azure_account_name"), |
|
390 | + get_option("xcloner_azure_api_key") |
|
391 | 391 | ); |
392 | 392 | |
393 | 393 | $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($endpoint); |
@@ -431,12 +431,12 @@ discard block |
||
431 | 431 | |
432 | 432 | |
433 | 433 | $client = new S3Client([ |
434 | - 'credentials' => [ |
|
435 | - 'key' => get_option("xcloner_aws_key"), |
|
436 | - 'secret' => get_option("xcloner_aws_secret") |
|
437 | - ], |
|
438 | - 'region' => get_option("xcloner_aws_region"), |
|
439 | - 'version' => 'latest', |
|
434 | + 'credentials' => [ |
|
435 | + 'key' => get_option("xcloner_aws_key"), |
|
436 | + 'secret' => get_option("xcloner_aws_secret") |
|
437 | + ], |
|
438 | + 'region' => get_option("xcloner_aws_region"), |
|
439 | + 'version' => 'latest', |
|
440 | 440 | ]); |
441 | 441 | |
442 | 442 | $adapter = new AwsS3Adapter($client, get_option("xcloner_aws_bucket_name")); |
@@ -599,9 +599,9 @@ discard block |
||
599 | 599 | { |
600 | 600 | $query = sprintf('mimeType = \'application/vnd.google-apps.folder\' and \'%s\' in parents and name contains \'%s\'', $parent, $dir); |
601 | 601 | $response = $service->files->listFiles([ |
602 | - 'pageSize' => 1, |
|
603 | - 'q' => $query |
|
604 | - ]); |
|
602 | + 'pageSize' => 1, |
|
603 | + 'q' => $query |
|
604 | + ]); |
|
605 | 605 | |
606 | 606 | if(sizeof($response)) |
607 | 607 | { |
@@ -630,16 +630,16 @@ discard block |
||
630 | 630 | $this->logger->info(sprintf("Creating the FTP remote storage connection"), array("")); |
631 | 631 | |
632 | 632 | $adapter = new Adapter([ |
633 | - 'host' => get_option("xcloner_ftp_hostname"), |
|
634 | - 'username' => get_option("xcloner_ftp_username"), |
|
635 | - 'password' => get_option("xcloner_ftp_password"), |
|
636 | - |
|
637 | - /** optional config settings */ |
|
638 | - 'port' => get_option("xcloner_ftp_port", 21), |
|
639 | - 'root' => get_option("xcloner_ftp_path"), |
|
640 | - 'passive' => get_option("xcloner_ftp_transfer_mode"), |
|
641 | - 'ssl' => get_option("xcloner_ftp_ssl_mode"), |
|
642 | - 'timeout' => get_option("xcloner_ftp_timeout", 30), |
|
633 | + 'host' => get_option("xcloner_ftp_hostname"), |
|
634 | + 'username' => get_option("xcloner_ftp_username"), |
|
635 | + 'password' => get_option("xcloner_ftp_password"), |
|
636 | + |
|
637 | + /** optional config settings */ |
|
638 | + 'port' => get_option("xcloner_ftp_port", 21), |
|
639 | + 'root' => get_option("xcloner_ftp_path"), |
|
640 | + 'passive' => get_option("xcloner_ftp_transfer_mode"), |
|
641 | + 'ssl' => get_option("xcloner_ftp_ssl_mode"), |
|
642 | + 'timeout' => get_option("xcloner_ftp_timeout", 30), |
|
643 | 643 | ]); |
644 | 644 | |
645 | 645 | $adapter->connect(); |
@@ -656,15 +656,15 @@ discard block |
||
656 | 656 | $this->logger->info(sprintf("Creating the SFTP remote storage connection"), array("")); |
657 | 657 | |
658 | 658 | $adapter = new SftpAdapter([ |
659 | - 'host' => get_option("xcloner_sftp_hostname"), |
|
660 | - 'username' => get_option("xcloner_sftp_username"), |
|
661 | - 'password' => get_option("xcloner_sftp_password"), |
|
662 | - |
|
663 | - /** optional config settings */ |
|
664 | - 'port' => get_option("xcloner_sftp_port", 22), |
|
665 | - 'root' => get_option("xcloner_sftp_path"), |
|
666 | - 'privateKey' => get_option("xcloner_sftp_private_key"), |
|
667 | - 'timeout' => get_option("xcloner_ftp_timeout", 30), |
|
659 | + 'host' => get_option("xcloner_sftp_hostname"), |
|
660 | + 'username' => get_option("xcloner_sftp_username"), |
|
661 | + 'password' => get_option("xcloner_sftp_password"), |
|
662 | + |
|
663 | + /** optional config settings */ |
|
664 | + 'port' => get_option("xcloner_sftp_port", 22), |
|
665 | + 'root' => get_option("xcloner_sftp_path"), |
|
666 | + 'privateKey' => get_option("xcloner_sftp_private_key"), |
|
667 | + 'timeout' => get_option("xcloner_ftp_timeout", 30), |
|
668 | 668 | ]); |
669 | 669 | |
670 | 670 | $adapter->connect(); |
@@ -1,25 +1,19 @@ |
||
1 | 1 | <?php |
2 | 2 | use League\Flysystem\Config; |
3 | 3 | use League\Flysystem\Filesystem; |
4 | - |
|
5 | 4 | use League\Flysystem\Adapter\Ftp as Adapter; |
6 | - |
|
7 | 5 | use League\Flysystem\Sftp\SftpAdapter; |
8 | 6 | |
9 | 7 | #use League\Flysystem\Dropbox\DropboxAdapter; |
10 | 8 | #use Dropbox\Client; |
11 | 9 | use Srmklive\Dropbox\Client\DropboxClient; |
12 | 10 | use Srmklive\Dropbox\Adapter\DropboxAdapter; |
13 | - |
|
14 | 11 | use MicrosoftAzure\Storage\Common\ServicesBuilder; |
15 | 12 | use League\Flysystem\Azure\AzureAdapter; |
16 | - |
|
17 | 13 | use Aws\S3\S3Client; |
18 | 14 | use League\Flysystem\AwsS3v3\AwsS3Adapter; |
19 | - |
|
20 | 15 | use Mhetreramesh\Flysystem\BackblazeAdapter; |
21 | 16 | use ChrisWhite\B2\Client as B2Client; |
22 | - |
|
23 | 17 | use Sabre\DAV\Client as SabreClient; |
24 | 18 | use League\Flysystem\WebDAV\WebDAVAdapter; |
25 | 19 |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | use Sabre\DAV\Client as SabreClient; |
24 | 24 | use League\Flysystem\WebDAV\WebDAVAdapter; |
25 | 25 | |
26 | -class Xcloner_Remote_Storage{ |
|
26 | +class Xcloner_Remote_Storage { |
|
27 | 27 | |
28 | - private $gdrive_app_name = "XCloner Backup and Restore"; |
|
28 | + private $gdrive_app_name = "XCloner Backup and Restore"; |
|
29 | 29 | |
30 | 30 | private $storage_fields = array( |
31 | 31 | "option_prefix" => "xcloner_", |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | { |
136 | 136 | $this->xcloner_sanitization = $xcloner_container->get_xcloner_sanitization(); |
137 | 137 | $this->xcloner_file_system = $xcloner_container->get_xcloner_filesystem(); |
138 | - $this->logger = $xcloner_container->get_xcloner_logger()->withName("xcloner_remote_storage"); |
|
139 | - $this->xcloner = $xcloner_container; |
|
138 | + $this->logger = $xcloner_container->get_xcloner_logger()->withName("xcloner_remote_storage"); |
|
139 | + $this->xcloner = $xcloner_container; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | private function get_xcloner_container() |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | public function get_available_storages() |
148 | 148 | { |
149 | 149 | $return = array(); |
150 | - foreach($this->storage_fields as $storage=>$data) |
|
150 | + foreach ($this->storage_fields as $storage=>$data) |
|
151 | 151 | { |
152 | 152 | $check_field = $this->storage_fields["option_prefix"].$storage."_enable"; |
153 | - if(get_option($check_field)) |
|
153 | + if (get_option($check_field)) |
|
154 | 154 | $return[$storage] = $data['text']; |
155 | 155 | } |
156 | 156 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | |
160 | 160 | public function save($action = "ftp") |
161 | 161 | { |
162 | - if(!$action) |
|
162 | + if (!$action) |
|
163 | 163 | { |
164 | 164 | return false; |
165 | 165 | } |
@@ -167,17 +167,17 @@ discard block |
||
167 | 167 | $storage = $this->xcloner_sanitization->sanitize_input_as_string($action); |
168 | 168 | $this->logger->debug(sprintf("Saving the remote storage %s options", strtoupper($action))); |
169 | 169 | |
170 | - if(is_array($this->storage_fields[$storage])) |
|
170 | + if (is_array($this->storage_fields[$storage])) |
|
171 | 171 | { |
172 | - foreach($this->storage_fields[$storage] as $field=>$validation) |
|
172 | + foreach ($this->storage_fields[$storage] as $field=>$validation) |
|
173 | 173 | { |
174 | 174 | $check_field = $this->storage_fields["option_prefix"].$field; |
175 | 175 | $sanitize_method = "sanitize_input_as_".$validation; |
176 | 176 | |
177 | - if(!isset($_POST[$check_field])) |
|
177 | + if (!isset($_POST[$check_field])) |
|
178 | 178 | $_POST[$check_field] = 0; |
179 | 179 | |
180 | - if(!method_exists($this->xcloner_sanitization, $sanitize_method)) |
|
180 | + if (!method_exists($this->xcloner_sanitization, $sanitize_method)) |
|
181 | 181 | $sanitize_method = "sanitize_input_as_string"; |
182 | 182 | |
183 | 183 | $sanitized_value = $this->xcloner_sanitization->$sanitize_method(stripslashes($_POST[$check_field])); |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | |
192 | 192 | public function check($action = "ftp") |
193 | 193 | { |
194 | - try{ |
|
194 | + try { |
|
195 | 195 | $this->verify_filesystem($action); |
196 | 196 | $this->xcloner->trigger_message(__("%s connection is valid.", 'xcloner-backup-and-restore'), "success", ucfirst($action)); |
197 | 197 | $this->logger->debug(sprintf("Connection to remote storage %s is valid", strtoupper($action))); |
198 | - }catch(Exception $e){ |
|
198 | + }catch (Exception $e) { |
|
199 | 199 | $this->xcloner->trigger_message("%s connection error: ".$e->getMessage(), "error", ucfirst($action)); |
200 | 200 | } |
201 | 201 | } |
@@ -206,35 +206,35 @@ discard block |
||
206 | 206 | |
207 | 207 | $this->logger->info(sprintf("Checking validity of the remote storage %s filesystem", strtoupper($storage_type))); |
208 | 208 | |
209 | - if(!method_exists($this, $method)) |
|
209 | + if (!method_exists($this, $method)) |
|
210 | 210 | return false; |
211 | 211 | |
212 | 212 | list($adapter, $filesystem) = $this->$method(); |
213 | 213 | |
214 | 214 | $test_file = substr(".xcloner_".md5(time()), 0, 15); |
215 | 215 | |
216 | - if($storage_type == "gdrive") |
|
216 | + if ($storage_type == "gdrive") |
|
217 | 217 | { |
218 | - if(!is_array($filesystem->listContents())) |
|
219 | - throw new Exception(__("Could not read data",'xcloner-backup-and-restore')); |
|
218 | + if (!is_array($filesystem->listContents())) |
|
219 | + throw new Exception(__("Could not read data", 'xcloner-backup-and-restore')); |
|
220 | 220 | $this->logger->debug(sprintf("I can list data from remote storage %s", strtoupper($storage_type))); |
221 | 221 | |
222 | 222 | return true; |
223 | 223 | } |
224 | 224 | |
225 | 225 | //testing write access |
226 | - if(!$filesystem->write($test_file, "data")) |
|
227 | - throw new Exception(__("Could not write data",'xcloner-backup-and-restore')); |
|
226 | + if (!$filesystem->write($test_file, "data")) |
|
227 | + throw new Exception(__("Could not write data", 'xcloner-backup-and-restore')); |
|
228 | 228 | $this->logger->debug(sprintf("I can write data to remote storage %s", strtoupper($storage_type))); |
229 | 229 | |
230 | 230 | //testing read access |
231 | - if(!$filesystem->has($test_file)) |
|
232 | - throw new Exception(__("Could not read data",'xcloner-backup-and-restore')); |
|
231 | + if (!$filesystem->has($test_file)) |
|
232 | + throw new Exception(__("Could not read data", 'xcloner-backup-and-restore')); |
|
233 | 233 | $this->logger->debug(sprintf("I can read data to remote storage %s", strtoupper($storage_type))); |
234 | 234 | |
235 | 235 | //delete test file |
236 | - if(!$filesystem->delete($test_file)) |
|
237 | - throw new Exception(__("Could not delete data",'xcloner-backup-and-restore')); |
|
236 | + if (!$filesystem->delete($test_file)) |
|
237 | + throw new Exception(__("Could not delete data", 'xcloner-backup-and-restore')); |
|
238 | 238 | $this->logger->debug(sprintf("I can delete data to remote storage %s", strtoupper($storage_type))); |
239 | 239 | |
240 | 240 | return true; |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | |
243 | 243 | public function upload_backup_to_storage($file, $storage) |
244 | 244 | { |
245 | - if(!$this->xcloner_file_system->get_storage_filesystem()->has($file)) |
|
245 | + if (!$this->xcloner_file_system->get_storage_filesystem()->has($file)) |
|
246 | 246 | { |
247 | 247 | $this->logger->info(sprintf("File not found %s in local storage", $file)); |
248 | 248 | return false; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | |
251 | 251 | $method = "get_".$storage."_filesystem"; |
252 | 252 | |
253 | - if(!method_exists($this, $method)) |
|
253 | + if (!method_exists($this, $method)) |
|
254 | 254 | return false; |
255 | 255 | |
256 | 256 | list($remote_storage_adapter, $remote_storage_filesystem) = $this->$method(); |
@@ -268,22 +268,22 @@ discard block |
||
268 | 268 | |
269 | 269 | $backup_file_stream = $this->xcloner_file_system->get_storage_filesystem()->readStream($file); |
270 | 270 | |
271 | - if(!$remote_storage_filesystem->writeStream($file, $backup_file_stream)) |
|
271 | + if (!$remote_storage_filesystem->writeStream($file, $backup_file_stream)) |
|
272 | 272 | { |
273 | 273 | $this->logger->info(sprintf("Could not transfer file %s", $file)); |
274 | 274 | return false; |
275 | 275 | } |
276 | 276 | |
277 | - if($this->xcloner_file_system->is_multipart($file)) |
|
277 | + if ($this->xcloner_file_system->is_multipart($file)) |
|
278 | 278 | { |
279 | 279 | $parts = $this->xcloner_file_system->get_multipart_files($file); |
280 | - if(is_array($parts)) |
|
281 | - foreach($parts as $part_file) |
|
280 | + if (is_array($parts)) |
|
281 | + foreach ($parts as $part_file) |
|
282 | 282 | { |
283 | 283 | $this->logger->info(sprintf("Transferring backup %s to remote storage %s", $part_file, strtoupper($storage)), array("")); |
284 | 284 | |
285 | 285 | $backup_file_stream = $this->xcloner_file_system->get_storage_filesystem()->readStream($part_file); |
286 | - if(!$remote_storage_filesystem->writeStream($part_file, $backup_file_stream)) |
|
286 | + if (!$remote_storage_filesystem->writeStream($part_file, $backup_file_stream)) |
|
287 | 287 | return false; |
288 | 288 | } |
289 | 289 | } |
@@ -300,18 +300,18 @@ discard block |
||
300 | 300 | |
301 | 301 | $target_filename = $file; |
302 | 302 | |
303 | - if(!method_exists($this, $method)) |
|
303 | + if (!method_exists($this, $method)) |
|
304 | 304 | return false; |
305 | 305 | |
306 | 306 | list($remote_storage_adapter, $remote_storage_filesystem) = $this->$method(); |
307 | 307 | |
308 | - if(!$remote_storage_filesystem->has($file)) |
|
308 | + if (!$remote_storage_filesystem->has($file)) |
|
309 | 309 | { |
310 | 310 | $this->logger->info(sprintf("File not found %s in remote storage %s", $file, strtoupper($storage))); |
311 | 311 | return false; |
312 | 312 | } |
313 | 313 | |
314 | - if($storage == "gdrive") |
|
314 | + if ($storage == "gdrive") |
|
315 | 315 | { |
316 | 316 | $metadata = $remote_storage_filesystem->getMetadata($file); |
317 | 317 | $target_filename = $metadata['filename'].".".$metadata['extension']; |
@@ -321,22 +321,22 @@ discard block |
||
321 | 321 | |
322 | 322 | $backup_file_stream = $remote_storage_filesystem->readStream($file); |
323 | 323 | |
324 | - if(!$this->xcloner_file_system->get_storage_filesystem()->writeStream($target_filename, $backup_file_stream)) |
|
324 | + if (!$this->xcloner_file_system->get_storage_filesystem()->writeStream($target_filename, $backup_file_stream)) |
|
325 | 325 | { |
326 | 326 | $this->logger->info(sprintf("Could not transfer file %s", $file)); |
327 | 327 | return false; |
328 | 328 | } |
329 | 329 | |
330 | - if($this->xcloner_file_system->is_multipart($target_filename)) |
|
330 | + if ($this->xcloner_file_system->is_multipart($target_filename)) |
|
331 | 331 | { |
332 | 332 | $parts = $this->xcloner_file_system->get_multipart_files($file, $storage); |
333 | - if(is_array($parts)) |
|
334 | - foreach($parts as $part_file) |
|
333 | + if (is_array($parts)) |
|
334 | + foreach ($parts as $part_file) |
|
335 | 335 | { |
336 | 336 | $this->logger->info(sprintf("Transferring backup %s to local storage from %s storage", $part_file, strtoupper($storage)), array("")); |
337 | 337 | |
338 | 338 | $backup_file_stream = $remote_storage_filesystem->readStream($part_file); |
339 | - if(!$this->xcloner_file_system->get_storage_filesystem()->writeStream($part_file, $backup_file_stream)) |
|
339 | + if (!$this->xcloner_file_system->get_storage_filesystem()->writeStream($part_file, $backup_file_stream)) |
|
340 | 340 | return false; |
341 | 341 | } |
342 | 342 | } |
@@ -350,19 +350,19 @@ discard block |
||
350 | 350 | public function clean_remote_storage($storage, $remote_storage_filesystem) |
351 | 351 | { |
352 | 352 | $check_field = $this->storage_fields["option_prefix"].$storage."_cleanup_days"; |
353 | - if($expire_days = get_option($check_field)) |
|
353 | + if ($expire_days = get_option($check_field)) |
|
354 | 354 | { |
355 | 355 | $this->logger->info(sprintf("Doing %s remote storage cleanup for %s days limit", strtoupper($storage), $expire_days)); |
356 | 356 | $files = $remote_storage_filesystem->listContents(); |
357 | 357 | |
358 | 358 | $current_timestamp = strtotime("-".$expire_days." days"); |
359 | 359 | |
360 | - if(is_array($files)) |
|
361 | - foreach($files as $file) |
|
360 | + if (is_array($files)) |
|
361 | + foreach ($files as $file) |
|
362 | 362 | { |
363 | 363 | $file['timestamp'] = $remote_storage_filesystem->getTimestamp($file['path']); |
364 | 364 | |
365 | - if($current_timestamp >= $file['timestamp']) |
|
365 | + if ($current_timestamp >= $file['timestamp']) |
|
366 | 366 | { |
367 | 367 | $remote_storage_filesystem->delete($file['path']); |
368 | 368 | $this->logger->info("Deleting remote file ".$file['path']." matching rule", array("RETENTION LIMIT TIMESTAMP", $file['timestamp']." =< ".$expire_days)); |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | { |
506 | 506 | |
507 | 507 | //if((function_exists("is_plugin_active") && !is_plugin_active("xcloner-google-drive/xcloner-google-drive.php")) || !file_exists(__DIR__ . "/../../xcloner-google-drive/vendor/autoload.php")) |
508 | - if(!class_exists('Google_Client')) |
|
508 | + if (!class_exists('Google_Client')) |
|
509 | 509 | { |
510 | 510 | return false; |
511 | 511 | } |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | { |
532 | 532 | $client = $this->gdrive_construct(); |
533 | 533 | |
534 | - if(!$client) |
|
534 | + if (!$client) |
|
535 | 535 | return false; |
536 | 536 | |
537 | 537 | return $authUrl = $client->createAuthUrl(); |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | { |
542 | 542 | $client = $this->gdrive_construct(); |
543 | 543 | |
544 | - if(!$client) |
|
544 | + if (!$client) |
|
545 | 545 | { |
546 | 546 | $error_msg = "Could not initialize the Google Drive Class, please check that the xcloner-google-drive plugin is enabled..."; |
547 | 547 | $this->logger->error($error_msg); |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | update_option("xcloner_gdrive_access_token", $token['access_token']); |
555 | 555 | update_option("xcloner_gdrive_refresh_token", $token['refresh_token']); |
556 | 556 | |
557 | - $redirect_url = ('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']."?page=xcloner_remote_storage_page#gdrive"); |
|
557 | + $redirect_url = ('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?page=xcloner_remote_storage_page#gdrive"); |
|
558 | 558 | |
559 | 559 | ?> |
560 | 560 | <script> |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | |
580 | 580 | $client = $this->gdrive_construct(); |
581 | 581 | |
582 | - if(!$client) |
|
582 | + if (!$client) |
|
583 | 583 | { |
584 | 584 | $error_msg = "Could not initialize the Google Drive Class, please check that the xcloner-google-drive plugin is enabled..."; |
585 | 585 | $this->logger->error($error_msg); |
@@ -591,18 +591,18 @@ discard block |
||
591 | 591 | $service = new \Google_Service_Drive($client); |
592 | 592 | |
593 | 593 | $parent = 'root'; |
594 | - $dir = basename( get_option("xcloner_gdrive_target_folder")); |
|
594 | + $dir = basename(get_option("xcloner_gdrive_target_folder")); |
|
595 | 595 | |
596 | 596 | $folderID = get_option("xcloner_gdrive_target_folder"); |
597 | 597 | |
598 | 598 | $tmp = parse_url($folderID); |
599 | 599 | |
600 | - if(isset($tmp['query'])) |
|
600 | + if (isset($tmp['query'])) |
|
601 | 601 | { |
602 | 602 | $folderID = str_replace("id=", "", $tmp['query']); |
603 | 603 | } |
604 | 604 | |
605 | - if(stristr($folderID, "/")) |
|
605 | + if (stristr($folderID, "/")) |
|
606 | 606 | { |
607 | 607 | $query = sprintf('mimeType = \'application/vnd.google-apps.folder\' and \'%s\' in parents and name contains \'%s\'', $parent, $dir); |
608 | 608 | $response = $service->files->listFiles([ |
@@ -610,12 +610,12 @@ discard block |
||
610 | 610 | 'q' => $query |
611 | 611 | ]); |
612 | 612 | |
613 | - if(sizeof($response)) |
|
613 | + if (sizeof($response)) |
|
614 | 614 | { |
615 | 615 | foreach ($response as $obj) { |
616 | - $folderID = $obj->getId(); |
|
616 | + $folderID = $obj->getId(); |
|
617 | 617 | } |
618 | - }else{ |
|
618 | + } else { |
|
619 | 619 | $this->xcloner->trigger_message(sprintf(__("Could not find folder ID by name %s", 'xcloner-backup-and-restore'), $folderID), "error"); |
620 | 620 | } |
621 | 621 | } |
@@ -150,8 +150,9 @@ discard block |
||
150 | 150 | foreach($this->storage_fields as $storage=>$data) |
151 | 151 | { |
152 | 152 | $check_field = $this->storage_fields["option_prefix"].$storage."_enable"; |
153 | - if(get_option($check_field)) |
|
154 | - $return[$storage] = $data['text']; |
|
153 | + if(get_option($check_field)) { |
|
154 | + $return[$storage] = $data['text']; |
|
155 | + } |
|
155 | 156 | } |
156 | 157 | |
157 | 158 | return $return; |
@@ -174,11 +175,13 @@ discard block |
||
174 | 175 | $check_field = $this->storage_fields["option_prefix"].$field; |
175 | 176 | $sanitize_method = "sanitize_input_as_".$validation; |
176 | 177 | |
177 | - if(!isset($_POST[$check_field])) |
|
178 | - $_POST[$check_field] = 0; |
|
178 | + if(!isset($_POST[$check_field])) { |
|
179 | + $_POST[$check_field] = 0; |
|
180 | + } |
|
179 | 181 | |
180 | - if(!method_exists($this->xcloner_sanitization, $sanitize_method)) |
|
181 | - $sanitize_method = "sanitize_input_as_string"; |
|
182 | + if(!method_exists($this->xcloner_sanitization, $sanitize_method)) { |
|
183 | + $sanitize_method = "sanitize_input_as_string"; |
|
184 | + } |
|
182 | 185 | |
183 | 186 | $sanitized_value = $this->xcloner_sanitization->$sanitize_method(stripslashes($_POST[$check_field])); |
184 | 187 | update_option($check_field, $sanitized_value); |
@@ -195,7 +198,7 @@ discard block |
||
195 | 198 | $this->verify_filesystem($action); |
196 | 199 | $this->xcloner->trigger_message(__("%s connection is valid.", 'xcloner-backup-and-restore'), "success", ucfirst($action)); |
197 | 200 | $this->logger->debug(sprintf("Connection to remote storage %s is valid", strtoupper($action))); |
198 | - }catch(Exception $e){ |
|
201 | + } catch(Exception $e){ |
|
199 | 202 | $this->xcloner->trigger_message("%s connection error: ".$e->getMessage(), "error", ucfirst($action)); |
200 | 203 | } |
201 | 204 | } |
@@ -206,8 +209,9 @@ discard block |
||
206 | 209 | |
207 | 210 | $this->logger->info(sprintf("Checking validity of the remote storage %s filesystem", strtoupper($storage_type))); |
208 | 211 | |
209 | - if(!method_exists($this, $method)) |
|
210 | - return false; |
|
212 | + if(!method_exists($this, $method)) { |
|
213 | + return false; |
|
214 | + } |
|
211 | 215 | |
212 | 216 | list($adapter, $filesystem) = $this->$method(); |
213 | 217 | |
@@ -215,26 +219,30 @@ discard block |
||
215 | 219 | |
216 | 220 | if($storage_type == "gdrive") |
217 | 221 | { |
218 | - if(!is_array($filesystem->listContents())) |
|
219 | - throw new Exception(__("Could not read data",'xcloner-backup-and-restore')); |
|
222 | + if(!is_array($filesystem->listContents())) { |
|
223 | + throw new Exception(__("Could not read data",'xcloner-backup-and-restore')); |
|
224 | + } |
|
220 | 225 | $this->logger->debug(sprintf("I can list data from remote storage %s", strtoupper($storage_type))); |
221 | 226 | |
222 | 227 | return true; |
223 | 228 | } |
224 | 229 | |
225 | 230 | //testing write access |
226 | - if(!$filesystem->write($test_file, "data")) |
|
227 | - throw new Exception(__("Could not write data",'xcloner-backup-and-restore')); |
|
231 | + if(!$filesystem->write($test_file, "data")) { |
|
232 | + throw new Exception(__("Could not write data",'xcloner-backup-and-restore')); |
|
233 | + } |
|
228 | 234 | $this->logger->debug(sprintf("I can write data to remote storage %s", strtoupper($storage_type))); |
229 | 235 | |
230 | 236 | //testing read access |
231 | - if(!$filesystem->has($test_file)) |
|
232 | - throw new Exception(__("Could not read data",'xcloner-backup-and-restore')); |
|
237 | + if(!$filesystem->has($test_file)) { |
|
238 | + throw new Exception(__("Could not read data",'xcloner-backup-and-restore')); |
|
239 | + } |
|
233 | 240 | $this->logger->debug(sprintf("I can read data to remote storage %s", strtoupper($storage_type))); |
234 | 241 | |
235 | 242 | //delete test file |
236 | - if(!$filesystem->delete($test_file)) |
|
237 | - throw new Exception(__("Could not delete data",'xcloner-backup-and-restore')); |
|
243 | + if(!$filesystem->delete($test_file)) { |
|
244 | + throw new Exception(__("Could not delete data",'xcloner-backup-and-restore')); |
|
245 | + } |
|
238 | 246 | $this->logger->debug(sprintf("I can delete data to remote storage %s", strtoupper($storage_type))); |
239 | 247 | |
240 | 248 | return true; |
@@ -250,8 +258,9 @@ discard block |
||
250 | 258 | |
251 | 259 | $method = "get_".$storage."_filesystem"; |
252 | 260 | |
253 | - if(!method_exists($this, $method)) |
|
254 | - return false; |
|
261 | + if(!method_exists($this, $method)) { |
|
262 | + return false; |
|
263 | + } |
|
255 | 264 | |
256 | 265 | list($remote_storage_adapter, $remote_storage_filesystem) = $this->$method(); |
257 | 266 | |
@@ -277,14 +286,16 @@ discard block |
||
277 | 286 | if($this->xcloner_file_system->is_multipart($file)) |
278 | 287 | { |
279 | 288 | $parts = $this->xcloner_file_system->get_multipart_files($file); |
280 | - if(is_array($parts)) |
|
281 | - foreach($parts as $part_file) |
|
289 | + if(is_array($parts)) { |
|
290 | + foreach($parts as $part_file) |
|
282 | 291 | { |
283 | 292 | $this->logger->info(sprintf("Transferring backup %s to remote storage %s", $part_file, strtoupper($storage)), array("")); |
293 | + } |
|
284 | 294 | |
285 | 295 | $backup_file_stream = $this->xcloner_file_system->get_storage_filesystem()->readStream($part_file); |
286 | - if(!$remote_storage_filesystem->writeStream($part_file, $backup_file_stream)) |
|
287 | - return false; |
|
296 | + if(!$remote_storage_filesystem->writeStream($part_file, $backup_file_stream)) { |
|
297 | + return false; |
|
298 | + } |
|
288 | 299 | } |
289 | 300 | } |
290 | 301 | |
@@ -300,8 +311,9 @@ discard block |
||
300 | 311 | |
301 | 312 | $target_filename = $file; |
302 | 313 | |
303 | - if(!method_exists($this, $method)) |
|
304 | - return false; |
|
314 | + if(!method_exists($this, $method)) { |
|
315 | + return false; |
|
316 | + } |
|
305 | 317 | |
306 | 318 | list($remote_storage_adapter, $remote_storage_filesystem) = $this->$method(); |
307 | 319 | |
@@ -330,14 +342,16 @@ discard block |
||
330 | 342 | if($this->xcloner_file_system->is_multipart($target_filename)) |
331 | 343 | { |
332 | 344 | $parts = $this->xcloner_file_system->get_multipart_files($file, $storage); |
333 | - if(is_array($parts)) |
|
334 | - foreach($parts as $part_file) |
|
345 | + if(is_array($parts)) { |
|
346 | + foreach($parts as $part_file) |
|
335 | 347 | { |
336 | 348 | $this->logger->info(sprintf("Transferring backup %s to local storage from %s storage", $part_file, strtoupper($storage)), array("")); |
349 | + } |
|
337 | 350 | |
338 | 351 | $backup_file_stream = $remote_storage_filesystem->readStream($part_file); |
339 | - if(!$this->xcloner_file_system->get_storage_filesystem()->writeStream($part_file, $backup_file_stream)) |
|
340 | - return false; |
|
352 | + if(!$this->xcloner_file_system->get_storage_filesystem()->writeStream($part_file, $backup_file_stream)) { |
|
353 | + return false; |
|
354 | + } |
|
341 | 355 | } |
342 | 356 | } |
343 | 357 | |
@@ -357,10 +371,11 @@ discard block |
||
357 | 371 | |
358 | 372 | $current_timestamp = strtotime("-".$expire_days." days"); |
359 | 373 | |
360 | - if(is_array($files)) |
|
361 | - foreach($files as $file) |
|
374 | + if(is_array($files)) { |
|
375 | + foreach($files as $file) |
|
362 | 376 | { |
363 | 377 | $file['timestamp'] = $remote_storage_filesystem->getTimestamp($file['path']); |
378 | + } |
|
364 | 379 | |
365 | 380 | if($current_timestamp >= $file['timestamp']) |
366 | 381 | { |
@@ -531,8 +546,9 @@ discard block |
||
531 | 546 | { |
532 | 547 | $client = $this->gdrive_construct(); |
533 | 548 | |
534 | - if(!$client) |
|
535 | - return false; |
|
549 | + if(!$client) { |
|
550 | + return false; |
|
551 | + } |
|
536 | 552 | |
537 | 553 | return $authUrl = $client->createAuthUrl(); |
538 | 554 | } |
@@ -615,7 +631,7 @@ discard block |
||
615 | 631 | foreach ($response as $obj) { |
616 | 632 | $folderID = $obj->getId(); |
617 | 633 | } |
618 | - }else{ |
|
634 | + } else{ |
|
619 | 635 | $this->xcloner->trigger_message(sprintf(__("Could not find folder ID by name %s", 'xcloner-backup-and-restore'), $folderID), "error"); |
620 | 636 | } |
621 | 637 | } |
@@ -44,8 +44,6 @@ |
||
44 | 44 | * Initialize the class and set its properties. |
45 | 45 | * |
46 | 46 | * @since 1.0.0 |
47 | - * @param string $plugin_name The name of the plugin. |
|
48 | - * @param string $version The version of this plugin. |
|
49 | 47 | */ |
50 | 48 | public function __construct( Xcloner $xcloner_container ) { |
51 | 49 |
@@ -47,10 +47,10 @@ 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( Xcloner $xcloner_container ) { |
|
50 | + public function __construct(Xcloner $xcloner_container) { |
|
51 | 51 | |
52 | - $this->plugin_name = $xcloner_container->get_plugin_name(); |
|
53 | - $this->version = $xcloner_container->get_version(); |
|
52 | + $this->plugin_name = $xcloner_container->get_plugin_name(); |
|
53 | + $this->version = $xcloner_container->get_version(); |
|
54 | 54 | |
55 | 55 | } |
56 | 56 | |
@@ -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 |
@@ -58,19 +58,19 @@ discard block |
||
58 | 58 | |
59 | 59 | public function xcloner_backup_add_admin_menu() |
60 | 60 | { |
61 | - if ( function_exists('add_menu_page') ) |
|
62 | - add_menu_page( __('Site Backup','xcloner-backup-and-restore'), __('Site Backup','xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page', array($this->xcloner_container, 'xcloner_display'), 'dashicons-backup'); |
|
61 | + if (function_exists('add_menu_page')) |
|
62 | + add_menu_page(__('Site Backup', 'xcloner-backup-and-restore'), __('Site Backup', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page', array($this->xcloner_container, 'xcloner_display'), 'dashicons-backup'); |
|
63 | 63 | |
64 | - if ( function_exists('add_submenu_page') ) |
|
64 | + if (function_exists('add_submenu_page')) |
|
65 | 65 | { |
66 | 66 | |
67 | - add_submenu_page( 'xcloner_init_page', __('XCloner Dashboard','xcloner-backup-and-restore'), __('Dashboard','xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page', array($this->xcloner_container, 'xcloner_display')); |
|
68 | - add_submenu_page( 'xcloner_init_page', __('XCloner Backup Settings','xcloner-backup-and-restore'), __('Settings','xcloner-backup-and-restore'), 'manage_options', 'xcloner_settings_page', array($this->xcloner_container, 'xcloner_display')); |
|
69 | - add_submenu_page( 'xcloner_init_page', __('Remote Storage Settings','xcloner-backup-and-restore'), __('Remote Storage','xcloner-backup-and-restore'), 'manage_options', 'xcloner_remote_storage_page', array($this->xcloner_container, 'xcloner_display')); |
|
70 | - add_submenu_page( 'xcloner_init_page', __('Manage Backups','xcloner-backup-and-restore'), __('Manage Backups','xcloner-backup-and-restore'), 'manage_options', 'xcloner_manage_backups_page', array($this->xcloner_container, 'xcloner_display')); |
|
71 | - add_submenu_page( 'xcloner_init_page', __('Scheduled Backups','xcloner-backup-and-restore'), __('Scheduled Backups','xcloner-backup-and-restore'), 'manage_options', 'xcloner_scheduled_backups_page', array($this->xcloner_container, 'xcloner_display')); |
|
72 | - add_submenu_page( 'xcloner_init_page', __('Generate Backups','xcloner-backup-and-restore'), __('Generate Backups','xcloner-backup-and-restore'), 'manage_options', 'xcloner_generate_backups_page', array($this->xcloner_container, 'xcloner_display')); |
|
73 | - add_submenu_page( 'xcloner_init_page', __('Restore Backups','xcloner-backup-and-restore'), __('Restore Backups','xcloner-backup-and-restore'), 'manage_options', 'xcloner_restore_page', array($this->xcloner_container, 'xcloner_display')); |
|
67 | + add_submenu_page('xcloner_init_page', __('XCloner Dashboard', 'xcloner-backup-and-restore'), __('Dashboard', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page', array($this->xcloner_container, 'xcloner_display')); |
|
68 | + add_submenu_page('xcloner_init_page', __('XCloner Backup Settings', 'xcloner-backup-and-restore'), __('Settings', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_settings_page', array($this->xcloner_container, 'xcloner_display')); |
|
69 | + add_submenu_page('xcloner_init_page', __('Remote Storage Settings', 'xcloner-backup-and-restore'), __('Remote Storage', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_remote_storage_page', array($this->xcloner_container, 'xcloner_display')); |
|
70 | + add_submenu_page('xcloner_init_page', __('Manage Backups', 'xcloner-backup-and-restore'), __('Manage Backups', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_manage_backups_page', array($this->xcloner_container, 'xcloner_display')); |
|
71 | + add_submenu_page('xcloner_init_page', __('Scheduled Backups', 'xcloner-backup-and-restore'), __('Scheduled Backups', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_scheduled_backups_page', array($this->xcloner_container, 'xcloner_display')); |
|
72 | + add_submenu_page('xcloner_init_page', __('Generate Backups', 'xcloner-backup-and-restore'), __('Generate Backups', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_generate_backups_page', array($this->xcloner_container, 'xcloner_display')); |
|
73 | + add_submenu_page('xcloner_init_page', __('Restore Backups', 'xcloner-backup-and-restore'), __('Restore Backups', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_restore_page', array($this->xcloner_container, 'xcloner_display')); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | } |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | * @param int $priority Optional. he priority at which the function should be fired. Default is 10. |
87 | 87 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. |
88 | 88 | */ |
89 | - public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
90 | - $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); |
|
89 | + public function add_action($hook, $component, $callback, $priority = 10, $accepted_args = 1) { |
|
90 | + $this->actions = $this->add($this->actions, $hook, $component, $callback, $priority, $accepted_args); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | * @param int $priority Optional. he priority at which the function should be fired. Default is 10. |
101 | 101 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1 |
102 | 102 | */ |
103 | - public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
104 | - $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); |
|
103 | + public function add_filter($hook, $component, $callback, $priority = 10, $accepted_args = 1) { |
|
104 | + $this->filters = $this->add($this->filters, $hook, $component, $callback, $priority, $accepted_args); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @param int $accepted_args The number of arguments that should be passed to the $callback. |
119 | 119 | * @return array The collection of actions and filters registered with WordPress. |
120 | 120 | */ |
121 | - private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { |
|
121 | + private function add($hooks, $hook, $component, $callback, $priority, $accepted_args) { |
|
122 | 122 | |
123 | 123 | $hooks[] = array( |
124 | 124 | 'hook' => $hook, |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function run() { |
141 | 141 | |
142 | - foreach ( $this->filters as $hook ) { |
|
143 | - add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
142 | + foreach ($this->filters as $hook) { |
|
143 | + add_filter($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']); |
|
144 | 144 | } |
145 | 145 | |
146 | - foreach ( $this->actions as $hook ) { |
|
147 | - add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
146 | + foreach ($this->actions as $hook) { |
|
147 | + add_action($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | } |
@@ -58,8 +58,9 @@ |
||
58 | 58 | |
59 | 59 | public function xcloner_backup_add_admin_menu() |
60 | 60 | { |
61 | - if ( function_exists('add_menu_page') ) |
|
62 | - add_menu_page( __('Site Backup','xcloner-backup-and-restore'), __('Site Backup','xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page', array($this->xcloner_container, 'xcloner_display'), 'dashicons-backup'); |
|
61 | + if ( function_exists('add_menu_page') ) { |
|
62 | + add_menu_page( __('Site Backup','xcloner-backup-and-restore'), __('Site Backup','xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page', array($this->xcloner_container, 'xcloner_display'), 'dashicons-backup'); |
|
63 | + } |
|
63 | 64 | |
64 | 65 | if ( function_exists('add_submenu_page') ) |
65 | 66 | { |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$xcloner_file_system = $this->get_xcloner_container()->get_xcloner_filesystem(); |
|
4 | -$xcloner_sanitization = $this->get_xcloner_container()->get_xcloner_sanitization(); |
|
5 | -$xcloner_remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage(); |
|
6 | -$storage_selection = ""; |
|
3 | +$xcloner_file_system = $this->get_xcloner_container()->get_xcloner_filesystem(); |
|
4 | +$xcloner_sanitization = $this->get_xcloner_container()->get_xcloner_sanitization(); |
|
5 | +$xcloner_remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage(); |
|
6 | +$storage_selection = ""; |
|
7 | 7 | |
8 | -if(isset($_GET['storage_selection']) and $_GET['storage_selection']) |
|
8 | +if (isset($_GET['storage_selection']) and $_GET['storage_selection']) |
|
9 | 9 | { |
10 | 10 | $storage_selection = $xcloner_sanitization->sanitize_input_as_string($_GET['storage_selection']); |
11 | 11 | } |
@@ -21,18 +21,18 @@ discard block |
||
21 | 21 | <div class="col s12 m6 l9"> |
22 | 22 | <h1><?= esc_html(get_admin_page_title()); ?></h1> |
23 | 23 | </div> |
24 | - <?php if(sizeof($available_storages)):?> |
|
24 | + <?php if (sizeof($available_storages)):?> |
|
25 | 25 | <div class="col s12 m6 l3 remote-storage-selection"> |
26 | 26 | <select name="storage_selection" id="storage_selection" class="validate" required > |
27 | 27 | |
28 | - <?php if($storage_selection):?> |
|
28 | + <?php if ($storage_selection):?> |
|
29 | 29 | <option value="" selected><?php echo __('Change To Local Storage...', 'xcloner-backup-and-restore') ?></option> |
30 | 30 | <?php else: ?> |
31 | 31 | <option value="" selected><?php echo __('Change To Remote Storage...', 'xcloner-backup-and-restore') ?></option> |
32 | - <?php endif;?> |
|
32 | + <?php endif; ?> |
|
33 | 33 | |
34 | - <?php foreach($available_storages as $storage=>$text):?> |
|
35 | - <option value="<?php echo $storage?>"<?php if($storage == $storage_selection) echo "selected"?>><?php echo $text?></option> |
|
34 | + <?php foreach ($available_storages as $storage=>$text):?> |
|
35 | + <option value="<?php echo $storage?>"<?php if ($storage == $storage_selection) echo "selected"?>><?php echo $text?></option> |
|
36 | 36 | <?php endforeach?> |
37 | 37 | </select> |
38 | 38 | <?php endif?> |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | <label for="select_all"> </label> |
48 | 48 | </p> |
49 | 49 | </th> |
50 | - <th data-field="id"><?php echo __("Backup Name",'xcloner-backup-and-restore')?></th> |
|
51 | - <th data-field="name"><?php echo __("Created Time",'xcloner-backup-and-restore')?></th> |
|
52 | - <th data-field="name"><?php echo __("Size",'xcloner-backup-and-restore')?></th> |
|
53 | - <th class="no-sort" data-field="price"><?php echo __("Action",'xcloner-backup-and-restore')?></th> |
|
50 | + <th data-field="id"><?php echo __("Backup Name", 'xcloner-backup-and-restore')?></th> |
|
51 | + <th data-field="name"><?php echo __("Created Time", 'xcloner-backup-and-restore')?></th> |
|
52 | + <th data-field="name"><?php echo __("Size", 'xcloner-backup-and-restore')?></th> |
|
53 | + <th class="no-sort" data-field="price"><?php echo __("Action", 'xcloner-backup-and-restore')?></th> |
|
54 | 54 | |
55 | 55 | </tr> |
56 | 56 | </thead> |
@@ -60,20 +60,20 @@ discard block |
||
60 | 60 | |
61 | 61 | <?php |
62 | 62 | $i = 0; |
63 | -foreach($backup_list as $file_info):?> |
|
63 | +foreach ($backup_list as $file_info):?> |
|
64 | 64 | <?php |
65 | - if($storage_selection == "gdrive") |
|
65 | + if ($storage_selection == "gdrive") |
|
66 | 66 | $file_info['path'] = $file_info['filename'].".".$file_info['extension']; |
67 | 67 | $file_exists_on_local_storage = true; |
68 | 68 | |
69 | - if($storage_selection) |
|
69 | + if ($storage_selection) |
|
70 | 70 | { |
71 | - if(!$xcloner_file_system->get_storage_filesystem()->has($file_info['path'])) |
|
71 | + if (!$xcloner_file_system->get_storage_filesystem()->has($file_info['path'])) |
|
72 | 72 | $file_exists_on_local_storage = false; |
73 | 73 | } |
74 | 74 | |
75 | 75 | ?> |
76 | -<?php if(!isset($file_info['parent'])):?> |
|
76 | +<?php if (!isset($file_info['parent'])):?> |
|
77 | 77 | |
78 | 78 | <tr> |
79 | 79 | <td class="checkbox"> |
@@ -84,55 +84,55 @@ discard block |
||
84 | 84 | </td> |
85 | 85 | <td> |
86 | 86 | <span class=""><?php echo $file_info['path']?></span> |
87 | - <?php if(!$file_exists_on_local_storage): ?> |
|
88 | - <a href="#" title="<?php echo __("File does not exists on local storage","xcloner-backup-and-restore")?>"><i class="material-icons backup_warning">warning</i></a> |
|
87 | + <?php if (!$file_exists_on_local_storage): ?> |
|
88 | + <a href="#" title="<?php echo __("File does not exists on local storage", "xcloner-backup-and-restore")?>"><i class="material-icons backup_warning">warning</i></a> |
|
89 | 89 | <?php endif?> |
90 | 90 | <?php |
91 | - if(isset($file_info['childs']) and is_array($file_info['childs'])): |
|
91 | + if (isset($file_info['childs']) and is_array($file_info['childs'])): |
|
92 | 92 | ?> |
93 | 93 | <a href="#" title="expand" class="expand-multipart add"><i class="material-icons">add</i></a> |
94 | 94 | <a href="#" title="collapse" class="expand-multipart remove"><i class="material-icons">remove</i></a> |
95 | 95 | <ul class="multipart"> |
96 | - <?php foreach($file_info['childs'] as $child):?> |
|
96 | + <?php foreach ($file_info['childs'] as $child):?> |
|
97 | 97 | <li> |
98 | 98 | <?php echo $child[0]?> (<?php echo size_format($child[2])?>) |
99 | 99 | <?php |
100 | 100 | $child_exists_on_local_storage = true; |
101 | - if($storage_selection) |
|
101 | + if ($storage_selection) |
|
102 | 102 | { |
103 | - if(!$xcloner_file_system->get_storage_filesystem()->has($child[0])) |
|
103 | + if (!$xcloner_file_system->get_storage_filesystem()->has($child[0])) |
|
104 | 104 | $child_exists_on_local_storage = false; |
105 | 105 | } |
106 | 106 | ?> |
107 | - <?php if(!$child_exists_on_local_storage): ?> |
|
108 | - <a href="#" title="<?php echo __("File does not exists on local storage","xcloner-backup-and-restore")?>"><i class="material-icons backup_warning">warning</i></a> |
|
107 | + <?php if (!$child_exists_on_local_storage): ?> |
|
108 | + <a href="#" title="<?php echo __("File does not exists on local storage", "xcloner-backup-and-restore")?>"><i class="material-icons backup_warning">warning</i></a> |
|
109 | 109 | <?php endif?> |
110 | - <?php if(!$storage_selection) :?> |
|
111 | - <a href="#<?php echo $child[0];?>" class="download" title="Download Backup"><i class="material-icons">file_download</i></a> |
|
112 | - <a href="#<?php echo $child[0]?>" class="list-backup-content" title="<?php echo __('List Backup Content','xcloner-backup-and-restore')?>"><i class="material-icons">folder_open</i></a> |
|
113 | - <?php elseif($storage_selection != "gdrive" && !$xcloner_file_system->get_storage_filesystem()->has($child[0])): ?> |
|
114 | - <a href="#<?php echo $child[0]?>" class="copy-remote-to-local" title="<?php echo __('Push Backup To Local Storage','xcloner-backup-and-restore')?>"><i class="material-icons">file_upload</i></a> |
|
110 | + <?php if (!$storage_selection) :?> |
|
111 | + <a href="#<?php echo $child[0]; ?>" class="download" title="Download Backup"><i class="material-icons">file_download</i></a> |
|
112 | + <a href="#<?php echo $child[0]?>" class="list-backup-content" title="<?php echo __('List Backup Content', 'xcloner-backup-and-restore')?>"><i class="material-icons">folder_open</i></a> |
|
113 | + <?php elseif ($storage_selection != "gdrive" && !$xcloner_file_system->get_storage_filesystem()->has($child[0])): ?> |
|
114 | + <a href="#<?php echo $child[0]?>" class="copy-remote-to-local" title="<?php echo __('Push Backup To Local Storage', 'xcloner-backup-and-restore')?>"><i class="material-icons">file_upload</i></a> |
|
115 | 115 | <?php endif?> |
116 | 116 | </li> |
117 | - <?php endforeach;?> |
|
117 | + <?php endforeach; ?> |
|
118 | 118 | </ul> |
119 | - <?php endif;?> |
|
119 | + <?php endif; ?> |
|
120 | 120 | </td> |
121 | - <td><?php if(isset($file_info['timestamp'])) echo date("d M, Y H:i", $file_info['timestamp'])?></td> |
|
121 | + <td><?php if (isset($file_info['timestamp'])) echo date("d M, Y H:i", $file_info['timestamp'])?></td> |
|
122 | 122 | <td><?php echo size_format($file_info['size'])?></td> |
123 | 123 | <td> |
124 | - <?php if(!$storage_selection):?> |
|
125 | - <a href="#<?php echo $file_info['basename'];?>" class="download" title="<?php echo __('Download Backup','xcloner-backup-and-restore')?>"><i class="material-icons">file_download</i></a> |
|
124 | + <?php if (!$storage_selection):?> |
|
125 | + <a href="#<?php echo $file_info['basename']; ?>" class="download" title="<?php echo __('Download Backup', 'xcloner-backup-and-restore')?>"><i class="material-icons">file_download</i></a> |
|
126 | 126 | |
127 | - <?php if(sizeof($available_storages)):?> |
|
128 | - <a href="#<?php echo $file_info['basename']?>" class="cloud-upload" title="<?php echo __('Send Backup To Remote Storage','xcloner-backup-and-restore')?>"><i class="material-icons">cloud_upload</i></a> |
|
127 | + <?php if (sizeof($available_storages)):?> |
|
128 | + <a href="#<?php echo $file_info['basename']?>" class="cloud-upload" title="<?php echo __('Send Backup To Remote Storage', 'xcloner-backup-and-restore')?>"><i class="material-icons">cloud_upload</i></a> |
|
129 | 129 | <?php endif?> |
130 | - <a href="#<?php echo $file_info['basename']?>" class="list-backup-content" title="<?php echo __('List Backup Content','xcloner-backup-and-restore')?>"><i class="material-icons">folder_open</i></a> |
|
131 | - <?php endif;?> |
|
130 | + <a href="#<?php echo $file_info['basename']?>" class="list-backup-content" title="<?php echo __('List Backup Content', 'xcloner-backup-and-restore')?>"><i class="material-icons">folder_open</i></a> |
|
131 | + <?php endif; ?> |
|
132 | 132 | |
133 | - <a href="#<?php echo $file_info['basename']?>" class="delete" title="<?php echo __('Delete Backup','xcloner-backup-and-restore')?>"><i class="material-icons">delete</i></a> |
|
134 | - <?php if($storage_selection and !$file_exists_on_local_storage):?> |
|
135 | - <a href="#<?php echo $file_info['basename'];?>" class="copy-remote-to-local" title="<?php echo __('Push Backup To Local Storage','xcloner-backup-and-restore')?>"><i class="material-icons">file_upload</i></a> |
|
133 | + <a href="#<?php echo $file_info['basename']?>" class="delete" title="<?php echo __('Delete Backup', 'xcloner-backup-and-restore')?>"><i class="material-icons">delete</i></a> |
|
134 | + <?php if ($storage_selection and !$file_exists_on_local_storage):?> |
|
135 | + <a href="#<?php echo $file_info['basename']; ?>" class="copy-remote-to-local" title="<?php echo __('Push Backup To Local Storage', 'xcloner-backup-and-restore')?>"><i class="material-icons">file_upload</i></a> |
|
136 | 136 | <?php endif?> |
137 | 137 | |
138 | 138 | </td> |
@@ -145,12 +145,12 @@ discard block |
||
145 | 145 | </tbody> |
146 | 146 | </table> |
147 | 147 | |
148 | -<a class="waves-effect waves-light btn delete-all"><i class="material-icons left">delete</i><?php echo __("Delete",'xcloner-backup-and-restore')?></a> |
|
148 | +<a class="waves-effect waves-light btn delete-all"><i class="material-icons left">delete</i><?php echo __("Delete", 'xcloner-backup-and-restore')?></a> |
|
149 | 149 | |
150 | 150 | <!-- List Backup Content Modal--> |
151 | 151 | <div id="backup_cotent_modal" class="modal"> |
152 | 152 | <div class="modal-content"> |
153 | - <h4><?php echo sprintf(__("Listing Backup Content ",'xcloner-backup-and-restore'), "")?></h4> |
|
153 | + <h4><?php echo sprintf(__("Listing Backup Content ", 'xcloner-backup-and-restore'), "")?></h4> |
|
154 | 154 | <h5 class="backup-name"></h5> |
155 | 155 | |
156 | 156 | <div class="progress"> |
@@ -163,14 +163,14 @@ discard block |
||
163 | 163 | <!-- Local Transfer Modal--> |
164 | 164 | <div id="local_storage_upload_modal" class="modal"> |
165 | 165 | <div class="modal-content"> |
166 | - <h4><?php echo sprintf(__("Transfer Remote Backup To Local Storage",'xcloner-backup-and-restore'), "")?></h4> |
|
166 | + <h4><?php echo sprintf(__("Transfer Remote Backup To Local Storage", 'xcloner-backup-and-restore'), "")?></h4> |
|
167 | 167 | <h5 class="backup-name"></h5> |
168 | 168 | |
169 | 169 | <div class="row status"> |
170 | 170 | <div class="progress"> |
171 | 171 | <div class="indeterminate"></div> |
172 | 172 | </div> |
173 | - <?php echo __("Uploading backup to the local storage filesystem...",'xcloner-backup-and-restore')?> <span class="status-text"></span> |
|
173 | + <?php echo __("Uploading backup to the local storage filesystem...", 'xcloner-backup-and-restore')?> <span class="status-text"></span> |
|
174 | 174 | </div> |
175 | 175 | </div> |
176 | 176 | </div> |
@@ -180,17 +180,17 @@ discard block |
||
180 | 180 | <form method="POST" class="remote-storage-form"> |
181 | 181 | <input type="hidden" name="file" class="backup_name"> |
182 | 182 | <div class="modal-content"> |
183 | - <h4><?php echo __("Remote Storage Transfer",'xcloner-backup-and-restore')?></h4> |
|
183 | + <h4><?php echo __("Remote Storage Transfer", 'xcloner-backup-and-restore')?></h4> |
|
184 | 184 | <p> |
185 | - <?php if(sizeof($available_storages)):?> |
|
185 | + <?php if (sizeof($available_storages)):?> |
|
186 | 186 | <div class="row"> |
187 | 187 | <div class="col s12 label"> |
188 | - <label><?php echo sprintf(__('Send %s to remote storage','xcloner-backup-and-restore'), "<span class='backup_name'></span>") ?></label> |
|
188 | + <label><?php echo sprintf(__('Send %s to remote storage', 'xcloner-backup-and-restore'), "<span class='backup_name'></span>") ?></label> |
|
189 | 189 | </div> |
190 | 190 | <div class="input-field col s8 m10"> |
191 | 191 | <select name="transfer_storage" id="transfer_storage" class="validate" required > |
192 | 192 | <option value="" selected><?php echo __('please select...', 'xcloner-backup-and-restore') ?></option> |
193 | - <?php foreach($available_storages as $storage=>$text):?> |
|
193 | + <?php foreach ($available_storages as $storage=>$text):?> |
|
194 | 194 | <option value="<?php echo $storage?>"><?php echo $text?></option> |
195 | 195 | <?php endforeach?> |
196 | 196 | </select> |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | </div> |
202 | 202 | </div> |
203 | 203 | <div class="row status"> |
204 | - <?php echo __("Uploading backup to the selected remote storage...",'xcloner-backup-and-restore')?> <span class="status-text"></span> |
|
204 | + <?php echo __("Uploading backup to the selected remote storage...", 'xcloner-backup-and-restore')?> <span class="status-text"></span> |
|
205 | 205 | <div class="progress"> |
206 | 206 | <div class="indeterminate"></div> |
207 | 207 | </div> |
@@ -27,12 +27,16 @@ discard block |
||
27 | 27 | |
28 | 28 | <?php if($storage_selection):?> |
29 | 29 | <option value="" selected><?php echo __('Change To Local Storage...', 'xcloner-backup-and-restore') ?></option> |
30 | - <?php else: ?> |
|
30 | + <?php else { |
|
31 | + : ?> |
|
31 | 32 | <option value="" selected><?php echo __('Change To Remote Storage...', 'xcloner-backup-and-restore') ?></option> |
32 | - <?php endif;?> |
|
33 | + <?php endif; |
|
34 | +} |
|
35 | +?> |
|
33 | 36 | |
34 | 37 | <?php foreach($available_storages as $storage=>$text):?> |
35 | - <option value="<?php echo $storage?>"<?php if($storage == $storage_selection) echo "selected"?>><?php echo $text?></option> |
|
38 | + <option value="<?php echo $storage?>"<?php if($storage == $storage_selection) { |
|
39 | + echo "selected"?>><?php echo $text?></option> |
|
36 | 40 | <?php endforeach?> |
37 | 41 | </select> |
38 | 42 | <?php endif?> |
@@ -60,16 +64,19 @@ discard block |
||
60 | 64 | |
61 | 65 | <?php |
62 | 66 | $i = 0; |
67 | +} |
|
63 | 68 | foreach($backup_list as $file_info):?> |
64 | 69 | <?php |
65 | - if($storage_selection == "gdrive") |
|
66 | - $file_info['path'] = $file_info['filename'].".".$file_info['extension']; |
|
70 | + if($storage_selection == "gdrive") { |
|
71 | + $file_info['path'] = $file_info['filename'].".".$file_info['extension']; |
|
72 | + } |
|
67 | 73 | $file_exists_on_local_storage = true; |
68 | 74 | |
69 | 75 | if($storage_selection) |
70 | 76 | { |
71 | - if(!$xcloner_file_system->get_storage_filesystem()->has($file_info['path'])) |
|
72 | - $file_exists_on_local_storage = false; |
|
77 | + if(!$xcloner_file_system->get_storage_filesystem()->has($file_info['path'])) { |
|
78 | + $file_exists_on_local_storage = false; |
|
79 | + } |
|
73 | 80 | } |
74 | 81 | |
75 | 82 | ?> |
@@ -100,8 +107,9 @@ discard block |
||
100 | 107 | $child_exists_on_local_storage = true; |
101 | 108 | if($storage_selection) |
102 | 109 | { |
103 | - if(!$xcloner_file_system->get_storage_filesystem()->has($child[0])) |
|
104 | - $child_exists_on_local_storage = false; |
|
110 | + if(!$xcloner_file_system->get_storage_filesystem()->has($child[0])) { |
|
111 | + $child_exists_on_local_storage = false; |
|
112 | + } |
|
105 | 113 | } |
106 | 114 | ?> |
107 | 115 | <?php if(!$child_exists_on_local_storage): ?> |
@@ -118,11 +126,14 @@ discard block |
||
118 | 126 | </ul> |
119 | 127 | <?php endif;?> |
120 | 128 | </td> |
121 | - <td><?php if(isset($file_info['timestamp'])) echo date("d M, Y H:i", $file_info['timestamp'])?></td> |
|
129 | + <td><?php if(isset($file_info['timestamp'])) { |
|
130 | + echo date("d M, Y H:i", $file_info['timestamp'])?></td> |
|
122 | 131 | <td><?php echo size_format($file_info['size'])?></td> |
123 | 132 | <td> |
124 | 133 | <?php if(!$storage_selection):?> |
125 | - <a href="#<?php echo $file_info['basename'];?>" class="download" title="<?php echo __('Download Backup','xcloner-backup-and-restore')?>"><i class="material-icons">file_download</i></a> |
|
134 | + <a href="#<?php echo $file_info['basename']; |
|
135 | +} |
|
136 | +?>" class="download" title="<?php echo __('Download Backup','xcloner-backup-and-restore')?>"><i class="material-icons">file_download</i></a> |
|
126 | 137 | |
127 | 138 | <?php if(sizeof($available_storages)):?> |
128 | 139 | <a href="#<?php echo $file_info['basename']?>" class="cloud-upload" title="<?php echo __('Send Backup To Remote Storage','xcloner-backup-and-restore')?>"><i class="material-icons">cloud_upload</i></a> |
@@ -65,13 +65,8 @@ |
||
65 | 65 | |
66 | 66 | use League\Flysystem\Config; |
67 | 67 | use League\Flysystem\Filesystem; |
68 | -use League\Flysystem\Util; |
|
69 | 68 | use League\Flysystem\Adapter\Local; |
70 | - |
|
71 | 69 | use splitbrain\PHPArchive\Tar; |
72 | -use splitbrain\PHPArchive\Archive; |
|
73 | -use splitbrain\PHPArchive\FileInfo; |
|
74 | - |
|
75 | 70 | use Monolog\Logger; |
76 | 71 | use Monolog\Handler\StreamHandler; |
77 | 72 |
@@ -158,15 +158,15 @@ discard block |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | private function friendly_error_type($type) { |
161 | - static $levels=null; |
|
162 | - if ($levels===null) { |
|
163 | - $levels=[]; |
|
164 | - foreach (get_defined_constants() as $key=>$value) { |
|
165 | - if (strpos($key,'E_')!==0) {continue;} |
|
161 | + static $levels=null; |
|
162 | + if ($levels===null) { |
|
163 | + $levels=[]; |
|
164 | + foreach (get_defined_constants() as $key=>$value) { |
|
165 | + if (strpos($key,'E_')!==0) {continue;} |
|
166 | 166 | $levels[$value]= $key; //substr($key,2); |
167 | - } |
|
168 | - } |
|
169 | - return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}"); |
|
167 | + } |
|
168 | + } |
|
169 | + return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}"); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | public function get_logger_filename() |
@@ -887,19 +887,19 @@ discard block |
||
887 | 887 | } |
888 | 888 | |
889 | 889 | private function return_bytes($val) { |
890 | - $val = trim($val); |
|
891 | - $last = strtolower($val[strlen($val)-1]); |
|
892 | - switch($last) { |
|
893 | - // The 'G' modifier is available since PHP 5.1.0 |
|
894 | - case 'g': |
|
895 | - $val *= 1024; |
|
896 | - case 'm': |
|
897 | - $val *= 1024; |
|
898 | - case 'k': |
|
899 | - $val *= 1024; |
|
900 | - } |
|
890 | + $val = trim($val); |
|
891 | + $last = strtolower($val[strlen($val)-1]); |
|
892 | + switch($last) { |
|
893 | + // The 'G' modifier is available since PHP 5.1.0 |
|
894 | + case 'g': |
|
895 | + $val *= 1024; |
|
896 | + case 'm': |
|
897 | + $val *= 1024; |
|
898 | + case 'k': |
|
899 | + $val *= 1024; |
|
900 | + } |
|
901 | 901 | |
902 | - return $val; |
|
902 | + return $val; |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | public function is_multipart($backup_name) |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | { |
948 | 948 | $direction = strtolower($direction); |
949 | 949 | |
950 | - usort($array, create_function('$a, $b', ' |
|
950 | + usort($array, create_function('$a, $b', ' |
|
951 | 951 | $a = $a["' . $field . '"]; |
952 | 952 | $b = $b["' . $field . '"]; |
953 | 953 | |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | return ($a ' . ($direction == 'desc' ? '>' : '<') .' $b) ? -1 : 1; |
960 | 960 | ')); |
961 | 961 | |
962 | - return true; |
|
962 | + return true; |
|
963 | 963 | } |
964 | 964 | |
965 | 965 | public static function send_response($status = 200, $response) |
@@ -999,10 +999,10 @@ discard block |
||
999 | 999 | $m[3] = ""; |
1000 | 1000 | |
1001 | 1001 | $data = 's:'.strlen(($m[3])).':\"'.($m[3]).'\";'; |
1002 | - //return $this->unescape_quotes($data); |
|
1002 | + //return $this->unescape_quotes($data); |
|
1003 | 1003 | |
1004 | - return $data; |
|
1005 | - }, $query); |
|
1004 | + return $data; |
|
1005 | + }, $query); |
|
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | private function unescape_quotes($value) { |
@@ -1019,14 +1019,14 @@ discard block |
||
1019 | 1019 | private function has_serialized($s) |
1020 | 1020 | { |
1021 | 1021 | if( |
1022 | - stristr($s, '{' ) != false && |
|
1023 | - stristr($s, '}' ) != false && |
|
1024 | - stristr($s, ';' ) != false && |
|
1025 | - stristr($s, ':' ) != false |
|
1026 | - ){ |
|
1027 | - return true; |
|
1022 | + stristr($s, '{' ) != false && |
|
1023 | + stristr($s, '}' ) != false && |
|
1024 | + stristr($s, ';' ) != false && |
|
1025 | + stristr($s, ':' ) != false |
|
1026 | + ){ |
|
1027 | + return true; |
|
1028 | 1028 | }else{ |
1029 | - return false; |
|
1029 | + return false; |
|
1030 | 1030 | } |
1031 | 1031 | |
1032 | 1032 | } |
@@ -45,11 +45,10 @@ discard block |
||
45 | 45 | { |
46 | 46 | |
47 | 47 | require_once($file); |
48 | -} |
|
49 | -elseif(file_exists("vendor.phar") and extension_loaded('phar')) |
|
48 | +} elseif(file_exists("vendor.phar") and extension_loaded('phar')) |
|
50 | 49 | { |
51 | 50 | require_once(__DIR__.DS."vendor.phar"); |
52 | -}else{ |
|
51 | +} else{ |
|
53 | 52 | |
54 | 53 | $file = dirname( __FILE__ ) . DS.'vendor'.DS.'autoload.php'; |
55 | 54 | |
@@ -87,7 +86,7 @@ discard block |
||
87 | 86 | try{ |
88 | 87 | $return = $xcloner_restore->init(); |
89 | 88 | $xcloner_restore->send_response(200, $return); |
90 | -}catch(Exception $e){ |
|
89 | +} catch(Exception $e){ |
|
91 | 90 | $xcloner_restore->send_response(417, $e->getMessage()); |
92 | 91 | } |
93 | 92 | |
@@ -191,7 +190,7 @@ discard block |
||
191 | 190 | $this->logger->debug(sprintf('Starting action %s', $method)); |
192 | 191 | return call_user_func(array($this, $method)); |
193 | 192 | |
194 | - }else{ |
|
193 | + } else{ |
|
195 | 194 | throw new Exception($method ." does not exists"); |
196 | 195 | } |
197 | 196 | } |
@@ -205,13 +204,15 @@ discard block |
||
205 | 204 | { |
206 | 205 | $target_file = filter_input(INPUT_POST, 'file', FILTER_SANITIZE_STRING); |
207 | 206 | |
208 | - if(!$_POST['start']) |
|
209 | - $fp = fopen($target_file, "wb+"); |
|
210 | - else |
|
211 | - $fp = fopen($target_file, "ab+"); |
|
207 | + if(!$_POST['start']) { |
|
208 | + $fp = fopen($target_file, "wb+"); |
|
209 | + } else { |
|
210 | + $fp = fopen($target_file, "ab+"); |
|
211 | + } |
|
212 | 212 | |
213 | - if(!$fp) |
|
214 | - throw new Exception("Unable to open $target_file file for writing"); |
|
213 | + if(!$fp) { |
|
214 | + throw new Exception("Unable to open $target_file file for writing"); |
|
215 | + } |
|
215 | 216 | |
216 | 217 | fseek($fp, $_POST['start']); |
217 | 218 | |
@@ -221,18 +222,20 @@ discard block |
||
221 | 222 | |
222 | 223 | $blob = file_get_contents($_FILES['blob']['tmp_name']); |
223 | 224 | |
224 | - if(!$bytes_written = fwrite($fp, $blob)) |
|
225 | - throw new Exception("Unable to write data to file $target_file"); |
|
225 | + if(!$bytes_written = fwrite($fp, $blob)) { |
|
226 | + throw new Exception("Unable to write data to file $target_file"); |
|
227 | + } |
|
226 | 228 | |
227 | 229 | @unlink($_FILES['blob']['tmp_name']); |
228 | - }elseif(isset($_POST['blob'])){ |
|
230 | + } elseif(isset($_POST['blob'])){ |
|
229 | 231 | $this->logger->debug(sprintf('Writing %s bytes to file %s starting position %s using POST blob', strlen($_POST['blob']), $target_file, $_POST['start'])); |
230 | 232 | |
231 | 233 | $blob = $_POST['blob']; |
232 | 234 | |
233 | - if(!$bytes_written = fwrite($fp, $blob)) |
|
234 | - throw new Exception("Unable to write data to file $target_file"); |
|
235 | - }else{ |
|
235 | + if(!$bytes_written = fwrite($fp, $blob)) { |
|
236 | + throw new Exception("Unable to write data to file $target_file"); |
|
237 | + } |
|
238 | + } else{ |
|
236 | 239 | throw new Exception("Upload failed, did not receive any binary data"); |
237 | 240 | } |
238 | 241 | |
@@ -256,10 +259,11 @@ discard block |
||
256 | 259 | |
257 | 260 | $mysqli->query("SET sql_mode='';"); |
258 | 261 | $mysqli->query("SET foreign_key_checks = 0;"); |
259 | - if(isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file']) |
|
260 | - $mysqli->query("SET NAMES ".$_REQUEST['charset_of_file'].""); |
|
261 | - else |
|
262 | - $mysqli->query("SET NAMES utf8;"); |
|
262 | + if(isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file']) { |
|
263 | + $mysqli->query("SET NAMES ".$_REQUEST['charset_of_file'].""); |
|
264 | + } else { |
|
265 | + $mysqli->query("SET NAMES utf8;"); |
|
266 | + } |
|
263 | 267 | |
264 | 268 | return $mysqli; |
265 | 269 | } |
@@ -284,8 +288,9 @@ discard block |
||
284 | 288 | |
285 | 289 | $mysql_backup_file = $remote_path.DS.$mysqldump_file; |
286 | 290 | |
287 | - if(!file_exists($mysql_backup_file)) |
|
288 | - throw new Exception(sprintf("Mysql backup file %s does not exists",$mysql_backup_file)); |
|
291 | + if(!file_exists($mysql_backup_file)) { |
|
292 | + throw new Exception(sprintf("Mysql backup file %s does not exists",$mysql_backup_file)); |
|
293 | + } |
|
289 | 294 | |
290 | 295 | |
291 | 296 | /*if(defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS) |
@@ -317,16 +322,18 @@ discard block |
||
317 | 322 | // process the line read. |
318 | 323 | |
319 | 324 | //check if line is comment |
320 | - if(substr($line, 0, 1) == "#") |
|
321 | - continue; |
|
325 | + if(substr($line, 0, 1) == "#") { |
|
326 | + continue; |
|
327 | + } |
|
322 | 328 | |
323 | 329 | //check if line is empty |
324 | - if($line == "\n" or trim($line) == "") |
|
325 | - continue; |
|
330 | + if($line == "\n" or trim($line) == "") { |
|
331 | + continue; |
|
332 | + } |
|
326 | 333 | |
327 | - if(substr($line, strlen($line)-2, strlen($line)) == ";\n") |
|
328 | - $query .= $line; |
|
329 | - else{ |
|
334 | + if(substr($line, strlen($line)-2, strlen($line)) == ";\n") { |
|
335 | + $query .= $line; |
|
336 | + } else{ |
|
330 | 337 | $query .= $line; |
331 | 338 | continue; |
332 | 339 | } |
@@ -385,7 +392,7 @@ discard block |
||
385 | 392 | if(!feof($fp)) |
386 | 393 | { |
387 | 394 | $return['finished'] = 0; |
388 | - }else{ |
|
395 | + } else{ |
|
389 | 396 | $this->logger->info(sprintf("Mysql Import Done.")); |
390 | 397 | } |
391 | 398 | |
@@ -437,7 +444,7 @@ discard block |
||
437 | 444 | $tar->open($this->backup_storage_dir.DS.$backup_file, $start); |
438 | 445 | |
439 | 446 | $data = $tar->contents($this->process_files_limit_list); |
440 | - }catch(Exception $e) |
|
447 | + } catch(Exception $e) |
|
441 | 448 | { |
442 | 449 | $return['error'] = true; |
443 | 450 | $return['message'] = $e->getMessage(); |
@@ -465,15 +472,16 @@ discard block |
||
465 | 472 | { |
466 | 473 | $return['start'] = $data['start']; |
467 | 474 | $return['finished'] = 0; |
468 | - }else{ |
|
475 | + } else{ |
|
469 | 476 | if($this->is_multipart($source_backup_file)) |
470 | 477 | { |
471 | 478 | $return['start'] = 0; |
472 | 479 | |
473 | 480 | ++$return['part']; |
474 | 481 | |
475 | - if($return['part'] < sizeof($backup_parts)) |
|
476 | - $return['finished'] = 0; |
|
482 | + if($return['part'] < sizeof($backup_parts)) { |
|
483 | + $return['finished'] = 0; |
|
484 | + } |
|
477 | 485 | |
478 | 486 | } |
479 | 487 | } |
@@ -590,19 +598,22 @@ discard block |
||
590 | 598 | { |
591 | 599 | $config = file_get_contents($wp_config); |
592 | 600 | preg_match("/.*table_prefix.*=.*'(.*)'/i", $config, $matches); |
593 | - if(isset($matches[1])) |
|
594 | - $table_prefix = $matches[1]; |
|
595 | - else |
|
596 | - throw new Exception("Could not load wordpress table prefix from wp-config.php file."); |
|
601 | + if(isset($matches[1])) { |
|
602 | + $table_prefix = $matches[1]; |
|
603 | + } else { |
|
604 | + throw new Exception("Could not load wordpress table prefix from wp-config.php file."); |
|
605 | + } |
|
606 | + } else { |
|
607 | + throw new Exception("Could not update the SITEURL and HOME, wp-config.php file not found"); |
|
597 | 608 | } |
598 | - else |
|
599 | - throw new Exception("Could not update the SITEURL and HOME, wp-config.php file not found"); |
|
600 | 609 | |
601 | - if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='home'")) |
|
602 | - throw new Exception(sprintf("Could not update the HOME option, error: %s\n", $mysqli->error)); |
|
610 | + if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='home'")) { |
|
611 | + throw new Exception(sprintf("Could not update the HOME option, error: %s\n", $mysqli->error)); |
|
612 | + } |
|
603 | 613 | |
604 | - if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='siteurl'")) |
|
605 | - throw new Exception(sprintf("Could not update the SITEURL option, error: %s\n", $mysqli->error)); |
|
614 | + if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='siteurl'")) { |
|
615 | + throw new Exception(sprintf("Could not update the SITEURL option, error: %s\n", $mysqli->error)); |
|
616 | + } |
|
606 | 617 | |
607 | 618 | return true; |
608 | 619 | } |
@@ -629,8 +640,9 @@ discard block |
||
629 | 640 | |
630 | 641 | $this->logger->info(sprintf('Updating wp-config.php file with the new mysql details')); |
631 | 642 | |
632 | - if(!file_put_contents($wp_config, $content)) |
|
633 | - throw new Exception("Could not write updated config data to ".$wp_config); |
|
643 | + if(!file_put_contents($wp_config, $content)) { |
|
644 | + throw new Exception("Could not write updated config data to ".$wp_config); |
|
645 | + } |
|
634 | 646 | |
635 | 647 | chmod($wp_config, $file_perms); |
636 | 648 | |
@@ -671,10 +683,11 @@ discard block |
||
671 | 683 | $mysqldump_list[$file['path']]['size'] = $file['size']; |
672 | 684 | $mysqldump_list[$file['path']]['timestamp'] = date("d M,Y H:i",$file['timestamp']); |
673 | 685 | |
674 | - if($hash and $hash == $matches[1]) |
|
675 | - $mysqldump_list[$file['path']]['selected'] = "selected"; |
|
676 | - else |
|
677 | - $mysqldump_list[$file['path']]['selected'] = ""; |
|
686 | + if($hash and $hash == $matches[1]) { |
|
687 | + $mysqldump_list[$file['path']]['selected'] = "selected"; |
|
688 | + } else { |
|
689 | + $mysqldump_list[$file['path']]['selected'] = ""; |
|
690 | + } |
|
678 | 691 | } |
679 | 692 | } |
680 | 693 | } |
@@ -689,13 +702,15 @@ discard block |
||
689 | 702 | |
690 | 703 | private function get_hash_from_backup($backup_file) |
691 | 704 | { |
692 | - if(!$backup_file) |
|
693 | - return false; |
|
705 | + if(!$backup_file) { |
|
706 | + return false; |
|
707 | + } |
|
694 | 708 | |
695 | 709 | $result = preg_match("/-(\w*)./", substr($backup_file, strlen($backup_file)-10, strlen($backup_file)), $matches) ; |
696 | 710 | |
697 | - if($result and isset($matches[1])) |
|
698 | - return ($matches[1]); |
|
711 | + if($result and isset($matches[1])) { |
|
712 | + return ($matches[1]); |
|
713 | + } |
|
699 | 714 | |
700 | 715 | return false; |
701 | 716 | } |
@@ -715,10 +730,11 @@ discard block |
||
715 | 730 | if(isset($file_info['extension']) and $file_info['extension'] == "csv") |
716 | 731 | { |
717 | 732 | $lines = explode(PHP_EOL, $this->filesystem->read($file_info['path'])); |
718 | - foreach($lines as $line) |
|
719 | - if($line) |
|
733 | + foreach($lines as $line) { |
|
734 | + if($line) |
|
720 | 735 | { |
721 | 736 | $data = str_getcsv($line); |
737 | + } |
|
722 | 738 | if(is_array($data)){ |
723 | 739 | $parents[$data[0]] = $file_info['path']; |
724 | 740 | $file_info['childs'][] = $data; |
@@ -728,20 +744,22 @@ discard block |
||
728 | 744 | |
729 | 745 | } |
730 | 746 | |
731 | - if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) |
|
732 | - $backup_files[$file_info['path']] = $file_info; |
|
747 | + if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) { |
|
748 | + $backup_files[$file_info['path']] = $file_info; |
|
749 | + } |
|
733 | 750 | } |
734 | 751 | |
735 | 752 | $new_list = array(); |
736 | 753 | |
737 | 754 | foreach($backup_files as $key=>$file_info) |
738 | 755 | { |
739 | - if(isset($parents[$file_info['path']])) |
|
740 | - $backup_files[$key]['parent'] = $parents[$file_info['path']]; |
|
741 | - else{ |
|
756 | + if(isset($parents[$file_info['path']])) { |
|
757 | + $backup_files[$key]['parent'] = $parents[$file_info['path']]; |
|
758 | + } else{ |
|
742 | 759 | |
743 | - if($local_backup_file and ($file_info['basename'] == $local_backup_file)) |
|
744 | - $file_info['selected'] = 'selected'; |
|
760 | + if($local_backup_file and ($file_info['basename'] == $local_backup_file)) { |
|
761 | + $file_info['selected'] = 'selected'; |
|
762 | + } |
|
745 | 763 | |
746 | 764 | $this->logger->info(sprintf('Found %s backup file', $file_info['path'])); |
747 | 765 | |
@@ -782,8 +800,9 @@ discard block |
||
782 | 800 | $backup_archive = new Tar(); |
783 | 801 | if($this->is_multipart($backup_file)) |
784 | 802 | { |
785 | - if(!$return['part']) |
|
786 | - $return['processed'] += $this->filesystem->getSize($backup_file); |
|
803 | + if(!$return['part']) { |
|
804 | + $return['processed'] += $this->filesystem->getSize($backup_file); |
|
805 | + } |
|
787 | 806 | |
788 | 807 | $backup_parts = $this->get_multipart_files($backup_file); |
789 | 808 | $backup_file = $backup_parts[$return['part']]; |
@@ -803,12 +822,13 @@ discard block |
||
803 | 822 | } |
804 | 823 | } |
805 | 824 | |
806 | - if(isset($data['start'])) |
|
807 | - //if(isset($data['start']) and $data['start'] <= $this->filesystem->getSize($backup_file)) |
|
825 | + if(isset($data['start'])) { |
|
826 | + //if(isset($data['start']) and $data['start'] <= $this->filesystem->getSize($backup_file)) |
|
808 | 827 | { |
809 | 828 | $return['finished'] = 0; |
829 | + } |
|
810 | 830 | $return['start'] = $data['start']; |
811 | - }else{ |
|
831 | + } else{ |
|
812 | 832 | |
813 | 833 | $return['processed'] += $start; |
814 | 834 | |
@@ -818,14 +838,16 @@ discard block |
||
818 | 838 | |
819 | 839 | ++$return['part']; |
820 | 840 | |
821 | - if($return['part'] < sizeof($backup_parts)) |
|
822 | - $return['finished'] = 0; |
|
841 | + if($return['part'] < sizeof($backup_parts)) { |
|
842 | + $return['finished'] = 0; |
|
843 | + } |
|
823 | 844 | |
824 | 845 | } |
825 | 846 | } |
826 | 847 | |
827 | - if($return['finished']) |
|
828 | - $this->logger->info(sprintf('Done extracting %s', $source_backup_file)); |
|
848 | + if($return['finished']) { |
|
849 | + $this->logger->info(sprintf('Done extracting %s', $source_backup_file)); |
|
850 | + } |
|
829 | 851 | |
830 | 852 | $return['backup_file'] = $backup_file; |
831 | 853 | |
@@ -854,8 +876,7 @@ discard block |
||
854 | 876 | $return['remote_mysql_user'] = $wpdb->dbuser; |
855 | 877 | $return['remote_mysql_pass'] = $wpdb->dbpassword; |
856 | 878 | $return['remote_mysql_db'] = $wpdb->dbname; |
857 | - } |
|
858 | - else{ |
|
879 | + } else{ |
|
859 | 880 | $return['dir'] = ($pathinfo['dirname']).DS.$suffix; |
860 | 881 | $return['restore_script_url'] = str_replace($pathinfo['basename'], "", $restore_script_url).$suffix; |
861 | 882 | } |
@@ -869,11 +890,13 @@ discard block |
||
869 | 890 | { |
870 | 891 | //check if i can write |
871 | 892 | $tmp_file = md5(time()); |
872 | - if(!file_put_contents($tmp_file, "++")) |
|
873 | - throw new Exception("Could not write to new host"); |
|
893 | + if(!file_put_contents($tmp_file, "++")) { |
|
894 | + throw new Exception("Could not write to new host"); |
|
895 | + } |
|
874 | 896 | |
875 | - if(!unlink($tmp_file)) |
|
876 | - throw new Exception("Could not delete temporary file from new host"); |
|
897 | + if(!unlink($tmp_file)) { |
|
898 | + throw new Exception("Could not delete temporary file from new host"); |
|
899 | + } |
|
877 | 900 | |
878 | 901 | $max_upload = $this->return_bytes((ini_get('upload_max_filesize'))); |
879 | 902 | $max_post = $this->return_bytes((ini_get('post_max_size'))); |
@@ -904,8 +927,9 @@ discard block |
||
904 | 927 | |
905 | 928 | public function is_multipart($backup_name) |
906 | 929 | { |
907 | - if(stristr($backup_name, "-multipart")) |
|
908 | - return true; |
|
930 | + if(stristr($backup_name, "-multipart")) { |
|
931 | + return true; |
|
932 | + } |
|
909 | 933 | |
910 | 934 | return false; |
911 | 935 | } |
@@ -916,8 +940,9 @@ discard block |
||
916 | 940 | if($this->is_multipart($backup_name)) |
917 | 941 | { |
918 | 942 | $backup_parts = $this->get_multipart_files($backup_name); |
919 | - foreach($backup_parts as $part_file) |
|
920 | - $backup_size += $this->filesystem->getSize($part_file); |
|
943 | + foreach($backup_parts as $part_file) { |
|
944 | + $backup_size += $this->filesystem->getSize($part_file); |
|
945 | + } |
|
921 | 946 | } |
922 | 947 | |
923 | 948 | return $backup_size; |
@@ -974,7 +999,7 @@ discard block |
||
974 | 999 | { |
975 | 1000 | $return['statusText'] = $response['message']; |
976 | 1001 | $return['error'] = true; |
977 | - }elseif($status != 200 and $status != 418) |
|
1002 | + } elseif($status != 200 and $status != 418) |
|
978 | 1003 | { |
979 | 1004 | $return['error'] = true; |
980 | 1005 | $return['message'] = $response; |
@@ -995,8 +1020,9 @@ discard block |
||
995 | 1020 | return preg_replace_callback('!s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!', function ($m) { |
996 | 1021 | $data = ""; |
997 | 1022 | |
998 | - if(!isset($m[3])) |
|
999 | - $m[3] = ""; |
|
1023 | + if(!isset($m[3])) { |
|
1024 | + $m[3] = ""; |
|
1025 | + } |
|
1000 | 1026 | |
1001 | 1027 | $data = 's:'.strlen(($m[3])).':\"'.($m[3]).'\";'; |
1002 | 1028 | //return $this->unescape_quotes($data); |
@@ -1025,7 +1051,7 @@ discard block |
||
1025 | 1051 | stristr($s, ':' ) != false |
1026 | 1052 | ){ |
1027 | 1053 | return true; |
1028 | - }else{ |
|
1054 | + } else{ |
|
1029 | 1055 | return false; |
1030 | 1056 | } |
1031 | 1057 |
@@ -580,6 +580,9 @@ discard block |
||
580 | 580 | |
581 | 581 | } |
582 | 582 | |
583 | + /** |
|
584 | + * @param mysqli $mysqli |
|
585 | + */ |
|
583 | 586 | private function update_wp_url($wp_path, $url, $mysqli) |
584 | 587 | { |
585 | 588 | $wp_config = $wp_path.DS."wp-config.php"; |
@@ -886,6 +889,9 @@ discard block |
||
886 | 889 | $this->send_response(200, $return); |
887 | 890 | } |
888 | 891 | |
892 | + /** |
|
893 | + * @param string $val |
|
894 | + */ |
|
889 | 895 | private function return_bytes($val) { |
890 | 896 | $val = trim($val); |
891 | 897 | $last = strtolower($val[strlen($val)-1]); |
@@ -943,6 +949,9 @@ discard block |
||
943 | 949 | return $files; |
944 | 950 | } |
945 | 951 | |
952 | + /** |
|
953 | + * @param string $field |
|
954 | + */ |
|
946 | 955 | private function sort_by( &$array, $field, $direction = 'asc') |
947 | 956 | { |
948 | 957 | $direction = strtolower($direction); |
@@ -988,6 +997,9 @@ discard block |
||
988 | 997 | * Serialize fix methods below for mysql query lines |
989 | 998 | */ |
990 | 999 | |
1000 | + /** |
|
1001 | + * @return string |
|
1002 | + */ |
|
991 | 1003 | function do_serialized_fix($query) |
992 | 1004 | { |
993 | 1005 | $query = str_replace(array("\\n","\\r","\\'"), array("","","\""), ($query)); |
@@ -1,30 +1,30 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('AUTH_KEY')) |
|
3 | +if (!defined('AUTH_KEY')) |
|
4 | 4 | { |
5 | 5 | define('AUTH_KEY', ''); |
6 | 6 | } |
7 | 7 | |
8 | -if(!defined("DS")) |
|
8 | +if (!defined("DS")) |
|
9 | 9 | { |
10 | 10 | define("DS", DIRECTORY_SEPARATOR); |
11 | 11 | } |
12 | 12 | |
13 | -if(!defined('XCLONER_PLUGIN_ACCESS') || XCLONER_PLUGIN_ACCESS != 1) |
|
13 | +if (!defined('XCLONER_PLUGIN_ACCESS') || XCLONER_PLUGIN_ACCESS != 1) |
|
14 | 14 | { |
15 | - if(!AUTH_KEY) |
|
15 | + if (!AUTH_KEY) |
|
16 | 16 | { |
17 | 17 | Xcloner_Restore::send_response("404", "Could not run restore script, AUTH_KEY not set!"); |
18 | 18 | exit; |
19 | 19 | } |
20 | 20 | |
21 | - if(!isset($_REQUEST['hash'])) |
|
21 | + if (!isset($_REQUEST['hash'])) |
|
22 | 22 | { |
23 | 23 | Xcloner_Restore::send_response("404", "Could not run restore script, sent HASH is empty!"); |
24 | 24 | exit; |
25 | 25 | } |
26 | 26 | |
27 | - if($_REQUEST['hash'] != AUTH_KEY) |
|
27 | + if ($_REQUEST['hash'] != AUTH_KEY) |
|
28 | 28 | { |
29 | 29 | Xcloner_Restore::send_response("404", "Could not run restore script, AUTH_KEY doesn't match the sent HASH!"); |
30 | 30 | exit; |
@@ -32,28 +32,28 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | //check minimum PHP version |
35 | -if(version_compare(phpversion(), Xcloner_Restore::xcloner_minimum_version, '<')) |
|
35 | +if (version_compare(phpversion(), Xcloner_Restore::xcloner_minimum_version, '<')) |
|
36 | 36 | { |
37 | - Xcloner_Restore::send_response(500, sprintf(("XCloner requires minimum PHP version %s in order to run correctly. We have detected your version as %s"),Xcloner_Restore::xcloner_minimum_version, phpversion()) ); |
|
37 | + Xcloner_Restore::send_response(500, sprintf(("XCloner requires minimum PHP version %s in order to run correctly. We have detected your version as %s"), Xcloner_Restore::xcloner_minimum_version, phpversion())); |
|
38 | 38 | exit; |
39 | 39 | |
40 | 40 | } |
41 | 41 | |
42 | -$file = dirname( __DIR__ ) . DS.'vendor'.DS.'autoload.php'; |
|
42 | +$file = dirname(__DIR__).DS.'vendor'.DS.'autoload.php'; |
|
43 | 43 | |
44 | -if(file_exists($file)) |
|
44 | +if (file_exists($file)) |
|
45 | 45 | { |
46 | 46 | |
47 | 47 | require_once($file); |
48 | 48 | } |
49 | -elseif(file_exists("vendor.phar") and extension_loaded('phar')) |
|
49 | +elseif (file_exists("vendor.phar") and extension_loaded('phar')) |
|
50 | 50 | { |
51 | 51 | require_once(__DIR__.DS."vendor.phar"); |
52 | -}else{ |
|
52 | +} else { |
|
53 | 53 | |
54 | - $file = dirname( __FILE__ ) . DS.'vendor'.DS.'autoload.php'; |
|
54 | + $file = dirname(__FILE__).DS.'vendor'.DS.'autoload.php'; |
|
55 | 55 | |
56 | - if(!file_exists($file)) |
|
56 | + if (!file_exists($file)) |
|
57 | 57 | { |
58 | 58 | Xcloner_Restore::send_response("404", "File $file does not exists, please extract the vendor.tgz archive on the server or enable PHP Phar module!"); |
59 | 59 | exit; |
@@ -78,16 +78,16 @@ discard block |
||
78 | 78 | |
79 | 79 | //do not modify below |
80 | 80 | $that = ""; |
81 | -if(defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS) |
|
81 | +if (defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS) |
|
82 | 82 | { |
83 | 83 | $that = $this; |
84 | 84 | } |
85 | 85 | $xcloner_restore = new Xcloner_Restore($that); |
86 | 86 | |
87 | -try{ |
|
87 | +try { |
|
88 | 88 | $return = $xcloner_restore->init(); |
89 | 89 | $xcloner_restore->send_response(200, $return); |
90 | -}catch(Exception $e){ |
|
90 | +}catch (Exception $e) { |
|
91 | 91 | $xcloner_restore->send_response(417, $e->getMessage()); |
92 | 92 | } |
93 | 93 | |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | |
97 | 97 | const xcloner_minimum_version = "5.4.0"; |
98 | 98 | |
99 | - private $backup_archive_extensions = array("zip", "tar", "tgz", "tar.gz", "gz", "csv"); |
|
100 | - private $process_files_limit = 150; |
|
101 | - private $process_files_limit_list = 350; |
|
102 | - private $process_mysql_records_limit = 250; |
|
99 | + private $backup_archive_extensions = array("zip", "tar", "tgz", "tar.gz", "gz", "csv"); |
|
100 | + private $process_files_limit = 150; |
|
101 | + private $process_files_limit_list = 350; |
|
102 | + private $process_mysql_records_limit = 250; |
|
103 | 103 | private $adapter; |
104 | 104 | private $filesystem; |
105 | 105 | private $logger; |
@@ -111,12 +111,12 @@ discard block |
||
111 | 111 | { |
112 | 112 | register_shutdown_function(array($this, 'exception_handler')); |
113 | 113 | |
114 | - if(defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS) |
|
114 | + if (defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS) |
|
115 | 115 | { |
116 | 116 | $dir = $parent_api->get_xcloner_container()->get_xcloner_settings()->get_xcloner_store_path(); |
117 | 117 | } |
118 | 118 | |
119 | - if(!isset($dir) || !$dir){ |
|
119 | + if (!isset($dir) || !$dir) { |
|
120 | 120 | $dir = dirname(__FILE__); |
121 | 121 | } |
122 | 122 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $this->backup_storage_dir = $dir; |
126 | 126 | |
127 | - $this->adapter = new Local($dir ,LOCK_EX, 'SKIP_LINKS'); |
|
127 | + $this->adapter = new Local($dir, LOCK_EX, 'SKIP_LINKS'); |
|
128 | 128 | $this->filesystem = new Filesystem($this->adapter, new Config([ |
129 | 129 | 'disable_asserts' => true, |
130 | 130 | ])); |
@@ -133,15 +133,15 @@ discard block |
||
133 | 133 | |
134 | 134 | $logger_path = $this->get_logger_filename(); |
135 | 135 | |
136 | - if(!is_writeable($logger_path) and !touch($logger_path)) |
|
136 | + if (!is_writeable($logger_path) and !touch($logger_path)) |
|
137 | 137 | { |
138 | 138 | $logger_path = "php://stderr"; |
139 | 139 | } |
140 | 140 | |
141 | 141 | $this->logger->pushHandler(new StreamHandler($logger_path, Logger::DEBUG)); |
142 | 142 | |
143 | - if(isset($_POST['API_ID'])){ |
|
144 | - $this->logger->info("Processing ajax request ID ".substr(filter_input(INPUT_POST, 'API_ID', FILTER_SANITIZE_STRING), 0 , 15)); |
|
143 | + if (isset($_POST['API_ID'])) { |
|
144 | + $this->logger->info("Processing ajax request ID ".substr(filter_input(INPUT_POST, 'API_ID', FILTER_SANITIZE_STRING), 0, 15)); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | } |
@@ -150,20 +150,20 @@ discard block |
||
150 | 150 | |
151 | 151 | $error = error_get_last(); |
152 | 152 | |
153 | - if($error['type'] and $this->logger) |
|
153 | + if ($error['type'] and $this->logger) |
|
154 | 154 | { |
155 | - $this->logger->info($this->friendly_error_type ($error['type']).": ".var_export($error, true)); |
|
155 | + $this->logger->info($this->friendly_error_type($error['type']).": ".var_export($error, true)); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | } |
159 | 159 | |
160 | 160 | private function friendly_error_type($type) { |
161 | - static $levels=null; |
|
162 | - if ($levels===null) { |
|
163 | - $levels=[]; |
|
161 | + static $levels = null; |
|
162 | + if ($levels === null) { |
|
163 | + $levels = []; |
|
164 | 164 | foreach (get_defined_constants() as $key=>$value) { |
165 | - if (strpos($key,'E_')!==0) {continue;} |
|
166 | - $levels[$value]= $key; //substr($key,2); |
|
165 | + if (strpos($key, 'E_') !== 0) {continue; } |
|
166 | + $levels[$value] = $key; //substr($key,2); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}"); |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | |
172 | 172 | public function get_logger_filename() |
173 | 173 | { |
174 | - $filename = $this->backup_storage_dir .DS. "xcloner_restore.log"; |
|
174 | + $filename = $this->backup_storage_dir.DS."xcloner_restore.log"; |
|
175 | 175 | |
176 | 176 | return $filename; |
177 | 177 | } |
178 | 178 | |
179 | 179 | public function init() |
180 | 180 | { |
181 | - if(isset($_POST['xcloner_action']) and $_POST['xcloner_action']) |
|
181 | + if (isset($_POST['xcloner_action']) and $_POST['xcloner_action']) |
|
182 | 182 | { |
183 | 183 | $method = filter_input(INPUT_POST, 'xcloner_action', FILTER_SANITIZE_STRING); |
184 | 184 | |
@@ -186,13 +186,13 @@ discard block |
||
186 | 186 | |
187 | 187 | $method .= "_action"; |
188 | 188 | |
189 | - if(method_exists($this, $method)) |
|
189 | + if (method_exists($this, $method)) |
|
190 | 190 | { |
191 | 191 | $this->logger->debug(sprintf('Starting action %s', $method)); |
192 | 192 | return call_user_func(array($this, $method)); |
193 | 193 | |
194 | - }else{ |
|
195 | - throw new Exception($method ." does not exists"); |
|
194 | + } else { |
|
195 | + throw new Exception($method." does not exists"); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
@@ -201,38 +201,38 @@ discard block |
||
201 | 201 | |
202 | 202 | public function write_file_action() |
203 | 203 | { |
204 | - if(isset($_POST['file'])) |
|
204 | + if (isset($_POST['file'])) |
|
205 | 205 | { |
206 | 206 | $target_file = filter_input(INPUT_POST, 'file', FILTER_SANITIZE_STRING); |
207 | 207 | |
208 | - if(!$_POST['start']) |
|
208 | + if (!$_POST['start']) |
|
209 | 209 | $fp = fopen($target_file, "wb+"); |
210 | 210 | else |
211 | 211 | $fp = fopen($target_file, "ab+"); |
212 | 212 | |
213 | - if(!$fp) |
|
213 | + if (!$fp) |
|
214 | 214 | throw new Exception("Unable to open $target_file file for writing"); |
215 | 215 | |
216 | 216 | fseek($fp, $_POST['start']); |
217 | 217 | |
218 | - if(isset($_FILES['blob'])) |
|
218 | + if (isset($_FILES['blob'])) |
|
219 | 219 | { |
220 | 220 | $this->logger->debug(sprintf('Writing %s bytes to file %s starting position %s using FILES blob', filesize($_FILES['blob']['tmp_name']), $target_file, $_POST['start'])); |
221 | 221 | |
222 | 222 | $blob = file_get_contents($_FILES['blob']['tmp_name']); |
223 | 223 | |
224 | - if(!$bytes_written = fwrite($fp, $blob)) |
|
224 | + if (!$bytes_written = fwrite($fp, $blob)) |
|
225 | 225 | throw new Exception("Unable to write data to file $target_file"); |
226 | 226 | |
227 | 227 | @unlink($_FILES['blob']['tmp_name']); |
228 | - }elseif(isset($_POST['blob'])){ |
|
228 | + }elseif (isset($_POST['blob'])) { |
|
229 | 229 | $this->logger->debug(sprintf('Writing %s bytes to file %s starting position %s using POST blob', strlen($_POST['blob']), $target_file, $_POST['start'])); |
230 | 230 | |
231 | 231 | $blob = $_POST['blob']; |
232 | 232 | |
233 | - if(!$bytes_written = fwrite($fp, $blob)) |
|
233 | + if (!$bytes_written = fwrite($fp, $blob)) |
|
234 | 234 | throw new Exception("Unable to write data to file $target_file"); |
235 | - }else{ |
|
235 | + } else { |
|
236 | 236 | throw new Exception("Upload failed, did not receive any binary data"); |
237 | 237 | } |
238 | 238 | |
@@ -243,20 +243,20 @@ discard block |
||
243 | 243 | |
244 | 244 | } |
245 | 245 | |
246 | - public function mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db ) |
|
246 | + public function mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db) |
|
247 | 247 | { |
248 | 248 | $this->logger->info(sprintf('Connecting to mysql database %s with %s@%s', $remote_mysql_db, $remote_mysql_user, $remote_mysql_host)); |
249 | 249 | |
250 | 250 | $mysqli = new mysqli($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db); |
251 | 251 | |
252 | 252 | if ($mysqli->connect_error) { |
253 | - throw new Exception('Connect Error (' . $mysqli->connect_errno . ') ' |
|
253 | + throw new Exception('Connect Error ('.$mysqli->connect_errno.') ' |
|
254 | 254 | . $mysqli->connect_error); |
255 | 255 | } |
256 | 256 | |
257 | 257 | $mysqli->query("SET sql_mode='';"); |
258 | 258 | $mysqli->query("SET foreign_key_checks = 0;"); |
259 | - if(isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file']) |
|
259 | + if (isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file']) |
|
260 | 260 | $mysqli->query("SET NAMES ".$_REQUEST['charset_of_file'].""); |
261 | 261 | else |
262 | 262 | $mysqli->query("SET NAMES utf8;"); |
@@ -266,15 +266,15 @@ discard block |
||
266 | 266 | |
267 | 267 | public function restore_mysql_backup_action() |
268 | 268 | { |
269 | - $mysqldump_file = filter_input(INPUT_POST, 'mysqldump_file', FILTER_SANITIZE_STRING); |
|
270 | - $remote_path = filter_input(INPUT_POST, 'remote_path', FILTER_SANITIZE_STRING); |
|
269 | + $mysqldump_file = filter_input(INPUT_POST, 'mysqldump_file', FILTER_SANITIZE_STRING); |
|
270 | + $remote_path = filter_input(INPUT_POST, 'remote_path', FILTER_SANITIZE_STRING); |
|
271 | 271 | $remote_mysql_user = filter_input(INPUT_POST, 'remote_mysql_user', FILTER_SANITIZE_STRING); |
272 | 272 | $remote_mysql_pass = filter_input(INPUT_POST, 'remote_mysql_pass', FILTER_SANITIZE_STRING); |
273 | - $remote_mysql_db = filter_input(INPUT_POST, 'remote_mysql_db', FILTER_SANITIZE_STRING); |
|
273 | + $remote_mysql_db = filter_input(INPUT_POST, 'remote_mysql_db', FILTER_SANITIZE_STRING); |
|
274 | 274 | $remote_mysql_host = filter_input(INPUT_POST, 'remote_mysql_host', FILTER_SANITIZE_STRING); |
275 | - $execute_query = trim(stripslashes($_POST['query'])); |
|
276 | - $error_line = filter_input(INPUT_POST, 'error_line', FILTER_SANITIZE_NUMBER_INT); |
|
277 | - $start = filter_input(INPUT_POST, 'start', FILTER_SANITIZE_NUMBER_INT); |
|
275 | + $execute_query = trim(stripslashes($_POST['query'])); |
|
276 | + $error_line = filter_input(INPUT_POST, 'error_line', FILTER_SANITIZE_NUMBER_INT); |
|
277 | + $start = filter_input(INPUT_POST, 'start', FILTER_SANITIZE_NUMBER_INT); |
|
278 | 278 | |
279 | 279 | $wp_home_url = filter_input(INPUT_POST, 'wp_home_url', FILTER_SANITIZE_STRING); |
280 | 280 | $remote_restore_url = filter_input(INPUT_POST, 'remote_restore_url', FILTER_SANITIZE_STRING); |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | |
285 | 285 | $mysql_backup_file = $remote_path.DS.$mysqldump_file; |
286 | 286 | |
287 | - if(!file_exists($mysql_backup_file)) |
|
288 | - throw new Exception(sprintf("Mysql backup file %s does not exists",$mysql_backup_file)); |
|
287 | + if (!file_exists($mysql_backup_file)) |
|
288 | + throw new Exception(sprintf("Mysql backup file %s does not exists", $mysql_backup_file)); |
|
289 | 289 | |
290 | 290 | |
291 | 291 | /*if(defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS) |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | }*/ |
300 | 300 | |
301 | 301 | { |
302 | - $mysqli = $this->mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db ); |
|
302 | + $mysqli = $this->mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | $line_count = 0; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | $return['backup_size'] = filesize($mysql_backup_file); |
310 | 310 | |
311 | 311 | $fp = fopen($mysql_backup_file, "r"); |
312 | - if($fp) |
|
312 | + if ($fp) |
|
313 | 313 | { |
314 | 314 | $this->logger->info(sprintf("Opening mysql dump file %s at position %s.", $mysql_backup_file, $start)); |
315 | 315 | fseek($fp, $start); |
@@ -317,49 +317,49 @@ discard block |
||
317 | 317 | // process the line read. |
318 | 318 | |
319 | 319 | //check if line is comment |
320 | - if(substr($line, 0, 1) == "#") |
|
320 | + if (substr($line, 0, 1) == "#") |
|
321 | 321 | continue; |
322 | 322 | |
323 | 323 | //check if line is empty |
324 | - if($line == "\n" or trim($line) == "") |
|
324 | + if ($line == "\n" or trim($line) == "") |
|
325 | 325 | continue; |
326 | 326 | |
327 | - if(substr($line, strlen($line)-2, strlen($line)) == ";\n") |
|
327 | + if (substr($line, strlen($line) - 2, strlen($line)) == ";\n") |
|
328 | 328 | $query .= $line; |
329 | - else{ |
|
329 | + else { |
|
330 | 330 | $query .= $line; |
331 | 331 | continue; |
332 | 332 | } |
333 | 333 | |
334 | - if($execute_query) |
|
334 | + if ($execute_query) |
|
335 | 335 | { |
336 | - $query = (($execute_query)); |
|
336 | + $query = (($execute_query)); |
|
337 | 337 | $execute_query = ""; |
338 | 338 | } |
339 | 339 | |
340 | 340 | //Doing serialized url replace here |
341 | 341 | |
342 | - if($wp_site_url and $wp_home_url and strlen($wp_home_url) < strlen($wp_site_url)) |
|
342 | + if ($wp_site_url and $wp_home_url and strlen($wp_home_url) < strlen($wp_site_url)) |
|
343 | 343 | { |
344 | - list($wp_home_url,$wp_site_url) = array($wp_site_url,$wp_home_url); |
|
345 | - list($remote_restore_url,$restore_site_url) = array($restore_site_url,$remote_restore_url); |
|
344 | + list($wp_home_url, $wp_site_url) = array($wp_site_url, $wp_home_url); |
|
345 | + list($remote_restore_url, $restore_site_url) = array($restore_site_url, $remote_restore_url); |
|
346 | 346 | |
347 | 347 | } |
348 | 348 | |
349 | - if($wp_home_url and $remote_restore_url and strpos($query, $wp_home_url) !== false) |
|
349 | + if ($wp_home_url and $remote_restore_url and strpos($query, $wp_home_url) !== false) |
|
350 | 350 | { |
351 | 351 | $query = $this->url_replace($wp_home_url, $remote_restore_url, $query); |
352 | 352 | } |
353 | 353 | |
354 | - if($wp_site_url and $restore_site_url and strpos($query, $wp_site_url) !== false) |
|
354 | + if ($wp_site_url and $restore_site_url and strpos($query, $wp_site_url) !== false) |
|
355 | 355 | { |
356 | 356 | $query = $this->url_replace($wp_site_url, $restore_site_url, $query); |
357 | 357 | } |
358 | 358 | |
359 | - if(!$mysqli->query($query) && !stristr($mysqli->error,"Duplicate entry")) |
|
359 | + if (!$mysqli->query($query) && !stristr($mysqli->error, "Duplicate entry")) |
|
360 | 360 | { |
361 | 361 | //$return['error_line'] = $line_count; |
362 | - $return['start'] = ftell($fp)-strlen($line); |
|
362 | + $return['start'] = ftell($fp) - strlen($line); |
|
363 | 363 | $return['query_error'] = true; |
364 | 364 | $return['query'] = $query; |
365 | 365 | $return['message'] = sprintf("Mysql Error: %s\n", $mysqli->error); |
@@ -380,12 +380,12 @@ discard block |
||
380 | 380 | |
381 | 381 | $return['start'] = ftell($fp); |
382 | 382 | |
383 | - $this->logger->info(sprintf("Executed %s queries of size %s bytes", $line_count, ($return['start']-$start))); |
|
383 | + $this->logger->info(sprintf("Executed %s queries of size %s bytes", $line_count, ($return['start'] - $start))); |
|
384 | 384 | |
385 | - if(!feof($fp)) |
|
385 | + if (!feof($fp)) |
|
386 | 386 | { |
387 | 387 | $return['finished'] = 0; |
388 | - }else{ |
|
388 | + } else { |
|
389 | 389 | $this->logger->info(sprintf("Mysql Import Done.")); |
390 | 390 | } |
391 | 391 | |
@@ -400,12 +400,12 @@ discard block |
||
400 | 400 | $query = str_replace($search, $replace, $query); |
401 | 401 | $original_query = $query; |
402 | 402 | |
403 | - if($this->has_serialized($query)) |
|
403 | + if ($this->has_serialized($query)) |
|
404 | 404 | { |
405 | 405 | $this->logger->info(sprintf("Query contains serialized data, doing serialized size fix"), array("QUERY_REPLACE")); |
406 | 406 | $query = $this->do_serialized_fix($query); |
407 | 407 | |
408 | - if(!$query) |
|
408 | + if (!$query) |
|
409 | 409 | { |
410 | 410 | $this->logger->info(sprintf("Serialization probably failed here..."), array("QUERY_REPLACE")); |
411 | 411 | $query = $original_query; |
@@ -421,37 +421,37 @@ discard block |
||
421 | 421 | $backup_parts = array(); |
422 | 422 | |
423 | 423 | $source_backup_file = filter_input(INPUT_POST, 'file', FILTER_SANITIZE_STRING); |
424 | - $start = (int)filter_input(INPUT_POST, 'start', FILTER_SANITIZE_STRING); |
|
425 | - $return['part'] = (int)filter_input(INPUT_POST, 'part', FILTER_SANITIZE_STRING); |
|
424 | + $start = (int)filter_input(INPUT_POST, 'start', FILTER_SANITIZE_STRING); |
|
425 | + $return['part'] = (int)filter_input(INPUT_POST, 'part', FILTER_SANITIZE_STRING); |
|
426 | 426 | |
427 | 427 | $backup_file = $source_backup_file; |
428 | 428 | |
429 | - if($this->is_multipart($backup_file)) |
|
429 | + if ($this->is_multipart($backup_file)) |
|
430 | 430 | { |
431 | 431 | $backup_parts = $this->get_multipart_files($backup_file); |
432 | 432 | $backup_file = $backup_parts[$return['part']]; |
433 | 433 | } |
434 | 434 | |
435 | - try{ |
|
435 | + try { |
|
436 | 436 | $tar = new Tar(); |
437 | 437 | $tar->open($this->backup_storage_dir.DS.$backup_file, $start); |
438 | 438 | |
439 | 439 | $data = $tar->contents($this->process_files_limit_list); |
440 | - }catch(Exception $e) |
|
440 | + }catch (Exception $e) |
|
441 | 441 | { |
442 | 442 | $return['error'] = true; |
443 | 443 | $return['message'] = $e->getMessage(); |
444 | 444 | $this->send_response(200, $return); |
445 | 445 | } |
446 | 446 | |
447 | - $return['files'] = array(); |
|
448 | - $return['finished'] = 1; |
|
449 | - $return['total_size'] = filesize($this->backup_storage_dir.DS.$backup_file); |
|
447 | + $return['files'] = array(); |
|
448 | + $return['finished'] = 1; |
|
449 | + $return['total_size'] = filesize($this->backup_storage_dir.DS.$backup_file); |
|
450 | 450 | $i = 0; |
451 | 451 | |
452 | - if(isset($data['extracted_files']) and is_array($data['extracted_files'])) |
|
452 | + if (isset($data['extracted_files']) and is_array($data['extracted_files'])) |
|
453 | 453 | { |
454 | - foreach($data['extracted_files'] as $file) |
|
454 | + foreach ($data['extracted_files'] as $file) |
|
455 | 455 | { |
456 | 456 | $return['files'][$i]['path'] = $file->getPath(); |
457 | 457 | $return['files'][$i]['size'] = $file->getSize(); |
@@ -461,18 +461,18 @@ discard block |
||
461 | 461 | } |
462 | 462 | } |
463 | 463 | |
464 | - if(isset($data['start'])) |
|
464 | + if (isset($data['start'])) |
|
465 | 465 | { |
466 | 466 | $return['start'] = $data['start']; |
467 | 467 | $return['finished'] = 0; |
468 | - }else{ |
|
469 | - if($this->is_multipart($source_backup_file)) |
|
468 | + } else { |
|
469 | + if ($this->is_multipart($source_backup_file)) |
|
470 | 470 | { |
471 | 471 | $return['start'] = 0; |
472 | 472 | |
473 | 473 | ++$return['part']; |
474 | 474 | |
475 | - if($return['part'] < sizeof($backup_parts)) |
|
475 | + if ($return['part'] < sizeof($backup_parts)) |
|
476 | 476 | $return['finished'] = 0; |
477 | 477 | |
478 | 478 | } |
@@ -490,28 +490,28 @@ discard block |
||
490 | 490 | |
491 | 491 | $remote_mysql_user = filter_input(INPUT_POST, 'remote_mysql_user', FILTER_SANITIZE_STRING); |
492 | 492 | $remote_mysql_pass = filter_input(INPUT_POST, 'remote_mysql_pass', FILTER_SANITIZE_STRING); |
493 | - $remote_mysql_db = filter_input(INPUT_POST, 'remote_mysql_db', FILTER_SANITIZE_STRING); |
|
493 | + $remote_mysql_db = filter_input(INPUT_POST, 'remote_mysql_db', FILTER_SANITIZE_STRING); |
|
494 | 494 | $remote_mysql_host = filter_input(INPUT_POST, 'remote_mysql_host', FILTER_SANITIZE_STRING); |
495 | 495 | |
496 | - $update_remote_site_url = filter_input(INPUT_POST, 'update_remote_site_url', FILTER_SANITIZE_NUMBER_INT); |
|
497 | - $delete_restore_script = filter_input(INPUT_POST, 'delete_restore_script', FILTER_SANITIZE_NUMBER_INT); |
|
498 | - $delete_backup_temporary_folder = filter_input(INPUT_POST, 'delete_backup_temporary_folder', FILTER_SANITIZE_NUMBER_INT); |
|
496 | + $update_remote_site_url = filter_input(INPUT_POST, 'update_remote_site_url', FILTER_SANITIZE_NUMBER_INT); |
|
497 | + $delete_restore_script = filter_input(INPUT_POST, 'delete_restore_script', FILTER_SANITIZE_NUMBER_INT); |
|
498 | + $delete_backup_temporary_folder = filter_input(INPUT_POST, 'delete_backup_temporary_folder', FILTER_SANITIZE_NUMBER_INT); |
|
499 | 499 | |
500 | - if($update_remote_site_url) |
|
500 | + if ($update_remote_site_url) |
|
501 | 501 | { |
502 | - $mysqli = $this->mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db ); |
|
502 | + $mysqli = $this->mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db); |
|
503 | 503 | $this->update_wp_config($remote_path, $remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db); |
504 | 504 | $this->update_wp_url($remote_path, $remote_restore_url, $mysqli); |
505 | 505 | } |
506 | 506 | |
507 | - if($delete_backup_temporary_folder) |
|
507 | + if ($delete_backup_temporary_folder) |
|
508 | 508 | { |
509 | 509 | $this->delete_backup_temporary_folder($remote_path); |
510 | 510 | } |
511 | 511 | |
512 | - if(!defined('XCLONER_PLUGIN_ACCESS') || XCLONER_PLUGIN_ACCESS != 1) |
|
512 | + if (!defined('XCLONER_PLUGIN_ACCESS') || XCLONER_PLUGIN_ACCESS != 1) |
|
513 | 513 | { |
514 | - if($delete_restore_script) |
|
514 | + if ($delete_restore_script) |
|
515 | 515 | { |
516 | 516 | $this->delete_self(); |
517 | 517 | } |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | |
524 | 524 | private function delete_backup_temporary_folder($remote_path) |
525 | 525 | { |
526 | - $this->target_adapter = new Local($remote_path ,LOCK_EX, 'SKIP_LINKS'); |
|
526 | + $this->target_adapter = new Local($remote_path, LOCK_EX, 'SKIP_LINKS'); |
|
527 | 527 | $this->target_filesystem = new Filesystem($this->target_adapter, new Config([ |
528 | 528 | 'disable_asserts' => true, |
529 | 529 | ])); |
@@ -531,13 +531,13 @@ discard block |
||
531 | 531 | $mysqldump_list = array(); |
532 | 532 | $list = $this->target_filesystem->listContents(); |
533 | 533 | |
534 | - foreach($list as $file) |
|
534 | + foreach ($list as $file) |
|
535 | 535 | { |
536 | 536 | $matches = array(); |
537 | 537 | |
538 | - if($file['type'] == "dir") |
|
538 | + if ($file['type'] == "dir") |
|
539 | 539 | { |
540 | - if(preg_match("/xcloner-(\w*)/", $file['basename'], $matches)){ |
|
540 | + if (preg_match("/xcloner-(\w*)/", $file['basename'], $matches)) { |
|
541 | 541 | $this->logger->info(sprintf('Deleting temporary folder %s', $file['path'])); |
542 | 542 | $this->target_filesystem->deleteDir($file['path']); |
543 | 543 | } |
@@ -550,29 +550,29 @@ discard block |
||
550 | 550 | |
551 | 551 | private function delete_self() |
552 | 552 | { |
553 | - if($this->filesystem->has("vendor.phar")) |
|
553 | + if ($this->filesystem->has("vendor.phar")) |
|
554 | 554 | { |
555 | 555 | $this->logger->info(sprintf('Deleting vendor.phar')); |
556 | 556 | $this->filesystem->delete("vendor.phar"); |
557 | 557 | } |
558 | - if($this->filesystem->has("vendor")) |
|
558 | + if ($this->filesystem->has("vendor")) |
|
559 | 559 | { |
560 | 560 | $this->logger->info(sprintf('Deleting vendor folder')); |
561 | 561 | $this->filesystem->deleteDir("vendor"); |
562 | 562 | } |
563 | - if($this->filesystem->has("xcloner_restore.php")) |
|
563 | + if ($this->filesystem->has("xcloner_restore.php")) |
|
564 | 564 | { |
565 | 565 | $this->logger->info(sprintf('Deleting xcloner_restore.php')); |
566 | 566 | $this->filesystem->delete("xcloner_restore.php"); |
567 | 567 | } |
568 | 568 | |
569 | - if($this->filesystem->has("xcloner_restore.log")) |
|
569 | + if ($this->filesystem->has("xcloner_restore.log")) |
|
570 | 570 | { |
571 | 571 | $this->logger->info(sprintf('Deleting xcloner_restore.log')); |
572 | 572 | $this->filesystem->delete("xcloner_restore.log"); |
573 | 573 | } |
574 | 574 | |
575 | - if($this->filesystem->has($this->get_logger_filename())) |
|
575 | + if ($this->filesystem->has($this->get_logger_filename())) |
|
576 | 576 | { |
577 | 577 | $this->logger->info(sprintf('Deleting logger file %s', $this->get_logger_filename())); |
578 | 578 | $this->filesystem->delete($this->get_logger_filename()); |
@@ -586,11 +586,11 @@ discard block |
||
586 | 586 | |
587 | 587 | $this->logger->info(sprintf('Updating site url to %s', $url)); |
588 | 588 | |
589 | - if(file_exists($wp_config)) |
|
589 | + if (file_exists($wp_config)) |
|
590 | 590 | { |
591 | 591 | $config = file_get_contents($wp_config); |
592 | 592 | preg_match("/.*table_prefix.*=.*'(.*)'/i", $config, $matches); |
593 | - if(isset($matches[1])) |
|
593 | + if (isset($matches[1])) |
|
594 | 594 | $table_prefix = $matches[1]; |
595 | 595 | else |
596 | 596 | throw new Exception("Could not load wordpress table prefix from wp-config.php file."); |
@@ -598,10 +598,10 @@ discard block |
||
598 | 598 | else |
599 | 599 | throw new Exception("Could not update the SITEURL and HOME, wp-config.php file not found"); |
600 | 600 | |
601 | - if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='home'")) |
|
601 | + if (!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='home'")) |
|
602 | 602 | throw new Exception(sprintf("Could not update the HOME option, error: %s\n", $mysqli->error)); |
603 | 603 | |
604 | - if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='siteurl'")) |
|
604 | + if (!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='siteurl'")) |
|
605 | 605 | throw new Exception(sprintf("Could not update the SITEURL option, error: %s\n", $mysqli->error)); |
606 | 606 | |
607 | 607 | return true; |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | { |
612 | 612 | $wp_config = $remote_path.DS."wp-config.php"; |
613 | 613 | |
614 | - if(!file_exists($wp_config)) |
|
614 | + if (!file_exists($wp_config)) |
|
615 | 615 | { |
616 | 616 | throw new Exception("Could not find the wp-config.php in ".$remote_path); |
617 | 617 | } |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | |
630 | 630 | $this->logger->info(sprintf('Updating wp-config.php file with the new mysql details')); |
631 | 631 | |
632 | - if(!file_put_contents($wp_config, $content)) |
|
632 | + if (!file_put_contents($wp_config, $content)) |
|
633 | 633 | throw new Exception("Could not write updated config data to ".$wp_config); |
634 | 634 | |
635 | 635 | chmod($wp_config, $file_perms); |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | |
646 | 646 | $hash = $this->get_hash_from_backup($source_backup_file); |
647 | 647 | |
648 | - $this->target_adapter = new Local($remote_path ,LOCK_EX, 'SKIP_LINKS'); |
|
648 | + $this->target_adapter = new Local($remote_path, LOCK_EX, 'SKIP_LINKS'); |
|
649 | 649 | $this->target_filesystem = new Filesystem($this->target_adapter, new Config([ |
650 | 650 | 'disable_asserts' => true, |
651 | 651 | ])); |
@@ -653,25 +653,25 @@ discard block |
||
653 | 653 | $mysqldump_list = array(); |
654 | 654 | $list = $this->target_filesystem->listContents(); |
655 | 655 | |
656 | - foreach($list as $file) |
|
656 | + foreach ($list as $file) |
|
657 | 657 | { |
658 | 658 | $matches = array(); |
659 | 659 | |
660 | - if($file['type'] == "dir") |
|
660 | + if ($file['type'] == "dir") |
|
661 | 661 | { |
662 | - if(preg_match("/xcloner-(\w*)/", $file['basename'], $matches)) |
|
662 | + if (preg_match("/xcloner-(\w*)/", $file['basename'], $matches)) |
|
663 | 663 | { |
664 | 664 | $files = $this->target_filesystem->listContents($file['basename']); |
665 | - foreach($files as $file) |
|
665 | + foreach ($files as $file) |
|
666 | 666 | { |
667 | - if($file['extension'] == "sql") |
|
667 | + if ($file['extension'] == "sql") |
|
668 | 668 | { |
669 | 669 | $this->logger->info(sprintf('Found %s mysql backup file', $file['path'])); |
670 | 670 | $mysqldump_list[$file['path']]['path'] = $file['path']; |
671 | 671 | $mysqldump_list[$file['path']]['size'] = $file['size']; |
672 | - $mysqldump_list[$file['path']]['timestamp'] = date("d M,Y H:i",$file['timestamp']); |
|
672 | + $mysqldump_list[$file['path']]['timestamp'] = date("d M,Y H:i", $file['timestamp']); |
|
673 | 673 | |
674 | - if($hash and $hash == $matches[1]) |
|
674 | + if ($hash and $hash == $matches[1]) |
|
675 | 675 | $mysqldump_list[$file['path']]['selected'] = "selected"; |
676 | 676 | else |
677 | 677 | $mysqldump_list[$file['path']]['selected'] = ""; |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | } |
682 | 682 | } |
683 | 683 | |
684 | - $this->sort_by($mysqldump_list, 'timestamp','desc'); |
|
684 | + $this->sort_by($mysqldump_list, 'timestamp', 'desc'); |
|
685 | 685 | $return['files'] = $mysqldump_list; |
686 | 686 | |
687 | 687 | $this->send_response(200, $return); |
@@ -689,12 +689,12 @@ discard block |
||
689 | 689 | |
690 | 690 | private function get_hash_from_backup($backup_file) |
691 | 691 | { |
692 | - if(!$backup_file) |
|
692 | + if (!$backup_file) |
|
693 | 693 | return false; |
694 | 694 | |
695 | - $result = preg_match("/-(\w*)./", substr($backup_file, strlen($backup_file)-10, strlen($backup_file)), $matches) ; |
|
695 | + $result = preg_match("/-(\w*)./", substr($backup_file, strlen($backup_file) - 10, strlen($backup_file)), $matches); |
|
696 | 696 | |
697 | - if($result and isset($matches[1])) |
|
697 | + if ($result and isset($matches[1])) |
|
698 | 698 | return ($matches[1]); |
699 | 699 | |
700 | 700 | return false; |
@@ -708,18 +708,18 @@ discard block |
||
708 | 708 | $backup_files = array(); |
709 | 709 | $parents = array(); |
710 | 710 | |
711 | - foreach($list as $file_info) |
|
711 | + foreach ($list as $file_info) |
|
712 | 712 | { |
713 | 713 | $data = array(); |
714 | 714 | |
715 | - if(isset($file_info['extension']) and $file_info['extension'] == "csv") |
|
715 | + if (isset($file_info['extension']) and $file_info['extension'] == "csv") |
|
716 | 716 | { |
717 | 717 | $lines = explode(PHP_EOL, $this->filesystem->read($file_info['path'])); |
718 | - foreach($lines as $line) |
|
719 | - if($line) |
|
718 | + foreach ($lines as $line) |
|
719 | + if ($line) |
|
720 | 720 | { |
721 | 721 | $data = str_getcsv($line); |
722 | - if(is_array($data)){ |
|
722 | + if (is_array($data)) { |
|
723 | 723 | $parents[$data[0]] = $file_info['path']; |
724 | 724 | $file_info['childs'][] = $data; |
725 | 725 | $file_info['size'] += $data[2]; |
@@ -728,19 +728,19 @@ discard block |
||
728 | 728 | |
729 | 729 | } |
730 | 730 | |
731 | - if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) |
|
731 | + if ($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) |
|
732 | 732 | $backup_files[$file_info['path']] = $file_info; |
733 | 733 | } |
734 | 734 | |
735 | 735 | $new_list = array(); |
736 | 736 | |
737 | - foreach($backup_files as $key=>$file_info) |
|
737 | + foreach ($backup_files as $key=>$file_info) |
|
738 | 738 | { |
739 | - if(isset($parents[$file_info['path']])) |
|
739 | + if (isset($parents[$file_info['path']])) |
|
740 | 740 | $backup_files[$key]['parent'] = $parents[$file_info['path']]; |
741 | - else{ |
|
741 | + else { |
|
742 | 742 | |
743 | - if($local_backup_file and ($file_info['basename'] == $local_backup_file)) |
|
743 | + if ($local_backup_file and ($file_info['basename'] == $local_backup_file)) |
|
744 | 744 | $file_info['selected'] = 'selected'; |
745 | 745 | |
746 | 746 | $this->logger->info(sprintf('Found %s backup file', $file_info['path'])); |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | |
751 | 751 | } |
752 | 752 | |
753 | - $this->sort_by($new_list, "timestamp","desc"); |
|
753 | + $this->sort_by($new_list, "timestamp", "desc"); |
|
754 | 754 | |
755 | 755 | $return['files'] = $new_list; |
756 | 756 | |
@@ -760,15 +760,15 @@ discard block |
||
760 | 760 | |
761 | 761 | public function restore_backup_to_path_action() |
762 | 762 | { |
763 | - $source_backup_file = filter_input(INPUT_POST, 'backup_file', FILTER_SANITIZE_STRING); |
|
764 | - $remote_path = filter_input(INPUT_POST, 'remote_path', FILTER_SANITIZE_STRING); |
|
763 | + $source_backup_file = filter_input(INPUT_POST, 'backup_file', FILTER_SANITIZE_STRING); |
|
764 | + $remote_path = filter_input(INPUT_POST, 'remote_path', FILTER_SANITIZE_STRING); |
|
765 | 765 | $include_filter_files = filter_input(INPUT_POST, 'filter_files', FILTER_SANITIZE_STRING); |
766 | 766 | $exclude_filter_files = ""; |
767 | - $start = filter_input(INPUT_POST, 'start', FILTER_SANITIZE_NUMBER_INT); |
|
768 | - $return['part'] = (int)filter_input(INPUT_POST, 'part', FILTER_SANITIZE_NUMBER_INT); |
|
767 | + $start = filter_input(INPUT_POST, 'start', FILTER_SANITIZE_NUMBER_INT); |
|
768 | + $return['part'] = (int)filter_input(INPUT_POST, 'part', FILTER_SANITIZE_NUMBER_INT); |
|
769 | 769 | $return['processed'] = (int)filter_input(INPUT_POST, 'processed', FILTER_SANITIZE_NUMBER_INT); |
770 | 770 | |
771 | - $this->target_adapter = new Local($remote_path ,LOCK_EX, 'SKIP_LINKS'); |
|
771 | + $this->target_adapter = new Local($remote_path, LOCK_EX, 'SKIP_LINKS'); |
|
772 | 772 | $this->target_filesystem = new Filesystem($this->target_adapter, new Config([ |
773 | 773 | 'disable_asserts' => true, |
774 | 774 | ])); |
@@ -780,9 +780,9 @@ discard block |
||
780 | 780 | $return['total_size'] = $this->get_backup_size($backup_file); |
781 | 781 | |
782 | 782 | $backup_archive = new Tar(); |
783 | - if($this->is_multipart($backup_file)) |
|
783 | + if ($this->is_multipart($backup_file)) |
|
784 | 784 | { |
785 | - if(!$return['part']) |
|
785 | + if (!$return['part']) |
|
786 | 786 | $return['processed'] += $this->filesystem->getSize($backup_file); |
787 | 787 | |
788 | 788 | $backup_parts = $this->get_multipart_files($backup_file); |
@@ -790,41 +790,41 @@ discard block |
||
790 | 790 | } |
791 | 791 | |
792 | 792 | $this->logger->info(sprintf('Opening backup archive %s at position %s', $backup_file, $start)); |
793 | - $backup_archive->open($this->backup_storage_dir .DS. $backup_file, $start); |
|
793 | + $backup_archive->open($this->backup_storage_dir.DS.$backup_file, $start); |
|
794 | 794 | |
795 | - $data = $backup_archive->extract($remote_path, '',$exclude_filter_files,$include_filter_files, $this->process_files_limit); |
|
795 | + $data = $backup_archive->extract($remote_path, '', $exclude_filter_files, $include_filter_files, $this->process_files_limit); |
|
796 | 796 | |
797 | - if(isset($data['extracted_files'])) |
|
797 | + if (isset($data['extracted_files'])) |
|
798 | 798 | { |
799 | - foreach($data['extracted_files'] as $spl_fileinfo) |
|
799 | + foreach ($data['extracted_files'] as $spl_fileinfo) |
|
800 | 800 | { |
801 | 801 | $this->logger->info(sprintf('Extracted %s file', $spl_fileinfo->getPath())); |
802 | 802 | $return['extracted_files'][] = $spl_fileinfo->getPath()." (".$spl_fileinfo->getSize()." bytes)"; |
803 | 803 | } |
804 | 804 | } |
805 | 805 | |
806 | - if(isset($data['start'])) |
|
806 | + if (isset($data['start'])) |
|
807 | 807 | //if(isset($data['start']) and $data['start'] <= $this->filesystem->getSize($backup_file)) |
808 | 808 | { |
809 | 809 | $return['finished'] = 0; |
810 | 810 | $return['start'] = $data['start']; |
811 | - }else{ |
|
811 | + } else { |
|
812 | 812 | |
813 | 813 | $return['processed'] += $start; |
814 | 814 | |
815 | - if($this->is_multipart($source_backup_file)) |
|
815 | + if ($this->is_multipart($source_backup_file)) |
|
816 | 816 | { |
817 | 817 | $return['start'] = 0; |
818 | 818 | |
819 | 819 | ++$return['part']; |
820 | 820 | |
821 | - if($return['part'] < sizeof($backup_parts)) |
|
821 | + if ($return['part'] < sizeof($backup_parts)) |
|
822 | 822 | $return['finished'] = 0; |
823 | 823 | |
824 | 824 | } |
825 | 825 | } |
826 | 826 | |
827 | - if($return['finished']) |
|
827 | + if ($return['finished']) |
|
828 | 828 | $this->logger->info(sprintf('Done extracting %s', $source_backup_file)); |
829 | 829 | |
830 | 830 | $return['backup_file'] = $backup_file; |
@@ -838,24 +838,24 @@ discard block |
||
838 | 838 | |
839 | 839 | $restore_script_url = filter_input(INPUT_POST, 'restore_script_url', FILTER_SANITIZE_STRING); |
840 | 840 | |
841 | - $pathinfo = pathinfo( __FILE__); |
|
841 | + $pathinfo = pathinfo(__FILE__); |
|
842 | 842 | |
843 | 843 | $suffix = ""; |
844 | 844 | $return['remote_mysql_host'] = "localhost"; |
845 | 845 | $return['remote_mysql_user'] = ""; |
846 | 846 | $return['remote_mysql_pass'] = ""; |
847 | - $return['remote_mysql_db'] = ""; |
|
847 | + $return['remote_mysql_db'] = ""; |
|
848 | 848 | |
849 | - if(defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS) |
|
849 | + if (defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS) |
|
850 | 850 | { |
851 | 851 | $return['dir'] = realpath(get_home_path().DS.$suffix); |
852 | - $return['restore_script_url'] = get_site_url(); |
|
852 | + $return['restore_script_url'] = get_site_url(); |
|
853 | 853 | $return['remote_mysql_host'] = $wpdb->dbhost; |
854 | 854 | $return['remote_mysql_user'] = $wpdb->dbuser; |
855 | 855 | $return['remote_mysql_pass'] = $wpdb->dbpassword; |
856 | - $return['remote_mysql_db'] = $wpdb->dbname; |
|
856 | + $return['remote_mysql_db'] = $wpdb->dbname; |
|
857 | 857 | } |
858 | - else{ |
|
858 | + else { |
|
859 | 859 | $return['dir'] = ($pathinfo['dirname']).DS.$suffix; |
860 | 860 | $return['restore_script_url'] = str_replace($pathinfo['basename'], "", $restore_script_url).$suffix; |
861 | 861 | } |
@@ -869,17 +869,17 @@ discard block |
||
869 | 869 | { |
870 | 870 | //check if i can write |
871 | 871 | $tmp_file = md5(time()); |
872 | - if(!file_put_contents($tmp_file, "++")) |
|
872 | + if (!file_put_contents($tmp_file, "++")) |
|
873 | 873 | throw new Exception("Could not write to new host"); |
874 | 874 | |
875 | - if(!unlink($tmp_file)) |
|
875 | + if (!unlink($tmp_file)) |
|
876 | 876 | throw new Exception("Could not delete temporary file from new host"); |
877 | 877 | |
878 | 878 | $max_upload = $this->return_bytes((ini_get('upload_max_filesize'))); |
879 | 879 | $max_post = $this->return_bytes((ini_get('post_max_size'))); |
880 | 880 | |
881 | 881 | $return['max_upload_size'] = min($max_upload, $max_post); // bytes |
882 | - $return['status'] = true; |
|
882 | + $return['status'] = true; |
|
883 | 883 | |
884 | 884 | $this->logger->info(sprintf('Current filesystem max upload size is %s bytes', $return['max_upload_size'])); |
885 | 885 | |
@@ -888,8 +888,8 @@ discard block |
||
888 | 888 | |
889 | 889 | private function return_bytes($val) { |
890 | 890 | $val = trim($val); |
891 | - $last = strtolower($val[strlen($val)-1]); |
|
892 | - switch($last) { |
|
891 | + $last = strtolower($val[strlen($val) - 1]); |
|
892 | + switch ($last) { |
|
893 | 893 | // The 'G' modifier is available since PHP 5.1.0 |
894 | 894 | case 'g': |
895 | 895 | $val *= 1024; |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | |
905 | 905 | public function is_multipart($backup_name) |
906 | 906 | { |
907 | - if(stristr($backup_name, "-multipart")) |
|
907 | + if (stristr($backup_name, "-multipart")) |
|
908 | 908 | return true; |
909 | 909 | |
910 | 910 | return false; |
@@ -913,10 +913,10 @@ discard block |
||
913 | 913 | public function get_backup_size($backup_name) |
914 | 914 | { |
915 | 915 | $backup_size = $this->filesystem->getSize($backup_name); |
916 | - if($this->is_multipart($backup_name)) |
|
916 | + if ($this->is_multipart($backup_name)) |
|
917 | 917 | { |
918 | 918 | $backup_parts = $this->get_multipart_files($backup_name); |
919 | - foreach($backup_parts as $part_file) |
|
919 | + foreach ($backup_parts as $part_file) |
|
920 | 920 | $backup_size += $this->filesystem->getSize($part_file); |
921 | 921 | } |
922 | 922 | |
@@ -927,12 +927,12 @@ discard block |
||
927 | 927 | { |
928 | 928 | $files = array(); |
929 | 929 | |
930 | - if($this->is_multipart($backup_name)) |
|
930 | + if ($this->is_multipart($backup_name)) |
|
931 | 931 | { |
932 | 932 | $lines = explode(PHP_EOL, $this->filesystem->read($backup_name)); |
933 | - foreach($lines as $line) |
|
933 | + foreach ($lines as $line) |
|
934 | 934 | { |
935 | - if($line) |
|
935 | + if ($line) |
|
936 | 936 | { |
937 | 937 | $data = str_getcsv($line); |
938 | 938 | $files[] = $data[0]; |
@@ -943,20 +943,20 @@ discard block |
||
943 | 943 | return $files; |
944 | 944 | } |
945 | 945 | |
946 | - private function sort_by( &$array, $field, $direction = 'asc') |
|
946 | + private function sort_by(&$array, $field, $direction = 'asc') |
|
947 | 947 | { |
948 | 948 | $direction = strtolower($direction); |
949 | 949 | |
950 | 950 | usort($array, create_function('$a, $b', ' |
951 | - $a = $a["' . $field . '"]; |
|
952 | - $b = $b["' . $field . '"]; |
|
951 | + $a = $a["' . $field.'"]; |
|
952 | + $b = $b["' . $field.'"]; |
|
953 | 953 | |
954 | 954 | if ($a == $b) |
955 | 955 | { |
956 | 956 | return 0; |
957 | 957 | } |
958 | 958 | |
959 | - return ($a ' . ($direction == 'desc' ? '>' : '<') .' $b) ? -1 : 1; |
|
959 | + return ($a ' . ($direction == 'desc' ? '>' : '<').' $b) ? -1 : 1; |
|
960 | 960 | ')); |
961 | 961 | |
962 | 962 | return true; |
@@ -970,11 +970,11 @@ discard block |
||
970 | 970 | $return['status'] = $status; |
971 | 971 | $return['statusText'] = $response; |
972 | 972 | |
973 | - if(isset($response['error']) && $response['error']) |
|
973 | + if (isset($response['error']) && $response['error']) |
|
974 | 974 | { |
975 | 975 | $return['statusText'] = $response['message']; |
976 | 976 | $return['error'] = true; |
977 | - }elseif($status != 200 and $status != 418) |
|
977 | + }elseif ($status != 200 and $status != 418) |
|
978 | 978 | { |
979 | 979 | $return['error'] = true; |
980 | 980 | $return['message'] = $response; |
@@ -990,12 +990,12 @@ discard block |
||
990 | 990 | |
991 | 991 | function do_serialized_fix($query) |
992 | 992 | { |
993 | - $query = str_replace(array("\\n","\\r","\\'"), array("","","\""), ($query)); |
|
993 | + $query = str_replace(array("\\n", "\\r", "\\'"), array("", "", "\""), ($query)); |
|
994 | 994 | |
995 | - return preg_replace_callback('!s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!', function ($m) { |
|
995 | + return preg_replace_callback('!s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!', function($m) { |
|
996 | 996 | $data = ""; |
997 | 997 | |
998 | - if(!isset($m[3])) |
|
998 | + if (!isset($m[3])) |
|
999 | 999 | $m[3] = ""; |
1000 | 1000 | |
1001 | 1001 | $data = 's:'.strlen(($m[3])).':\"'.($m[3]).'\";'; |
@@ -1010,22 +1010,22 @@ discard block |
||
1010 | 1010 | } |
1011 | 1011 | |
1012 | 1012 | private function unescape_mysql($value) { |
1013 | - return str_replace(array("\\\\", "\\0", "\\n", "\\r", "\Z", "\'", '\"'), |
|
1014 | - array("\\", "\0", "\n", "\r", "\x1a", "'", '"'), |
|
1013 | + return str_replace(array("\\\\", "\\0", "\\n", "\\r", "\Z", "\'", '\"'), |
|
1014 | + array("\\", "\0", "\n", "\r", "\x1a", "'", '"'), |
|
1015 | 1015 | $value); |
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | |
1019 | 1019 | private function has_serialized($s) |
1020 | 1020 | { |
1021 | - if( |
|
1022 | - stristr($s, '{' ) != false && |
|
1023 | - stristr($s, '}' ) != false && |
|
1024 | - stristr($s, ';' ) != false && |
|
1025 | - stristr($s, ':' ) != false |
|
1026 | - ){ |
|
1021 | + if ( |
|
1022 | + stristr($s, '{') != false && |
|
1023 | + stristr($s, '}') != false && |
|
1024 | + stristr($s, ';') != false && |
|
1025 | + stristr($s, ':') != false |
|
1026 | + ) { |
|
1027 | 1027 | return true; |
1028 | - }else{ |
|
1028 | + } else { |
|
1029 | 1029 | return false; |
1030 | 1030 | } |
1031 | 1031 |
@@ -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 | - $xcloner_scheduler_table = $wpdb->prefix . "xcloner_scheduler"; |
|
49 | + $xcloner_scheduler_table = $wpdb->prefix."xcloner_scheduler"; |
|
50 | 50 | |
51 | - if($installed_ver != $xcloner_db_version) |
|
51 | + if ($installed_ver != $xcloner_db_version) |
|
52 | 52 | { |
53 | - $xcloner_schedule_sql="CREATE TABLE `".$xcloner_scheduler_table."` ( |
|
53 | + $xcloner_schedule_sql = "CREATE TABLE `".$xcloner_scheduler_table."` ( |
|
54 | 54 | `id` int(11) NOT NULL AUTO_INCREMENT, |
55 | 55 | `name` varchar(255) NOT NULL, |
56 | 56 | `recurrence` varchar(25) NOT NULL, |
@@ -64,53 +64,53 @@ discard block |
||
64 | 64 | ) ".$charset_collate."; |
65 | 65 | "; |
66 | 66 | |
67 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
68 | - dbDelta( $xcloner_schedule_sql ); |
|
67 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
68 | + dbDelta($xcloner_schedule_sql); |
|
69 | 69 | |
70 | - update_option( "xcloner_db_version", $xcloner_db_version ); |
|
70 | + update_option("xcloner_db_version", $xcloner_db_version); |
|
71 | 71 | } |
72 | 72 | |
73 | - if(get_option('xcloner_backup_compression_level') === false) |
|
73 | + if (get_option('xcloner_backup_compression_level') === false) |
|
74 | 74 | update_option('xcloner_backup_compression_level', 0); |
75 | 75 | |
76 | - if(get_option('xcloner_enable_log') === false) |
|
76 | + if (get_option('xcloner_enable_log') === false) |
|
77 | 77 | update_option('xcloner_enable_log', 1); |
78 | 78 | |
79 | - if(get_option('xcloner_enable_mysql_backup') === false) |
|
79 | + if (get_option('xcloner_enable_mysql_backup') === false) |
|
80 | 80 | update_option('xcloner_enable_mysql_backup', 1); |
81 | 81 | |
82 | - if(get_option('xcloner_system_settings_page') === false) |
|
82 | + if (get_option('xcloner_system_settings_page') === false) |
|
83 | 83 | update_option('xcloner_system_settings_page', 100); |
84 | 84 | |
85 | - if(get_option('xcloner_files_to_process_per_request') === false) |
|
85 | + if (get_option('xcloner_files_to_process_per_request') === false) |
|
86 | 86 | update_option('xcloner_files_to_process_per_request', 250); |
87 | 87 | |
88 | - if(get_option('xcloner_database_records_per_request') === false) |
|
88 | + if (get_option('xcloner_database_records_per_request') === false) |
|
89 | 89 | update_option('xcloner_database_records_per_request', 10000); |
90 | 90 | |
91 | - if(get_option('xcloner_exclude_files_larger_than_mb') === false) |
|
91 | + if (get_option('xcloner_exclude_files_larger_than_mb') === false) |
|
92 | 92 | update_option('xcloner_exclude_files_larger_than_mb', 0); |
93 | 93 | |
94 | - if(get_option('xcloner_split_backup_limit') === false) |
|
94 | + if (get_option('xcloner_split_backup_limit') === false) |
|
95 | 95 | update_option('xcloner_split_backup_limit', 2048); |
96 | 96 | |
97 | - if(get_option('xcloner_size_limit_per_request') === false) |
|
97 | + if (get_option('xcloner_size_limit_per_request') === false) |
|
98 | 98 | update_option('xcloner_size_limit_per_request', 50); |
99 | 99 | |
100 | - if(get_option('xcloner_cleanup_retention_limit_days') === false) |
|
100 | + if (get_option('xcloner_cleanup_retention_limit_days') === false) |
|
101 | 101 | update_option('xcloner_cleanup_retention_limit_days', 60); |
102 | 102 | |
103 | - if(get_option('xcloner_cleanup_retention_limit_archives') === false) |
|
103 | + if (get_option('xcloner_cleanup_retention_limit_archives') === false) |
|
104 | 104 | update_option('xcloner_cleanup_retention_limit_archives', 100); |
105 | 105 | |
106 | - if(get_option('xcloner_directories_to_scan_per_request') === false) |
|
106 | + if (get_option('xcloner_directories_to_scan_per_request') === false) |
|
107 | 107 | update_option('xcloner_directories_to_scan_per_request', 25); |
108 | 108 | |
109 | 109 | /*if(!get_option('xcloner_diff_backup_recreate_period')) |
110 | 110 | update_option('xcloner_diff_backup_recreate_period', 10); |
111 | 111 | * */ |
112 | 112 | |
113 | - if(!get_option('xcloner_regex_exclude')) |
|
113 | + if (!get_option('xcloner_regex_exclude')) |
|
114 | 114 | update_option('xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$".PHP_EOL."(.*)\.(svn|git)(.*)$".PHP_EOL."wp-content\/cache(.*)$".PHP_EOL."(.*)error_log$"); |
115 | 115 | |
116 | 116 | } |
@@ -70,48 +70,61 @@ |
||
70 | 70 | update_option( "xcloner_db_version", $xcloner_db_version ); |
71 | 71 | } |
72 | 72 | |
73 | - if(get_option('xcloner_backup_compression_level') === false) |
|
74 | - update_option('xcloner_backup_compression_level', 0); |
|
73 | + if(get_option('xcloner_backup_compression_level') === false) { |
|
74 | + update_option('xcloner_backup_compression_level', 0); |
|
75 | + } |
|
75 | 76 | |
76 | - if(get_option('xcloner_enable_log') === false) |
|
77 | - update_option('xcloner_enable_log', 1); |
|
77 | + if(get_option('xcloner_enable_log') === false) { |
|
78 | + update_option('xcloner_enable_log', 1); |
|
79 | + } |
|
78 | 80 | |
79 | - if(get_option('xcloner_enable_mysql_backup') === false) |
|
80 | - update_option('xcloner_enable_mysql_backup', 1); |
|
81 | + if(get_option('xcloner_enable_mysql_backup') === false) { |
|
82 | + update_option('xcloner_enable_mysql_backup', 1); |
|
83 | + } |
|
81 | 84 | |
82 | - if(get_option('xcloner_system_settings_page') === false) |
|
83 | - update_option('xcloner_system_settings_page', 100); |
|
85 | + if(get_option('xcloner_system_settings_page') === false) { |
|
86 | + update_option('xcloner_system_settings_page', 100); |
|
87 | + } |
|
84 | 88 | |
85 | - if(get_option('xcloner_files_to_process_per_request') === false) |
|
86 | - update_option('xcloner_files_to_process_per_request', 250); |
|
89 | + if(get_option('xcloner_files_to_process_per_request') === false) { |
|
90 | + update_option('xcloner_files_to_process_per_request', 250); |
|
91 | + } |
|
87 | 92 | |
88 | - if(get_option('xcloner_database_records_per_request') === false) |
|
89 | - update_option('xcloner_database_records_per_request', 10000); |
|
93 | + if(get_option('xcloner_database_records_per_request') === false) { |
|
94 | + update_option('xcloner_database_records_per_request', 10000); |
|
95 | + } |
|
90 | 96 | |
91 | - if(get_option('xcloner_exclude_files_larger_than_mb') === false) |
|
92 | - update_option('xcloner_exclude_files_larger_than_mb', 0); |
|
97 | + if(get_option('xcloner_exclude_files_larger_than_mb') === false) { |
|
98 | + update_option('xcloner_exclude_files_larger_than_mb', 0); |
|
99 | + } |
|
93 | 100 | |
94 | - if(get_option('xcloner_split_backup_limit') === false) |
|
95 | - update_option('xcloner_split_backup_limit', 2048); |
|
101 | + if(get_option('xcloner_split_backup_limit') === false) { |
|
102 | + update_option('xcloner_split_backup_limit', 2048); |
|
103 | + } |
|
96 | 104 | |
97 | - if(get_option('xcloner_size_limit_per_request') === false) |
|
98 | - update_option('xcloner_size_limit_per_request', 50); |
|
105 | + if(get_option('xcloner_size_limit_per_request') === false) { |
|
106 | + update_option('xcloner_size_limit_per_request', 50); |
|
107 | + } |
|
99 | 108 | |
100 | - if(get_option('xcloner_cleanup_retention_limit_days') === false) |
|
101 | - update_option('xcloner_cleanup_retention_limit_days', 60); |
|
109 | + if(get_option('xcloner_cleanup_retention_limit_days') === false) { |
|
110 | + update_option('xcloner_cleanup_retention_limit_days', 60); |
|
111 | + } |
|
102 | 112 | |
103 | - if(get_option('xcloner_cleanup_retention_limit_archives') === false) |
|
104 | - update_option('xcloner_cleanup_retention_limit_archives', 100); |
|
113 | + if(get_option('xcloner_cleanup_retention_limit_archives') === false) { |
|
114 | + update_option('xcloner_cleanup_retention_limit_archives', 100); |
|
115 | + } |
|
105 | 116 | |
106 | - if(get_option('xcloner_directories_to_scan_per_request') === false) |
|
107 | - update_option('xcloner_directories_to_scan_per_request', 25); |
|
117 | + if(get_option('xcloner_directories_to_scan_per_request') === false) { |
|
118 | + update_option('xcloner_directories_to_scan_per_request', 25); |
|
119 | + } |
|
108 | 120 | |
109 | 121 | /*if(!get_option('xcloner_diff_backup_recreate_period')) |
110 | 122 | update_option('xcloner_diff_backup_recreate_period', 10); |
111 | 123 | * */ |
112 | 124 | |
113 | - if(!get_option('xcloner_regex_exclude')) |
|
114 | - update_option('xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$".PHP_EOL."(.*)\.(svn|git)(.*)$".PHP_EOL."wp-content\/cache(.*)$".PHP_EOL."(.*)error_log$"); |
|
125 | + if(!get_option('xcloner_regex_exclude')) { |
|
126 | + update_option('xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$".PHP_EOL."(.*)\.(svn|git)(.*)$".PHP_EOL."wp-content\/cache(.*)$".PHP_EOL."(.*)error_log$"); |
|
127 | + } |
|
115 | 128 | |
116 | 129 | } |
117 | 130 |
@@ -31,8 +31,9 @@ discard block |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | //i will not load the plugin outside admin or cron |
34 | -if(!is_admin() and !defined('DOING_CRON')) |
|
34 | +if(!is_admin() and !defined('DOING_CRON')) { |
|
35 | 35 | return; |
36 | +} |
|
36 | 37 | |
37 | 38 | if(!defined("DS")) |
38 | 39 | { |
@@ -126,7 +127,7 @@ discard block |
||
126 | 127 | |
127 | 128 | $xcloner_plugin = run_xcloner(); |
128 | 129 | |
129 | -}catch(Exception $e){ |
|
130 | +} catch(Exception $e){ |
|
130 | 131 | |
131 | 132 | echo $e->getMessage(); |
132 | 133 |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | */ |
27 | 27 | |
28 | 28 | // If this file is called directly, abort. |
29 | -if ( ! defined( 'WPINC' ) ) { |
|
29 | +if (!defined('WPINC')) { |
|
30 | 30 | die; |
31 | 31 | } |
32 | 32 | |
33 | 33 | //i will not load the plugin outside admin or cron |
34 | -if(!is_admin() and !defined('DOING_CRON')) |
|
34 | +if (!is_admin() and !defined('DOING_CRON')) |
|
35 | 35 | return; |
36 | 36 | |
37 | -if(!defined("DS")) |
|
37 | +if (!defined("DS")) |
|
38 | 38 | { |
39 | 39 | define("DS", DIRECTORY_SEPARATOR); |
40 | 40 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | function activate_xcloner() |
47 | 47 | { |
48 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-xcloner-activator.php'; |
|
48 | + require_once plugin_dir_path(__FILE__).'includes/class-xcloner-activator.php'; |
|
49 | 49 | Xcloner_Activator::activate(); |
50 | 50 | } |
51 | 51 | |
@@ -55,31 +55,31 @@ discard block |
||
55 | 55 | */ |
56 | 56 | function deactivate_xcloner() |
57 | 57 | { |
58 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-xcloner-deactivator.php'; |
|
58 | + require_once plugin_dir_path(__FILE__).'includes/class-xcloner-deactivator.php'; |
|
59 | 59 | Xcloner_Deactivator::deactivate(); |
60 | 60 | } |
61 | 61 | |
62 | -register_activation_hook( __FILE__, 'activate_xcloner' ); |
|
63 | -register_deactivation_hook( __FILE__, 'deactivate_xcloner' ); |
|
62 | +register_activation_hook(__FILE__, 'activate_xcloner'); |
|
63 | +register_deactivation_hook(__FILE__, 'deactivate_xcloner'); |
|
64 | 64 | |
65 | -require_once plugin_dir_path( __FILE__ ) . 'includes/class-xcloner-activator.php'; |
|
65 | +require_once plugin_dir_path(__FILE__).'includes/class-xcloner-activator.php'; |
|
66 | 66 | |
67 | -if(version_compare(phpversion(), Xcloner_Activator::xcloner_minimum_version, '<')) |
|
67 | +if (version_compare(phpversion(), Xcloner_Activator::xcloner_minimum_version, '<')) |
|
68 | 68 | { |
69 | 69 | ?> |
70 | 70 | <div class="error notice"> |
71 | - <p><?php echo sprintf(__("XCloner requires minimum PHP version %s in order to run correctly. We have detected your version as %s. Plugin is now deactivated."),Xcloner_Activator::xcloner_minimum_version, phpversion())?></p> |
|
71 | + <p><?php echo sprintf(__("XCloner requires minimum PHP version %s in order to run correctly. We have detected your version as %s. Plugin is now deactivated."), Xcloner_Activator::xcloner_minimum_version, phpversion())?></p> |
|
72 | 72 | </div> |
73 | 73 | <?php |
74 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
75 | - deactivate_plugins( plugin_basename( __FILE__ ) ); |
|
74 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
75 | + deactivate_plugins(plugin_basename(__FILE__)); |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 | |
79 | -$db_installed_ver = get_option( "xcloner_db_version" ); |
|
79 | +$db_installed_ver = get_option("xcloner_db_version"); |
|
80 | 80 | $xcloner_db_version = Xcloner_Activator::xcloner_db_version; |
81 | 81 | |
82 | -if($db_installed_ver != $xcloner_db_version) |
|
82 | +if ($db_installed_ver != $xcloner_db_version) |
|
83 | 83 | { |
84 | 84 | Xcloner_Activator::activate(); |
85 | 85 | } |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | wp_deregister_script('heartbeat'); |
95 | 95 | } |
96 | 96 | |
97 | -if(isset($_GET['page']) and stristr($_GET['page'] , "xcloner_")) |
|
97 | +if (isset($_GET['page']) and stristr($_GET['page'], "xcloner_")) |
|
98 | 98 | { |
99 | - add_action( 'init', 'xcloner_stop_heartbeat', 1 ); |
|
99 | + add_action('init', 'xcloner_stop_heartbeat', 1); |
|
100 | 100 | |
101 | 101 | } |
102 | 102 | |
@@ -120,14 +120,14 @@ discard block |
||
120 | 120 | |
121 | 121 | } |
122 | 122 | |
123 | -require_once(plugin_dir_path( __FILE__ ) . '/vendor/autoload.php'); |
|
124 | -require plugin_dir_path( __FILE__ ) . 'includes/class-xcloner.php'; |
|
123 | +require_once(plugin_dir_path(__FILE__).'/vendor/autoload.php'); |
|
124 | +require plugin_dir_path(__FILE__).'includes/class-xcloner.php'; |
|
125 | 125 | |
126 | -try{ |
|
126 | +try { |
|
127 | 127 | |
128 | 128 | $xcloner_plugin = run_xcloner(); |
129 | 129 | |
130 | -}catch(Exception $e){ |
|
130 | +}catch (Exception $e) { |
|
131 | 131 | |
132 | 132 | echo $e->getMessage(); |
133 | 133 |