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 ( 637491...478ef7 )
by Liuta
08:06 queued 05:23
created
includes/class-xcloner-api.php 4 patches
Unused Use Statements   -5 removed lines patch added patch discarded remove patch
@@ -2,13 +2,8 @@
 block discarded – undo
2 2
 
3 3
 use League\Flysystem\Config;
4 4
 use League\Flysystem\Filesystem;
5
-use League\Flysystem\Util;
6 5
 use League\Flysystem\Adapter\Local;
7
-
8 6
 use splitbrain\PHPArchive\Tar;
9
-use splitbrain\PHPArchive\Zip;
10
-use splitbrain\PHPArchive\Archive;
11
-use splitbrain\PHPArchive\FileInfo;
12 7
 
13 8
 
14 9
 class Xcloner_Api{
Please login to merge, or discard this patch.
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -200,12 +200,12 @@  discard block
 block discarded – undo
200 200
 			$scheduler->update_cron_hook($_POST['id']);
201 201
 			
202 202
 		if( $wpdb->last_error ) {
203
-            $response['error'] = 1;
204
-            $response['error_message'] = $wpdb->last_error/*."--".$wpdb->last_query*/;
203
+			$response['error'] = 1;
204
+			$response['error_message'] = $wpdb->last_error/*."--".$wpdb->last_query*/;
205 205
             
206
-        }
206
+		}
207 207
         
208
-        $scheduler->update_wp_cron_hooks();
208
+		$scheduler->update_wp_cron_hooks();
209 209
 		$response['finished'] = 1;
210 210
 		
211 211
 		$this->send_response($response);
@@ -851,14 +851,14 @@  discard block
 block discarded – undo
851 851
 		$tar->close();
852 852
 		
853 853
 		if (file_exists($tmp_file)) {
854
-		    header('Content-Description: File Transfer');
855
-		    header('Content-Type: application/octet-stream');
856
-		    header('Content-Disposition: attachment; filename="'.basename($tmp_file).'"');
857
-		    header('Expires: 0');
858
-		    header('Cache-Control: must-revalidate');
859
-		    header('Pragma: public');
860
-		    header('Content-Length: ' . filesize($tmp_file));
861
-		    readfile($tmp_file);
854
+			header('Content-Description: File Transfer');
855
+			header('Content-Type: application/octet-stream');
856
+			header('Content-Disposition: attachment; filename="'.basename($tmp_file).'"');
857
+			header('Expires: 0');
858
+			header('Cache-Control: must-revalidate');
859
+			header('Pragma: public');
860
+			header('Content-Length: ' . filesize($tmp_file));
861
+			readfile($tmp_file);
862 862
 		    
863 863
 		}
864 864
 		
@@ -888,25 +888,25 @@  discard block
 block discarded – undo
888 888
 		
889 889
 		
890 890
 		header('Pragma: public');
891
-	    header('Expires: 0');
892
-	    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
893
-	    header('Cache-Control: private', false);
894
-	    header('Content-Transfer-Encoding: binary');
895
-	    header('Content-Disposition: attachment; filename="'.$metadata['path'].'";');
896
-	    //header('Content-Type: ' . $mimetype);
897
-	    header('Content-Type: application/octet-stream');
898
-	    header('Content-Length: ' . $metadata['size']);
891
+		header('Expires: 0');
892
+		header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
893
+		header('Cache-Control: private', false);
894
+		header('Content-Transfer-Encoding: binary');
895
+		header('Content-Disposition: attachment; filename="'.$metadata['path'].'";');
896
+		//header('Content-Type: ' . $mimetype);
897
+		header('Content-Type: application/octet-stream');
898
+		header('Content-Length: ' . $metadata['size']);
899 899
 	    
900
-	    @ob_end_clean();
900
+		@ob_end_clean();
901 901
 	    
902
-	    $chunkSize = 1024 * 1024;
903
-	    while (!feof($read_stream))
904
-	    {
905
-	        $buffer = fread($read_stream, $chunkSize);
906
-	        echo $buffer;
907
-	    }
908
-	    fclose($read_stream);
909
-	    exit;
902
+		$chunkSize = 1024 * 1024;
903
+		while (!feof($read_stream))
904
+		{
905
+			$buffer = fread($read_stream, $chunkSize);
906
+			echo $buffer;
907
+		}
908
+		fclose($read_stream);
909
+		exit;
910 910
     
911 911
 	}
912 912
 	
Please login to merge, or discard this patch.
Spacing   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 use splitbrain\PHPArchive\FileInfo;
12 12
 
13 13
 
