GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( f90b76...ba7917 )
by Liuta
14s
created
includes/class-xcloner-sanitization.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
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
 		
Please login to merge, or discard this patch.
includes/class-xcloner-requirements.php 1 patch
Braces   +49 added lines, -34 removed lines patch added patch discarded remove patch
@@ -13,20 +13,25 @@  discard block
 block discarded – undo
13 13
 	
14 14
 	public function check_backup_ready_status()
15 15
 	{
16
-		if(!$this->check_min_php_version(1))
17
-			return false;
16
+		if(!$this->check_min_php_version(1)) {
17
+					return false;
18
+		}
18 19
 		
19
-		if(!$this->check_safe_mode(1))
20
-			return false;
20
+		if(!$this->check_safe_mode(1)) {
21
+					return false;
22
+		}
21 23
 		
22
-		if(!$this->check_xcloner_start_path(1))
23
-			return false;
24
+		if(!$this->check_xcloner_start_path(1)) {
25
+					return false;
26
+		}
24 27
 		
25
-		if(!$this->check_xcloner_store_path(1))
26
-			return false;
28
+		if(!$this->check_xcloner_store_path(1)) {
29
+					return false;
30
+		}
27 31
 		
28
-		if(!$this->check_xcloner_tmp_path(1))
29
-			return false;
32
+		if(!$this->check_xcloner_tmp_path(1)) {
33
+					return false;
34
+		}
30 35
 			
31 36
 		return true;	
32 37
 	}
@@ -41,10 +46,11 @@  discard block
 block discarded – undo
41 46
 		
42 47
 		if($return_bool == 1)
43 48
 		{
44
-			if(version_compare(phpversion(), $this->min_php_version, '<'))
45
-				return false;
46
-			else
47
-				return true;
49
+			if(version_compare(phpversion(), $this->min_php_version, '<')) {
50
+							return false;
51
+			} else {
52
+							return true;
53
+			}
48 54
 		}
49 55
 		
50 56
 		return phpversion();
@@ -56,14 +62,16 @@  discard block
 block discarded – undo
56 62
 		
57 63
 		if($return_bool)
58 64
 		{
59
-			if( ini_get('safe_mode') )
60
-				return false;
61
-			else
62
-				return true;
65
+			if( ini_get('safe_mode') ) {
66
+							return false;
67
+			} else {
68
+							return true;
69
+			}
63 70
 		}
64 71
 		
65
-		if( ini_get('safe_mode') )
66
-			$safe_mode = "On";
72
+		if( ini_get('safe_mode') ) {
73
+					$safe_mode = "On";
74
+		}
67 75
 			
68 76
 		return $safe_mode;
69 77
 	}
@@ -74,8 +82,9 @@  discard block
 block discarded – undo
74 82
 		
75 83
 		if($return_bool)
76 84
 		{
77
-			if(!file_exists($path))
78
-				return false;
85
+			if(!file_exists($path)) {
86
+							return false;
87
+			}
79 88
 				
80 89
 			return is_readable($path);
81 90
 		}
@@ -89,11 +98,13 @@  discard block
 block discarded – undo
89 98
 		
90 99
 		if($return_bool)
91 100
 		{
92
-			if(!file_exists($path))
93
-				return false;
101
+			if(!file_exists($path)) {
102
+							return false;
103
+			}
94 104
 			
95
-			if(!is_writeable($path))	
96
-				@chmod($path, 0777);
105
+			if(!is_writeable($path)) {
106
+							@chmod($path, 0777);
107
+			}
97 108
 					
98 109
 			return is_writeable($path);
99 110
 		}
@@ -107,11 +118,13 @@  discard block
 block discarded – undo
107 118
 		
108 119
 		if($return_bool)
