@@ -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 | |
@@ -208,7 +207,7 @@ discard block |
||
208 | 207 | $this->logger->debug(sprintf('Starting action %s', $method)); |
209 | 208 | return call_user_func(array($this, $method)); |
210 | 209 | |
211 | - }else{ |
|
210 | + } else{ |
|
212 | 211 | throw new Exception($method ." does not exists"); |
213 | 212 | } |
214 | 213 | } |
@@ -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,18 +245,20 @@ 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 | @unlink($_FILES['blob']['tmp_name']); |
251 | - }elseif(isset($_POST['blob'])){ |
|
253 | + } elseif(isset($_POST['blob'])){ |
|
252 | 254 | $this->logger->debug(sprintf('Writing %s bytes to file %s starting position %s using POST blob', strlen($_POST['blob']), $target_file, $_POST['start'])); |
253 | 255 | |
254 | 256 | $blob = $_POST['blob']; |
255 | 257 | |
256 | - if(!$bytes_written = fwrite($fp, $blob)) |
|
257 | - throw new Exception("Unable to write data to file $target_file"); |
|
258 | - }else{ |
|
258 | + if(!$bytes_written = fwrite($fp, $blob)) { |
|
259 | + throw new Exception("Unable to write data to file $target_file"); |
|
260 | + } |
|
261 | + } else{ |
|
259 | 262 | throw new Exception("Upload failed, did not receive any binary data"); |
260 | 263 | } |
261 | 264 | |
@@ -289,10 +292,11 @@ discard block |
||
289 | 292 | |
290 | 293 | $mysqli->query("SET sql_mode='';"); |
291 | 294 | $mysqli->query("SET foreign_key_checks = 0;"); |
292 | - if(isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file']) |
|
293 | - $mysqli->query("SET NAMES ".$_REQUEST['charset_of_file'].""); |
|
294 | - else |
|
295 | - $mysqli->query("SET NAMES utf8;"); |
|
295 | + if(isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file']) { |
|
296 | + $mysqli->query("SET NAMES ".$_REQUEST['charset_of_file'].""); |
|
297 | + } else { |
|
298 | + $mysqli->query("SET NAMES utf8;"); |
|
299 | + } |
|
296 | 300 | |
297 | 301 | return $mysqli; |
298 | 302 | } |
@@ -322,8 +326,9 @@ discard block |
||
322 | 326 | |
323 | 327 | $mysql_backup_file = $remote_path.DS.$mysqldump_file; |
324 | 328 | |
325 | - if(!file_exists($mysql_backup_file)) |
|
326 | - throw new Exception(sprintf("Mysql backup file %s does not exists",$mysql_backup_file)); |
|
329 | + if(!file_exists($mysql_backup_file)) { |
|
330 | + throw new Exception(sprintf("Mysql backup file %s does not exists",$mysql_backup_file)); |
|
331 | + } |
|
327 | 332 | |
328 | 333 | |
329 | 334 | /*if(defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS) |
@@ -355,16 +360,18 @@ discard block |
||
355 | 360 | // process the line read. |
356 | 361 | |
357 | 362 | //check if line is comment |
358 | - if(substr($line, 0, 1) == "#") |
|
359 | - continue; |
|
363 | + if(substr($line, 0, 1) == "#") { |
|
364 | + continue; |
|
365 | + } |
|
360 | 366 | |
361 | 367 | //check if line is empty |
362 | - if($line == "\n" or trim($line) == "") |
|
363 | - continue; |
|
368 | + if($line == "\n" or trim($line) == "") { |
|
369 | + continue; |
|
370 | + } |
|
364 | 371 | |
365 | - if(substr($line, strlen($line)-2, strlen($line)) == ";\n") |
|
366 | - $query .= $line; |
|
367 | - else{ |
|
372 | + if(substr($line, strlen($line)-2, strlen($line)) == ";\n") { |
|
373 | + $query .= $line; |
|
374 | + } else{ |
|
368 | 375 | $query .= $line; |
369 | 376 | continue; |
370 | 377 | } |
@@ -423,7 +430,7 @@ discard block |
||
423 | 430 | if(!feof($fp)) |
424 | 431 | { |
425 | 432 | $return['finished'] = 0; |
426 | - }else{ |
|
433 | + } else{ |
|
427 | 434 | $this->logger->info(sprintf("Mysql Import Done.")); |
428 | 435 | } |
429 | 436 | |
@@ -488,7 +495,7 @@ discard block |
||
488 | 495 | $tar->open($this->backup_storage_dir.DS.$backup_file, $start); |
489 | 496 | |
490 | 497 | $data = $tar->contents($this->process_files_limit_list); |
491 | - }catch(Exception $e) |
|
498 | + } catch(Exception $e) |
|
492 | 499 | { |
493 | 500 | $return['error'] = true; |
494 | 501 | $return['message'] = $e->getMessage(); |
@@ -516,15 +523,16 @@ discard block |
||
516 | 523 | { |
517 | 524 | $return['start'] = $data['start']; |
518 | 525 | $return['finished'] = 0; |
519 | - }else{ |
|
526 | + } else{ |
|
520 | 527 | if($this->is_multipart($source_backup_file)) |
521 | 528 | { |
522 | 529 | $return['start'] = 0; |
523 | 530 | |
524 | 531 | ++$return['part']; |
525 | 532 | |
526 | - if($return['part'] < sizeof($backup_parts)) |
|
527 | - $return['finished'] = 0; |
|
533 | + if($return['part'] < sizeof($backup_parts)) { |
|
534 | + $return['finished'] = 0; |
|
535 | + } |
|
528 | 536 | |
529 | 537 | } |
530 | 538 | } |
@@ -665,19 +673,22 @@ discard block |
||
665 | 673 | { |
666 | 674 | $config = file_get_contents($wp_config); |
667 | 675 | preg_match("/.*table_prefix.*=.*'(.*)'/i", $config, $matches); |
668 | - if(isset($matches[1])) |
|
669 | - $table_prefix = $matches[1]; |
|
670 | - else |
|
671 | - throw new Exception("Could not load wordpress table prefix from wp-config.php file."); |
|
676 | + if(isset($matches[1])) { |
|
677 | + $table_prefix = $matches[1]; |
|
678 | + } else { |
|
679 | + throw new Exception("Could not load wordpress table prefix from wp-config.php file."); |
|
680 | + } |
|
681 | + } else { |
|
682 | + throw new Exception("Could not update the SITEURL and HOME, wp-config.php file not found"); |
|
672 | 683 | } |
673 | - else |
|
674 | - throw new Exception("Could not update the SITEURL and HOME, wp-config.php file not found"); |
|
675 | 684 | |
676 | - if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='home'")) |
|
677 | - throw new Exception(sprintf("Could not update the HOME option, error: %s\n", $mysqli->error)); |
|
685 | + if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='home'")) { |
|
686 | + throw new Exception(sprintf("Could not update the HOME option, error: %s\n", $mysqli->error)); |
|
687 | + } |
|
678 | 688 | |
679 | - if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='siteurl'")) |
|
680 | - throw new Exception(sprintf("Could not update the SITEURL option, error: %s\n", $mysqli->error)); |
|
689 | + if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='siteurl'")) { |
|
690 | + throw new Exception(sprintf("Could not update the SITEURL option, error: %s\n", $mysqli->error)); |
|
691 | + } |
|
681 | 692 | |
682 | 693 | return true; |
683 | 694 | } |
@@ -715,8 +726,9 @@ discard block |
||
715 | 726 | |
716 | 727 | $this->logger->info(sprintf('Updating wp-config.php file with the new mysql details')); |
717 | 728 | |
718 | - if(!file_put_contents($wp_config, $content)) |
|
719 | - throw new Exception("Could not write updated config data to ".$wp_config); |
|
729 | + if(!file_put_contents($wp_config, $content)) { |
|
730 | + throw new Exception("Could not write updated config data to ".$wp_config); |
|
731 | + } |
|
720 | 732 | |
721 | 733 | chmod($wp_config, $file_perms); |
722 | 734 | |
@@ -761,10 +773,11 @@ discard block |
||
761 | 773 | $mysqldump_list[$file['path']]['size'] = $file['size']; |
762 | 774 | $mysqldump_list[$file['path']]['timestamp'] = date("d M,Y H:i",$file['timestamp']); |
763 | 775 | |
764 | - if($hash and $hash == $matches[1]) |
|
765 | - $mysqldump_list[$file['path']]['selected'] = "selected"; |
|
766 | - else |
|
767 | - $mysqldump_list[$file['path']]['selected'] = ""; |
|
776 | + if($hash and $hash == $matches[1]) { |
|
777 | + $mysqldump_list[$file['path']]['selected'] = "selected"; |
|
778 | + } else { |
|
779 | + $mysqldump_list[$file['path']]['selected'] = ""; |
|
780 | + } |
|
768 | 781 | } |
769 | 782 | } |
770 | 783 | } |
@@ -785,13 +798,15 @@ discard block |
||
785 | 798 | */ |
786 | 799 | private function get_hash_from_backup($backup_file) |
787 | 800 | { |
788 | - if(!$backup_file) |
|
789 | - return false; |
|
801 | + if(!$backup_file) { |
|
802 | + return false; |
|
803 | + } |
|
790 | 804 | |
791 | 805 | $result = preg_match("/-(\w*)./", substr($backup_file, strlen($backup_file)-10, strlen($backup_file)), $matches) ; |
792 | 806 | |
793 | - if($result and isset($matches[1])) |
|
794 | - return ($matches[1]); |
|
807 | + if($result and isset($matches[1])) { |
|
808 | + return ($matches[1]); |
|
809 | + } |
|
795 | 810 | |
796 | 811 | return false; |
797 | 812 | } |
@@ -816,10 +831,11 @@ discard block |
||
816 | 831 | if(isset($file_info['extension']) and $file_info['extension'] == "csv") |
817 | 832 | { |
818 | 833 | $lines = explode(PHP_EOL, $this->filesystem->read($file_info['path'])); |
819 | - foreach($lines as $line) |
|
820 | - if($line) |
|
834 | + foreach($lines as $line) { |
|
835 | + if($line) |
|
821 | 836 | { |
822 | 837 | $data = str_getcsv($line); |
838 | + } |
|
823 | 839 | if(is_array($data)){ |
824 | 840 | $parents[$data[0]] = $file_info['path']; |
825 | 841 | $file_info['childs'][] = $data; |
@@ -829,20 +845,22 @@ discard block |
||
829 | 845 | |
830 | 846 | } |
831 | 847 | |
832 | - if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) |
|
833 | - $backup_files[$file_info['path']] = $file_info; |
|
848 | + if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) { |
|
849 | + $backup_files[$file_info['path']] = $file_info; |
|
850 | + } |
|
834 | 851 | } |
835 | 852 | |
836 | 853 | $new_list = array(); |
837 | 854 | |
838 | 855 | foreach($backup_files as $key=>$file_info) |
839 | 856 | { |
840 | - if(isset($parents[$file_info['path']])) |
|
841 | - $backup_files[$key]['parent'] = $parents[$file_info['path']]; |
|
842 | - else{ |
|
857 | + if(isset($parents[$file_info['path']])) { |
|
858 | + $backup_files[$key]['parent'] = $parents[$file_info['path']]; |
|
859 | + } else{ |
|
843 | 860 | |
844 | - if($local_backup_file and ($file_info['basename'] == $local_backup_file)) |
|
845 | - $file_info['selected'] = 'selected'; |
|
861 | + if($local_backup_file and ($file_info['basename'] == $local_backup_file)) { |
|
862 | + $file_info['selected'] = 'selected'; |
|
863 | + } |
|
846 | 864 | |
847 | 865 | $this->logger->info(sprintf('Found %s backup file', $file_info['path'])); |
848 | 866 | |
@@ -889,8 +907,9 @@ discard block |
||
889 | 907 | $backup_archive = new Tar(); |
890 | 908 | if($this->is_multipart($backup_file)) |
891 | 909 | { |
892 | - if(!$return['part']) |
|
893 | - $return['processed'] += $this->filesystem->getSize($backup_file); |
|
910 | + if(!$return['part']) { |
|
911 | + $return['processed'] += $this->filesystem->getSize($backup_file); |
|
912 | + } |
|
894 | 913 | |
895 | 914 | $backup_parts = $this->get_multipart_files($backup_file); |
896 | 915 | $backup_file = $backup_parts[$return['part']]; |
@@ -910,12 +929,13 @@ discard block |
||
910 | 929 | } |
911 | 930 | } |
912 | 931 | |
913 | - if(isset($data['start'])) |
|
914 | - //if(isset($data['start']) and $data['start'] <= $this->filesystem->getSize($backup_file)) |
|
932 | + if(isset($data['start'])) { |
|
933 | + //if(isset($data['start']) and $data['start'] <= $this->filesystem->getSize($backup_file)) |
|
915 | 934 | { |
916 | 935 | $return['finished'] = 0; |
936 | + } |
|
917 | 937 | $return['start'] = $data['start']; |
918 | - }else{ |
|
938 | + } else{ |
|
919 | 939 | |
920 | 940 | $return['processed'] += $start; |
921 | 941 | |
@@ -925,14 +945,16 @@ discard block |
||
925 | 945 | |
926 | 946 | ++$return['part']; |
927 | 947 | |
928 | - if($return['part'] < sizeof($backup_parts)) |
|
929 | - $return['finished'] = 0; |
|
948 | + if($return['part'] < sizeof($backup_parts)) { |
|
949 | + $return['finished'] = 0; |
|
950 | + } |
|
930 | 951 | |
931 | 952 | } |
932 | 953 | } |
933 | 954 | |
934 | - if($return['finished']) |
|
935 | - $this->logger->info(sprintf('Done extracting %s', $source_backup_file)); |
|
955 | + if($return['finished']) { |
|
956 | + $this->logger->info(sprintf('Done extracting %s', $source_backup_file)); |
|
957 | + } |
|
936 | 958 | |
937 | 959 | $return['backup_file'] = $backup_file; |
938 | 960 | |
@@ -964,8 +986,7 @@ discard block |
||
964 | 986 | $return['remote_mysql_user'] = $wpdb->dbuser; |
965 | 987 | $return['remote_mysql_pass'] = $wpdb->dbpassword; |
966 | 988 | $return['remote_mysql_db'] = $wpdb->dbname; |
967 | - } |
|
968 | - else{ |
|
989 | + } else{ |
|
969 | 990 | $return['dir'] = ($pathinfo['dirname']).DS.$suffix; |
970 | 991 | $return['restore_script_url'] = str_replace($pathinfo['basename'], "", $restore_script_url).$suffix; |
971 | 992 | } |
@@ -984,11 +1005,13 @@ discard block |
||
984 | 1005 | { |
985 | 1006 | //check if i can write |
986 | 1007 | $tmp_file = md5(time()); |
987 | - if(!file_put_contents($tmp_file, "++")) |
|
988 | - throw new Exception("Could not write to new host"); |
|
1008 | + if(!file_put_contents($tmp_file, "++")) { |
|
1009 | + throw new Exception("Could not write to new host"); |
|
1010 | + } |
|
989 | 1011 | |
990 | - if(!unlink($tmp_file)) |
|
991 | - throw new Exception("Could not delete temporary file from new host"); |
|
1012 | + if(!unlink($tmp_file)) { |
|
1013 | + throw new Exception("Could not delete temporary file from new host"); |
|
1014 | + } |
|
992 | 1015 | |
993 | 1016 | $max_upload = $this->return_bytes((ini_get('upload_max_filesize'))); |
994 | 1017 | $max_post = $this->return_bytes((ini_get('post_max_size'))); |
@@ -1032,8 +1055,9 @@ discard block |
||
1032 | 1055 | */ |
1033 | 1056 | public function is_multipart($backup_name) |
1034 | 1057 | { |
1035 | - if(stristr($backup_name, "-multipart")) |
|
1036 | - return true; |
|
1058 | + if(stristr($backup_name, "-multipart")) { |
|
1059 | + return true; |
|
1060 | + } |
|
1037 | 1061 | |
1038 | 1062 | return false; |
1039 | 1063 | } |
@@ -1051,8 +1075,9 @@ discard block |
||
1051 | 1075 | if($this->is_multipart($backup_name)) |
1052 | 1076 | { |
1053 | 1077 | $backup_parts = $this->get_multipart_files($backup_name); |
1054 | - foreach($backup_parts as $part_file) |
|
1055 | - $backup_size += $this->filesystem->getSize($part_file); |
|
1078 | + foreach($backup_parts as $part_file) { |
|
1079 | + $backup_size += $this->filesystem->getSize($part_file); |
|
1080 | + } |
|
1056 | 1081 | } |
1057 | 1082 | |
1058 | 1083 | return $backup_size; |
@@ -1110,15 +1135,13 @@ discard block |
||
1110 | 1135 | if($direction == 'desc') { |
1111 | 1136 | if($a > $b) { |
1112 | 1137 | return -1; |
1113 | - } |
|
1114 | - else{ |
|
1138 | + } else{ |
|
1115 | 1139 | return 1; |
1116 | 1140 | } |
1117 | - }else { |
|
1141 | + } else { |
|
1118 | 1142 | if($a < $b) { |
1119 | 1143 | return -1; |
1120 | - } |
|
1121 | - else{ |
|
1144 | + } else{ |
|
1122 | 1145 | return 1; |
1123 | 1146 | } |
1124 | 1147 | } |
@@ -1148,7 +1171,7 @@ discard block |
||
1148 | 1171 | { |
1149 | 1172 | $return['statusText'] = $response['message']; |
1150 | 1173 | $return['error'] = true; |
1151 | - }elseif($status != 200 and $status != 418) |
|
1174 | + } elseif($status != 200 and $status != 418) |
|
1152 | 1175 | { |
1153 | 1176 | $return['error'] = true; |
1154 | 1177 | $return['message'] = $response; |
@@ -1172,8 +1195,9 @@ discard block |
||
1172 | 1195 | return preg_replace_callback('!s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!', function ($m) { |
1173 | 1196 | $data = ""; |
1174 | 1197 | |
1175 | - if(!isset($m[3])) |
|
1176 | - $m[3] = ""; |
|
1198 | + if(!isset($m[3])) { |
|
1199 | + $m[3] = ""; |
|
1200 | + } |
|
1177 | 1201 | |
1178 | 1202 | $data = 's:'.strlen(($m[3])).':\"'.($m[3]).'\";'; |
1179 | 1203 | //return $this->unescape_quotes($data); |
@@ -1219,7 +1243,7 @@ discard block |
||
1219 | 1243 | stristr($s, ':' ) != false |
1220 | 1244 | ){ |
1221 | 1245 | return true; |
1222 | - }else{ |
|
1246 | + } else{ |
|
1223 | 1247 | return false; |
1224 | 1248 | } |
1225 | 1249 |
@@ -31,10 +31,13 @@ |
||
31 | 31 | <?php if ($storage_selection): ?> |
32 | 32 | <option value="" |
33 | 33 | selected><?php echo __('Change To Local Storage...', 'xcloner-backup-and-restore') ?></option> |
34 | - <?php else: ?> |
|
34 | + <?php else { |
|
35 | + : ?> |
|
35 | 36 | <option value="" |
36 | 37 | selected><?php echo __('Change To Remote Storage...', 'xcloner-backup-and-restore') ?></option> |
37 | - <?php endif; ?> |
|
38 | + <?php endif; |
|
39 | +} |
|
40 | +?> |
|
38 | 41 | |
39 | 42 | <?php foreach ($available_storages as $storage => $text): ?> |
40 | 43 | <option value="<?php echo $storage ?>"<?php if ($storage == $storage_selection) |
@@ -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') ?>"> |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | $this->xcloner_container = $xcloner_container; |
24 | 24 | if(method_exists($xcloner_container, 'get_xcloner_settings')) { |
25 | 25 | $this->xcloner_settings = $xcloner_container->get_xcloner_settings(); |
26 | - }else{ |
|
26 | + } else{ |
|
27 | 27 | $this->xcloner_settings = ""; |
28 | 28 | } |
29 | 29 | |
30 | 30 | if(method_exists($xcloner_container, 'get_xcloner_logger')) { |
31 | 31 | $this->logger = $xcloner_container->get_xcloner_logger()->withName("xcloner_encryption"); |
32 | - }else{ |
|
32 | + } else{ |
|
33 | 33 | $this->logger = ""; |
34 | 34 | } |
35 | 35 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | if( !$start ) { |
127 | 127 | $fpOut = fopen($this->get_xcloner_path() .$dest, 'w'); |
128 | - }else{ |
|
128 | + } else{ |
|
129 | 129 | $fpOut = fopen($this->get_xcloner_path() .$dest, 'a'); |
130 | 130 | } |
131 | 131 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | //self::encryptFile($source, $dest, $key, $start, $iv); |
163 | 163 | if($recursive ){ |
164 | 164 | $this->encrypt_file($source, $dest, $key, $start, ($iv), $verification, $recursive); |
165 | - }else { |
|
165 | + } else { |
|
166 | 166 | |
167 | 167 | if(($iv) != base64_decode(base64_encode($iv))) |
168 | 168 | { |
@@ -249,13 +249,13 @@ discard block |
||
249 | 249 | if( !$start ) { |
250 | 250 | if($this->verification){ |
251 | 251 | $fpOut = fopen("php://stdout", 'w'); |
252 | - }else { |
|
252 | + } else { |
|
253 | 253 | $fpOut = fopen($this->get_xcloner_path() . $dest, 'w'); |
254 | 254 | } |
255 | - }else{ |
|
255 | + } else{ |
|
256 | 256 | if($this->verification){ |
257 | 257 | $fpOut = fopen("php://stdout", 'a'); |
258 | - }else { |
|
258 | + } else { |
|
259 | 259 | $fpOut = fopen($this->get_xcloner_path() . $dest, 'a'); |
260 | 260 | } |
261 | 261 | } |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | $ciphertext = ""; |
308 | 308 | $plaintext = ""; |
309 | 309 | $this->decrypt_file($source, $dest, $key, $start, $iv, $recursive); |
310 | - }else { |
|
310 | + } else { |
|
311 | 311 | if(($iv) != base64_decode(base64_encode($iv))) |
312 | 312 | { |
313 | 313 | throw new \Exception('Could not encode IV for transport'); |
@@ -374,6 +374,6 @@ discard block |
||
374 | 374 | $xcloner_encryption->decrypt_file($argv[2], $argv[2] . ".dec", $argv[4], '', '', true); |
375 | 375 | } |
376 | 376 | } |
377 | -}catch(\Exception $e) { |
|
377 | +} catch(\Exception $e) { |
|
378 | 378 | echo "CAUGHT: " . $e->getMessage(); |
379 | 379 | } |