@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | <label> |
27 | 27 | Off |
28 | 28 | <input type="checkbox" name="xcloner_ftp_enable" class="status" |
29 | - value="1" <?php if (get_option("xcloner_ftp_enable")) |
|
29 | + value="1" <?php if (get_option("xcloner_ftp_enable")) { |
|
30 | 30 | echo "checked" ?> \> |
31 | 31 | <span class="lever"></span> |
32 | 32 | On |
@@ -340,6 +340,7 @@ discard block |
||
340 | 340 | value=""><?php echo __("Please Select AWS S3 Region or Leave Unselected for Custom Endpoint") ?></option> |
341 | 341 | <?php |
342 | 342 | $aws_regions = $remote_storage->get_aws_regions(); |
343 | +} |
|
343 | 344 | |
344 | 345 | foreach ($aws_regions as $key => $region) { |
345 | 346 | ?> |
@@ -423,7 +424,7 @@ discard block |
||
423 | 424 | <label> |
424 | 425 | Off |
425 | 426 | <input type="checkbox" name="xcloner_dropbox_enable" class="status" |
426 | - value="1" <?php if (get_option("xcloner_dropbox_enable")) |
|
427 | + value="1" <?php if (get_option("xcloner_dropbox_enable")) { |
|
427 | 428 | echo "checked" ?> \> |
428 | 429 | <span class="lever"></span> |
429 | 430 | On |
@@ -957,6 +958,7 @@ discard block |
||
957 | 958 | <div class="center"> |
958 | 959 | <?php |
959 | 960 | $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=xcloner-google-drive'), 'install-plugin_xcloner-google-drive'); |
961 | +} |
|
960 | 962 | ?> |
961 | 963 | <h6><?php echo __("This storage option requires the XCloner-Google-Drive Wordpress Plugin to be installed and activated.") ?></h6> |
962 | 964 | <h6><?php echo __("PHP 5.5 minimum version is required.") ?></h6> |
@@ -110,7 +110,8 @@ discard block |
||
110 | 110 | echo date($date_format." ".$time_format, $latest_backup['timestamp'] + (get_option('gmt_offset') * HOUR_IN_SECONDS)) |
111 | 111 | ?> |
112 | 112 | </div> |
113 | - <?php else: ?> |
|
113 | + <?php else { |
|
114 | + : ?> |
|
114 | 115 | <div class="item"> |
115 | 116 | <div class="title"><?php echo __("No Backup Yet", 'xcloner-backup-and-restore') ?></div> |
116 | 117 | </div> |
@@ -123,7 +124,9 @@ discard block |
||
123 | 124 | <div class="title"><?php echo __("Total Size", 'xcloner-backup-and-restore') ?> |
124 | 125 | : |
125 | 126 | </div> |
126 | - <?php echo size_format($xcloner_file_system->get_storage_usage()); ?> |
|
127 | + <?php echo size_format($xcloner_file_system->get_storage_usage()); |
|
128 | +} |
|
129 | +?> |
|
127 | 130 | </div> |
128 | 131 | </blockquote> |
129 | 132 | <h5><?php echo __("Next Scheduled Backup", 'xcloner-backup-and-restore') ?></h5> |
@@ -45,8 +45,7 @@ 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 | 51 | } else { |
@@ -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 | |
@@ -228,13 +227,15 @@ discard block |
||
228 | 227 | { |
229 | 228 | $target_file = filter_input(INPUT_POST, 'file', FILTER_SANITIZE_STRING); |
230 | 229 | |
231 | - if (!$_POST['start']) |
|
232 | - $fp = fopen($target_file, "wb+"); |
|
233 | - else |
|
234 | - $fp = fopen($target_file, "ab+"); |
|
230 | + if (!$_POST['start']) { |
|
231 | + $fp = fopen($target_file, "wb+"); |
|
232 | + } else { |
|
233 | + $fp = fopen($target_file, "ab+"); |
|
234 | + } |
|
235 | 235 | |
236 | - if (!$fp) |
|
237 | - throw new Exception("Unable to open $target_file file for writing"); |
|
236 | + if (!$fp) { |
|
237 | + throw new Exception("Unable to open $target_file file for writing"); |
|
238 | + } |
|
238 | 239 | |
239 | 240 | fseek($fp, $_POST['start']); |
240 | 241 | |
@@ -244,22 +245,24 @@ discard block |
||
244 | 245 | |
245 | 246 | $blob = file_get_contents($_FILES['blob']['tmp_name']); |
246 | 247 | |
247 | - if (!$bytes_written = fwrite($fp, $blob)) |
|
248 | - throw new Exception("Unable to write data to file $target_file"); |
|
248 | + if (!$bytes_written = fwrite($fp, $blob)) { |
|
249 | + throw new Exception("Unable to write data to file $target_file"); |
|
250 | + } |
|
249 | 251 | |
250 | 252 | try { |
251 | 253 | unlink($_FILES['blob']['tmp_name']); |
252 | - }catch (Exception $e) { |
|
254 | + } catch (Exception $e) { |
|
253 | 255 | |
254 | 256 | } |
255 | 257 | |
256 | - }elseif (isset($_POST['blob'])) { |
|
258 | + } elseif (isset($_POST['blob'])) { |
|
257 | 259 | $this->logger->debug(sprintf('Writing %s bytes to file %s starting position %s using POST blob', strlen($_POST['blob']), $target_file, $_POST['start'])); |
258 | 260 | |
259 | 261 | $blob = $_POST['blob']; |
260 | 262 | |
261 | - if (!$bytes_written = fwrite($fp, $blob)) |
|
262 | - throw new Exception("Unable to write data to file $target_file"); |
|
263 | + if (!$bytes_written = fwrite($fp, $blob)) { |
|
264 | + throw new Exception("Unable to write data to file $target_file"); |
|
265 | + } |
|
263 | 266 | } else { |
264 | 267 | throw new Exception("Upload failed, did not receive any binary data"); |
265 | 268 | } |
@@ -294,10 +297,11 @@ discard block |
||
294 | 297 | |
295 | 298 | $mysqli->query("SET sql_mode='';"); |
296 | 299 | $mysqli->query("SET foreign_key_checks = 0;"); |
297 | - if (isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file']) |
|
298 | - $mysqli->query("SET NAMES ".$_REQUEST['charset_of_file'].""); |
|
299 | - else |
|
300 | - $mysqli->query("SET NAMES utf8;"); |
|
300 | + if (isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file']) { |
|
301 | + $mysqli->query("SET NAMES ".$_REQUEST['charset_of_file'].""); |
|
302 | + } else { |
|
303 | + $mysqli->query("SET NAMES utf8;"); |
|
304 | + } |
|
301 | 305 | |
302 | 306 | return $mysqli; |
303 | 307 | } |
@@ -327,8 +331,9 @@ discard block |
||
327 | 331 | |
328 | 332 | $mysql_backup_file = $remote_path.DS.$mysqldump_file; |
329 | 333 | |
330 | - if (!file_exists($mysql_backup_file)) |
|
331 | - throw new Exception(sprintf("Mysql backup file %s does not exists", $mysql_backup_file)); |
|
334 | + if (!file_exists($mysql_backup_file)) { |
|
335 | + throw new Exception(sprintf("Mysql backup file %s does not exists", $mysql_backup_file)); |
|
336 | + } |
|
332 | 337 | |
333 | 338 | |
334 | 339 | /*if(defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS) |
@@ -360,16 +365,18 @@ discard block |
||
360 | 365 | // process the line read. |
361 | 366 | |
362 | 367 | //check if line is comment |
363 | - if (substr($line, 0, 1) == "#") |
|
364 | - continue; |
|
368 | + if (substr($line, 0, 1) == "#") { |
|
369 | + continue; |
|
370 | + } |
|
365 | 371 | |
366 | 372 | //check if line is empty |
367 | - if ($line == "\n" or trim($line) == "") |
|
368 | - continue; |
|
373 | + if ($line == "\n" or trim($line) == "") { |
|
374 | + continue; |
|
375 | + } |
|
369 | 376 | |
370 | - if (substr($line, strlen($line) - 2, strlen($line)) == ";\n") |
|
371 | - $query .= $line; |
|
372 | - else { |
|
377 | + if (substr($line, strlen($line) - 2, strlen($line)) == ";\n") { |
|
378 | + $query .= $line; |
|
379 | + } else { |
|
373 | 380 | $query .= $line; |
374 | 381 | continue; |
375 | 382 | } |
@@ -493,7 +500,7 @@ discard block |
||
493 | 500 | $tar->open($this->backup_storage_dir.DS.$backup_file, $start); |
494 | 501 | |
495 | 502 | $data = $tar->contents($this->process_files_limit_list); |
496 | - }catch (Exception $e) |
|
503 | + } catch (Exception $e) |
|
497 | 504 | { |
498 | 505 | $return['error'] = true; |
499 | 506 | $return['message'] = $e->getMessage(); |
@@ -528,8 +535,9 @@ discard block |
||
528 | 535 | |
529 | 536 | ++$return['part']; |
530 | 537 | |
531 | - if ($return['part'] < sizeof($backup_parts)) |
|
532 | - $return['finished'] = 0; |
|
538 | + if ($return['part'] < sizeof($backup_parts)) { |
|
539 | + $return['finished'] = 0; |
|
540 | + } |
|
533 | 541 | |
534 | 542 | } |
535 | 543 | } |
@@ -670,19 +678,22 @@ discard block |
||
670 | 678 | { |
671 | 679 | $config = file_get_contents($wp_config); |
672 | 680 | preg_match("/.*table_prefix.*=.*'(.*)'/i", $config, $matches); |
673 | - if (isset($matches[1])) |
|
674 | - $table_prefix = $matches[1]; |
|
675 | - else |
|
676 | - throw new Exception("Could not load wordpress table prefix from wp-config.php file."); |
|
681 | + if (isset($matches[1])) { |
|
682 | + $table_prefix = $matches[1]; |
|
683 | + } else { |
|
684 | + throw new Exception("Could not load wordpress table prefix from wp-config.php file."); |
|
685 | + } |
|
686 | + } else { |
|
687 | + throw new Exception("Could not update the SITEURL and HOME, wp-config.php file not found"); |
|
677 | 688 | } |
678 | - else |
|
679 | - throw new Exception("Could not update the SITEURL and HOME, wp-config.php file not found"); |
|
680 | 689 | |
681 | - if (!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='home'")) |
|
682 | - throw new Exception(sprintf("Could not update the HOME option, error: %s\n", $mysqli->error)); |
|
690 | + if (!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='home'")) { |
|
691 | + throw new Exception(sprintf("Could not update the HOME option, error: %s\n", $mysqli->error)); |
|
692 | + } |
|
683 | 693 | |
684 | - if (!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='siteurl'")) |
|
685 | - throw new Exception(sprintf("Could not update the SITEURL option, error: %s\n", $mysqli->error)); |
|
694 | + if (!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='siteurl'")) { |
|
695 | + throw new Exception(sprintf("Could not update the SITEURL option, error: %s\n", $mysqli->error)); |
|
696 | + } |
|
686 | 697 | |
687 | 698 | return true; |
688 | 699 | } |
@@ -720,8 +731,9 @@ discard block |
||
720 | 731 | |
721 | 732 | $this->logger->info(sprintf('Updating wp-config.php file with the new mysql details')); |
722 | 733 | |
723 | - if (!file_put_contents($wp_config, $content)) |
|
724 | - throw new Exception("Could not write updated config data to ".$wp_config); |
|
734 | + if (!file_put_contents($wp_config, $content)) { |
|
735 | + throw new Exception("Could not write updated config data to ".$wp_config); |
|
736 | + } |
|
725 | 737 | |
726 | 738 | chmod($wp_config, $file_perms); |
727 | 739 | |
@@ -766,10 +778,11 @@ discard block |
||
766 | 778 | $mysqldump_list[$file['path']]['size'] = $file['size']; |
767 | 779 | $mysqldump_list[$file['path']]['timestamp'] = date("d M,Y H:i", $file['timestamp']); |
768 | 780 | |
769 | - if ($hash and $hash == $matches[1]) |
|
770 | - $mysqldump_list[$file['path']]['selected'] = "selected"; |
|
771 | - else |
|
772 | - $mysqldump_list[$file['path']]['selected'] = ""; |
|
781 | + if ($hash and $hash == $matches[1]) { |
|
782 | + $mysqldump_list[$file['path']]['selected'] = "selected"; |
|
783 | + } else { |
|
784 | + $mysqldump_list[$file['path']]['selected'] = ""; |
|
785 | + } |
|
773 | 786 | } |
774 | 787 | } |
775 | 788 | } |
@@ -790,13 +803,15 @@ discard block |
||
790 | 803 | */ |
791 | 804 | private function get_hash_from_backup($backup_file) |
792 | 805 | { |
793 | - if (!$backup_file) |
|
794 | - return false; |
|
806 | + if (!$backup_file) { |
|
807 | + return false; |
|
808 | + } |
|
795 | 809 | |
796 | 810 | $result = preg_match("/-(\w*)./", substr($backup_file, strlen($backup_file) - 10, strlen($backup_file)), $matches); |
797 | 811 | |
798 | - if ($result and isset($matches[1])) |
|
799 | - return ($matches[1]); |
|
812 | + if ($result and isset($matches[1])) { |
|
813 | + return ($matches[1]); |
|
814 | + } |
|
800 | 815 | |
801 | 816 | return false; |
802 | 817 | } |
@@ -821,10 +836,11 @@ discard block |
||
821 | 836 | if (isset($file_info['extension']) and $file_info['extension'] == "csv") |
822 | 837 | { |
823 | 838 | $lines = explode(PHP_EOL, $this->filesystem->read($file_info['path'])); |
824 | - foreach ($lines as $line) |
|
825 | - if ($line) |
|
839 | + foreach ($lines as $line) { |
|
840 | + if ($line) |
|
826 | 841 | { |
827 | 842 | $data = str_getcsv($line); |
843 | + } |
|
828 | 844 | if (is_array($data)) { |
829 | 845 | $parents[$data[0]] = $file_info['path']; |
830 | 846 | $file_info['childs'][] = $data; |
@@ -834,20 +850,22 @@ discard block |
||
834 | 850 | |
835 | 851 | } |
836 | 852 | |
837 | - if ($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) |
|
838 | - $backup_files[$file_info['path']] = $file_info; |
|
853 | + if ($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) { |
|
854 | + $backup_files[$file_info['path']] = $file_info; |
|
855 | + } |
|
839 | 856 | } |
840 | 857 | |
841 | 858 | $new_list = array(); |
842 | 859 | |
843 | 860 | foreach ($backup_files as $key=>$file_info) |
844 | 861 | { |
845 | - if (isset($parents[$file_info['path']])) |
|
846 | - $backup_files[$key]['parent'] = $parents[$file_info['path']]; |
|
847 | - else { |
|
862 | + if (isset($parents[$file_info['path']])) { |
|
863 | + $backup_files[$key]['parent'] = $parents[$file_info['path']]; |
|
864 | + } else { |
|
848 | 865 | |
849 | - if ($local_backup_file and ($file_info['basename'] == $local_backup_file)) |
|
850 | - $file_info['selected'] = 'selected'; |
|
866 | + if ($local_backup_file and ($file_info['basename'] == $local_backup_file)) { |
|
867 | + $file_info['selected'] = 'selected'; |
|
868 | + } |
|
851 | 869 | |
852 | 870 | $this->logger->info(sprintf('Found %s backup file', $file_info['path'])); |
853 | 871 | |
@@ -894,8 +912,9 @@ discard block |
||
894 | 912 | $backup_archive = new Tar(); |
895 | 913 | if ($this->is_multipart($backup_file)) |
896 | 914 | { |
897 | - if (!$return['part']) |
|
898 | - $return['processed'] += $this->filesystem->getSize($backup_file); |
|
915 | + if (!$return['part']) { |
|
916 | + $return['processed'] += $this->filesystem->getSize($backup_file); |
|
917 | + } |
|
899 | 918 | |
900 | 919 | $backup_parts = $this->get_multipart_files($backup_file); |
901 | 920 | $backup_file = $backup_parts[$return['part']]; |
@@ -915,10 +934,11 @@ discard block |
||
915 | 934 | } |
916 | 935 | } |
917 | 936 | |
918 | - if (isset($data['start'])) |
|
919 | - //if(isset($data['start']) and $data['start'] <= $this->filesystem->getSize($backup_file)) |
|
937 | + if (isset($data['start'])) { |
|
938 | + //if(isset($data['start']) and $data['start'] <= $this->filesystem->getSize($backup_file)) |
|
920 | 939 | { |
921 | 940 | $return['finished'] = 0; |
941 | + } |
|
922 | 942 | $return['start'] = $data['start']; |
923 | 943 | } else { |
924 | 944 | |
@@ -930,14 +950,16 @@ discard block |
||
930 | 950 | |
931 | 951 | ++$return['part']; |
932 | 952 | |
933 | - if ($return['part'] < sizeof($backup_parts)) |
|
934 | - $return['finished'] = 0; |
|
953 | + if ($return['part'] < sizeof($backup_parts)) { |
|
954 | + $return['finished'] = 0; |
|
955 | + } |
|
935 | 956 | |
936 | 957 | } |
937 | 958 | } |
938 | 959 | |
939 | - if ($return['finished']) |
|
940 | - $this->logger->info(sprintf('Done extracting %s', $source_backup_file)); |
|
960 | + if ($return['finished']) { |
|
961 | + $this->logger->info(sprintf('Done extracting %s', $source_backup_file)); |
|
962 | + } |
|
941 | 963 | |
942 | 964 | $return['backup_file'] = $backup_file; |
943 | 965 | |
@@ -969,8 +991,7 @@ discard block |
||
969 | 991 | $return['remote_mysql_user'] = $wpdb->dbuser; |
970 | 992 | $return['remote_mysql_pass'] = $wpdb->dbpassword; |
971 | 993 | $return['remote_mysql_db'] = $wpdb->dbname; |
972 | - } |
|
973 | - else { |
|
994 | + } else { |
|
974 | 995 | $return['dir'] = ($pathinfo['dirname']).DS.$suffix; |
975 | 996 | $return['restore_script_url'] = str_replace($pathinfo['basename'], "", $restore_script_url).$suffix; |
976 | 997 | } |
@@ -989,11 +1010,13 @@ discard block |
||
989 | 1010 | { |
990 | 1011 | //check if i can write |
991 | 1012 | $tmp_file = md5(time()); |
992 | - if (!file_put_contents($tmp_file, "++")) |
|
993 | - throw new Exception("Could not write to new host"); |
|
1013 | + if (!file_put_contents($tmp_file, "++")) { |
|
1014 | + throw new Exception("Could not write to new host"); |
|
1015 | + } |
|
994 | 1016 | |
995 | - if (!unlink($tmp_file)) |
|
996 | - throw new Exception("Could not delete temporary file from new host"); |
|
1017 | + if (!unlink($tmp_file)) { |
|
1018 | + throw new Exception("Could not delete temporary file from new host"); |
|
1019 | + } |
|
997 | 1020 | |
998 | 1021 | $max_upload = $this->return_bytes((ini_get('upload_max_filesize'))); |
999 | 1022 | $max_post = $this->return_bytes((ini_get('post_max_size'))); |
@@ -1037,8 +1060,9 @@ discard block |
||
1037 | 1060 | */ |
1038 | 1061 | public function is_multipart($backup_name) |
1039 | 1062 | { |
1040 | - if (stristr($backup_name, "-multipart")) |
|
1041 | - return true; |
|
1063 | + if (stristr($backup_name, "-multipart")) { |
|
1064 | + return true; |
|
1065 | + } |
|
1042 | 1066 | |
1043 | 1067 | return false; |
1044 | 1068 | } |
@@ -1056,8 +1080,9 @@ discard block |
||
1056 | 1080 | if ($this->is_multipart($backup_name)) |
1057 | 1081 | { |
1058 | 1082 | $backup_parts = $this->get_multipart_files($backup_name); |
1059 | - foreach ($backup_parts as $part_file) |
|
1060 | - $backup_size += $this->filesystem->getSize($part_file); |
|
1083 | + foreach ($backup_parts as $part_file) { |
|
1084 | + $backup_size += $this->filesystem->getSize($part_file); |
|
1085 | + } |
|
1061 | 1086 | } |
1062 | 1087 | |
1063 | 1088 | return $backup_size; |
@@ -1119,15 +1144,13 @@ discard block |
||
1119 | 1144 | if ($direction == 'desc') { |
1120 | 1145 | if ($a > $b) { |
1121 | 1146 | return -1; |
1122 | - } |
|
1123 | - else { |
|
1147 | + } else { |
|
1124 | 1148 | return 1; |
1125 | 1149 | } |
1126 | 1150 | } else { |
1127 | 1151 | if ($a < $b) { |
1128 | 1152 | return -1; |
1129 | - } |
|
1130 | - else { |
|
1153 | + } else { |
|
1131 | 1154 | return 1; |
1132 | 1155 | } |
1133 | 1156 | } |
@@ -1157,7 +1180,7 @@ discard block |
||
1157 | 1180 | { |
1158 | 1181 | $return['statusText'] = $response['message']; |
1159 | 1182 | $return['error'] = true; |
1160 | - }elseif ($status != 200 and $status != 418) |
|
1183 | + } elseif ($status != 200 and $status != 418) |
|
1161 | 1184 | { |
1162 | 1185 | $return['error'] = true; |
1163 | 1186 | $return['message'] = $response; |
@@ -1181,8 +1204,9 @@ discard block |
||
1181 | 1204 | return preg_replace_callback('!s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!', function($m) { |
1182 | 1205 | $data = ""; |
1183 | 1206 | |
1184 | - if (!isset($m[3])) |
|
1185 | - $m[3] = ""; |
|
1207 | + if (!isset($m[3])) { |
|
1208 | + $m[3] = ""; |
|
1209 | + } |
|
1186 | 1210 | |
1187 | 1211 | $data = 's:'.strlen(($m[3])).':\"'.($m[3]).'\";'; |
1188 | 1212 | //return $this->unescape_quotes($data); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $this->storage_filesystem_append = new Filesystem($this->storage_adapter, new Config([ |
103 | 103 | 'disable_asserts' => true, |
104 | 104 | ])); |
105 | - }catch (Exception $e) { |
|
105 | + } catch (Exception $e) { |
|
106 | 106 | $this->logger->error("Filesystem Initialization Error: ".$e->getMessage()); |
107 | 107 | } |
108 | 108 | |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | } |
646 | 646 | } |
647 | 647 | |
648 | - }catch (Exception $e) { |
|
648 | + } catch (Exception $e) { |
|
649 | 649 | |
650 | 650 | $this->logger->error($e->getMessage()); |
651 | 651 | |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | |
673 | 673 | $this->tmp_filesystem->delete($tmp_file); |
674 | 674 | |
675 | - }catch (Exception $e) { |
|
675 | + } catch (Exception $e) { |
|
676 | 676 | |
677 | 677 | $this->logger->error($e->getMessage()); |
678 | 678 | |
@@ -710,9 +710,11 @@ discard block |
||
710 | 710 | foreach ($_backup_files_list as $file) { |
711 | 711 | //processing rule folder capacity |
712 | 712 | if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') && |
713 | - $_storage_size >= ($set_storage_limit = 1024 * 1024 * $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit'))) //bytes |
|
713 | + $_storage_size >= ($set_storage_limit = 1024 * 1024 * $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit'))) { |
|
714 | + //bytes |
|
714 | 715 | { |
715 | 716 | $this->storage_filesystem->delete($file['path']); |
717 | + } |
|
716 | 718 | $_storage_size -= $file['size']; |
717 | 719 | $this->logger->info("Deleting backup ".$file['path']." matching rule", array( |
718 | 720 | "STORAGE SIZE LIMIT", |
@@ -979,7 +981,7 @@ discard block |
||
979 | 981 | if ($file['type'] == "dir") { |
980 | 982 | try { |
981 | 983 | $this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file['path']."\n"); |
982 | - }catch (Exception $e) { |
|
984 | + } catch (Exception $e) { |
|
983 | 985 | $this->logger->error($e->getMessage()); |
984 | 986 | } |
985 | 987 | } |
@@ -1005,7 +1007,7 @@ discard block |
||
1005 | 1007 | |
1006 | 1008 | $this->tmp_filesystem_append->write($this->get_included_files_handler(), $line); |
1007 | 1009 | |
1008 | - }catch (Exception $e) { |
|
1010 | + } catch (Exception $e) { |
|
1009 | 1011 | |
1010 | 1012 | $this->logger->error($e->getMessage()); |
1011 | 1013 | } |
@@ -54,7 +54,7 @@ |
||
54 | 54 | if (is_a($xcloner_plugin, 'Xcloner')) { |
55 | 55 | try { |
56 | 56 | $xcloner_plugin->get_xcloner_filesystem()->cleanup_tmp_directories(); |
57 | - }catch (Exception $e) { |
|
57 | + } catch (Exception $e) { |
|
58 | 58 | $xcloner_plugin->trigger_message_notice($e->getMessage()); |
59 | 59 | } |
60 | 60 |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | |
378 | 378 | if(defined('DOING_CRON') || $_POST['hash'] == "generate_hash"){ |
379 | 379 | $this->xcloner_settings->generate_new_hash(); |
380 | - }else{ |
|
380 | + } else{ |
|
381 | 381 | $this->xcloner_settings->set_hash($_POST['hash']); |
382 | 382 | } |
383 | 383 | } |
@@ -489,7 +489,7 @@ discard block |
||
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 |
@@ -44,11 +44,13 @@ discard block |
||
44 | 44 | $this->xcloner_settings = $xcloner_container->get_xcloner_settings(); |
45 | 45 | $this->fs = $xcloner_container->get_xcloner_filesystem(); |
46 | 46 | |
47 | - if ($this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request')) |
|
48 | - $this->recordsPerSession = $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request'); |
|
47 | + if ($this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request')) { |
|
48 | + $this->recordsPerSession = $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request'); |
|
49 | + } |
|
49 | 50 | |
50 | - if (!$this->recordsPerSession) |
|
51 | - $this->recordsPerSession = 100; |
|
51 | + if (!$this->recordsPerSession) { |
|
52 | + $this->recordsPerSession = 100; |
|
53 | + } |
|
52 | 54 | |
53 | 55 | if (!$wp_user && !$wp_pass && !$wp_host && !$wp_db) |
54 | 56 | { |
@@ -108,37 +110,43 @@ discard block |
||
108 | 110 | { |
109 | 111 | foreach ($params['#'] as $database) |
110 | 112 | { |
111 | - if (!isset($params[$database]) or !is_array($params[$database])) |
|
112 | - $params[$database] = array(); |
|
113 | + if (!isset($params[$database]) or !is_array($params[$database])) { |
|
114 | + $params[$database] = array(); |
|
115 | + } |
|
113 | 116 | } |
114 | 117 | $db_count = -1; |
115 | 118 | } |
116 | 119 | |
117 | - if (isset($params) and is_array($params)) |
|
118 | - foreach ($params as $database=>$tables) |
|
120 | + if (isset($params) and is_array($params)) { |
|
121 | + foreach ($params as $database=>$tables) |
|
119 | 122 | { |
120 | 123 | if ($database != "#") |
121 | 124 | { |
122 | - $stats = $this->write_backup_process_list($database, $tables); |
|
125 | + $stats = $this->write_backup_process_list($database, $tables); |
|
126 | + } |
|
123 | 127 | $return['stats']['tables_count'] += $stats['tables_count']; |
124 | 128 | $return['stats']['total_records'] += $stats['total_records']; |
125 | 129 | } |
126 | 130 | } |
127 | 131 | |
128 | - if (sizeof($params)) |
|
129 | - $return['stats']['database_count'] = sizeof($params) + $db_count; |
|
130 | - else |
|
131 | - $return['stats']['database_count'] = 0; |
|
132 | + if (sizeof($params)) { |
|
133 | + $return['stats']['database_count'] = sizeof($params) + $db_count; |
|
134 | + } else { |
|
135 | + $return['stats']['database_count'] = 0; |
|
136 | + } |
|
132 | 137 | |
133 | 138 | return $return; |
134 | 139 | } |
135 | 140 | |
136 | - if (!isset($extra_params['startAtLine'])) |
|
137 | - $extra_params['startAtLine'] = 0; |
|
138 | - if (!isset($extra_params['startAtRecord'])) |
|
139 | - $extra_params['startAtRecord'] = 0; |
|
140 | - if (!isset($extra_params['dumpfile'])) |
|
141 | - $extra_params['dumpfile'] = ""; |
|
141 | + if (!isset($extra_params['startAtLine'])) { |
|
142 | + $extra_params['startAtLine'] = 0; |
|
143 | + } |
|
144 | + if (!isset($extra_params['startAtRecord'])) { |
|
145 | + $extra_params['startAtRecord'] = 0; |
|
146 | + } |
|
147 | + if (!isset($extra_params['dumpfile'])) { |
|
148 | + $extra_params['dumpfile'] = ""; |
|
149 | + } |
|
142 | 150 | |
143 | 151 | $return = $this->process_incremental($extra_params['startAtLine'], $extra_params['startAtRecord'], $extra_params['dumpfile']); |
144 | 152 | |
@@ -151,10 +159,12 @@ discard block |
||
151 | 159 | if ($message) { |
152 | 160 | $this->logger->info($message, array("")); |
153 | 161 | } else { |
154 | - if ($this->last_query) |
|
155 | - $this->logger->debug($this->last_query, array("")); |
|
156 | - if ($this->last_error) |
|
157 | - $this->logger->error($this->last_error, array("")); |
|
162 | + if ($this->last_query) { |
|
163 | + $this->logger->debug($this->last_query, array("")); |
|
164 | + } |
|
165 | + if ($this->last_error) { |
|
166 | + $this->logger->error($this->last_error, array("")); |
|
167 | + } |
|
158 | 168 | } |
159 | 169 | |
160 | 170 | return; |
@@ -225,11 +235,12 @@ discard block |
||
225 | 235 | $databases_list[$i]['num_tables'] = $this->get_database_num_tables($this->dbname); |
226 | 236 | $i++; |
227 | 237 | |
228 | - if (is_array($databases)) |
|
229 | - foreach ($databases as $db) { |
|
238 | + if (is_array($databases)) { |
|
239 | + foreach ($databases as $db) { |
|
230 | 240 | if ($db->Database != $this->dbname) |
231 | 241 | { |
232 | 242 | $databases_list[$i]['name'] = $db->Database; |
243 | + } |
|
233 | 244 | $databases_list[$i]['num_tables'] = $this->get_database_num_tables($db->Database); |
234 | 245 | $i++; |
235 | 246 | } |
@@ -252,8 +263,9 @@ discard block |
||
252 | 263 | $tablesList[0] = array( ); |
253 | 264 | $inc = 0; |
254 | 265 | |
255 | - if (!$database) |
|
256 | - $database = $this->dbname; |
|
266 | + if (!$database) { |
|
267 | + $database = $this->dbname; |
|
268 | + } |
|
257 | 269 | |
258 | 270 | $this->logger->debug(sprintf(("Listing tables in %s database"), $database)); |
259 | 271 | |
@@ -277,10 +289,11 @@ discard block |
||
277 | 289 | |
278 | 290 | $tablesList[$inc]['excluded'] = 0; |
279 | 291 | |
280 | - if (sizeof($included) and is_array($included)) |
|
281 | - if (!in_array($table, $included)) |
|
292 | + if (sizeof($included) and is_array($included)) { |
|
293 | + if (!in_array($table, $included)) |
|
282 | 294 | { |
283 | 295 | $tablesList[$inc]['excluded'] = 1; |
296 | + } |
|
284 | 297 | $this->log(sprintf(__("Excluding table %s.%s from backup"), $table, $database)); |
285 | 298 | } |
286 | 299 | $inc++; |
@@ -299,19 +312,21 @@ discard block |
||
299 | 312 | |
300 | 313 | $tables = $this->list_tables($dbname, $incl_tables, 1); |
301 | 314 | |
302 | - if ($this->dbname != $dbname) |
|
303 | - $dumpfile = $dbname."-backup.sql"; |
|
304 | - else |
|
305 | - $dumpfile = $this->TEMP_DUMP_FILE; |
|
315 | + if ($this->dbname != $dbname) { |
|
316 | + $dumpfile = $dbname."-backup.sql"; |
|
317 | + } else { |
|
318 | + $dumpfile = $this->TEMP_DUMP_FILE; |
|
319 | + } |
|
306 | 320 | |
307 | 321 | $line = sprintf("###newdump###\t%s\t%s\n", $dbname, $dumpfile); |
308 | 322 | $this->fs->get_tmp_filesystem_append()->write($this->TEMP_DBPROCESS_FILE, $line); |
309 | 323 | |
310 | 324 | // write this to the class and write to $TEMP_DBPROCESS_FILE file as database.table records |
311 | - foreach ($tables as $key=>$table) |
|
312 | - if ($table != "" and !$tables[$key]['excluded']) { |
|
325 | + foreach ($tables as $key=>$table) { |
|
326 | + if ($table != "" and !$tables[$key]['excluded']) { |
|
313 | 327 | |
314 | 328 | $line = sprintf("`%s`.`%s`\t%s\t%s\n", $dbname, $tables[$key]['name'], $tables[$key]['records'], $tables[$key]['excluded']); |
329 | + } |
|
315 | 330 | $this->fs->get_tmp_filesystem_append()->write($this->TEMP_DBPROCESS_FILE, $line); |
316 | 331 | $return['tables_count']++; |
317 | 332 | $return['total_records'] += $tables[$key]['records']; |
@@ -359,8 +374,9 @@ discard block |
||
359 | 374 | $return['finished'] = 0; |
360 | 375 | $lines = array(); |
361 | 376 | |
362 | - if ($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) |
|
363 | - $lines = array_filter(explode("\n", $this->fs->get_tmp_filesystem()->read($this->TEMP_DBPROCESS_FILE))); |
|
377 | + if ($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) { |
|
378 | + $lines = array_filter(explode("\n", $this->fs->get_tmp_filesystem()->read($this->TEMP_DBPROCESS_FILE))); |
|
379 | + } |
|
364 | 380 | |
365 | 381 | foreach ($lines as $buffer) { |
366 | 382 | |
@@ -387,12 +403,14 @@ discard block |
||
387 | 403 | //break; |
388 | 404 | } else { |
389 | 405 | //we export the table |
390 | - if ($tableInfo[0] == "###enddump###") |
|
391 | - $return['endDump'] = 1; |
|
406 | + if ($tableInfo[0] == "###enddump###") { |
|
407 | + $return['endDump'] = 1; |
|
408 | + } |
|
392 | 409 | |
393 | 410 | //table is excluded |
394 | - if ($tableInfo[2]) |
|
395 | - continue; |
|
411 | + if ($tableInfo[2]) { |
|
412 | + continue; |
|
413 | + } |
|
396 | 414 | |
397 | 415 | $next = $startAtRecord + $this->recordsPerSession; |
398 | 416 | |
@@ -408,14 +426,17 @@ discard block |
||
408 | 426 | |
409 | 427 | $processed_records = 0; |
410 | 428 | |
411 | - if (trim($tableName) != "" and !$tableInfo[2]) |
|
412 | - $processed_records = $this->export_table($databaseName, $tableName, $startAtRecord, $this->recordsPerSession, $dumpfile); |
|
429 | + if (trim($tableName) != "" and !$tableInfo[2]) { |
|
430 | + $processed_records = $this->export_table($databaseName, $tableName, $startAtRecord, $this->recordsPerSession, $dumpfile); |
|
431 | + } |
|
413 | 432 | |
414 | 433 | $return['processedRecords'] = $startAtRecord + $processed_records; |
415 | 434 | |
416 | - if ($next >= $tableInfo[1]) //we finished loading the records for next sessions, will go to the new record |
|
435 | + if ($next >= $tableInfo[1]) { |
|
436 | + //we finished loading the records for next sessions, will go to the new record |
|
417 | 437 | { |
418 | 438 | $startAtLine++; |
439 | + } |
|
419 | 440 | $startAtRecord = 0; |
420 | 441 | } else { |
421 | 442 | $startAtRecord = $startAtRecord + $this->recordsPerSession; |
@@ -450,8 +471,9 @@ discard block |
||
450 | 471 | $return['finished'] = 1; |
451 | 472 | $return['startAtLine'] = $startAtLine; |
452 | 473 | |
453 | - if ($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) |
|
454 | - $this->fs->get_tmp_filesystem()->delete($this->TEMP_DBPROCESS_FILE); |
|
474 | + if ($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) { |
|
475 | + $this->fs->get_tmp_filesystem()->delete($this->TEMP_DBPROCESS_FILE); |
|
476 | + } |
|
455 | 477 | |
456 | 478 | $this->logger->debug(sprintf(("Database backup finished!"))); |
457 | 479 | |
@@ -484,8 +506,9 @@ discard block |
||
484 | 506 | |
485 | 507 | $records = 0; |
486 | 508 | |
487 | - if ($start == 0) |
|
488 | - $this->dump_structure($databaseName, $tableName, $dumpfile); |
|
509 | + if ($start == 0) { |
|
510 | + $this->dump_structure($databaseName, $tableName, $dumpfile); |
|
511 | + } |
|
489 | 512 | |
490 | 513 | $start = intval($start); |
491 | 514 | $limit = intval($limit); |
@@ -24,7 +24,7 @@ |
||
24 | 24 | |
25 | 25 | try { |
26 | 26 | $option = Util::normalizePath($path); |
27 | - }catch (Exception $e) { |
|
27 | + } catch (Exception $e) { |
|
28 | 28 | add_settings_error('xcloner_error_message', '', __($e->getMessage()), 'error'); |
29 | 29 | } |
30 | 30 |
@@ -797,23 +797,23 @@ discard block |
||
797 | 797 | |
798 | 798 | if(isset($this->form_params['extra']['start'])) { |
799 | 799 | $start = $this->xcloner_sanitization->sanitize_input_as_int($this->form_params['extra']['start']); |
800 | - }else{ |
|
800 | + } else{ |
|
801 | 801 | $start = 0; |
802 | 802 | } |
803 | 803 | |
804 | 804 | if(isset($this->form_params['extra']['iv'])) { |
805 | 805 | $iv = $this->xcloner_sanitization->sanitize_input_as_raw($this->form_params['extra']['iv']); |
806 | - }else{ |
|
806 | + } else{ |
|
807 | 807 | $iv = ""; |
808 | 808 | } |
809 | 809 | |
810 | 810 | if(isset($this->form_params['extra']['part'])) { |
811 | 811 | $return['part'] = (int)$this->xcloner_sanitization->sanitize_input_as_int($this->form_params['extra']['part']); |
812 | - }else{ |
|
812 | + } else{ |
|
813 | 813 | $return['part'] = 0; |
814 | 814 | } |
815 | 815 | |
816 | - }else{ |
|
816 | + } else{ |
|
817 | 817 | $source_backup_file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']); |
818 | 818 | $start = $this->xcloner_sanitization->sanitize_input_as_int($_POST['start']); |
819 | 819 | $iv = $this->xcloner_sanitization->sanitize_input_as_raw($_POST['iv']); |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | $this->logger->info($iv); |
836 | 836 | $return = array_merge($return, |
837 | 837 | $this->xcloner_encryption->encrypt_file($backup_file, "", "", $start, base64_decode($iv))); |
838 | - }catch(\Exception $e){ |
|
838 | + } catch(\Exception $e){ |
|
839 | 839 | $return['error'] = true; |
840 | 840 | $return['message'] = $e->getMessage(); |
841 | 841 | $return['error_message'] = $e->getMessage(); |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | try { |
893 | 893 | $return = array_merge($return, |
894 | 894 | $this->xcloner_encryption->decrypt_file($backup_file, "", $decryption_key, $start, base64_decode($iv))); |
895 | - }catch(\Exception $e){ |
|
895 | + } catch(\Exception $e){ |
|
896 | 896 | $return['error'] = true; |
897 | 897 | $return['message'] = $e->getMessage(); |
898 | 898 | } |
@@ -994,7 +994,8 @@ discard block |
||
994 | 994 | title="<?php echo __('Backup Decryption', 'xcloner-backup-and-restore') ?>"> |
995 | 995 | <i class="material-icons">enhanced_encryption</i> |
996 | 996 | </a> |
997 | - <?php else: ?> |
|
997 | + <?php else { |
|
998 | + : ?> |
|
998 | 999 | <a href="#<?php echo $child[0] ?>" class="list-backup-content" |
999 | 1000 | title="<?php echo __('List Backup Content', |
1000 | 1001 | 'xcloner-backup-and-restore') ?>"><i |
@@ -1013,7 +1014,9 @@ discard block |
||
1013 | 1014 | class="material-icons">file_upload</i></a> |
1014 | 1015 | <?php endif ?> |
1015 | 1016 | </li> |
1016 | - <?php endforeach; ?> |
|
1017 | + <?php endforeach; |
|
1018 | +} |
|
1019 | +?> |
|
1017 | 1020 | </ul> |
1018 | 1021 | <?php endif; ?> |
1019 | 1022 | <?php |
@@ -1021,11 +1024,12 @@ discard block |
||
1021 | 1024 | ob_end_clean(); |
1022 | 1025 | ?> |
1023 | 1026 | <?php ob_start(); ?> |
1024 | - <?php if (isset($file_info['timestamp'])) |
|
1027 | + <?php if (isset($file_info['timestamp'])) { |
|
1025 | 1028 | echo date("Y-m-d H:i", $file_info['timestamp']) |
1026 | 1029 | ?> |
1027 | 1030 | <?php |
1028 | 1031 | $return['data'][$i][] = ob_get_contents(); |
1032 | +} |
|
1029 | 1033 | ob_end_clean(); |
1030 | 1034 | ?> |
1031 | 1035 | |
@@ -1050,15 +1054,17 @@ discard block |
||
1050 | 1054 | <?php endif ?> |
1051 | 1055 | <?php |
1052 | 1056 | $basename = $file_info['basename']; |
1053 | - if(isset($file_info['childs']) and sizeof($file_info['childs'])) |
|
1054 | - $basename = $file_info['childs'][0][0]; |
|
1057 | + if(isset($file_info['childs']) and sizeof($file_info['childs'])) { |
|
1058 | + $basename = $file_info['childs'][0][0]; |
|
1059 | + } |
|
1055 | 1060 | ?> |
1056 | 1061 | <?php if($this->xcloner_encryption->is_encrypted_file($basename)) :?> |
1057 | 1062 | <a href="#<?php echo $file_info['basename'] ?>" class="backup-decryption" |
1058 | 1063 | title="<?php echo __('Backup Decryption', 'xcloner-backup-and-restore') ?>"> |
1059 | 1064 | <i class="material-icons">enhanced_encryption</i> |
1060 | 1065 | </a> |
1061 | - <?php else: ?> |
|
1066 | + <?php else { |
|
1067 | + : ?> |
|
1062 | 1068 | <a href="#<?php echo $file_info['basename'] ?>" class="list-backup-content" |
1063 | 1069 | title="<?php echo __('List Backup Content', 'xcloner-backup-and-restore') ?>"><i |
1064 | 1070 | class="material-icons">folder_open</i></a> |
@@ -1068,7 +1074,9 @@ discard block |
||
1068 | 1074 | <i class="material-icons">no_encryption</i> |
1069 | 1075 | </a> |
1070 | 1076 | <?php endif?> |
1071 | - <?php endif; ?> |
|
1077 | + <?php endif; |
|
1078 | +} |
|
1079 | +?> |
|
1072 | 1080 | |
1073 | 1081 | <a href="#<?php echo $file_info['basename'] ?>" class="delete" |
1074 | 1082 | title="<?php echo __('Delete Backup', 'xcloner-backup-and-restore') ?>"> |