109 120
 		{
110
-			if(!file_exists($path))
111
-				return false;
121
+			if(!file_exists($path)) {
122
+							return false;
123
+			}
112 124
 			
113
-			if(!is_writeable($path))	
114
-				@chmod($path, 0777);
125
+			if(!is_writeable($path)) {
126
+							@chmod($path, 0777);
127
+			}
115 128
 				
116 129
 			return is_writeable($path);
117 130
 		}
@@ -133,8 +146,9 @@  discard block
 block discarded – undo
133 146
 	{
134 147
 		$open_basedir =  ini_get('open_basedir');
135 148
 		
136
-		if(!$open_basedir)
137
-			$open_basedir = "none";
149
+		if(!$open_basedir) {
150
+					$open_basedir = "none";
151
+		}
138 152
 		return $open_basedir;	
139 153
 	}
140 154
 	
@@ -153,8 +167,9 @@  discard block
 block discarded – undo
153 167
 	  $unit_count = count($unit_list);
154 168
 	  for ($i = $unit_count - 1; $i >= 0; $i--) {
155 169
 	    $power = $i * 10;
156
-	    if (($bytes >> $power) >= 1)
157
-	      return round($bytes / (1 << $power), $decimals) . ' ' . $unit_list[$i];
170
+	    if (($bytes >> $power) >= 1) {
171
+	    	      return round($bytes / (1 << $power), $decimals) . ' ' . $unit_list[$i];
172
+	    }
158 173
 	  }
159 174
 	}
160 175
 }
Please login to merge, or discard this patch.
includes/class-xcloner-file-transfer.php 1 patch
Braces   +7 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,8 +19,9 @@  discard block
 block discarded – undo
19 19
 	
20 20
 	public function transfer_file($file, $start = 0, $hash = "")
