@@ -612,10 +612,10 @@ |
||
612 | 612 | |
613 | 613 | } |
614 | 614 | |
615 | - /** |
|
616 | - * @param $schedules |
|
617 | - * @return mixed |
|
618 | - */ |
|
615 | + /** |
|
616 | + * @param $schedules |
|
617 | + * @return mixed |
|
618 | + */ |
|
619 | 619 | public function add_new_intervals($schedules) |
620 | 620 | { |
621 | 621 | //weekly scheduler interval |
@@ -489,7 +489,7 @@ |
||
489 | 489 | |
490 | 490 | try { |
491 | 491 | $this->xcloner_scheduler->xcloner_scheduler_callback(0, $schedule); |
492 | - }catch (Exception $e) { |
|
492 | + } catch (Exception $e) { |
|
493 | 493 | $this->get_xcloner_logger()->error($e->getMessage()); |
494 | 494 | } |
495 | 495 |
@@ -1324,18 +1324,18 @@ |
||
1324 | 1324 | if (file_exists($tmp_file)) { |
1325 | 1325 | header('Content-Description: File Transfer'); |
1326 | 1326 | header('Content-Type: application/octet-stream'); |
1327 | - header('Content-Disposition: attachment; filename="' . basename($tmp_file) . '"'); |
|
1327 | + header('Content-Disposition: attachment; filename="'.basename($tmp_file).'"'); |
|
1328 | 1328 | header('Expires: 0'); |
1329 | 1329 | header('Cache-Control: must-revalidate'); |
1330 | 1330 | header('Pragma: public'); |
1331 | - header('Content-Length: ' . filesize($tmp_file)); |
|
1331 | + header('Content-Length: '.filesize($tmp_file)); |
|
1332 | 1332 | readfile($tmp_file); |
1333 | 1333 | |
1334 | 1334 | } |
1335 | 1335 | |
1336 | 1336 | try { |
1337 | 1337 | unlink($tmp_file); |
1338 | - }catch(Exception $e) { |
|
1338 | + }catch (Exception $e) { |
|
1339 | 1339 | //We are not interested in the error here |
1340 | 1340 | } |
1341 | 1341 |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | try { |
138 | 138 | $this->xcloner_database->init($data); |
139 | 139 | |
140 | - }catch (Exception $e) { |
|
140 | + } catch (Exception $e) { |
|
141 | 141 | |
142 | 142 | $this->send_response($e->getMessage()); |
143 | 143 | $this->logger->error($e->getMessage()); |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | try { |
313 | 313 | $return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], |
314 | 314 | $this->form_params['extra'], $init); |
315 | - }catch (Exception $e) { |
|
315 | + } catch (Exception $e) { |
|
316 | 316 | $return = array(); |
317 | 317 | $return['error'] = true; |
318 | 318 | $return['status'] = 500; |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | $additional['lines_total'] = $return['extra']['lines_total']; |
340 | 340 | $this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'], |
341 | 341 | $this->form_params, "", $additional); |
342 | - }catch (Exception $e) { |
|
342 | + } catch (Exception $e) { |
|
343 | 343 | $this->logger->error($e->getMessage()); |
344 | 344 | } |
345 | 345 | } |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | |
523 | 523 | try { |
524 | 524 | $files = $this->xcloner_file_system->list_directory($folder); |
525 | - }catch (Exception $e) { |
|
525 | + } catch (Exception $e) { |
|
526 | 526 | |
527 | 527 | print $e->getMessage(); |
528 | 528 | $this->logger->error($e->getMessage()); |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | if ($database == "#") { |
587 | 587 | try { |
588 | 588 | $return = $this->xcloner_database->get_all_databases(); |
589 | - }catch (Exception $e) { |
|
589 | + } catch (Exception $e) { |
|
590 | 590 | $this->logger->error($e->getMessage()); |
591 | 591 | } |
592 | 592 | |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | |
619 | 619 | try { |
620 | 620 | $return = $this->xcloner_database->list_tables($database, "", 1); |
621 | - }catch (Exception $e) { |
|
621 | + } catch (Exception $e) { |
|
622 | 622 | $this->logger->error($e->getMessage()); |
623 | 623 | } |
624 | 624 | |
@@ -848,7 +848,7 @@ discard block |
||
848 | 848 | $this->logger->info($iv); |
849 | 849 | $return = array_merge($return, |
850 | 850 | $this->xcloner_encryption->encrypt_file($backup_file, "", "", $start, base64_decode($iv))); |
851 | - }catch (\Exception $e) { |
|
851 | + } catch (\Exception $e) { |
|
852 | 852 | $return['error'] = true; |
853 | 853 | $return['message'] = $e->getMessage(); |
854 | 854 | $return['error_message'] = $e->getMessage(); |
@@ -905,7 +905,7 @@ discard block |
||
905 | 905 | try { |
906 | 906 | $return = array_merge($return, |
907 | 907 | $this->xcloner_encryption->decrypt_file($backup_file, "", $decryption_key, $start, base64_decode($iv))); |
908 | - }catch (\Exception $e) { |
|
908 | + } catch (\Exception $e) { |
|
909 | 909 | $return['error'] = true; |
910 | 910 | $return['message'] = $e->getMessage(); |
911 | 911 | } |
@@ -1009,7 +1009,8 @@ discard block |
||
1009 | 1009 | title="<?php echo __('Backup Decryption', 'xcloner-backup-and-restore') ?>"> |
1010 | 1010 | <i class="material-icons">enhanced_encryption</i> |
1011 | 1011 | </a> |
1012 | - <?php else: ?> |
|
1012 | + <?php else { |
|
1013 | + : ?> |
|
1013 | 1014 | <a href="#<?php echo $child[0] ?>" class="list-backup-content" |
1014 | 1015 | title="<?php echo __('List Backup Content', |
1015 | 1016 | 'xcloner-backup-and-restore') ?>"><i |
@@ -1028,7 +1029,9 @@ discard block |
||
1028 | 1029 | class="material-icons">file_upload</i></a> |
1029 | 1030 | <?php endif ?> |
1030 | 1031 | </li> |
1031 | - <?php endforeach; ?> |
|
1032 | + <?php endforeach; |
|
1033 | +} |
|
1034 | +?> |
|
1032 | 1035 | </ul> |
1033 | 1036 | <?php endif; ?> |
1034 | 1037 | <?php |
@@ -1036,11 +1039,12 @@ discard block |
||
1036 | 1039 | ob_end_clean(); |
1037 | 1040 | ?> |
1038 | 1041 | <?php ob_start(); ?> |
1039 | - <?php if (isset($file_info['timestamp'])) |
|
1042 | + <?php if (isset($file_info['timestamp'])) { |
|
1040 | 1043 | echo date("Y-m-d H:i", $file_info['timestamp']) |
1041 | 1044 | ?> |
1042 | 1045 | <?php |
1043 | 1046 | $return['data'][$i][] = ob_get_contents(); |
1047 | +} |
|
1044 | 1048 | ob_end_clean(); |
1045 | 1049 | ?> |
1046 | 1050 | |
@@ -1065,15 +1069,17 @@ discard block |
||
1065 | 1069 | <?php endif ?> |
1066 | 1070 | <?php |
1067 | 1071 | $basename = $file_info['basename']; |
1068 | - if (isset($file_info['childs']) and sizeof($file_info['childs'])) |
|
1069 | - $basename = $file_info['childs'][0][0]; |
|
1072 | + if (isset($file_info['childs']) and sizeof($file_info['childs'])) { |
|
1073 | + $basename = $file_info['childs'][0][0]; |
|
1074 | + } |
|
1070 | 1075 | ?> |
1071 | 1076 | <?php if ($this->xcloner_encryption->is_encrypted_file($basename)) :?> |
1072 | 1077 | <a href="#<?php echo $file_info['basename'] ?>" class="backup-decryption" |
1073 | 1078 | title="<?php echo __('Backup Decryption', 'xcloner-backup-and-restore') ?>"> |
1074 | 1079 | <i class="material-icons">enhanced_encryption</i> |
1075 | 1080 | </a> |
1076 | - <?php else: ?> |
|
1081 | + <?php else { |
|
1082 | + : ?> |
|
1077 | 1083 | <a href="#<?php echo $file_info['basename'] ?>" class="list-backup-content" |
1078 | 1084 | title="<?php echo __('List Backup Content', 'xcloner-backup-and-restore') ?>"><i |
1079 | 1085 | class="material-icons">folder_open</i></a> |
@@ -1083,7 +1089,9 @@ discard block |
||
1083 | 1089 | <i class="material-icons">no_encryption</i> |
1084 | 1090 | </a> |
1085 | 1091 | <?php endif?> |
1086 | - <?php endif; ?> |
|
1092 | + <?php endif; |
|
1093 | +} |
|
1094 | +?> |
|
1087 | 1095 | |
1088 | 1096 | <a href="#<?php echo $file_info['basename'] ?>" class="delete" |
1089 | 1097 | title="<?php echo __('Delete Backup', 'xcloner-backup-and-restore') ?>"> |
@@ -1137,7 +1145,7 @@ discard block |
||
1137 | 1145 | $tar->open($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file, $start); |
1138 | 1146 | |
1139 | 1147 | $data = $tar->contents(get_option('xcloner_files_to_process_per_request')); |
1140 | - }catch (Exception $e) { |
|
1148 | + } catch (Exception $e) { |
|
1141 | 1149 | $return['error'] = true; |
1142 | 1150 | $return['message'] = $e->getMessage(); |
1143 | 1151 | $this->send_response($return, 0); |
@@ -1200,7 +1208,7 @@ discard block |
||
1200 | 1208 | "copy_backup_remote_to_local" |
1201 | 1209 | ), array($backup_file, $storage_type)); |
1202 | 1210 | } |
1203 | - }catch (Exception $e) { |
|
1211 | + } catch (Exception $e) { |
|
1204 | 1212 | |
1205 | 1213 | $return['error'] = 1; |
1206 | 1214 | $return['message'] = $e->getMessage(); |
@@ -1239,7 +1247,7 @@ discard block |
||
1239 | 1247 | "upload_backup_to_storage" |
1240 | 1248 | ), array($backup_file, $storage_type)); |
1241 | 1249 | } |
1242 | - }catch (Exception $e) { |
|
1250 | + } catch (Exception $e) { |
|
1243 | 1251 | |
1244 | 1252 | $return['error'] = 1; |
1245 | 1253 | $return['message'] = $e->getMessage(); |
@@ -1335,7 +1343,7 @@ discard block |
||
1335 | 1343 | |
1336 | 1344 | try { |
1337 | 1345 | unlink($tmp_file); |
1338 | - }catch(Exception $e) { |
|
1346 | + } catch(Exception $e) { |
|
1339 | 1347 | //We are not interested in the error here |
1340 | 1348 | } |
1341 | 1349 | |
@@ -1430,7 +1438,7 @@ discard block |
||
1430 | 1438 | $xcloner_file_transfer->set_target($target_url); |
1431 | 1439 | $return['start'] = $xcloner_file_transfer->transfer_file($file, $start, $hash); |
1432 | 1440 | |
1433 | - }catch (Exception $e) { |
|
1441 | + } catch (Exception $e) { |
|
1434 | 1442 | |
1435 | 1443 | $return = array(); |
1436 | 1444 | $return['error'] = true; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | foreach ($list as $schedule) { |
104 | 104 | $hook = 'xcloner_scheduler_'.$schedule->id; |
105 | 105 | |
106 | - if($timestamp = wp_next_scheduled($hook, array($schedule->id))) { |
|
106 | + if ($timestamp = wp_next_scheduled($hook, array($schedule->id))) { |
|
107 | 107 | wp_unschedule_event($timestamp, $hook, array($schedule->id)); |
108 | 108 | } |
109 | 109 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | } elseif (!$schedule->status) { |
130 | - if($timestamp = wp_next_scheduled($hook, array($schedule->id))) { |
|
130 | + if ($timestamp = wp_next_scheduled($hook, array($schedule->id))) { |
|
131 | 131 | wp_unschedule_event($timestamp, $hook, array($schedule->id)); |
132 | 132 | } |
133 | 133 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $schedule = $this->get_schedule_by_id_object($id); |
140 | 140 | $hook = 'xcloner_scheduler_'.$schedule->id; |
141 | 141 | |
142 | - if( $timestamp = wp_next_scheduled($hook, array($schedule->id))) { |
|
142 | + if ($timestamp = wp_next_scheduled($hook, array($schedule->id))) { |
|
143 | 143 | wp_unschedule_event($timestamp, $hook, array($schedule->id)); |
144 | 144 | } |
145 | 145 | |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | |
157 | 157 | public function disable_single_cron($schedule_id) { |
158 | 158 | $schedule = array(); |
159 | - $hook = 'xcloner_scheduler_'.$schedule_id; |
|
159 | + $hook = 'xcloner_scheduler_'.$schedule_id; |
|
160 | 160 | |
161 | - if($timestamp = wp_next_scheduled($hook, array($schedule_id))) { |
|
161 | + if ($timestamp = wp_next_scheduled($hook, array($schedule_id))) { |
|
162 | 162 | wp_unschedule_event($timestamp, $hook, array($schedule_id)); |
163 | 163 | } |
164 | 164 | |
@@ -215,13 +215,13 @@ discard block |
||
215 | 215 | return $update; |
216 | 216 | } |
217 | 217 | |
218 | - private function _xcloner_scheduler_callback( $id, $schedule ) { |
|
219 | - set_time_limit( 0 ); |
|
218 | + private function _xcloner_scheduler_callback($id, $schedule) { |
|
219 | + set_time_limit(0); |
|
220 | 220 | |
221 | 221 | |
222 | 222 | $xcloner = new XCloner(); |
223 | 223 | $xcloner->init(); |
224 | - $this->set_xcloner_container( $xcloner ); |
|
224 | + $this->set_xcloner_container($xcloner); |
|
225 | 225 | $return_encrypted = array(); |
226 | 226 | $return = array(); |
227 | 227 | $additional = array(); |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | |
369 | 369 | $this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'], $schedule, "", $additional); |
370 | 370 | |
371 | - }catch (Exception $e) { |
|
371 | + } catch (Exception $e) { |
|
372 | 372 | $this->logger->error($e->getMessage()); |
373 | 373 | } |
374 | 374 | } |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | } |
403 | 403 | $this->_xcloner_scheduler_callback($id, $schedule); |
404 | 404 | |
405 | - }catch (Exception $e) { |
|
405 | + } catch (Exception $e) { |
|
406 | 406 | |
407 | 407 | //send email to site admin if email notification is not set in the scheduler |
408 | 408 | if (!isset($schedule['backup_params']->email_notification) || !$schedule['backup_params']->email_notification) { |
@@ -166,26 +166,26 @@ |
||
166 | 166 | * Xcloner_Remote_Storage constructor. |
167 | 167 | * @param Xcloner $xcloner_container |
168 | 168 | */ |
169 | - public function __construct( Xcloner $xcloner_container ) { |
|
169 | + public function __construct(Xcloner $xcloner_container) { |
|
170 | 170 | $this->xcloner_sanitization = $xcloner_container->get_xcloner_sanitization(); |
171 | 171 | $this->xcloner_file_system = $xcloner_container->get_xcloner_filesystem(); |
172 | - $this->logger = $xcloner_container->get_xcloner_logger()->withName( "xcloner_remote_storage" ); |
|
172 | + $this->logger = $xcloner_container->get_xcloner_logger()->withName("xcloner_remote_storage"); |
|
173 | 173 | $this->xcloner = $xcloner_container; |
174 | 174 | |
175 | - foreach($this->storage_fields as $main_key=>$array){ |
|
175 | + foreach ($this->storage_fields as $main_key=>$array) { |
|
176 | 176 | |
177 | - if(is_array($array)) { |
|
177 | + if (is_array($array)) { |
|
178 | 178 | foreach ($array as $key => $type) { |
179 | 179 | |
180 | - if( $type == "raw") { |
|
181 | - add_filter("pre_update_option_" . $this->storage_fields['option_prefix'] . $key, |
|
182 | - function ($value) { |
|
180 | + if ($type == "raw") { |
|
181 | + add_filter("pre_update_option_".$this->storage_fields['option_prefix'].$key, |
|
182 | + function($value) { |
|
183 | 183 | |
184 | 184 | return $this->simple_crypt($value, 'e'); |
185 | 185 | |
186 | 186 | }, 10, 1); |
187 | 187 | |
188 | - add_filter("option_" . $this->storage_fields['option_prefix'] . $key, function ($value) { |
|
188 | + add_filter("option_".$this->storage_fields['option_prefix'].$key, function($value) { |
|
189 | 189 | |
190 | 190 | return $this->simple_crypt($value, 'd'); |
191 | 191 |
@@ -217,8 +217,7 @@ discard block |
||
217 | 217 | |
218 | 218 | if ($action == 'e' && function_exists('openssl_encrypt')) { |
219 | 219 | $output = base64_encode(openssl_encrypt($string, $encrypt_method, $key, 0, $iv)); |
220 | - } |
|
221 | - else if ($action == 'd' && function_exists('openssl_decrypt') && base64_decode($string)) { |
|
220 | + } else if ($action == 'd' && function_exists('openssl_decrypt') && base64_decode($string)) { |
|
222 | 221 | $decrypt = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv); |
223 | 222 | if ($decrypt) { |
224 | 223 | //we check if decrypt was succesful |
@@ -280,7 +279,7 @@ discard block |
||
280 | 279 | $this->verify_filesystem($action); |
281 | 280 | $this->xcloner->trigger_message(__("%s connection is valid.", 'xcloner-backup-and-restore'), "success", $this->storage_fields[$action]['text']); |
282 | 281 | $this->logger->debug(sprintf("Connection to remote storage %s is valid", strtoupper($action))); |
283 | - }catch (Exception $e) { |
|
282 | + } catch (Exception $e) { |
|
284 | 283 | $this->xcloner->trigger_message("%s connection error: ".$e->getMessage(), "error", $this->storage_fields[$action]['text']); |
285 | 284 | } |
286 | 285 | } |
@@ -93,12 +93,12 @@ |
||
93 | 93 | |
94 | 94 | $path = sys_get_temp_dir(); |
95 | 95 | if (!is_dir($path)) { |
96 | - try { |
|
97 | - mkdir($path); |
|
98 | - chmod($path, 0777); |
|
99 | - }catch(Exception $e){ |
|
100 | - //silent catch |
|
101 | - } |
|
96 | + try { |
|
97 | + mkdir($path); |
|
98 | + chmod($path, 0777); |
|
99 | + }catch(Exception $e){ |
|
100 | + //silent catch |
|
101 | + } |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | if (!is_dir($path) or !is_writeable($path)) { |
@@ -96,7 +96,7 @@ |
||
96 | 96 | try { |
97 | 97 | mkdir($path); |
98 | 98 | chmod($path, 0777); |
99 | - }catch(Exception $e){ |
|
99 | + }catch (Exception $e) { |
|
100 | 100 | //silent catch |
101 | 101 | } |
102 | 102 | } |
@@ -96,7 +96,7 @@ |
||
96 | 96 | try { |
97 | 97 | mkdir($path); |
98 | 98 | chmod($path, 0777); |
99 | - }catch(Exception $e){ |
|
99 | + } catch(Exception $e){ |
|
100 | 100 | //silent catch |
101 | 101 | } |
102 | 102 | } |