14
-class Xcloner_Api{
14
+class Xcloner_Api {
15 15
 
16 16
 	private $xcloner_database;
17 17
 	private $xcloner_settings;
@@ -27,33 +27,33 @@  discard block
 block discarded – undo
27 27
 		global $wpdb;
28 28
 		
29 29
 		error_reporting(0);
30
-		if( ob_get_length() )
30
+		if (ob_get_length())
31 31
 			ob_end_clean();
32 32
 		ob_start();
33 33
 		
34
-		$wpdb->show_errors		= false;
34
+		$wpdb->show_errors = false;
35 35
 		
36
-		$this->xcloner_settings 		= new Xcloner_Settings();
36
+		$this->xcloner_settings = new Xcloner_Settings();
37 37
 		
38 38
 		//generating the hash suffix for tmp xcloner store folder
39
-		if(isset($_POST['hash'])){
39
+		if (isset($_POST['hash'])) {
40 40
 			
41
-			if($_POST['hash'] == "generate_hash")
41
+			if ($_POST['hash'] == "generate_hash")
42 42
 				$this->xcloner_settings->generate_new_hash();
43 43
 			else
44 44
 				$this->xcloner_settings->set_hash($_POST['hash']);
45 45
 		}
46 46
 
47
-		$this->logger 					= new XCloner_Logger("xcloner_api", $this->xcloner_settings->get_hash());
47
+		$this->logger = new XCloner_Logger("xcloner_api", $this->xcloner_settings->get_hash());
48 48
 		$this->xcloner_file_system 		= new Xcloner_File_System($this->xcloner_settings->get_hash());
49 49
 		$this->xcloner_sanitization 	= new Xcloner_Sanitization();
50 50
 		$this->xcloner_requirements 	= new XCloner_Requirements();
51
-		$this->archive_system 			= new Xcloner_Archive($this->xcloner_settings->get_hash());
52
-		$this->xcloner_database 		= new XCloner_Database($this->xcloner_settings->get_hash());
51
+		$this->archive_system = new Xcloner_Archive($this->xcloner_settings->get_hash());
52
+		$this->xcloner_database = new XCloner_Database($this->xcloner_settings->get_hash());
53 53
 		
54 54
 		
55
-		if(isset($_POST['API_ID'])){
56
-			$this->logger->info("Processing ajax request ID ".substr($this->xcloner_sanitization->sanitize_input_as_string($_POST['API_ID']), 0 , 15));
55
+		if (isset($_POST['API_ID'])) {
56
+			$this->logger->info("Processing ajax request ID ".substr($this->xcloner_sanitization->sanitize_input_as_string($_POST['API_ID']), 0, 15));
57 57
 		}
58 58
 		
59 59
 	}
@@ -69,16 +69,16 @@  discard block
 block discarded – undo
69 69
 		$data['dbDatabase'] = $this->xcloner_settings->get_db_database();
70 70
 		
71 71
 		
72
-		$data['recordsPerSession'] 		= $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request');
73
-		$data['TEMP_DBPROCESS_FILE'] 	= $this->xcloner_settings->get_xcloner_tmp_path().DS.".database";
74
-		$data['TEMP_DUMP_FILE'] 		= $this->xcloner_settings->get_xcloner_tmp_path().DS."database-sql.sql";
72
+		$data['recordsPerSession'] = $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request');
73
+		$data['TEMP_DBPROCESS_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path().DS.".database";
74
+		$data['TEMP_DUMP_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path().DS."database-sql.sql";
75 75
 		
76 76
 		try
77 77
 		{
78 78
 			//$xcloner_db = new XCloner_Database($data['dbUsername'], $data['dbPassword'], $data['dbDatabase'], $data['dbHostname']);
79 79
 			$this->xcloner_database->init($data);
80 80
 
81
-		}catch(Exception $e)
81
+		}catch (Exception $e)
82 82
 		{
83 83
 			$this->send_response($e->getMessage());
84 84
 			$this->logger->error($e->getMessage());
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 		$params = array();
107 107
 		$schedule = array();
108 108
 		
109
-		if(isset($_POST['data']))
109
+		if (isset($_POST['data']))
110 110
 			$params = json_decode(stripslashes($_POST['data']));
111 111
 		
112 112
 		$this->process_params($params);
113 113
 		
114
-		if(isset($_POST['id']))
114
+		if (isset($_POST['id']))
115 115
 		{
116 116
 			
117 117
 			$this->form_params['backup_params']['backup_name'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['backup_name']);
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 			$tables = explode(PHP_EOL, $this->form_params['database']);
127 127
 			$return = array();
128 128
 			
129
-			foreach($tables as $table)
129
+			foreach ($tables as $table)
130 130
 			{
131
-					$table = str_replace("\r","", $table);
131
+					$table = str_replace("\r", "", $table);
132 132
 					$data = explode(".", $table);
133
-					if(isset($data[1]))
133
+					if (isset($data[1]))
134 134
 						$return[$data[0]][] = $data[1];
135 135
 			}
136 136
 			
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
 			$excluded_files = explode(PHP_EOL, $this->form_params['excluded_files']);
140 140
 			$return = array();
141 141
 			
142
-			foreach($excluded_files as $file)
142
+			foreach ($excluded_files as $file)
143 143
 			{
144
-				$file = str_replace("\r","", $file);
145
-				if($file)
144
+				$file = str_replace("\r", "", $file);
145
+				if ($file)
146 146
 					$return[] = $file;
147 147
 			}
148 148
 			
@@ -151,20 +151,20 @@  discard block
 block discarded – undo
151 151
 			//print_r($this->form_params['database'] );
152 152
 			//print_r($this->form_params['excluded_files']);
153 153
 			
154
-			$schedule['start_at'] = $this->form_params['backup_params']['start_at'] ;
154
+			$schedule['start_at'] = $this->form_params['backup_params']['start_at'];
155 155
 			
156
-			if(!isset($_POST['status']))
156
+			if (!isset($_POST['status']))
157 157
 				$schedule['status'] = 0;
158 158
 			else	
159 159
 				$schedule['status'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['status']);
160
-		}else{
160
+		} else {
161 161
 		
162 162
 			$schedule['status'] = 1;
163
-			$schedule['start_at'] = strtotime($this->form_params['backup_params']['schedule_start_date'] .
163
+			$schedule['start_at'] = strtotime($this->form_params['backup_params']['schedule_start_date'].
164 164
 								" ".$this->form_params['backup_params']['schedule_start_time']);
165 165
 		}
166 166
 		
167
-		if(!$schedule['start_at'])						
167
+		if (!$schedule['start_at'])						
168 168
 			$schedule['start_at'] = time();
169 169
 		
170 170
 		$schedule['start_at'] = date('Y-m-d H:i:s', $schedule['start_at']);	
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 		
176 176
 		$schedule['params'] = json_encode($this->form_params);
177 177
 		
178
-		if(!isset($_POST['id']))
178
+		if (!isset($_POST['id']))
179 179
 		{
180 180
 			$insert = $wpdb->insert( 
181 181
 				$wpdb->prefix.'xcloner_scheduler', 
@@ -185,21 +185,21 @@  discard block
 block discarded – undo
185 185
 					'%s' 
186 186
 				) 
187 187
 			);
188
-		}else		{
188
+		} else {
189 189
 			$insert = $wpdb->update( 
190 190
 				$wpdb->prefix.'xcloner_scheduler', 
191 191
 				$schedule, 
192
-				array( 'id' => $_POST['id'] ), 
192
+				array('id' => $_POST['id']), 
193 193
 				array( 
194 194
 					'%s', 
195 195
 					'%s' 
196 196
 				) 
197 197
 			);
198 198
 		}
199
-		if(isset($_POST['id']))
199
+		if (isset($_POST['id']))
200 200
 			$scheduler->update_cron_hook($_POST['id']);
201 201
 			
202
-		if( $wpdb->last_error ) {
202
+		if ($wpdb->last_error) {
203 203
             $response['error'] = 1;
204 204
             $response['error_message'] = $wpdb->last_error/*."--".$wpdb->last_query*/;
205 205
             
@@ -224,19 +224,19 @@  discard block
 block discarded – undo
224 224
 		
225 225
 		$params = json_decode(stripslashes($_POST['data']));
226 226
 		
227
-		$init 	= (int)$_POST['init'];
227
+		$init = (int)$_POST['init'];
228 228
 		
229
-		if($params === NULL)
230
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
229
+		if ($params === NULL)
230
+			 die('{"status":false,"msg":"The post_data parameter must be valid JSON"}');
231 231
 			 
232 232
 		$this->process_params($params);
233 233
 		
234 234
 		$return['finished'] = 1;
235 235
 
236 236
 		//$return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], $this->form_params['extra'], $init);
237
-		try{
237
+		try {
238 238
 			$return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], $this->form_params['extra'], $init);
239
-		}catch(Exception $e)
239
+		}catch (Exception $e)
240 240
 		{
241 241
 			$return = array();
242 242
 			$return['error'] = true;
@@ -245,25 +245,25 @@  discard block
 block discarded – undo
245 245
 			return $this->send_response($return, $hash = 1);
246 246
 		}
247 247
 		
248
-		if($return['finished'])
248
+		if ($return['finished'])
249 249
 		{
250 250
 			$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_with_extension();
251
-			if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension()))
251
+			if ($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension()))
252 252
 				$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart();
253 253
 		}
254 254
 		
255 255
 		$data = $return;
256 256
 		
257 257
 		//check if backup is finished
258
-		if($return['finished'] )
258
+		if ($return['finished'])
259 259
 		{
260
-			if(isset($this->form_params['backup_params']['email_notification']) and $to=$this->form_params['backup_params']['email_notification'])
260
+			if (isset($this->form_params['backup_params']['email_notification']) and $to = $this->form_params['backup_params']['email_notification'])
261 261
 			{
262
-				try{
262
+				try {
263 263
 					$from = "";
264 264
 					$subject = "";
265 265
 					$this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'], $this->form_params);
266
-				}catch(Exception $e)
266
+				}catch (Exception $e)
267 267
 				{
268 268
 					$this->logger->error($e->getMessage());
269 269
 				}
@@ -287,17 +287,17 @@  discard block
 block discarded – undo
287 287
 		
288 288
 		$params = json_decode(stripslashes($_POST['data']));
289 289
 		
290
-		$init 	= (int)$_POST['init'];
290
+		$init = (int)$_POST['init'];
291 291
 		
292
-		if($params === NULL)
293
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
292
+		if ($params === NULL)
293
+			 die('{"status":false,"msg":"The post_data parameter must be valid JSON"}');
294 294
 		
295 295
 		$this->process_params($params);
296 296
 			
297 297
 		//$xcloner_database = $this->init_db();	
298 298
 		$return = $this->xcloner_database->start_database_recursion($this->form_params['database'], $this->form_params['extra'], $init);
299 299
 		
300
-		if(isset($return['error']) and $return['error'])
300
+		if (isset($return['error']) and $return['error'])
301 301
 			$data['finished'] = 1;
302 302
 		else	
303 303
 			$data['finished'] = $return['finished'];
@@ -319,10 +319,10 @@  discard block
 block discarded – undo
319 319
 		}
320 320
 		
321 321
 		$params = json_decode(stripslashes($_POST['data']));
322
-		$init 	= (int)$_POST['init'];
322
+		$init = (int)$_POST['init'];
323 323
 		
324
-		if($params === NULL)
325
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
324
+		if ($params === NULL)
325
+			 die('{"status":false,"msg":"The post_data parameter must be valid JSON"}');
326 326
 			 
327 327
 		$hash = $this->process_params($params);
328 328
 		
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 		$data["finished"] = !$return;
334 334
 		$data["total_files_num"] = $this->xcloner_file_system->get_scanned_files_num();
335 335
 		$data["last_logged_file"] = $this->xcloner_file_system->last_logged_file();
336
-		$data["total_files_size"] = sprintf("%.2f",$this->xcloner_file_system->get_scanned_files_total_size()/(1024*1024));
336
+		$data["total_files_size"] = sprintf("%.2f", $this->xcloner_file_system->get_scanned_files_total_size() / (1024 * 1024));
337 337
 		
338 338
 		return $this->send_response($data, $hash = 1);
339 339
 	}
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 	 */ 
346 346
 	private function process_params($params)
347 347
 	{
348
-		if(isset($params->hash))
348
+		if (isset($params->hash))
349 349
 			$this->xcloner_settings->set_hash($params->hash);
350 350
 			
351 351
 		$this->form_params['extra'] = array();
@@ -353,9 +353,9 @@  discard block
 block discarded – undo
353 353
 		
354 354
 		$this->form_params['database'] = array();
355 355
 		
356
-		if(isset($params->backup_params))
356
+		if (isset($params->backup_params))
357 357
 		{
358
-			foreach($params->backup_params as $param)
358
+			foreach ($params->backup_params as $param)
359 359
 			{
360 360
 				$this->form_params['backup_params'][$param->name] = $this->xcloner_sanitization->sanitize_input_as_string($param->value);
361 361
 				$this->logger->debug("Adding form parameter ".$param->name.".".$param->value."\n", array('POST', 'fields filter'));
@@ -364,28 +364,28 @@  discard block
 block discarded – undo
364 364
 		
365 365
 		$this->form_params['database'] = array();
366 366
 		
367
-		if(isset($params->table_params))
367
+		if (isset($params->table_params))
368 368
 		{
369
-			foreach($params->table_params as $param)
369
+			foreach ($params->table_params as $param)
370 370
 			{
371 371
 				$this->form_params['database'][$param->parent][] = $this->xcloner_sanitization->sanitize_input_as_raw($param->id);
372 372
 				$this->logger->debug("Adding database filter ".$param->parent.".".$param->id."\n", array('POST', 'database filter'));
373 373
 			}
374 374
 		}
375 375
 		
376
-		$this->form_params['excluded_files'] =  array();
377
-		if(isset($params->files_params))
376
+		$this->form_params['excluded_files'] = array();
377
+		if (isset($params->files_params))
378 378
 		{
379
-			foreach($params->files_params as $param)
379
+			foreach ($params->files_params as $param)
380 380
 			{
381 381
 				$this->form_params['excluded_files'][] = $this->xcloner_sanitization->sanitize_input_as_relative_path($param->id);
382 382
 			}
383 383
 			
384 384
 			$unique_exclude_files = array();
385 385
 			
386
-			foreach($params->files_params as $key=>$param)
386
+			foreach ($params->files_params as $key=>$param)
387 387
 			{
388
-				if(!in_array($param->parent, $this->form_params['excluded_files'])){
388
+				if (!in_array($param->parent, $this->form_params['excluded_files'])) {
389 389
 				//$this->form_params['excluded_files'][] = $this->xcloner_sanitization->sanitize_input_as_relative_path($param->id);
390 390
 					$unique_exclude_files[] = $param->id;
391 391
 					$this->logger->debug("Adding file filter ".$param->id."\n", array('POST', 'exclude files filter'));
@@ -397,9 +397,9 @@  discard block
 block discarded – undo
397 397
 		
398 398
 		//$this->form_params['excluded_files'] =  array_merge($this->form_params['excluded_files'], $this->exclude_files_by_default);
399 399
 		
400
-		if(isset($params->extra))
400
+		if (isset($params->extra))
401 401
 		{
402
-			foreach($params->extra as $key=>$value)
402
+			foreach ($params->extra as $key=>$value)
403 403
 				$this->form_params['extra'][$key] = $this->xcloner_sanitization->sanitize_input_as_raw($value);
404 404
 		}
405 405
 			
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 		
422 422
 		$data = array();
423 423
 		
424
-		if($folder == "#"){
424
+		if ($folder == "#") {
425 425
 			
426 426
 			$folder = "/";
427 427
 			//$list_directory = $this->xcloner_settings->get_xcloner_start_path();
@@ -435,9 +435,9 @@  discard block
 block discarded – undo
435 435
 						);
436 436
 		}
437 437
 			
438
-			try{
438
+			try {
439 439
 				$files = $this->xcloner_file_system->list_directory($folder);
440
-			}catch(Exception $e){
440
+			}catch (Exception $e) {
441 441
 				
442 442
 				print $e->getMessage();
443 443
 				$this->logger->error($e->getMessage());
@@ -452,19 +452,19 @@  discard block
 block discarded – undo
452 452
 			}
453 453
 			array_multisort($type, SORT_ASC, $files);
454 454
 			
455
-			foreach($files as $file)
455
+			foreach ($files as $file)
456 456
 			{
457 457
 				$children = false;
458 458
 				$text = $file['basename'];
459 459
 				
460
-				if($file['type'] == "dir")
460
+				if ($file['type'] == "dir")
461 461
 					$children = true;
462 462
 				else
463
-					 $text .= " (". $this->xcloner_requirements->file_format_size($file['size']).")";
463
+					 $text .= " (".$this->xcloner_requirements->file_format_size($file['size']).")";
464 464
 				
465 465
 				//if(in_array($file['path'], $this->xcloner_file_system->get_excluded_files()))
466 466
 				//echo $file['path']."--".$this->xcloner_file_system->is_excluded($file);
467
-				if($excluded_pattern = $this->xcloner_file_system->is_excluded($file))
467
+				if ($excluded_pattern = $this->xcloner_file_system->is_excluded($file))
468 468
 					$selected = true;
469 469
 				else
470 470
 					$selected = false;
@@ -501,25 +501,25 @@  discard block
 block discarded – undo
501 501
 		
502 502
 		$xcloner_backup_only_wp_tables = $this->xcloner_settings->get_xcloner_option('xcloner_backup_only_wp_tables');
503 503
 	
504
-		if($database == "#")
504
+		if ($database == "#")
505 505
 		{
506
-			try{
506
+			try {
507 507
 				$return = $this->xcloner_database->get_all_databases();
508
-			}catch(Exception $e){
508
+			}catch (Exception $e) {
509 509
 				$this->logger->error($e->getMessage());
510 510
 			}
511 511
 			
512
-			foreach($return as $database)
512
+			foreach ($return as $database)
513 513
 			{
514
-				if($xcloner_backup_only_wp_tables and $database['name'] != $this->xcloner_settings->get_db_database())
514
+				if ($xcloner_backup_only_wp_tables and $database['name'] != $this->xcloner_settings->get_db_database())
515 515
 					continue;
516 516
 					
517 517
 				$state = array();
518 518
 				
519
-				if($database['name'] == $this->xcloner_settings->get_db_database())
519
+				if ($database['name'] == $this->xcloner_settings->get_db_database())
520 520
 				{
521 521
 					$state['selected'] = true;
522
-					if($database['num_tables'] < 25)
522
+					if ($database['num_tables'] < 25)
523 523
 						$state['opened'] = false;
524 524
 				}
525 525
 					
@@ -535,22 +535,22 @@  discard block
 block discarded – undo
535 535
 			
536 536
 		}
537 537
 		
538
-		else{
538
+		else {
539 539
 			
540
-			try{
540
+			try {
541 541
 				$return = $this->xcloner_database->list_tables($database, "", 1);
542
-			}catch(Exception $e){
542
+			}catch (Exception $e) {
543 543
 				$this->logger->error($e->getMessage());
544 544
 			}
545 545
 			
546
-			foreach($return as $table)
546
+			foreach ($return as $table)
547 547
 			{
548 548
 				$state = array();
549 549
 				
550
-				if($xcloner_backup_only_wp_tables and !stristr($table['name'], $this->xcloner_settings->get_table_prefix()))
550
+				if ($xcloner_backup_only_wp_tables and !stristr($table['name'], $this->xcloner_settings->get_table_prefix()))
551 551
 					continue;
552 552
 				
553
-				if(isset($database['name']) and $database['name'] == $this->xcloner_settings->get_db_database())
553
+				if (isset($database['name']) and $database['name'] == $this->xcloner_settings->get_db_database())
554 554
 					$state = array('selected' => true);
555 555
 					
556 556
 				$data[] = array(
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 		
581 581
 		$schedule_id = $this->xcloner_sanitization->sanitize_input_as_int($_GET['id']);
582 582
 		$scheduler = new Xcloner_Scheduler();
583
-		$data  = $scheduler->get_schedule_by_id($schedule_id);
583
+		$data = $scheduler->get_schedule_by_id($schedule_id);
584 584
 		
585 585
 		return $this->send_response($data);
586 586
 	}
@@ -597,14 +597,14 @@  discard block
 block discarded – undo
597 597
 		}
598 598
 		
599 599
 		$scheduler = new Xcloner_Scheduler();
600
-		$data  = $scheduler->get_scheduler_list();
600
+		$data = $scheduler->get_scheduler_list();
601 601
 		$return['data'] = array();
602 602
 		
603
-		foreach($data as $res)
603
+		foreach ($data as $res)
604 604
 		{
605 605
 			$action = "<a href=\"#".$res->id."\" class=\"edit\" title='Edit'> <i class=\"material-icons \">edit</i></a> 
606 606
 					<a href=\"#".$res->id."\" class=\"delete\" title='Delete'><i class=\"material-icons  \">delete</i></a>";
607
-			if($res->status)
607
+			if ($res->status)
608 608
 				$status = '<i class="material-icons active status">timer</i>';
609 609
 			else
610 610
 				$status = '<i class="material-icons status inactive">timer_off</i>';
@@ -615,14 +615,14 @@  discard block
 block discarded – undo
615 615
 			
616 616
 			$remote_storage = $res->remote_storage;
617 617
 			
618
-			if(!$next_run_time >= time())
618
+			if (!$next_run_time >= time())
619 619
 				$next_run = " ";
620 620
 			
621
-			if(trim($next_run))
621
+			if (trim($next_run))
622 622
 			{
623 623
 				$date_text = $next_run;
624 624
 				
625
-				if($next_run_time >= time())
625
+				if ($next_run_time >= time())
626 626
 					$next_run = "in ".human_time_diff($next_run_time, time());
627 627
 				else
628 628
 					$next_run = __("executed", 'xcloner-backup-and-restore');
@@ -635,9 +635,9 @@  discard block
 block discarded – undo
635 635
 			$backup_size = "";
636 636
 			$backup_time = "";
637 637
 			
638
-			if($res->last_backup)
638
+			if ($res->last_backup)
639 639
 			{
640
-				if( $this->xcloner_file_system->get_storage_filesystem()->has($res->last_backup))
640
+				if ($this->xcloner_file_system->get_storage_filesystem()->has($res->last_backup))
641 641
 				{
642 642
 					$metadata = $this->xcloner_file_system->get_storage_filesystem()->getMetadata($res->last_backup);
643 643
 					$backup_size  = size_format($metadata['size']);
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 				$backup_text = "<span title='".$backup_time."' class='shorten_string'>".$res->last_backup." (".$backup_size.")</span>";
648 648
 			}
649 649
 				
650
-			$return['data'][] = array($res->id, $res->name, $res->recurrence,/*$res->start_at,*/ $next_run, $remote_storage, $backup_text, $status, $action);
650
+			$return['data'][] = array($res->id, $res->name, $res->recurrence, /*$res->start_at,*/ $next_run, $remote_storage, $backup_text, $status, $action);
651 651
 		}
652 652
 		
653 653
 		return $this->send_response($return, 0);
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 		
667 667
 		$schedule_id = $this->xcloner_sanitization->sanitize_input_as_int($_GET['id']);
668 668
 		$scheduler = new Xcloner_Scheduler();
669
-		$data['finished']  = $scheduler->delete_schedule_by_id($schedule_id);
669
+		$data['finished'] = $scheduler->delete_schedule_by_id($schedule_id);
670 670
 		
671 671
 		return $this->send_response($data);
672 672
 	}
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 		
685 685
 		$backup_name = $this->xcloner_sanitization->sanitize_input_as_string($_POST['name']);
686 686
 		
687
-		$data['finished']  = $this->xcloner_file_system->delete_backup_by_name($backup_name);
687
+		$data['finished'] = $this->xcloner_file_system->delete_backup_by_name($backup_name);
688 688
 		
689 689
 		return $this->send_response($data);
690 690
 	}
@@ -701,32 +701,32 @@  discard block
 block discarded – undo
701 701
 		
702 702
 		$backup_file = $source_backup_file;
703 703
 		
704
-		if($this->xcloner_file_system->is_multipart($backup_file))
704
+		if ($this->xcloner_file_system->is_multipart($backup_file))
705 705
 		{
706 706
 			$backup_parts = $this->xcloner_file_system->get_multipart_files($backup_file);
707 707
 			$backup_file = $backup_parts[$return['part']];
708 708
 		}
709 709
 		
710
-		try{
710
+		try {
711 711
 			$tar = new Tar();
712 712
 			$tar->open($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file, $start);
713 713
 		
714 714
 			$data = $tar->contents(get_option('xcloner_files_to_process_per_request'));
715
-		}catch(Exception $e)
715
+		}catch (Exception $e)
716 716
 		{
717 717
 			$return['error'] = true;
718 718
 			$return['message'] = $e->getMessage();
719 719
 			$this->send_response($return, 0);
720 720
 		}
721 721
 		
722
-		$return['files'] 		= array();
723
-		$return['finished'] 	= 1;
724
-		$return['total_size'] 	= filesize($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file);
722
+		$return['files'] = array();
723
+		$return['finished'] = 1;
724
+		$return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file);
725 725
 		$i = 0;
726 726
 		
727
-		if(isset($data['extracted_files']) and is_array($data['extracted_files']))
727
+		if (isset($data['extracted_files']) and is_array($data['extracted_files']))
728 728
 		{
729
-			foreach($data['extracted_files'] as $file)
729
+			foreach ($data['extracted_files'] as $file)
730 730
 			{
731 731
 				$return['files'][$i]['path'] = $file->getPath();
732 732
 				$return['files'][$i]['size'] = $file->getSize();
@@ -736,18 +736,18 @@  discard block
 block discarded – undo
736 736
 			}
737 737
 		}
738 738
 		
739
-		if(isset($data['start']))
739
+		if (isset($data['start']))
740 740
 		{
741 741
 			$return['start'] = $data['start'];
742 742
 			$return['finished'] = 0;	
743
-		}else{
744
-			if($this->xcloner_file_system->is_multipart($source_backup_file))
743
+		} else {
744
+			if ($this->xcloner_file_system->is_multipart($source_backup_file))
745 745
 			{
746 746
 				$return['start'] = 0;
747 747
 				
748 748
 				++$return['part'];
749 749
 			
750
-				if($return['part'] < sizeof($backup_parts))	
750
+				if ($return['part'] < sizeof($backup_parts))	
751 751
 					$return['finished'] = 0;
752 752
 				
753 753
 			}
@@ -776,17 +776,17 @@  discard block
 block discarded – undo
776 776
 		
777 777
 		try
778 778
 		{
779
-			if(method_exists($xcloner_remote_storage, "upload_backup_to_storage"))
779
+			if (method_exists($xcloner_remote_storage, "upload_backup_to_storage"))
780 780
 			{
781 781
 				$return = call_user_func_array(array($xcloner_remote_storage, "upload_backup_to_storage"), array($backup_file, $storage_type));
782 782
 			}
783
-		}catch(Exception $e){
783
+		}catch (Exception $e) {
784 784
 		
785 785
 			$return['error'] = 1;
786 786
 			$return['message'] = $e->getMessage();
787 787
 		}
788 788
 		
789
-		if(!$return)
789
+		if (!$return)
790 790
 		{
791 791
 			$return['error'] = 1;
792 792
 			$return['message'] = "Upload failed, please check the error log for more information!";
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 		
825 825
 		@ob_end_clean();
826 826
 		
827
-		$adapter = new Local(dirname(__DIR__) ,LOCK_EX, 'SKIP_LINKS');
827
+		$adapter = new Local(dirname(__DIR__), LOCK_EX, 'SKIP_LINKS');
828 828
 		$xcloner_plugin_filesystem = new Filesystem($adapter, new Config([
829 829
 				'disable_asserts' => true,
830 830
 			]));
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 		//$tar->addFile(dirname(__DIR__)."/restore/vendor.tgz", "vendor.tgz");
839 839
 		
840 840
 		$files = $xcloner_plugin_filesystem->listContents("vendor/", true);
841
-		foreach($files as $file)
841
+		foreach ($files as $file)
842 842
 		{
843 843
 			$tar->addFile(dirname(__DIR__).DS.$file['path'], $file['path']);
844 844
 		}
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
 		    header('Expires: 0');
858 858
 		    header('Cache-Control: must-revalidate');
859 859
 		    header('Pragma: public');
860
-		    header('Content-Length: ' . filesize($tmp_file));
860
+		    header('Content-Length: '.filesize($tmp_file));
861 861
 		    readfile($tmp_file);
862 862
 		    
863 863
 		}
@@ -882,9 +882,9 @@  discard block
 block discarded – undo
882 882
 		$backup_name = $this->xcloner_sanitization->sanitize_input_as_string($_GET['name']);
883 883
 		
884 884
 		
885
-		$metadata  = $this->xcloner_file_system->get_storage_filesystem()->getMetadata($backup_name);
885
+		$metadata = $this->xcloner_file_system->get_storage_filesystem()->getMetadata($backup_name);
886 886
 		//$mimetype  = $this->xcloner_file_system->get_storage_filesystem()->getMimetype($backup_name);
887
-		$read_stream  = $this->xcloner_file_system->get_storage_filesystem()->readStream($backup_name);
887
+		$read_stream = $this->xcloner_file_system->get_storage_filesystem()->readStream($backup_name);
888 888
 		
889 889
 		
890 890
 		header('Pragma: public');
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
 	    header('Content-Disposition: attachment; filename="'.$metadata['path'].'";');
896 896
 	    //header('Content-Type: ' . $mimetype);
897 897
 	    header('Content-Type: application/octet-stream');
898
-	    header('Content-Length: ' . $metadata['size']);
898
+	    header('Content-Length: '.$metadata['size']);
899 899
 	    
900 900
 	    @ob_end_clean();
901 901
 	    
@@ -925,10 +925,10 @@  discard block
 block discarded – undo
925 925
 		$file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
926 926
 		$hash = $this->xcloner_sanitization->sanitize_input_as_string($_POST['hash']);
927 927
 		
928
-		if(isset($_POST['part']))
928
+		if (isset($_POST['part']))
929 929
 			$return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
930 930
 		
931
-		if(isset($_POST['uploaded_size']))
931
+		if (isset($_POST['uploaded_size']))
932 932
 			$return['uploaded_size'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['uploaded_size']);
933 933
 		
934 934
 		$start = $this->xcloner_sanitization->sanitize_input_as_string($_POST['start']);
@@ -936,46 +936,46 @@  discard block
 block discarded – undo
936 936
 		
937 937
 		$return['total_size'] = $this->xcloner_file_system->get_backup_size($file);
938 938
 		
939
-		if($this->xcloner_file_system->is_multipart($file))
939
+		if ($this->xcloner_file_system->is_multipart($file))
940 940
 		{
941 941
 			$backup_parts = $this->xcloner_file_system->get_multipart_files($file);
942 942
 			
943
-			$return['total_parts'] = sizeof($backup_parts)+1;
943
+			$return['total_parts'] = sizeof($backup_parts) + 1;
944 944
 			
945
-			if($return['part'] and isset($backup_parts[$return['part']-1]))
945
+			if ($return['part'] and isset($backup_parts[$return['part'] - 1]))
946 946
 			{
947
-				$file = $backup_parts[$return['part']-1];
947
+				$file = $backup_parts[$return['part'] - 1];
948 948
 			}
949 949
 			
950 950
 			$is_multipart = 1;	
951 951
 		}
952 952
 		
953
-		try{
953
+		try {
954 954
 		
955 955
 			$xcloner_file_transfer = new Xcloner_File_Transfer();
956 956
 			$xcloner_file_transfer->set_target($target_url);
957 957
 			$return['start'] = $xcloner_file_transfer->transfer_file($file, $start, $hash);
958 958
 		
959
-		}catch(Exception $e){
959
+		}catch (Exception $e) {
960 960
 		
961 961
 			$return = array();
962 962
 			$return['error'] = true;
963 963
 			$return['status'] = 500;
964 964
 			$return['message'] = "CURL communication error with the restore host. ".$e->getMessage();
965
-			$this->send_response( $return, 0);
965
+			$this->send_response($return, 0);
966 966
 		
967 967
 		}
968 968
 		
969 969
 		$return['status'] = 200;
970 970
 		
971 971
 		//we have finished the upload
972
-		if(!$return['start'] and $is_multipart)
972
+		if (!$return['start'] and $is_multipart)
973 973
 		{
974 974
 			$return['part']++;
975 975
 			$return['uploaded_size'] += $this->xcloner_file_system->get_storage_filesystem()->getSize($file);
976 976
 		}
977 977
 		
978
-		$this->send_response( $return, 0);
978
+		$this->send_response($return, 0);
979 979
 	}
980 980
 	/*
981 981
 	 * 
@@ -985,12 +985,12 @@  discard block
 block discarded – undo
985 985
 	private function send_response($data, $attach_hash = 1)
986 986
 	{
987 987
 		
988
-		if($attach_hash and null !== $this->xcloner_settings->get_hash())
988
+		if ($attach_hash and null !== $this->xcloner_settings->get_hash())
989 989
 		{
990 990
 			$data['hash'] = $this->xcloner_settings->get_hash();
991 991
 		}
992 992
 			
993
-		if( ob_get_length() )
993
+		if (ob_get_length())
994 994
 			ob_clean();
995 995
 		wp_send_json($data);
996 996
 		
Please login to merge, or discard this patch.
Braces   +111 added lines, -85 removed lines patch added patch discarded remove patch
@@ -27,8 +27,9 @@  discard block
 block discarded – undo
27 27
 		global $wpdb;
28 28
 		
29 29
 		error_reporting(0);
30
-		if( ob_get_length() )
31
-			ob_end_clean();
30
+		if( ob_get_length() ) {
31
+					ob_end_clean();
32
+		}
32 33
 		ob_start();
33 34
 		
34 35
 		$wpdb->show_errors		= false;
@@ -38,10 +39,11 @@  discard block
 block discarded – undo
38 39
 		//generating the hash suffix for tmp xcloner store folder
39 40
 		if(isset($_POST['hash'])){
40 41
 			
41
-			if($_POST['hash'] == "generate_hash")
42
-				$this->xcloner_settings->generate_new_hash();
43
-			else
44
-				$this->xcloner_settings->set_hash($_POST['hash']);
42
+			if($_POST['hash'] == "generate_hash") {
43
+							$this->xcloner_settings->generate_new_hash();
44
+			} else {
45
+							$this->xcloner_settings->set_hash($_POST['hash']);
46
+			}
45 47
 		}
46 48
 
47 49
 		$this->logger 					= new XCloner_Logger("xcloner_api", $this->xcloner_settings->get_hash());
@@ -78,7 +80,7 @@  discard block
 block discarded – undo
78 80
 			//$xcloner_db = new XCloner_Database($data['dbUsername'], $data['dbPassword'], $data['dbDatabase'], $data['dbHostname']);
79 81
 			$this->xcloner_database->init($data);
80 82
 
81
-		}catch(Exception $e)
83
+		} catch(Exception $e)
82 84
 		{
83 85
 			$this->send_response($e->getMessage());
84 86
 			$this->logger->error($e->getMessage());
@@ -106,8 +108,9 @@  discard block
 block discarded – undo
106 108
 		$params = array();
107 109
 		$schedule = array();
108 110
 		
109
-		if(isset($_POST['data']))
110
-			$params = json_decode(stripslashes($_POST['data']));
111
+		if(isset($_POST['data'])) {
112
+					$params = json_decode(stripslashes($_POST['data']));
113
+		}
111 114
 		
112 115
 		$this->process_params($params);
113 116
 		
@@ -130,8 +133,9 @@  discard block
 block discarded – undo
130 133
 			{
131 134
 					$table = str_replace("\r","", $table);
132 135
 					$data = explode(".", $table);
133
-					if(isset($data[1]))
134
-						$return[$data[0]][] = $data[1];
136
+					if(isset($data[1])) {
137
+											$return[$data[0]][] = $data[1];
138
+					}
135 139
 			}
136 140
 			
137 141
 			$this->form_params['database'] = ($return);
@@ -142,8 +146,9 @@  discard block
 block discarded – undo
142 146
 			foreach($excluded_files as $file)
143 147
 			{
144 148
 				$file = str_replace("\r","", $file);
145
-				if($file)
146
-					$return[] = $file;
149
+				if($file) {
150
+									$return[] = $file;
151
+				}
147 152
 			}
148 153
 			
149 154
 			$this->form_params['excluded_files'] = ($return);
@@ -153,19 +158,21 @@  discard block
 block discarded – undo
153 158
 			
154 159
 			$schedule['start_at'] = $this->form_params['backup_params']['start_at'] ;
155 160
 			
156
-			if(!isset($_POST['status']))
157
-				$schedule['status'] = 0;
158
-			else	
159
-				$schedule['status'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['status']);
160
-		}else{
161
+			if(!isset($_POST['status'])) {
162
+							$schedule['status'] = 0;
163
+			} else {
164
+							$schedule['status'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['status']);
165
+			}
166
+		} else{
161 167
 		
162 168
 			$schedule['status'] = 1;
163 169
 			$schedule['start_at'] = strtotime($this->form_params['backup_params']['schedule_start_date'] .
164 170
 								" ".$this->form_params['backup_params']['schedule_start_time']);
165 171
 		}
166 172
 		
167
-		if(!$schedule['start_at'])						
168
-			$schedule['start_at'] = time();
173
+		if(!$schedule['start_at']) {
174
+					$schedule['start_at'] = time();
175
+		}
169 176
 		
170 177
 		$schedule['start_at'] = date('Y-m-d H:i:s', $schedule['start_at']);	
171 178
 		
@@ -185,7 +192,7 @@  discard block
 block discarded – undo
185 192
 					'%s' 
186 193
 				) 
187 194
 			);
188
-		}else		{
195
+		} else		{
189 196
 			$insert = $wpdb->update( 
190 197
 				$wpdb->prefix.'xcloner_scheduler', 
191 198
 				$schedule, 
@@ -196,8 +203,9 @@  discard block
 block discarded – undo
196 203
 				) 
197 204
 			);
198 205
 		}
199
-		if(isset($_POST['id']))
200
-			$scheduler->update_cron_hook($_POST['id']);
206
+		if(isset($_POST['id'])) {
207
+					$scheduler->update_cron_hook($_POST['id']);
208
+		}
201 209
 			
202 210
 		if( $wpdb->last_error ) {
203 211
             $response['error'] = 1;
@@ -226,8 +234,9 @@  discard block
 block discarded – undo
226 234
 		
227 235
 		$init 	= (int)$_POST['init'];
228 236
 		
229
-		if($params === NULL)
230
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
237
+		if($params === NULL) {
238
+					 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
239
+		}
231 240
 			 
232 241
 		$this->process_params($params);
233 242
 		
@@ -236,7 +245,7 @@  discard block
 block discarded – undo
236 245
 		//$return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], $this->form_params['extra'], $init);
237 246
 		try{
238 247
 			$return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], $this->form_params['extra'], $init);
239
-		}catch(Exception $e)
248
+		} catch(Exception $e)
240 249
 		{
241 250
 			$return = array();
242 251
 			$return['error'] = true;
@@ -248,8 +257,9 @@  discard block
 block discarded – undo
248 257
 		if($return['finished'])
249 258
 		{
250 259
 			$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_with_extension();
251
-			if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension()))
252
-				$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart();
260
+			if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension())) {
261
+							$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart();
262
+			}
253 263
 		}
254 264
 		
255 265
 		$data = $return;
@@ -263,7 +273,7 @@  discard block
 block discarded – undo
263 273
 					$from = "";
264 274
 					$subject = "";
265 275
 					$this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'], $this->form_params);
266
-				}catch(Exception $e)
276
+				} catch(Exception $e)
267 277
 				{
268 278
 					$this->logger->error($e->getMessage());
269 279
 				}
@@ -289,18 +299,20 @@  discard block
 block discarded – undo
289 299
 		
290 300
 		$init 	= (int)$_POST['init'];
291 301
 		
292
-		if($params === NULL)
293
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
302
+		if($params === NULL) {
303
+					 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
304
+		}
294 305
 		
295 306
 		$this->process_params($params);
296 307
 			
297 308
 		//$xcloner_database = $this->init_db();	
298 309
 		$return = $this->xcloner_database->start_database_recursion($this->form_params['database'], $this->form_params['extra'], $init);
299 310
 		
300
-		if(isset($return['error']) and $return['error'])
301
-			$data['finished'] = 1;
302
-		else	
303
-			$data['finished'] = $return['finished'];
311
+		if(isset($return['error']) and $return['error']) {
312
+					$data['finished'] = 1;
313
+		} else {
314
+					$data['finished'] = $return['finished'];
315
+		}
304 316
 			
305 317
 		$data['extra'] = $return;
306 318
 		
@@ -321,8 +333,9 @@  discard block
 block discarded – undo
321 333
 		$params = json_decode(stripslashes($_POST['data']));
322 334
 		$init 	= (int)$_POST['init'];
323 335
 		
324
-		if($params === NULL)
325
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
336
+		if($params === NULL) {
337
+					 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
338
+		}
326 339
 			 
327 340
 		$hash = $this->process_params($params);
328 341
 		
@@ -345,8 +358,9 @@  discard block
 block discarded – undo
345 358
 	 */ 
346 359
 	private function process_params($params)
347 360
 	{
348
-		if(isset($params->hash))
349
-			$this->xcloner_settings->set_hash($params->hash);
361
+		if(isset($params->hash)) {
362
+					$this->xcloner_settings->set_hash($params->hash);
363
+		}
350 364
 			
351 365
 		$this->form_params['extra'] = array();
352 366
 		$this->form_params['backup_params'] = array();
@@ -399,8 +413,9 @@  discard block
 block discarded – undo
399 413
 		
400 414
 		if(isset($params->extra))
401 415
 		{
402
-			foreach($params->extra as $key=>$value)
403
-				$this->form_params['extra'][$key] = $this->xcloner_sanitization->sanitize_input_as_raw($value);
416
+			foreach($params->extra as $key=>$value) {
417
+							$this->form_params['extra'][$key] = $this->xcloner_sanitization->sanitize_input_as_raw($value);
418
+			}
404 419
 		}
405 420
 			
406 421
 		return $this->xcloner_settings->get_hash();
@@ -437,7 +452,7 @@  discard block
 block discarded – undo
437 452
 			
438 453
 			try{
439 454
 				$files = $this->xcloner_file_system->list_directory($folder);
440
-			}catch(Exception $e){
455
+			} catch(Exception $e){
441 456
 				
442 457
 				print $e->getMessage();
443 458
 				$this->logger->error($e->getMessage());
@@ -457,17 +472,19 @@  discard block
 block discarded – undo
457 472
 				$children = false;
458 473
 				$text = $file['basename'];
459 474
 				
460
-				if($file['type'] == "dir")
461
-					$children = true;
462
-				else
463
-					 $text .= " (". $this->xcloner_requirements->file_format_size($file['size']).")";
475
+				if($file['type'] == "dir") {
476
+									$children = true;
477
+				} else {
478
+									 $text .= " (". $this->xcloner_requirements->file_format_size($file['size']).")";
479
+				}
464 480
 				
465 481
 				//if(in_array($file['path'], $this->xcloner_file_system->get_excluded_files()))
466 482
 				//echo $file['path']."--".$this->xcloner_file_system->is_excluded($file);
467
-				if($excluded_pattern = $this->xcloner_file_system->is_excluded($file))
468
-					$selected = true;
469
-				else
470
-					$selected = false;
483
+				if($excluded_pattern = $this->xcloner_file_system->is_excluded($file)) {
484
+									$selected = true;
485
+				} else {
486
+									$selected = false;
487
+				}
471 488
 					
472 489
 				$data[] = array(
473 490
 							'id' => $file['path'],
@@ -505,22 +522,24 @@  discard block
 block discarded – undo
505 522
 		{
506 523
 			try{
507 524
 				$return = $this->xcloner_database->get_all_databases();
508
-			}catch(Exception $e){
525
+			} catch(Exception $e){
509 526
 				$this->logger->error($e->getMessage());
510 527
 			}
511 528
 			
512 529
 			foreach($return as $database)
513 530
 			{
514
-				if($xcloner_backup_only_wp_tables and $database['name'] != $this->xcloner_settings->get_db_database())
515
-					continue;
531
+				if($xcloner_backup_only_wp_tables and $database['name'] != $this->xcloner_settings->get_db_database()) {
532
+									continue;
533
+				}
516 534
 					
517 535
 				$state = array();
518 536
 				
519 537
 				if($database['name'] == $this->xcloner_settings->get_db_database())
520 538
 				{
521 539
 					$state['selected'] = true;
522
-					if($database['num_tables'] < 25)
523
-						$state['opened'] = false;
540
+					if($database['num_tables'] < 25) {
541
+											$state['opened'] = false;
542
+					}
524 543
 				}
525 544
 					
526 545
 				$data[] = array(
@@ -533,13 +552,11 @@  discard block
 block discarded – undo
533 552
 						);
534 553
 			}
535 554
 			
536
-		}
537
-		
538
-		else{
555
+		} else{
539 556
 			
540 557
 			try{
541 558
 				$return = $this->xcloner_database->list_tables($database, "", 1);
542
-			}catch(Exception $e){
559
+			} catch(Exception $e){
543 560
 				$this->logger->error($e->getMessage());
544 561
 			}
545 562
 			
@@ -547,11 +564,13 @@  discard block
 block discarded – undo
547 564
 			{
548 565
 				$state = array();
549 566
 				
550
-				if($xcloner_backup_only_wp_tables and !stristr($table['name'], $this->xcloner_settings->get_table_prefix()))
551
-					continue;
567
+				if($xcloner_backup_only_wp_tables and !stristr($table['name'], $this->xcloner_settings->get_table_prefix())) {
568
+									continue;
569
+				}
552 570
 				
553
-				if(isset($database['name']) and $database['name'] == $this->xcloner_settings->get_db_database())
554
-					$state = array('selected' => true);
571
+				if(isset($database['name']) and $database['name'] == $this->xcloner_settings->get_db_database()) {
572
+									$state = array('selected' => true);
573
+				}
555 574
 					
556 575
 				$data[] = array(
557 576
 						'id' => $table['name'],
@@ -604,10 +623,11 @@  discard block
 block discarded – undo
604 623
 		{
605 624
 			$action = "<a href=\"#".$res->id."\" class=\"edit\" title='Edit'> <i class=\"material-icons \">edit</i></a> 
606 625
 					<a href=\"#".$res->id."\" class=\"delete\" title='Delete'><i class=\"material-icons  \">delete</i></a>";
607
-			if($res->status)
608
-				$status = '<i class="material-icons active status">timer</i>';
609
-			else
610
-				$status = '<i class="material-icons status inactive">timer_off</i>';
626
+			if($res->status) {
627
+							$status = '<i class="material-icons active status">timer</i>';
628
+			} else {
629
+							$status = '<i class="material-icons status inactive">timer_off</i>';
630
+			}
611 631
 				
612 632
 			$next_run_time = wp_next_scheduled('xcloner_scheduler_'.$res->id, array($res->id));
613 633
 				
@@ -615,17 +635,19 @@  discard block
 block discarded – undo
615 635
 			
616 636
 			$remote_storage = $res->remote_storage;
617 637
 			
618
-			if(!$next_run_time >= time())
619
-				$next_run = " ";
638
+			if(!$next_run_time >= time()) {
639
+							$next_run = " ";
640
+			}
620 641
 			
621 642
 			if(trim($next_run))
622 643
 			{
623 644
 				$date_text = $next_run;
624 645
 				
625
-				if($next_run_time >= time())
626
-					$next_run = "in ".human_time_diff($next_run_time, time());
627
-				else
628
-					$next_run = __("executed", 'xcloner-backup-and-restore');
646
+				if($next_run_time >= time()) {
647
+									$next_run = "in ".human_time_diff($next_run_time, time());
648
+				} else {
649
+									$next_run = __("executed", 'xcloner-backup-and-restore');
650
+				}
629 651
 				
630 652
 				$next_run = "<a href='#' title='".$date_text."'>".$next_run."</a>";
631 653
 				//$next_run .=" ($date_text)";	
@@ -712,7 +734,7 @@  discard block
 block discarded – undo
712 734
 			$tar->open($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file, $start);
713 735
 		
714 736
 			$data = $tar->contents(get_option('xcloner_files_to_process_per_request'));
715
-		}catch(Exception $e)
737
+		} catch(Exception $e)
716 738
 		{
717 739
 			$return['error'] = true;
718 740
 			$return['message'] = $e->getMessage();
@@ -740,15 +762,16 @@  discard block
 block discarded – undo
740 762
 		{
741 763
 			$return['start'] = $data['start'];
742 764
 			$return['finished'] = 0;	
743
-		}else{
765
+		} else{
744 766
 			if($this->xcloner_file_system->is_multipart($source_backup_file))
745 767
 			{
746 768
 				$return['start'] = 0;
747 769
 				
748 770
 				++$return['part'];
749 771
 			
750
-				if($return['part'] < sizeof($backup_parts))	
751
-					$return['finished'] = 0;
772
+				if($return['part'] < sizeof($backup_parts)) {
773
+									$return['finished'] = 0;
774
+				}
752 775
 				
753 776
 			}
754 777
 		}	
@@ -780,7 +803,7 @@  discard block
 block discarded – undo
780 803
 			{
781 804
 				$return = call_user_func_array(array($xcloner_remote_storage, "upload_backup_to_storage"), array($backup_file, $storage_type));
782 805
 			}
783
-		}catch(Exception $e){
806
+		} catch(Exception $e){
784 807
 		
785 808
 			$return['error'] = 1;
786 809
 			$return['message'] = $e->getMessage();
@@ -925,11 +948,13 @@  discard block
 block discarded – undo
925 948
 		$file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
926 949
 		$hash = $this->xcloner_sanitization->sanitize_input_as_string($_POST['hash']);
927 950
 		
928
-		if(isset($_POST['part']))
929
-			$return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
951
+		if(isset($_POST['part'])) {
952
+					$return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
953
+		}
930 954
 		
931
-		if(isset($_POST['uploaded_size']))
932
-			$return['uploaded_size'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['uploaded_size']);
955
+		if(isset($_POST['uploaded_size'])) {
956
+					$return['uploaded_size'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['uploaded_size']);
957
+		}
933 958
 		
934 959
 		$start = $this->xcloner_sanitization->sanitize_input_as_string($_POST['start']);
935 960
 		$target_url = $this->xcloner_sanitization->sanitize_input_as_string($_POST['target_url']);
@@ -956,7 +981,7 @@  discard block
 block discarded – undo
956 981
 			$xcloner_file_transfer->set_target($target_url);
957 982
 			$return['start'] = $xcloner_file_transfer->transfer_file($file, $start, $hash);
958 983
 		
959
-		}catch(Exception $e){
984
+		} catch(Exception $e){
960 985
 		
961 986
 			$return = array();
962 987
 			$return['error'] = true;
@@ -990,8 +1015,9 @@  discard block
 block discarded – undo
990 1015
 			$data['hash'] = $this->xcloner_settings->get_hash();
991 1016
 		}
992 1017
 			
993
-		if( ob_get_length() )
994
-			ob_clean();
1018
+		if( ob_get_length() ) {
1019
+					ob_clean();
1020
+		}
995 1021
 		wp_send_json($data);
996 1022
 		
997 1023
 		die();
Please login to merge, or discard this patch.
includes/class-xcloner-archive.php 5 patches
Doc Comments   +26 added lines patch added patch discarded remove patch
@@ -44,6 +44,11 @@  discard block
 block discarded – undo
44 44
 	 * Rename backup archive
45 45
 	 * 
46 46
 	 */ 
47
+
48
+	/**
49
+	 * @param string $old_name
50
+	 * @param string $new_name
51
+	 */
47 52
 	public function rename_archive($old_name, $new_name)
48 53
 	{
49 54
 		$this->logger->info(sprintf("Renaming backup archive %s to %s", $old_name, $new_name));
@@ -108,6 +113,10 @@  discard block
 block discarded – undo
108 113
 	 * Send notification error by E-Mail
109 114
 	 * 
110 115
 	 */
116
+
117
+	/**
118
+	 * @param string $error_message
119
+	 */
111 120
 	public function send_notification_error($to, $from, $subject, $backup_name, $params, $error_message)
112 121
 	{
113 122
 		
@@ -132,6 +141,11 @@  discard block
 block discarded – undo
132 141
 	 * Send backup archive notfication by E-Mail
133 142
 	 * 
134 143
 	 */ 
144
+
145
+	/**
146
+	 * @param string $from
147
+	 * @param string $subject
148
+	 */
135 149
 	public function send_notification($to, $from, $subject, $backup_name, $params, $error_message="")
136 150
 	{
137 151
 		if(!$from)
@@ -204,6 +218,10 @@  discard block
 block discarded – undo
204 218
 	 * Incremental Backup method
205 219
 	 * 
206 220
 	 */ 
221
+
222
+	/**
223
+	 * @param integer $init
224
+	 */
207 225
 	public function start_incremental_backup($backup_params, $extra_params, $init)
208 226
 	{
209 227
 		if(!isset($extra_params['backup_part']))
@@ -416,6 +434,10 @@  discard block
 block discarded – undo
416 434
 	 * Write multipart file components
417 435
 	 * 
418 436
 	 */ 
437
+
438
+	/**
439
+	 * @param string $path
440
+	 */
419 441
 	private function write_multipart_file($path)
420 442
 	{
421 443
 		$path = $this->get_archive_name_with_extension();
@@ -475,6 +497,10 @@  discard block
 block discarded – undo
475 497
 	 * Add file to archive
476 498
 	 * 
477 499
 	 */ 
500
+
501
+	/**
502
+	 * @param integer $append
503
+	 */
478 504
 	public function add_file_to_archive($file_info, $start_at_byte, $byte_limit = 0, $append, $filesystem)
479 505
 	{
480 506
 		
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,5 @@
 block discarded – undo
1 1
 <?php
2 2
 use splitbrain\PHPArchive\Tar;
3
-use splitbrain\PHPArchive\Archive;
4 3
 use splitbrain\PHPArchive\FileInfo;
5 4
 
6 5
 class Xcloner_Archive extends Tar
Please login to merge, or discard this patch.
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -555,15 +555,15 @@  discard block
 block discarded – undo
555 555
 		return array($bytes_wrote, $last_position);
556 556
 	}
557 557
 	    
558
-    /**
559
-     * Open a TAR archive and put the file cursor at the end for data appending
560
-     *
561
-     * If $file is empty, the tar file will be created in memory
562
-     *
563
-     * @param string $file
564
-     * @throws ArchiveIOException
565
-     */
566
-    /*
558
+	/**
559
+	 * Open a TAR archive and put the file cursor at the end for data appending
560
+	 *
561
+	 * If $file is empty, the tar file will be created in memory
562
+	 *
563
+	 * @param string $file
564
+	 * @throws ArchiveIOException
565
+	 */
566
+	/*
567 567
     public function openForAppend($file = '')
568 568
     {
569 569
         $this->file   = $file;
@@ -593,16 +593,16 @@  discard block
 block discarded – undo
593 593
     }
594 594
     */
595 595
     
596
-     /**
597
-     * Append data to a file to the current TAR archive using an existing file in the filesystem
598
-     *
599
-     * @param string          	$file     path to the original file
600
-     * @param int          		$start    starting reading position in file
601
-     * @param int          		$end      end position in reading multiple with 512
602
-     * @param string|FileInfo $fileinfo either the name to us in archive (string) or a FileInfo oject with all meta data, empty to take from original
603
-     * @throws ArchiveIOException
604
-     */
605
-    /*
596
+	 /**
597
+	  * Append data to a file to the current TAR archive using an existing file in the filesystem
598
+	  *
599
+	  * @param string          	$file     path to the original file
600
+	  * @param int          		$start    starting reading position in file
601
+	  * @param int          		$end      end position in reading multiple with 512
602
+	  * @param string|FileInfo $fileinfo either the name to us in archive (string) or a FileInfo oject with all meta data, empty to take from original
603
+	  * @throws ArchiveIOException
604
+	  */
605
+	/*
606 606
      * public function appendFileData($file, $fileinfo = '', $start = 0, $limit = 0)
607 607
     {
608 608
 		$end = $start+($limit*512);
@@ -658,14 +658,14 @@  discard block
 block discarded – undo
658 658
         return $last_position;
659 659
     }*/
660 660
     
661
-    /**
662
-     * Adds a file to a TAR archive by appending it's data
663
-     *
664
-     * @param string $archive			name of the archive file
665
-     * @param string $file				name of the file to read data from				
666
-     * @param string $start				start position from where to start reading data
667
-     * @throws ArchiveIOException
668
-     */
661
+	/**
662
+	 * Adds a file to a TAR archive by appending it's data
663
+	 *
664
+	 * @param string $archive			name of the archive file
665
+	 * @param string $file				name of the file to read data from				
666
+	 * @param string $start				start position from where to start reading data
667
+	 * @throws ArchiveIOException
668
+	 */
669 669
 	/*public function addFileToArchive($archive, $file, $start = 0)
670 670
 	{
671 671
 		$this->openForAppend($archive);
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -8,34 +8,34 @@  discard block
 block discarded – undo
8 8
 	/*
9 9
 	 * bytes
10 10
 	 */ 
11
-	private $file_size_per_request_limit	= 52428800 ; //50MB = 52428800; 1MB = 1048576
12
-	private $files_to_process_per_request 	= 250; //block of 512 bytes
13
-	private $compression_level 				= 0; //0-9 , 0 uncompressed
11
+	private $file_size_per_request_limit	= 52428800; //50MB = 52428800; 1MB = 1048576
12
+	private $files_to_process_per_request = 250; //block of 512 bytes
13
+	private $compression_level = 0; //0-9 , 0 uncompressed
14 14
 	private $xcloner_split_backup_limit		= 2048; //2048MB
15 15
 	
16 16
 	private $archive_name;
17 17
 	
18 18
 	public function __construct($hash = "", $archive_name = "")
19 19
 	{
20
-		$this->filesystem 		= new Xcloner_File_System($hash);
21
-		$this->logger 			= new XCloner_Logger('xcloner_archive', $hash);
20
+		$this->filesystem = new Xcloner_File_System($hash);
21
+		$this->logger = new XCloner_Logger('xcloner_archive', $hash);
22 22
 		$this->xcloner_settings = new Xcloner_Settings($hash);
23 23
 		
24
-		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_size_limit_per_request'))
25
-			$this->file_size_per_request_limit = $value*1024*1024; //MB
24
+		if ($value = $this->xcloner_settings->get_xcloner_option('xcloner_size_limit_per_request'))
25
+			$this->file_size_per_request_limit = $value * 1024 * 1024; //MB
26 26
 			
27
-		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_files_to_process_per_request'))
27
+		if ($value = $this->xcloner_settings->get_xcloner_option('xcloner_files_to_process_per_request'))
28 28
 			$this->files_to_process_per_request = $value;
29 29
 		
30
-		if($value = get_option('xcloner_backup_compression_level'))
30
+		if ($value = get_option('xcloner_backup_compression_level'))
31 31
 			$this->compression_level = $value;
32 32
 		
33
-		if($value = get_option('xcloner_split_backup_limit'))
33
+		if ($value = get_option('xcloner_split_backup_limit'))
34 34
 			$this->xcloner_split_backup_limit = $value;
35 35
 		
36
-		$this->xcloner_split_backup_limit = $this->xcloner_split_backup_limit * 1024*1024; //transform to bytes
36
+		$this->xcloner_split_backup_limit = $this->xcloner_split_backup_limit * 1024 * 1024; //transform to bytes
37 37
 			
38
-		if(isset($archive_name))
38
+		if (isset($archive_name))
39 39
 			$this->set_archive_name($archive_name);
40 40
 	}
41 41
 	
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 	{
61 61
 		$this->archive_name = $this->filesystem->process_backup_name($name);
62 62
 		
63
-		if(isset($part) and $part)
63
+		if (isset($part) and $part)
64 64
 		{
65
-			$new_name =  preg_replace('/-part(\d*)/', "-part".$part, $this->archive_name);
66
-			if(!stristr($new_name, "-part"))
67
-				$new_name = $this->archive_name . "-part".$part;
65
+			$new_name = preg_replace('/-part(\d*)/', "-part".$part, $this->archive_name);
66
+			if (!stristr($new_name, "-part"))
67
+				$new_name = $this->archive_name."-part".$part;
68 68
 			
69 69
 			$this->archive_name = $new_name;	
70 70
 		}
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 */ 
90 90
 	public function get_archive_name_multipart()
91 91
 	{
92
-		$new_name =  preg_replace('/-part(\d*)/', "", $this->archive_name);
92
+		$new_name = preg_replace('/-part(\d*)/', "", $this->archive_name);
93 93
 		return $new_name."-multipart".$this->xcloner_settings->get_backup_extension_name(".csv");
94 94
 	}
95 95
 	
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	public function send_notification_error($to, $from, $subject, $backup_name, $params, $error_message)
112 112
 	{
113 113
 		
114
-		$body  = $error_message; 
114
+		$body = $error_message; 
115 115
 		
116 116
 		$this->logger->info(sprintf("Sending backup error notification to %s", $to));
117 117
 		
@@ -119,10 +119,10 @@  discard block
 block discarded – undo
119 119
 		
120 120
 		$headers = array('Content-Type: text/html; charset=UTF-8');
121 121
 		
122
-		if($admin_email and $from )
122
+		if ($admin_email and $from)
123 123
 			$headers[] = 'From: '.$from.' <'.$admin_email.'>';
124 124
 
125
-		$return = wp_mail( $to, $subject, $body, $headers );
125
+		$return = wp_mail($to, $subject, $body, $headers);
126 126
 		
127 127
 		return $return;
128 128
 	}
@@ -132,47 +132,47 @@  discard block
 block discarded – undo
132 132
 	 * Send backup archive notfication by E-Mail
133 133
 	 * 
134 134
 	 */ 
135
-	public function send_notification($to, $from, $subject, $backup_name, $params, $error_message="")
135
+	public function send_notification($to, $from, $subject, $backup_name, $params, $error_message = "")
136 136
 	{
137
-		if(!$from)
137
+		if (!$from)
138 138
 			$from = "XCloner Backup";
139 139
 			
140
-		if(($error_message))
140
+		if (($error_message))
141 141
 		{
142 142
 			return $this->send_notification_error($to, $from, $subject, $backup_name, $params, $error_message);
143 143
 		}
144 144
 		
145 145
 		$params = (array)$params;
146 146
 		
147
-		if(!$subject)
148
-			$subject = sprintf(__("New backup generated %s") ,$backup_name);
147
+		if (!$subject)
148
+			$subject = sprintf(__("New backup generated %s"), $backup_name);
149 149
 			
150 150
 		$body = sprintf(__("Generated Backup Size: %s"), size_format($this->filesystem->get_backup_size($backup_name)));
151 151
 		$body .= "<br /><br />";
152 152
 		
153 153
 		$backup_parts = $this->filesystem->get_multipart_files($backup_name);
154 154
 		
155
-		if(!$backups_counter = sizeof($backup_parts))
155
+		if (!$backups_counter = sizeof($backup_parts))
156 156
 			$backups_counter = 1;
157 157
 		
158 158
 		$body .= sprintf(__("Backup Parts: %s"), $backups_counter);
159 159
 		$body .= "<br />";
160 160
 		
161
-		if(sizeof($backup_parts))
161
+		if (sizeof($backup_parts))
162 162
 		{
163
-			$body .= implode("<br />",$backup_parts);
163
+			$body .= implode("<br />", $backup_parts);
164 164
 			$body .= "<br />";
165 165
 		}
166 166
 		
167
-		$body.= "<br />";
167
+		$body .= "<br />";
168 168
 		
169
-		if(isset($params['backup_params']->backup_comments))
169
+		if (isset($params['backup_params']->backup_comments))
170 170
 		{
171 171
 			$body .= __("Backup Comments: ").$params['backup_params']->backup_comments;
172 172
 			$body .= "<br /><br />";
173 173
 		}
174 174
 		
175
-		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log'))
175
+		if ($this->xcloner_settings->get_xcloner_option('xcloner_enable_log'))
176 176
 			$body .= __("Latest 50 Log Lines: ")."<br />".implode("<br />\n", $this->logger->getLastDebugLines(50));
177 177
 		
178 178
 		$attachments = $this->filesystem->get_backup_attachments();
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 		$tar = new Tar();
183 183
 		$tar->create($attachments_archive);
184 184
 			
185
-		foreach($attachments as $key => $file)
185
+		foreach ($attachments as $key => $file)
186 186
 		{
187 187
 			$tar->addFile($file, basename($file));
188 188
 		}
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 		
195 195
 		$headers = array('Content-Type: text/html; charset=UTF-8', 'From: '.$from.' <'.$admin_email.'>');
196 196
 		
197
-		$return = wp_mail( $to, $subject, $body, $headers, array($attachments_archive) );
197
+		$return = wp_mail($to, $subject, $body, $headers, array($attachments_archive));
198 198
 	
199 199
 		return $return;
200 200
 	}
@@ -206,17 +206,17 @@  discard block
 block discarded – undo
206 206
 	 */ 
207 207
 	public function start_incremental_backup($backup_params, $extra_params, $init)
208 208
 	{
209
-		if(!isset($extra_params['backup_part']))
209
+		if (!isset($extra_params['backup_part']))
210 210
 			$extra_params['backup_part'] = 0;
211 211
 		
212 212
 		$return['extra']['backup_part'] = $extra_params['backup_part'];
213 213
 					
214
-		if(isset( $extra_params['backup_archive_name']))
214
+		if (isset($extra_params['backup_archive_name']))
215 215
 			$this->set_archive_name($extra_params['backup_archive_name'], $return['extra']['backup_part']);
216 216
 		else
217 217
 			$this->set_archive_name($backup_params['backup_name']);
218 218
 			
219
-		if(!$this->get_archive_name())
219
+		if (!$this->get_archive_name())
220 220
 			$this->set_archive_name();
221 221
 		
222 222
 		$this->backup_archive = new Tar();
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		
225 225
 		$archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
226 226
 		
227
-		if($init)
227
+		if ($init)
228 228
 		{
229 229
 			$this->logger->info(sprintf(__("Initializing the backup archive %s"), $this->get_archive_name()));
230 230
 		
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 			
235 235
 			$return['extra']['backup_init'] = 1;
236 236
 			
237
-		}else{
237
+		} else {
238 238
 			$this->logger->info(sprintf(__("Opening for append the backup archive %s"), $this->get_archive_name()));
239 239
 			
240 240
 			$this->backup_archive->openForAppend($archive_info->getPath().DS.$archive_info->getFilename());
@@ -246,13 +246,13 @@  discard block
 block discarded – undo
246 246
 		$return['extra']['backup_archive_name'] = $this->get_archive_name();
247 247
 		$return['extra']['backup_archive_name_full'] = $this->get_archive_name_with_extension();
248 248
 		
249
-		if(!isset($extra_params['start_at_line']))
249
+		if (!isset($extra_params['start_at_line']))
250 250
 			$extra_params['start_at_line'] = 0;
251 251
 		
252
-		if(!isset($extra_params['start_at_byte']))
252
+		if (!isset($extra_params['start_at_byte']))
253 253
 			$extra_params['start_at_byte'] = 0;
254 254
 		
255
-		if(!$this->filesystem->get_tmp_filesystem()->has($this->filesystem->get_included_files_handler()))
255
+		if (!$this->filesystem->get_tmp_filesystem()->has($this->filesystem->get_included_files_handler()))
256 256
 		{
257 257
 			$this->logger->error(sprintf("Missing the includes file handler %s, aborting...", $this->filesystem->get_included_files_handler()));
258 258
 			
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 		//$this->file_size_per_request_limit = 1024*1024;
281 281
 		$byte_limit = 0;
282 282
 		
283
-		while(!$file->eof() and $counter<=$this->files_to_process_per_request)
283
+		while (!$file->eof() and $counter <= $this->files_to_process_per_request)
284 284
 		{
285 285
 			$line = str_getcsv($file->current());
286 286
 
@@ -288,13 +288,13 @@  discard block
 block discarded – undo
288 288
 			
289 289
 			$start_filesystem = "start_filesystem";
290 290
 			
291
-			if(isset($line[4])){
291
+			if (isset($line[4])) {
292 292
 				$start_filesystem = $line[4];
293 293
 			}
294 294
 			
295 295
 			//$adapter = $this->filesystem->get_adapter($start_filesystem);
296 296
 			
297
-			if(!$this->filesystem->get_filesystem($start_filesystem)->has($relative_path))
297
+			if (!$this->filesystem->get_filesystem($start_filesystem)->has($relative_path))
298 298
 			{
299 299
 				$extra_params['start_at_line']++;
300 300
 				$file->next();
@@ -305,35 +305,35 @@  discard block
 block discarded – undo
305 305
 			
306 306
 			//echo "Processing ".$file_info['path']."(".$file_info['size'].")";
307 307
 			
308
-			if(!isset($file_info['size']))
308
+			if (!isset($file_info['size']))
309 309
 				$file_info['size'] = 0;
310 310
 			
311
-			if($start_filesystem == "tmp_filesystem")	
311
+			if ($start_filesystem == "tmp_filesystem")	
312 312
 				$file_info['archive_prefix_path'] = $this->xcloner_settings->get_xcloner_tmp_path_suffix();
313 313
 			
314
-			$byte_limit = (int)$this->file_size_per_request_limit/512;
314
+			$byte_limit = (int)$this->file_size_per_request_limit / 512;
315 315
 			
316 316
 			$append = 0;
317 317
 			
318
-			if($file_info['size'] > $byte_limit*512 or $start_byte)
318
+			if ($file_info['size'] > $byte_limit * 512 or $start_byte)
319 319
 				$append = 1;
320 320
 						
321
-			if(!isset($return['extra']['backup_size']))
322
-				$return['extra']['backup_size'] =0;
321
+			if (!isset($return['extra']['backup_size']))
322
+				$return['extra']['backup_size'] = 0;
323 323
 			
324 324
 			$return['extra']['backup_size'] = $archive_info->getSize();
325 325
 			
326 326
 			$estimated_new_size = $return['extra']['backup_size'] + $file_info['size'];
327 327
 			
328 328
 			//we create a new backup part if we reach the Split Achive Limit
329
-			if($this->xcloner_split_backup_limit and ($estimated_new_size > $this->xcloner_split_backup_limit) and (!$start_byte))
329
+			if ($this->xcloner_split_backup_limit and ($estimated_new_size > $this->xcloner_split_backup_limit) and (!$start_byte))
330 330
 			{
331
-				$this->logger->info(sprintf("Backup size limit %s bytes reached, file add estimate %s, attempt to create a new archive ",$this->xcloner_split_backup_limit, $estimated_new_size));
331
+				$this->logger->info(sprintf("Backup size limit %s bytes reached, file add estimate %s, attempt to create a new archive ", $this->xcloner_split_backup_limit, $estimated_new_size));
332 332
 				list($archive_info, $return['extra']['backup_part']) = $this->create_new_backup_part($return['extra']['backup_part']);
333 333
 				
334
-				if($file_info['size'] > $this->xcloner_split_backup_limit)
334
+				if ($file_info['size'] > $this->xcloner_split_backup_limit)
335 335
 				{
336
-					$this->logger->info(sprintf("Excluding %s file as it's size(%s) is bigger than the backup split limit of %s and it won't fit a single backup file",$file_info['path'], $file_info['size'], $this->xcloner_split_backup_limit));
336
+					$this->logger->info(sprintf("Excluding %s file as it's size(%s) is bigger than the backup split limit of %s and it won't fit a single backup file", $file_info['path'], $file_info['size'], $this->xcloner_split_backup_limit));
337 337
 					$extra_params['start_at_line']++;
338 338
 				}
339 339
 				
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 				return $return;
346 346
 			}
347 347
 			
348
-			list($bytes_wrote, $last_position) = $this->add_file_to_archive( $file_info, $start_byte, $byte_limit, $append, $start_filesystem);
348
+			list($bytes_wrote, $last_position) = $this->add_file_to_archive($file_info, $start_byte, $byte_limit, $append, $start_filesystem);
349 349
 			$this->processed_size_bytes += $bytes_wrote;
350 350
 			
351 351
 			//echo" - processed ".$this->processed_size_bytes." bytes ".$this->file_size_per_request_limit." last_position:".$last_position." \n";
@@ -353,17 +353,17 @@  discard block
 block discarded – undo
353 353
 			$return['extra']['processed_file_size'] = $file_info['size'];
354 354
 			$return['extra']['backup_size'] = $archive_info->getSize();
355 355
 			
356
-			if($last_position>0){	
356
+			if ($last_position > 0) {	
357 357
 				$start_byte = $last_position;
358 358
 			}
359
-			else{	
359
+			else {	
360 360
 				$extra_params['start_at_line']++;
361 361
 				$file->next();
362 362
 				$start_byte = 0;
363 363
 				$counter++;
364 364
 			}
365 365
 			
366
-			if($this->processed_size_bytes >= $this->file_size_per_request_limit)
366
+			if ($this->processed_size_bytes >= $this->file_size_per_request_limit)
367 367
 			{
368 368
 				clearstatcache();
369 369
 				$return['extra']['backup_size'] = $archive_info->getSize();
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 			}
377 377
 		}
378 378
 		
379
-		if(!$file->eof())
379
+		if (!$file->eof())
380 380
 		{
381 381
 			clearstatcache();
382 382
 			$return['extra']['backup_size'] = $archive_info->getSize();
@@ -393,12 +393,12 @@  discard block
 block discarded – undo
393 393
 		$this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.", $this->get_archive_name_with_extension()));
394 394
 		$this->backup_archive->close();
395 395
 				
396
-		if($return['extra']['backup_part'])
396
+		if ($return['extra']['backup_part'])
397 397
 			$this->write_multipart_file($this->get_archive_name_with_extension());
398 398
 		
399
-		$return['extra']['start_at_line'] = $extra_params['start_at_line']-1;
399
+		$return['extra']['start_at_line'] = $extra_params['start_at_line'] - 1;
400 400
 		
401
-		if(isset($file_info))
401
+		if (isset($file_info))
402 402
 		{
403 403
 			$return['extra']['processed_file'] = $file_info['path'];
404 404
 			$return['extra']['processed_file_size'] = $file_info['size'];
@@ -440,20 +440,20 @@  discard block
 block discarded – undo
440 440
 		$this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.", $this->get_archive_name_with_extension()));
441 441
 		$this->backup_archive->close();		
442 442
 		
443
-		if(!$part)
443
+		if (!$part)
444 444
 		{
445 445
 			$old_name = $this->get_archive_name_with_extension();
446 446
 			$this->set_archive_name($this->get_archive_name(), ++$part);
447 447
 			$this->rename_archive($old_name, $this->get_archive_name_with_extension());
448 448
 			
449
-			if($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart()))
449
+			if ($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart()))
450 450
 				$this->filesystem->get_storage_filesystem()->delete($this->get_archive_name_multipart());
451 451
 				
452 452
 			$this->write_multipart_file($this->get_archive_name_with_extension());
453 453
 			
454
-		}else
454
+		} else
455 455
 		{
456
-			$this->logger->info(sprintf("Creating new multipart info file %s",$this->get_archive_name_with_extension()));
456
+			$this->logger->info(sprintf("Creating new multipart info file %s", $this->get_archive_name_with_extension()));
457 457
 			$this->write_multipart_file($this->get_archive_name_with_extension());
458 458
 		}
459 459
 				
@@ -481,10 +481,10 @@  discard block
 block discarded – undo
481 481
 		$start_adapter = $this->filesystem->get_adapter($filesystem);
482 482
 		$start_filesystem = $this->filesystem->get_adapter($filesystem);
483 483
 		
484
-		if(!$file_info['path'])
484
+		if (!$file_info['path'])
485 485
 			return;
486 486
 		
487
-		if(isset($file_info['archive_prefix_path']))	
487
+		if (isset($file_info['archive_prefix_path']))	
488 488
 			$file_info['target_path'] = $file_info['archive_prefix_path']."/".$file_info['path'];
489 489
 		else
490 490
 			$file_info['target_path'] = $file_info['path'];
@@ -493,36 +493,36 @@  discard block
 block discarded – undo
493 493
 		
494 494
 		//$start_adapter = $this->filesystem->get_start_adapter();
495 495
 
496
-		if(!$append){
496
+		if (!$append) {
497 497
 			$bytes_wrote = $file_info['size'];
498 498
 			$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()));
499 499
 			$this->backup_archive->addFile($start_adapter->applyPathPrefix($file_info['path']), $file_info['target_path']);
500 500
 		}
501
-		else{	
501
+		else {	
502 502
 			$tmp_file = md5($file_info['path']);
503 503
 			
504 504
 			//we isolate file to tmp if we are at byte 0, the starting point of file reading
505
-			if(!$start_at_byte)
505
+			if (!$start_at_byte)
506 506
 			{
507 507
 				$this->logger->info(sprintf("Copying %s file to tmp filesystem file %s to prevent reading changes", $file_info['path'], $tmp_file));
508 508
 				$file_stream = $start_filesystem->readStream($file_info['path']);
509 509
 				
510
-				if(is_resource($file_stream['stream']))
510
+				if (is_resource($file_stream['stream']))
511 511
 					$this->filesystem->get_tmp_filesystem()->writeStream($tmp_file, $file_stream['stream']);
512 512
 			}
513 513
 			
514
-			if($this->filesystem->get_tmp_filesystem()->has($tmp_file))
514
+			if ($this->filesystem->get_tmp_filesystem()->has($tmp_file))
515 515
 			{
516 516
 				$is_tmp = 1;
517 517
 				$last_position = $this->backup_archive->appendFileData($this->filesystem->get_tmp_filesystem_adapter()->applyPathPrefix($tmp_file), $file_info['target_path'], $start_at_byte, $byte_limit);
518 518
 			}
519
-			else{
519
+			else {
520 520
 				$is_tmp = 0;
521 521
 				$last_position = $this->backup_archive->appendFileData($start_adapter->applyPathPrefix($file_info['path']), $file_info['target_path'], $start_at_byte, $byte_limit);
522 522
 			}
523 523
 				
524 524
 			
525
-			if($last_position == -1)
525
+			if ($last_position == -1)
526 526
 			{
527 527
 				$bytes_wrote = $file_info['size'] - $start_at_byte;
528 528
 			}
@@ -532,18 +532,18 @@  discard block
 block discarded – undo
532 532
 			}
533 533
 			
534 534
 			
535
-			if($is_tmp)
535
+			if ($is_tmp)
536 536
 			{
537 537
 				$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()));
538 538
 			}
539
-			else{
539
+			else {
540 540
 				$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()));
541 541
 			}
542 542
 			
543 543
 			//we delete here the isolated tmp file
544
-			if($last_position == -1)
544
+			if ($last_position == -1)
545 545
 			{
546
-				if($this->filesystem->get_tmp_filesystem_adapter()->has($tmp_file))
546
+				if ($this->filesystem->get_tmp_filesystem_adapter()->has($tmp_file))
547 547
 				{
548 548
 					$this->logger->info(sprintf("Deleting %s from the tmp filesystem", $tmp_file));
549 549
 					$this->filesystem->get_tmp_filesystem_adapter()->delete($tmp_file);
Please login to merge, or discard this patch.
Braces   +87 added lines, -66 removed lines patch added patch discarded remove patch
@@ -21,22 +21,28 @@  discard block
 block discarded – undo
21 21
 		$this->logger 			= new XCloner_Logger('xcloner_archive', $hash);
22 22
 		$this->xcloner_settings = new Xcloner_Settings($hash);
23 23
 		
24
-		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_size_limit_per_request'))
25
-			$this->file_size_per_request_limit = $value*1024*1024; //MB
24
+		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_size_limit_per_request')) {
25
+					$this->file_size_per_request_limit = $value*1024*1024;
26
+		}
27
+		//MB
26 28
 			
27
-		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_files_to_process_per_request'))
28
-			$this->files_to_process_per_request = $value;
29
+		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_files_to_process_per_request')) {
30
+					$this->files_to_process_per_request = $value;
31
+		}
29 32
 		
30
-		if($value = get_option('xcloner_backup_compression_level'))
31
-			$this->compression_level = $value;
33
+		if($value = get_option('xcloner_backup_compression_level')) {
34
+					$this->compression_level = $value;
35
+		}
32 36
 		
33
-		if($value = get_option('xcloner_split_backup_limit'))
34
-			$this->xcloner_split_backup_limit = $value;
37
+		if($value = get_option('xcloner_split_backup_limit')) {
38
+					$this->xcloner_split_backup_limit = $value;
39
+		}
35 40
 		
36 41
 		$this->xcloner_split_backup_limit = $this->xcloner_split_backup_limit * 1024*1024; //transform to bytes
37 42
 			
38
-		if(isset($archive_name))
39
-			$this->set_archive_name($archive_name);
43
+		if(isset($archive_name)) {
44
+					$this->set_archive_name($archive_name);
45
+		}
40 46
 	}
41 47
 	
42 48
 	/*
@@ -63,8 +69,9 @@  discard block
 block discarded – undo
63 69
 		if(isset($part) and $part)
64 70
 		{
65 71
 			$new_name =  preg_replace('/-part(\d*)/', "-part".$part, $this->archive_name);
66
-			if(!stristr($new_name, "-part"))
67
-				$new_name = $this->archive_name . "-part".$part;
72
+			if(!stristr($new_name, "-part")) {
73
+							$new_name = $this->archive_name . "-part".$part;
74
+			}
68 75
 			
69 76
 			$this->archive_name = $new_name;	
70 77
 		}
@@ -119,8 +126,9 @@  discard block
 block discarded – undo
119 126
 		
120 127
 		$headers = array('Content-Type: text/html; charset=UTF-8');
121 128
 		
122
-		if($admin_email and $from )
123
-			$headers[] = 'From: '.$from.' <'.$admin_email.'>';
129
+		if($admin_email and $from ) {
130
+					$headers[] = 'From: '.$from.' <'.$admin_email.'>';
131
+		}
124 132
 
125 133
 		$return = wp_mail( $to, $subject, $body, $headers );
126 134
 		
@@ -134,8 +142,9 @@  discard block
 block discarded – undo
134 142
 	 */ 
135 143
 	public function send_notification($to, $from, $subject, $backup_name, $params, $error_message="")
136 144
 	{
137
-		if(!$from)
138
-			$from = "XCloner Backup";
145
+		if(!$from) {
146
+					$from = "XCloner Backup";
147
+		}
139 148
 			
140 149
 		if(($error_message))
141 150
 		{
@@ -144,16 +153,18 @@  discard block
 block discarded – undo
144 153
 		
145 154
 		$params = (array)$params;
146 155
 		
147
-		if(!$subject)
148
-			$subject = sprintf(__("New backup generated %s") ,$backup_name);
156
+		if(!$subject) {
157
+					$subject = sprintf(__("New backup generated %s") ,$backup_name);
158
+		}
149 159
 			
150 160
 		$body = sprintf(__("Generated Backup Size: %s"), size_format($this->filesystem->get_backup_size($backup_name)));
151 161
 		$body .= "<br /><br />";
152 162
 		
153 163
 		$backup_parts = $this->filesystem->get_multipart_files($backup_name);
154 164
 		
155
-		if(!$backups_counter = sizeof($backup_parts))
156
-			$backups_counter = 1;
165
+		if(!$backups_counter = sizeof($backup_parts)) {
166
+					$backups_counter = 1;
167
+		}
157 168
 		
158 169
 		$body .= sprintf(__("Backup Parts: %s"), $backups_counter);
159 170
 		$body .= "<br />";
@@ -172,8 +183,9 @@  discard block
 block discarded – undo
172 183
 			$body .= "<br /><br />";
173 184
 		}
174 185
 		
175
-		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log'))
176
-			$body .= __("Latest 50 Log Lines: ")."<br />".implode("<br />\n", $this->logger->getLastDebugLines(50));
186
+		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) {
187
+					$body .= __("Latest 50 Log Lines: ")."<br />".implode("<br />\n", $this->logger->getLastDebugLines(50));
188
+		}
177 189
 		
178 190
 		$attachments = $this->filesystem->get_backup_attachments();
179 191
 		
@@ -206,18 +218,21 @@  discard block
 block discarded – undo
206 218
 	 */ 
207 219
 	public function start_incremental_backup($backup_params, $extra_params, $init)
208 220
 	{
209
-		if(!isset($extra_params['backup_part']))
210
-			$extra_params['backup_part'] = 0;
221
+		if(!isset($extra_params['backup_part'])) {
222
+					$extra_params['backup_part'] = 0;
223
+		}
211 224
 		
212 225
 		$return['extra']['backup_part'] = $extra_params['backup_part'];
213 226
 					
214
-		if(isset( $extra_params['backup_archive_name']))
215
-			$this->set_archive_name($extra_params['backup_archive_name'], $return['extra']['backup_part']);
216
-		else
217
-			$this->set_archive_name($backup_params['backup_name']);
227
+		if(isset( $extra_params['backup_archive_name'])) {
228
+					$this->set_archive_name($extra_params['backup_archive_name'], $return['extra']['backup_part']);
229
+		} else {
230
+					$this->set_archive_name($backup_params['backup_name']);
231
+		}
218 232
 			
219
-		if(!$this->get_archive_name())
220
-			$this->set_archive_name();
233
+		if(!$this->get_archive_name()) {
234
+					$this->set_archive_name();
235
+		}
221 236
 		
222 237
 		$this->backup_archive = new Tar();
223 238
 		$this->backup_archive->setCompression($this->compression_level);
@@ -234,7 +249,7 @@  discard block
 block discarded – undo
234 249
 			
235 250
 			$return['extra']['backup_init'] = 1;
236 251
 			
237
-		}else{
252
+		} else{
238 253
 			$this->logger->info(sprintf(__("Opening for append the backup archive %s"), $this->get_archive_name()));
239 254
 			
240 255
 			$this->backup_archive->openForAppend($archive_info->getPath().DS.$archive_info->getFilename());
@@ -246,11 +261,13 @@  discard block
 block discarded – undo
246 261
 		$return['extra']['backup_archive_name'] = $this->get_archive_name();
247 262
 		$return['extra']['backup_archive_name_full'] = $this->get_archive_name_with_extension();
248 263
 		
249
-		if(!isset($extra_params['start_at_line']))
250
-			$extra_params['start_at_line'] = 0;
264
+		if(!isset($extra_params['start_at_line'])) {
265
+					$extra_params['start_at_line'] = 0;
266
+		}
251 267
 		
252
-		if(!isset($extra_params['start_at_byte']))
253
-			$extra_params['start_at_byte'] = 0;
268
+		if(!isset($extra_params['start_at_byte'])) {
269
+					$extra_params['start_at_byte'] = 0;
270
+		}
254 271
 		
255 272
 		if(!$this->filesystem->get_tmp_filesystem()->has($this->filesystem->get_included_files_handler()))
256 273
 		{
@@ -305,21 +322,25 @@  discard block
 block discarded – undo
305 322
 			
306 323
 			//echo "Processing ".$file_info['path']."(".$file_info['size'].")";
307 324
 			
308
-			if(!isset($file_info['size']))
309
-				$file_info['size'] = 0;
325
+			if(!isset($file_info['size'])) {
326
+							$file_info['size'] = 0;
327
+			}
310 328
 			
311
-			if($start_filesystem == "tmp_filesystem")	
312
-				$file_info['archive_prefix_path'] = $this->xcloner_settings->get_xcloner_tmp_path_suffix();
329
+			if($start_filesystem == "tmp_filesystem") {
330
+							$file_info['archive_prefix_path'] = $this->xcloner_settings->get_xcloner_tmp_path_suffix();
331
+			}
313 332
 			
314 333
 			$byte_limit = (int)$this->file_size_per_request_limit/512;
315 334
 			
316 335
 			$append = 0;
317 336
 			
318
-			if($file_info['size'] > $byte_limit*512 or $start_byte)
319
-				$append = 1;
337
+			if($file_info['size'] > $byte_limit*512 or $start_byte) {
338
+							$append = 1;
339
+			}
320 340
 						
321
-			if(!isset($return['extra']['backup_size']))
322
-				$return['extra']['backup_size'] =0;
341
+			if(!isset($return['extra']['backup_size'])) {
342
+							$return['extra']['backup_size'] =0;
343
+			}
323 344
 			
324 345
 			$return['extra']['backup_size'] = $archive_info->getSize();
325 346
 			
@@ -355,8 +376,7 @@  discard block
 block discarded – undo
355 376
 			
356 377
 			if($last_position>0){	
357 378
 				$start_byte = $last_position;
358
-			}
359
-			else{	
379
+			} else{	
360 380
 				$extra_params['start_at_line']++;
361 381
 				$file->next();
362 382
 				$start_byte = 0;
@@ -393,8 +413,9 @@  discard block
 block discarded – undo
393 413
 		$this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.", $this->get_archive_name_with_extension()));
394 414
 		$this->backup_archive->close();
395 415
 				
396
-		if($return['extra']['backup_part'])
397
-			$this->write_multipart_file($this->get_archive_name_with_extension());
416
+		if($return['extra']['backup_part']) {
417
+					$this->write_multipart_file($this->get_archive_name_with_extension());
418
+		}
398 419
 		
399 420
 		$return['extra']['start_at_line'] = $extra_params['start_at_line']-1;
400 421
 		
@@ -446,12 +467,13 @@  discard block
 block discarded – undo
446 467
 			$this->set_archive_name($this->get_archive_name(), ++$part);
447 468
 			$this->rename_archive($old_name, $this->get_archive_name_with_extension());
448 469
 			
449
-			if($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart()))
450
-				$this->filesystem->get_storage_filesystem()->delete($this->get_archive_name_multipart());
470
+			if($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart())) {
471
+							$this->filesystem->get_storage_filesystem()->delete($this->get_archive_name_multipart());
472
+			}
451 473
 				
452 474
 			$this->write_multipart_file($this->get_archive_name_with_extension());
453 475
 			
454
-		}else
476
+		} else
455 477
 		{
456 478
 			$this->logger->info(sprintf("Creating new multipart info file %s",$this->get_archive_name_with_extension()));
457 479
 			$this->write_multipart_file($this->get_archive_name_with_extension());
@@ -481,13 +503,15 @@  discard block
 block discarded – undo
481 503
 		$start_adapter = $this->filesystem->get_adapter($filesystem);
482 504
 		$start_filesystem = $this->filesystem->get_adapter($filesystem);
483 505
 		
484
-		if(!$file_info['path'])
485
-			return;
506
+		if(!$file_info['path']) {
507
+					return;
508
+		}
486 509
 		
487
-		if(isset($file_info['archive_prefix_path']))	
488
-			$file_info['target_path'] = $file_info['archive_prefix_path']."/".$file_info['path'];
489
-		else
490
-			$file_info['target_path'] = $file_info['path'];
510
+		if(isset($file_info['archive_prefix_path'])) {
511
+					$file_info['target_path'] = $file_info['archive_prefix_path']."/".$file_info['path'];
512
+		} else {
513
+					$file_info['target_path'] = $file_info['path'];
514
+		}
491 515
 			
492 516
 		$last_position = $start_at_byte;
493 517
 		
@@ -497,8 +521,7 @@  discard block
 block discarded – undo
497 521
 			$bytes_wrote = $file_info['size'];
498 522
 			$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()));
499 523
 			$this->backup_archive->addFile($start_adapter->applyPathPrefix($file_info['path']), $file_info['target_path']);
500
-		}
501
-		else{	
524
+		} else{	
502 525
 			$tmp_file = md5($file_info['path']);
503 526
 			
504 527
 			//we isolate file to tmp if we are at byte 0, the starting point of file reading
@@ -507,16 +530,16 @@  discard block
 block discarded – undo
507 530
 				$this->logger->info(sprintf("Copying %s file to tmp filesystem file %s to prevent reading changes", $file_info['path'], $tmp_file));
508 531
 				$file_stream = $start_filesystem->readStream($file_info['path']);
509 532
 				
510
-				if(is_resource($file_stream['stream']))
511
-					$this->filesystem->get_tmp_filesystem()->writeStream($tmp_file, $file_stream['stream']);
533
+				if(is_resource($file_stream['stream'])) {
534
+									$this->filesystem->get_tmp_filesystem()->writeStream($tmp_file, $file_stream['stream']);
535
+				}
512 536
 			}
513 537
 			
514 538
 			if($this->filesystem->get_tmp_filesystem()->has($tmp_file))
515 539
 			{
516 540
 				$is_tmp = 1;
517 541
 				$last_position = $this->backup_archive->appendFileData($this->filesystem->get_tmp_filesystem_adapter()->applyPathPrefix($tmp_file), $file_info['target_path'], $start_at_byte, $byte_limit);
518
-			}
519
-			else{
542
+			} else{
520 543
 				$is_tmp = 0;
521 544
 				$last_position = $this->backup_archive->appendFileData($start_adapter->applyPathPrefix($file_info['path']), $file_info['target_path'], $start_at_byte, $byte_limit);
522 545
 			}
@@ -525,8 +548,7 @@  discard block
 block discarded – undo
525 548
 			if($last_position == -1)
526 549
 			{
527 550
 				$bytes_wrote = $file_info['size'] - $start_at_byte;
528
-			}
529
-			else
551
+			} else
530 552
 			{
531 553
 				$bytes_wrote = $last_position - $start_at_byte;
532 554
 			}
@@ -535,8 +557,7 @@  discard block
 block discarded – undo
535 557
 			if($is_tmp)
536 558
 			{
537 559
 				$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()));
538
-			}
539
-			else{
560
+			} else{
540 561
 				$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()));
541 562
 			}
542 563
 			
Please login to merge, or discard this patch.
includes/class-xcloner-database.php 4 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -469,6 +469,11 @@
 block discarded – undo
469 469
 	 * 		handler $fd - file handler where to write the records
470 470
 	 * @return
471 471
 	 */
472
+
473
+	/**
474
+	 * @param integer $start
475
+	 * @param integer $limit
476
+	 */
472 477
 	public function export_table($databaseName, $tableName, $start, $limit, $dumpfile)
473 478
 	{
474 479
 		$this->logger->debug(sprintf(("Exporting table  %s.%s data"), $databaseName, $tableName));
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 					$this->log(sprintf(__("Excluding table %s.%s from backup"), $table, $database));
280 280
 				}
281 281
 			$inc++;
282
-        }
282
+		}
283 283
 
284 284
 		return $tablesList;
285 285
 
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 					$buffer = "";
504 504
 					$this->countRecords++;
505 505
 
506
-	                foreach ($arr as $key => $value) {
506
+					foreach ($arr as $key => $value) {
507 507
 						$value = $this->_real_escape($value);
508 508
 						$buffer .= "'".$value."', ";
509 509
 					}
@@ -529,8 +529,8 @@  discard block
 block discarded – undo
529 529
 		$line = ("\n#\n# Table structure for table `$tableName`\n#\n\n");
530 530
 		$this->fs->get_tmp_filesystem_append()->write($dumpfile, $line);
531 531
 
532
-        if ($this->dbDropSyntax)
533
-        {
532
+		if ($this->dbDropSyntax)
533
+		{
534 534
 			$line = ("\nDROP table IF EXISTS `$tableName`;\n");
535 535
 			$this->fs->get_tmp_filesystem_append()->write($dumpfile, $line);
536 536
 		}
Please login to merge, or discard this patch.
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
  */
22 22
 
23 23
 
24
-class XCloner_Database extends wpdb{
24
+class XCloner_Database extends wpdb {
25 25
 
26 26
 
27
-	public  $debug 						= 0;
28
-	public  $recordsPerSession			= 10000;
29
-	public  $dbCompatibility			= "";
27
+	public  $debug = 0;
28
+	public  $recordsPerSession = 10000;
29
+	public  $dbCompatibility = "";
30 30
 	public  $dbDropSyntax				= 1;
31 31
 	public  $countRecords				= 0;
32 32
 
@@ -38,22 +38,22 @@  discard block
 block discarded – undo
38 38
 	private   $TEMP_DBPROCESS_FILE = ".database";
39 39
 	private   $TEMP_DUMP_FILE = "database-backup.sql";
40 40
 	
41
-	public function __construct($hash="", $wp_user="", $wp_pass="", $wp_db="", $wp_host="")
41
+	public function __construct($hash = "", $wp_user = "", $wp_pass = "", $wp_db = "", $wp_host = "")
42 42
 	{
43
-		$this->logger 					= new XCloner_Logger("xcloner_database", $hash);
44
-		$this->xcloner_settings 		= new Xcloner_Settings($hash);
45
-		$this->fs 						= new Xcloner_File_System($hash);
43
+		$this->logger = new XCloner_Logger("xcloner_database", $hash);
44
+		$this->xcloner_settings = new Xcloner_Settings($hash);
45
+		$this->fs = new Xcloner_File_System($hash);
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
-		if(!$this->recordsPerSession)
50
+		if (!$this->recordsPerSession)
51 51
 			$this->recordsPerSession = 100;
52 52
 		
53 53
 		$wp_host 	= $this->xcloner_settings->get_db_hostname();
54 54
 		$wp_user 	= $this->xcloner_settings->get_db_username();
55 55
 		$wp_pass 	= $this->xcloner_settings->get_db_password();
56
-		$wp_db 		= $this->xcloner_settings->get_db_database();
56
+		$wp_db = $this->xcloner_settings->get_db_database();
57 57
 
58 58
 		parent::__construct($wp_user, $wp_pass, $wp_db, $wp_host);
59 59
 		
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function init($data, $start = 0)
70 70
 	{
71
-		if($start and $this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)){
71
+		if ($start and $this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) {
72 72
 				$this->fs->get_tmp_filesystem()->delete($this->TEMP_DBPROCESS_FILE);
73 73
 		}
74 74
 		
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 				"database_count"=>0,
88 88
 		);
89 89
 		
90
-		if(!$this->xcloner_settings->get_enable_mysql_backup())
90
+		if (!$this->xcloner_settings->get_enable_mysql_backup())
91 91
 		{
92 92
 			$return['finished'] = 1;
93 93
 			return $return;
@@ -97,44 +97,44 @@  discard block
 block discarded – undo
97 97
 		
98 98
 		$this->init($params, $init);
99 99
 		
100
-		if($init)
100
+		if ($init)
101 101
 		{
102 102
 			$db_count = 0;
103 103
 			
104
-			if(isset($params['#']))
104
+			if (isset($params['#']))
105 105
 			{
106
-				foreach($params['#'] as $database)
106
+				foreach ($params['#'] as $database)
107 107
 				{
108
-					if(!isset($params[$database]) or !is_array($params[$database]))
108
+					if (!isset($params[$database]) or !is_array($params[$database]))
109 109
 						$params[$database] = array();
110 110
 				}
111 111
 				$db_count = -1;
112 112
 			}
113 113
 			
114
-			if(isset($params) and is_array($params))
115
-				foreach($params as $database=>$tables)
114
+			if (isset($params) and is_array($params))
115
+				foreach ($params as $database=>$tables)
116 116
 				{	
117
-					if($database != "#")
117
+					if ($database != "#")
118 118
 					{
119 119
 						$stats = $this->write_backup_process_list($database, $tables);	
120
-						$return['stats']['tables_count'] 	+= $stats['tables_count'];
121
-						$return['stats']['total_records'] 	+= $stats['total_records'];
120
+						$return['stats']['tables_count'] += $stats['tables_count'];
121
+						$return['stats']['total_records'] += $stats['total_records'];
122 122
 					}
123 123
 				}
124 124
 
125
-			if(sizeof($params))
126
-				$return['stats']['database_count'] = sizeof($params)+$db_count;
125
+			if (sizeof($params))
126
+				$return['stats']['database_count'] = sizeof($params) + $db_count;
127 127
 			else	
128 128
 				$return['stats']['database_count'] = 0;
129 129
 				
130 130
 			return $return;
131 131
 		}
132 132
 		
133
-		if(!isset($extra_params['startAtLine']))
133
+		if (!isset($extra_params['startAtLine']))
134 134
 			$extra_params['startAtLine'] = 0;
135
-		if(!isset($extra_params['startAtRecord']))
135
+		if (!isset($extra_params['startAtRecord']))
136 136
 			$extra_params['startAtRecord'] = 0;
137
-		if(!isset($extra_params['dumpfile']))
137
+		if (!isset($extra_params['dumpfile']))
138 138
 			$extra_params['dumpfile'] = "";
139 139
 		
140 140
 		$return = $this->process_incremental($extra_params['startAtLine'], $extra_params['startAtRecord'], $extra_params['dumpfile']);
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
 	public function log($message = "")
146 146
 	{
147 147
 		
148
-		if($message){
149
-			$this->logger->info( $message, array(""));
150
-		}else{	
151
-			if($this->last_query)
152
-				$this->logger->debug( $this->last_query, array(""));
153
-			if($this->last_error)
154
-				$this->logger->error( $this->last_error, array(""));
148
+		if ($message) {
149
+			$this->logger->info($message, array(""));
150
+		} else {	
151
+			if ($this->last_query)
152
+				$this->logger->debug($this->last_query, array(""));
153
+			if ($this->last_error)
154
+				$this->logger->error($this->last_error, array(""));
155 155
 		}
156 156
 		
157 157
 		return;
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	*/
167 167
 	public function error($message)
168 168
 	{
169
-		$this->logger->error( $message, array(""));
169
+		$this->logger->error($message, array(""));
170 170
 		
171 171
 		return;
172 172
 	}
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 		
200 200
 		$query = "show tables in `".$database."`";
201 201
 		
202
-		$res =  $this->get_results($query);
202
+		$res = $this->get_results($query);
203 203
 		$this->log();
204 204
 			
205 205
 		return count($res);
@@ -222,9 +222,9 @@  discard block
 block discarded – undo
222 222
 		$databases_list[$i]['num_tables'] = $this->get_database_num_tables($this->dbname);
223 223
 		$i++;
224 224
 		
225
-		if(is_array($databases))
226
-		foreach( $databases as $db){
227
-			if($db->Database != $this->dbname)
225
+		if (is_array($databases))
226
+		foreach ($databases as $db) {
227
+			if ($db->Database != $this->dbname)
228 228
 			{
229 229
 				$databases_list[$i]['name'] = $db->Database;
230 230
 				$databases_list[$i]['num_tables'] = $this->get_database_num_tables($db->Database);
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 		$tablesList[0] = array( );
248 248
 		$inc = 0;
249 249
 
250
-		if(!$database)
250
+		if (!$database)
251 251
 			$database = $this->dbname;
252 252
 		
253 253
 		$this->logger->debug(sprintf(("Listing tables in %s database"), $database));
@@ -255,14 +255,14 @@  discard block
 block discarded – undo
255 255
 		$tables = $this->get_results("SHOW TABLES in `".$database."`");
256 256
 		$this->log();
257 257
 
258
-		foreach ($tables as $table){
258
+		foreach ($tables as $table) {
259 259
 			
260 260
 			$table = array_values((array)$table)[0];
261 261
 			
262 262
 			$tablesList[$inc]['name'] = $table;
263 263
 			$tablesList[$inc]['database'] = $database;
264 264
 
265
-			if($get_num_records)
265
+			if ($get_num_records)
266 266
 			{
267 267
 				$records_num_result = $this->get_var("SELECT count(*) FROM `".$database."`.`".$table."`");
268 268
 				$this->log();
@@ -272,8 +272,8 @@  discard block
 block discarded – undo
272 272
 			
273 273
 			$tablesList[$inc]['excluded'] = 0;
274 274
 						
275
-			if(sizeof($included) and is_array($included))
276
-				if(!in_array($table, $included) )
275
+			if (sizeof($included) and is_array($included))
276
+				if (!in_array($table, $included))
277 277
 				{
278 278
 					$tablesList[$inc]['excluded'] = 1;
279 279
 					$this->log(sprintf(__("Excluding table %s.%s from backup"), $table, $database));
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 		
295 295
 		$tables = $this->list_tables($dbname, $incl_tables, 1);
296 296
 		
297
-		if($this->dbname != $dbname)
297
+		if ($this->dbname != $dbname)
298 298
 			$dumpfile = $dbname."-backup.sql";
299 299
 		else
300 300
 			$dumpfile = $this->TEMP_DUMP_FILE;
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 		$this->fs->get_tmp_filesystem_append()->write($this->TEMP_DBPROCESS_FILE, $line);
304 304
 			
305 305
 		// write this to the class and write to $TEMP_DBPROCESS_FILE file as database.table records
306
-		foreach($tables as $key=>$table) 
307
-		if($table!= "" and !$tables[$key]['excluded']){
306
+		foreach ($tables as $key=>$table) 
307
+		if ($table != "" and !$tables[$key]['excluded']) {
308 308
 
309 309
 			$line = sprintf("`%s`.`%s`\t%s\t%s\n", $dbname, $tables[$key]['name'], $tables[$key]['records'], $tables[$key]['excluded']);
310 310
 			$this->fs->get_tmp_filesystem_append()->write($this->TEMP_DBPROCESS_FILE, $line);
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 
333 333
 			$result = $this->get_var("SELECT count(*) FROM $table;");
334 334
 
335
-			return intval($result) ;// not max limit on 32 bit systems 2147483647; on 64 bit 999999999999
335
+			return intval($result); // not max limit on 32 bit systems 2147483647; on 64 bit 999999999999
336 336
 
337 337
 	}
338 338
 
@@ -348,25 +348,25 @@  discard block
 block discarded – undo
348 348
 	 * 		int $dbDropSyntax	- check if the DROP TABLE syntax should be added
349 349
 	 * @return array $return
350 350
 	 */
351
-	public function process_incremental($startAtLine= 0, $startAtRecord = 0, $dumpfile = "", $dbCompatibility= ""){
351
+	public function process_incremental($startAtLine = 0, $startAtRecord = 0, $dumpfile = "", $dbCompatibility = "") {
352 352
 
353 353
 		$count = 0;
354 354
 		$return['finished'] = 0;
355 355
 		$lines = array();
356 356
 		
357
-		if($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE))
358
-			$lines = array_filter(explode("\n",$this->fs->get_tmp_filesystem()->read($this->TEMP_DBPROCESS_FILE)));
357
+		if ($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE))
358
+			$lines = array_filter(explode("\n", $this->fs->get_tmp_filesystem()->read($this->TEMP_DBPROCESS_FILE)));
359 359
 	
360
-		foreach ($lines as $buffer){
360
+		foreach ($lines as $buffer) {
361 361
 			
362
-			if($count == $startAtLine)
362
+			if ($count == $startAtLine)
363 363
 			{
364 364
 	
365
-				$tableInfo =explode("\t", $buffer);
365
+				$tableInfo = explode("\t", $buffer);
366 366
 				
367
-				if($tableInfo[0] == "###newdump###"){
367
+				if ($tableInfo[0] == "###newdump###") {
368 368
 						// we create a new mysql dump file
369
-						if($dumpfile != ""){
369
+						if ($dumpfile != "") {
370 370
 								// we finished a previous one and write the footers
371 371
 								$return['dumpsize'] = $this->data_footers($dumpfile);
372 372
 						}
@@ -380,13 +380,13 @@  discard block
 block discarded – undo
380 380
 						$startAtLine++;
381 381
 						$return['new_dump'] = 1;
382 382
 						//break;
383
-				}else{
383
+				} else {
384 384
 						//we export the table
385
-						if($tableInfo[0] == "###enddump###")
385
+						if ($tableInfo[0] == "###enddump###")
386 386
 							$return['endDump'] = 1;
387 387
 	
388 388
 						//table is excluded
389
-						if($tableInfo[2])
389
+						if ($tableInfo[2])
390 390
 							continue;
391 391
 							
392 392
 						$next = $startAtRecord + $this->recordsPerSession;
@@ -398,29 +398,29 @@  discard block
 block discarded – undo
398 398
 
399 399
 						//return something to the browser
400 400
 						$return['databaseName'] 	= $databaseName;
401
-						$return['tableName'] 		= $tableName;
401
+						$return['tableName'] = $tableName;
402 402
 						$return['totalRecords'] 	= $tableInfo[1];
403 403
 
404 404
 						//if(intval($return['totalRecords']) != 0)
405 405
 						//print_r($tableInfo);
406 406
 						
407
-						if(trim($tableName) !=""  and !$tableInfo[2])
407
+						if (trim($tableName) != "" and !$tableInfo[2])
408 408
 							$processed_records = $this->export_table($databaseName, $tableName, $startAtRecord, $this->recordsPerSession, $dumpfile);
409 409
 						
410
-						$return['processedRecords'] = $startAtRecord+$processed_records;
410
+						$return['processedRecords'] = $startAtRecord + $processed_records;
411 411
 						
412
-						if($next >= $tableInfo[1]) //we finished loading the records for next sessions, will go to the new record
412
+						if ($next >= $tableInfo[1]) //we finished loading the records for next sessions, will go to the new record
413 413
 						{
414
-								$startAtLine ++;
414
+								$startAtLine++;
415 415
 								$startAtRecord = 0;
416
-						}else{
416
+						} else {
417 417
 								$startAtRecord = $startAtRecord + $this->recordsPerSession;
418 418
 							}
419 419
 
420 420
 						//$return['dbCompatibility'] 	= self::$dbCompatibility;
421 421
 						
422
-						$return['startAtLine']		= $startAtLine;
423
-						$return['startAtRecord']	= $startAtRecord;
422
+						$return['startAtLine'] = $startAtLine;
423
+						$return['startAtRecord'] = $startAtRecord;
424 424
 						$return['dumpfile']			= $dumpfile;
425 425
 						$return['dumpsize']			= $this->fs->get_tmp_filesystem_append()->getSize($dumpfile);
426 426
 
@@ -438,15 +438,15 @@  discard block
 block discarded – undo
438 438
 		}
439 439
 	
440 440
 		//while is finished, lets go home...
441
-		if($dumpfile != ""){
441
+		if ($dumpfile != "") {
442 442
 			// we finished a previous one and write the footers
443 443
 			$return['dumpsize'] = $this->data_footers($dumpfile);
444 444
 			$return['dumpfile'] = ($dumpfile);
445 445
 		}
446 446
 		$return['finished'] = 1;
447
-		$return['startAtLine']	= $startAtLine;
447
+		$return['startAtLine'] = $startAtLine;
448 448
 		
449
-		if($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE))
449
+		if ($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE))
450 450
 			$this->fs->get_tmp_filesystem()->delete($this->TEMP_DBPROCESS_FILE);
451 451
 		
452 452
 		$this->logger->debug(sprintf(("Database backup finished!")));
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 		
476 476
 		$records = 0;
477 477
 		
478
-		if($start == 0)
478
+		if ($start == 0)
479 479
 			$this->dump_structure($databaseName, $tableName, $dumpfile);
480 480
 
481 481
 		$start = intval($start);
@@ -483,20 +483,20 @@  discard block
 block discarded – undo
483 483
 		//exporting the table content now
484 484
 
485 485
 		$query = "SELECT * from `$databaseName`.`$tableName` Limit $start, $limit ;";
486
-		if($this->use_mysqli)
486
+		if ($this->use_mysqli)
487 487
 		{
488 488
 			$result = mysqli_query($this->dbh, $query);
489 489
 			$mysql_fetch_function = "mysqli_fetch_array";
490 490
 		
491
-		}else{
491
+		} else {
492 492
 			$result = mysql_query($query, $this->dbh);
493 493
 			$mysql_fetch_function = "mysql_fetch_array";
494 494
 		}
495 495
 		//$result = $this->get_results($query, ARRAY_N);
496 496
 		//print_r($result); exit;
497 497
 		
498
-		if($result){
499
-			while($row = $mysql_fetch_function($result, MYSQLI_ASSOC)){
498
+		if ($result) {
499
+			while ($row = $mysql_fetch_function($result, MYSQLI_ASSOC)) {
500 500
 					
501 501
 					$this->fs->get_tmp_filesystem_append()->write($dumpfile, "INSERT INTO `$tableName` VALUES (");
502 502
 					$arr = $row;
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 						$value = $this->_real_escape($value);
508 508
 						$buffer .= "'".$value."', ";
509 509
 					}
510
-					$buffer = rtrim($buffer, ', ') . ");\n";
510
+					$buffer = rtrim($buffer, ', ').");\n";
511 511
 					$this->fs->get_tmp_filesystem_append()->write($dumpfile, $buffer);
512 512
 					unset($buffer);
513 513
 					
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 
523 523
 	}
524 524
 
525
-	public function dump_structure($databaseName, $tableName ,$dumpfile)
525
+	public function dump_structure($databaseName, $tableName, $dumpfile)
526 526
 	{
527 527
 		$this->log(sprintf(__("Dumping the structure for %s.%s table"), $databaseName, $tableName));
528 528
 		
@@ -537,14 +537,14 @@  discard block
 block discarded – undo
537 537
 
538 538
 		//$result = mysqli_query($this->dbh,"SHOW CREATE table `$databaseName`.`$tableName`;");
539 539
 		$result = $this->get_row("SHOW CREATE table `$databaseName`.`$tableName`;", ARRAY_N);
540
-		if($result){
540
+		if ($result) {
541 541
 			//$row = mysqli_fetch_row( $result);
542 542
 			$line = ($result[1].";\n");
543 543
 			$this->fs->get_tmp_filesystem_append()->write($dumpfile, $line);
544 544
 		}
545 545
 
546
-		$line = ( "\n#\n# End Structure for table `$tableName`\n#\n\n");
547
-		$line .=("#\n# Dumping data for table `$tableName`\n#\n\n");
546
+		$line = ("\n#\n# End Structure for table `$tableName`\n#\n\n");
547
+		$line .= ("#\n# Dumping data for table `$tableName`\n#\n\n");
548 548
 		$this->fs->get_tmp_filesystem_append()->write($dumpfile, $line);
549 549
 		
550 550
 		return;
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 
568 568
 	}
569 569
 
570
-	public function resetcountRecords(){
570
+	public function resetcountRecords() {
571 571
 		
572 572
 		$this->countRecords = 0;
573 573
 
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 	
576 576
 	}
577 577
 
578
-	public function getcountRecords(){
578
+	public function getcountRecords() {
579 579
 		
580 580
 		return $this->countRecords;
581 581
 		
@@ -592,14 +592,14 @@  discard block
 block discarded – undo
592 592
 		$return .= "# Powered by XCloner Site Backup\n";
593 593
 		$return .= "# http://www.xcloner.com\n";
594 594
 		$return .= "#\n";
595
-		$return .= "# Host: " . $_SERVER['HTTP_HOST'] . "\n";
596
-		$return .= "# Generation Time: " . date("M j, Y \a\\t H:i") . "\n";
597
-		$return .= "# PHP Version: " . phpversion() . "\n";
598
-		$return .= "# Database Charset: ". $this->charset . "\n";
595
+		$return .= "# Host: ".$_SERVER['HTTP_HOST']."\n";
596
+		$return .= "# Generation Time: ".date("M j, Y \a\\t H:i")."\n";
597
+		$return .= "# PHP Version: ".phpversion()."\n";
598
+		$return .= "# Database Charset: ".$this->charset."\n";
599 599
 		
600 600
 		$results = $this->get_results("SHOW VARIABLES LIKE \"%version%\";", ARRAY_N);
601
-		if(isset($results)){
602
-			foreach($results as $result){
601
+		if (isset($results)) {
602
+			foreach ($results as $result) {
603 603
 
604 604
 					$return .= "# MYSQL ".$result[0].": ".$result[1]."\n";
605 605
 
@@ -609,13 +609,13 @@  discard block
 block discarded – undo
609 609
 		$results = $this->get_results("SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME
610 610
 					FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '".$database."';");
611 611
 		
612
-		if(isset($results[0])){
612
+		if (isset($results[0])) {
613 613
 
614 614
 			$return .= "# MYSQL DEFAULT_CHARACTER_SET_NAME: ".$results[0]->DEFAULT_CHARACTER_SET_NAME."\n";
615 615
 			$return .= "# MYSQL SCHEMA_NAME: ".$results[0]->DEFAULT_COLLATION_NAME."\n";
616 616
 		}
617 617
 
618
-		$return .= "#\n# Database : `" . $database . "`\n# --------------------------------------------------------\n\n";
618
+		$return .= "#\n# Database : `".$database."`\n# --------------------------------------------------------\n\n";
619 619
 		
620 620
 		$this->log(sprintf(__("Writing %s database dump headers"), $database));
621 621
 		
Please login to merge, or discard this patch.
Braces   +75 added lines, -52 removed lines patch added patch discarded remove patch
@@ -44,11 +44,13 @@  discard block
 block discarded – undo
44 44
 		$this->xcloner_settings 		= new Xcloner_Settings($hash);
45 45
 		$this->fs 						= new Xcloner_File_System($hash);
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
 		$wp_host 	= $this->xcloner_settings->get_db_hostname();
54 56
 		$wp_user 	= $this->xcloner_settings->get_db_username();
@@ -105,37 +107,43 @@  discard block
 block discarded – undo
105 107
 			{
106 108
 				foreach($params['#'] as $database)
107 109
 				{
108
-					if(!isset($params[$database]) or !is_array($params[$database]))
109
-						$params[$database] = array();
110
+					if(!isset($params[$database]) or !is_array($params[$database])) {
111
+											$params[$database] = array();
112
+					}
110 113
 				}
111 114
 				$db_count = -1;
112 115
 			}
113 116
 			
114
-			if(isset($params) and is_array($params))
115
-				foreach($params as $database=>$tables)
117
+			if(isset($params) and is_array($params)) {
118
+							foreach($params as $database=>$tables)
116 119
 				{	
117 120
 					if($database != "#")
118 121
 					{
119
-						$stats = $this->write_backup_process_list($database, $tables);	
122
+						$stats = $this->write_backup_process_list($database, $tables);
123
+			}
120 124
 						$return['stats']['tables_count'] 	+= $stats['tables_count'];
121 125
 						$return['stats']['total_records'] 	+= $stats['total_records'];
122 126
 					}
123 127
 				}
124 128
 
125
-			if(sizeof($params))
126
-				$return['stats']['database_count'] = sizeof($params)+$db_count;
127
-			else	
128
-				$return['stats']['database_count'] = 0;
129
+			if(sizeof($params)) {
130
+							$return['stats']['database_count'] = sizeof($params)+$db_count;
131
+			} else {
132
+							$return['stats']['database_count'] = 0;
133
+			}
129 134
 				
130 135
 			return $return;
131 136
 		}
132 137
 		
133
-		if(!isset($extra_params['startAtLine']))
134
-			$extra_params['startAtLine'] = 0;
135
-		if(!isset($extra_params['startAtRecord']))
136
-			$extra_params['startAtRecord'] = 0;
137
-		if(!isset($extra_params['dumpfile']))
138
-			$extra_params['dumpfile'] = "";
138
+		if(!isset($extra_params['startAtLine'])) {
139
+					$extra_params['startAtLine'] = 0;
140
+		}
141
+		if(!isset($extra_params['startAtRecord'])) {
142
+					$extra_params['startAtRecord'] = 0;
143
+		}
144
+		if(!isset($extra_params['dumpfile'])) {
145
+					$extra_params['dumpfile'] = "";
146
+		}
139 147
 		
140 148
 		$return = $this->process_incremental($extra_params['startAtLine'], $extra_params['startAtRecord'], $extra_params['dumpfile']);
141 149
 		
@@ -147,11 +155,13 @@  discard block
 block discarded – undo
147 155
 		
148 156
 		if($message){
149 157
 			$this->logger->info( $message, array(""));
150
-		}else{	
151
-			if($this->last_query)
152
-				$this->logger->debug( $this->last_query, array(""));
153
-			if($this->last_error)
154
-				$this->logger->error( $this->last_error, array(""));
158
+		} else{	
159
+			if($this->last_query) {
160
+							$this->logger->debug( $this->last_query, array(""));
161
+			}
162
+			if($this->last_error) {
163
+							$this->logger->error( $this->last_error, array(""));
164
+			}
155 165
 		}
156 166
 		
157 167
 		return;
@@ -222,11 +232,12 @@  discard block
 block discarded – undo
222 232
 		$databases_list[$i]['num_tables'] = $this->get_database_num_tables($this->dbname);
223 233
 		$i++;
224 234
 		
225
-		if(is_array($databases))
226
-		foreach( $databases as $db){
235
+		if(is_array($databases)) {
236
+				foreach( $databases as $db){
227 237
 			if($db->Database != $this->dbname)
228 238
 			{
229 239
 				$databases_list[$i]['name'] = $db->Database;
240
+		}
230 241
 				$databases_list[$i]['num_tables'] = $this->get_database_num_tables($db->Database);
231 242
 				$i++;
232 243
 			}
@@ -247,8 +258,9 @@  discard block
 block discarded – undo
247 258
 		$tablesList[0] = array( );
248 259
 		$inc = 0;
249 260
 
250
-		if(!$database)
251
-			$database = $this->dbname;
261
+		if(!$database) {
262
+					$database = $this->dbname;
263
+		}
252 264
 		
253 265
 		$this->logger->debug(sprintf(("Listing tables in %s database"), $database));
254 266
 		
@@ -272,10 +284,11 @@  discard block
 block discarded – undo
272 284
 			
273 285
 			$tablesList[$inc]['excluded'] = 0;
274 286
 						
275
-			if(sizeof($included) and is_array($included))
276
-				if(!in_array($table, $included) )
287
+			if(sizeof($included) and is_array($included)) {
288
+							if(!in_array($table, $included) )
277 289
 				{
278 290
 					$tablesList[$inc]['excluded'] = 1;
291
+			}
279 292
 					$this->log(sprintf(__("Excluding table %s.%s from backup"), $table, $database));
280 293
 				}
281 294
 			$inc++;
@@ -294,19 +307,21 @@  discard block
 block discarded – undo
294 307
 		
295 308
 		$tables = $this->list_tables($dbname, $incl_tables, 1);
296 309
 		
297
-		if($this->dbname != $dbname)
298
-			$dumpfile = $dbname."-backup.sql";
299
-		else
300
-			$dumpfile = $this->TEMP_DUMP_FILE;
310
+		if($this->dbname != $dbname) {
311
+					$dumpfile = $dbname."-backup.sql";
312
+		} else {
313
+					$dumpfile = $this->TEMP_DUMP_FILE;
314
+		}
301 315
 		
302 316
 		$line = sprintf("###newdump###\t%s\t%s\n", $dbname, $dumpfile);
303 317
 		$this->fs->get_tmp_filesystem_append()->write($this->TEMP_DBPROCESS_FILE, $line);
304 318
 			
305 319
 		// write this to the class and write to $TEMP_DBPROCESS_FILE file as database.table records
306
-		foreach($tables as $key=>$table) 
307
-		if($table!= "" and !$tables[$key]['excluded']){
320
+		foreach($tables as $key=>$table) {
321
+				if($table!= "" and !$tables[$key]['excluded']){
308 322
 
309 323
 			$line = sprintf("`%s`.`%s`\t%s\t%s\n", $dbname, $tables[$key]['name'], $tables[$key]['records'], $tables[$key]['excluded']);
324
+		}
310 325
 			$this->fs->get_tmp_filesystem_append()->write($this->TEMP_DBPROCESS_FILE, $line);
311 326
 			$return['tables_count']++;
312 327
 			$return['total_records'] += $tables[$key]['records'];
@@ -354,8 +369,9 @@  discard block
 block discarded – undo
354 369
 		$return['finished'] = 0;
355 370
 		$lines = array();
356 371
 		
357
-		if($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE))
358
-			$lines = array_filter(explode("\n",$this->fs->get_tmp_filesystem()->read($this->TEMP_DBPROCESS_FILE)));
372
+		if($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) {
373
+					$lines = array_filter(explode("\n",$this->fs->get_tmp_filesystem()->read($this->TEMP_DBPROCESS_FILE)));
374
+		}
359 375
 	
360 376
 		foreach ($lines as $buffer){
361 377
 			
@@ -380,14 +396,16 @@  discard block
 block discarded – undo
380 396
 						$startAtLine++;
381 397
 						$return['new_dump'] = 1;
382 398
 						//break;
383
-				}else{
399
+				} else{
384 400
 						//we export the table
385
-						if($tableInfo[0] == "###enddump###")
386
-							$return['endDump'] = 1;
401
+						if($tableInfo[0] == "###enddump###") {
402
+													$return['endDump'] = 1;
403
+						}
387 404
 	
388 405
 						//table is excluded
389
-						if($tableInfo[2])
390
-							continue;
406
+						if($tableInfo[2]) {
407
+													continue;
408
+						}
391 409
 							
392 410
 						$next = $startAtRecord + $this->recordsPerSession;
393 411
 						
@@ -404,16 +422,19 @@  discard block
 block discarded – undo
404 422
 						//if(intval($return['totalRecords']) != 0)
405 423
 						//print_r($tableInfo);
406 424
 						
407
-						if(trim($tableName) !=""  and !$tableInfo[2])
408
-							$processed_records = $this->export_table($databaseName, $tableName, $startAtRecord, $this->recordsPerSession, $dumpfile);
425
+						if(trim($tableName) !=""  and !$tableInfo[2]) {
426
+													$processed_records = $this->export_table($databaseName, $tableName, $startAtRecord, $this->recordsPerSession, $dumpfile);
427
+						}
409 428
 						
410 429
 						$return['processedRecords'] = $startAtRecord+$processed_records;
411 430
 						
412
-						if($next >= $tableInfo[1]) //we finished loading the records for next sessions, will go to the new record
431
+						if($next >= $tableInfo[1]) {
432
+							//we finished loading the records for next sessions, will go to the new record
413 433
 						{
414 434
 								$startAtLine ++;
435
+						}
415 436
 								$startAtRecord = 0;
416
-						}else{
437
+						} else{
417 438
 								$startAtRecord = $startAtRecord + $this->recordsPerSession;
418 439
 							}
419 440
 
@@ -446,8 +467,9 @@  discard block
 block discarded – undo
446 467
 		$return['finished'] = 1;
447 468
 		$return['startAtLine']	= $startAtLine;
448 469
 		
449
-		if($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE))
450
-			$this->fs->get_tmp_filesystem()->delete($this->TEMP_DBPROCESS_FILE);
470
+		if($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) {
471
+					$this->fs->get_tmp_filesystem()->delete($this->TEMP_DBPROCESS_FILE);
472
+		}
451 473
 		
452 474
 		$this->logger->debug(sprintf(("Database backup finished!")));
453 475
 		
@@ -475,8 +497,9 @@  discard block
 block discarded – undo
475 497
 		
476 498
 		$records = 0;
477 499
 		
478
-		if($start == 0)
479
-			$this->dump_structure($databaseName, $tableName, $dumpfile);
500
+		if($start == 0) {
501
+					$this->dump_structure($databaseName, $tableName, $dumpfile);
502
+		}
480 503
 
481 504
 		$start = intval($start);
482 505
 		$limit = intval($limit);
@@ -488,7 +511,7 @@  discard block
 block discarded – undo
488 511
 			$result = mysqli_query($this->dbh, $query);
489 512
 			$mysql_fetch_function = "mysqli_fetch_array";
490 513
 		
491
-		}else{
514
+		} else{
492 515
 			$result = mysql_query($query, $this->dbh);
493 516
 			$mysql_fetch_function = "mysql_fetch_array";
494 517
 		}
Please login to merge, or discard this patch.
includes/class-xcloner-file-system.php 5 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 use League\Flysystem\Config;
3 3
 use League\Flysystem\Filesystem;
4
-use League\Flysystem\Util;
5 4
 use League\Flysystem\Adapter\Local;
6 5
 
7 6
 class Xcloner_File_System{
Please login to merge, or discard this patch.
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -187,6 +187,9 @@  discard block
 block discarded – undo
187 187
 		return $total;		
188 188
 	}
189 189
 	
190
+	/**
191
+	 * @param string $backup_name
192
+	 */
190 193
 	public function is_part($backup_name)
191 194
 	{
192 195
 		if(stristr($backup_name, "-part"))
@@ -577,6 +580,9 @@  discard block
 block discarded – undo
577 580
 		
578 581
 	}
579 582
 	
583
+	/**
584
+	 * @param string $tmp_file
585
+	 */
580 586
 	public function estimate_reading_time($tmp_file)
581 587
 	{
582 588
 		$this->logger->debug(sprintf(("Estimating file system reading time")));
@@ -615,6 +621,9 @@  discard block
 block discarded – undo
615 621
 		return $name;	
616 622
 	}
617 623
 	
624
+	/**
625
+	 * @param string $field
626
+	 */
618 627
 	public function sort_by( &$array, $field, $direction = 'asc')
619 628
 	{
620 629
 		if(strtolower($direction) == "desc" || $direction == SORT_DESC)
Please login to merge, or discard this patch.
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -260,12 +260,12 @@  discard block
 block discarded – undo
260 260
 	}
261 261
 	
262 262
 	public function getMetadataFull($adapter = "storage_adapter" , $path)
263
-    {
264
-        $location = $this->$adapter->applyPathPrefix($path);
265
-        $spl_info = new SplFileInfo($location);
263
+	{
264
+		$location = $this->$adapter->applyPathPrefix($path);
265
+		$spl_info = new SplFileInfo($location);
266 266
         
267
-        return ($spl_info);
268
-    }
267
+		return ($spl_info);
268
+	}
269 269
 	
270 270
 	
271 271
 	public function get_backup_archives_list()
@@ -629,27 +629,27 @@  discard block
 block discarded – undo
629 629
 	
630 630
 	private function array_orderby()
631 631
 	{
632
-	    $args = func_get_args();
633
-	    $data = array_shift($args);
632
+		$args = func_get_args();
633
+		$data = array_shift($args);
634 634
 	    
635
-	    foreach ($args as $n => $field) {
636
-	        if (is_string($field)) {
637
-	            $tmp = array();
638
-	            foreach ($data as $key => $row)
639
-	            {
635
+		foreach ($args as $n => $field) {
636
+			if (is_string($field)) {
637
+				$tmp = array();
638
+				foreach ($data as $key => $row)
639
+				{
640 640
 					if(is_array($row))
641 641
 						$tmp[$key] = $row[$field];
642 642
 					else
643 643
 						$tmp[$key] = $row->$field;
644 644
 				}
645
-	            $args[$n] = $tmp;
646
-	            }
647
-	    }
648
-	    $args[] = &$data;
645
+				$args[$n] = $tmp;
646
+				}
647
+		}
648
+		$args[] = &$data;
649 649
 	    
650
-	    call_user_func_array('array_multisort', $args);
650
+		call_user_func_array('array_multisort', $args);
651 651
 	    
652
-	    return array_pop($args);
652
+		return array_pop($args);
653 653
 	}
654 654
 	
655 655
 	public function is_excluded($file)
Please login to merge, or discard this patch.
Spacing   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -4,12 +4,12 @@  discard block
 block discarded – undo
4 4
 use League\Flysystem\Util;
5 5
 use League\Flysystem\Adapter\Local;
6 6
 
7
-class Xcloner_File_System{
7
+class Xcloner_File_System {
8 8
 	
9
-	private $excluded_files 			= "";
10
-	private $excluded_files_by_default	= array("administrator/backups", "wp-content/backups");
11
-	private $included_files_handler 	= "backup_files.csv";
12
-	private $temp_dir_handler 			= ".dir";
9
+	private $excluded_files = "";
10
+	private $excluded_files_by_default = array("administrator/backups", "wp-content/backups");
11
+	private $included_files_handler = "backup_files.csv";
12
+	private $temp_dir_handler = ".dir";
13 13
 	public  $filesystem;
14 14
 	public  $tmp_filesystem;
15 15
 	public  $storage_filesystem;
@@ -33,39 +33,39 @@  discard block
 block discarded – undo
33 33
 		$this->logger = new XCloner_Logger('xcloner_file_system', $hash);
34 34
 		$this->xcloner_requirements = new Xcloner_Requirements();
35 35
 
36
-		$this->xcloner_settings 		= new Xcloner_Settings($hash);
36
+		$this->xcloner_settings = new Xcloner_Settings($hash);
37 37
 
38
-		try{
38
+		try {
39 39
 			
40
-			$this->start_adapter = new Local($this->xcloner_settings->get_xcloner_start_path(),LOCK_EX, 'SKIP_LINKS');
40
+			$this->start_adapter = new Local($this->xcloner_settings->get_xcloner_start_path(), LOCK_EX, 'SKIP_LINKS');
41 41
 			$this->start_filesystem = new Filesystem($this->start_adapter, new Config([
42 42
 					'disable_asserts' => true,
43 43
 				]));
44 44
 			
45
-			$this->tmp_adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(),LOCK_EX, 'SKIP_LINKS');
45
+			$this->tmp_adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(), LOCK_EX, 'SKIP_LINKS');
46 46
 			$this->tmp_filesystem = new Filesystem($this->tmp_adapter, new Config([
47 47
 					'disable_asserts' => true,
48 48
 				]));
49
-			$adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(),LOCK_EX|FILE_APPEND, 'SKIP_LINKS');
49
+			$adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(), LOCK_EX | FILE_APPEND, 'SKIP_LINKS');
50 50
 			$this->tmp_filesystem_append = new Filesystem($adapter, new Config([
51 51
 					'disable_asserts' => true,
52 52
 				]));
53 53
 
54
-			$adapter = new Local($this->xcloner_settings->get_xcloner_store_path(),LOCK_EX, 'SKIP_LINKS');
54
+			$adapter = new Local($this->xcloner_settings->get_xcloner_store_path(), LOCK_EX, 'SKIP_LINKS');
55 55
 			$this->storage_filesystem = new Filesystem($adapter, new Config([
56 56
 					'disable_asserts' => true,
57 57
 				]));	
58 58
 			
59
-			$this->storage_adapter = new Local($this->xcloner_settings->get_xcloner_store_path(),FILE_APPEND, 'SKIP_LINKS');
59
+			$this->storage_adapter = new Local($this->xcloner_settings->get_xcloner_store_path(), FILE_APPEND, 'SKIP_LINKS');
60 60
 			$this->storage_filesystem_append = new Filesystem($this->storage_adapter, new Config([
61 61
 					'disable_asserts' => true,
62 62
 				]));
63
-		}catch(Exception $e){
63
+		}catch (Exception $e) {
64 64
 			return false;
65 65
 		}
66 66
 		
67 67
 		
68
-		if($value = get_option('xcloner_directories_to_scan_per_request'))
68
+		if ($value = get_option('xcloner_directories_to_scan_per_request'))
69 69
 			$this->folders_to_process_per_session = $value;
70 70
 
71 71
 	}
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
 		return $this->getMetadataFull('storage_adapter', $file);
127 127
 	}
128 128
 	
129
-	public function get_included_files_handler($metadata  = 0)
129
+	public function get_included_files_handler($metadata = 0)
130 130
 	{
131 131
 		$path = $this->included_files_handler;
132
-		if(!$metadata)
132
+		if (!$metadata)
133 133
 			return $path;
134 134
 		
135 135
 		$spl_info = $this->getMetadataFull('tmp_adapter', $path);
@@ -146,16 +146,16 @@  discard block
 block discarded – undo
146 146
 	{
147 147
 		$files = $this->get_backup_archives_list();
148 148
 		
149
-		if(is_array($files))
150
-			$this->sort_by($files, "timestamp","desc");
149
+		if (is_array($files))
150
+			$this->sort_by($files, "timestamp", "desc");
151 151
 		
152 152
 		$new_list = array();
153 153
 		
154
-		foreach($files as $key=>$file)
155
-			if(!isset($file['parent']))
154
+		foreach ($files as $key=>$file)
155
+			if (!isset($file['parent']))
156 156
 				$new_list[] = ($files[$key]);
157 157
 
158
-		if(isset($new_list[0]))
158
+		if (isset($new_list[0]))
159 159
 			return $new_list[0];
160 160
 	}
161 161
 	
@@ -163,13 +163,13 @@  discard block
 block discarded – undo
163 163
 	{
164 164
 		$files = $this->get_backup_archives_list();
165 165
 
166
-		if(is_array($files))
167
-			$this->sort_by($files, "timestamp","desc");
166
+		if (is_array($files))
167
+			$this->sort_by($files, "timestamp", "desc");
168 168
 		
169 169
 		$new_list = array();
170 170
 		
171
-		foreach($files as $key=>$file)
172
-			if(!isset($file['parent']))
171
+		foreach ($files as $key=>$file)
172
+			if (!isset($file['parent']))
173 173
 				$new_list[] = ($files[$key]);
174 174
 
175 175
 		return $new_list;
@@ -180,8 +180,8 @@  discard block
 block discarded – undo
180 180
 		$files = $this->get_backup_archives_list();
181 181
 		$total = 0;
182 182
 		
183
-		if(is_array($files))
184
-			foreach($files as $file)
183
+		if (is_array($files))
184
+			foreach ($files as $file)
185 185
 				$total += $file['size'];
186 186
 				
187 187
 		return $total;		
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	
190 190
 	public function is_part($backup_name)
191 191
 	{
192
-		if(stristr($backup_name, "-part"))
192
+		if (stristr($backup_name, "-part"))
193 193
 			return true;
194 194
 		
195 195
 		return false;	
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	
198 198
 	public function is_multipart($backup_name)
199 199
 	{
200
-		if(stristr($backup_name, "-multipart"))
200
+		if (stristr($backup_name, "-multipart"))
201 201
 			return true;
202 202
 		
203 203
 		return false;	
@@ -206,10 +206,10 @@  discard block
 block discarded – undo
206 206
 	public function get_backup_size($backup_name)
207 207
 	{
208 208
 		$backup_size = $this->get_storage_filesystem()->getSize($backup_name);
209
-		if($this->is_multipart($backup_name))
209
+		if ($this->is_multipart($backup_name))
210 210
 		{
211 211
 			$backup_parts = $this->get_multipart_files($backup_name);
212
-			foreach($backup_parts as $part_file)
212
+			foreach ($backup_parts as $part_file)
213 213
 				$backup_size += $this->get_storage_filesystem()->getSize($part_file);
214 214
 		}
215 215
 		
@@ -220,12 +220,12 @@  discard block
 block discarded – undo
220 220
 	{
221 221
 		$files = array();
222 222
 		
223
-		if($this->is_multipart($backup_name))
223
+		if ($this->is_multipart($backup_name))
224 224
 		{
225 225
 			$lines = explode(PHP_EOL, $this->get_storage_filesystem()->read($backup_name));
226
-			foreach($lines as $line)
226
+			foreach ($lines as $line)
227 227
 			{
228
-				if($line)
228
+				if ($line)
229 229
 				{
230 230
 					$data = str_getcsv($line);
231 231
 					$files[] = $data[0];
@@ -238,12 +238,12 @@  discard block
 block discarded – undo
238 238
 	
239 239
 	public function delete_backup_by_name($backup_name)
240 240
 	{
241
-		if($this->is_multipart($backup_name))
241
+		if ($this->is_multipart($backup_name))
242 242
 		{
243 243
 			$lines = explode(PHP_EOL, $this->get_storage_filesystem()->read($backup_name));
244
-			foreach($lines as $line)
244
+			foreach ($lines as $line)
245 245
 			{
246
-				if($line)
246
+				if ($line)
247 247
 				{
248 248
 					$data = str_getcsv($line);
249 249
 					$this->get_storage_filesystem()->delete($data[0]);
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 			}
252 252
 		}
253 253
 		
254
-		if($this->get_storage_filesystem()->delete($backup_name))
254
+		if ($this->get_storage_filesystem()->delete($backup_name))
255 255
 			$return = true;
256 256
 		else
257 257
 			$return = false;
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 		return $return;	
260 260
 	}
261 261
 	
262
-	public function getMetadataFull($adapter = "storage_adapter" , $path)
262
+	public function getMetadataFull($adapter = "storage_adapter", $path)
263 263
     {
264 264
         $location = $this->$adapter->applyPathPrefix($path);
265 265
         $spl_info = new SplFileInfo($location);
@@ -272,25 +272,25 @@  discard block
 block discarded – undo
272 272
 	{
273 273
 		$list = array();
274 274
 		
275
-		if(method_exists($this->get_storage_filesystem(), "listContents"))
275
+		if (method_exists($this->get_storage_filesystem(), "listContents"))
276 276
 			$list = $this->get_storage_filesystem()->listContents();
277 277
 
278 278
 		
279 279
 		$backup_files = array();
280 280
 		$parents = array();
281 281
 		
282
-		foreach($list as $file_info)
282
+		foreach ($list as $file_info)
283 283
 		{
284 284
 			$data = array();
285 285
 			
286
-			if(isset($file_info['extension']) and $file_info['extension'] == "csv")
286
+			if (isset($file_info['extension']) and $file_info['extension'] == "csv")
287 287
 			{
288 288
 				$lines = explode(PHP_EOL, $this->get_storage_filesystem()->read($file_info['path']));
289
-				foreach($lines as $line)
290
-					if($line)
289
+				foreach ($lines as $line)
290
+					if ($line)
291 291
 					{
292 292
 						$data = str_getcsv($line);
293
-						if(is_array($data)){
293
+						if (is_array($data)) {
294 294
 							$parents[$data[0]] = $file_info['path'];
295 295
 							$file_info['childs'][] = $data;
296 296
 							$file_info['size'] += $data[2];
@@ -299,13 +299,13 @@  discard block
 block discarded – undo
299 299
 						
300 300
 			}
301 301
 			
302
-			if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions))
302
+			if ($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions))
303 303
 				$backup_files[$file_info['path']] = $file_info;
304 304
 		}
305 305
 		
306
-		foreach($backup_files as $key=>$file_info)
306
+		foreach ($backup_files as $key=>$file_info)
307 307
 		{
308
-			if(isset($parents[$file_info['path']]))
308
+			if (isset($parents[$file_info['path']]))
309 309
 				$backup_files[$key]['parent'] = $parents[$file_info['path']];
310 310
 		}
311 311
 		
@@ -314,40 +314,40 @@  discard block
 block discarded – undo
314 314
 	
315 315
 	public function start_file_recursion($init = 0)
316 316
 	{
317
-		if($init)
317
+		if ($init)
318 318
 		{
319 319
 			$this->logger->info(sprintf(__("Starting the filesystem scanner on root folder %s"), $this->xcloner_settings->get_xcloner_start_path()));
320 320
 			$this->do_system_init();
321 321
 		}
322 322
 		
323
-		if($this->tmp_filesystem->has($this->get_temp_dir_handler())){
323
+		if ($this->tmp_filesystem->has($this->get_temp_dir_handler())) {
324 324
 		//.dir exists, we presume we have files to iterate	
325 325
 			$content = $this->tmp_filesystem->read($this->get_temp_dir_handler());
326 326
 			$files = array_filter(explode("\n", $content));
327 327
 			$this->tmp_filesystem->delete($this->get_temp_dir_handler());
328 328
 			
329 329
 			$counter = 0;
330
-			foreach($files as $file)
330
+			foreach ($files as $file)
331 331
 			{
332
-				if($counter < $this->folders_to_process_per_session){
332
+				if ($counter < $this->folders_to_process_per_session) {
333 333
 					$this->build_files_list($file);
334 334
 					$counter++;
335
-				}else{
335
+				} else {
336 336
 					$this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file."\n");
337 337
 				}
338 338
 			}
339
-		}else{
339
+		} else {
340 340
 			$this->build_files_list();
341 341
 		}
342 342
 		
343
-		if($this->scan_finished())
343
+		if ($this->scan_finished())
344 344
 		{
345 345
 			$metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata("index.html");
346 346
 			$this->store_file($metadata_dumpfile, 'tmp_filesystem');
347 347
 			$this->files_counter++;
348 348
 		
349 349
 			//adding included dump file to the included files list
350
-			if($this->get_tmp_filesystem()->has($this->get_included_files_handler()))
350
+			if ($this->get_tmp_filesystem()->has($this->get_included_files_handler()))
351 351
 			{
352 352
 				$metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata($this->get_included_files_handler());
353 353
 				$this->store_file($metadata_dumpfile, 'tmp_filesystem');
@@ -355,13 +355,13 @@  discard block
 block discarded – undo
355 355
 			}
356 356
 		
357 357
 			//adding a default index.html to the temp xcloner folder
358
-			if(!$this->get_tmp_filesystem()->has("index.html"))
358
+			if (!$this->get_tmp_filesystem()->has("index.html"))
359 359
 			{
360
-				$this->get_tmp_filesystem()->write("index.html","");
360
+				$this->get_tmp_filesystem()->write("index.html", "");
361 361
 			}
362 362
 			
363 363
 			//adding the default log file
364
-			if($this->get_tmp_filesystem()->has($this->xcloner_settings->get_logger_filename(1)))
364
+			if ($this->get_tmp_filesystem()->has($this->xcloner_settings->get_logger_filename(1)))
365 365
 			{
366 366
 				$metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata($this->xcloner_settings->get_logger_filename(1));
367 367
 				$this->store_file($metadata_dumpfile, 'tmp_filesystem');
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 	{
379 379
 		$return = array();
380 380
 		$return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->get_included_files_handler();
381
-		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log'))
381
+		if ($this->xcloner_settings->get_xcloner_option('xcloner_enable_log'))
382 382
 			$return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->xcloner_settings->get_logger_filename(1);
383 383
 		
384 384
 		return $return;
@@ -391,8 +391,8 @@  discard block
 block discarded – undo
391 391
 		
392 392
 		$contents = $this->get_tmp_filesystem()->listContents();
393 393
 	
394
-		if(is_array($contents))
395
-		foreach($contents as $file_info)
394
+		if (is_array($contents))
395
+		foreach ($contents as $file_info)
396 396
 			$this->get_tmp_filesystem()->delete($file_info['path']);
397 397
 			
398 398
 		@rmdir($this->xcloner_settings->get_xcloner_tmp_path());
@@ -404,16 +404,16 @@  discard block
 block discarded – undo
404 404
 	{
405 405
 		$this->files_counter = 0;
406 406
 		
407
-		if(!$this->storage_filesystem->has("index.html"))	
408
-			$this->storage_filesystem->write("index.html","");
407
+		if (!$this->storage_filesystem->has("index.html"))	
408
+			$this->storage_filesystem->write("index.html", "");
409 409
 		
410
-		if(!$this->tmp_filesystem->has("index.html"))	
411
-			$this->tmp_filesystem->write("index.html","");
410
+		if (!$this->tmp_filesystem->has("index.html"))	
411
+			$this->tmp_filesystem->write("index.html", "");
412 412
 			
413
-		if($this->tmp_filesystem->has($this->get_included_files_handler()))
413
+		if ($this->tmp_filesystem->has($this->get_included_files_handler()))
414 414
 			$this->tmp_filesystem->delete($this->get_included_files_handler());
415 415
 		
416
-		if($this->tmp_filesystem->has($this->get_temp_dir_handler()))	
416
+		if ($this->tmp_filesystem->has($this->get_temp_dir_handler()))	
417 417
 			$this->tmp_filesystem->delete($this->get_temp_dir_handler());
418 418
 	}
419 419
 	
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 	
435 435
 	public function set_excluded_files($excluded_files = array())
436 436
 	{
437
-		if(!is_array($excluded_files))
437
+		if (!is_array($excluded_files))
438 438
 			$excluded_files = array();
439 439
 			
440 440
 		$this->excluded_files = array_merge($excluded_files, $this->excluded_files_by_default);
@@ -457,33 +457,33 @@  discard block
 block discarded – undo
457 457
 		$this->logger->debug(sprintf(("Building the files system list")));
458 458
 		
459 459
 		//if we start with the root folder(empty value), we initializa the file system
460
-		if(!$folder){
460
+		if (!$folder) {
461 461
 			
462 462
 		}
463 463
 			
464
-		try{
464
+		try {
465 465
 			
466 466
 			$files = $this->start_filesystem->listContents($folder);
467
-			foreach($files as $file)
467
+			foreach ($files as $file)
468 468
 			{
469
-				if(!is_readable($this->xcloner_settings->get_xcloner_start_path().DS.$file['path']))
469
+				if (!is_readable($this->xcloner_settings->get_xcloner_start_path().DS.$file['path']))
470 470
 				{
471
-					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, file not readable"), $file['path']), array("FILESYSTEM SCAN","NOT READABLE"));
471
+					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, file not readable"), $file['path']), array("FILESYSTEM SCAN", "NOT READABLE"));
472 472
 				}
473
-				elseif(!$matching_pattern = $this->is_excluded($file) ){
474
-					$this->logger->info(sprintf(__("Adding %s to the filesystem list"), $file['path']), array("FILESYSTEM SCAN","INCLUDE"));
473
+				elseif (!$matching_pattern = $this->is_excluded($file)) {
474
+					$this->logger->info(sprintf(__("Adding %s to the filesystem list"), $file['path']), array("FILESYSTEM SCAN", "INCLUDE"));
475 475
 					$file['visibility'] = $this->start_filesystem->getVisibility($file['path']);
476 476
 					$this->store_file($file);
477 477
 					$this->files_counter++;
478
-					if(isset($file['size']))
478
+					if (isset($file['size']))
479 479
 						$this->files_size += $file['size'];
480 480
 					
481
-				}else{
482
-					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, matching pattern %s"), $file['path'], $matching_pattern), array("FILESYSTEM SCAN","EXCLUDE"));
481
+				} else {
482
+					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, matching pattern %s"), $file['path'], $matching_pattern), array("FILESYSTEM SCAN", "EXCLUDE"));
483 483
 					}
484 484
 			}
485 485
 			
486
-		}catch(Exception $e){
486
+		}catch (Exception $e) {
487 487
 			
488 488
 			$this->logger->error($e->getMessage());
489 489
 		
@@ -497,9 +497,9 @@  discard block
 block discarded – undo
497 497
 				
498 498
 		$start_time = microtime();
499 499
 		
500
-		$data = str_repeat(rand(0,9), 1024*1024); //write 1MB data
500
+		$data = str_repeat(rand(0, 9), 1024 * 1024); //write 1MB data
501 501
 		
502
-		try{
502
+		try {
503 503
 			$this->tmp_filesystem->write($tmp_file, $data);
504 504
 			
505 505
 			$end_time = microtime() - $start_time;
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 		
511 511
 			$this->tmp_filesystem->delete($tmp_file);
512 512
 		
513
-		}catch(Exception $e){
513
+		}catch (Exception $e) {
514 514
 			
515 515
 			$this->logger->error($e->getMessage());
516 516
 			
@@ -531,10 +531,10 @@  discard block
 block discarded – undo
531 531
 		
532 532
 		$files = $this->storage_filesystem->listContents();
533 533
 		
534
-		if(is_array($files))
535
-			foreach($files as $file)
534
+		if (is_array($files))
535
+			foreach ($files as $file)
536 536
 			{
537
-				if(isset($file['extension']) and in_array($file['extension'], $this->backup_archive_extensions))
537
+				if (isset($file['extension']) and in_array($file['extension'], $this->backup_archive_extensions))
538 538
 				{
539 539
 					$_storage_size += $file['size']; //bytes
540 540
 					$_backup_files_list[] = $file;
@@ -542,15 +542,15 @@  discard block
 block discarded – undo
542 542
 			}
543 543
 		
544 544
 		
545
-		$this->sort_by($_backup_files_list, "timestamp","asc");
545
+		$this->sort_by($_backup_files_list, "timestamp", "asc");
546 546
 		
547 547
 		$_backups_counter = sizeof($_backup_files_list);
548 548
 				
549
-		foreach($_backup_files_list as $file)
549
+		foreach ($_backup_files_list as $file)
550 550
 		{
551 551
 			//processing rule folder capacity
552
-			if($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') &&
553
-			$_storage_size >= ($set_storage_limit = 1024*1024*$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit')))	//bytes	
552
+			if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') &&
553
+			$_storage_size >= ($set_storage_limit = 1024 * 1024 * $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit')))	//bytes	
554 554
 			{
555 555
 				$this->storage_filesystem->delete($file['path']);
556 556
 				$_storage_size -= $file['size'];
@@ -558,14 +558,14 @@  discard block
 block discarded – undo
558 558
 			}
559 559
 			
560 560
 			//processing rule days limit
561
-			if($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days') && $current_timestamp >= $file['timestamp'])
561
+			if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days') && $current_timestamp >= $file['timestamp'])
562 562
 			{
563 563
 				$this->storage_filesystem->delete($file['path']);
564 564
 				$this->logger->info("Deleting backup ".$file['path']." matching rule", array("RETENTION LIMIT TIMESTAMP", $file['timestamp']." =< ".$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days')));
565 565
 			}
566 566
 			
567 567
 			//processing backup countert limit
568
-			if($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_archives') && $_backups_counter >= $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_archives'))
568
+			if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_archives') && $_backups_counter >= $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_archives'))
569 569
 			{
570 570
 				$this->storage_filesystem->delete($file['path']);
571 571
 				$_backups_counter--;
@@ -591,33 +591,33 @@  discard block
 block discarded – undo
591 591
 	
592 592
 	}
593 593
 	
594
-	public function process_backup_name($name = "", $max_length=100)
594
+	public function process_backup_name($name = "", $max_length = 100)
595 595
 	{
596
-		if(!$name)
596
+		if (!$name)
597 597
 			$name = $this->xcloner_settings->get_default_backup_name();
598 598
 		
599
-		foreach($this->backup_name_tags as $tag)
599
+		foreach ($this->backup_name_tags as $tag)
600 600
 		{
601
-			if($tag == '[time]')
602
-				$name = str_replace($tag, date("Y-m-d_H-i"),$name);
603
-			elseif($tag == '[hostname]')
604
-				$name = str_replace($tag, gethostname() ,$name);	
605
-			elseif($tag == '[domain]')
601
+			if ($tag == '[time]')
602
+				$name = str_replace($tag, date("Y-m-d_H-i"), $name);
603
+			elseif ($tag == '[hostname]')
604
+				$name = str_replace($tag, gethostname(), $name);	
605
+			elseif ($tag == '[domain]')
606 606
 			{
607 607
 				$domain = parse_url(admin_url(), PHP_URL_HOST);
608
-				$name = str_replace($tag, $domain ,$name);	
608
+				$name = str_replace($tag, $domain, $name);	
609 609
 			}
610 610
 		}
611 611
 		
612
-		if($max_length)
612
+		if ($max_length)
613 613
 			$name = substr($name, 0, $max_length);
614 614
 			
615 615
 		return $name;	
616 616
 	}
617 617
 	
618
-	public function sort_by( &$array, $field, $direction = 'asc')
618
+	public function sort_by(&$array, $field, $direction = 'asc')
619 619
 	{
620
-		if(strtolower($direction) == "desc" || $direction == SORT_DESC)
620
+		if (strtolower($direction) == "desc" || $direction == SORT_DESC)
621 621
 			$direction = SORT_DESC;
622 622
 		else
623 623
 			$direction = SORT_ASC;
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 	            $tmp = array();
638 638
 	            foreach ($data as $key => $row)
639 639
 	            {
640
-					if(is_array($row))
640
+					if (is_array($row))
641 641
 						$tmp[$key] = $row[$field];
642 642
 					else
643 643
 						$tmp[$key] = $row->$field;
@@ -656,29 +656,29 @@  discard block
 block discarded – undo
656 656
 	{
657 657
 		$this->logger->debug(sprintf(("Checking if %s is excluded"), $file['path']));
658 658
 		
659
-		if($xcloner_exclude_files_larger_than_mb = $this->xcloner_settings->get_xcloner_option('xcloner_exclude_files_larger_than_mb'))
659
+		if ($xcloner_exclude_files_larger_than_mb = $this->xcloner_settings->get_xcloner_option('xcloner_exclude_files_larger_than_mb'))
660 660
 		{
661
-			if(isset($file['size']) and $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb))
661
+			if (isset($file['size']) and $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb))
662 662
 				return "> ".$xcloner_exclude_files_larger_than_mb."MB";
663 663
 		}
664 664
 		
665
-		if(!sizeof($this->excluded_files))
665
+		if (!sizeof($this->excluded_files))
666 666
 			$this->set_excluded_files();
667 667
 				
668
-		if(is_array($this->excluded_files))
669
-		foreach($this->excluded_files as $excluded_file_pattern)
668
+		if (is_array($this->excluded_files))
669
+		foreach ($this->excluded_files as $excluded_file_pattern)
670 670
 		{
671
-			if($excluded_file_pattern == "/")
671
+			if ($excluded_file_pattern == "/")
672 672
 				$needle = "$";
673 673
 			else
674 674
 				$needle = "$".$excluded_file_pattern;
675 675
 				
676
-			if(strstr("$".$file['path'], $needle)){
676
+			if (strstr("$".$file['path'], $needle)) {
677 677
 				return $excluded_file_pattern;
678 678
 			}
679 679
 		}
680 680
 		
681
-		if( $regex = $this->is_excluded_regex($file))
681
+		if ($regex = $this->is_excluded_regex($file))
682 682
 			return $regex;
683 683
 		
684 684
 		return false;
@@ -724,25 +724,25 @@  discard block
 block discarded – undo
724 724
 		
725 725
 		//print_r($regex_patterns);exit;
726 726
 		
727
-		if(is_array($regex_patterns))
727
+		if (is_array($regex_patterns))
728 728
 		{
729 729
 			//$this->excluded_files = array();
730 730
 			//$this->excluded_files[] ="(.*)\.(git)(.*)$";
731 731
 			//$this->excluded_files[] ="wp-content\/backups(.*)$";
732 732
 			
733
-			foreach($regex_patterns as $excluded_file_pattern)
733
+			foreach ($regex_patterns as $excluded_file_pattern)
734 734
 			{
735 735
 				
736
-				if( substr($excluded_file_pattern, strlen($excluded_file_pattern)-1, strlen($excluded_file_pattern)) == "\r")
737
-					$excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern)-1);
736
+				if (substr($excluded_file_pattern, strlen($excluded_file_pattern) - 1, strlen($excluded_file_pattern)) == "\r")
737
+					$excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern) - 1);
738 738
 					
739
-				if($file['path'] == "/")
739
+				if ($file['path'] == "/")
740 740
 					$needle = "/";
741 741
 				else
742 742
 					$needle = "/".$file['path'];
743 743
 				//echo $needle."---".$excluded_file_pattern."---\n";
744 744
 				
745
-				if(@preg_match("/(^|^\/)".$excluded_file_pattern."/i", $needle)){
745
+				if (@preg_match("/(^|^\/)".$excluded_file_pattern."/i", $needle)) {
746 746
 					return $excluded_file_pattern;
747 747
 				}
748 748
 			}
@@ -755,27 +755,27 @@  discard block
 block discarded – undo
755 755
 	{
756 756
 		$this->logger->debug(sprintf("Storing %s in the backup list", $file['path']));
757 757
 		
758
-		if(!isset($file['size']))
758
+		if (!isset($file['size']))
759 759
 			$file['size'] = 0;
760
-		if(!isset($file['visibility']))	
760
+		if (!isset($file['visibility']))	
761 761
 			$file['visibility'] = "private";
762 762
 		
763 763
 		$line = '"'.addslashes($file['path']).'","'.$file['timestamp'].'","'.$file['size'].'","'.$file['visibility'].'","'.$storage.'"'.PHP_EOL;
764 764
 		
765 765
 		$this->last_logged_file = $file['path'];
766 766
 		
767
-		try{
767
+		try {
768 768
 			$this->tmp_filesystem_append->write($this->get_included_files_handler(), $line);
769 769
 		
770
-		}catch(Exception $e){
770
+		}catch (Exception $e) {
771 771
 		
772 772
 			$this->logger->error($e->getMessage());	
773 773
 		}
774 774
 		
775
-		if($file['type'] == "dir"){
776
-			try{
775
+		if ($file['type'] == "dir") {
776
+			try {
777 777
 				$this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file['path']."\n");
778
-			}catch(Exception $e){
778
+			}catch (Exception $e) {
779 779
 				$this->logger->error($e->getMessage());	
780 780
 			}
781 781
 		}
@@ -788,13 +788,13 @@  discard block
 block discarded – undo
788 788
 	
789 789
 	public function get_filesystem($system = "")
790 790
 	{
791
-		if($system == "storage_filesystem_append")
791
+		if ($system == "storage_filesystem_append")
792 792
 			return $this->storage_filesystem_append;
793
-		elseif($system == "tmp_filesystem_append")
793
+		elseif ($system == "tmp_filesystem_append")
794 794
 			return $this->tmp_filesystem_append;
795
-		elseif($system == "tmp_filesystem")
795
+		elseif ($system == "tmp_filesystem")
796 796
 			return $this->tmp_filesystem;
797
-		elseif($system == "storage_filesystem")
797
+		elseif ($system == "storage_filesystem")
798 798
 			return $this->storage_filesystem;
799 799
 		else
800 800
 			return $this->start_filesystem;	
@@ -802,9 +802,9 @@  discard block
 block discarded – undo
802 802
 	
803 803
 	public function get_adapter($system)
804 804
 	{
805
-		if($system == "tmp_filesystem")
805
+		if ($system == "tmp_filesystem")
806 806
 			return $this->tmp_adapter;
807
-		elseif($system == "storage_filesystem")
807
+		elseif ($system == "storage_filesystem")
808 808
 			return $this->storage_adapter;
809 809
 		else
810 810
 			return $this->start_adapter;	
@@ -812,10 +812,10 @@  discard block
 block discarded – undo
812 812
 	
813 813
 	private function scan_finished()
814 814
 	{
815
-		if($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler()))
815
+		if ($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler()))
816 816
 			return false;
817 817
 		
818
-		if($this->tmp_filesystem->has($this->get_temp_dir_handler()))
818
+		if ($this->tmp_filesystem->has($this->get_temp_dir_handler()))
819 819
 			$this->tmp_filesystem->delete($this->get_temp_dir_handler());
820 820
 		
821 821
 		$this->logger->debug(sprintf(("File scan finished")));
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 	
826 826
 	private function calc_to_bytes($mb_size)
827 827
 	{
828
-		return $mb_size*(1024*1024);
828
+		return $mb_size * (1024 * 1024);
829 829
 	}
830 830
 	
831 831
 }
Please login to merge, or discard this patch.
Braces   +164 added lines, -121 removed lines patch added patch discarded remove patch
@@ -60,13 +60,14 @@  discard block
 block discarded – undo
60 60
 			$this->storage_filesystem_append = new Filesystem($this->storage_adapter, new Config([
61 61
 					'disable_asserts' => true,
62 62
 				]));
63
-		}catch(Exception $e){
63
+		} catch(Exception $e){
64 64
 			return false;
65 65
 		}
66 66
 		
67 67
 		
68
-		if($value = get_option('xcloner_directories_to_scan_per_request'))
69
-			$this->folders_to_process_per_session = $value;
68
+		if($value = get_option('xcloner_directories_to_scan_per_request')) {
69
+					$this->folders_to_process_per_session = $value;
70
+		}
70 71
 
71 72
 	}
72 73
 	
@@ -129,8 +130,9 @@  discard block
 block discarded – undo
129 130
 	public function get_included_files_handler($metadata  = 0)
130 131
 	{
131 132
 		$path = $this->included_files_handler;
132
-		if(!$metadata)
133
-			return $path;
133
+		if(!$metadata) {
134
+					return $path;
135
+		}
134 136
 		
135 137
 		$spl_info = $this->getMetadataFull('tmp_adapter', $path);
136 138
 		return $spl_info;
@@ -146,31 +148,36 @@  discard block
 block discarded – undo
146 148
 	{
147 149
 		$files = $this->get_backup_archives_list();
148 150
 		
149
-		if(is_array($files))
150
-			$this->sort_by($files, "timestamp","desc");
151
+		if(is_array($files)) {
152
+					$this->sort_by($files, "timestamp","desc");
153
+		}
151 154
 		
152 155
 		$new_list = array();
153 156
 		
154
-		foreach($files as $key=>$file)
155
-			if(!isset($file['parent']))
157
+		foreach($files as $key=>$file) {
158
+					if(!isset($file['parent']))
156 159
 				$new_list[] = ($files[$key]);
160
+		}
157 161
 
158
-		if(isset($new_list[0]))
159
-			return $new_list[0];
162
+		if(isset($new_list[0])) {
163
+					return $new_list[0];
164
+		}
160 165
 	}
161 166
 	
162 167
 	public function get_latest_backups()
163 168
 	{
164 169
 		$files = $this->get_backup_archives_list();
165 170
 
166
-		if(is_array($files))
167
-			$this->sort_by($files, "timestamp","desc");
171
+		if(is_array($files)) {
172
+					$this->sort_by($files, "timestamp","desc");
173
+		}
168 174
 		
169 175
 		$new_list = array();
170 176
 		
171
-		foreach($files as $key=>$file)
172
-			if(!isset($file['parent']))
177
+		foreach($files as $key=>$file) {
178
+					if(!isset($file['parent']))
173 179
 				$new_list[] = ($files[$key]);
180
+		}
174 181
 
175 182
 		return $new_list;
176 183
 	}
@@ -180,25 +187,28 @@  discard block
 block discarded – undo
180 187
 		$files = $this->get_backup_archives_list();
181 188
 		$total = 0;
182 189
 		
183
-		if(is_array($files))
184
-			foreach($files as $file)
190
+		if(is_array($files)) {
191
+					foreach($files as $file)
185 192
 				$total += $file['size'];
193
+		}
186 194
 				
187 195
 		return $total;		
188 196
 	}
189 197
 	
190 198
 	public function is_part($backup_name)
191 199
 	{
192
-		if(stristr($backup_name, "-part"))
193
-			return true;
200
+		if(stristr($backup_name, "-part")) {
201
+					return true;
202
+		}
194 203
 		
195 204
 		return false;	
196 205
 	}
197 206
 	
198 207
 	public function is_multipart($backup_name)
199 208
 	{
200
-		if(stristr($backup_name, "-multipart"))
201
-			return true;
209
+		if(stristr($backup_name, "-multipart")) {
210
+					return true;
211
+		}
202 212
 		
203 213
 		return false;	
204 214
 	}
@@ -209,8 +219,9 @@  discard block
 block discarded – undo
209 219
 		if($this->is_multipart($backup_name))
210 220
 		{
211 221
 			$backup_parts = $this->get_multipart_files($backup_name);
212
-			foreach($backup_parts as $part_file)
213
-				$backup_size += $this->get_storage_filesystem()->getSize($part_file);
222
+			foreach($backup_parts as $part_file) {
223
+							$backup_size += $this->get_storage_filesystem()->getSize($part_file);
224
+			}
214 225
 		}
215 226
 		
216 227
 		return $backup_size;
@@ -251,10 +262,11 @@  discard block
 block discarded – undo
251 262
 			}
252 263
 		}
253 264
 		
254
-		if($this->get_storage_filesystem()->delete($backup_name))
255
-			$return = true;
256
-		else
257
-			$return = false;
265
+		if($this->get_storage_filesystem()->delete($backup_name)) {
266
+					$return = true;
267
+		} else {
268
+					$return = false;
269
+		}
258 270
 			
259 271
 		return $return;	
260 272
 	}
@@ -272,8 +284,9 @@  discard block
 block discarded – undo
272 284
 	{
273 285
 		$list = array();
274 286
 		
275
-		if(method_exists($this->get_storage_filesystem(), "listContents"))
276
-			$list = $this->get_storage_filesystem()->listContents();
287
+		if(method_exists($this->get_storage_filesystem(), "listContents")) {
288
+					$list = $this->get_storage_filesystem()->listContents();
289
+		}
277 290
 
278 291
 		
279 292
 		$backup_files = array();
@@ -286,10 +299,11 @@  discard block
 block discarded – undo
286 299
 			if(isset($file_info['extension']) and $file_info['extension'] == "csv")
287 300
 			{
288 301
 				$lines = explode(PHP_EOL, $this->get_storage_filesystem()->read($file_info['path']));
289
-				foreach($lines as $line)
290
-					if($line)
302
+				foreach($lines as $line) {
303
+									if($line)
291 304
 					{
292 305
 						$data = str_getcsv($line);
306
+				}
293 307
 						if(is_array($data)){
294 308
 							$parents[$data[0]] = $file_info['path'];
295 309
 							$file_info['childs'][] = $data;
@@ -299,14 +313,16 @@  discard block
 block discarded – undo
299 313
 						
300 314
 			}
301 315
 			
302
-			if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions))
303
-				$backup_files[$file_info['path']] = $file_info;
316
+			if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) {
317
+							$backup_files[$file_info['path']] = $file_info;
318
+			}
304 319
 		}
305 320
 		
306 321
 		foreach($backup_files as $key=>$file_info)
307 322
 		{
308
-			if(isset($parents[$file_info['path']]))
309
-				$backup_files[$key]['parent'] = $parents[$file_info['path']];
323
+			if(isset($parents[$file_info['path']])) {
324
+							$backup_files[$key]['parent'] = $parents[$file_info['path']];
325
+			}
310 326
 		}
311 327
 		
312 328
 		return $backup_files;
@@ -332,11 +348,11 @@  discard block
 block discarded – undo
332 348
 				if($counter < $this->folders_to_process_per_session){
333 349
 					$this->build_files_list($file);
334 350
 					$counter++;
335
-				}else{
351
+				} else{
336 352
 					$this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file."\n");
337 353
 				}
338 354
 			}
339
-		}else{
355
+		} else{
340 356
 			$this->build_files_list();
341 357
 		}
342 358
 		
@@ -378,8 +394,9 @@  discard block
 block discarded – undo
378 394
 	{
379 395
 		$return = array();
380 396
 		$return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->get_included_files_handler();
381
-		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log'))
382
-			$return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->xcloner_settings->get_logger_filename(1);
397
+		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) {
398
+					$return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->xcloner_settings->get_logger_filename(1);
399
+		}
383 400
 		
384 401
 		return $return;
385 402
 	}
@@ -391,9 +408,10 @@  discard block
 block discarded – undo
391 408
 		
392 409
 		$contents = $this->get_tmp_filesystem()->listContents();
393 410
 	
394
-		if(is_array($contents))
395
-		foreach($contents as $file_info)
411
+		if(is_array($contents)) {
412
+				foreach($contents as $file_info)
396 413
 			$this->get_tmp_filesystem()->delete($file_info['path']);
414
+		}
397 415
 			
398 416
 		@rmdir($this->xcloner_settings->get_xcloner_tmp_path());
399 417
 		
@@ -404,17 +422,21 @@  discard block
 block discarded – undo
404 422
 	{
405 423
 		$this->files_counter = 0;
406 424
 		
407
-		if(!$this->storage_filesystem->has("index.html"))	
408
-			$this->storage_filesystem->write("index.html","");
425
+		if(!$this->storage_filesystem->has("index.html")) {
426
+					$this->storage_filesystem->write("index.html","");
427
+		}
409 428
 		
410
-		if(!$this->tmp_filesystem->has("index.html"))	
411
-			$this->tmp_filesystem->write("index.html","");
429
+		if(!$this->tmp_filesystem->has("index.html")) {
430
+					$this->tmp_filesystem->write("index.html","");
431
+		}
412 432
 			
413
-		if($this->tmp_filesystem->has($this->get_included_files_handler()))
414
-			$this->tmp_filesystem->delete($this->get_included_files_handler());
433
+		if($this->tmp_filesystem->has($this->get_included_files_handler())) {
434
+					$this->tmp_filesystem->delete($this->get_included_files_handler());
435
+		}
415 436
 		
416
-		if($this->tmp_filesystem->has($this->get_temp_dir_handler()))	
417
-			$this->tmp_filesystem->delete($this->get_temp_dir_handler());
437
+		if($this->tmp_filesystem->has($this->get_temp_dir_handler())) {
438
+					$this->tmp_filesystem->delete($this->get_temp_dir_handler());
439
+		}
418 440
 	}
419 441
 	
420 442
 	public function get_scanned_files_num()
@@ -434,8 +456,9 @@  discard block
 block discarded – undo
434 456
 	
435 457
 	public function set_excluded_files($excluded_files = array())
436 458
 	{
437
-		if(!is_array($excluded_files))
438
-			$excluded_files = array();
459
+		if(!is_array($excluded_files)) {
460
+					$excluded_files = array();
461
+		}
439 462
 			
440 463
 		$this->excluded_files = array_merge($excluded_files, $this->excluded_files_by_default);
441 464
 		
@@ -469,21 +492,21 @@  discard block
 block discarded – undo
469 492
 				if(!is_readable($this->xcloner_settings->get_xcloner_start_path().DS.$file['path']))
470 493
 				{
471 494
 					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, file not readable"), $file['path']), array("FILESYSTEM SCAN","NOT READABLE"));
472
-				}
473
-				elseif(!$matching_pattern = $this->is_excluded($file) ){
495
+				} elseif(!$matching_pattern = $this->is_excluded($file) ){
474 496
 					$this->logger->info(sprintf(__("Adding %s to the filesystem list"), $file['path']), array("FILESYSTEM SCAN","INCLUDE"));
475 497
 					$file['visibility'] = $this->start_filesystem->getVisibility($file['path']);
476 498
 					$this->store_file($file);
477 499
 					$this->files_counter++;
478
-					if(isset($file['size']))
479
-						$this->files_size += $file['size'];
500
+					if(isset($file['size'])) {
501
+											$this->files_size += $file['size'];
502
+					}
480 503
 					
481
-				}else{
504
+				} else{
482 505
 					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, matching pattern %s"), $file['path'], $matching_pattern), array("FILESYSTEM SCAN","EXCLUDE"));
483 506
 					}
484 507
 			}
485 508
 			
486
-		}catch(Exception $e){
509
+		} catch(Exception $e){
487 510
 			
488 511
 			$this->logger->error($e->getMessage());
489 512
 		
@@ -510,7 +533,7 @@  discard block
 block discarded – undo
510 533
 		
511 534
 			$this->tmp_filesystem->delete($tmp_file);
512 535
 		
513
-		}catch(Exception $e){
536
+		} catch(Exception $e){
514 537
 			
515 538
 			$this->logger->error($e->getMessage());
516 539
 			
@@ -531,12 +554,14 @@  discard block
 block discarded – undo
531 554
 		
532 555
 		$files = $this->storage_filesystem->listContents();
533 556
 		
534
-		if(is_array($files))
535
-			foreach($files as $file)
557
+		if(is_array($files)) {
558
+					foreach($files as $file)
536 559
 			{
537 560
 				if(isset($file['extension']) and in_array($file['extension'], $this->backup_archive_extensions))
538 561
 				{
539
-					$_storage_size += $file['size']; //bytes
562
+					$_storage_size += $file['size'];
563
+		}
564
+		//bytes
540 565
 					$_backup_files_list[] = $file;
541 566
 				}
542 567
 			}
@@ -550,9 +575,11 @@  discard block
 block discarded – undo
550 575
 		{
551 576
 			//processing rule folder capacity
552 577
 			if($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') &&
553
-			$_storage_size >= ($set_storage_limit = 1024*1024*$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit')))	//bytes	
578
+			$_storage_size >= ($set_storage_limit = 1024*1024*$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit'))) {
579
+				//bytes	
554 580
 			{
555 581
 				$this->storage_filesystem->delete($file['path']);
582
+			}
556 583
 				$_storage_size -= $file['size'];
557 584
 				$this->logger->info("Deleting backup ".$file['path']." matching rule", array("STORAGE SIZE LIMIT", $_storage_size." >= ".$set_storage_limit));
558 585
 			}
@@ -593,34 +620,37 @@  discard block
 block discarded – undo
593 620
 	
594 621
 	public function process_backup_name($name = "", $max_length=100)
595 622
 	{
596
-		if(!$name)
597
-			$name = $this->xcloner_settings->get_default_backup_name();
623
+		if(!$name) {
624
+					$name = $this->xcloner_settings->get_default_backup_name();
625
+		}
598 626
 		
599 627
 		foreach($this->backup_name_tags as $tag)
600 628
 		{
601
-			if($tag == '[time]')
602
-				$name = str_replace($tag, date("Y-m-d_H-i"),$name);
603
-			elseif($tag == '[hostname]')
604
-				$name = str_replace($tag, gethostname() ,$name);	
605
-			elseif($tag == '[domain]')
629
+			if($tag == '[time]') {
630
+							$name = str_replace($tag, date("Y-m-d_H-i"),$name);
631
+			} elseif($tag == '[hostname]') {
632
+							$name = str_replace($tag, gethostname() ,$name);
633
+			} elseif($tag == '[domain]')
606 634
 			{
607 635
 				$domain = parse_url(admin_url(), PHP_URL_HOST);
608 636
 				$name = str_replace($tag, $domain ,$name);	
609 637
 			}
610 638
 		}
611 639
 		
612
-		if($max_length)
613
-			$name = substr($name, 0, $max_length);
640
+		if($max_length) {
641
+					$name = substr($name, 0, $max_length);
642
+		}
614 643
 			
615 644
 		return $name;	
616 645
 	}
617 646
 	
618 647
 	public function sort_by( &$array, $field, $direction = 'asc')
619 648
 	{
620
-		if(strtolower($direction) == "desc" || $direction == SORT_DESC)
621
-			$direction = SORT_DESC;
622
-		else
623
-			$direction = SORT_ASC;
649
+		if(strtolower($direction) == "desc" || $direction == SORT_DESC) {
650
+					$direction = SORT_DESC;
651
+		} else {
652
+					$direction = SORT_ASC;
653
+		}
624 654
 					
625 655
 	   $array = $this->array_orderby($array, $field, $direction);
626 656
 	    
@@ -637,10 +667,11 @@  discard block
 block discarded – undo
637 667
 	            $tmp = array();
638 668
 	            foreach ($data as $key => $row)
639 669
 	            {
640
-					if(is_array($row))
641
-						$tmp[$key] = $row[$field];
642
-					else
643
-						$tmp[$key] = $row->$field;
670
+					if(is_array($row)) {
671
+											$tmp[$key] = $row[$field];
672
+					} else {
673
+											$tmp[$key] = $row->$field;
674
+					}
644 675
 				}
645 676
 	            $args[$n] = $tmp;
646 677
 	            }
@@ -658,28 +689,32 @@  discard block
 block discarded – undo
658 689
 		
659 690
 		if($xcloner_exclude_files_larger_than_mb = $this->xcloner_settings->get_xcloner_option('xcloner_exclude_files_larger_than_mb'))
660 691
 		{
661
-			if(isset($file['size']) and $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb))
662
-				return "> ".$xcloner_exclude_files_larger_than_mb."MB";
692
+			if(isset($file['size']) and $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb)) {
693
+							return "> ".$xcloner_exclude_files_larger_than_mb."MB";
694
+			}
663 695
 		}
664 696
 		
665
-		if(!sizeof($this->excluded_files))
666
-			$this->set_excluded_files();
697
+		if(!sizeof($this->excluded_files)) {
698
+					$this->set_excluded_files();
699
+		}
667 700
 				
668
-		if(is_array($this->excluded_files))
669
-		foreach($this->excluded_files as $excluded_file_pattern)
701
+		if(is_array($this->excluded_files)) {
702
+				foreach($this->excluded_files as $excluded_file_pattern)
670 703
 		{
671 704
 			if($excluded_file_pattern == "/")
672 705
 				$needle = "$";
673
-			else
674
-				$needle = "$".$excluded_file_pattern;
706
+		} else {
707
+							$needle = "$".$excluded_file_pattern;
708
+			}
675 709
 				
676 710
 			if(strstr("$".$file['path'], $needle)){
677 711
 				return $excluded_file_pattern;
678 712
 			}
679 713
 		}
680 714
 		
681
-		if( $regex = $this->is_excluded_regex($file))
682
-			return $regex;
715
+		if( $regex = $this->is_excluded_regex($file)) {
716
+					return $regex;
717
+		}
683 718
 		
684 719
 		return false;
685 720
 	}
@@ -733,13 +768,15 @@  discard block
 block discarded – undo
733 768
 			foreach($regex_patterns as $excluded_file_pattern)
734 769
 			{
735 770
 				
736
-				if( substr($excluded_file_pattern, strlen($excluded_file_pattern)-1, strlen($excluded_file_pattern)) == "\r")
737
-					$excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern)-1);
771
+				if( substr($excluded_file_pattern, strlen($excluded_file_pattern)-1, strlen($excluded_file_pattern)) == "\r") {
772
+									$excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern)-1);
773
+				}
738 774
 					
739
-				if($file['path'] == "/")
740
-					$needle = "/";
741
-				else
742
-					$needle = "/".$file['path'];
775
+				if($file['path'] == "/") {
776
+									$needle = "/";
777
+				} else {
778
+									$needle = "/".$file['path'];
779
+				}
743 780
 				//echo $needle."---".$excluded_file_pattern."---\n";
744 781
 				
745 782
 				if(@preg_match("/(^|^\/)".$excluded_file_pattern."/i", $needle)){
@@ -755,10 +792,12 @@  discard block
 block discarded – undo
755 792
 	{
756 793
 		$this->logger->debug(sprintf("Storing %s in the backup list", $file['path']));
757 794
 		
758
-		if(!isset($file['size']))
759
-			$file['size'] = 0;
760
-		if(!isset($file['visibility']))	
761
-			$file['visibility'] = "private";
795
+		if(!isset($file['size'])) {
796
+					$file['size'] = 0;
797
+		}
798
+		if(!isset($file['visibility'])) {
799
+					$file['visibility'] = "private";
800
+		}
762 801
 		
763 802
 		$line = '"'.addslashes($file['path']).'","'.$file['timestamp'].'","'.$file['size'].'","'.$file['visibility'].'","'.$storage.'"'.PHP_EOL;
764 803
 		
@@ -767,7 +806,7 @@  discard block
 block discarded – undo
767 806
 		try{
768 807
 			$this->tmp_filesystem_append->write($this->get_included_files_handler(), $line);
769 808
 		
770
-		}catch(Exception $e){
809
+		} catch(Exception $e){
771 810
 		
772 811
 			$this->logger->error($e->getMessage());	
773 812
 		}
@@ -775,7 +814,7 @@  discard block
 block discarded – undo
775 814
 		if($file['type'] == "dir"){
776 815
 			try{
777 816
 				$this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file['path']."\n");
778
-			}catch(Exception $e){
817
+			} catch(Exception $e){
779 818
 				$this->logger->error($e->getMessage());	
780 819
 			}
781 820
 		}
@@ -788,35 +827,39 @@  discard block
 block discarded – undo
788 827
 	
789 828
 	public function get_filesystem($system = "")
790 829
 	{
791
-		if($system == "storage_filesystem_append")
792
-			return $this->storage_filesystem_append;
793
-		elseif($system == "tmp_filesystem_append")
794
-			return $this->tmp_filesystem_append;
795
-		elseif($system == "tmp_filesystem")
796
-			return $this->tmp_filesystem;
797
-		elseif($system == "storage_filesystem")
798
-			return $this->storage_filesystem;
799
-		else
800
-			return $this->start_filesystem;	
830
+		if($system == "storage_filesystem_append") {
831
+					return $this->storage_filesystem_append;
832
+		} elseif($system == "tmp_filesystem_append") {
833
+					return $this->tmp_filesystem_append;
834
+		} elseif($system == "tmp_filesystem") {
835
+					return $this->tmp_filesystem;
836
+		} elseif($system == "storage_filesystem") {
837
+					return $this->storage_filesystem;
838
+		} else {
839
+					return $this->start_filesystem;
840
+		}
801 841
 	}
802 842
 	
803 843
 	public function get_adapter($system)
804 844
 	{
805
-		if($system == "tmp_filesystem")
806
-			return $this->tmp_adapter;
807
-		elseif($system == "storage_filesystem")
808
-			return $this->storage_adapter;
809
-		else
810
-			return $this->start_adapter;	
845
+		if($system == "tmp_filesystem") {
846
+					return $this->tmp_adapter;
847
+		} elseif($system == "storage_filesystem") {
848
+					return $this->storage_adapter;
849
+		} else {
850
+					return $this->start_adapter;
851
+		}
811 852
 	}
812 853
 	
813 854
 	private function scan_finished()
814 855
 	{
815
-		if($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler()))
816
-			return false;
856
+		if($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler())) {
857
+					return false;
858
+		}
817 859
 		
818
-		if($this->tmp_filesystem->has($this->get_temp_dir_handler()))
819
-			$this->tmp_filesystem->delete($this->get_temp_dir_handler());
860
+		if($this->tmp_filesystem->has($this->get_temp_dir_handler())) {
861
+					$this->tmp_filesystem->delete($this->get_temp_dir_handler());
862
+		}
820 863
 		
821 864
 		$this->logger->debug(sprintf(("File scan finished")));
822 865
 			
Please login to merge, or discard this patch.
includes/class-xcloner-file-transfer.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -87,6 +87,9 @@
 block discarded – undo
87 87
 		return ftell($fp);
88 88
 	}
89 89
 	
90
+	/**
91
+	 * @param string $filename
92
+	 */
90 93
 	function curl_file_create($filename, $mimetype = '', $postname = '') {
91 94
 		if (!function_exists('curl_file_create')) {
92 95
 	        
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
 		
55 55
 		curl_setopt($ch, CURLOPT_POST, 1);
56 56
 		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
57
-        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
58
-        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
59
-        curl_setopt($ch, CURLOPT_TIMEOUT, 1200);
60
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
57
+		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
58
+		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
59
+		curl_setopt($ch, CURLOPT_TIMEOUT, 1200);
60
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
61 61
         
62 62
 		curl_setopt($ch, CURLOPT_POSTFIELDS, $send_array );
63 63
 		curl_setopt($ch, CURLOPT_VERBOSE, true);
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 	function curl_file_create($filename, $mimetype = '', $postname = '') {
91 91
 		if (!function_exists('curl_file_create')) {
92 92
 	        
93
-	        return "@$filename;filename="
94
-	            . ($postname ?: basename($filename))
95
-	            . ($mimetype ? ";type=$mimetype" : '');
93
+			return "@$filename;filename="
94
+				. ($postname ?: basename($filename))
95
+				. ($mimetype ? ";type=$mimetype" : '');
96 96
 		
97 97
 		}else{
98 98
 			
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class Xcloner_File_Transfer extends Xcloner_File_System{
3
+class Xcloner_File_Transfer extends Xcloner_File_System {
4 4
 	
5 5
 	private $target_url;
6 6
 	private $transfer_limit = 1048576; //bytes 1MB= 1048576 300KB = 358400
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 	
9 9
 	public function set_target($target_url)
10 10
 	{
11
-		return $this->target_url= $target_url;
11
+		return $this->target_url = $target_url;
12 12
 	}
13 13
 	
14 14
 	public function get_target()
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	
20 20
 	public function transfer_file($file, $start = 0, $hash = "")
21 21
 	{
22
-		if(!$this->target_url)
22
+		if (!$this->target_url)
23 23
 			throw new Exception("Please setup a target url for upload");
24 24
 
25 25
 		
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 		
28 28
 		fseek($fp, $start, SEEK_SET);
29 29
 		
30
-		$binary_data =  fread($fp, $this->transfer_limit);
30
+		$binary_data = fread($fp, $this->transfer_limit);
31 31
 		
32 32
 		$tmp_filename = "xcloner_upload_".substr(md5(time()), 0, 5);
33 33
 		$tmp_file = $this->get_tmp_filesystem()->write($tmp_filename, $binary_data);
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 		$send_array = array();
38 38
 		
39 39
 		$send_array['file'] 	= $file;
40
-		$send_array['start'] 	= $start;
41
-		$send_array['action'] 	= "write_file";
40
+		$send_array['start'] = $start;
41
+		$send_array['action'] = "write_file";
42 42
 		$send_array['hash'] 	= $hash;
43 43
 		#$send_array['blob'] 	= $binary_data;
44
-		$send_array['blob'] 	= $this->curl_file_create($tmp_file_path,'application/x-binary',$tmp_filename);
44
+		$send_array['blob'] 	= $this->curl_file_create($tmp_file_path, 'application/x-binary', $tmp_filename);
45 45
 		//var_dump($send_array);exit;
46 46
 		
47 47
 		$data = http_build_query($send_array);
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		
51 51
 		
52 52
 		$ch = curl_init();
53
-		curl_setopt($ch, CURLOPT_URL,$this->target_url);
53
+		curl_setopt($ch, CURLOPT_URL, $this->target_url);
54 54
 		
55 55
 		curl_setopt($ch, CURLOPT_POST, 1);
56 56
 		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
@@ -59,25 +59,25 @@  discard block
 block discarded – undo
59 59
         curl_setopt($ch, CURLOPT_TIMEOUT, 1200);
60 60
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
61 61
         
62
-		curl_setopt($ch, CURLOPT_POSTFIELDS, $send_array );
62
+		curl_setopt($ch, CURLOPT_POSTFIELDS, $send_array);
63 63
 		curl_setopt($ch, CURLOPT_VERBOSE, true);
64 64
 		
65
-		$original_result = curl_exec ($ch);
65
+		$original_result = curl_exec($ch);
66 66
 		
67 67
 		$this->get_tmp_filesystem()->delete($tmp_filename);
68 68
 		
69 69
 		$result = json_decode($original_result);
70 70
 				
71
-		if(!$result)
72
-			throw new Exception("We have received no valid response from the remote host, original message: ". $original_result);
71
+		if (!$result)
72
+			throw new Exception("We have received no valid response from the remote host, original message: ".$original_result);
73 73
 			
74
-		if($result->status != 200)
74
+		if ($result->status != 200)
75 75
 		{
76 76
 			throw new Exception($result->response);
77 77
 			return false;
78 78
 		}
79 79
 		
80
-		if(ftell($fp) >= $this->get_storage_filesystem()->getSize($file))
80
+		if (ftell($fp) >= $this->get_storage_filesystem()->getSize($file))
81 81
 		{
82 82
 			$this->get_logger()->info(sprintf("Upload done for file %s to target url %s, transferred a total of %s bytes", $file, $this->target_url, ftell($fp)));
83 83
 			$this->remove_tmp_filesystem();
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	            . ($postname ?: basename($filename))
95 95
 	            . ($mimetype ? ";type=$mimetype" : '');
96 96
 		
97
-		}else{
97
+		} else {
98 98
 			
99 99
 			return curl_file_create($filename, $mimetype, $postname);	
100 100
 				
Please login to merge, or discard this 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.
includes/class-xcloner-remote-storage.php 5 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -142,6 +142,9 @@
 block discarded – undo
142 142
 		
143 143
 	}
144 144
 	
145
+	/**
146
+	 * @param string $storage_type
147
+	 */
145 148
 	public function verify_filesystem($storage_type)
146 149
 	{
147 150
 		$method = "get_".$storage_type."_filesystem";
Please login to merge, or discard this patch.
Unused Use Statements   -6 removed lines patch added patch discarded remove patch
@@ -1,20 +1,14 @@
 block discarded – undo
1 1
 <?php
2 2
 use League\Flysystem\Config;
3 3
 use League\Flysystem\Filesystem;
4
-
5 4
 use League\Flysystem\Adapter\Ftp as Adapter;
6
-
7 5
 use League\Flysystem\Sftp\SftpAdapter;
8
-
9 6
 use League\Flysystem\Dropbox\DropboxAdapter;
10 7
 use Dropbox\Client;
11
-
12 8
 use MicrosoftAzure\Storage\Common\ServicesBuilder;
13 9
 use League\Flysystem\Azure\AzureAdapter;
14
-
15 10
 use Aws\S3\S3Client;
16 11
 use League\Flysystem\AwsS3v3\AwsS3Adapter;
17
-
18 12
 use Mhetreramesh\Flysystem\BackblazeAdapter;
19 13
 use ChrisWhite\B2\Client as B2Client;
20 14
 
Please login to merge, or discard this patch.
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
 		$this->logger->info(sprintf("Creating the AZURE BLOB remote storage connection"), array(""));
255 255
 		
256 256
 		$endpoint = sprintf(
257
-		    'DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s',
258
-		    get_option("xcloner_azure_account_name"),
259
-		    get_option("xcloner_azure_api_key")
257
+			'DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s',
258
+			get_option("xcloner_azure_account_name"),
259
+			get_option("xcloner_azure_api_key")
260 260
 		);
261 261
 		
262 262
 		$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($endpoint);
@@ -293,12 +293,12 @@  discard block
 block discarded – undo
293 293
 		
294 294
 		
295 295
 		$client = new S3Client([
296
-		    'credentials' => [
297
-		        'key'    => get_option("xcloner_aws_key"),
298
-		        'secret' => get_option("xcloner_aws_secret")
299
-		    ],
300
-		    'region' => get_option("xcloner_aws_region"),
301
-		    'version' => 'latest',
296
+			'credentials' => [
297
+				'key'    => get_option("xcloner_aws_key"),
298
+				'secret' => get_option("xcloner_aws_secret")
299
+			],
300
+			'region' => get_option("xcloner_aws_region"),
301
+			'version' => 'latest',
302 302
 		]);
303 303
 		
304 304
 		$adapter = new AwsS3Adapter($client, get_option("xcloner_aws_bucket_name"));
@@ -332,16 +332,16 @@  discard block
 block discarded – undo
332 332
 		$this->logger->info(sprintf("Creating the FTP remote storage connection"), array(""));
333 333
 		
334 334
 		$adapter = new Adapter([
335
-		    'host' => get_option("xcloner_ftp_hostname"),
336
-		    'username' => get_option("xcloner_ftp_username"),
337
-		    'password' => get_option("xcloner_ftp_password"),
338
-		
339
-		    /** optional config settings */
340
-		    'port' => get_option("xcloner_ftp_port", 21),
341
-		    'root' => get_option("xcloner_ftp_path"),
342
-		    'passive' => get_option("xcloner_ftp_transfer_mode"),
343
-		    'ssl' => get_option("xcloner_ftp_ssl_mode"),
344
-		    'timeout' => get_option("xcloner_ftp_timeout", 30),
335
+			'host' => get_option("xcloner_ftp_hostname"),
336
+			'username' => get_option("xcloner_ftp_username"),
337
+			'password' => get_option("xcloner_ftp_password"),
338
+		
339
+			/** optional config settings */
340
+			'port' => get_option("xcloner_ftp_port", 21),
341
+			'root' => get_option("xcloner_ftp_path"),
342
+			'passive' => get_option("xcloner_ftp_transfer_mode"),
343
+			'ssl' => get_option("xcloner_ftp_ssl_mode"),
344
+			'timeout' => get_option("xcloner_ftp_timeout", 30),
345 345
 		]);
346 346
 		
347 347
 		$adapter->connect();
@@ -358,15 +358,15 @@  discard block
 block discarded – undo
358 358
 		$this->logger->info(sprintf("Creating the SFTP remote storage connection"), array(""));
359 359
 		
360 360
 		$adapter = new SftpAdapter([
361
-		    'host' => get_option("xcloner_sftp_hostname"),
362
-		    'username' => get_option("xcloner_sftp_username"),
363
-		    'password' => get_option("xcloner_sftp_password"),
364
-		
365
-		    /** optional config settings */
366
-		    'port' => get_option("xcloner_sftp_port", 22),
367
-		    'root' => get_option("xcloner_sftp_path"),
368
-		    'privateKey' => get_option("xcloner_sftp_private_key"),
369
-		    'timeout' => get_option("xcloner_ftp_timeout", 30),
361
+			'host' => get_option("xcloner_sftp_hostname"),
362
+			'username' => get_option("xcloner_sftp_username"),
363
+			'password' => get_option("xcloner_sftp_password"),
364
+		
365
+			/** optional config settings */
366
+			'port' => get_option("xcloner_sftp_port", 22),
367
+			'root' => get_option("xcloner_sftp_path"),
368
+			'privateKey' => get_option("xcloner_sftp_private_key"),
369
+			'timeout' => get_option("xcloner_ftp_timeout", 30),
370 370
 		]);
371 371
 		
372 372
 		$adapter->connect();
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 use Mhetreramesh\Flysystem\BackblazeAdapter;
19 19
 use ChrisWhite\B2\Client as B2Client;
20 20
 
21
-class Xcloner_Remote_Storage{
21
+class Xcloner_Remote_Storage {
22 22
 	
23 23
 	private $storage_fields = array(
24 24
 					"option_prefix" => "xcloner_",
@@ -87,17 +87,17 @@  discard block
 block discarded – undo
87 87
 	{
88 88
 		$this->xcloner_sanitization 	= new Xcloner_Sanitization($hash);
89 89
 		$this->xcloner_file_system 		= new Xcloner_File_System($hash);
90
-		$this->logger 					= new XCloner_Logger("xcloner_remote_storage", $hash);
90
+		$this->logger = new XCloner_Logger("xcloner_remote_storage", $hash);
91 91
 		$this->xcloner = new Xcloner();
92 92
 	}
93 93
 	
94 94
 	public function get_available_storages()
95 95
 	{
96 96
 		$return = array();
97
-		foreach($this->storage_fields as $storage=>$data)
97
+		foreach ($this->storage_fields as $storage=>$data)
98 98
 		{
99 99
 			$check_field = $this->storage_fields["option_prefix"].$storage."_enable";
100
-			if(get_option($check_field))
100
+			if (get_option($check_field))
101 101
 				$return[$storage] = $data['text'];
102 102
 		}
103 103
 		
@@ -109,17 +109,17 @@  discard block
 block discarded – undo
109 109
 		$storage = $this->xcloner_sanitization->sanitize_input_as_string($action);
110 110
 		$this->logger->debug(sprintf("Saving the remote storage %s options", strtoupper($action)));	
111 111
 		
112
-		if(is_array($this->storage_fields[$storage]))
112
+		if (is_array($this->storage_fields[$storage]))
113 113
 		{
114
-			foreach($this->storage_fields[$storage] as $field=>$validation)
114
+			foreach ($this->storage_fields[$storage] as $field=>$validation)
115 115
 			{
116 116
 				$check_field = $this->storage_fields["option_prefix"].$field;
117 117
 				$sanitize_method = "sanitize_input_as_".$validation;
118 118
 				
119
-				if(!isset($_POST[$check_field]))
119
+				if (!isset($_POST[$check_field]))
120 120
 					$_POST[$check_field] = 0;
121 121
 				
122
-				if(!method_exists($this->xcloner_sanitization, $sanitize_method))
122
+				if (!method_exists($this->xcloner_sanitization, $sanitize_method))
123 123
 					$sanitize_method = "sanitize_input_as_string";
124 124
 					
125 125
 				$sanitized_value = $this->xcloner_sanitization->$sanitize_method($_POST[$check_field]);
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 			$this->xcloner->trigger_message(__("%s storage settings saved.", 'xcloner-backup-and-restore'), "success", ucfirst($action));
130 130
 		}
131 131
 		
132
-		if(isset($_POST['connection_check']) && $_POST['connection_check'])
132
+		if (isset($_POST['connection_check']) && $_POST['connection_check'])
133 133
 		{
134
-			try{
134
+			try {
135 135
 				$this->verify_filesystem($action);
136 136
 				$this->xcloner->trigger_message(__("%s connection is valid.", 'xcloner-backup-and-restore'), "success", ucfirst($action));
137 137
 				$this->logger->debug(sprintf("Connection to remote storage %s is valid", strtoupper($action)));	
138
-			}catch(Exception $e){
138
+			}catch (Exception $e) {
139 139
 				$this->xcloner->trigger_message("%s connection error: ".$e->getMessage(), "error", ucfirst($action));
140 140
 			}
141 141
 		}
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		
149 149
 		$this->logger->info(sprintf("Checking validity of the remote storage %s filesystem", strtoupper($storage_type)));	
150 150
 		
151
-		if(!method_exists($this, $method))
151
+		if (!method_exists($this, $method))
152 152
 			return false;
153 153
 		
154 154
 		list($adapter, $filesystem) = $this->$method();
@@ -156,29 +156,29 @@  discard block
 block discarded – undo
156 156
 		$test_file = substr(".xcloner_".md5(time()), 0, 15);
157 157
 			
158 158
 		//testing write access
159
-		if(!$filesystem->write($test_file, "data"))
160
-			throw new Exception(__("Could not write data",'xcloner-backup-and-restore'));
159
+		if (!$filesystem->write($test_file, "data"))
160
+			throw new Exception(__("Could not write data", 'xcloner-backup-and-restore'));
161 161
 		$this->logger->debug(sprintf("I can write data to remote storage %s", strtoupper($storage_type)));	
162 162
 		
163 163
 		//testing read access
164
-		if(!$filesystem->read($test_file))
165
-			throw new Exception(__("Could not read data",'xcloner-backup-and-restore'));
164
+		if (!$filesystem->read($test_file))
165
+			throw new Exception(__("Could not read data", 'xcloner-backup-and-restore'));
166 166
 		$this->logger->debug(sprintf("I can read data to remote storage %s", strtoupper($storage_type)));		
167 167
 		
168 168
 		//delete test file
169
-		if(!$filesystem->delete($test_file))
170
-			throw new Exception(__("Could not delete data",'xcloner-backup-and-restore'));
169
+		if (!$filesystem->delete($test_file))
170
+			throw new Exception(__("Could not delete data", 'xcloner-backup-and-restore'));
171 171
 		$this->logger->debug(sprintf("I can delete data to remote storage %s", strtoupper($storage_type)));		
172 172
 	}
173 173
 	
174 174
 	public function upload_backup_to_storage($file, $storage)
175 175
 	{
176
-		if(!$this->xcloner_file_system->get_storage_filesystem()->has($file))
176
+		if (!$this->xcloner_file_system->get_storage_filesystem()->has($file))
177 177
 			return false;
178 178
 			
179 179
 		$method = "get_".$storage."_filesystem";	
180 180
 		
181
-		if(!method_exists($this, $method))
181
+		if (!method_exists($this, $method))
182 182
 			return false;
183 183
 			
184 184
 		list($remote_storage_adapter, $remote_storage_filesystem) = $this->$method();
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		
189 189
 		$this->logger->info(sprintf("Transferring backup %s to remote storage %s", $file, strtoupper($storage)), array(""));
190 190
 		
191
-		if(!$this->xcloner_file_system->get_storage_filesystem()->has($file))
191
+		if (!$this->xcloner_file_system->get_storage_filesystem()->has($file))
192 192
 		{
193 193
 			$this->logger->info(sprintf("File not found %s in local storage", $file));
194 194
 			return false;
@@ -196,22 +196,22 @@  discard block
 block discarded – undo
196 196
 		
197 197
 		$backup_file_stream = $this->xcloner_file_system->get_storage_filesystem()->readStream($file);
198 198
 
199
-		if(!$remote_storage_filesystem->updateStream($file, $backup_file_stream))
199
+		if (!$remote_storage_filesystem->updateStream($file, $backup_file_stream))
200 200
 		{
201 201
 			$this->logger->info(sprintf("Could not transfer file %s", $file));
202 202
 			return false;
203 203
 		}
204 204
 		
205
-		if($this->xcloner_file_system->is_multipart($file))
205
+		if ($this->xcloner_file_system->is_multipart($file))
206 206
 		{
207 207
 			$parts = $this->xcloner_file_system->get_multipart_files($file);
208
-			if(is_array($parts))
209
-				foreach($parts as $part_file)
208
+			if (is_array($parts))
209
+				foreach ($parts as $part_file)
210 210
 				{
211 211
 					$this->logger->info(sprintf("Transferring backup %s to remote storage %s", $part_file, strtoupper($storage)), array(""));
212 212
 					
213 213
 					$backup_file_stream = $this->xcloner_file_system->get_storage_filesystem()->readStream($part_file);
214
-					if(!$remote_storage_filesystem->updateStream($part_file, $backup_file_stream))
214
+					if (!$remote_storage_filesystem->updateStream($part_file, $backup_file_stream))
215 215
 						return false;
216 216
 				}
217 217
 		}
@@ -227,19 +227,19 @@  discard block
 block discarded – undo
227 227
 	public function clean_remote_storage($storage, $remote_storage_filesystem)
228 228
 	{
229 229
 		$check_field = $this->storage_fields["option_prefix"].$storage."_cleanup_days";
230
-		if($expire_days = get_option($check_field))
230
+		if ($expire_days = get_option($check_field))
231 231
 		{
232 232
 			$this->logger->info(sprintf("Doing %s remote storage cleanup for %s days limit", strtoupper($storage), $expire_days));
233 233
 			$files = $remote_storage_filesystem->listContents();
234 234
 			
235 235
 			$current_timestamp = strtotime("-".$expire_days." days");
236 236
 			
237
-			if(is_array($files))
238
-			foreach($files as $file)
237
+			if (is_array($files))
238
+			foreach ($files as $file)
239 239
 			{
240 240
 				$file['timestamp'] = $remote_storage_filesystem->getTimestamp($file['path']);
241 241
 				
242
-				if($current_timestamp >= $file['timestamp'])
242
+				if ($current_timestamp >= $file['timestamp'])
243 243
 				{
244 244
 					$remote_storage_filesystem->delete($file['path']);
245 245
 					$this->logger->info("Deleting remote file ".$file['path']." matching rule", array("RETENTION LIMIT TIMESTAMP", $file['timestamp']." =< ".$expire_days));
Please login to merge, or discard this patch.
Braces   +37 added lines, -25 removed lines patch added patch discarded remove patch
@@ -97,8 +97,9 @@  discard block
 block discarded – undo
97 97
 		foreach($this->storage_fields as $storage=>$data)
98 98
 		{
99 99
 			$check_field = $this->storage_fields["option_prefix"].$storage."_enable";
100
-			if(get_option($check_field))
101
-				$return[$storage] = $data['text'];
100
+			if(get_option($check_field)) {
101
+							$return[$storage] = $data['text'];
102
+			}
102 103
 		}
103 104
 		
104 105
 		return $return;
@@ -116,11 +117,13 @@  discard block
 block discarded – undo
116 117
 				$check_field = $this->storage_fields["option_prefix"].$field;
117 118
 				$sanitize_method = "sanitize_input_as_".$validation;
118 119
 				
119
-				if(!isset($_POST[$check_field]))
120
-					$_POST[$check_field] = 0;
120
+				if(!isset($_POST[$check_field])) {
121
+									$_POST[$check_field] = 0;
122
+				}
121 123
 				
122
-				if(!method_exists($this->xcloner_sanitization, $sanitize_method))
123
-					$sanitize_method = "sanitize_input_as_string";
124
+				if(!method_exists($this->xcloner_sanitization, $sanitize_method)) {
125
+									$sanitize_method = "sanitize_input_as_string";
126
+				}
124 127
 					
125 128
 				$sanitized_value = $this->xcloner_sanitization->$sanitize_method($_POST[$check_field]);
126 129
 				update_option($check_field, $sanitized_value);
@@ -135,7 +138,7 @@  discard block
 block discarded – undo
135 138
 				$this->verify_filesystem($action);
136 139
 				$this->xcloner->trigger_message(__("%s connection is valid.", 'xcloner-backup-and-restore'), "success", ucfirst($action));
137 140
 				$this->logger->debug(sprintf("Connection to remote storage %s is valid", strtoupper($action)));	
138
-			}catch(Exception $e){
141
+			} catch(Exception $e){
139 142
 				$this->xcloner->trigger_message("%s connection error: ".$e->getMessage(), "error", ucfirst($action));
140 143
 			}
141 144
 		}
@@ -148,38 +151,44 @@  discard block
 block discarded – undo
148 151
 		
149 152
 		$this->logger->info(sprintf("Checking validity of the remote storage %s filesystem", strtoupper($storage_type)));	
150 153
 		
151
-		if(!method_exists($this, $method))
152
-			return false;
154
+		if(!method_exists($this, $method)) {
155
+					return false;
156
+		}
153 157
 		
154 158
 		list($adapter, $filesystem) = $this->$method();
155 159
 		
156 160
 		$test_file = substr(".xcloner_".md5(time()), 0, 15);
157 161
 			
158 162
 		//testing write access
159
-		if(!$filesystem->write($test_file, "data"))
160
-			throw new Exception(__("Could not write data",'xcloner-backup-and-restore'));
163
+		if(!$filesystem->write($test_file, "data")) {
164
+					throw new Exception(__("Could not write data",'xcloner-backup-and-restore'));
165
+		}
161 166
 		$this->logger->debug(sprintf("I can write data to remote storage %s", strtoupper($storage_type)));	
162 167
 		
163 168
 		//testing read access
164
-		if(!$filesystem->read($test_file))
165
-			throw new Exception(__("Could not read data",'xcloner-backup-and-restore'));
169
+		if(!$filesystem->read($test_file)) {
170
+					throw new Exception(__("Could not read data",'xcloner-backup-and-restore'));
171
+		}
166 172
 		$this->logger->debug(sprintf("I can read data to remote storage %s", strtoupper($storage_type)));		
167 173
 		
168 174
 		//delete test file
169
-		if(!$filesystem->delete($test_file))
170
-			throw new Exception(__("Could not delete data",'xcloner-backup-and-restore'));
175
+		if(!$filesystem->delete($test_file)) {
176
+					throw new Exception(__("Could not delete data",'xcloner-backup-and-restore'));
177
+		}
171 178
 		$this->logger->debug(sprintf("I can delete data to remote storage %s", strtoupper($storage_type)));		
172 179
 	}
173 180
 	
174 181
 	public function upload_backup_to_storage($file, $storage)
175 182
 	{
176
-		if(!$this->xcloner_file_system->get_storage_filesystem()->has($file))
177
-			return false;
183
+		if(!$this->xcloner_file_system->get_storage_filesystem()->has($file)) {
184
+					return false;
185
+		}
178 186
 			
179 187
 		$method = "get_".$storage."_filesystem";	
180 188
 		
181
-		if(!method_exists($this, $method))
182
-			return false;
189
+		if(!method_exists($this, $method)) {
190
+					return false;
191
+		}
183 192
 			
184 193
 		list($remote_storage_adapter, $remote_storage_filesystem) = $this->$method();
185 194
 		
@@ -205,14 +214,16 @@  discard block
 block discarded – undo
205 214
 		if($this->xcloner_file_system->is_multipart($file))
206 215
 		{
207 216
 			$parts = $this->xcloner_file_system->get_multipart_files($file);
208
-			if(is_array($parts))
209
-				foreach($parts as $part_file)
217
+			if(is_array($parts)) {
218
+							foreach($parts as $part_file)
210 219
 				{
211 220
 					$this->logger->info(sprintf("Transferring backup %s to remote storage %s", $part_file, strtoupper($storage)), array(""));
221
+			}
212 222
 					
213 223
 					$backup_file_stream = $this->xcloner_file_system->get_storage_filesystem()->readStream($part_file);
214
-					if(!$remote_storage_filesystem->updateStream($part_file, $backup_file_stream))
215
-						return false;
224
+					if(!$remote_storage_filesystem->updateStream($part_file, $backup_file_stream)) {
225
+											return false;
226
+					}
216 227
 				}
217 228
 		}
218 229
 		
@@ -234,10 +245,11 @@  discard block
 block discarded – undo
234 245
 			
235 246
 			$current_timestamp = strtotime("-".$expire_days." days");
236 247
 			
237
-			if(is_array($files))
238
-			foreach($files as $file)
248
+			if(is_array($files)) {
249
+						foreach($files as $file)
239 250
 			{
240 251
 				$file['timestamp'] = $remote_storage_filesystem->getTimestamp($file['path']);
252
+			}
241 253
 				
242 254
 				if($current_timestamp >= $file['timestamp'])
243 255
 				{
Please login to merge, or discard this patch.
includes/class-xcloner-settings.php 4 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -22,6 +22,9 @@  discard block
 block discarded – undo
22 22
 		return $filename;
23 23
 	}
24 24
 	
25
+	/**
26
+	 * @return string
27
+	 */
25 28
 	public function get_xcloner_start_path()
26 29
 	{
27 30
 		if(!get_option('xcloner_start_path') or !is_dir(get_option('xcloner_start_path')))
@@ -39,6 +42,9 @@  discard block
 block discarded – undo
39 42
 		return $path;
40 43
 	}
41 44
 	
45
+	/**
46
+	 * @return string
47
+	 */
42 48
 	public function get_xcloner_store_path()
43 49
 	{
44 50
 		if(!get_option('xcloner_store_path')  or !is_dir(get_option('xcloner_store_path')))
@@ -175,6 +181,9 @@  discard block
 block discarded – undo
175 181
 		return $wpdb->prefix;
176 182
 	}
177 183
 	
184
+	/**
185
+	 * @param string $option
186
+	 */
178 187
 	public function get_xcloner_option($option)
179 188
 	{
180 189
 		$data = get_option($option);
Please login to merge, or discard this patch.
Indentation   +250 added lines, -250 removed lines patch added patch discarded remove patch
@@ -194,348 +194,348 @@  discard block
 block discarded – undo
194 194
 	
195 195
 	public function settings_init()
196 196
 	{
197
-	    global $wpdb;
198
-	    $this->xcloner_sanitization = new Xcloner_Sanitization();
197
+		global $wpdb;
198
+		$this->xcloner_sanitization = new Xcloner_Sanitization();
199 199
 	    
200
-	    //ADDING MISSING OPTIONS
201
-	    if( false == get_option( 'xcloner_mysql_settings_page' ) ) {  
200
+		//ADDING MISSING OPTIONS
201
+		if( false == get_option( 'xcloner_mysql_settings_page' ) ) {  
202 202
 			add_option( 'xcloner_mysql_settings_page' );
203 203
 		} // end if
204 204
 		
205
-	    if( false == get_option( 'xcloner_cron_settings_page' ) ) {  
205
+		if( false == get_option( 'xcloner_cron_settings_page' ) ) {  
206 206
 			add_option( 'xcloner_cron_settings_page' );
207 207
 		} // end if
208 208
 	    
209
-	    if( false == get_option( 'xcloner_system_settings_page' ) ) {  
209
+		if( false == get_option( 'xcloner_system_settings_page' ) ) {  
210 210
 			add_option( 'xcloner_system_settings_page' );
211 211
 		} // end if
212 212
 		
213
-	    if( false == get_option( 'xcloner_cleanup_settings_page' ) ) {  
213
+		if( false == get_option( 'xcloner_cleanup_settings_page' ) ) {  
214 214
 			add_option( 'xcloner_cleanup_settings_page' );
215 215
 		} // end if
216 216
 	 
217 217
 	    
218
-	    //ADDING SETTING SECTIONS
219
-	    //GENERAL section
220
-	    add_settings_section(
221
-	        'xcloner_general_settings_group',
222
-	        __(' '),
223
-	        array($this, 'xcloner_settings_section_cb'),
224
-	        'xcloner_settings_page'
225
-	    );
226
-	    //MYSQL section
227
-	    add_settings_section(
228
-	        'xcloner_mysql_settings_group',
229
-	        __(' '),
230
-	        array($this, 'xcloner_settings_section_cb'),
231
-	        'xcloner_mysql_settings_page'
232
-	    );
218
+		//ADDING SETTING SECTIONS
219
+		//GENERAL section
220
+		add_settings_section(
221
+			'xcloner_general_settings_group',
222
+			__(' '),
223
+			array($this, 'xcloner_settings_section_cb'),
224
+			'xcloner_settings_page'
225
+		);
226
+		//MYSQL section
227
+		add_settings_section(
228
+			'xcloner_mysql_settings_group',
229
+			__(' '),
230
+			array($this, 'xcloner_settings_section_cb'),
231
+			'xcloner_mysql_settings_page'
232
+		);
233 233
 	    
234
-	    //SYSTEM section
235
-	    add_settings_section(
236
-	        'xcloner_system_settings_group',
237
-	        __('These are advanced options recommended for developers!','xcloner-backup-and-restore'),
238
-	        array($this, 'xcloner_settings_section_cb'),
239
-	        'xcloner_system_settings_page'
240
-	    );
234
+		//SYSTEM section
235
+		add_settings_section(
236
+			'xcloner_system_settings_group',
237
+			__('These are advanced options recommended for developers!','xcloner-backup-and-restore'),
238
+			array($this, 'xcloner_settings_section_cb'),
239
+			'xcloner_system_settings_page'
240
+		);
241 241
 	    
242
-	    //CLEANUP section
243
-	    add_settings_section(
244
-	        'xcloner_cleanup_settings_group',
245
-	        __(' '),
246
-	        array($this, 'xcloner_settings_section_cb'),
247
-	        'xcloner_cleanup_settings_page'
248
-	    );
242
+		//CLEANUP section
243
+		add_settings_section(
244
+			'xcloner_cleanup_settings_group',
245
+			__(' '),
246
+			array($this, 'xcloner_settings_section_cb'),
247
+			'xcloner_cleanup_settings_page'
248
+		);
249 249
 	    
250 250
 		
251 251
 		//CRON section
252
-	    add_settings_section(
253
-	        'xcloner_cron_settings_group',
254
-	        __(' '),
255
-	        array($this, 'xcloner_settings_section_cb'),
256
-	        'xcloner_cron_settings_page'
257
-	    );
252
+		add_settings_section(
253
+			'xcloner_cron_settings_group',
254
+			__(' '),
255
+			array($this, 'xcloner_settings_section_cb'),
256
+			'xcloner_cron_settings_page'
257
+		);
258 258
 	    
259 259
 	    
260 260
 	    
261 261
 		//REGISTERING THE 'GENERAL SECTION' FIELDS
262 262
 		register_setting('xcloner_general_settings_group', 'xcloner_backup_compression_level', array($this->xcloner_sanitization, "sanitize_input_as_int"));
263
-	    add_settings_field(
264
-	        'xcloner_backup_compression_level',
265
-	       __('Backup Compression Level','xcloner-backup-and-restore'),
266
-	        array($this, 'do_form_range_field'),
267
-	        'xcloner_settings_page',
268
-	        'xcloner_general_settings_group',
269
-	        array('xcloner_backup_compression_level',
270
-	         __('Options between [0-9]. Value 0 means no compression, while 9 is maximum compression affecting cpu load','xcloner-backup-and-restore'), 
271
-	         0,
272
-	         9
273
-	         )
274
-	    );
263
+		add_settings_field(
264
+			'xcloner_backup_compression_level',
265
+		   __('Backup Compression Level','xcloner-backup-and-restore'),
266
+			array($this, 'do_form_range_field'),
267
+			'xcloner_settings_page',
268
+			'xcloner_general_settings_group',
269
+			array('xcloner_backup_compression_level',
270
+			 __('Options between [0-9]. Value 0 means no compression, while 9 is maximum compression affecting cpu load','xcloner-backup-and-restore'), 
271
+			 0,
272
+			 9
273
+			 )
274
+		);
275 275
 	    
276
-	    register_setting('xcloner_general_settings_group', 'xcloner_start_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path"));
277
-	    add_settings_field(
278
-	        'xcloner_start_path',
279
-	        __('Backup Start Location','xcloner-backup-and-restore'),
280
-	        array($this, 'do_form_text_field'),
281
-	        'xcloner_settings_page',
282
-	        'xcloner_general_settings_group',
283
-	        array('xcloner_start_path',
276
+		register_setting('xcloner_general_settings_group', 'xcloner_start_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path"));
277
+		add_settings_field(
278
+			'xcloner_start_path',
279
+			__('Backup Start Location','xcloner-backup-and-restore'),
280
+			array($this, 'do_form_text_field'),
281
+			'xcloner_settings_page',
282
+			'xcloner_general_settings_group',
283
+			array('xcloner_start_path',
284 284
 				__('Base path location from where XCloner can start the Backup.','xcloner-backup-and-restore'),
285 285
 				$this->get_xcloner_start_path(),
286 286
 				//'disabled'
287 287
 				)
288
-	    );
288
+		);
289 289
 	    
290
-	    register_setting('xcloner_general_settings_group', 'xcloner_store_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path"));
291
-	    add_settings_field(
292
-	        'xcloner_store_path',
293
-	        __('Backup Storage Location','xcloner-backup-and-restore'),
294
-	        array($this, 'do_form_text_field'),
295
-	        'xcloner_settings_page',
296
-	        'xcloner_general_settings_group',
297
-	        array('xcloner_store_path',
290
+		register_setting('xcloner_general_settings_group', 'xcloner_store_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path"));
291
+		add_settings_field(
292
+			'xcloner_store_path',
293
+			__('Backup Storage Location','xcloner-backup-and-restore'),
294
+			array($this, 'do_form_text_field'),
295
+			'xcloner_settings_page',
296
+			'xcloner_general_settings_group',
297
+			array('xcloner_store_path',
298 298
 				__('Location where XCloner will store the Backup archives.','xcloner-backup-and-restore'),
299 299
 				$this->get_xcloner_store_path(), 
300 300
 				//'disabled'
301 301
 				)
302
-	    );
302
+		);
303 303
 	    
304
-	    register_setting('xcloner_general_settings_group', 'xcloner_enable_log', array($this->xcloner_sanitization, "sanitize_input_as_int"));
305
-	    add_settings_field(
306
-	        'xcloner_enable_log',
307
-	        __('Enable XCloner Backup Log','xcloner-backup-and-restore'),
308
-	        array($this, 'do_form_switch_field'),
309
-	        'xcloner_settings_page',
310
-	        'xcloner_general_settings_group',
311
-	        array('xcloner_enable_log',
304
+		register_setting('xcloner_general_settings_group', 'xcloner_enable_log', array($this->xcloner_sanitization, "sanitize_input_as_int"));
305
+		add_settings_field(
306
+			'xcloner_enable_log',
307
+			__('Enable XCloner Backup Log','xcloner-backup-and-restore'),
308
+			array($this, 'do_form_switch_field'),
309
+			'xcloner_settings_page',
310
+			'xcloner_general_settings_group',
311
+			array('xcloner_enable_log',
312 312
 				sprintf(__('Enable the XCloner Backup log. You will find it stored unde the Backup Storage Location, file %s','xcloner-backup-and-restore'), $this->get_logger_filename())
313 313
 				)
314 314
 		);	
315 315
 		
316 316
 		register_setting('xcloner_general_settings_group', 'xcloner_regex_exclude', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
317
-	    add_settings_field(
318
-	        'xcloner_regex_exclude',
319
-	        __('Regex Exclude Files','xcloner-backup-and-restore'),
320
-	        array($this, 'do_form_textarea_field'),
321
-	        'xcloner_settings_page',
322
-	        'xcloner_general_settings_group',
323
-	        array('xcloner_regex_exclude',
317
+		add_settings_field(
318
+			'xcloner_regex_exclude',
319
+			__('Regex Exclude Files','xcloner-backup-and-restore'),
320
+			array($this, 'do_form_textarea_field'),
321
+			'xcloner_settings_page',
322
+			'xcloner_general_settings_group',
323
+			array('xcloner_regex_exclude',
324 324
 				__('Regular expression match to exclude files and folders, example patterns provided below, one pattern per line','xcloner-backup-and-restore'),
325 325
 				//$this->get_xcloner_store_path(), 
326 326
 				//'disabled'
327 327
 				)
328
-	    );
328
+		);
329 329
 	 
330 330
 		//REGISTERING THE 'MYSQL SECTION' FIELDS
331 331
 		register_setting('xcloner_mysql_settings_group', 'xcloner_enable_mysql_backup', array($this->xcloner_sanitization, "sanitize_input_as_int"));
332
-	    add_settings_field(
333
-	        'xcloner_enable_mysql_backup',
334
-	        __('Enable Mysql Backup','xcloner-backup-and-restore'),
335
-	        array($this, 'do_form_switch_field'),
336
-	        'xcloner_mysql_settings_page',
337
-	        'xcloner_mysql_settings_group',
338
-	        array('xcloner_enable_mysql_backup',
332
+		add_settings_field(
333
+			'xcloner_enable_mysql_backup',
334
+			__('Enable Mysql Backup','xcloner-backup-and-restore'),
335
+			array($this, 'do_form_switch_field'),
336
+			'xcloner_mysql_settings_page',
337
+			'xcloner_mysql_settings_group',
338
+			array('xcloner_enable_mysql_backup',
339 339
 				__('Enable Mysql Backup Option. If you don\'t want to backup the database, you can disable this.','xcloner-backup-and-restore')
340 340
 				)
341
-	    );
341
+		);
342 342
 	    
343
-	    register_setting('xcloner_mysql_settings_group', 'xcloner_backup_only_wp_tables');
344
-	    add_settings_field(
345
-	        'xcloner_backup_only_wp_tables',
346
-	        __('Backup only WP tables','xcloner-backup-and-restore'),
347
-	        array($this, 'do_form_switch_field'),
348
-	        'xcloner_mysql_settings_page',
349
-	        'xcloner_mysql_settings_group',
350
-	        array('xcloner_backup_only_wp_tables',
343
+		register_setting('xcloner_mysql_settings_group', 'xcloner_backup_only_wp_tables');
344
+		add_settings_field(
345
+			'xcloner_backup_only_wp_tables',
346
+			__('Backup only WP tables','xcloner-backup-and-restore'),
347
+			array($this, 'do_form_switch_field'),
348
+			'xcloner_mysql_settings_page',
349
+			'xcloner_mysql_settings_group',
350
+			array('xcloner_backup_only_wp_tables',
351 351
 				sprintf(__('Enable this if you only want to Backup only tables starting with \'%s\' prefix','xcloner-backup-and-restore'), $this->get_table_prefix())
352 352
 				)
353
-	    );
353
+		);
354 354
 	    
355
-	    register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_hostname', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
356
-	    add_settings_field(
357
-	        'xcloner_mysql_hostname',
358
-	        __('Mysql Hostname','xcloner-backup-and-restore'),
359
-	        array($this, 'do_form_text_field'),
360
-	        'xcloner_mysql_settings_page',
361
-	        'xcloner_mysql_settings_group',
362
-	        array('xcloner_mysql_hostname',
355
+		register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_hostname', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
356
+		add_settings_field(
357
+			'xcloner_mysql_hostname',
358
+			__('Mysql Hostname','xcloner-backup-and-restore'),
359
+			array($this, 'do_form_text_field'),
360
+			'xcloner_mysql_settings_page',
361
+			'xcloner_mysql_settings_group',
362
+			array('xcloner_mysql_hostname',
363 363
 				__('Wordpress mysql hostname','xcloner-backup-and-restore'),
364 364
 				$this->get_db_hostname(),
365 365
 				'disabled'
366 366
 				)
367
-	    );
367
+		);
368 368
 
369
-	    register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_username', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
370
-	    add_settings_field(
371
-	        'xcloner_mysql_username',
372
-	        __('Mysql Username','xcloner-backup-and-restore'),
373
-	        array($this, 'do_form_text_field'),
374
-	        'xcloner_mysql_settings_page',
375
-	        'xcloner_mysql_settings_group',
376
-	        array('xcloner_mysql_username',
369
+		register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_username', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
370
+		add_settings_field(
371
+			'xcloner_mysql_username',
372
+			__('Mysql Username','xcloner-backup-and-restore'),
373
+			array($this, 'do_form_text_field'),
374
+			'xcloner_mysql_settings_page',
375
+			'xcloner_mysql_settings_group',
376
+			array('xcloner_mysql_username',
377 377
 				__('Wordpress mysql username','xcloner-backup-and-restore'),
378 378
 				$this->get_db_username(),
379 379
 				'disabled'
380 380
 				)
381
-	    );
381
+		);
382 382
 	    
383
-	    register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_database', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
384
-	    add_settings_field(
385
-	        'xcloner_mysql_database',
386
-	        __('Mysql Database','xcloner-backup-and-restore'),
387
-	        array($this, 'do_form_text_field'),
388
-	        'xcloner_mysql_settings_page',
389
-	        'xcloner_mysql_settings_group',
390
-	        array('xcloner_mysql_database',
383
+		register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_database', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
384
+		add_settings_field(
385
+			'xcloner_mysql_database',
386
+			__('Mysql Database','xcloner-backup-and-restore'),
387
+			array($this, 'do_form_text_field'),
388
+			'xcloner_mysql_settings_page',
389
+			'xcloner_mysql_settings_group',
390
+			array('xcloner_mysql_database',
391 391
 				__('Wordpress mysql database','xcloner-backup-and-restore'),
392 392
 				$this->get_db_database(),
393 393
 				'disabled'
394 394
 				)
395
-	    );
395
+		);
396 396
 	    
397
-	    //REGISTERING THE 'SYSTEM SECTION' FIELDS
398
-	    register_setting('xcloner_system_settings_group', 'xcloner_size_limit_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int"));
399
-	    add_settings_field(
400
-	        'xcloner_size_limit_per_request',
401
-	       __('Data Size Limit Per Request','xcloner-backup-and-restore'),
402
-	        array($this, 'do_form_range_field'),
403
-	        'xcloner_system_settings_page',
404
-	        'xcloner_system_settings_group',
405
-	        array('xcloner_size_limit_per_request',
406
-	         __('Use this option to set how much file data can XCloner backup in one AJAX request. Range 0-1024 MB','xcloner-backup-and-restore'), 
407
-	         0,
408
-	         1024
409
-	         )
410
-	    );
397
+		//REGISTERING THE 'SYSTEM SECTION' FIELDS
398
+		register_setting('xcloner_system_settings_group', 'xcloner_size_limit_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int"));
399
+		add_settings_field(
400
+			'xcloner_size_limit_per_request',
401
+		   __('Data Size Limit Per Request','xcloner-backup-and-restore'),
402
+			array($this, 'do_form_range_field'),
403
+			'xcloner_system_settings_page',
404
+			'xcloner_system_settings_group',
405
+			array('xcloner_size_limit_per_request',
406
+			 __('Use this option to set how much file data can XCloner backup in one AJAX request. Range 0-1024 MB','xcloner-backup-and-restore'), 
407
+			 0,
408
+			 1024
409
+			 )
410
+		);
411 411
 	    
412 412
 		register_setting('xcloner_system_settings_group', 'xcloner_files_to_process_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int"));
413
-	    add_settings_field(
414
-	        'xcloner_files_to_process_per_request',
415
-	       __('Files To Process Per Request','xcloner-backup-and-restore'),
416
-	        array($this, 'do_form_range_field'),
417
-	        'xcloner_system_settings_page',
418
-	        'xcloner_system_settings_group',
419
-	        array('xcloner_files_to_process_per_request',
420
-	         __('Use this option to set how many files XCloner should process at one time before doing another AJAX call','xcloner-backup-and-restore'), 
421
-	         0,
422
-	         1000
423
-	         )
424
-	    );
413
+		add_settings_field(
414
+			'xcloner_files_to_process_per_request',
415
+		   __('Files To Process Per Request','xcloner-backup-and-restore'),
416
+			array($this, 'do_form_range_field'),
417
+			'xcloner_system_settings_page',
418
+			'xcloner_system_settings_group',
419
+			array('xcloner_files_to_process_per_request',
420
+			 __('Use this option to set how many files XCloner should process at one time before doing another AJAX call','xcloner-backup-and-restore'), 
421
+			 0,
422
+			 1000
423
+			 )
424
+		);
425 425
 	    
426 426
 		register_setting('xcloner_system_settings_group', 'xcloner_directories_to_scan_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int"));
427
-	    add_settings_field(
428
-	        'xcloner_directories_to_scan_per_request',
429
-	       __('Directories To Scan Per Request','xcloner-backup-and-restore'),
430
-	        array($this, 'do_form_range_field'),
431
-	        'xcloner_system_settings_page',
432
-	        'xcloner_system_settings_group',
433
-	        array('xcloner_directories_to_scan_per_request',
434
-	         __('Use this option to set how many directories XCloner should scan at one time before doing another AJAX call','xcloner-backup-and-restore'), 
435
-	         0,
436
-	         1000
437
-	         )
438
-	    );
427
+		add_settings_field(
428
+			'xcloner_directories_to_scan_per_request',
429
+		   __('Directories To Scan Per Request','xcloner-backup-and-restore'),
430
+			array($this, 'do_form_range_field'),
431
+			'xcloner_system_settings_page',
432
+			'xcloner_system_settings_group',
433
+			array('xcloner_directories_to_scan_per_request',
434
+			 __('Use this option to set how many directories XCloner should scan at one time before doing another AJAX call','xcloner-backup-and-restore'), 
435
+			 0,
436
+			 1000
437
+			 )
438
+		);
439 439
 	    
440 440
 		register_setting('xcloner_system_settings_group', 'xcloner_database_records_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int"));
441
-	    add_settings_field(
442
-	        'xcloner_database_records_per_request',
443
-	       __('Database Records Per Request','xcloner-backup-and-restore'),
444
-	        array($this, 'do_form_range_field'),
445
-	        'xcloner_system_settings_page',
446
-	        'xcloner_system_settings_group',
447
-	        array('xcloner_database_records_per_request',
448
-	         __('Use this option to set how many database table records should be fetched per AJAX request, or set to 0 to fetch all.  Range 0-100000 records','xcloner-backup-and-restore'), 
449
-	         0,
450
-	         100000
451
-	         )
452
-	    );
441
+		add_settings_field(
442
+			'xcloner_database_records_per_request',
443
+		   __('Database Records Per Request','xcloner-backup-and-restore'),
444
+			array($this, 'do_form_range_field'),
445
+			'xcloner_system_settings_page',
446
+			'xcloner_system_settings_group',
447
+			array('xcloner_database_records_per_request',
448
+			 __('Use this option to set how many database table records should be fetched per AJAX request, or set to 0 to fetch all.  Range 0-100000 records','xcloner-backup-and-restore'), 
449
+			 0,
450
+			 100000
451
+			 )
452
+		);
453 453
 	    
454 454
 		register_setting('xcloner_system_settings_group', 'xcloner_exclude_files_larger_than_mb', array($this->xcloner_sanitization, "sanitize_input_as_int"));
455
-	    add_settings_field(
456
-	        'xcloner_exclude_files_larger_than_mb',
457
-	       __('Exclude files larger than (MB)','xcloner-backup-and-restore'),
458
-	        array($this, 'do_form_number_field'),
459
-	        'xcloner_system_settings_page',
460
-	        'xcloner_system_settings_group',
461
-	        array('xcloner_exclude_files_larger_than_mb',
462
-	         __('Use this option to automatically exclude files larger than a certain size in MB, or set to -1 to include all. Range 0-1000 MB','xcloner-backup-and-restore'), 
463
-	         )
464
-	    );
455
+		add_settings_field(
456
+			'xcloner_exclude_files_larger_than_mb',
457
+		   __('Exclude files larger than (MB)','xcloner-backup-and-restore'),
458
+			array($this, 'do_form_number_field'),
459
+			'xcloner_system_settings_page',
460
+			'xcloner_system_settings_group',
461
+			array('xcloner_exclude_files_larger_than_mb',
462
+			 __('Use this option to automatically exclude files larger than a certain size in MB, or set to -1 to include all. Range 0-1000 MB','xcloner-backup-and-restore'), 
463
+			 )
464
+		);
465 465
 	    
466 466
 		register_setting('xcloner_system_settings_group', 'xcloner_split_backup_limit', array($this->xcloner_sanitization, "sanitize_input_as_int"));
467
-	    add_settings_field(
468
-	        'xcloner_split_backup_limit',
469
-	       __('Split Backup Archive Limit (MB)','xcloner-backup-and-restore'),
470
-	        array($this, 'do_form_number_field'),
471
-	        'xcloner_system_settings_page',
472
-	        'xcloner_system_settings_group',
473
-	        array('xcloner_split_backup_limit',
474
-	         __('Use this option to automatically split the backup archive into smaller parts. Range  0-10000 MB','xcloner-backup-and-restore'), 
475
-	         )
476
-	    );
467
+		add_settings_field(
468
+			'xcloner_split_backup_limit',
469
+		   __('Split Backup Archive Limit (MB)','xcloner-backup-and-restore'),
470
+			array($this, 'do_form_number_field'),
471
+			'xcloner_system_settings_page',
472
+			'xcloner_system_settings_group',
473
+			array('xcloner_split_backup_limit',
474
+			 __('Use this option to automatically split the backup archive into smaller parts. Range  0-10000 MB','xcloner-backup-and-restore'), 
475
+			 )
476
+		);
477 477
 	    
478
-	    register_setting('xcloner_system_settings_group', 'xcloner_force_tmp_path_site_root');
479
-	    add_settings_field(
480
-	        'xcloner_force_tmp_path_site_root',
481
-	        __('Force Temporary Path Within XCloner Storage','xcloner-backup-and-restore'),
482
-	        array($this, 'do_form_switch_field'),
483
-	        'xcloner_system_settings_page',
484
-	        'xcloner_system_settings_group',
485
-	        array('xcloner_force_tmp_path_site_root',
478
+		register_setting('xcloner_system_settings_group', 'xcloner_force_tmp_path_site_root');
479
+		add_settings_field(
480
+			'xcloner_force_tmp_path_site_root',
481
+			__('Force Temporary Path Within XCloner Storage','xcloner-backup-and-restore'),
482
+			array($this, 'do_form_switch_field'),
483
+			'xcloner_system_settings_page',
484
+			'xcloner_system_settings_group',
485
+			array('xcloner_force_tmp_path_site_root',
486 486
 				sprintf(__('Enable this option if you want the XCloner Temporary Path to be within your XCloner Storage Location','xcloner-backup-and-restore'), $this->get_table_prefix())
487 487
 				)
488
-	    );
488
+		);
489 489
 		
490 490
 		//REGISTERING THE 'CLEANUP SECTION' FIELDS
491 491
 		register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_days', array($this->xcloner_sanitization, "sanitize_input_as_int"));
492
-	    add_settings_field(
493
-	        'xcloner_cleanup_retention_limit_days',
494
-	        __('Cleanup by Date(days)','xcloner-backup-and-restore'),
495
-	        array($this, 'do_form_number_field'),
496
-	        'xcloner_cleanup_settings_page',
497
-	        'xcloner_cleanup_settings_group',
498
-	        array('xcloner_cleanup_retention_limit_days',
492
+		add_settings_field(
493
+			'xcloner_cleanup_retention_limit_days',
494
+			__('Cleanup by Date(days)','xcloner-backup-and-restore'),
495
+			array($this, 'do_form_number_field'),
496
+			'xcloner_cleanup_settings_page',
497
+			'xcloner_cleanup_settings_group',
498
+			array('xcloner_cleanup_retention_limit_days',
499 499
 				__('Specify the maximum number of days a backup archive can be kept on the server. 0 disables this option','xcloner-backup-and-restore')
500 500
 			)
501
-	    );
501
+		);
502 502
 	    
503 503
 		register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_archives', array($this->xcloner_sanitization, "sanitize_input_as_int"));
504
-	    add_settings_field(
505
-	        'xcloner_cleanup_retention_limit_archives',
506
-	        __('Cleanup by Quantity','xcloner-backup-and-restore'),
507
-	        array($this, 'do_form_number_field'),
508
-	        'xcloner_cleanup_settings_page',
509
-	        'xcloner_cleanup_settings_group',
510
-	        array('xcloner_cleanup_retention_limit_archives',
504
+		add_settings_field(
505
+			'xcloner_cleanup_retention_limit_archives',
506
+			__('Cleanup by Quantity','xcloner-backup-and-restore'),
507
+			array($this, 'do_form_number_field'),
508
+			'xcloner_cleanup_settings_page',
509
+			'xcloner_cleanup_settings_group',
510
+			array('xcloner_cleanup_retention_limit_archives',
511 511
 				__('Specify the maximum number of backup archives to keep on the server. 0 disables this option','xcloner-backup-and-restore')
512 512
 			)
513
-	    );
513
+		);
514 514
 	    
515 515
 		register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_capacity_limit', array($this->xcloner_sanitization, "sanitize_input_as_int"));
516
-	    add_settings_field(
517
-	        'xcloner_cleanup_capacity_limit',
518
-	        __('Cleanup by Capacity(MB)','xcloner-backup-and-restore'),
519
-	        array($this, 'do_form_number_field'),
520
-	        'xcloner_cleanup_settings_page',
521
-	        'xcloner_cleanup_settings_group',
522
-	        array('xcloner_cleanup_capacity_limit',
516
+		add_settings_field(
517
+			'xcloner_cleanup_capacity_limit',
518
+			__('Cleanup by Capacity(MB)','xcloner-backup-and-restore'),
519
+			array($this, 'do_form_number_field'),
520
+			'xcloner_cleanup_settings_page',
521
+			'xcloner_cleanup_settings_group',
522
+			array('xcloner_cleanup_capacity_limit',
523 523
 				__('Remove oldest backups if all created backups exceed the configured limit in Megabytes. 0 disables this option','xcloner-backup-and-restore')
524 524
 			)
525
-	    );
525
+		);
526 526
 		
527 527
 		//REGISTERING THE 'CRON SECTION' FIELDS
528 528
 		register_setting('xcloner_cron_settings_group', 'xcloner_cron_frequency');
529
-	    add_settings_field(
530
-	        'xcloner_cron_frequency',
531
-	        __('Cron frequency','xcloner-backup-and-restore'),
532
-	        array($this, 'do_form_text_field'),
533
-	        'xcloner_cron_settings_page',
534
-	        'xcloner_cron_settings_group',
535
-	        array('xcloner_cron_frequency',
529
+		add_settings_field(
530
+			'xcloner_cron_frequency',
531
+			__('Cron frequency','xcloner-backup-and-restore'),
532
+			array($this, 'do_form_text_field'),
533
+			'xcloner_cron_settings_page',
534
+			'xcloner_cron_settings_group',
535
+			array('xcloner_cron_frequency',
536 536
 				__('Cron frequency')
537 537
 			)
538
-	    );
538
+		);
539 539
 	}
540 540
 	 
541 541
 	
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 	// section content cb
549 549
 	public function xcloner_settings_section_cb()
550 550
 	{
551
-	    //echo '<p>WPOrg Section Introduction.</p>';
551
+		//echo '<p>WPOrg Section Introduction.</p>';
552 552
 	}
553 553
 	 
554 554
 	// text field content cb
@@ -563,8 +563,8 @@  discard block
 block discarded – undo
563 563
 		
564 564
 		if(!$value)
565 565
 			$value = get_option($fieldname);
566
-	    // output the field
567
-	    ?>
566
+		// output the field
567
+		?>
568 568
 	    <div class="row">
569 569
 	        <div class="input-field col s10 m10 l8">
570 570
 	          <input class="validate" <?php echo ($disabled)?"disabled":""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="text" class="validate" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>">
@@ -590,8 +590,8 @@  discard block
 block discarded – undo
590 590
 		
591 591
 		if(!$value)
592 592
 			$value = get_option($fieldname);
593
-	    // output the field
594
-	    ?>
593
+		// output the field
594
+		?>
595 595
 	    <div class="row">
596 596
 	        <div class="input-field col s10 m10 l8">
597 597
 	          <textarea class="validate" <?php echo ($disabled)?"disabled":""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="text" class="validate" value=""><?php echo isset($value) ? esc_attr($value) : ''; ?></textarea>
@@ -633,8 +633,8 @@  discard block
 block discarded – undo
633 633
 		
634 634
 		if(!$value)
635 635
 			$value = get_option($fieldname);
636
-	    // output the field
637
-	    ?>
636
+		// output the field
637
+		?>
638 638
 	    <div class="row">
639 639
 	        <div class="input-field col s10 m5 l3">
640 640
 	          <input class="validate" <?php echo ($disabled)?"disabled":""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="number" class="validate" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>">
Please login to merge, or discard this patch.
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -4,17 +4,17 @@  discard block
 block discarded – undo
4 4
 {
5 5
 	private $logger_file = "xcloner_main_%s.log";
6 6
 	private $logger_file_hash = "xcloner%s.log";
7
-	private $hash ;
7
+	private $hash;
8 8
 	
9 9
 	public function __construct($hash = "")
10 10
 	{
11
-		if(isset($hash))
11
+		if (isset($hash))
12 12
 			$this->set_hash($hash);
13 13
 	}
14 14
 	
15 15
 	public function get_logger_filename($include_hash = 0)
16 16
 	{
17
-		if($include_hash)
17
+		if ($include_hash)
18 18
 			$filename = sprintf($this->logger_file_hash, $this->get_hash()); 
19 19
 		else
20 20
 			$filename = sprintf($this->logger_file, $this->get_server_unique_hash(5));
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	
25 25
 	public function get_xcloner_start_path()
26 26
 	{
27
-		if(!get_option('xcloner_start_path') or !is_dir(get_option('xcloner_start_path')))
27
+		if (!get_option('xcloner_start_path') or !is_dir(get_option('xcloner_start_path')))
28 28
 			$path = realpath(ABSPATH);
29 29
 		else
30 30
 			$path = get_option('xcloner_start_path');
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	
42 42
 	public function get_xcloner_store_path()
43 43
 	{
44
-		if(!get_option('xcloner_store_path')  or !is_dir(get_option('xcloner_store_path')))
44
+		if (!get_option('xcloner_store_path') or !is_dir(get_option('xcloner_store_path')))
45 45
 			$path = realpath(XCLONER_STORAGE_PATH);
46 46
 		else
47 47
 			$path = get_option('xcloner_store_path');
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
 	public function get_xcloner_tmp_path()
59 59
 	{
60 60
 		$path = sys_get_temp_dir().DS.".".$this->get_xcloner_tmp_path_suffix();
61
-		if(!is_dir($path))
61
+		if (!is_dir($path))
62 62
 		{
63 63
 			@mkdir($path);
64 64
 			@chmod($path, 0777);
65 65
 		}
66 66
 		
67
-		if(!is_dir($path) or !is_writeable($path) or get_option('xcloner_force_tmp_path_site_root'))
67
+		if (!is_dir($path) or !is_writeable($path) or get_option('xcloner_force_tmp_path_site_root'))
68 68
 			$path = $this->get_xcloner_store_path().DS.".".$this->get_xcloner_tmp_path_suffix();
69 69
 		
70 70
 		return $path;
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	
73 73
 	public function get_enable_mysql_backup()
74 74
 	{
75
-		if(get_option('xcloner_enable_mysql_backup'))
75
+		if (get_option('xcloner_enable_mysql_backup'))
76 76
 			return true;
77 77
 		
78 78
 		return false;	
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 	
81 81
 	public function get_backup_extension_name($ext = "")
82 82
 	{
83
-		if(!$ext)
83
+		if (!$ext)
84 84
 		{
85
-			if(get_option('xcloner_backup_compression_level'))
85
+			if (get_option('xcloner_backup_compression_level'))
86 86
 				$ext = ".tgz";
87 87
 			else
88 88
 				$ext = ".tar";
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	
93 93
 	public function get_hash()
94 94
 	{
95
-		if(!$this->hash){
95
+		if (!$this->hash) {
96 96
 			$this->set_hash("-".$this->get_server_unique_hash(5));
97 97
 		}
98 98
 		
@@ -104,17 +104,17 @@  discard block
 block discarded – undo
104 104
 	{
105 105
 		$hash = "-".md5(rand());
106 106
 		
107
-		$this->set_hash(substr( $hash, 0, 6));
107
+		$this->set_hash(substr($hash, 0, 6));
108 108
 		
109 109
 		return $hash;
110 110
 	}
111 111
 	
112 112
 	public function set_hash($hash = "")
113 113
 	{
114
-		if(substr($hash, 0, 1) != "-" and strlen($hash))
114
+		if (substr($hash, 0, 1) != "-" and strlen($hash))
115 115
 			$hash = "-".$hash;
116 116
 			
117
-		$this->hash = substr( $hash, 0, 6);
117
+		$this->hash = substr($hash, 0, 6);
118 118
 		
119 119
 		return $this;
120 120
 	}
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	{
124 124
 		$data = parse_url(get_site_url());
125 125
 			
126
-		$backup_name = "backup_[domain]".(isset($data['port'])?":".$data['port']:"")."-[time]-".($this->get_enable_mysql_backup()?"sql":"nosql");
126
+		$backup_name = "backup_[domain]".(isset($data['port']) ? ":".$data['port'] : "")."-[time]-".($this->get_enable_mysql_backup() ? "sql" : "nosql");
127 127
 		
128 128
 		return $backup_name;
129 129
 	}
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	{
133 133
 		global $wpdb;
134 134
 		
135
-		if(!$data = get_option('xcloner_mysql_hostname'))
135
+		if (!$data = get_option('xcloner_mysql_hostname'))
136 136
 			$data = $wpdb->dbhost;
137 137
 		
138 138
 		return $data;
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	{
143 143
 		global $wpdb;
144 144
 		
145
-		if(!$data = get_option('xcloner_mysql_username'))
145
+		if (!$data = get_option('xcloner_mysql_username'))
146 146
 			$data = $wpdb->dbuser;
147 147
 		
148 148
 		return $data;
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	{
153 153
 		global $wpdb;
154 154
 		
155
-		if(!$data = get_option('xcloner_mysql_password'))
155
+		if (!$data = get_option('xcloner_mysql_password'))
156 156
 			$data = $wpdb->dbpassword;
157 157
 		
158 158
 		return $data;
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	{
163 163
 		global $wpdb;
164 164
 		
165
-		if(!$data = get_option('xcloner_mysql_database'))
165
+		if (!$data = get_option('xcloner_mysql_database'))
166 166
 			$data = $wpdb->dbname;
167 167
 		
168 168
 		return $data;
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	{
187 187
 		$hash = md5(get_home_url().__DIR__);
188 188
 		
189
-		if($strlen)
189
+		if ($strlen)
190 190
 			$hash = substr($hash, 0, $strlen);
191 191
 			
192 192
 		return $hash;
@@ -198,20 +198,20 @@  discard block
 block discarded – undo
198 198
 	    $this->xcloner_sanitization = new Xcloner_Sanitization();
199 199
 	    
200 200
 	    //ADDING MISSING OPTIONS
201
-	    if( false == get_option( 'xcloner_mysql_settings_page' ) ) {  
202
-			add_option( 'xcloner_mysql_settings_page' );
201
+	    if (false == get_option('xcloner_mysql_settings_page')) {  
202
+			add_option('xcloner_mysql_settings_page');
203 203
 		} // end if
204 204
 		
205
-	    if( false == get_option( 'xcloner_cron_settings_page' ) ) {  
206
-			add_option( 'xcloner_cron_settings_page' );
205
+	    if (false == get_option('xcloner_cron_settings_page')) {  
206
+			add_option('xcloner_cron_settings_page');
207 207
 		} // end if
208 208
 	    
209
-	    if( false == get_option( 'xcloner_system_settings_page' ) ) {  
210
-			add_option( 'xcloner_system_settings_page' );
209
+	    if (false == get_option('xcloner_system_settings_page')) {  
210
+			add_option('xcloner_system_settings_page');
211 211
 		} // end if
212 212
 		
213
-	    if( false == get_option( 'xcloner_cleanup_settings_page' ) ) {  
214
-			add_option( 'xcloner_cleanup_settings_page' );
213
+	    if (false == get_option('xcloner_cleanup_settings_page')) {  
214
+			add_option('xcloner_cleanup_settings_page');
215 215
 		} // end if
216 216
 	 
217 217
 	    
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	    //SYSTEM section
235 235
 	    add_settings_section(
236 236
 	        'xcloner_system_settings_group',
237
-	        __('These are advanced options recommended for developers!','xcloner-backup-and-restore'),
237
+	        __('These are advanced options recommended for developers!', 'xcloner-backup-and-restore'),
238 238
 	        array($this, 'xcloner_settings_section_cb'),
239 239
 	        'xcloner_system_settings_page'
240 240
 	    );
@@ -262,12 +262,12 @@  discard block
 block discarded – undo
262 262
 		register_setting('xcloner_general_settings_group', 'xcloner_backup_compression_level', array($this->xcloner_sanitization, "sanitize_input_as_int"));
263 263
 	    add_settings_field(
264 264
 	        'xcloner_backup_compression_level',
265
-	       __('Backup Compression Level','xcloner-backup-and-restore'),
265
+	       __('Backup Compression Level', 'xcloner-backup-and-restore'),
266 266
 	        array($this, 'do_form_range_field'),
267 267
 	        'xcloner_settings_page',
268 268
 	        'xcloner_general_settings_group',
269 269
 	        array('xcloner_backup_compression_level',
270
-	         __('Options between [0-9]. Value 0 means no compression, while 9 is maximum compression affecting cpu load','xcloner-backup-and-restore'), 
270
+	         __('Options between [0-9]. Value 0 means no compression, while 9 is maximum compression affecting cpu load', 'xcloner-backup-and-restore'), 
271 271
 	         0,
272 272
 	         9
273 273
 	         )
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
 	    register_setting('xcloner_general_settings_group', 'xcloner_start_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path"));
277 277
 	    add_settings_field(
278 278
 	        'xcloner_start_path',
279
-	        __('Backup Start Location','xcloner-backup-and-restore'),
279
+	        __('Backup Start Location', 'xcloner-backup-and-restore'),
280 280
 	        array($this, 'do_form_text_field'),
281 281
 	        'xcloner_settings_page',
282 282
 	        'xcloner_general_settings_group',
283 283
 	        array('xcloner_start_path',
284
-				__('Base path location from where XCloner can start the Backup.','xcloner-backup-and-restore'),
284
+				__('Base path location from where XCloner can start the Backup.', 'xcloner-backup-and-restore'),
285 285
 				$this->get_xcloner_start_path(),
286 286
 				//'disabled'
287 287
 				)
@@ -290,12 +290,12 @@  discard block
 block discarded – undo
290 290
 	    register_setting('xcloner_general_settings_group', 'xcloner_store_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path"));
291 291
 	    add_settings_field(
292 292
 	        'xcloner_store_path',
293
-	        __('Backup Storage Location','xcloner-backup-and-restore'),
293
+	        __('Backup Storage Location', 'xcloner-backup-and-restore'),
294 294
 	        array($this, 'do_form_text_field'),
295 295
 	        'xcloner_settings_page',
296 296
 	        'xcloner_general_settings_group',
297 297
 	        array('xcloner_store_path',
298
-				__('Location where XCloner will store the Backup archives.','xcloner-backup-and-restore'),
298
+				__('Location where XCloner will store the Backup archives.', 'xcloner-backup-and-restore'),
299 299
 				$this->get_xcloner_store_path(), 
300 300
 				//'disabled'
301 301
 				)
@@ -304,24 +304,24 @@  discard block
 block discarded – undo
304 304
 	    register_setting('xcloner_general_settings_group', 'xcloner_enable_log', array($this->xcloner_sanitization, "sanitize_input_as_int"));
305 305
 	    add_settings_field(
306 306
 	        'xcloner_enable_log',
307
-	        __('Enable XCloner Backup Log','xcloner-backup-and-restore'),
307
+	        __('Enable XCloner Backup Log', 'xcloner-backup-and-restore'),
308 308
 	        array($this, 'do_form_switch_field'),
309 309
 	        'xcloner_settings_page',
310 310
 	        'xcloner_general_settings_group',
311 311
 	        array('xcloner_enable_log',
312
-				sprintf(__('Enable the XCloner Backup log. You will find it stored unde the Backup Storage Location, file %s','xcloner-backup-and-restore'), $this->get_logger_filename())
312
+				sprintf(__('Enable the XCloner Backup log. You will find it stored unde the Backup Storage Location, file %s', 'xcloner-backup-and-restore'), $this->get_logger_filename())
313 313
 				)
314 314
 		);	
315 315
 		
316 316
 		register_setting('xcloner_general_settings_group', 'xcloner_regex_exclude', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
317 317
 	    add_settings_field(
318 318
 	        'xcloner_regex_exclude',
319
-	        __('Regex Exclude Files','xcloner-backup-and-restore'),
319
+	        __('Regex Exclude Files', 'xcloner-backup-and-restore'),
320 320
 	        array($this, 'do_form_textarea_field'),
321 321
 	        'xcloner_settings_page',
322 322
 	        'xcloner_general_settings_group',
323 323
 	        array('xcloner_regex_exclude',
324
-				__('Regular expression match to exclude files and folders, example patterns provided below, one pattern per line','xcloner-backup-and-restore'),
324
+				__('Regular expression match to exclude files and folders, example patterns provided below, one pattern per line', 'xcloner-backup-and-restore'),
325 325
 				//$this->get_xcloner_store_path(), 
326 326
 				//'disabled'
327 327
 				)
@@ -331,36 +331,36 @@  discard block
 block discarded – undo
331 331
 		register_setting('xcloner_mysql_settings_group', 'xcloner_enable_mysql_backup', array($this->xcloner_sanitization, "sanitize_input_as_int"));
332 332
 	    add_settings_field(
333 333
 	        'xcloner_enable_mysql_backup',
334
-	        __('Enable Mysql Backup','xcloner-backup-and-restore'),
334
+	        __('Enable Mysql Backup', 'xcloner-backup-and-restore'),
335 335
 	        array($this, 'do_form_switch_field'),
336 336
 	        'xcloner_mysql_settings_page',
337 337
 	        'xcloner_mysql_settings_group',
338 338
 	        array('xcloner_enable_mysql_backup',
339
-				__('Enable Mysql Backup Option. If you don\'t want to backup the database, you can disable this.','xcloner-backup-and-restore')
339
+				__('Enable Mysql Backup Option. If you don\'t want to backup the database, you can disable this.', 'xcloner-backup-and-restore')
340 340
 				)
341 341
 	    );
342 342
 	    
343 343
 	    register_setting('xcloner_mysql_settings_group', 'xcloner_backup_only_wp_tables');
344 344
 	    add_settings_field(
345 345
 	        'xcloner_backup_only_wp_tables',
346
-	        __('Backup only WP tables','xcloner-backup-and-restore'),
346
+	        __('Backup only WP tables', 'xcloner-backup-and-restore'),
347 347
 	        array($this, 'do_form_switch_field'),
348 348
 	        'xcloner_mysql_settings_page',
349 349
 	        'xcloner_mysql_settings_group',
350 350
 	        array('xcloner_backup_only_wp_tables',
351
-				sprintf(__('Enable this if you only want to Backup only tables starting with \'%s\' prefix','xcloner-backup-and-restore'), $this->get_table_prefix())
351
+				sprintf(__('Enable this if you only want to Backup only tables starting with \'%s\' prefix', 'xcloner-backup-and-restore'), $this->get_table_prefix())
352 352
 				)
353 353
 	    );
354 354
 	    
355 355
 	    register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_hostname', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
356 356
 	    add_settings_field(
357 357
 	        'xcloner_mysql_hostname',
358
-	        __('Mysql Hostname','xcloner-backup-and-restore'),
358
+	        __('Mysql Hostname', 'xcloner-backup-and-restore'),
359 359
 	        array($this, 'do_form_text_field'),
360 360
 	        'xcloner_mysql_settings_page',
361 361
 	        'xcloner_mysql_settings_group',
362 362
 	        array('xcloner_mysql_hostname',
363
-				__('Wordpress mysql hostname','xcloner-backup-and-restore'),
363
+				__('Wordpress mysql hostname', 'xcloner-backup-and-restore'),
364 364
 				$this->get_db_hostname(),
365 365
 				'disabled'
366 366
 				)
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
 	    register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_username', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
370 370
 	    add_settings_field(
371 371
 	        'xcloner_mysql_username',
372
-	        __('Mysql Username','xcloner-backup-and-restore'),
372
+	        __('Mysql Username', 'xcloner-backup-and-restore'),
373 373
 	        array($this, 'do_form_text_field'),
374 374
 	        'xcloner_mysql_settings_page',
375 375
 	        'xcloner_mysql_settings_group',
376 376
 	        array('xcloner_mysql_username',
377
-				__('Wordpress mysql username','xcloner-backup-and-restore'),
377
+				__('Wordpress mysql username', 'xcloner-backup-and-restore'),
378 378
 				$this->get_db_username(),
379 379
 				'disabled'
380 380
 				)
@@ -383,12 +383,12 @@  discard block
 block discarded – undo
383 383
 	    register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_database', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
384 384
 	    add_settings_field(
385 385
 	        'xcloner_mysql_database',
386
-	        __('Mysql Database','xcloner-backup-and-restore'),
386
+	        __('Mysql Database', 'xcloner-backup-and-restore'),
387 387
 	        array($this, 'do_form_text_field'),
388 388
 	        'xcloner_mysql_settings_page',
389 389
 	        'xcloner_mysql_settings_group',
390 390
 	        array('xcloner_mysql_database',
391
-				__('Wordpress mysql database','xcloner-backup-and-restore'),
391
+				__('Wordpress mysql database', 'xcloner-backup-and-restore'),
392 392
 				$this->get_db_database(),
393 393
 				'disabled'
394 394
 				)
@@ -398,12 +398,12 @@  discard block
 block discarded – undo
398 398
 	    register_setting('xcloner_system_settings_group', 'xcloner_size_limit_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int"));
399 399
 	    add_settings_field(
400 400
 	        'xcloner_size_limit_per_request',
401
-	       __('Data Size Limit Per Request','xcloner-backup-and-restore'),
401
+	       __('Data Size Limit Per Request', 'xcloner-backup-and-restore'),
402 402
 	        array($this, 'do_form_range_field'),
403 403
 	        'xcloner_system_settings_page',
404 404
 	        'xcloner_system_settings_group',
405 405
 	        array('xcloner_size_limit_per_request',
406
-	         __('Use this option to set how much file data can XCloner backup in one AJAX request. Range 0-1024 MB','xcloner-backup-and-restore'), 
406
+	         __('Use this option to set how much file data can XCloner backup in one AJAX request. Range 0-1024 MB', 'xcloner-backup-and-restore'), 
407 407
 	         0,
408 408
 	         1024
409 409
 	         )
@@ -412,12 +412,12 @@  discard block
 block discarded – undo
412 412
 		register_setting('xcloner_system_settings_group', 'xcloner_files_to_process_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int"));
413 413
 	    add_settings_field(
414 414
 	        'xcloner_files_to_process_per_request',
415
-	       __('Files To Process Per Request','xcloner-backup-and-restore'),
415
+	       __('Files To Process Per Request', 'xcloner-backup-and-restore'),
416 416
 	        array($this, 'do_form_range_field'),
417 417
 	        'xcloner_system_settings_page',
418 418
 	        'xcloner_system_settings_group',
419 419
 	        array('xcloner_files_to_process_per_request',
420
-	         __('Use this option to set how many files XCloner should process at one time before doing another AJAX call','xcloner-backup-and-restore'), 
420
+	         __('Use this option to set how many files XCloner should process at one time before doing another AJAX call', 'xcloner-backup-and-restore'), 
421 421
 	         0,
422 422
 	         1000
423 423
 	         )
@@ -426,12 +426,12 @@  discard block
 block discarded – undo
426 426
 		register_setting('xcloner_system_settings_group', 'xcloner_directories_to_scan_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int"));
427 427
 	    add_settings_field(
428 428
 	        'xcloner_directories_to_scan_per_request',
429
-	       __('Directories To Scan Per Request','xcloner-backup-and-restore'),
429
+	       __('Directories To Scan Per Request', 'xcloner-backup-and-restore'),
430 430
 	        array($this, 'do_form_range_field'),
431 431
 	        'xcloner_system_settings_page',
432 432
 	        'xcloner_system_settings_group',
433 433
 	        array('xcloner_directories_to_scan_per_request',
434
-	         __('Use this option to set how many directories XCloner should scan at one time before doing another AJAX call','xcloner-backup-and-restore'), 
434
+	         __('Use this option to set how many directories XCloner should scan at one time before doing another AJAX call', 'xcloner-backup-and-restore'), 
435 435
 	         0,
436 436
 	         1000
437 437
 	         )
@@ -440,12 +440,12 @@  discard block
 block discarded – undo
440 440
 		register_setting('xcloner_system_settings_group', 'xcloner_database_records_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int"));
441 441
 	    add_settings_field(
442 442
 	        'xcloner_database_records_per_request',
443
-	       __('Database Records Per Request','xcloner-backup-and-restore'),
443
+	       __('Database Records Per Request', 'xcloner-backup-and-restore'),
444 444
 	        array($this, 'do_form_range_field'),
445 445
 	        'xcloner_system_settings_page',
446 446
 	        'xcloner_system_settings_group',
447 447
 	        array('xcloner_database_records_per_request',
448
-	         __('Use this option to set how many database table records should be fetched per AJAX request, or set to 0 to fetch all.  Range 0-100000 records','xcloner-backup-and-restore'), 
448
+	         __('Use this option to set how many database table records should be fetched per AJAX request, or set to 0 to fetch all.  Range 0-100000 records', 'xcloner-backup-and-restore'), 
449 449
 	         0,
450 450
 	         100000
451 451
 	         )
@@ -454,36 +454,36 @@  discard block
 block discarded – undo
454 454
 		register_setting('xcloner_system_settings_group', 'xcloner_exclude_files_larger_than_mb', array($this->xcloner_sanitization, "sanitize_input_as_int"));
455 455
 	    add_settings_field(
456 456
 	        'xcloner_exclude_files_larger_than_mb',
457
-	       __('Exclude files larger than (MB)','xcloner-backup-and-restore'),
457
+	       __('Exclude files larger than (MB)', 'xcloner-backup-and-restore'),
458 458
 	        array($this, 'do_form_number_field'),
459 459
 	        'xcloner_system_settings_page',
460 460
 	        'xcloner_system_settings_group',
461 461
 	        array('xcloner_exclude_files_larger_than_mb',
462
-	         __('Use this option to automatically exclude files larger than a certain size in MB, or set to -1 to include all. Range 0-1000 MB','xcloner-backup-and-restore'), 
462
+	         __('Use this option to automatically exclude files larger than a certain size in MB, or set to -1 to include all. Range 0-1000 MB', 'xcloner-backup-and-restore'), 
463 463
 	         )
464 464
 	    );
465 465
 	    
466 466
 		register_setting('xcloner_system_settings_group', 'xcloner_split_backup_limit', array($this->xcloner_sanitization, "sanitize_input_as_int"));
467 467
 	    add_settings_field(
468 468
 	        'xcloner_split_backup_limit',
469
-	       __('Split Backup Archive Limit (MB)','xcloner-backup-and-restore'),
469
+	       __('Split Backup Archive Limit (MB)', 'xcloner-backup-and-restore'),
470 470
 	        array($this, 'do_form_number_field'),
471 471
 	        'xcloner_system_settings_page',
472 472
 	        'xcloner_system_settings_group',
473 473
 	        array('xcloner_split_backup_limit',
474
-	         __('Use this option to automatically split the backup archive into smaller parts. Range  0-10000 MB','xcloner-backup-and-restore'), 
474
+	         __('Use this option to automatically split the backup archive into smaller parts. Range  0-10000 MB', 'xcloner-backup-and-restore'), 
475 475
 	         )
476 476
 	    );
477 477
 	    
478 478
 	    register_setting('xcloner_system_settings_group', 'xcloner_force_tmp_path_site_root');
479 479
 	    add_settings_field(
480 480
 	        'xcloner_force_tmp_path_site_root',
481
-	        __('Force Temporary Path Within XCloner Storage','xcloner-backup-and-restore'),
481
+	        __('Force Temporary Path Within XCloner Storage', 'xcloner-backup-and-restore'),
482 482
 	        array($this, 'do_form_switch_field'),
483 483
 	        'xcloner_system_settings_page',
484 484
 	        'xcloner_system_settings_group',
485 485
 	        array('xcloner_force_tmp_path_site_root',
486
-				sprintf(__('Enable this option if you want the XCloner Temporary Path to be within your XCloner Storage Location','xcloner-backup-and-restore'), $this->get_table_prefix())
486
+				sprintf(__('Enable this option if you want the XCloner Temporary Path to be within your XCloner Storage Location', 'xcloner-backup-and-restore'), $this->get_table_prefix())
487 487
 				)
488 488
 	    );
489 489
 		
@@ -491,36 +491,36 @@  discard block
 block discarded – undo
491 491
 		register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_days', array($this->xcloner_sanitization, "sanitize_input_as_int"));
492 492
 	    add_settings_field(
493 493
 	        'xcloner_cleanup_retention_limit_days',
494
-	        __('Cleanup by Date(days)','xcloner-backup-and-restore'),
494
+	        __('Cleanup by Date(days)', 'xcloner-backup-and-restore'),
495 495
 	        array($this, 'do_form_number_field'),
496 496
 	        'xcloner_cleanup_settings_page',
497 497
 	        'xcloner_cleanup_settings_group',
498 498
 	        array('xcloner_cleanup_retention_limit_days',
499
-				__('Specify the maximum number of days a backup archive can be kept on the server. 0 disables this option','xcloner-backup-and-restore')
499
+				__('Specify the maximum number of days a backup archive can be kept on the server. 0 disables this option', 'xcloner-backup-and-restore')
500 500
 			)
501 501
 	    );
502 502
 	    
503 503
 		register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_archives', array($this->xcloner_sanitization, "sanitize_input_as_int"));
504 504
 	    add_settings_field(
505 505
 	        'xcloner_cleanup_retention_limit_archives',
506
-	        __('Cleanup by Quantity','xcloner-backup-and-restore'),
506
+	        __('Cleanup by Quantity', 'xcloner-backup-and-restore'),
507 507
 	        array($this, 'do_form_number_field'),
508 508
 	        'xcloner_cleanup_settings_page',
509 509
 	        'xcloner_cleanup_settings_group',
510 510
 	        array('xcloner_cleanup_retention_limit_archives',
511
-				__('Specify the maximum number of backup archives to keep on the server. 0 disables this option','xcloner-backup-and-restore')
511
+				__('Specify the maximum number of backup archives to keep on the server. 0 disables this option', 'xcloner-backup-and-restore')
512 512
 			)
513 513
 	    );
514 514
 	    
515 515
 		register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_capacity_limit', array($this->xcloner_sanitization, "sanitize_input_as_int"));
516 516
 	    add_settings_field(
517 517
 	        'xcloner_cleanup_capacity_limit',
518
-	        __('Cleanup by Capacity(MB)','xcloner-backup-and-restore'),
518
+	        __('Cleanup by Capacity(MB)', 'xcloner-backup-and-restore'),
519 519
 	        array($this, 'do_form_number_field'),
520 520
 	        'xcloner_cleanup_settings_page',
521 521
 	        'xcloner_cleanup_settings_group',
522 522
 	        array('xcloner_cleanup_capacity_limit',
523
-				__('Remove oldest backups if all created backups exceed the configured limit in Megabytes. 0 disables this option','xcloner-backup-and-restore')
523
+				__('Remove oldest backups if all created backups exceed the configured limit in Megabytes. 0 disables this option', 'xcloner-backup-and-restore')
524 524
 			)
525 525
 	    );
526 526
 		
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 		register_setting('xcloner_cron_settings_group', 'xcloner_cron_frequency');
529 529
 	    add_settings_field(
530 530
 	        'xcloner_cron_frequency',
531
-	        __('Cron frequency','xcloner-backup-and-restore'),
531
+	        __('Cron frequency', 'xcloner-backup-and-restore'),
532 532
 	        array($this, 'do_form_text_field'),
533 533
 	        'xcloner_cron_settings_page',
534 534
 	        'xcloner_cron_settings_group',
@@ -554,20 +554,20 @@  discard block
 block discarded – undo
554 554
 	// text field content cb
555 555
 	public function do_form_text_field($params)
556 556
 	{
557
-		if(!isset($params['3']))
557
+		if (!isset($params['3']))
558 558
 			$params[3] = 0;
559
-		if(!isset($params['2']))
559
+		if (!isset($params['2']))
560 560
 			$params[2] = 0;	
561 561
 			
562 562
 		list($fieldname, $label, $value, $disabled) = $params;
563 563
 		
564
-		if(!$value)
564
+		if (!$value)
565 565
 			$value = get_option($fieldname);
566 566
 	    // output the field
567 567
 	    ?>
568 568
 	    <div class="row">
569 569
 	        <div class="input-field col s10 m10 l8">
570
-	          <input class="validate" <?php echo ($disabled)?"disabled":""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="text" class="validate" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>">
570
+	          <input class="validate" <?php echo ($disabled) ? "disabled" : ""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="text" class="validate" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>">
571 571
 	        </div>
572 572
 	        <div class="col s2 m2 ">
573 573
 				<a class="btn-floating tooltipped btn-small" data-position="left" data-delay="50" data-tooltip="<?php echo $label?>" data-tooltip-id=""><i class="material-icons">help_outline</i></a>
@@ -581,20 +581,20 @@  discard block
 block discarded – undo
581 581
 	// textarea field content cb
582 582
 	public function do_form_textarea_field($params)
583 583
 	{
584
-		if(!isset($params['3']))
584
+		if (!isset($params['3']))
585 585
 			$params[3] = 0;
586
-		if(!isset($params['2']))
586
+		if (!isset($params['2']))
587 587
 			$params[2] = 0;	
588 588
 			
589 589
 		list($fieldname, $label, $value, $disabled) = $params;
590 590
 		
591
-		if(!$value)
591
+		if (!$value)
592 592
 			$value = get_option($fieldname);
593 593
 	    // output the field
594 594
 	    ?>
595 595
 	    <div class="row">
596 596
 	        <div class="input-field col s10 m10 l8">
597
-	          <textarea class="validate" <?php echo ($disabled)?"disabled":""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="text" class="validate" value=""><?php echo isset($value) ? esc_attr($value) : ''; ?></textarea>
597
+	          <textarea class="validate" <?php echo ($disabled) ? "disabled" : ""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="text" class="validate" value=""><?php echo isset($value) ? esc_attr($value) : ''; ?></textarea>
598 598
 	        </div>
599 599
 	        <div class="col s2 m2 ">
600 600
 				<a class="btn-floating tooltipped btn-small" data-position="center" data-html="true" data-delay="50" data-tooltip="<?php echo $label?>" data-tooltip-id=""><i class="material-icons">help_outline</i></a>
@@ -624,20 +624,20 @@  discard block
 block discarded – undo
624 624
 	// number field content cb
625 625
 	public function do_form_number_field($params)
626 626
 	{
627
-		if(!isset($params['3']))
627
+		if (!isset($params['3']))
628 628
 			$params[3] = 0;
629
-		if(!isset($params['2']))
629
+		if (!isset($params['2']))
630 630
 			$params[2] = 0;	
631 631
 			
632 632
 		list($fieldname, $label, $value, $disabled) = $params;
633 633
 		
634
-		if(!$value)
634
+		if (!$value)
635 635
 			$value = get_option($fieldname);
636 636
 	    // output the field
637 637
 	    ?>
638 638
 	    <div class="row">
639 639
 	        <div class="input-field col s10 m5 l3">
640
-	          <input class="validate" <?php echo ($disabled)?"disabled":""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="number" class="validate" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>">
640
+	          <input class="validate" <?php echo ($disabled) ? "disabled" : ""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="number" class="validate" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>">
641 641
 	        </div>
642 642
 	        <div class="col s2 m2 ">
643 643
 				<a class="btn-floating tooltipped btn-small" data-position="center" data-delay="50" data-tooltip="<?php echo $label?>" data-tooltip-id=""><i class="material-icons">help_outline</i></a>
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 	
651 651
 	public function do_form_range_field($params)
652 652
 	{
653
-		if(!isset($params['4']))
653
+		if (!isset($params['4']))
654 654
 			$params[4] = 0;
655 655
 			
656 656
 		list($fieldname, $label, $range_start, $range_end, $disabled) = $params;
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 		<div class="row">
660 660
 	        <div class="input-field col s10 m10 l8">
661 661
 				<p class="range-field">
662
-			      <input <?php echo ($disabled)?"disabled":""?> type="range" name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" min="<?php echo $range_start?>" max="<?php echo $range_end?>" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>" />
662
+			      <input <?php echo ($disabled) ? "disabled" : ""?> type="range" name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" min="<?php echo $range_start?>" max="<?php echo $range_end?>" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>" />
663 663
 			    </p>
664 664
 			</div>
665 665
 			<div class="col s2 m2 ">
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 	
673 673
 	public function do_form_switch_field($params)
674 674
 	{
675
-		if(!isset($params['2']))
675
+		if (!isset($params['2']))
676 676
 			$params[2] = 0;
677 677
 		list($fieldname, $label, $disabled) = $params;
678 678
 		$value = get_option($fieldname);
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 			<div class="switch">
683 683
 				<label>
684 684
 				  Off
685
-				  <input <?php echo ($disabled)?"disabled":""?> type="checkbox" name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" value="1" <?php echo ($value) ? 'checked="checked"' : ''; ?>">
685
+				  <input <?php echo ($disabled) ? "disabled" : ""?> type="checkbox" name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" value="1" <?php echo ($value) ? 'checked="checked"' : ''; ?>">
686 686
 				  <span class="lever"></span>
687 687
 				  On
688 688
 				</label>
Please login to merge, or discard this patch.
Braces   +80 added lines, -56 removed lines patch added patch discarded remove patch
@@ -8,26 +8,29 @@  discard block
 block discarded – undo
8 8
 	
9 9
 	public function __construct($hash = "")
10 10
 	{
11
-		if(isset($hash))
12
-			$this->set_hash($hash);
11
+		if(isset($hash)) {
12
+					$this->set_hash($hash);
13
+		}
13 14
 	}
14 15
 	
15 16
 	public function get_logger_filename($include_hash = 0)
16 17
 	{
17
-		if($include_hash)
18
-			$filename = sprintf($this->logger_file_hash, $this->get_hash()); 
19
-		else
20
-			$filename = sprintf($this->logger_file, $this->get_server_unique_hash(5));
18
+		if($include_hash) {
19
+					$filename = sprintf($this->logger_file_hash, $this->get_hash());
20
+		} else {
21
+					$filename = sprintf($this->logger_file, $this->get_server_unique_hash(5));
22
+		}
21 23
 		
22 24
 		return $filename;
23 25
 	}
24 26
 	
25 27
 	public function get_xcloner_start_path()
26 28
 	{
27
-		if(!get_option('xcloner_start_path') or !is_dir(get_option('xcloner_start_path')))
28
-			$path = realpath(ABSPATH);
29
-		else
30
-			$path = get_option('xcloner_start_path');
29
+		if(!get_option('xcloner_start_path') or !is_dir(get_option('xcloner_start_path'))) {
30
+					$path = realpath(ABSPATH);
31
+		} else {
32
+					$path = get_option('xcloner_start_path');
33
+		}
31 34
 		
32 35
 		return $path;
33 36
 	}
@@ -41,10 +44,11 @@  discard block
 block discarded – undo
41 44
 	
42 45
 	public function get_xcloner_store_path()
43 46
 	{
44
-		if(!get_option('xcloner_store_path')  or !is_dir(get_option('xcloner_store_path')))
45
-			$path = realpath(XCLONER_STORAGE_PATH);
46
-		else
47
-			$path = get_option('xcloner_store_path');
47
+		if(!get_option('xcloner_store_path')  or !is_dir(get_option('xcloner_store_path'))) {
48
+					$path = realpath(XCLONER_STORAGE_PATH);
49
+		} else {
50
+					$path = get_option('xcloner_store_path');
51
+		}
48 52
 		
49 53
 		return $path;
50 54
 	}
@@ -64,16 +68,18 @@  discard block
 block discarded – undo
64 68
 			@chmod($path, 0777);
65 69
 		}
66 70
 		
67
-		if(!is_dir($path) or !is_writeable($path) or get_option('xcloner_force_tmp_path_site_root'))
68
-			$path = $this->get_xcloner_store_path().DS.".".$this->get_xcloner_tmp_path_suffix();
71
+		if(!is_dir($path) or !is_writeable($path) or get_option('xcloner_force_tmp_path_site_root')) {
72
+					$path = $this->get_xcloner_store_path().DS.".".$this->get_xcloner_tmp_path_suffix();
73
+		}
69 74
 		
70 75
 		return $path;
71 76
 	}
72 77
 	
73 78
 	public function get_enable_mysql_backup()
74 79
 	{
75
-		if(get_option('xcloner_enable_mysql_backup'))
76
-			return true;
80
+		if(get_option('xcloner_enable_mysql_backup')) {
81
+					return true;
82
+		}
77 83
 		
78 84
 		return false;	
79 85
 	}
@@ -82,10 +88,11 @@  discard block
 block discarded – undo
82 88
 	{
83 89
 		if(!$ext)
84 90
 		{
85
-			if(get_option('xcloner_backup_compression_level'))
86
-				$ext = ".tgz";
87
-			else
88
-				$ext = ".tar";
91
+			if(get_option('xcloner_backup_compression_level')) {
92
+							$ext = ".tgz";
93
+			} else {
94
+							$ext = ".tar";
95
+			}
89 96
 		}	
90 97
 		return ($this->get_hash()).$ext;	
91 98
 	}
@@ -111,8 +118,9 @@  discard block
 block discarded – undo
111 118
 	
112 119
 	public function set_hash($hash = "")
113 120
 	{
114
-		if(substr($hash, 0, 1) != "-" and strlen($hash))
115
-			$hash = "-".$hash;
121
+		if(substr($hash, 0, 1) != "-" and strlen($hash)) {
122
+					$hash = "-".$hash;
123
+		}
116 124
 			
117 125
 		$this->hash = substr( $hash, 0, 6);
118 126
 		
@@ -132,8 +140,9 @@  discard block
 block discarded – undo
132 140
 	{
133 141
 		global $wpdb;
134 142
 		
135
-		if(!$data = get_option('xcloner_mysql_hostname'))
136
-			$data = $wpdb->dbhost;
143
+		if(!$data = get_option('xcloner_mysql_hostname')) {
144
+					$data = $wpdb->dbhost;
145
+		}
137 146
 		
138 147
 		return $data;
139 148
 	}
@@ -142,8 +151,9 @@  discard block
 block discarded – undo
142 151
 	{
143 152
 		global $wpdb;
144 153
 		
145
-		if(!$data = get_option('xcloner_mysql_username'))
146
-			$data = $wpdb->dbuser;
154
+		if(!$data = get_option('xcloner_mysql_username')) {
155
+					$data = $wpdb->dbuser;
156
+		}
147 157
 		
148 158
 		return $data;
149 159
 	}
@@ -152,8 +162,9 @@  discard block
 block discarded – undo
152 162
 	{
153 163
 		global $wpdb;
154 164
 		
155
-		if(!$data = get_option('xcloner_mysql_password'))
156
-			$data = $wpdb->dbpassword;
165
+		if(!$data = get_option('xcloner_mysql_password')) {
166
+					$data = $wpdb->dbpassword;
167
+		}
157 168
 		
158 169
 		return $data;
159 170
 	}
@@ -162,8 +173,9 @@  discard block
 block discarded – undo
162 173
 	{
163 174
 		global $wpdb;
164 175
 		
165
-		if(!$data = get_option('xcloner_mysql_database'))
166
-			$data = $wpdb->dbname;
176
+		if(!$data = get_option('xcloner_mysql_database')) {
177
+					$data = $wpdb->dbname;
178
+		}
167 179
 		
168 180
 		return $data;
169 181
 	}
@@ -186,8 +198,9 @@  discard block
 block discarded – undo
186 198
 	{
187 199
 		$hash = md5(get_home_url().__DIR__);
188 200
 		
189
-		if($strlen)
190
-			$hash = substr($hash, 0, $strlen);
201
+		if($strlen) {
202
+					$hash = substr($hash, 0, $strlen);
203
+		}
191 204
 			
192 205
 		return $hash;
193 206
 	}
@@ -554,15 +567,18 @@  discard block
 block discarded – undo
554 567
 	// text field content cb
555 568
 	public function do_form_text_field($params)
556 569
 	{
557
-		if(!isset($params['3']))
558
-			$params[3] = 0;
559
-		if(!isset($params['2']))
560
-			$params[2] = 0;	
570
+		if(!isset($params['3'])) {
571
+					$params[3] = 0;
572
+		}
573
+		if(!isset($params['2'])) {
574
+					$params[2] = 0;
575
+		}
561 576
 			
562 577
 		list($fieldname, $label, $value, $disabled) = $params;
563 578
 		
564
-		if(!$value)
565
-			$value = get_option($fieldname);
579
+		if(!$value) {
580
+					$value = get_option($fieldname);
581
+		}
566 582
 	    // output the field
567 583
 	    ?>
568 584
 	    <div class="row">
@@ -581,15 +597,18 @@  discard block
 block discarded – undo
581 597
 	// textarea field content cb
582 598
 	public function do_form_textarea_field($params)
583 599
 	{
584
-		if(!isset($params['3']))
585
-			$params[3] = 0;
586
-		if(!isset($params['2']))
587
-			$params[2] = 0;	
600
+		if(!isset($params['3'])) {
601
+					$params[3] = 0;
602
+		}
603
+		if(!isset($params['2'])) {
604
+					$params[2] = 0;
605
+		}
588 606
 			
589 607
 		list($fieldname, $label, $value, $disabled) = $params;
590 608
 		
591
-		if(!$value)
592
-			$value = get_option($fieldname);
609
+		if(!$value) {
610
+					$value = get_option($fieldname);
611
+		}
593 612
 	    // output the field
594 613
 	    ?>
595 614
 	    <div class="row">
@@ -624,15 +643,18 @@  discard block
 block discarded – undo
624 643
 	// number field content cb
625 644
 	public function do_form_number_field($params)
626 645
 	{
627
-		if(!isset($params['3']))
628
-			$params[3] = 0;
629
-		if(!isset($params['2']))
630
-			$params[2] = 0;	
646
+		if(!isset($params['3'])) {
647
+					$params[3] = 0;
648
+		}
649
+		if(!isset($params['2'])) {
650
+					$params[2] = 0;
651
+		}
631 652
 			
632 653
 		list($fieldname, $label, $value, $disabled) = $params;
633 654
 		
634
-		if(!$value)
635
-			$value = get_option($fieldname);
655
+		if(!$value) {
656
+					$value = get_option($fieldname);
657
+		}
636 658
 	    // output the field
637 659
 	    ?>
638 660
 	    <div class="row">
@@ -650,8 +672,9 @@  discard block
 block discarded – undo
650 672
 	
651 673
 	public function do_form_range_field($params)
652 674
 	{
653
-		if(!isset($params['4']))
654
-			$params[4] = 0;
675
+		if(!isset($params['4'])) {
676
+					$params[4] = 0;
677
+		}
655 678
 			
656 679
 		list($fieldname, $label, $range_start, $range_end, $disabled) = $params;
657 680
 		$value = get_option($fieldname);
@@ -672,8 +695,9 @@  discard block
 block discarded – undo
672 695
 	
673 696
 	public function do_form_switch_field($params)
674 697
 	{
675
-		if(!isset($params['2']))
676
-			$params[2] = 0;
698
+		if(!isset($params['2'])) {
699
+					$params[2] = 0;
700
+		}
677 701
 		list($fieldname, $label, $disabled) = $params;
678 702
 		$value = get_option($fieldname);
679 703
 	?>
Please login to merge, or discard this patch.
includes/class-xcloner.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -115,6 +115,9 @@
 block discarded – undo
115 115
 		
116 116
 	}
117 117
 	
118
+	/**
119
+	 * @param string $message
120
+	 */
118 121
 	public function trigger_message($message, $status = "error", $message_param1 = "", $message_param2 = "", $message_param3 = "")
119 122
 	{
120 123
 			$message = sprintf(__($message), $message_param1, $message_param2, $message_param3);
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
248 248
 		
249 249
 		//wp_localize_script( 'ajax-script', 'my_ajax_object',
250
-        //   array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
250
+		//   array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
251 251
 
252 252
 	}
253 253
 
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	
282 282
 	private function define_plugin_settings(){
283 283
 		/**
284
-		* register wporg_settings_init to the admin_init action hook
285
-		*/
284
+		 * register wporg_settings_init to the admin_init action hook
285
+		 */
286 286
 		$settings = new Xcloner_Settings();
287 287
 		add_action('admin_init', array($settings, 'settings_init'));
288 288
 	}
@@ -316,15 +316,15 @@  discard block
 block discarded – undo
316 316
 	}
317 317
 	
318 318
 	function friendly_error_type($type) {
319
-	    static $levels=null;
320
-	    if ($levels===null) {
321
-	        $levels=[];
322
-	        foreach (get_defined_constants() as $key=>$value) {
323
-	            if (strpos($key,'E_')!==0) {continue;}
319
+		static $levels=null;
320
+		if ($levels===null) {
321
+			$levels=[];
322
+			foreach (get_defined_constants() as $key=>$value) {
323
+				if (strpos($key,'E_')!==0) {continue;}
324 324
 					$levels[$value]= $key; //substr($key,2);
325
-	        }
326
-	    }
327
-	    return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}");
325
+			}
326
+		}
327
+		return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}");
328 328
 	}
329 329
 		
330 330
 	private function define_ajax_hooks()
@@ -355,20 +355,20 @@  discard block
 block discarded – undo
355 355
 			add_action( 'admin_notices', array($this, 'xcloner_error_admin_notices' ));
356 356
 		
357 357
 		//if (is_admin()) {
358
-            add_filter('plugin_action_links', array($this, 'add_plugin_action_links'), 10, 2);
359
-        }
358
+			add_filter('plugin_action_links', array($this, 'add_plugin_action_links'), 10, 2);
359
+		}
360 360
 		
361 361
 	}
362 362
 	
363 363
 	function add_plugin_action_links($links, $file) {
364
-        if ($file == plugin_basename(dirname(dirname(__FILE__)) . '/xcloner.php'))
364
+		if ($file == plugin_basename(dirname(dirname(__FILE__)) . '/xcloner.php'))
365 365
 		{	
366 366
 			$links[] = '<a href="admin.php?page=xcloner_settings_page">'.__('Settings', 'xcloner-backup-and-restore').'</a>';
367 367
 			$links[] = '<a href="admin.php?page=xcloner_generate_backups_page">'.__('Generate Backup', 'xcloner-backup-and-restore').'</a>';
368 368
 		}
369 369
         
370
-        return $links;
371
-    }
370
+		return $links;
371
+	}
372 372
 	
373 373
 	public function xcloner_error_admin_notices() {
374 374
 			settings_errors( 'xcloner_error_message' );
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -88,15 +88,15 @@  discard block
 block discarded – undo
88 88
 		
89 89
 	}
90 90
 	
91
-	public function check_dependencies(){
91
+	public function check_dependencies() {
92 92
 		
93 93
 		$backup_storage_path = realpath(__DIR__.DS."..".DS."..".DS."..").DS."backups".DS;
94 94
 		
95 95
 		define("XCLONER_STORAGE_PATH", realpath($backup_storage_path));
96 96
 
97
-		if(!is_dir($backup_storage_path))
97
+		if (!is_dir($backup_storage_path))
98 98
 		{
99
-			if(!@mkdir($backup_storage_path))
99
+			if (!@mkdir($backup_storage_path))
100 100
 			{
101 101
 				$status = "error";
102 102
 				$message = sprintf(__("Unable to create the Backup Storage Location Folder %s . Please fix this before starting the backup process."), $backup_storage_path);
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 				return;
105 105
 			}
106 106
 		}	
107
-		if(!is_writable($backup_storage_path))
107
+		if (!is_writable($backup_storage_path))
108 108
 		{
109 109
 			$status = "error";
110 110
 			$message = sprintf(__("Unable to write to the Backup Storage Location Folder %s . Please fix this before starting the backup process."), $backup_storage_path);
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
 	public function trigger_message($message, $status = "error", $message_param1 = "", $message_param2 = "", $message_param3 = "")
119 119
 	{
120 120
 			$message = sprintf(__($message), $message_param1, $message_param2, $message_param3);
121
-			add_action( 'xcloner_admin_notices', array($this,"trigger_message_notice"), 10, 2);
122
-			do_action( 'xcloner_admin_notices', $message, $status);
121
+			add_action('xcloner_admin_notices', array($this, "trigger_message_notice"), 10, 2);
122
+			do_action('xcloner_admin_notices', $message, $status);
123 123
 	}
124 124
 	
125 125
 	public function trigger_message_notice($message, $status = "success")
126 126
 	{
127 127
 		?>
128 128
 		<div class="notice notice-<?php echo $status?> is-dismissible">
129
-	        <p><?php _e( $message, 'xcloner-backup-and-restore' ); ?></p>
129
+	        <p><?php _e($message, 'xcloner-backup-and-restore'); ?></p>
130 130
 	    </div>
131 131
 		<?php
132 132
 	}
@@ -153,79 +153,79 @@  discard block
 block discarded – undo
153 153
 		 * The class responsible for orchestrating the actions and filters of the
154 154
 		 * core plugin.
155 155
 		 */
156
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-loader.php';
156
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-loader.php';
157 157
 
158 158
 		/**
159 159
 		 * The class responsible for defining internationalization functionality
160 160
 		 * of the plugin.
161 161
 		 */
162
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-i18n.php';
162
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-i18n.php';
163 163
 
164 164
 		/**
165 165
 		 * The class responsible for defining all actions that occur in the admin area.
166 166
 		 */
167
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-xcloner-admin.php';
167
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-xcloner-admin.php';
168 168
 		
169 169
 		/**
170 170
 		 * The class responsible for debugging XCloner.
171 171
 		 */
172
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-logger.php';
172
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-logger.php';
173 173
 		
174 174
 		/**
175 175
 		 * The class responsible for defining the admin settings area.
176 176
 		 */
177
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-settings.php';
177
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-settings.php';
178 178
 		
179 179
 		/**
180 180
 		 * The class responsible for defining the Remote Storage settings area.
181 181
 		 */
182
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-remote-storage.php';
182
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-remote-storage.php';
183 183
 		
184 184
 		/**
185 185
 		 * The class responsible for implementing the database backup methods.
186 186
 		 */
187
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-database.php';
187
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-database.php';
188 188
 		
189 189
 		/**
190 190
 		 * The class responsible for sanitization of users input.
191 191
 		 */
192
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-sanitization.php';
192
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-sanitization.php';
193 193
 		
194 194
 		/**
195 195
 		 * The class responsible for XCloner system requirements validation.
196 196
 		 */
197
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-requirements.php';
197
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-requirements.php';
198 198
 		
199 199
 		/**
200 200
 		 * The class responsible for XCloner backup archive creation.
201 201
 		 */
202
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-archive.php';
202
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-archive.php';
203 203
 		
204 204
 		/**
205 205
 		 * The class responsible for XCloner API requests.
206 206
 		 */
207
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-api.php';
207
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-api.php';
208 208
 		
209 209
 		/**
210 210
 		 * The class responsible for the XCloner File System methods.
211 211
 		 */
212
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-file-system.php';
212
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-file-system.php';
213 213
 		
214 214
 		/**
215 215
 		 * The class responsible for the XCloner File Transfer methods.
216 216
 		 */
217
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-file-transfer.php';
217
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-file-transfer.php';
218 218
 		
219 219
 		/**
220 220
 		 * The class responsible for the XCloner Scheduler methods.
221 221
 		 */
222
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-scheduler.php';
222
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-scheduler.php';
223 223
 
224 224
 		/**
225 225
 		 * The class responsible for defining all actions that occur in the public-facing
226 226
 		 * side of the site.
227 227
 		 */
228
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-xcloner-public.php';
228
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-xcloner-public.php';
229 229
 		
230 230
 		$this->loader = new Xcloner_Loader();
231 231
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 
245 245
 		$plugin_i18n = new Xcloner_i18n();
246 246
 
247
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
247
+		$this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
248 248
 		
249 249
 		//wp_localize_script( 'ajax-script', 'my_ajax_object',
250 250
         //   array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
@@ -260,11 +260,11 @@  discard block
 block discarded – undo
260 260
 	 */
261 261
 	private function define_admin_hooks() {
262 262
 	
263
-		$plugin_admin = new Xcloner_Admin( $this->get_plugin_name(), $this->get_version() );
263
+		$plugin_admin = new Xcloner_Admin($this->get_plugin_name(), $this->get_version());
264 264
 		$this->plugin_admin = $plugin_admin;
265 265
 
266
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
267
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
266
+		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
267
+		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
268 268
 		
269 269
 	}
270 270
 	
@@ -273,13 +273,13 @@  discard block
 block discarded – undo
273 273
 	 * 
274 274
 	 * @access 	private
275 275
 	 */
276
-	private function define_admin_menu(){
276
+	private function define_admin_menu() {
277 277
 		
278 278
 		add_action('admin_menu', array($this->loader, 'xcloner_backup_add_admin_menu'));
279 279
 		
280 280
 	}
281 281
 	
282
-	private function define_plugin_settings(){
282
+	private function define_plugin_settings() {
283 283
 		/**
284 284
 		* register wporg_settings_init to the admin_init action hook
285 285
 		*/
@@ -296,10 +296,10 @@  discard block
 block discarded – undo
296 296
 	 */
297 297
 	private function define_public_hooks() {
298 298
 
299
-		$plugin_public = new Xcloner_Public( $this->get_plugin_name(), $this->get_version() );
299
+		$plugin_public = new Xcloner_Public($this->get_plugin_name(), $this->get_version());
300 300
 
301
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
302
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
301
+		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
302
+		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
303 303
 
304 304
 	}
305 305
 	
@@ -308,20 +308,20 @@  discard block
 block discarded – undo
308 308
 		$logger = new XCloner_Logger("php_system");
309 309
 		$error = error_get_last();
310 310
 		
311
-		if($error['type'] and $logger)
311
+		if ($error['type'] and $logger)
312 312
 		{
313
-			$logger->info($this->friendly_error_type ($error['type']).": ".var_export($error, true));
313
+			$logger->info($this->friendly_error_type($error['type']).": ".var_export($error, true));
314 314
 		}
315 315
 	
316 316
 	}
317 317
 	
318 318
 	function friendly_error_type($type) {
319
-	    static $levels=null;
320
-	    if ($levels===null) {
321
-	        $levels=[];
319
+	    static $levels = null;
320
+	    if ($levels === null) {
321
+	        $levels = [];
322 322
 	        foreach (get_defined_constants() as $key=>$value) {
323
-	            if (strpos($key,'E_')!==0) {continue;}
324
-					$levels[$value]= $key; //substr($key,2);
323
+	            if (strpos($key, 'E_') !== 0) {continue; }
324
+					$levels[$value] = $key; //substr($key,2);
325 325
 	        }
326 326
 	    }
327 327
 	    return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}");
@@ -329,30 +329,30 @@  discard block
 block discarded – undo
329 329
 		
330 330
 	private function define_ajax_hooks()
331 331
 	{
332
-		$plugin_public = new Xcloner_Public( $this->get_plugin_name(), $this->get_version() );
332
+		$plugin_public = new Xcloner_Public($this->get_plugin_name(), $this->get_version());
333 333
 		//$this->loader->add_action( 'wp_ajax_get_database_tables_action', $plugin_public, array('Xcloner_Api','get_database_tables_action') );
334 334
 		
335
-		if(is_admin())
335
+		if (is_admin())
336 336
 		{
337 337
 			$xcloner_api = new Xcloner_Api();
338 338
 
339
-			add_action( 'wp_ajax_get_database_tables_action'	, array($xcloner_api,'get_database_tables_action')  );
340
-			add_action( 'wp_ajax_get_file_system_action'		, array($xcloner_api,'get_file_system_action')  );
341
-			add_action( 'wp_ajax_scan_filesystem'		, array($xcloner_api,'scan_filesystem')  );
342
-			add_action( 'wp_ajax_backup_database'		, array($xcloner_api,'backup_database')  );
343
-			add_action( 'wp_ajax_backup_files'		, array($xcloner_api,'backup_files')  );
344
-			add_action( 'wp_ajax_save_schedule'		, array($xcloner_api,'save_schedule')  );
345
-			add_action( 'wp_ajax_get_schedule_by_id'		, array($xcloner_api,'get_schedule_by_id')  );
346
-			add_action( 'wp_ajax_get_scheduler_list'		, array($xcloner_api,'get_scheduler_list')  );
347
-			add_action( 'wp_ajax_delete_schedule_by_id'		, array($xcloner_api,'delete_schedule_by_id')  );
348
-			add_action( 'wp_ajax_delete_backup_by_name'		, array($xcloner_api,'delete_backup_by_name')  );
349
-			add_action( 'wp_ajax_download_backup_by_name'		, array($xcloner_api,'download_backup_by_name')  );
350
-			add_action( 'wp_ajax_remote_storage_save_status'		, array($xcloner_api,'remote_storage_save_status')  );
351
-			add_action( 'wp_ajax_upload_backup_to_remote'		, array($xcloner_api,'upload_backup_to_remote')  );
352
-			add_action( 'wp_ajax_list_backup_files'		, array($xcloner_api,'list_backup_files')  );
353
-			add_action( 'wp_ajax_restore_upload_backup'		, array($xcloner_api,'restore_upload_backup')  );
354
-			add_action( 'wp_ajax_download_restore_script'		, array($xcloner_api,'download_restore_script')  );
355
-			add_action( 'admin_notices', array($this, 'xcloner_error_admin_notices' ));
339
+			add_action('wp_ajax_get_database_tables_action', array($xcloner_api, 'get_database_tables_action'));
340
+			add_action('wp_ajax_get_file_system_action', array($xcloner_api, 'get_file_system_action'));
341
+			add_action('wp_ajax_scan_filesystem', array($xcloner_api, 'scan_filesystem'));
342
+			add_action('wp_ajax_backup_database', array($xcloner_api, 'backup_database'));
343
+			add_action('wp_ajax_backup_files', array($xcloner_api, 'backup_files'));
344
+			add_action('wp_ajax_save_schedule', array($xcloner_api, 'save_schedule'));
345
+			add_action('wp_ajax_get_schedule_by_id', array($xcloner_api, 'get_schedule_by_id'));
346
+			add_action('wp_ajax_get_scheduler_list', array($xcloner_api, 'get_scheduler_list'));
347
+			add_action('wp_ajax_delete_schedule_by_id', array($xcloner_api, 'delete_schedule_by_id'));
348
+			add_action('wp_ajax_delete_backup_by_name', array($xcloner_api, 'delete_backup_by_name'));
349
+			add_action('wp_ajax_download_backup_by_name', array($xcloner_api, 'download_backup_by_name'));
350
+			add_action('wp_ajax_remote_storage_save_status', array($xcloner_api, 'remote_storage_save_status'));
351
+			add_action('wp_ajax_upload_backup_to_remote', array($xcloner_api, 'upload_backup_to_remote'));
352
+			add_action('wp_ajax_list_backup_files', array($xcloner_api, 'list_backup_files'));
353
+			add_action('wp_ajax_restore_upload_backup', array($xcloner_api, 'restore_upload_backup'));
354
+			add_action('wp_ajax_download_restore_script', array($xcloner_api, 'download_restore_script'));
355
+			add_action('admin_notices', array($this, 'xcloner_error_admin_notices'));
356 356
 		
357 357
 		//if (is_admin()) {
358 358
             add_filter('plugin_action_links', array($this, 'add_plugin_action_links'), 10, 2);
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	}
362 362
 	
363 363
 	function add_plugin_action_links($links, $file) {
364
-        if ($file == plugin_basename(dirname(dirname(__FILE__)) . '/xcloner.php'))
364
+        if ($file == plugin_basename(dirname(dirname(__FILE__)).'/xcloner.php'))
365 365
 		{	
366 366
 			$links[] = '<a href="admin.php?page=xcloner_settings_page">'.__('Settings', 'xcloner-backup-and-restore').'</a>';
367 367
 			$links[] = '<a href="admin.php?page=xcloner_generate_backups_page">'.__('Generate Backup', 'xcloner-backup-and-restore').'</a>';
@@ -371,13 +371,13 @@  discard block
 block discarded – undo
371 371
     }
372 372
 	
373 373
 	public function xcloner_error_admin_notices() {
374
-			settings_errors( 'xcloner_error_message' );
374
+			settings_errors('xcloner_error_message');
375 375
 		}
376 376
 	
377 377
 	public function define_cron_hooks()
378 378
 	{
379 379
 		//registering new schedule intervals
380
-		add_filter( 'cron_schedules', array($this, 'add_new_intervals'));
380
+		add_filter('cron_schedules', array($this, 'add_new_intervals'));
381 381
 			
382 382
 		
383 383
 		$xcloner_scheduler = new Xcloner_Scheduler();
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 	
452 452
 	public function display($page)
453 453
 	{
454
-		$plugin_admin = new Xcloner_Admin( $this->get_plugin_name(), $this->get_version() );
454
+		$plugin_admin = new Xcloner_Admin($this->get_plugin_name(), $this->get_version());
455 455
 		$this->plugin_admin = $plugin_admin;
456 456
 		
457 457
 		$view = call_user_func_array(array($this->plugin_admin, $page), array());
Please login to merge, or discard this patch.
uninstall.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,6 +26,6 @@
 block discarded – undo
26 26
  */
27 27
 
28 28
 // If uninstall not called from WordPress, then exit.
29
-if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
29
+if (!defined('WP_UNINSTALL_PLUGIN')) {
30 30
 	exit;
31 31
 }
Please login to merge, or discard this patch.