21 21
 	{
22
-		if(!$this->target_url)
23
-			throw new Exception("Please setup a target url for upload");
22
+		if(!$this->target_url) {
23
+					throw new Exception("Please setup a target url for upload");
24
+		}
24 25
 
25 26
 		
26 27
 		$fp = $this->get_storage_filesystem()->readStream($file);
@@ -68,8 +69,9 @@  discard block
 block discarded – undo
68 69
 		
69 70
 		$result = json_decode($original_result);
70 71
 				
71
-		if(!$result)
72
-			throw new Exception("We have received no valid response from the remote host, original message: ". $original_result);
72
+		if(!$result) {
73
+					throw new Exception("We have received no valid response from the remote host, original message: ". $original_result);
74
+		}
73 75
 			
74 76
 		if($result->status != 200)
75 77
 		{
@@ -94,7 +96,7 @@  discard block
 block discarded – undo
94 96
 	            . ($postname ?: basename($filename))
95 97
 	            . ($mimetype ? ";type=$mimetype" : '');
96 98
 		
97
-		}else{
99
+		} else{
98 100
 			
99 101
 			return curl_file_create($filename, $mimetype, $postname);	
100 102
 				
Please login to merge, or discard this patch.
admin/partials/xcloner_console_page.php 1 patch
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,10 @@
 block discarded – undo
33 33
 			<li class="active">
34 34
 				<div class="collapsible-header active"><i class="material-icons">bug_report</i>XCloner Debugger</div>
35 35
 				<div class="collapsible-body">
36
-					<div class="console" id="xcloner-console"><?php if(isset($logger_content)) echo implode("<br />\n", $logger_content); ?></div>
36
+					<div class="console" id="xcloner-console"><?php if(isset($logger_content)) {
37
+	echo implode("<br />\n", $logger_content);
38
+}
39
+?></div>
37 40
 				</div>
38 41
 			</li>
39 42
 		</ul>
Please login to merge, or discard this patch.
admin/class-xcloner-admin.php 1 patch
Braces   +9 added lines, -7 removed lines patch added patch discarded remove patch
@@ -61,8 +61,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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');
Please login to merge, or discard this patch.
includes/class-xcloner-loader.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,8 +58,9 @@
 block discarded – undo
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
 		{
Please login to merge, or discard this patch.
admin/partials/xcloner_manage_backups_page.php 1 patch
Braces   +22 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,12 +27,16 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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>
Please login to merge, or discard this patch.
includes/class-xcloner-archive.php 1 patch
Braces   +79 added lines, -61 removed lines patch added patch discarded remove patch
@@ -26,17 +26,22 @@  discard block
 block discarded – undo
26 26
 		$this->logger 			= $xcloner_container->get_xcloner_logger()->withName("xcloner_archive");
27 27
 		$this->xcloner_settings = $xcloner_container->get_xcloner_settings();
28 28
 		
29
-		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_size_limit_per_request'))
30
-			$this->file_size_per_request_limit = $value*1024*1024; //MB
29
+		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_size_limit_per_request')) {
30
+					$this->file_size_per_request_limit = $value*1024*1024;
31
+		}
32
+		//MB
31 33
 			
32
-		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_files_to_process_per_request'))
33
-			$this->files_to_process_per_request = $value;
34
+		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_files_to_process_per_request')) {
35
+					$this->files_to_process_per_request = $value;
36
+		}
34 37
 		
35
-		if($value = get_option('xcloner_backup_compression_level'))
36
-			$this->compression_level = $value;
38
+		if($value = get_option('xcloner_backup_compression_level')) {
39
+					$this->compression_level = $value;
40
+		}
37 41
 		
38
-		if($value = get_option('xcloner_split_backup_limit'))
39
-			$this->xcloner_split_backup_limit = $value;
42
+		if($value = get_option('xcloner_split_backup_limit')) {
43
+					$this->xcloner_split_backup_limit = $value;
44
+		}
40 45
 		
41 46
 		$this->xcloner_split_backup_limit = $this->xcloner_split_backup_limit * 1024*1024; //transform to bytes
42 47
 			
@@ -73,8 +78,9 @@  discard block
 block discarded – undo
73 78
 			//$this->archive_name = $this->archive_name."-diff-".date("Y-m-d_H-i",$diff_timestamp_start);
74 79
 			$new_name = $this->archive_name;
75 80
 			
76
-			if(!stristr($new_name, "-diff"))
77
-				$new_name = $this->archive_name . "-diff".date("Y-m-d_H-i",$diff_timestamp_start);
81
+			if(!stristr($new_name, "-diff")) {
82
+							$new_name = $this->archive_name . "-diff".date("Y-m-d_H-i",$diff_timestamp_start);
83
+			}
78 84
 			
79 85
 			$this->archive_name = $new_name;
80 86
 			
@@ -83,8 +89,9 @@  discard block
 block discarded – undo
83 89
 		if(isset($part) and $part)
84 90
 		{
85 91
 			$new_name =  preg_replace('/-part(\d*)/', "-part".$part, $this->archive_name);
86
-			if(!stristr($new_name, "-part"))
87
-				$new_name = $this->archive_name . "-part".$part;
92
+			if(!stristr($new_name, "-part")) {
93
+							$new_name = $this->archive_name . "-part".$part;
94
+			}
88 95
 			
89 96
 			$this->archive_name = $new_name;	
90 97
 		}
@@ -139,8 +146,9 @@  discard block
 block discarded – undo
139 146
 		
140 147
 		$headers = array('Content-Type: text/html; charset=UTF-8');
141 148
 		
142
-		if($admin_email and $from )
143
-			$headers[] = 'From: '.$from.' <'.$admin_email.'>';
149
+		if($admin_email and $from ) {
150
+					$headers[] = 'From: '.$from.' <'.$admin_email.'>';
151
+		}
144 152
 
145 153
 		$return = wp_mail( $to, $subject, $body, $headers );
146 154
 		
@@ -182,8 +190,9 @@  discard block
 block discarded – undo
182 190
 		
183 191
 		$backup_parts = $this->filesystem->get_multipart_files($backup_name);
184 192
 		
185
-		if(!$backups_counter = sizeof($backup_parts))
186
-			$backups_counter = 1;
193
+		if(!$backups_counter = sizeof($backup_parts)) {
194
+					$backups_counter = 1;
195
+		}
187 196
 		
188 197
 		$body .= sprintf(__("Backup Parts: %s"), $backups_counter);
189 198
 		$body .= "<br />";
@@ -202,8 +211,9 @@  discard block
 block discarded – undo
202 211
 			$body .= "<br /><br />";
203 212
 		}
204 213
 		
205
-		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log'))
206
-			$body .= __("Latest 50 Log Lines: ")."<br />".implode("<br />\n", $this->logger->getLastDebugLines(50));
214
+		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) {
215
+					$body .= __("Latest 50 Log Lines: ")."<br />".implode("<br />\n", $this->logger->getLastDebugLines(50));
216
+		}
207 217
 		
208 218
 		$attachments = $this->filesystem->get_backup_attachments();
209 219
 		
@@ -238,18 +248,21 @@  discard block
 block discarded – undo
238 248
 	{
239 249
 		$return = array();
240 250
 		
241
-		if(!isset($extra_params['backup_part']))
242
-			$extra_params['backup_part'] = 0;
251
+		if(!isset($extra_params['backup_part'])) {
252
+					$extra_params['backup_part'] = 0;
253
+		}
243 254
 		
244 255
 		$return['extra']['backup_part'] = $extra_params['backup_part'];
245 256
 					
246
-		if(isset( $extra_params['backup_archive_name']))
247
-			$this->set_archive_name($extra_params['backup_archive_name'], $return['extra']['backup_part']);
248
-		else
249
-			$this->set_archive_name($backup_params['backup_name']);
257
+		if(isset( $extra_params['backup_archive_name'])) {
258
+					$this->set_archive_name($extra_params['backup_archive_name'], $return['extra']['backup_part']);
259
+		} else {
260
+					$this->set_archive_name($backup_params['backup_name']);
261
+		}
250 262
 			
251
-		if(!$this->get_archive_name())
252
-			$this->set_archive_name();
263
+		if(!$this->get_archive_name()) {
264
+					$this->set_archive_name();
265
+		}
253 266
 		
254 267
 		$this->backup_archive = new Tar();
255 268
 		$this->backup_archive->setCompression($this->compression_level);
@@ -264,7 +277,7 @@  discard block
 block discarded – undo
264 277
 			
265 278
 			$return['extra']['backup_init'] = 1;
266 279
 			
267
-		}else{
280
+		} else{
268 281
 			$this->logger->info(sprintf(__("Opening for append the backup archive %s"), $this->get_archive_name()));
269 282
 			
270 283
 			$this->backup_archive->openForAppend($archive_info->getPath().DS.$archive_info->getFilename());
@@ -276,11 +289,13 @@  discard block
 block discarded – undo
276 289
 		$return['extra']['backup_archive_name'] = $this->get_archive_name();
277 290
 		$return['extra']['backup_archive_name_full'] = $this->get_archive_name_with_extension();
278 291
 		
279
-		if(!isset($extra_params['start_at_line']))
280
-			$extra_params['start_at_line'] = 0;
292
+		if(!isset($extra_params['start_at_line'])) {
293
+					$extra_params['start_at_line'] = 0;
294
+		}
281 295
 		
282
-		if(!isset($extra_params['start_at_byte']))
283
-			$extra_params['start_at_byte'] = 0;
296
+		if(!isset($extra_params['start_at_byte'])) {
297
+					$extra_params['start_at_byte'] = 0;
298
+		}
284 299
 		
285 300
 		if(!$this->filesystem->get_tmp_filesystem()->has($this->filesystem->get_included_files_handler()))
286 301
 		{
@@ -302,7 +317,7 @@  discard block
 block discarded – undo
302 317
 		if(!$extra_params['start_at_line'])
303 318
 		{
304 319
 			$file->seek(1);
305
-		}else{
320
+		} else{
306 321
 			$file->seek($extra_params['start_at_line']+1);
307 322
 		}
308 323
 		
@@ -344,8 +359,9 @@  discard block
 block discarded – undo
344 359
 			
345 360
 			$file_info = $this->filesystem->get_filesystem($start_filesystem)->getMetadata($relative_path);
346 361
 			
347
-			if(!isset($file_info['size']))
348
-				$file_info['size'] = 0;
362
+			if(!isset($file_info['size'])) {
363
+							$file_info['size'] = 0;
364
+			}
349 365
 			
350 366
 			if($start_filesystem == "tmp_filesystem")
351 367
 			{	
@@ -356,11 +372,13 @@  discard block
 block discarded – undo
356 372
 			
357 373
 			$append = 0;
358 374
 			
359
-			if($file_info['size'] > $byte_limit*512 or $start_byte)
360
-				$append = 1;
375
+			if($file_info['size'] > $byte_limit*512 or $start_byte) {
376
+							$append = 1;
377
+			}
361 378
 						
362
-			if(!isset($return['extra']['backup_size']))
363
-				$return['extra']['backup_size'] =0;
379
+			if(!isset($return['extra']['backup_size'])) {
380
+							$return['extra']['backup_size'] =0;
381
+			}
364 382
 			
365 383
 			$return['extra']['backup_size'] = $archive_info->getSize();
366 384
 			
@@ -396,8 +414,7 @@  discard block
 block discarded – undo
396 414
 			
397 415
 			if($last_position>0){	
398 416
 				$start_byte = $last_position;
399
-			}
400
-			else{	
417
+			} else{	
401 418
 				$extra_params['start_at_line']++;
402 419
 				$file->next();
403 420
 				$start_byte = 0;
@@ -434,8 +451,9 @@  discard block
 block discarded – undo
434 451
 		$this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.", $this->get_archive_name_with_extension()));
435 452
 		$this->backup_archive->close();
436 453
 				
437
-		if($return['extra']['backup_part'])
438
-			$this->write_multipart_file($this->get_archive_name_with_extension());
454
+		if($return['extra']['backup_part']) {
455
+					$this->write_multipart_file($this->get_archive_name_with_extension());
456
+		}
439 457
 		
440 458
 		$return['extra']['start_at_line'] = $extra_params['start_at_line']-1;
441 459
 		
@@ -487,12 +505,13 @@  discard block
 block discarded – undo
487 505
 			$this->set_archive_name($this->get_archive_name(), ++$part);
488 506
 			$this->rename_archive($old_name, $this->get_archive_name_with_extension());
489 507
 			
490
-			if($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart()))
491
-				$this->filesystem->get_storage_filesystem()->delete($this->get_archive_name_multipart());
508
+			if($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart())) {
509
+							$this->filesystem->get_storage_filesystem()->delete($this->get_archive_name_multipart());
510
+			}
492 511
 				
493 512
 			$this->write_multipart_file($this->get_archive_name_with_extension());
494 513
 			
495
-		}else
514
+		} else
496 515
 		{
497 516
 			$this->logger->info(sprintf("Creating new multipart info file %s",$this->get_archive_name_with_extension()));
498 517
 			$this->write_multipart_file($this->get_archive_name_with_extension());
@@ -522,13 +541,15 @@  discard block
 block discarded – undo
522 541
 		$start_adapter = $this->filesystem->get_adapter($filesystem);
523 542
 		$start_filesystem = $this->filesystem->get_adapter($filesystem);
524 543
 		
525
-		if(!$file_info['path'])
526
-			return;
544
+		if(!$file_info['path']) {
545
+					return;
546
+		}
527 547
 		
528
-		if(isset($file_info['archive_prefix_path']))	
529
-			$file_info['target_path'] = $file_info['archive_prefix_path']."/".$file_info['path'];
530
-		else
531
-			$file_info['target_path'] = $file_info['path'];
548
+		if(isset($file_info['archive_prefix_path'])) {
549
+					$file_info['target_path'] = $file_info['archive_prefix_path']."/".$file_info['path'];
550
+		} else {
551
+					$file_info['target_path'] = $file_info['path'];
552
+		}
532 553
 			
533 554
 		$last_position = $start_at_byte;
534 555
 		
@@ -538,8 +559,7 @@  discard block
 block discarded – undo
538 559
 			$bytes_wrote = $file_info['size'];
539 560
 			$this->logger->info(sprintf("Adding %s bytes of file %s to archive %s ", $bytes_wrote, $file_info['target_path'], $this->get_archive_name_with_extension()));
540 561
 			$this->backup_archive->addFile($start_adapter->applyPathPrefix($file_info['path']), $file_info['target_path']);
541
-		}
542
-		else{	
562
+		} else{	
543 563
 			$tmp_file = md5($file_info['path']);
544 564
 			
545 565
 			//we isolate file to tmp if we are at byte 0, the starting point of file reading
@@ -548,16 +568,16 @@  discard block
 block discarded – undo
548 568
 				$this->logger->info(sprintf("Copying %s file to tmp filesystem file %s to prevent reading changes", $file_info['path'], $tmp_file));
549 569
 				$file_stream = $start_filesystem->readStream($file_info['path']);
550 570
 				
551
-				if(is_resource($file_stream['stream']))
552
-					$this->filesystem->get_tmp_filesystem()->writeStream($tmp_file, $file_stream['stream']);
571
+				if(is_resource($file_stream['stream'])) {
572
+									$this->filesystem->get_tmp_filesystem()->writeStream($tmp_file, $file_stream['stream']);
573
+				}
553 574
 			}
554 575
 			
555 576
 			if($this->filesystem->get_tmp_filesystem()->has($tmp_file))
556 577
 			{
557 578
 				$is_tmp = 1;
558 579
 				$last_position = $this->backup_archive->appendFileData($this->filesystem->get_tmp_filesystem_adapter()->applyPathPrefix($tmp_file), $file_info['target_path'], $start_at_byte, $byte_limit);
559
-			}
560
-			else{
580
+			} else{
561 581
 				$is_tmp = 0;
562 582
 				$last_position = $this->backup_archive->appendFileData($start_adapter->applyPathPrefix($file_info['path']), $file_info['target_path'], $start_at_byte, $byte_limit);
563 583
 			}
@@ -566,8 +586,7 @@  discard block
 block discarded – undo
566 586
 			if($last_position == -1)
567 587
 			{
568 588
 				$bytes_wrote = $file_info['size'] - $start_at_byte;
569
-			}
570
-			else
589
+			} else
571 590
 			{
572 591
 				$bytes_wrote = $last_position - $start_at_byte;
573 592
 			}
@@ -576,8 +595,7 @@  discard block
 block discarded – undo
576 595
 			if($is_tmp)
577 596
 			{
578 597
 				$this->logger->info(sprintf("Appended %s bytes, starting position %s, of tmp file %s (%s) to archive %s ", $bytes_wrote, $start_at_byte, $tmp_file, $file_info['target_path'], $this->get_archive_name()));
579
-			}
580
-			else{
598
+			} else{
581 599
 				$this->logger->info(sprintf("Appended %s bytes, starting position %s, of original file %s to archive %s ", $bytes_wrote, $start_at_byte, $file_info['target_path'], $tmp_file, $this->get_archive_name()));
582 600
 			}
583 601
 			
Please login to merge, or discard this patch.
includes/class-xcloner-settings.php 1 patch
Braces   +77 added lines, -54 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	?>
Please login to merge, or discard this patch.