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.
Passed
Branch dev (c13330)
by Liuta
03:02
created
includes/class-xcloner-sanitization.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 
25 25
 		try {
26 26
 			$option = Util::normalizePath($path);
27
-		}catch (Exception $e) {
27
+		} catch (Exception $e) {
28 28
 			add_settings_error('xcloner_error_message', '', __($e->getMessage()), 'error');
29 29
 		}
30 30
 
Please login to merge, or discard this patch.
includes/class-xcloner-archive.php 2 patches
Indentation   +350 added lines, -350 removed lines patch added patch discarded remove patch
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
      * @return bool
215 215
      */
216 216
 
217
-    /**
218
-     * @param string $error_message
219
-     */
217
+	/**
218
+	 * @param string $error_message
219
+	 */
220 220
 	public function send_notification_error($to, $from, $subject, $backup_name, $params, $error_message)
221 221
 	{
222 222
 
@@ -255,486 +255,486 @@  discard block
 block discarded – undo
255 255
      *
256 256
      * @return bool
257 257
      */
258
-    public function send_notification(
259
-        $to,
260
-        $from,
261
-        $subject,
262
-        $backup_name,
263
-        $params,
264
-        $error_message = "",
265
-        $additional = array()
266
-    ) {
267
-        if (!$from) {
268
-            $from = "XCloner Backup";
269
-        }
258
+	public function send_notification(
259
+		$to,
260
+		$from,
261
+		$subject,
262
+		$backup_name,
263
+		$params,
264
+		$error_message = "",
265
+		$additional = array()
266
+	) {
267
+		if (!$from) {
268
+			$from = "XCloner Backup";
269
+		}
270 270
 
271
-        if (($error_message)) {
272
-            return $this->send_notification_error($to, $from, $subject, $backup_name, $params, $error_message);
273
-        }
271
+		if (($error_message)) {
272
+			return $this->send_notification_error($to, $from, $subject, $backup_name, $params, $error_message);
273
+		}
274 274
 
275
-        $params = (array)$params;
275
+		$params = (array)$params;
276 276
 
277
-        if (!$subject) {
278
-            $subject = sprintf(__("New backup generated %s"), $backup_name);
279
-        }
277
+		if (!$subject) {
278
+			$subject = sprintf(__("New backup generated %s"), $backup_name);
279
+		}
280 280
 
281
-        $body = sprintf(__("Generated Backup Size: %s"), size_format($this->filesystem->get_backup_size($backup_name)));
282
-        $body .= "<br /><br />";
281
+		$body = sprintf(__("Generated Backup Size: %s"), size_format($this->filesystem->get_backup_size($backup_name)));
282
+		$body .= "<br /><br />";
283 283
 
284
-        if (isset($additional['lines_total'])) {
285
-            $body .= sprintf(__("Total files added: %s"), $additional['lines_total']);
286
-            $body .= "<br /><br />";
287
-        }
284
+		if (isset($additional['lines_total'])) {
285
+			$body .= sprintf(__("Total files added: %s"), $additional['lines_total']);
286
+			$body .= "<br /><br />";
287
+		}
288 288
 
289
-        $backup_parts = $this->filesystem->get_multipart_files($backup_name);
289
+		$backup_parts = $this->filesystem->get_multipart_files($backup_name);
290 290
 
291
-        if (!$backups_counter = sizeof($backup_parts)) {
292
-            $backups_counter = 1;
293
-        }
291
+		if (!$backups_counter = sizeof($backup_parts)) {
292
+			$backups_counter = 1;
293
+		}
294 294
 
295
-        $body .= sprintf(__("Backup Parts: %s"), $backups_counter);
296
-        $body .= "<br />";
295
+		$body .= sprintf(__("Backup Parts: %s"), $backups_counter);
296
+		$body .= "<br />";
297 297
 
298
-        if (sizeof($backup_parts)) {
299
-            $body .= implode("<br />", $backup_parts);
300
-            $body .= "<br />";
301
-        }
298
+		if (sizeof($backup_parts)) {
299
+			$body .= implode("<br />", $backup_parts);
300
+			$body .= "<br />";
301
+		}
302 302
 
303
-        $body .= "<br />";
303
+		$body .= "<br />";
304 304
 
305
-        $body .= sprintf(__("Backup Site Url: %s"), get_site_url());
306
-        $body .= "<br />";
305
+		$body .= sprintf(__("Backup Site Url: %s"), get_site_url());
306
+		$body .= "<br />";
307 307
 
308
-        if (isset($params['backup_params']->backup_comments)) {
309
-            $body .= __("Backup Comments: ").$params['backup_params']->backup_comments;
310
-            $body .= "<br /><br />";
311
-        }
308
+		if (isset($params['backup_params']->backup_comments)) {
309
+			$body .= __("Backup Comments: ").$params['backup_params']->backup_comments;
310
+			$body .= "<br /><br />";
311
+		}
312 312
 
313
-        if ($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) {
314
-            $body .= __("Latest 50 Log Lines: ")."<br />".implode("<br />\n",
315
-                                                                        $this->logger->getLastDebugLines(50));
316
-        }
313
+		if ($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) {
314
+			$body .= __("Latest 50 Log Lines: ")."<br />".implode("<br />\n",
315
+																		$this->logger->getLastDebugLines(50));
316
+		}
317 317
 
318
-        $attachments = $this->filesystem->get_backup_attachments();
318
+		$attachments = $this->filesystem->get_backup_attachments();
319 319
 
320
-        $attachments_archive = $this->xcloner_settings->get_xcloner_tmp_path().DS."info.tgz";
320
+		$attachments_archive = $this->xcloner_settings->get_xcloner_tmp_path().DS."info.tgz";
321 321
 
322
-        $tar = new Tar();
323
-        $tar->create($attachments_archive);
322
+		$tar = new Tar();
323
+		$tar->create($attachments_archive);
324 324
 
325
-        foreach ($attachments as $key => $file) {
326
-            $tar->addFile($file, basename($file));
327
-        }
328
-        $tar->close();
325
+		foreach ($attachments as $key => $file) {
326
+			$tar->addFile($file, basename($file));
327
+		}
328
+		$tar->close();
329 329
 
330
-        $this->logger->info(sprintf("Sending backup notification to %s", $to));
330
+		$this->logger->info(sprintf("Sending backup notification to %s", $to));
331 331
 
332
-        $admin_email = get_option("admin_email");
332
+		$admin_email = get_option("admin_email");
333 333
 
334
-        $headers = array('Content-Type: text/html; charset=UTF-8', 'From: '.$from.' <'.$admin_email.'>');
334
+		$headers = array('Content-Type: text/html; charset=UTF-8', 'From: '.$from.' <'.$admin_email.'>');
335 335
 
336
-        $return = wp_mail($to, $subject, $body, $headers, array($attachments_archive));
336
+		$return = wp_mail($to, $subject, $body, $headers, array($attachments_archive));
337 337
 
338
-        return $return;
339
-    }
338
+		return $return;
339
+	}
340 340
 
341
-    /*
341
+	/*
342 342
      *
343 343
      * Incremental Backup method
344 344
      *
345 345
      */
346
-    public function start_incremental_backup($backup_params, $extra_params, $init)
347
-    {
348
-        $return = array();
349
-
350
-        if (!isset($extra_params['backup_part'])) {
351
-            $extra_params['backup_part'] = 0;
352
-        }
353
-
354
-        $return['extra']['backup_part'] = $extra_params['backup_part'];
346
+	public function start_incremental_backup($backup_params, $extra_params, $init)
347
+	{
348
+		$return = array();
355 349
 
356
-        if (isset($extra_params['backup_archive_name'])) {
357
-            $this->set_archive_name($extra_params['backup_archive_name'], $return['extra']['backup_part']);
358
-        } else {
359
-            $this->set_archive_name($backup_params['backup_name']);
360
-        }
350
+		if (!isset($extra_params['backup_part'])) {
351
+			$extra_params['backup_part'] = 0;
352
+		}
361 353
 
362
-        if (!$this->get_archive_name()) {
363
-            $this->set_archive_name();
364
-        }
354
+		$return['extra']['backup_part'] = $extra_params['backup_part'];
365 355
 
366
-        $this->backup_archive = new Tar();
367
-        $this->backup_archive->setCompression($this->compression_level);
356
+		if (isset($extra_params['backup_archive_name'])) {
357
+			$this->set_archive_name($extra_params['backup_archive_name'], $return['extra']['backup_part']);
358
+		} else {
359
+			$this->set_archive_name($backup_params['backup_name']);
360
+		}
368 361
 
369
-        $archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
362
+		if (!$this->get_archive_name()) {
363
+			$this->set_archive_name();
364
+		}
370 365
 
371
-        if ($init) {
372
-            $this->logger->info(sprintf(__("Initializing the backup archive %s"), $this->get_archive_name()));
366
+		$this->backup_archive = new Tar();
367
+		$this->backup_archive->setCompression($this->compression_level);
373 368
 
374
-            $this->backup_archive->create($archive_info->getPath().DS.$archive_info->getFilename());
369
+		$archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
375 370
 
376
-            $return['extra']['backup_init'] = 1;
371
+		if ($init) {
372
+			$this->logger->info(sprintf(__("Initializing the backup archive %s"), $this->get_archive_name()));
377 373
 
378
-        } else {
379
-            $this->logger->info(sprintf(__("Opening for append the backup archive %s"), $this->get_archive_name()));
374
+			$this->backup_archive->create($archive_info->getPath().DS.$archive_info->getFilename());
380 375
 
381
-            $this->backup_archive->openForAppend($archive_info->getPath().DS.$archive_info->getFilename());
376
+			$return['extra']['backup_init'] = 1;
382 377
 
383
-            $return['extra']['backup_init'] = 0;
378
+		} else {
379
+			$this->logger->info(sprintf(__("Opening for append the backup archive %s"), $this->get_archive_name()));
384 380
 
385
-        }
381
+			$this->backup_archive->openForAppend($archive_info->getPath().DS.$archive_info->getFilename());
386 382
 
387
-        $return['extra']['backup_archive_name'] = $this->get_archive_name();
388
-        $return['extra']['backup_archive_name_full'] = $this->get_archive_name_with_extension();
383
+			$return['extra']['backup_init'] = 0;
389 384
 
390
-        if (!isset($extra_params['start_at_line'])) {
391
-            $extra_params['start_at_line'] = 0;
392
-        }
385
+		}
393 386
 
394
-        if (!isset($extra_params['start_at_byte'])) {
395
-            $extra_params['start_at_byte'] = 0;
396
-        }
387
+		$return['extra']['backup_archive_name'] = $this->get_archive_name();
388
+		$return['extra']['backup_archive_name_full'] = $this->get_archive_name_with_extension();
397 389
 
398
-        if (!$this->filesystem->get_tmp_filesystem()->has($this->filesystem->get_included_files_handler())) {
399
-            $this->logger->error(sprintf("Missing the includes file handler %s, aborting...",
400
-                $this->filesystem->get_included_files_handler()));
390
+		if (!isset($extra_params['start_at_line'])) {
391
+			$extra_params['start_at_line'] = 0;
392
+		}
401 393
 
402
-            $return['finished'] = 1;
403
-            return $return;
404
-        }
394
+		if (!isset($extra_params['start_at_byte'])) {
395
+			$extra_params['start_at_byte'] = 0;
396
+		}
405 397
 
406
-        $included_files_handler = $this->filesystem->get_included_files_handler(1);
398
+		if (!$this->filesystem->get_tmp_filesystem()->has($this->filesystem->get_included_files_handler())) {
399
+			$this->logger->error(sprintf("Missing the includes file handler %s, aborting...",
400
+				$this->filesystem->get_included_files_handler()));
407 401
 
408
-        $file = new SplFileObject($included_files_handler);
402
+			$return['finished'] = 1;
403
+			return $return;
404
+		}
409 405
 
410
-        $file->seek(PHP_INT_MAX);
406
+		$included_files_handler = $this->filesystem->get_included_files_handler(1);
411 407
 
412
-        $return['extra']['lines_total'] = ($file->key() - 1);
408
+		$file = new SplFileObject($included_files_handler);
413 409
 
414
-        //we skip the first CSV line with headers
415
-        if (!$extra_params['start_at_line']) {
416
-            $file->seek(1);
417
-        } else {
418
-            $file->seek($extra_params['start_at_line'] + 1);
419
-        }
410
+		$file->seek(PHP_INT_MAX);
420 411
 
421
-        $this->processed_size_bytes = 0;
412
+		$return['extra']['lines_total'] = ($file->key() - 1);
422 413
 
423
-        $counter = 0;
414
+		//we skip the first CSV line with headers
415
+		if (!$extra_params['start_at_line']) {
416
+			$file->seek(1);
417
+		} else {
418
+			$file->seek($extra_params['start_at_line'] + 1);
419
+		}
424 420
 
425
-        $start_byte = $extra_params['start_at_byte'];
421
+		$this->processed_size_bytes = 0;
426 422
 
427
-        $byte_limit = 0;
423
+		$counter = 0;
428 424
 
429
-        while (!$file->eof() and $counter <= $this->files_to_process_per_request) {
430
-            $current_line_str = $file->current();
425
+		$start_byte = $extra_params['start_at_byte'];
431 426
 
432
-            $line = str_getcsv($current_line_str);
427
+		$byte_limit = 0;
433 428
 
434
-            $relative_path = stripslashes($line[0]);
429
+		while (!$file->eof() and $counter <= $this->files_to_process_per_request) {
430
+			$current_line_str = $file->current();
435 431
 
436
-            $start_filesystem = "start_filesystem";
432
+			$line = str_getcsv($current_line_str);
437 433
 
438
-            if (isset($line[4])) {
439
-                $start_filesystem = $line[4];
440
-            }
434
+			$relative_path = stripslashes($line[0]);
441 435
 
442
-            //$adapter = $this->filesystem->get_adapter($start_filesystem);
436
+			$start_filesystem = "start_filesystem";
443 437
 
444
-            if (!$relative_path || !$this->filesystem->get_filesystem($start_filesystem)->has($relative_path)) {
445
-                if ($relative_path != "") {
446
-                    $this->logger->error(sprintf("Could not add file %b to backup archive, file not found",
447
-                        $relative_path));
448
-                }
438
+			if (isset($line[4])) {
439
+				$start_filesystem = $line[4];
440
+			}
449 441
 
450
-                $extra_params['start_at_line']++;
451
-                $file->next();
452
-                continue;
453
-            }
442
+			//$adapter = $this->filesystem->get_adapter($start_filesystem);
454 443
 
455
-            $file_info = $this->filesystem->get_filesystem($start_filesystem)->getMetadata($relative_path);
444
+			if (!$relative_path || !$this->filesystem->get_filesystem($start_filesystem)->has($relative_path)) {
445
+				if ($relative_path != "") {
446
+					$this->logger->error(sprintf("Could not add file %b to backup archive, file not found",
447
+						$relative_path));
448
+				}
456 449
 
457
-            if (!isset($file_info['size'])) {
458
-                $file_info['size'] = 0;
459
-            }
450
+				$extra_params['start_at_line']++;
451
+				$file->next();
452
+				continue;
453
+			}
460 454
 
461
-            if ($start_filesystem == "tmp_filesystem") {
462
-                $file_info['archive_prefix_path'] = $this->xcloner_settings->get_xcloner_tmp_path_suffix();
463
-            }
455
+			$file_info = $this->filesystem->get_filesystem($start_filesystem)->getMetadata($relative_path);
464 456
 
465
-            $byte_limit = (int)$this->file_size_per_request_limit / 512;
457
+			if (!isset($file_info['size'])) {
458
+				$file_info['size'] = 0;
459
+			}
466 460
 
467
-            $append = 0;
461
+			if ($start_filesystem == "tmp_filesystem") {
462
+				$file_info['archive_prefix_path'] = $this->xcloner_settings->get_xcloner_tmp_path_suffix();
463
+			}
468 464
 
469
-            if ($file_info['size'] > $byte_limit * 512 or $start_byte) {
470
-                $append = 1;
471
-            }
465
+			$byte_limit = (int)$this->file_size_per_request_limit / 512;
472 466
 
473
-            if (!isset($return['extra']['backup_size'])) {
474
-                $return['extra']['backup_size'] = 0;
475
-            }
467
+			$append = 0;
476 468
 
477
-            $return['extra']['backup_size'] = $archive_info->getSize();
469
+			if ($file_info['size'] > $byte_limit * 512 or $start_byte) {
470
+				$append = 1;
471
+			}
478 472
 
479
-            $estimated_new_size = $return['extra']['backup_size'] + $file_info['size'];
473
+			if (!isset($return['extra']['backup_size'])) {
474
+				$return['extra']['backup_size'] = 0;
475
+			}
480 476
 
481
-            //we create a new backup part if we reach the Split Achive Limit
482
-            if ($this->xcloner_split_backup_limit and ($estimated_new_size > $this->xcloner_split_backup_limit) and (!$start_byte)) {
483
-                $this->logger->info(sprintf("Backup size limit %s bytes reached, file add estimate %s, attempt to create a new archive ",
484
-                    $this->xcloner_split_backup_limit, $estimated_new_size));
485
-                list($archive_info, $return['extra']['backup_part']) = $this->create_new_backup_part($return['extra']['backup_part']);
477
+			$return['extra']['backup_size'] = $archive_info->getSize();
486 478
 
487
-                if ($file_info['size'] > $this->xcloner_split_backup_limit) {
488
-                    $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",
489
-                        $file_info['path'], $file_info['size'], $this->xcloner_split_backup_limit));
490
-                    $extra_params['start_at_line']++;
491
-                }
479
+			$estimated_new_size = $return['extra']['backup_size'] + $file_info['size'];
492 480
 
493
-                $return['extra']['start_at_line'] = $extra_params['start_at_line'];
494
-                $return['extra']['start_at_byte'] = 0;
481
+			//we create a new backup part if we reach the Split Achive Limit
482
+			if ($this->xcloner_split_backup_limit and ($estimated_new_size > $this->xcloner_split_backup_limit) and (!$start_byte)) {
483
+				$this->logger->info(sprintf("Backup size limit %s bytes reached, file add estimate %s, attempt to create a new archive ",
484
+					$this->xcloner_split_backup_limit, $estimated_new_size));
485
+				list($archive_info, $return['extra']['backup_part']) = $this->create_new_backup_part($return['extra']['backup_part']);
495 486
 
496
-                $return['finished'] = 0;
487
+				if ($file_info['size'] > $this->xcloner_split_backup_limit) {
488
+					$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",
489
+						$file_info['path'], $file_info['size'], $this->xcloner_split_backup_limit));
490
+					$extra_params['start_at_line']++;
491
+				}
497 492
 
498
-                return $return;
499
-            }
493
+				$return['extra']['start_at_line'] = $extra_params['start_at_line'];
494
+				$return['extra']['start_at_byte'] = 0;
500 495
 
501
-            list($bytes_wrote, $last_position) = $this->add_file_to_archive($file_info, $start_byte, $byte_limit,
502
-                $append, $start_filesystem);
503
-            $this->processed_size_bytes += $bytes_wrote;
496
+				$return['finished'] = 0;
504 497
 
505
-            //echo" - processed ".$this->processed_size_bytes." bytes ".$this->file_size_per_request_limit." last_position:".$last_position." \n";
506
-            $return['extra']['processed_file'] = $file_info['path'];
507
-            $return['extra']['processed_file_size'] = $file_info['size'];
508
-            $return['extra']['backup_size'] = $archive_info->getSize();
498
+				return $return;
499
+			}
509 500
 
510
-            if ($last_position > 0) {
511
-                $start_byte = $last_position;
512
-            } else {
513
-                $extra_params['start_at_line']++;
514
-                $file->next();
515
-                $start_byte = 0;
516
-                $counter++;
517
-            }
501
+			list($bytes_wrote, $last_position) = $this->add_file_to_archive($file_info, $start_byte, $byte_limit,
502
+				$append, $start_filesystem);
503
+			$this->processed_size_bytes += $bytes_wrote;
504
+
505
+			//echo" - processed ".$this->processed_size_bytes." bytes ".$this->file_size_per_request_limit." last_position:".$last_position." \n";
506
+			$return['extra']['processed_file'] = $file_info['path'];
507
+			$return['extra']['processed_file_size'] = $file_info['size'];
508
+			$return['extra']['backup_size'] = $archive_info->getSize();
509
+
510
+			if ($last_position > 0) {
511
+				$start_byte = $last_position;
512
+			} else {
513
+				$extra_params['start_at_line']++;
514
+				$file->next();
515
+				$start_byte = 0;
516
+				$counter++;
517
+			}
518 518
 
519
-            if ($this->processed_size_bytes >= $this->file_size_per_request_limit) {
520
-                clearstatcache();
521
-                $return['extra']['backup_size'] = $archive_info->getSize();
519
+			if ($this->processed_size_bytes >= $this->file_size_per_request_limit) {
520
+				clearstatcache();
521
+				$return['extra']['backup_size'] = $archive_info->getSize();
522 522
 
523
-                $return['finished'] = 0;
524
-                $return['extra']['start_at_line'] = $extra_params['start_at_line'];
525
-                $return['extra']['start_at_byte'] = $last_position;
526
-                $this->logger->info(sprintf("Reached the maximum %s request data limit, returning response",
527
-                    $this->file_size_per_request_limit));
528
-                return $return;
529
-            }
530
-        }
523
+				$return['finished'] = 0;
524
+				$return['extra']['start_at_line'] = $extra_params['start_at_line'];
525
+				$return['extra']['start_at_byte'] = $last_position;
526
+				$this->logger->info(sprintf("Reached the maximum %s request data limit, returning response",
527
+					$this->file_size_per_request_limit));
528
+				return $return;
529
+			}
530
+		}
531 531
 
532
-        if (!$file->eof()) {
533
-            clearstatcache();
534
-            $return['extra']['backup_size'] = $archive_info->getSize();
532
+		if (!$file->eof()) {
533
+			clearstatcache();
534
+			$return['extra']['backup_size'] = $archive_info->getSize();
535 535
 
536
-            $return['finished'] = 0;
537
-            $return['extra']['start_at_line'] = $extra_params['start_at_line'];
538
-            $return['extra']['start_at_byte'] = $last_position;
539
-            $this->logger->info(sprintf("We have reached the maximum files to process per request limit of %s, returning response",
540
-                $this->files_to_process_per_request));
536
+			$return['finished'] = 0;
537
+			$return['extra']['start_at_line'] = $extra_params['start_at_line'];
538
+			$return['extra']['start_at_byte'] = $last_position;
539
+			$this->logger->info(sprintf("We have reached the maximum files to process per request limit of %s, returning response",
540
+				$this->files_to_process_per_request));
541 541
 
542
-            return $return;
543
-        }
542
+			return $return;
543
+		}
544 544
 
545
-        //close the backup archive by adding 2*512 blocks of zero bytes
546
-        $this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.",
547
-            $this->get_archive_name_with_extension()));
548
-        $this->backup_archive->close();
545
+		//close the backup archive by adding 2*512 blocks of zero bytes
546
+		$this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.",
547
+			$this->get_archive_name_with_extension()));
548
+		$this->backup_archive->close();
549 549
 
550
-        /**
551
-         * XCloner HOOK backup_archive_finished.
552
-         *
553
-         * This will get triggered when a backup archive is finished writing.
554
-         */
555
-        //do_action('backup_archive_finished', $this->backup_archive, $this);
550
+		/**
551
+		 * XCloner HOOK backup_archive_finished.
552
+		 *
553
+		 * This will get triggered when a backup archive is finished writing.
554
+		 */
555
+		//do_action('backup_archive_finished', $this->backup_archive, $this);
556 556
 
557
-        //updating archive_info
558
-        $archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
557
+		//updating archive_info
558
+		$archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
559 559
 
560
-        if ($return['extra']['backup_part']) {
561
-            $this->write_multipart_file($this->get_archive_name_with_extension());
562
-        }
560
+		if ($return['extra']['backup_part']) {
561
+			$this->write_multipart_file($this->get_archive_name_with_extension());
562
+		}
563 563
 
564
-        $return['extra']['start_at_line'] = $extra_params['start_at_line'] - 1;
564
+		$return['extra']['start_at_line'] = $extra_params['start_at_line'] - 1;
565 565
 
566
-        if (isset($file_info)) {
567
-            $return['extra']['processed_file'] = $file_info['path'];
568
-            $return['extra']['processed_file_size'] = $file_info['size'];
569
-        }
566
+		if (isset($file_info)) {
567
+			$return['extra']['processed_file'] = $file_info['path'];
568
+			$return['extra']['processed_file_size'] = $file_info['size'];
569
+		}
570 570
 
571
-        clearstatcache();
572
-        $return['extra']['backup_size'] = $archive_info->getSize();
571
+		clearstatcache();
572
+		$return['extra']['backup_size'] = $archive_info->getSize();
573 573
 
574
-        $return['finished'] = 1;
575
-        return $return;
576
-    }
574
+		$return['finished'] = 1;
575
+		return $return;
576
+	}
577 577
 
578
-    /*
578
+	/*
579 579
      *
580 580
      * Write multipart file components
581 581
      *
582 582
      */
583
-    private function write_multipart_file($path = "")
584
-    {
585
-        if (!$path) {
586
-            $path = $this->get_archive_name_with_extension();
587
-        }
583
+	private function write_multipart_file($path = "")
584
+	{
585
+		if (!$path) {
586
+			$path = $this->get_archive_name_with_extension();
587
+		}
588 588
 
589
-        $file = $this->filesystem->get_filesystem("storage_filesystem_append")->getMetadata($path);
590
-        //print_r($file_info);
591
-        $line = '"'.$file['path'].'","'.$file['timestamp'].'","'.$file['size'].'"'.PHP_EOL;
589
+		$file = $this->filesystem->get_filesystem("storage_filesystem_append")->getMetadata($path);
590
+		//print_r($file_info);
591
+		$line = '"'.$file['path'].'","'.$file['timestamp'].'","'.$file['size'].'"'.PHP_EOL;
592 592
 
593 593
 
594
-        $this->filesystem->get_filesystem("storage_filesystem_append")
595
-            ->write($this->get_archive_name_multipart(), $line);
596
-    }
594
+		$this->filesystem->get_filesystem("storage_filesystem_append")
595
+			->write($this->get_archive_name_multipart(), $line);
596
+	}
597 597
 
598
-    /*
598
+	/*
599 599
      *
600 600
      * Create a new backup part
601 601
      *
602 602
      */
603
-    private function create_new_backup_part($part = 0)
604
-    {
605
-        //close the backup archive by adding 2*512 blocks of zero bytes
606
-        $this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.",
607
-            $this->get_archive_name_with_extension()));
608
-        $this->backup_archive->close();
609
-
610
-        if (!$part) {
611
-            $old_name = $this->get_archive_name_with_extension();
612
-            $this->set_archive_name($this->get_archive_name(), ++$part);
613
-            $this->rename_archive($old_name, $this->get_archive_name_with_extension());
614
-
615
-            if ($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart())) {
616
-                $this->filesystem->get_storage_filesystem()->delete($this->get_archive_name_multipart());
617
-            }
603
+	private function create_new_backup_part($part = 0)
604
+	{
605
+		//close the backup archive by adding 2*512 blocks of zero bytes
606
+		$this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.",
607
+			$this->get_archive_name_with_extension()));
608
+		$this->backup_archive->close();
609
+
610
+		if (!$part) {
611
+			$old_name = $this->get_archive_name_with_extension();
612
+			$this->set_archive_name($this->get_archive_name(), ++$part);
613
+			$this->rename_archive($old_name, $this->get_archive_name_with_extension());
614
+
615
+			if ($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart())) {
616
+				$this->filesystem->get_storage_filesystem()->delete($this->get_archive_name_multipart());
617
+			}
618 618
 
619
-            $this->write_multipart_file($this->get_archive_name_with_extension());
619
+			$this->write_multipart_file($this->get_archive_name_with_extension());
620 620
 
621
-        } else {
622
-            $this->logger->info(sprintf("Creating new multipart info file %s",
623
-                $this->get_archive_name_with_extension()));
624
-            $this->write_multipart_file($this->get_archive_name_with_extension());
625
-        }
621
+		} else {
622
+			$this->logger->info(sprintf("Creating new multipart info file %s",
623
+				$this->get_archive_name_with_extension()));
624
+			$this->write_multipart_file($this->get_archive_name_with_extension());
625
+		}
626 626
 
627
-        $this->set_archive_name($this->get_archive_name(), ++$part);
627
+		$this->set_archive_name($this->get_archive_name(), ++$part);
628 628
 
629
-        $this->logger->info(sprintf("Creating new backup archive part %s", $this->get_archive_name_with_extension()));
629
+		$this->logger->info(sprintf("Creating new backup archive part %s", $this->get_archive_name_with_extension()));
630 630
 
631
-        $this->backup_archive = new Tar();
632
-        $this->backup_archive->setCompression($this->compression_level);
633
-        $archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
634
-        $this->backup_archive->create($archive_info->getPath().DS.$archive_info->getFilename());
631
+		$this->backup_archive = new Tar();
632
+		$this->backup_archive->setCompression($this->compression_level);
633
+		$archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
634
+		$this->backup_archive->create($archive_info->getPath().DS.$archive_info->getFilename());
635 635
 
636
-        return array($archive_info, $part);
636
+		return array($archive_info, $part);
637 637
 
638
-    }
638
+	}
639 639
 
640
-    /*
640
+	/*
641 641
      *
642 642
      * Add file to archive
643 643
      *
644 644
      */
645 645
 
646
-    /**
647
-     * @param integer $append
648
-     */
649
-    public function add_file_to_archive($file_info, $start_at_byte, $byte_limit = 0, $append, $filesystem)
650
-    {
646
+	/**
647
+	 * @param integer $append
648
+	 */
649
+	public function add_file_to_archive($file_info, $start_at_byte, $byte_limit = 0, $append, $filesystem)
650
+	{
651 651
 
652
-        $start_adapter = $this->filesystem->get_adapter($filesystem);
653
-        $start_filesystem = $this->filesystem->get_adapter($filesystem);
652
+		$start_adapter = $this->filesystem->get_adapter($filesystem);
653
+		$start_filesystem = $this->filesystem->get_adapter($filesystem);
654 654
 
655
-        if (!$file_info['path']) {
656
-            return;
657
-        }
655
+		if (!$file_info['path']) {
656
+			return;
657
+		}
658 658
 
659
-        if (isset($file_info['archive_prefix_path'])) {
660
-            $file_info['target_path'] = $file_info['archive_prefix_path']."/".$file_info['path'];
661
-        } else {
662
-            $file_info['target_path'] = $file_info['path'];
663
-        }
659
+		if (isset($file_info['archive_prefix_path'])) {
660
+			$file_info['target_path'] = $file_info['archive_prefix_path']."/".$file_info['path'];
661
+		} else {
662
+			$file_info['target_path'] = $file_info['path'];
663
+		}
664 664
 
665
-        $last_position = $start_at_byte;
665
+		$last_position = $start_at_byte;
666 666
 
667
-        //$start_adapter = $this->filesystem->get_start_adapter();
667
+		//$start_adapter = $this->filesystem->get_start_adapter();
668 668
 
669
-        if (!$append) {
670
-            $bytes_wrote = $file_info['size'];
671
-            $this->logger->info(sprintf("Adding %s bytes of file %s to archive %s ", $bytes_wrote,
672
-                $file_info['target_path'], $this->get_archive_name_with_extension()));
673
-            $this->backup_archive->addFile($start_adapter->applyPathPrefix($file_info['path']),
674
-                $file_info['target_path']);
675
-        } else {
676
-            $tmp_file = md5($file_info['path']);
669
+		if (!$append) {
670
+			$bytes_wrote = $file_info['size'];
671
+			$this->logger->info(sprintf("Adding %s bytes of file %s to archive %s ", $bytes_wrote,
672
+				$file_info['target_path'], $this->get_archive_name_with_extension()));
673
+			$this->backup_archive->addFile($start_adapter->applyPathPrefix($file_info['path']),
674
+				$file_info['target_path']);
675
+		} else {
676
+			$tmp_file = md5($file_info['path']);
677 677
 
678
-            //we isolate file to tmp if we are at byte 0, the starting point of file reading
679
-            if (!$start_at_byte) {
680
-                $this->logger->info(sprintf("Copying %s file to tmp filesystem file %s to prevent reading changes",
681
-                    $file_info['path'], $tmp_file));
682
-                $file_stream = $start_filesystem->readStream($file_info['path']);
678
+			//we isolate file to tmp if we are at byte 0, the starting point of file reading
679
+			if (!$start_at_byte) {
680
+				$this->logger->info(sprintf("Copying %s file to tmp filesystem file %s to prevent reading changes",
681
+					$file_info['path'], $tmp_file));
682
+				$file_stream = $start_filesystem->readStream($file_info['path']);
683 683
 
684
-                if (is_resource($file_stream['stream'])) {
685
-                    $this->filesystem->get_tmp_filesystem()->writeStream($tmp_file, $file_stream['stream']);
686
-                }
687
-            }
684
+				if (is_resource($file_stream['stream'])) {
685
+					$this->filesystem->get_tmp_filesystem()->writeStream($tmp_file, $file_stream['stream']);
686
+				}
687
+			}
688 688
 
689
-            if ($this->filesystem->get_tmp_filesystem()->has($tmp_file)) {
690
-                $is_tmp = 1;
691
-                $last_position = $this->backup_archive->appendFileData($this->filesystem->get_tmp_filesystem_adapter()
692
-                                                        ->applyPathPrefix($tmp_file),
693
-                    $file_info['target_path'], $start_at_byte, $byte_limit);
694
-            } else {
695
-                $is_tmp = 0;
696
-                $last_position = $this->backup_archive->appendFileData($start_adapter->applyPathPrefix($file_info['path']),
697
-                    $file_info['target_path'], $start_at_byte, $byte_limit);
698
-            }
689
+			if ($this->filesystem->get_tmp_filesystem()->has($tmp_file)) {
690
+				$is_tmp = 1;
691
+				$last_position = $this->backup_archive->appendFileData($this->filesystem->get_tmp_filesystem_adapter()
692
+														->applyPathPrefix($tmp_file),
693
+					$file_info['target_path'], $start_at_byte, $byte_limit);
694
+			} else {
695
+				$is_tmp = 0;
696
+				$last_position = $this->backup_archive->appendFileData($start_adapter->applyPathPrefix($file_info['path']),
697
+					$file_info['target_path'], $start_at_byte, $byte_limit);
698
+			}
699 699
 
700 700
 
701
-            if ($last_position == -1) {
702
-                $bytes_wrote = $file_info['size'] - $start_at_byte;
703
-            } else {
704
-                $bytes_wrote = $last_position - $start_at_byte;
705
-            }
701
+			if ($last_position == -1) {
702
+				$bytes_wrote = $file_info['size'] - $start_at_byte;
703
+			} else {
704
+				$bytes_wrote = $last_position - $start_at_byte;
705
+			}
706 706
 
707 707
 
708
-            if ($is_tmp) {
709
-                $this->logger->info(sprintf("Appended %s bytes, starting position %s, of tmp file %s (%s) to archive %s ",
710
-                    $bytes_wrote, $start_at_byte, $tmp_file, $file_info['target_path'], $this->get_archive_name()));
711
-            } else {
712
-                $this->logger->info(sprintf("Appended %s bytes, starting position %s, of original file %s to archive %s ",
713
-                    $bytes_wrote, $start_at_byte, $file_info['target_path'], $tmp_file, $this->get_archive_name()));
714
-            }
708
+			if ($is_tmp) {
709
+				$this->logger->info(sprintf("Appended %s bytes, starting position %s, of tmp file %s (%s) to archive %s ",
710
+					$bytes_wrote, $start_at_byte, $tmp_file, $file_info['target_path'], $this->get_archive_name()));
711
+			} else {
712
+				$this->logger->info(sprintf("Appended %s bytes, starting position %s, of original file %s to archive %s ",
713
+					$bytes_wrote, $start_at_byte, $file_info['target_path'], $tmp_file, $this->get_archive_name()));
714
+			}
715 715
 
716
-            //we delete here the isolated tmp file
717
-            if ($last_position == -1) {
718
-                if ($this->filesystem->get_tmp_filesystem_adapter()->has($tmp_file)) {
719
-                    $this->logger->info(sprintf("Deleting %s from the tmp filesystem", $tmp_file));
720
-                    $this->filesystem->get_tmp_filesystem_adapter()->delete($tmp_file);
721
-                }
722
-            }
716
+			//we delete here the isolated tmp file
717
+			if ($last_position == -1) {
718
+				if ($this->filesystem->get_tmp_filesystem_adapter()->has($tmp_file)) {
719
+					$this->logger->info(sprintf("Deleting %s from the tmp filesystem", $tmp_file));
720
+					$this->filesystem->get_tmp_filesystem_adapter()->delete($tmp_file);
721
+				}
722
+			}
723 723
 
724
-        }
724
+		}
725 725
 
726
-        return array($bytes_wrote, $last_position);
727
-    }
726
+		return array($bytes_wrote, $last_position);
727
+	}
728 728
 
729
-    /**
730
-     * Open a TAR archive and put the file cursor at the end for data appending
731
-     *
732
-     * If $file is empty, the tar file will be created in memory
733
-     *
734
-     * @param string $file
735
-     * @throws ArchiveIOException
736
-     */
737
-    /*
729
+	/**
730
+	 * Open a TAR archive and put the file cursor at the end for data appending
731
+	 *
732
+	 * If $file is empty, the tar file will be created in memory
733
+	 *
734
+	 * @param string $file
735
+	 * @throws ArchiveIOException
736
+	 */
737
+	/*
738 738
     public function openForAppend($file = '')
739 739
     {
740 740
         $this->file   = $file;
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 			$new_name = $this->archive_name;
149 149
 
150 150
 			if (!stristr($new_name, "-diff")) {
151
-				$new_name = $this->archive_name . "-diff" . date("Y-m-d_H-i", $diff_timestamp_start);
151
+				$new_name = $this->archive_name."-diff".date("Y-m-d_H-i", $diff_timestamp_start);
152 152
 			}
153 153
 
154 154
 			$this->archive_name = $new_name;
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
 		}
157 157
 
158 158
 		if (isset($part) and $part) {
159
-			$new_name = preg_replace('/-part(\d*)/', "-part" . $part, $this->archive_name);
159
+			$new_name = preg_replace('/-part(\d*)/', "-part".$part, $this->archive_name);
160 160
 			if (!stristr($new_name, "-part")) {
161
-				$new_name = $this->archive_name . "-part" . $part;
161
+				$new_name = $this->archive_name."-part".$part;
162 162
 			}
163 163
 
164 164
 			$this->archive_name = $new_name;
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	public function get_archive_name_multipart()
188 188
 	{
189 189
 		$new_name = preg_replace('/-part(\d*)/', "", $this->archive_name);
190
-		return $new_name . "-multipart" . $this->xcloner_settings->get_backup_extension_name(".csv");
190
+		return $new_name."-multipart".$this->xcloner_settings->get_backup_extension_name(".csv");
191 191
 	}
192 192
 
193 193
 	/*
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
      */
198 198
 	public function get_archive_name_with_extension()
199 199
 	{
200
-		return $this->archive_name . $this->xcloner_settings->get_backup_extension_name();
200
+		return $this->archive_name.$this->xcloner_settings->get_backup_extension_name();
201 201
 	}
202 202
 
203 203
 	/*
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 		$headers = array('Content-Type: text/html; charset=UTF-8');
234 234
 
235 235
 		if ($admin_email and $from) {
236
-			$headers[] = 'From: ' . $from . ' <' . $admin_email . '>';
236
+			$headers[] = 'From: '.$from.' <'.$admin_email.'>';
237 237
 		}
238 238
 
239 239
 		$return = wp_mail($to, $subject, $body, $headers);
Please login to merge, or discard this patch.
includes/class-xcloner-file-transfer.php 1 patch
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -29,137 +29,137 @@
 block discarded – undo
29 29
 class Xcloner_File_Transfer extends Xcloner_File_System
30 30
 {
31 31
 
32
-    /**
33
-     * Target url web address of the restore script
34
-     * @var string
35
-     */
36
-    private $target_url;
37
-    /**
38
-     * Transfer data limit in bytes
39
-     * @var int
40
-     */
41
-    private $transfer_limit = 1048576; //bytes 1MB= 1048576 300KB = 358400
32
+	/**
33
+	 * Target url web address of the restore script
34
+	 * @var string
35
+	 */
36
+	private $target_url;
37
+	/**
38
+	 * Transfer data limit in bytes
39
+	 * @var int
40
+	 */
41
+	private $transfer_limit = 1048576; //bytes 1MB= 1048576 300KB = 358400
42 42
 
43 43
 
44
-    /**
45
-     * @param $target_url
46
-     *
47
-     * @return mixed
48
-     */
49
-    public function set_target($target_url)
50
-    {
51
-        return $this->target_url = $target_url;
52
-    }
44
+	/**
45
+	 * @param $target_url
46
+	 *
47
+	 * @return mixed
48
+	 */
49
+	public function set_target($target_url)
50
+	{
51
+		return $this->target_url = $target_url;
52
+	}
53 53
 
54
-    /**
55
-     * @return string
56
-     */
57
-    public function get_target()
58
-    {
59
-        return $this->target_url;
60
-    }
54
+	/**
55
+	 * @return string
56
+	 */
57
+	public function get_target()
58
+	{
59
+		return $this->target_url;
60
+	}
61 61
 
62 62
 
63
-    /**
64
-     * @param $file
65
-     * @param int $start
66
-     * @param string $hash
67
-     *
68
-     * @return bool|int
69
-     * @throws Exception
70
-     */
71
-    public function transfer_file($file, $start = 0, $hash = "")
72
-    {
73
-        if (!$this->target_url) {
74
-            throw new Exception("Please setup a target url for upload");
75
-        }
63
+	/**
64
+	 * @param $file
65
+	 * @param int $start
66
+	 * @param string $hash
67
+	 *
68
+	 * @return bool|int
69
+	 * @throws Exception
70
+	 */
71
+	public function transfer_file($file, $start = 0, $hash = "")
72
+	{
73
+		if (!$this->target_url) {
74
+			throw new Exception("Please setup a target url for upload");
75
+		}
76 76
 
77 77
 
78
-        $fp = $this->get_storage_filesystem()->readStream($file);
78
+		$fp = $this->get_storage_filesystem()->readStream($file);
79 79
 
80
-        fseek($fp, $start, SEEK_SET);
80
+		fseek($fp, $start, SEEK_SET);
81 81
 
82
-        $binary_data = fread($fp, $this->transfer_limit);
82
+		$binary_data = fread($fp, $this->transfer_limit);
83 83
 
84
-        $tmp_filename = "xcloner_upload_".substr(md5(time()), 0, 5);
84
+		$tmp_filename = "xcloner_upload_".substr(md5(time()), 0, 5);
85 85
 
86
-        $this->get_tmp_filesystem()->write($tmp_filename, $binary_data);
86
+		$this->get_tmp_filesystem()->write($tmp_filename, $binary_data);
87 87
 
88
-        $tmp_file_path = $this->get_tmp_filesystem_adapter()->applyPathPrefix($tmp_filename);
88
+		$tmp_file_path = $this->get_tmp_filesystem_adapter()->applyPathPrefix($tmp_filename);
89 89
 
90
-        $send_array = array();
90
+		$send_array = array();
91 91
 
92
-        $send_array['file'] = $file;
93
-        $send_array['start'] = $start;
94
-        $send_array['xcloner_action'] = "write_file";
95
-        $send_array['hash'] = $hash;
96
-        #$send_array['blob'] 	= $binary_data;
97
-        $send_array['blob'] = $this->curl_file_create($tmp_file_path, 'application/x-binary', $tmp_filename);
92
+		$send_array['file'] = $file;
93
+		$send_array['start'] = $start;
94
+		$send_array['xcloner_action'] = "write_file";
95
+		$send_array['hash'] = $hash;
96
+		#$send_array['blob'] 	= $binary_data;
97
+		$send_array['blob'] = $this->curl_file_create($tmp_file_path, 'application/x-binary', $tmp_filename);
98 98
 
99
-        //$data = http_build_query($send_array);
99
+		//$data = http_build_query($send_array);
100 100
 
101
-        $this->get_logger()->info(sprintf("Sending curl request to %s with %s data of file %s starting position %s using temporary file %s",
102
-            $this->target_url, $this->transfer_limit, $file, $start, $tmp_filename));
101
+		$this->get_logger()->info(sprintf("Sending curl request to %s with %s data of file %s starting position %s using temporary file %s",
102
+			$this->target_url, $this->transfer_limit, $file, $start, $tmp_filename));
103 103
 
104 104
 
105
-        $ch = curl_init();
106
-        curl_setopt($ch, CURLOPT_URL, $this->target_url);
105
+		$ch = curl_init();
106
+		curl_setopt($ch, CURLOPT_URL, $this->target_url);
107 107
 
108
-        curl_setopt($ch, CURLOPT_POST, 1);
109
-        //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
110
-        //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
111
-        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
112
-        curl_setopt($ch, CURLOPT_TIMEOUT, 1200);
113
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
108
+		curl_setopt($ch, CURLOPT_POST, 1);
109
+		//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
110
+		//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
111
+		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
112
+		curl_setopt($ch, CURLOPT_TIMEOUT, 1200);
113
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
114 114
 
115
-        curl_setopt($ch, CURLOPT_POSTFIELDS, $send_array);
116
-        curl_setopt($ch, CURLOPT_VERBOSE, true);
115
+		curl_setopt($ch, CURLOPT_POSTFIELDS, $send_array);
116
+		curl_setopt($ch, CURLOPT_VERBOSE, true);
117 117
 
118
-        $original_result = curl_exec($ch);
118
+		$original_result = curl_exec($ch);
119 119
 
120 120
 
121
-        $this->get_tmp_filesystem()->delete($tmp_filename);
121
+		$this->get_tmp_filesystem()->delete($tmp_filename);
122 122
 
123
-        $result = json_decode($original_result);
123
+		$result = json_decode($original_result);
124 124
 
125
-        if (!$result) {
126
-            throw new Exception("We have received no valid response from the remote host, original message: ".$original_result);
127
-        }
125
+		if (!$result) {
126
+			throw new Exception("We have received no valid response from the remote host, original message: ".$original_result);
127
+		}
128 128
 
129
-        if ($result->status != 200) {
130
-            throw new Exception($result->response);
131
-        }
129
+		if ($result->status != 200) {
130
+			throw new Exception($result->response);
131
+		}
132 132
 
133
-        if (ftell($fp) >= $this->get_storage_filesystem()->getSize($file)) {
134
-            $this->get_logger()->info(sprintf("Upload done for file %s to target url %s, transferred a total of %s bytes",
135
-                $file, $this->target_url, ftell($fp)));
136
-            $this->remove_tmp_filesystem();
133
+		if (ftell($fp) >= $this->get_storage_filesystem()->getSize($file)) {
134
+			$this->get_logger()->info(sprintf("Upload done for file %s to target url %s, transferred a total of %s bytes",
135
+				$file, $this->target_url, ftell($fp)));
136
+			$this->remove_tmp_filesystem();
137 137
 
138
-            return false;
139
-        }
138
+			return false;
139
+		}
140 140
 
141
-        return ftell($fp);
142
-    }
141
+		return ftell($fp);
142
+	}
143 143
 
144
-    /**
145
-     * @param string $filename
146
-     * @param string $mimetype
147
-     * @param string $postname
148
-     *
149
-     * @return CURLFile|string
150
-     */
151
-    private function curl_file_create($filename, $mimetype = '', $postname = '')
152
-    {
153
-        if (!function_exists('curl_file_create')) {
144
+	/**
145
+	 * @param string $filename
146
+	 * @param string $mimetype
147
+	 * @param string $postname
148
+	 *
149
+	 * @return CURLFile|string
150
+	 */
151
+	private function curl_file_create($filename, $mimetype = '', $postname = '')
152
+	{
153
+		if (!function_exists('curl_file_create')) {
154 154
 
155
-            return "@$filename;filename="
156
-                . ($postname ?: basename($filename))
157
-                . ($mimetype ? ";type=$mimetype" : '');
155
+			return "@$filename;filename="
156
+				. ($postname ?: basename($filename))
157
+				. ($mimetype ? ";type=$mimetype" : '');
158 158
 
159
-        } else {
159
+		} else {
160 160
 
161
-            return curl_file_create($filename, $mimetype, $postname);
161
+			return curl_file_create($filename, $mimetype, $postname);
162 162
 
163
-        }
164
-    }
163
+		}
164
+	}
165 165
 }
Please login to merge, or discard this patch.
includes/class-xcloner-settings.php 1 patch
Spacing   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
 	public function get_xcloner_encryption_key() {
58 58
 
59
-		if(!get_option('xcloner_encryption_key') )
59
+		if (!get_option('xcloner_encryption_key'))
60 60
 		{
61 61
 			return $this->randomString(35);
62 62
 		}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 */
73 73
 	private function randomString($length = 6) {
74 74
 		$str = "";
75
-		$characters = array_merge(range('A','Z'), range('a','z'), range('0','9'));
75
+		$characters = array_merge(range('A', 'Z'), range('a', 'z'), range('0', '9'));
76 76
 		$max = count($characters) - 1;
77 77
 		for ($i = 0; $i < $length; $i++) {
78 78
 			$rand = mt_rand(0, $max);
@@ -213,17 +213,17 @@  discard block
 block discarded – undo
213 213
 	/**
214 214
 	 * @param string $option
215 215
 	 */
216
-	public function get_xcloner_option( $option ) {
217
-		$data = get_option( $option );
216
+	public function get_xcloner_option($option) {
217
+		$data = get_option($option);
218 218
 
219 219
 		return $data;
220 220
 	}
221 221
 
222
-	public function get_server_unique_hash( $strlen = 0 ) {
223
-		$hash = md5( get_home_url() . __DIR__ );
222
+	public function get_server_unique_hash($strlen = 0) {
223
+		$hash = md5(get_home_url().__DIR__);
224 224
 
225
-		if ( $strlen ) {
226
-			$hash = substr( $hash, 0, $strlen );
225
+		if ($strlen) {
226
+			$hash = substr($hash, 0, $strlen);
227 227
 		}
228 228
 
229 229
 		return $hash;
@@ -287,287 +287,287 @@  discard block
 block discarded – undo
287 287
 		//CRON section
288 288
 		add_settings_section(
289 289
 			'xcloner_cron_settings_group',
290
-			__( ' ' ),
291
-			array( $this, 'xcloner_settings_section_cb' ),
290
+			__(' '),
291
+			array($this, 'xcloner_settings_section_cb'),
292 292
 			'xcloner_cron_settings_page'
293 293
 		);
294 294
 
295 295
 
296 296
 		//REGISTERING THE 'GENERAL SECTION' FIELDS
297
-		register_setting( 'xcloner_general_settings_group', 'xcloner_backup_compression_level', array(
297
+		register_setting('xcloner_general_settings_group', 'xcloner_backup_compression_level', array(
298 298
 			$this->xcloner_sanitization,
299 299
 			"sanitize_input_as_int"
300
-		) );
300
+		));
301 301
 		add_settings_field(
302 302
 			'xcloner_backup_compression_level',
303
-			__( 'Backup Compression Level', 'xcloner-backup-and-restore' ),
304
-			array( $this, 'do_form_range_field' ),
303
+			__('Backup Compression Level', 'xcloner-backup-and-restore'),
304
+			array($this, 'do_form_range_field'),
305 305
 			'xcloner_settings_page',
306 306
 			'xcloner_general_settings_group',
307 307
 			array(
308 308
 				'xcloner_backup_compression_level',
309
-				__( 'Options between [0-9]. Value 0 means no compression, while 9 is maximum compression affecting cpu load', 'xcloner-backup-and-restore' ),
309
+				__('Options between [0-9]. Value 0 means no compression, while 9 is maximum compression affecting cpu load', 'xcloner-backup-and-restore'),
310 310
 				0,
311 311
 				9
312 312
 			)
313 313
 		);
314 314
 
315
-		register_setting( 'xcloner_general_settings_group', 'xcloner_start_path', array(
315
+		register_setting('xcloner_general_settings_group', 'xcloner_start_path', array(
316 316
 			$this->xcloner_sanitization,
317 317
 			"sanitize_input_as_absolute_path"
318
-		) );
318
+		));
319 319
 		add_settings_field(
320 320
 			'xcloner_start_path',
321
-			__( 'Backup Start Location', 'xcloner-backup-and-restore' ),
322
-			array( $this, 'do_form_text_field' ),
321
+			__('Backup Start Location', 'xcloner-backup-and-restore'),
322
+			array($this, 'do_form_text_field'),
323 323
 			'xcloner_settings_page',
324 324
 			'xcloner_general_settings_group',
325 325
 			array(
326 326
 				'xcloner_start_path',
327
-				__( 'Base path location from where XCloner can start the Backup.', 'xcloner-backup-and-restore' ),
327
+				__('Base path location from where XCloner can start the Backup.', 'xcloner-backup-and-restore'),
328 328
 				$this->get_xcloner_start_path(),
329 329
 				//'disabled'
330 330
 			)
331 331
 		);
332 332
 
333
-		register_setting( 'xcloner_general_settings_group', 'xcloner_store_path', array(
333
+		register_setting('xcloner_general_settings_group', 'xcloner_store_path', array(
334 334
 			$this->xcloner_sanitization,
335 335
 			"sanitize_input_as_absolute_path"
336
-		) );
336
+		));
337 337
 		add_settings_field(
338 338
 			'xcloner_store_path',
339
-			__( 'Backup Storage Location', 'xcloner-backup-and-restore' ),
340
-			array( $this, 'do_form_text_field' ),
339
+			__('Backup Storage Location', 'xcloner-backup-and-restore'),
340
+			array($this, 'do_form_text_field'),
341 341
 			'xcloner_settings_page',
342 342
 			'xcloner_general_settings_group',
343 343
 			array(
344 344
 				'xcloner_store_path',
345
-				__( 'Location where XCloner will store the Backup archives.', 'xcloner-backup-and-restore' ),
345
+				__('Location where XCloner will store the Backup archives.', 'xcloner-backup-and-restore'),
346 346
 				$this->get_xcloner_store_path(),
347 347
 				//'disabled'
348 348
 			)
349 349
 		);
350 350
 
351
-		register_setting( 'xcloner_general_settings_group', 'xcloner_encryption_key', array(
351
+		register_setting('xcloner_general_settings_group', 'xcloner_encryption_key', array(
352 352
 			$this->xcloner_sanitization,
353 353
 			"sanitize_input_as_string"
354
-		) );
354
+		));
355 355
 		add_settings_field(
356 356
 			'xcloner_encryption_key',
357
-			__( 'Backup Encryption Key', 'xcloner-backup-and-restore' ),
358
-			array( $this, 'do_form_text_field' ),
357
+			__('Backup Encryption Key', 'xcloner-backup-and-restore'),
358
+			array($this, 'do_form_text_field'),
359 359
 			'xcloner_settings_page',
360 360
 			'xcloner_general_settings_group',
361 361
 			array(
362 362
 				'xcloner_encryption_key',
363
-				__( 'Backup Encryption Key used to Encrypt/Decrypt backups, you might want to save this somewhere else as well.', 'xcloner-backup-and-restore' ),
363
+				__('Backup Encryption Key used to Encrypt/Decrypt backups, you might want to save this somewhere else as well.', 'xcloner-backup-and-restore'),
364 364
 				$this->get_xcloner_encryption_key(),
365 365
 				//'disabled'
366 366
 			)
367 367
 		);
368 368
 
369
-		register_setting( 'xcloner_general_settings_group', 'xcloner_enable_log', array(
369
+		register_setting('xcloner_general_settings_group', 'xcloner_enable_log', array(
370 370
 			$this->xcloner_sanitization,
371 371
 			"sanitize_input_as_int"
372
-		) );
372
+		));
373 373
 		add_settings_field(
374 374
 			'xcloner_enable_log',
375
-			__( 'Enable XCloner Backup Log', 'xcloner-backup-and-restore' ),
376
-			array( $this, 'do_form_switch_field' ),
375
+			__('Enable XCloner Backup Log', 'xcloner-backup-and-restore'),
376
+			array($this, 'do_form_switch_field'),
377 377
 			'xcloner_settings_page',
378 378
 			'xcloner_general_settings_group',
379 379
 			array(
380 380
 				'xcloner_enable_log',
381
-				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() )
381
+				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())
382 382
 			)
383 383
 		);
384 384
 
385
-		register_setting( 'xcloner_general_settings_group', 'xcloner_enable_pre_update_backup', array(
385
+		register_setting('xcloner_general_settings_group', 'xcloner_enable_pre_update_backup', array(
386 386
 			$this->xcloner_sanitization,
387 387
 			"sanitize_input_as_int"
388
-		) );
388
+		));
389 389
 		add_settings_field(
390 390
 			'xcloner_enable_pre_update_backup',
391
-			__( 'Generate Backups before Automatic WP Upgrades', 'xcloner-backup-and-restore' ),
392
-			array( $this, 'do_form_switch_field' ),
391
+			__('Generate Backups before Automatic WP Upgrades', 'xcloner-backup-and-restore'),
392
+			array($this, 'do_form_switch_field'),
393 393
 			'xcloner_settings_page',
394 394
 			'xcloner_general_settings_group',
395 395
 			array(
396 396
 				'xcloner_enable_pre_update_backup',
397
-				sprintf( __( 'Attempt to generate a core, plugins, themes or languages files backup before the automatic update of Wordpress core, plugins, themes or languages files.', 'xcloner-backup-and-restore' ), $this->get_logger_filename() )
397
+				sprintf(__('Attempt to generate a core, plugins, themes or languages files backup before the automatic update of Wordpress core, plugins, themes or languages files.', 'xcloner-backup-and-restore'), $this->get_logger_filename())
398 398
 			)
399 399
 		);
400 400
 
401
-		register_setting( 'xcloner_general_settings_group', 'xcloner_regex_exclude', array(
401
+		register_setting('xcloner_general_settings_group', 'xcloner_regex_exclude', array(
402 402
 			$this->xcloner_sanitization,
403 403
 			"sanitize_input_as_raw"
404
-		) );
404
+		));
405 405
 		add_settings_field(
406 406
 			'xcloner_regex_exclude',
407
-			__( 'Regex Exclude Files', 'xcloner-backup-and-restore' ),
408
-			array( $this, 'do_form_textarea_field' ),
407
+			__('Regex Exclude Files', 'xcloner-backup-and-restore'),
408
+			array($this, 'do_form_textarea_field'),
409 409
 			'xcloner_settings_page',
410 410
 			'xcloner_general_settings_group',
411 411
 			array(
412 412
 				'xcloner_regex_exclude',
413
-				__( 'Regular expression match to exclude files and folders, example patterns provided below, one pattern per line', 'xcloner-backup-and-restore' ),
413
+				__('Regular expression match to exclude files and folders, example patterns provided below, one pattern per line', 'xcloner-backup-and-restore'),
414 414
 				//$this->get_xcloner_store_path(), 
415 415
 				//'disabled'
416 416
 			)
417 417
 		);
418 418
 
419 419
 		//REGISTERING THE 'MYSQL SECTION' FIELDS
420
-		register_setting( 'xcloner_mysql_settings_group', 'xcloner_enable_mysql_backup', array(
420
+		register_setting('xcloner_mysql_settings_group', 'xcloner_enable_mysql_backup', array(
421 421
 			$this->xcloner_sanitization,
422 422
 			"sanitize_input_as_int"
423
-		) );
423
+		));
424 424
 		add_settings_field(
425 425
 			'xcloner_enable_mysql_backup',
426
-			__( 'Enable Mysql Backup', 'xcloner-backup-and-restore' ),
427
-			array( $this, 'do_form_switch_field' ),
426
+			__('Enable Mysql Backup', 'xcloner-backup-and-restore'),
427
+			array($this, 'do_form_switch_field'),
428 428
 			'xcloner_mysql_settings_page',
429 429
 			'xcloner_mysql_settings_group',
430 430
 			array(
431 431
 				'xcloner_enable_mysql_backup',
432
-				__( 'Enable Mysql Backup Option. If you don\'t want to backup the database, you can disable this.', 'xcloner-backup-and-restore' )
432
+				__('Enable Mysql Backup Option. If you don\'t want to backup the database, you can disable this.', 'xcloner-backup-and-restore')
433 433
 			)
434 434
 		);
435 435
 
436
-		register_setting( 'xcloner_mysql_settings_group', 'xcloner_backup_only_wp_tables' );
436
+		register_setting('xcloner_mysql_settings_group', 'xcloner_backup_only_wp_tables');
437 437
 		add_settings_field(
438 438
 			'xcloner_backup_only_wp_tables',
439
-			__( 'Backup only WP tables', 'xcloner-backup-and-restore' ),
440
-			array( $this, 'do_form_switch_field' ),
439
+			__('Backup only WP tables', 'xcloner-backup-and-restore'),
440
+			array($this, 'do_form_switch_field'),
441 441
 			'xcloner_mysql_settings_page',
442 442
 			'xcloner_mysql_settings_group',
443 443
 			array(
444 444
 				'xcloner_backup_only_wp_tables',
445
-				sprintf( __( 'Enable this if you only want to Backup only tables starting with \'%s\' prefix', 'xcloner-backup-and-restore' ), $this->get_table_prefix() )
445
+				sprintf(__('Enable this if you only want to Backup only tables starting with \'%s\' prefix', 'xcloner-backup-and-restore'), $this->get_table_prefix())
446 446
 			)
447 447
 		);
448 448
 
449
-		register_setting( 'xcloner_mysql_settings_group', 'xcloner_mysql_hostname', array(
449
+		register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_hostname', array(
450 450
 			$this->xcloner_sanitization,
451 451
 			"sanitize_input_as_raw"
452
-		) );
452
+		));
453 453
 		add_settings_field(
454 454
 			'xcloner_mysql_hostname',
455
-			__( 'Mysql Hostname', 'xcloner-backup-and-restore' ),
456
-			array( $this, 'do_form_text_field' ),
455
+			__('Mysql Hostname', 'xcloner-backup-and-restore'),
456
+			array($this, 'do_form_text_field'),
457 457
 			'xcloner_mysql_settings_page',
458 458
 			'xcloner_mysql_settings_group',
459 459
 			array(
460 460
 				'xcloner_mysql_hostname',
461
-				__( 'Wordpress mysql hostname', 'xcloner-backup-and-restore' ),
461
+				__('Wordpress mysql hostname', 'xcloner-backup-and-restore'),
462 462
 				$this->get_db_hostname(),
463 463
 				'disabled'
464 464
 			)
465 465
 		);
466 466
 
467
-		register_setting( 'xcloner_mysql_settings_group', 'xcloner_mysql_username', array(
467
+		register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_username', array(
468 468
 			$this->xcloner_sanitization,
469 469
 			"sanitize_input_as_raw"
470
-		) );
470
+		));
471 471
 		add_settings_field(
472 472
 			'xcloner_mysql_username',
473
-			__( 'Mysql Username', 'xcloner-backup-and-restore' ),
474
-			array( $this, 'do_form_text_field' ),
473
+			__('Mysql Username', 'xcloner-backup-and-restore'),
474
+			array($this, 'do_form_text_field'),
475 475
 			'xcloner_mysql_settings_page',
476 476
 			'xcloner_mysql_settings_group',
477 477
 			array(
478 478
 				'xcloner_mysql_username',
479
-				__( 'Wordpress mysql username', 'xcloner-backup-and-restore' ),
479
+				__('Wordpress mysql username', 'xcloner-backup-and-restore'),
480 480
 				$this->get_db_username(),
481 481
 				'disabled'
482 482
 			)
483 483
 		);
484 484
 
485
-		register_setting( 'xcloner_mysql_settings_group', 'xcloner_mysql_database', array(
485
+		register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_database', array(
486 486
 			$this->xcloner_sanitization,
487 487
 			"sanitize_input_as_raw"
488
-		) );
488
+		));
489 489
 		add_settings_field(
490 490
 			'xcloner_mysql_database',
491
-			__( 'Mysql Database', 'xcloner-backup-and-restore' ),
492
-			array( $this, 'do_form_text_field' ),
491
+			__('Mysql Database', 'xcloner-backup-and-restore'),
492
+			array($this, 'do_form_text_field'),
493 493
 			'xcloner_mysql_settings_page',
494 494
 			'xcloner_mysql_settings_group',
495 495
 			array(
496 496
 				'xcloner_mysql_database',
497
-				__( 'Wordpress mysql database', 'xcloner-backup-and-restore' ),
497
+				__('Wordpress mysql database', 'xcloner-backup-and-restore'),
498 498
 				$this->get_db_database(),
499 499
 				'disabled'
500 500
 			)
501 501
 		);
502 502
 
503 503
 		//REGISTERING THE 'SYSTEM SECTION' FIELDS
504
-		register_setting( 'xcloner_system_settings_group', 'xcloner_size_limit_per_request', array(
504
+		register_setting('xcloner_system_settings_group', 'xcloner_size_limit_per_request', array(
505 505
 			$this->xcloner_sanitization,
506 506
 			"sanitize_input_as_int"
507
-		) );
507
+		));
508 508
 		add_settings_field(
509 509
 			'xcloner_size_limit_per_request',
510
-			__( 'Data Size Limit Per Request', 'xcloner-backup-and-restore' ),
511
-			array( $this, 'do_form_range_field' ),
510
+			__('Data Size Limit Per Request', 'xcloner-backup-and-restore'),
511
+			array($this, 'do_form_range_field'),
512 512
 			'xcloner_system_settings_page',
513 513
 			'xcloner_system_settings_group',
514 514
 			array(
515 515
 				'xcloner_size_limit_per_request',
516
-				__( 'Use this option to set how much file data can XCloner backup in one AJAX request. Range 0-1024 MB', 'xcloner-backup-and-restore' ),
516
+				__('Use this option to set how much file data can XCloner backup in one AJAX request. Range 0-1024 MB', 'xcloner-backup-and-restore'),
517 517
 				0,
518 518
 				1024
519 519
 			)
520 520
 		);
521 521
 
522
-		register_setting( 'xcloner_system_settings_group', 'xcloner_files_to_process_per_request', array(
522
+		register_setting('xcloner_system_settings_group', 'xcloner_files_to_process_per_request', array(
523 523
 			$this->xcloner_sanitization,
524 524
 			"sanitize_input_as_int"
525
-		) );
525
+		));
526 526
 		add_settings_field(
527 527
 			'xcloner_files_to_process_per_request',
528
-			__( 'Files To Process Per Request', 'xcloner-backup-and-restore' ),
529
-			array( $this, 'do_form_range_field' ),
528
+			__('Files To Process Per Request', 'xcloner-backup-and-restore'),
529
+			array($this, 'do_form_range_field'),
530 530
 			'xcloner_system_settings_page',
531 531
 			'xcloner_system_settings_group',
532 532
 			array(
533 533
 				'xcloner_files_to_process_per_request',
534
-				__( 'Use this option to set how many files XCloner should process at one time before doing another AJAX call', 'xcloner-backup-and-restore' ),
534
+				__('Use this option to set how many files XCloner should process at one time before doing another AJAX call', 'xcloner-backup-and-restore'),
535 535
 				0,
536 536
 				1000
537 537
 			)
538 538
 		);
539 539
 
540
-		register_setting( 'xcloner_system_settings_group', 'xcloner_directories_to_scan_per_request', array(
540
+		register_setting('xcloner_system_settings_group', 'xcloner_directories_to_scan_per_request', array(
541 541
 			$this->xcloner_sanitization,
542 542
 			"sanitize_input_as_int"
543
-		) );
543
+		));
544 544
 		add_settings_field(
545 545
 			'xcloner_directories_to_scan_per_request',
546
-			__( 'Directories To Scan Per Request', 'xcloner-backup-and-restore' ),
547
-			array( $this, 'do_form_range_field' ),
546
+			__('Directories To Scan Per Request', 'xcloner-backup-and-restore'),
547
+			array($this, 'do_form_range_field'),
548 548
 			'xcloner_system_settings_page',
549 549
 			'xcloner_system_settings_group',
550 550
 			array(
551 551
 				'xcloner_directories_to_scan_per_request',
552
-				__( 'Use this option to set how many directories XCloner should scan at one time before doing another AJAX call', 'xcloner-backup-and-restore' ),
552
+				__('Use this option to set how many directories XCloner should scan at one time before doing another AJAX call', 'xcloner-backup-and-restore'),
553 553
 				0,
554 554
 				1000
555 555
 			)
556 556
 		);
557 557
 
558
-		register_setting( 'xcloner_system_settings_group', 'xcloner_database_records_per_request', array(
558
+		register_setting('xcloner_system_settings_group', 'xcloner_database_records_per_request', array(
559 559
 			$this->xcloner_sanitization,
560 560
 			"sanitize_input_as_int"
561
-		) );
561
+		));
562 562
 		add_settings_field(
563 563
 			'xcloner_database_records_per_request',
564
-			__( 'Database Records Per Request', 'xcloner-backup-and-restore' ),
565
-			array( $this, 'do_form_range_field' ),
564
+			__('Database Records Per Request', 'xcloner-backup-and-restore'),
565
+			array($this, 'do_form_range_field'),
566 566
 			'xcloner_system_settings_page',
567 567
 			'xcloner_system_settings_group',
568 568
 			array(
569 569
 				'xcloner_database_records_per_request',
570
-				__( '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' ),
570
+				__('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'),
571 571
 				0,
572 572
 				100000
573 573
 			)
@@ -585,140 +585,140 @@  discard block
 block discarded – undo
585 585
 	         )
586 586
 	    );*/
587 587
 
588
-		register_setting( 'xcloner_system_settings_group', 'xcloner_exclude_files_larger_than_mb', array(
588
+		register_setting('xcloner_system_settings_group', 'xcloner_exclude_files_larger_than_mb', array(
589 589
 			$this->xcloner_sanitization,
590 590
 			"sanitize_input_as_int"
591
-		) );
591
+		));
592 592
 		add_settings_field(
593 593
 			'xcloner_exclude_files_larger_than_mb',
594
-			__( 'Exclude files larger than (MB)', 'xcloner-backup-and-restore' ),
595
-			array( $this, 'do_form_number_field' ),
594
+			__('Exclude files larger than (MB)', 'xcloner-backup-and-restore'),
595
+			array($this, 'do_form_number_field'),
596 596
 			'xcloner_system_settings_page',
597 597
 			'xcloner_system_settings_group',
598 598
 			array(
599 599
 				'xcloner_exclude_files_larger_than_mb',
600
-				__( 'Use this option to automatically exclude files larger than a certain size in MB, or set to 0 to include all. Range 0-1000 MB', 'xcloner-backup-and-restore' ),
600
+				__('Use this option to automatically exclude files larger than a certain size in MB, or set to 0 to include all. Range 0-1000 MB', 'xcloner-backup-and-restore'),
601 601
 			)
602 602
 		);
603 603
 
604
-		register_setting( 'xcloner_system_settings_group', 'xcloner_split_backup_limit', array(
604
+		register_setting('xcloner_system_settings_group', 'xcloner_split_backup_limit', array(
605 605
 			$this->xcloner_sanitization,
606 606
 			"sanitize_input_as_int"
607
-		) );
607
+		));
608 608
 		add_settings_field(
609 609
 			'xcloner_split_backup_limit',
610
-			__( 'Split Backup Archive Limit (MB)', 'xcloner-backup-and-restore' ),
611
-			array( $this, 'do_form_number_field' ),
610
+			__('Split Backup Archive Limit (MB)', 'xcloner-backup-and-restore'),
611
+			array($this, 'do_form_number_field'),
612 612
 			'xcloner_system_settings_page',
613 613
 			'xcloner_system_settings_group',
614 614
 			array(
615 615
 				'xcloner_split_backup_limit',
616
-				__( 'Use this option to automatically split the backup archive into smaller parts. Range  0-10000 MB', 'xcloner-backup-and-restore' ),
616
+				__('Use this option to automatically split the backup archive into smaller parts. Range  0-10000 MB', 'xcloner-backup-and-restore'),
617 617
 			)
618 618
 		);
619 619
 
620
-		register_setting( 'xcloner_system_settings_group', 'xcloner_force_tmp_path_site_root' );
620
+		register_setting('xcloner_system_settings_group', 'xcloner_force_tmp_path_site_root');
621 621
 		add_settings_field(
622 622
 			'xcloner_force_tmp_path_site_root',
623
-			__( 'Force Temporary Path Within XCloner Storage', 'xcloner-backup-and-restore' ),
624
-			array( $this, 'do_form_switch_field' ),
623
+			__('Force Temporary Path Within XCloner Storage', 'xcloner-backup-and-restore'),
624
+			array($this, 'do_form_switch_field'),
625 625
 			'xcloner_system_settings_page',
626 626
 			'xcloner_system_settings_group',
627 627
 			array(
628 628
 				'xcloner_force_tmp_path_site_root',
629
-				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() )
629
+				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())
630 630
 			)
631 631
 		);
632 632
 
633
-		register_setting( 'xcloner_system_settings_group', 'xcloner_disable_email_notification' );
633
+		register_setting('xcloner_system_settings_group', 'xcloner_disable_email_notification');
634 634
 		add_settings_field(
635 635
 			'xcloner_disable_email_notification',
636
-			__( 'Disable Email Notifications', 'xcloner-backup-and-restore' ),
637
-			array( $this, 'do_form_switch_field' ),
636
+			__('Disable Email Notifications', 'xcloner-backup-and-restore'),
637
+			array($this, 'do_form_switch_field'),
638 638
 			'xcloner_system_settings_page',
639 639
 			'xcloner_system_settings_group',
640 640
 			array(
641 641
 				'xcloner_disable_email_notification',
642
-				sprintf( __( 'Enable this option if you want the XCloner to NOT send email notifications on successful backups', 'xcloner-backup-and-restore' ), $this->get_table_prefix() )
642
+				sprintf(__('Enable this option if you want the XCloner to NOT send email notifications on successful backups', 'xcloner-backup-and-restore'), $this->get_table_prefix())
643 643
 			)
644 644
 		);
645 645
 
646 646
 		//REGISTERING THE 'CLEANUP SECTION' FIELDS
647
-		register_setting( 'xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_days', array(
647
+		register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_days', array(
648 648
 			$this->xcloner_sanitization,
649 649
 			"sanitize_input_as_int"
650
-		) );
650
+		));
651 651
 		add_settings_field(
652 652
 			'xcloner_cleanup_retention_limit_days',
653
-			__( 'Cleanup by Date(days)', 'xcloner-backup-and-restore' ),
654
-			array( $this, 'do_form_number_field' ),
653
+			__('Cleanup by Date(days)', 'xcloner-backup-and-restore'),
654
+			array($this, 'do_form_number_field'),
655 655
 			'xcloner_cleanup_settings_page',
656 656
 			'xcloner_cleanup_settings_group',
657 657
 			array(
658 658
 				'xcloner_cleanup_retention_limit_days',
659
-				__( 'Specify the maximum number of days a backup archive can be kept on the server. 0 disables this option', 'xcloner-backup-and-restore' )
659
+				__('Specify the maximum number of days a backup archive can be kept on the server. 0 disables this option', 'xcloner-backup-and-restore')
660 660
 			)
661 661
 		);
662 662
 
663
-		register_setting( 'xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_archives', array(
663
+		register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_archives', array(
664 664
 			$this->xcloner_sanitization,
665 665
 			"sanitize_input_as_int"
666
-		) );
666
+		));
667 667
 		add_settings_field(
668 668
 			'xcloner_cleanup_retention_limit_archives',
669
-			__( 'Cleanup by Quantity', 'xcloner-backup-and-restore' ),
670
-			array( $this, 'do_form_number_field' ),
669
+			__('Cleanup by Quantity', 'xcloner-backup-and-restore'),
670
+			array($this, 'do_form_number_field'),
671 671
 			'xcloner_cleanup_settings_page',
672 672
 			'xcloner_cleanup_settings_group',
673 673
 			array(
674 674
 				'xcloner_cleanup_retention_limit_archives',
675
-				__( 'Specify the maximum number of backup archives to keep on the server. 0 disables this option', 'xcloner-backup-and-restore' )
675
+				__('Specify the maximum number of backup archives to keep on the server. 0 disables this option', 'xcloner-backup-and-restore')
676 676
 			)
677 677
 		);
678 678
 
679
-		register_setting( 'xcloner_cleanup_settings_group', 'xcloner_cleanup_capacity_limit', array(
679
+		register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_capacity_limit', array(
680 680
 			$this->xcloner_sanitization,
681 681
 			"sanitize_input_as_int"
682
-		) );
682
+		));
683 683
 		add_settings_field(
684 684
 			'xcloner_cleanup_capacity_limit',
685
-			__( 'Cleanup by Capacity(MB)', 'xcloner-backup-and-restore' ),
686
-			array( $this, 'do_form_number_field' ),
685
+			__('Cleanup by Capacity(MB)', 'xcloner-backup-and-restore'),
686
+			array($this, 'do_form_number_field'),
687 687
 			'xcloner_cleanup_settings_page',
688 688
 			'xcloner_cleanup_settings_group',
689 689
 			array(
690 690
 				'xcloner_cleanup_capacity_limit',
691
-				__( 'Remove oldest backups if all created backups exceed the configured limit in Megabytes. 0 disables this option', 'xcloner-backup-and-restore' )
691
+				__('Remove oldest backups if all created backups exceed the configured limit in Megabytes. 0 disables this option', 'xcloner-backup-and-restore')
692 692
 			)
693 693
 		);
694 694
 
695
-		register_setting( 'xcloner_cleanup_settings_group', 'xcloner_cleanup_delete_after_remote_transfer', array(
695
+		register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_delete_after_remote_transfer', array(
696 696
 			$this->xcloner_sanitization,
697 697
 			"sanitize_input_as_int"
698
-		) );
698
+		));
699 699
 		add_settings_field(
700 700
 			'xcloner_cleanup_delete_after_remote_transfer',
701
-			__( 'Delete Backup After Remote Storage Transfer', 'xcloner-backup-and-restore' ),
702
-			array( $this, 'do_form_switch_field' ),
701
+			__('Delete Backup After Remote Storage Transfer', 'xcloner-backup-and-restore'),
702
+			array($this, 'do_form_switch_field'),
703 703
 			'xcloner_cleanup_settings_page',
704 704
 			'xcloner_cleanup_settings_group',
705 705
 			array(
706 706
 				'xcloner_cleanup_delete_after_remote_transfer',
707
-				__( 'Remove backup created automatically from local storage after sending the backup to Remote Storage', 'xcloner-backup-and-restore' )
707
+				__('Remove backup created automatically from local storage after sending the backup to Remote Storage', 'xcloner-backup-and-restore')
708 708
 			)
709 709
 		);
710 710
 
711 711
 		//REGISTERING THE 'CRON SECTION' FIELDS
712
-		register_setting( 'xcloner_cron_settings_group', 'xcloner_cron_frequency' );
712
+		register_setting('xcloner_cron_settings_group', 'xcloner_cron_frequency');
713 713
 		add_settings_field(
714 714
 			'xcloner_cron_frequency',
715
-			__( 'Cron frequency', 'xcloner-backup-and-restore' ),
716
-			array( $this, 'do_form_text_field' ),
715
+			__('Cron frequency', 'xcloner-backup-and-restore'),
716
+			array($this, 'do_form_text_field'),
717 717
 			'xcloner_cron_settings_page',
718 718
 			'xcloner_cron_settings_group',
719 719
 			array(
720 720
 				'xcloner_cron_frequency',
721
-				__( 'Cron frequency' )
721
+				__('Cron frequency')
722 722
 			)
723 723
 		);
724 724
 	}
Please login to merge, or discard this patch.
includes/class-xcloner-remote-storage.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -213,8 +213,7 @@
 block discarded – undo
213 213
 
214 214
 		if( $action == 'e' && function_exists('openssl_encrypt')) {
215 215
 			$output = base64_encode( openssl_encrypt( $string, $encrypt_method, $key, 0, $iv ) );
216
-		}
217
-		else if( $action == 'd' && function_exists('openssl_decrypt') && base64_decode( $string )){
216
+		} else if( $action == 'd' && function_exists('openssl_decrypt') && base64_decode( $string )){
218 217
 			$decrypt = openssl_decrypt( base64_decode( $string ), $encrypt_method, $key, 0, $iv );
219 218
 			if($decrypt) {
220 219
 				//we check if decrypt was succesful
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -162,11 +162,11 @@
 block discarded – undo
162 162
 	private $logger;
163 163
 	private $xcloner;
164 164
 
165
-    /**
166
-     * Xcloner_Remote_Storage constructor.
167
-     * @param Xcloner $xcloner_container
168
-     */
169
-    public function __construct( Xcloner $xcloner_container ) {
165
+	/**
166
+	 * Xcloner_Remote_Storage constructor.
167
+	 * @param Xcloner $xcloner_container
168
+	 */
169
+	public function __construct( Xcloner $xcloner_container ) {
170 170
 		$this->xcloner_sanitization = $xcloner_container->get_xcloner_sanitization();
171 171
 		$this->xcloner_file_system  = $xcloner_container->get_xcloner_filesystem();
172 172
 		$this->logger               = $xcloner_container->get_xcloner_logger()->withName( "xcloner_remote_storage" );
Please login to merge, or discard this patch.
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -166,26 +166,26 @@  discard block
 block discarded – undo
166 166
      * Xcloner_Remote_Storage constructor.
167 167
      * @param Xcloner $xcloner_container
168 168
      */
169
-    public function __construct( Xcloner $xcloner_container ) {
169
+    public function __construct(Xcloner $xcloner_container) {
170 170
 		$this->xcloner_sanitization = $xcloner_container->get_xcloner_sanitization();
171 171
 		$this->xcloner_file_system  = $xcloner_container->get_xcloner_filesystem();
172
-		$this->logger               = $xcloner_container->get_xcloner_logger()->withName( "xcloner_remote_storage" );
172
+		$this->logger               = $xcloner_container->get_xcloner_logger()->withName("xcloner_remote_storage");
173 173
 		$this->xcloner              = $xcloner_container;
174 174
 
175
-		foreach($this->storage_fields as $main_key=>$array){
175
+		foreach ($this->storage_fields as $main_key=>$array) {
176 176
 
177
-			if(is_array($array)) {
177
+			if (is_array($array)) {
178 178
 				foreach ($array as $key => $type) {
179 179
 
180
-					if( $type == "raw") {
181
-						add_filter("pre_update_option_" . $this->storage_fields['option_prefix'] . $key,
182
-							function ($value) {
180
+					if ($type == "raw") {
181
+						add_filter("pre_update_option_".$this->storage_fields['option_prefix'].$key,
182
+							function($value) {
183 183
 
184 184
 								return $this->simple_crypt($value, 'e');
185 185
 
186 186
 							}, 10, 1);
187 187
 
188
-						add_filter("option_" . $this->storage_fields['option_prefix'] . $key, function ($value) {
188
+						add_filter("option_".$this->storage_fields['option_prefix'].$key, function($value) {
189 189
 
190 190
 							return $this->simple_crypt($value, 'd');
191 191
 
@@ -205,22 +205,22 @@  discard block
 block discarded – undo
205 205
 	 * @param string $action
206 206
 	 * @return string
207 207
 	 */
208
-	private function simple_crypt( $string, $action = 'e' ) {
208
+	private function simple_crypt($string, $action = 'e') {
209 209
 		// you may change these values to your own
210 210
 		$secret_key = NONCE_KEY;
211 211
 		$secret_iv = NONCE_SALT;
212 212
 
213 213
 		$output = $string;
214 214
 		$encrypt_method = "AES-256-CBC";
215
-		$key = hash( 'sha256', $secret_key );
216
-		$iv = substr( hash( 'sha256', $secret_iv ), 0, 16 );
215
+		$key = hash('sha256', $secret_key);
216
+		$iv = substr(hash('sha256', $secret_iv), 0, 16);
217 217
 
218
-		if( $action == 'e' && function_exists('openssl_encrypt')) {
219
-			$output = base64_encode( openssl_encrypt( $string, $encrypt_method, $key, 0, $iv ) );
218
+		if ($action == 'e' && function_exists('openssl_encrypt')) {
219
+			$output = base64_encode(openssl_encrypt($string, $encrypt_method, $key, 0, $iv));
220 220
 		}
221
-		else if( $action == 'd' && function_exists('openssl_decrypt') && base64_decode( $string )){
222
-			$decrypt = openssl_decrypt( base64_decode( $string ), $encrypt_method, $key, 0, $iv );
223
-			if($decrypt) {
221
+		else if ($action == 'd' && function_exists('openssl_decrypt') && base64_decode($string)) {
222
+			$decrypt = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
223
+			if ($decrypt) {
224 224
 				//we check if decrypt was succesful
225 225
 				$output = $decrypt;
226 226
 			}
@@ -235,121 +235,121 @@  discard block
 block discarded – undo
235 235
 
236 236
 	public function get_available_storages() {
237 237
 		$return = array();
238
-		foreach ( $this->storage_fields as $storage => $data ) {
239
-			$check_field = $this->storage_fields["option_prefix"] . $storage . "_enable";
240
-			if ( get_option( $check_field ) ) {
241
-				$return[ $storage ] = $data['text'];
238
+		foreach ($this->storage_fields as $storage => $data) {
239
+			$check_field = $this->storage_fields["option_prefix"].$storage."_enable";
240
+			if (get_option($check_field)) {
241
+				$return[$storage] = $data['text'];
242 242
 			}
243 243
 		}
244 244
 
245 245
 		return $return;
246 246
 	}
247 247
 
248
-	public function save( $action = "ftp" ) {
249
-		if ( ! $action ) {
248
+	public function save($action = "ftp") {
249
+		if (!$action) {
250 250
 			return false;
251 251
 		}
252 252
 
253
-		$storage = $this->xcloner_sanitization->sanitize_input_as_string( $action );
254
-		$this->logger->debug( sprintf( "Saving the remote storage %s options", strtoupper( $action ) ) );
253
+		$storage = $this->xcloner_sanitization->sanitize_input_as_string($action);
254
+		$this->logger->debug(sprintf("Saving the remote storage %s options", strtoupper($action)));
255 255
 
256
-		if ( is_array( $this->storage_fields[ $storage ] ) ) {
257
-			foreach ( $this->storage_fields[ $storage ] as $field => $validation ) {
258
-				$check_field     = $this->storage_fields["option_prefix"] . $field;
259
-				$sanitize_method = "sanitize_input_as_" . $validation;
256
+		if (is_array($this->storage_fields[$storage])) {
257
+			foreach ($this->storage_fields[$storage] as $field => $validation) {
258
+				$check_field     = $this->storage_fields["option_prefix"].$field;
259
+				$sanitize_method = "sanitize_input_as_".$validation;
260 260
 
261
-				if ( ! isset( $_POST[ $check_field ] ) ) {
262
-					$_POST[ $check_field ] = 0;
261
+				if (!isset($_POST[$check_field])) {
262
+					$_POST[$check_field] = 0;
263 263
 				}
264 264
 
265
-				if ( ! method_exists( $this->xcloner_sanitization, $sanitize_method ) ) {
265
+				if (!method_exists($this->xcloner_sanitization, $sanitize_method)) {
266 266
 					$sanitize_method = "sanitize_input_as_string";
267 267
 				}
268 268
 
269
-				$sanitized_value = $this->xcloner_sanitization->$sanitize_method( stripslashes( $_POST[ $check_field ] ) );
270
-				update_option( $check_field, $sanitized_value );
269
+				$sanitized_value = $this->xcloner_sanitization->$sanitize_method(stripslashes($_POST[$check_field]));
270
+				update_option($check_field, $sanitized_value);
271 271
 			}
272 272
 
273
-			$this->xcloner->trigger_message( __( "%s storage settings saved.", 'xcloner-backup-and-restore' ), "success", $this->storage_fields[ $action ]['text'] );
273
+			$this->xcloner->trigger_message(__("%s storage settings saved.", 'xcloner-backup-and-restore'), "success", $this->storage_fields[$action]['text']);
274 274
 		}
275 275
 
276 276
 	}
277 277
 
278
-	public function check( $action = "ftp" ) {
278
+	public function check($action = "ftp") {
279 279
 		try {
280
-			$this->verify_filesystem( $action );
281
-			$this->xcloner->trigger_message( __( "%s connection is valid.", 'xcloner-backup-and-restore' ), "success", $this->storage_fields[ $action ]['text'] );
282
-			$this->logger->debug( sprintf( "Connection to remote storage %s is valid", strtoupper( $action ) ) );
283
-		} catch ( Exception $e ) {
284
-			$this->xcloner->trigger_message( "%s connection error: " . $e->getMessage(), "error", $this->storage_fields[ $action ]['text'] );
280
+			$this->verify_filesystem($action);
281
+			$this->xcloner->trigger_message(__("%s connection is valid.", 'xcloner-backup-and-restore'), "success", $this->storage_fields[$action]['text']);
282
+			$this->logger->debug(sprintf("Connection to remote storage %s is valid", strtoupper($action)));
283
+		}catch (Exception $e) {
284
+			$this->xcloner->trigger_message("%s connection error: ".$e->getMessage(), "error", $this->storage_fields[$action]['text']);
285 285
 		}
286 286
 	}
287 287
 
288 288
 	/**
289 289
 	 * @param string $storage_type
290 290
 	 */
291
-	public function verify_filesystem( $storage_type ) {
292
-		$method = "get_" . $storage_type . "_filesystem";
291
+	public function verify_filesystem($storage_type) {
292
+		$method = "get_".$storage_type."_filesystem";
293 293
 
294
-		$this->logger->info( sprintf( "Checking validity of the remote storage %s filesystem", strtoupper( $storage_type ) ) );
294
+		$this->logger->info(sprintf("Checking validity of the remote storage %s filesystem", strtoupper($storage_type)));
295 295
 
296
-		if ( ! method_exists( $this, $method ) ) {
296
+		if (!method_exists($this, $method)) {
297 297
 			return false;
298 298
 		}
299 299
 
300
-		list( $adapter, $filesystem ) = $this->$method();
300
+		list($adapter, $filesystem) = $this->$method();
301 301
 
302
-		$test_file = substr( ".xcloner_" . md5( time() ), 0, 15 );
302
+		$test_file = substr(".xcloner_".md5(time()), 0, 15);
303 303
 
304
-		if ( $storage_type == "gdrive" ) {
305
-			if ( ! is_array( $filesystem->listContents() ) ) {
306
-				throw new Exception( __( "Could not read data", 'xcloner-backup-and-restore' ) );
304
+		if ($storage_type == "gdrive") {
305
+			if (!is_array($filesystem->listContents())) {
306
+				throw new Exception(__("Could not read data", 'xcloner-backup-and-restore'));
307 307
 			}
308
-			$this->logger->debug( sprintf( "I can list data from remote storage %s", strtoupper( $storage_type ) ) );
308
+			$this->logger->debug(sprintf("I can list data from remote storage %s", strtoupper($storage_type)));
309 309
 
310 310
 			return true;
311 311
 		}
312 312
 
313 313
 		//testing write access
314
-		if ( ! $filesystem->write( $test_file, "data" ) ) {
315
-			throw new Exception( __( "Could not write data", 'xcloner-backup-and-restore' ) );
314
+		if (!$filesystem->write($test_file, "data")) {
315
+			throw new Exception(__("Could not write data", 'xcloner-backup-and-restore'));
316 316
 		}
317
-		$this->logger->debug( sprintf( "I can write data to remote storage %s", strtoupper( $storage_type ) ) );
317
+		$this->logger->debug(sprintf("I can write data to remote storage %s", strtoupper($storage_type)));
318 318
 
319 319
 		//testing read access
320
-		if ( ! $filesystem->has( $test_file ) ) {
321
-			throw new Exception( __( "Could not read data", 'xcloner-backup-and-restore' ) );
320
+		if (!$filesystem->has($test_file)) {
321
+			throw new Exception(__("Could not read data", 'xcloner-backup-and-restore'));
322 322
 		}
323
-		$this->logger->debug( sprintf( "I can read data to remote storage %s", strtoupper( $storage_type ) ) );
323
+		$this->logger->debug(sprintf("I can read data to remote storage %s", strtoupper($storage_type)));
324 324
 
325 325
 		//delete test file
326
-		if ( ! $filesystem->delete( $test_file ) ) {
327
-			throw new Exception( __( "Could not delete data", 'xcloner-backup-and-restore' ) );
326
+		if (!$filesystem->delete($test_file)) {
327
+			throw new Exception(__("Could not delete data", 'xcloner-backup-and-restore'));
328 328
 		}
329
-		$this->logger->debug( sprintf( "I can delete data to remote storage %s", strtoupper( $storage_type ) ) );
329
+		$this->logger->debug(sprintf("I can delete data to remote storage %s", strtoupper($storage_type)));
330 330
 
331 331
 		return true;
332 332
 	}
333 333
 
334
-	public function upload_backup_to_storage( $file, $storage ) {
335
-		if ( ! $this->xcloner_file_system->get_storage_filesystem()->has( $file ) ) {
336
-			$this->logger->info( sprintf( "File not found %s in local storage", $file ) );
334
+	public function upload_backup_to_storage($file, $storage) {
335
+		if (!$this->xcloner_file_system->get_storage_filesystem()->has($file)) {
336
+			$this->logger->info(sprintf("File not found %s in local storage", $file));
337 337
 
338 338
 			return false;
339 339
 		}
340 340
 
341
-		$method = "get_" . $storage . "_filesystem";
341
+		$method = "get_".$storage."_filesystem";
342 342
 
343
-		if ( ! method_exists( $this, $method ) ) {
343
+		if (!method_exists($this, $method)) {
344 344
 			return false;
345 345
 		}
346 346
 
347
-		list( $remote_storage_adapter, $remote_storage_filesystem ) = $this->$method();
347
+		list($remote_storage_adapter, $remote_storage_filesystem) = $this->$method();
348 348
 
349 349
 		//doing remote storage cleaning here
350
-		$this->clean_remote_storage( $storage, $remote_storage_filesystem );
350
+		$this->clean_remote_storage($storage, $remote_storage_filesystem);
351 351
 
352
-		$this->logger->info( sprintf( "Transferring backup %s to remote storage %s", $file, strtoupper( $storage ) ), array( "" ) );
352
+		$this->logger->info(sprintf("Transferring backup %s to remote storage %s", $file, strtoupper($storage)), array(""));
353 353
 
354 354
 		/*if(!$this->xcloner_file_system->get_storage_filesystem()->has($file))
355 355
 		{
Please login to merge, or discard this patch.
xcloner.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@
 block discarded – undo
117 117
 
118 118
 try {
119 119
 	$xcloner_plugin = run_xcloner();
120
-}catch (Exception $e) {
120
+} catch (Exception $e) {
121 121
 	echo $e->getMessage();
122 122
 }
123 123
 
Please login to merge, or discard this patch.
includes/class-xcloner-logger.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
 	private $max_logger_files = 7;
11 11
 	private $main_logger_url;
12 12
 
13
-    /**
14
-     * Xcloner_Logger constructor.
15
-     * @param Xcloner $xcloner_container
16
-     * @param string $logger_name
17
-     * @throws Exception
18
-     */
19
-    public function __construct(Xcloner $xcloner_container, $logger_name = "xcloner_logger") {
13
+	/**
14
+	 * Xcloner_Logger constructor.
15
+	 * @param Xcloner $xcloner_container
16
+	 * @param string $logger_name
17
+	 * @throws Exception
18
+	 */
19
+	public function __construct(Xcloner $xcloner_container, $logger_name = "xcloner_logger") {
20 20
 		if (!$xcloner_container->get_xcloner_settings()) {
21 21
 			$xcloner_settings = new Xcloner_Settings($xcloner_container);
22 22
 		} else {
@@ -76,18 +76,18 @@  discard block
 block discarded – undo
76 76
 		//return $this;
77 77
 	}
78 78
 
79
-    /**
80
-     * @return string|null
81
-     */
82
-    function get_main_logger_url() {
79
+	/**
80
+	 * @return string|null
81
+	 */
82
+	function get_main_logger_url() {
83 83
 		return $this->main_logger_url;
84 84
 	}
85 85
 
86
-    /**
87
-     * @param int $totalLines
88
-     * @return array|bool
89
-     */
90
-    function getLastDebugLines($totalLines = 200) {
86
+	/**
87
+	 * @param int $totalLines
88
+	 * @return array|bool
89
+	 */
90
+	function getLastDebugLines($totalLines = 200) {
91 91
 		$lines = array();
92 92
 
93 93
 		if (!file_exists($this->main_logger_url) or !is_readable($this->main_logger_url)) {
Please login to merge, or discard this patch.
admin/class-xcloner-admin.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -40,28 +40,28 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	private $version;
42 42
 
43
-    /**
44
-     * @var Xcloner
45
-     */
46
-    private $xcloner_container;
47
-
48
-    /**
49
-     * Initialize the class and set its properties.
50
-     *
51
-     * Xcloner_Admin constructor.
52
-     * @param Xcloner $xcloner_container
53
-     */
54
-    public function __construct(Xcloner $xcloner_container) {
43
+	/**
44
+	 * @var Xcloner
45
+	 */
46
+	private $xcloner_container;
47
+
48
+	/**
49
+	 * Initialize the class and set its properties.
50
+	 *
51
+	 * Xcloner_Admin constructor.
52
+	 * @param Xcloner $xcloner_container
53
+	 */
54
+	public function __construct(Xcloner $xcloner_container) {
55 55
 
56 56
 		$this->plugin_name       = $xcloner_container->get_plugin_name();
57 57
 		$this->version           = $xcloner_container->get_version();
58 58
 		$this->xcloner_container = $xcloner_container;
59 59
 	}
60 60
 
61
-    /**
62
-     * @return Xcloner
63
-     */
64
-    public function get_xcloner_container() {
61
+	/**
62
+	 * @return Xcloner
63
+	 */
64
+	public function get_xcloner_container() {
65 65
 		return $this->xcloner_container;
66 66
 	}
67 67
 
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 
145 145
 	}
146 146
 
147
-    /**
148
-     * Returns the XCloner Storage Page
149
-     */
150
-    public function xcloner_remote_storage_page() {
147
+	/**
148
+	 * Returns the XCloner Storage Page
149
+	 */
150
+	public function xcloner_remote_storage_page() {
151 151
 		$xcloner_sanitization = $this->get_xcloner_container()->get_xcloner_sanitization();
152 152
 		$remote_storage       = $this->get_xcloner_container()->get_xcloner_remote_storage();
153 153
 
Please login to merge, or discard this patch.
includes/class-xcloner-api.php 3 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 	}
107 107
 
108 108
 
109
-    /**
110
-     * Checks API access
111
-     */
112
-    private function check_access()
109
+	/**
110
+	 * Checks API access
111
+	 */
112
+	private function check_access()
113 113
 	{
114 114
 		if (function_exists('current_user_can') && !current_user_can('manage_options')) {
115
-            $this->send_response(json_encode("Not allowed access here!"));
115
+			$this->send_response(json_encode("Not allowed access here!"));
116 116
 		}
117 117
 	}
118 118
 
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
      */
292 292
 	public function backup_files()
293 293
 	{
294
-        $return = array();
295
-        $additional = array();
294
+		$return = array();
295
+		$additional = array();
296 296
 
297 297
 		$this->check_access();
298 298
 
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
      */
357 357
 	public function backup_database()
358 358
 	{
359
-        $data = array();
359
+		$data = array();
360 360
 
361 361
 		$this->check_access();
362 362
 
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
      */
393 393
 	public function scan_filesystem()
394 394
 	{
395
-        $data = array();
395
+		$data = array();
396 396
 
397 397
 		$this->check_access();
398 398
 
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 		$init = (int)$_POST['init'];
401 401
 
402 402
 		if ($params === null) {
403
-            $this->send_response('{"status":false,"msg":"The post_data parameter must be valid JSON"}');
403
+			$this->send_response('{"status":false,"msg":"The post_data parameter must be valid JSON"}');
404 404
 		}
405 405
 
406 406
 		$this->process_params($params);
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
      */
678 678
 	public function get_scheduler_list()
679 679
 	{
680
-        $return = array();
680
+		$return = array();
681 681
 
682 682
 		$this->check_access();
683 683
 
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
      */
762 762
 	public function delete_schedule_by_id()
763 763
 	{
764
-        $data = array();
764
+		$data = array();
765 765
 
766 766
 		$this->check_access();
767 767
 
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
      */
780 780
 	public function delete_backup_by_name()
781 781
 	{
782
-        $data = array();
782
+		$data = array();
783 783
 
784 784
 		$this->check_access();
785 785
 
@@ -928,9 +928,9 @@  discard block
 block discarded – undo
928 928
 
929 929
 	public function get_manage_backups_list() {
930 930
 
931
-        $this->check_access();
931
+		$this->check_access();
932 932
 
933
-        $return = array();
933
+		$return = array();
934 934
 		$storage_selection = "";
935 935
 
936 936
 		if (isset($_GET['storage_selection']) and $_GET['storage_selection']) {
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 		$this->check_access();
1114 1114
 
1115 1115
 		$backup_parts = array();
1116
-        $return = array();
1116
+		$return = array();
1117 1117
 
1118 1118
 		$source_backup_file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
1119 1119
 		$start = $this->xcloner_sanitization->sanitize_input_as_int($_POST['start']);
@@ -1225,7 +1225,7 @@  discard block
 block discarded – undo
1225 1225
 	{
1226 1226
 		$this->check_access();
1227 1227
 
1228
-        $return = array();
1228
+		$return = array();
1229 1229
 
1230 1230
 		$backup_file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
1231 1231
 		$storage_type = $this->xcloner_sanitization->sanitize_input_as_string($_POST['storage_type']);
@@ -1264,7 +1264,7 @@  discard block
 block discarded – undo
1264 1264
 	{
1265 1265
 		$this->check_access();
1266 1266
 
1267
-        $return = array();
1267
+		$return = array();
1268 1268
 
1269 1269
 		$xcloner_remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage();
1270 1270
 
@@ -1334,10 +1334,10 @@  discard block
 block discarded – undo
1334 1334
 		}
1335 1335
 
1336 1336
 		try {
1337
-            unlink($tmp_file);
1338
-        }catch(Exception $e) {
1339
-		    //We are not interested in the error here
1340
-        }
1337
+			unlink($tmp_file);
1338
+		}catch(Exception $e) {
1339
+			//We are not interested in the error here
1340
+		}
1341 1341
 
1342 1342
 		die();
1343 1343
 	}
@@ -1378,7 +1378,7 @@  discard block
 block discarded – undo
1378 1378
 		}
1379 1379
 		fclose($read_stream);
1380 1380
 
1381
-        wp_die();
1381
+		wp_die();
1382 1382
 
1383 1383
 	}
1384 1384
 
@@ -1389,7 +1389,7 @@  discard block
 block discarded – undo
1389 1389
 	{
1390 1390
 		$this->check_access();
1391 1391
 
1392
-        $return = array();
1392
+		$return = array();
1393 1393
 
1394 1394
 		$return['part'] = 0;
1395 1395
 		$return['total_parts'] = 0;
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		$this->xcloner_remote_storage   = $xcloner_container->get_xcloner_remote_storage();
91 91
 
92 92
 		if (isset($_POST['API_ID'])) {
93
-			$this->logger->info("Processing ajax request ID " . substr($this->xcloner_sanitization->sanitize_input_as_string($_POST['API_ID']),
93
+			$this->logger->info("Processing ajax request ID ".substr($this->xcloner_sanitization->sanitize_input_as_string($_POST['API_ID']),
94 94
 					0, 15));
95 95
 		}
96 96
 
@@ -131,13 +131,13 @@  discard block
 block discarded – undo
131 131
 
132 132
 
133 133
 		$data['recordsPerSession'] = $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request');
134
-		$data['TEMP_DBPROCESS_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path() . DS . ".database";
135
-		$data['TEMP_DUMP_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path() . DS . "database-sql.sql";
134
+		$data['TEMP_DBPROCESS_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path().DS.".database";
135
+		$data['TEMP_DUMP_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path().DS."database-sql.sql";
136 136
 
137 137
 		try {
138 138
 			$this->xcloner_database->init($data);
139 139
 
140
-		} catch (Exception $e) {
140
+		}catch (Exception $e) {
141 141
 
142 142
 			$this->send_response($e->getMessage());
143 143
 			$this->logger->error($e->getMessage());
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 		} else {
224 224
 
225 225
 			$schedule['status'] = 1;
226
-			$schedule['start_at'] = strtotime($this->form_params['backup_params']['schedule_start_date'] .
227
-				" " . $this->form_params['backup_params']['schedule_start_time']);
226
+			$schedule['start_at'] = strtotime($this->form_params['backup_params']['schedule_start_date'].
227
+				" ".$this->form_params['backup_params']['schedule_start_time']);
228 228
 
229 229
 			if ($schedule['start_at'] <= time()) {
230 230
 				$schedule['start_at'] = "";
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
 		if (!isset($_POST['id'])) {
251 251
 			$wpdb->insert(
252
-				$wpdb->prefix . 'xcloner_scheduler',
252
+				$wpdb->prefix.'xcloner_scheduler',
253 253
 				$schedule,
254 254
 				array(
255 255
 					'%s',
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 			);
259 259
 		} else {
260 260
 			$wpdb->update(
261
-				$wpdb->prefix . 'xcloner_scheduler',
261
+				$wpdb->prefix.'xcloner_scheduler',
262 262
 				$schedule,
263 263
 				array('id' => $_POST['id']),
264 264
 				array(
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 		try {
313 313
 			$return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'],
314 314
 				$this->form_params['extra'], $init);
315
-		} catch (Exception $e) {
315
+		}catch (Exception $e) {
316 316
 			$return = array();
317 317
 			$return['error'] = true;
318 318
 			$return['status'] = 500;
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 					$additional['lines_total'] = $return['extra']['lines_total'];
340 340
 					$this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'],
341 341
 						$this->form_params, "", $additional);
342
-				} catch (Exception $e) {
342
+				}catch (Exception $e) {
343 343
 					$this->logger->error($e->getMessage());
344 344
 				}
345 345
 			}
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 		if (isset($params->backup_params)) {
438 438
 			foreach ($params->backup_params as $param) {
439 439
 				$this->form_params['backup_params'][$param->name] = $this->xcloner_sanitization->sanitize_input_as_string($param->value);
440
-				$this->logger->debug("Adding form parameter " . $param->name . "." . $param->value . "\n", array(
440
+				$this->logger->debug("Adding form parameter ".$param->name.".".$param->value."\n", array(
441 441
 					'POST',
442 442
 					'fields filter'
443 443
 				));
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 		if (isset($params->table_params)) {
450 450
 			foreach ($params->table_params as $param) {
451 451
 				$this->form_params['database'][$param->parent][] = $this->xcloner_sanitization->sanitize_input_as_raw($param->id);
452
-				$this->logger->debug("Adding database filter " . $param->parent . "." . $param->id . "\n", array(
452
+				$this->logger->debug("Adding database filter ".$param->parent.".".$param->id."\n", array(
453 453
 					'POST',
454 454
 					'database filter'
455 455
 				));
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 				if (!in_array($param->parent, $this->form_params['excluded_files'])) {
469 469
 					//$this->form_params['excluded_files'][] = $this->xcloner_sanitization->sanitize_input_as_relative_path($param->id);
470 470
 					$unique_exclude_files[] = $param->id;
471
-					$this->logger->debug("Adding file filter " . $param->id . "\n", array(
471
+					$this->logger->debug("Adding file filter ".$param->id."\n", array(
472 472
 						'POST',
473 473
 						'exclude files filter'
474 474
 					));
@@ -516,13 +516,13 @@  discard block
 block discarded – undo
516 516
 				'text' => $this->xcloner_settings->get_xcloner_start_path(),
517 517
 				//'children' => true,
518 518
 				'state' => array('selected' => false, 'opened' => true),
519
-				'icon' => plugin_dir_url(dirname(__FILE__)) . "/admin/assets/file-icon-root.png"
519
+				'icon' => plugin_dir_url(dirname(__FILE__))."/admin/assets/file-icon-root.png"
520 520
 			);
521 521
 		}
522 522
 
523 523
 		try {
524 524
 			$files = $this->xcloner_file_system->list_directory($folder);
525
-		} catch (Exception $e) {
525
+		}catch (Exception $e) {
526 526
 
527 527
 			print $e->getMessage();
528 528
 			$this->logger->error($e->getMessage());
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 			if ($file['type'] == "dir") {
544 544
 				$children = true;
545 545
 			} else {
546
-				$text .= " (" . $this->xcloner_requirements->file_format_size($file['size']) . ")";
546
+				$text .= " (".$this->xcloner_requirements->file_format_size($file['size']).")";
547 547
 			}
548 548
 
549 549
 			if ($this->xcloner_file_system->is_excluded($file)) {
@@ -559,8 +559,8 @@  discard block
 block discarded – undo
559 559
 				//'title' => "test",
560 560
 				'children' => $children,
561 561
 				'state' => array('selected' => $selected, 'opened' => false, "checkbox_disabled" => $selected),
562
-				'icon' => plugin_dir_url(dirname(__FILE__)) . "/admin/assets/file-icon-" . strtolower(substr($file['type'],
563
-						0, 1)) . ".png"
562
+				'icon' => plugin_dir_url(dirname(__FILE__))."/admin/assets/file-icon-".strtolower(substr($file['type'],
563
+						0, 1)).".png"
564 564
 			);
565 565
 		}
566 566
 
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 		if ($database == "#") {
587 587
 			try {
588 588
 				$return = $this->xcloner_database->get_all_databases();
589
-			} catch (Exception $e) {
589
+			}catch (Exception $e) {
590 590
 				$this->logger->error($e->getMessage());
591 591
 			}
592 592
 
@@ -607,10 +607,10 @@  discard block
 block discarded – undo
607 607
 				$data[] = array(
608 608
 					'id' => $database['name'],
609 609
 					'parent' => '#',
610
-					'text' => $database['name'] . " (" . (int)$database['num_tables'] . ")",
610
+					'text' => $database['name']." (".(int)$database['num_tables'].")",
611 611
 					'children' => true,
612 612
 					'state' => $state,
613
-					'icon' => plugin_dir_url(dirname(__FILE__)) . "/admin/assets/database-icon.png"
613
+					'icon' => plugin_dir_url(dirname(__FILE__))."/admin/assets/database-icon.png"
614 614
 				);
615 615
 			}
616 616
 
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 
619 619
 			try {
620 620
 				$return = $this->xcloner_database->list_tables($database, "", 1);
621
-			} catch (Exception $e) {
621
+			}catch (Exception $e) {
622 622
 				$this->logger->error($e->getMessage());
623 623
 			}
624 624
 
@@ -635,12 +635,12 @@  discard block
 block discarded – undo
635 635
 				}
636 636
 
637 637
 				$data[] = array(
638
-					'id' => $database . "." . $table['name'],
638
+					'id' => $database.".".$table['name'],
639 639
 					'parent' => $database,
640
-					'text' => $table['name'] . " (" . (int)$table['records'] . ")",
640
+					'text' => $table['name']." (".(int)$table['records'].")",
641 641
 					'children' => false,
642 642
 					'state' => $state,
643
-					'icon' => plugin_dir_url(dirname(__FILE__)) . "/admin/assets/table-icon.png"
643
+					'icon' => plugin_dir_url(dirname(__FILE__))."/admin/assets/table-icon.png"
644 644
 				);
645 645
 			}
646 646
 		}
@@ -686,17 +686,17 @@  discard block
 block discarded – undo
686 686
 		$return['data'] = array();
687 687
 
688 688
 		foreach ($data as $res) {
689
-			$action = "<a href=\"#" . $res->id . "\" class=\"edit\" title='Edit'> <i class=\"material-icons \">edit</i></a>
690
-					<a href=\"#" . $res->id . "\" class=\"delete\" title='Delete'><i class=\"material-icons  \">delete</i></a>";
689
+			$action = "<a href=\"#".$res->id."\" class=\"edit\" title='Edit'> <i class=\"material-icons \">edit</i></a>
690
+					<a href=\"#" . $res->id."\" class=\"delete\" title='Delete'><i class=\"material-icons  \">delete</i></a>";
691 691
 			if ($res->status) {
692 692
 				$status = '<i class="material-icons active status">timer</i>';
693 693
 			} else {
694 694
 				$status = '<i class="material-icons status inactive">timer_off</i>';
695 695
 			}
696 696
 
697
-			$next_run_time = wp_next_scheduled('xcloner_scheduler_' . $res->id, array($res->id));
697
+			$next_run_time = wp_next_scheduled('xcloner_scheduler_'.$res->id, array($res->id));
698 698
 
699
-			$next_run = date(get_option('date_format') . " " . get_option('time_format'), $next_run_time);
699
+			$next_run = date(get_option('date_format')." ".get_option('time_format'), $next_run_time);
700 700
 
701 701
 			$remote_storage = $res->remote_storage;
702 702
 
@@ -705,16 +705,16 @@  discard block
 block discarded – undo
705 705
 			}
706 706
 
707 707
 			if (trim($next_run)) {
708
-				$date_text = date(get_option('date_format') . " " . get_option('time_format'),
708
+				$date_text = date(get_option('date_format')." ".get_option('time_format'),
709 709
 					$next_run_time + (get_option('gmt_offset') * HOUR_IN_SECONDS));
710 710
 
711 711
 				if ($next_run_time >= time()) {
712
-					$next_run = "in " . human_time_diff($next_run_time, time());
712
+					$next_run = "in ".human_time_diff($next_run_time, time());
713 713
 				} else {
714 714
 					$next_run = __("executed", 'xcloner-backup-and-restore');
715 715
 				}
716 716
 
717
-				$next_run = "<a href='#' title='" . $date_text . "'>" . $next_run . "</a>";
717
+				$next_run = "<a href='#' title='".$date_text."'>".$next_run."</a>";
718 718
 				//$next_run .=" ($date_text)";
719 719
 			}
720 720
 
@@ -726,11 +726,11 @@  discard block
 block discarded – undo
726 726
 				if ($this->xcloner_file_system->get_storage_filesystem()->has($res->last_backup)) {
727 727
 					$metadata = $this->xcloner_file_system->get_storage_filesystem()->getMetadata($res->last_backup);
728 728
 					$backup_size = size_format($this->xcloner_file_system->get_backup_size($res->last_backup));
729
-					$backup_time = date(get_option('date_format') . " " . get_option('time_format'),
729
+					$backup_time = date(get_option('date_format')." ".get_option('time_format'),
730 730
 						$metadata['timestamp'] + (get_option('gmt_offset') * HOUR_IN_SECONDS));
731 731
 				}
732 732
 
733
-				$backup_text = "<span title='" . $backup_time . "' class='shorten_string'>" . $res->last_backup . " (" . $backup_size . ")</span>";
733
+				$backup_text = "<span title='".$backup_time."' class='shorten_string'>".$res->last_backup." (".$backup_size.")</span>";
734 734
 			}
735 735
 
736 736
 			$schedules = wp_get_schedules();
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 			$return['data'][] = array(
743 743
 				$res->id,
744 744
 				$res->name,
745
-				$res->recurrence,/*$res->start_at,*/
745
+				$res->recurrence, /*$res->start_at,*/
746 746
 				$next_run,
747 747
 				$remote_storage,
748 748
 				$backup_text,
@@ -808,25 +808,25 @@  discard block
 block discarded – undo
808 808
 			$this->process_params($params);
809 809
 			$source_backup_file = $this->xcloner_sanitization->sanitize_input_as_string($this->form_params['extra']['backup_parent']);
810 810
 
811
-			if(isset($this->form_params['extra']['start'])) {
811
+			if (isset($this->form_params['extra']['start'])) {
812 812
 				$start = $this->xcloner_sanitization->sanitize_input_as_int($this->form_params['extra']['start']);
813
-			}else{
813
+			} else {
814 814
 				$start = 0;
815 815
 			}
816 816
 
817
-			if(isset($this->form_params['extra']['iv'])) {
817
+			if (isset($this->form_params['extra']['iv'])) {
818 818
 				$iv = $this->xcloner_sanitization->sanitize_input_as_raw($this->form_params['extra']['iv']);
819
-			}else{
819
+			} else {
820 820
 				$iv = "";
821 821
 			}
822 822
 
823
-			if(isset($this->form_params['extra']['part'])) {
823
+			if (isset($this->form_params['extra']['part'])) {
824 824
 				$return['part'] = (int)$this->xcloner_sanitization->sanitize_input_as_int($this->form_params['extra']['part']);
825
-			}else{
825
+			} else {
826 826
 				$return['part'] = 0;
827 827
 			}
828 828
 
829
-		}else{
829
+		} else {
830 830
 			$source_backup_file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
831 831
 			$start = $this->xcloner_sanitization->sanitize_input_as_int($_POST['start']);
832 832
 			$iv = $this->xcloner_sanitization->sanitize_input_as_raw($_POST['iv']);
@@ -841,14 +841,14 @@  discard block
 block discarded – undo
841 841
 		}
842 842
 
843 843
 		$return['processing_file'] = $backup_file;
844
-		$return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path() . DS . $backup_file);
844
+		$return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file);
845 845
 
846 846
 		try {
847 847
 			$this->logger->info(json_encode($_POST));
848 848
 			$this->logger->info($iv);
849 849
 			$return = array_merge($return,
850 850
 				$this->xcloner_encryption->encrypt_file($backup_file, "", "", $start, base64_decode($iv)));
851
-		}catch(\Exception $e){
851
+		}catch (\Exception $e) {
852 852
 			$return['error'] = true;
853 853
 			$return['message'] = $e->getMessage();
854 854
 			$return['error_message'] = $e->getMessage();
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 
857 857
 		//echo strlen($return['iv']);exit;
858 858
 
859
-		if($return['finished']) {
859
+		if ($return['finished']) {
860 860
 			if ($this->xcloner_file_system->is_multipart($source_backup_file)) {
861 861
 				$return['start'] = 0;
862 862
 
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
 		}
871 871
 
872 872
 		if (isset($_POST['data'])) {
873
-			$return['extra'] = array_merge($this->form_params['extra'],  $return);
873
+			$return['extra'] = array_merge($this->form_params['extra'], $return);
874 874
 		}
875 875
 
876 876
 		$this->send_response($return, 0);
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 		$source_backup_file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
890 890
 		$start = $this->xcloner_sanitization->sanitize_input_as_int($_POST['start']);
891 891
 		$iv = $this->xcloner_sanitization->sanitize_input_as_raw($_POST['iv']);
892
-		$decryption_key = $this->xcloner_sanitization->sanitize_input_as_raw($_POST['decryption_key']);;
892
+		$decryption_key = $this->xcloner_sanitization->sanitize_input_as_raw($_POST['decryption_key']); ;
893 893
 		$return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
894 894
 
895 895
 		$backup_file = $source_backup_file;
@@ -900,17 +900,17 @@  discard block
 block discarded – undo
900 900
 		}
901 901
 
902 902
 		$return['processing_file'] = $backup_file;
903
-		$return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path() . DS . $backup_file);
903
+		$return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file);
904 904
 
905 905
 		try {
906 906
 			$return = array_merge($return,
907 907
 				$this->xcloner_encryption->decrypt_file($backup_file, "", $decryption_key, $start, base64_decode($iv)));
908
-		}catch(\Exception $e){
908
+		}catch (\Exception $e) {
909 909
 			$return['error'] = true;
910 910
 			$return['message'] = $e->getMessage();
911 911
 		}
912 912
 
913
-		if($return['finished']) {
913
+		if ($return['finished']) {
914 914
 			if ($this->xcloner_file_system->is_multipart($source_backup_file)) {
915 915
 				$return['start'] = 0;
916 916
 
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 		foreach ($backup_list as $file_info):?>
945 945
             <?php
946 946
 			if ($storage_selection == "gdrive") {
947
-				$file_info['path'] = $file_info['filename'] . "." . $file_info['extension'];
947
+				$file_info['path'] = $file_info['filename'].".".$file_info['extension'];
948 948
 			}
949 949
 			$file_exists_on_local_storage = true;
950 950
 
@@ -1065,10 +1065,10 @@  discard block
 block discarded – undo
1065 1065
                             <?php endif ?>
1066 1066
                             <?php
1067 1067
 							$basename = $file_info['basename'];
1068
-							if(isset($file_info['childs']) and sizeof($file_info['childs']))
1068
+							if (isset($file_info['childs']) and sizeof($file_info['childs']))
1069 1069
 								$basename = $file_info['childs'][0][0];
1070 1070
 							?>
1071
-                            <?php if($this->xcloner_encryption->is_encrypted_file($basename)) :?>
1071
+                            <?php if ($this->xcloner_encryption->is_encrypted_file($basename)) :?>
1072 1072
                                 <a href="#<?php echo $file_info['basename'] ?>" class="backup-decryption"
1073 1073
                                    title="<?php echo __('Backup Decryption', 'xcloner-backup-and-restore') ?>">
1074 1074
                                     <i class="material-icons">enhanced_encryption</i>
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
 			$backup_file = $backup_parts[$return['part']];
1127 1127
 		}
1128 1128
 
1129
-		if($this->xcloner_encryption->is_encrypted_file($backup_file)) {
1129
+		if ($this->xcloner_encryption->is_encrypted_file($backup_file)) {
1130 1130
 			$return['error'] = true;
1131 1131
 			$return['message'] = __("Backup archive is encrypted, please decrypt it first before you can list it's content.", "xcloner-backup-and-restore");
1132 1132
 			$this->send_response($return, 0);
@@ -1134,10 +1134,10 @@  discard block
 block discarded – undo
1134 1134
 
1135 1135
 		try {
1136 1136
 			$tar = new Tar();
1137
-			$tar->open($this->xcloner_settings->get_xcloner_store_path() . DS . $backup_file, $start);
1137
+			$tar->open($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file, $start);
1138 1138
 
1139 1139
 			$data = $tar->contents(get_option('xcloner_files_to_process_per_request'));
1140
-		} catch (Exception $e) {
1140
+		}catch (Exception $e) {
1141 1141
 			$return['error'] = true;
1142 1142
 			$return['message'] = $e->getMessage();
1143 1143
 			$this->send_response($return, 0);
@@ -1145,14 +1145,14 @@  discard block
 block discarded – undo
1145 1145
 
1146 1146
 		$return['files'] = array();
1147 1147
 		$return['finished'] = 1;
1148
-		$return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path() . DS . $backup_file);
1148
+		$return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file);
1149 1149
 		$i = 0;
1150 1150
 
1151 1151
 		if (isset($data['extracted_files']) and is_array($data['extracted_files'])) {
1152 1152
 			foreach ($data['extracted_files'] as $file) {
1153 1153
 				$return['files'][$i]['path'] = $file->getPath();
1154 1154
 				$return['files'][$i]['size'] = $file->getSize();
1155
-				$return['files'][$i]['mtime'] = date(get_option('date_format') . " " . get_option('time_format'),
1155
+				$return['files'][$i]['mtime'] = date(get_option('date_format')." ".get_option('time_format'),
1156 1156
 					$file->getMtime());
1157 1157
 
1158 1158
 				$i++;
@@ -1200,7 +1200,7 @@  discard block
 block discarded – undo
1200 1200
 					"copy_backup_remote_to_local"
1201 1201
 				), array($backup_file, $storage_type));
1202 1202
 			}
1203
-		} catch (Exception $e) {
1203
+		}catch (Exception $e) {
1204 1204
 
1205 1205
 			$return['error'] = 1;
1206 1206
 			$return['message'] = $e->getMessage();
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
 					"upload_backup_to_storage"
1240 1240
 				), array($backup_file, $storage_type));
1241 1241
 			}
1242
-		} catch (Exception $e) {
1242
+		}catch (Exception $e) {
1243 1243
 
1244 1244
 			$return['error'] = 1;
1245 1245
 			$return['message'] = $e->getMessage();
@@ -1301,21 +1301,21 @@  discard block
 block discarded – undo
1301 1301
         $phar2->setStub($phar2->createDefaultStub('vendor/autoload.php', 'vendor/autoload.php'));
1302 1302
          * */
1303 1303
 
1304
-		$tmp_file = $this->xcloner_settings->get_xcloner_tmp_path() . DS . "xcloner-restore.tgz";
1304
+		$tmp_file = $this->xcloner_settings->get_xcloner_tmp_path().DS."xcloner-restore.tgz";
1305 1305
 
1306 1306
 		$tar = new Tar();
1307 1307
 		$tar->create($tmp_file);
1308 1308
 
1309
-		$tar->addFile(dirname(__DIR__) . "/restore/vendor.build.txt", "vendor.phar");
1309
+		$tar->addFile(dirname(__DIR__)."/restore/vendor.build.txt", "vendor.phar");
1310 1310
 		//$tar->addFile(dirname(__DIR__)."/restore/vendor.tgz", "vendor.tgz");
1311 1311
 
1312 1312
 		$files = $xcloner_plugin_filesystem->listContents("vendor/", true);
1313 1313
 		foreach ($files as $file) {
1314
-			$tar->addFile(dirname(__DIR__) . DS . $file['path'], $file['path']);
1314
+			$tar->addFile(dirname(__DIR__).DS.$file['path'], $file['path']);
1315 1315
 		}
1316 1316
 
1317
-		$content = file_get_contents(dirname(__DIR__) . "/restore/xcloner_restore.php");
1318
-		$content = str_replace("define('AUTH_KEY', '');", "define('AUTH_KEY', '" . md5(AUTH_KEY) . "');", $content);
1317
+		$content = file_get_contents(dirname(__DIR__)."/restore/xcloner_restore.php");
1318
+		$content = str_replace("define('AUTH_KEY', '');", "define('AUTH_KEY', '".md5(AUTH_KEY)."');", $content);
1319 1319
 
1320 1320
 		$tar->addData("xcloner_restore.php", $content);
1321 1321
 
@@ -1324,18 +1324,18 @@  discard block
 block discarded – undo
1324 1324
 		if (file_exists($tmp_file)) {
1325 1325
 			header('Content-Description: File Transfer');
1326 1326
 			header('Content-Type: application/octet-stream');
1327
-			header('Content-Disposition: attachment; filename="' . basename($tmp_file) . '"');
1327
+			header('Content-Disposition: attachment; filename="'.basename($tmp_file).'"');
1328 1328
 			header('Expires: 0');
1329 1329
 			header('Cache-Control: must-revalidate');
1330 1330
 			header('Pragma: public');
1331
-			header('Content-Length: ' . filesize($tmp_file));
1331
+			header('Content-Length: '.filesize($tmp_file));
1332 1332
 			readfile($tmp_file);
1333 1333
 
1334 1334
 		}
1335 1335
 
1336 1336
 		try {
1337 1337
             unlink($tmp_file);
1338
-        }catch(Exception $e) {
1338
+        }catch (Exception $e) {
1339 1339
 		    //We are not interested in the error here
1340 1340
         }
1341 1341
 
@@ -1365,9 +1365,9 @@  discard block
 block discarded – undo
1365 1365
 		header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
1366 1366
 		header('Cache-Control: private', false);
1367 1367
 		header('Content-Transfer-Encoding: binary');
1368
-		header('Content-Disposition: attachment; filename="' . $metadata['path'] . '";');
1368
+		header('Content-Disposition: attachment; filename="'.$metadata['path'].'";');
1369 1369
 		header('Content-Type: application/octet-stream');
1370
-		header('Content-Length: ' . $metadata['size']);
1370
+		header('Content-Length: '.$metadata['size']);
1371 1371
 
1372 1372
 		ob_end_clean();
1373 1373
 
@@ -1430,12 +1430,12 @@  discard block
 block discarded – undo
1430 1430
 			$xcloner_file_transfer->set_target($target_url);
1431 1431
 			$return['start'] = $xcloner_file_transfer->transfer_file($file, $start, $hash);
1432 1432
 
1433
-		} catch (Exception $e) {
1433
+		}catch (Exception $e) {
1434 1434
 
1435 1435
 			$return = array();
1436 1436
 			$return['error'] = true;
1437 1437
 			$return['status'] = 500;
1438
-			$return['message'] = "CURL communication error with the restore host. " . $e->getMessage();
1438
+			$return['message'] = "CURL communication error with the restore host. ".$e->getMessage();
1439 1439
 			$this->send_response($return, 0);
1440 1440
 
1441 1441
 		}
@@ -1459,7 +1459,7 @@  discard block
 block discarded – undo
1459 1459
 		$this->check_access();
1460 1460
 
1461 1461
 		define("XCLONER_PLUGIN_ACCESS", 1);
1462
-		include_once(dirname(__DIR__) . DS . "restore" . DS . "xcloner_restore.php");
1462
+		include_once(dirname(__DIR__).DS."restore".DS."xcloner_restore.php");
1463 1463
 
1464 1464
 		return;
1465 1465
 	}
Please login to merge, or discard this patch.
Braces   +22 added lines, -14 removed lines patch added patch discarded remove patch
@@ -810,23 +810,23 @@  discard block
 block discarded – undo
810 810
 
811 811
 			if(isset($this->form_params['extra']['start'])) {
812 812
 				$start = $this->xcloner_sanitization->sanitize_input_as_int($this->form_params['extra']['start']);
813
-			}else{
813
+			} else{
814 814
 				$start = 0;
815 815
 			}
816 816
 
817 817
 			if(isset($this->form_params['extra']['iv'])) {
818 818
 				$iv = $this->xcloner_sanitization->sanitize_input_as_raw($this->form_params['extra']['iv']);
819
-			}else{
819
+			} else{
820 820
 				$iv = "";
821 821
 			}
822 822
 
823 823
 			if(isset($this->form_params['extra']['part'])) {
824 824
 				$return['part'] = (int)$this->xcloner_sanitization->sanitize_input_as_int($this->form_params['extra']['part']);
825
-			}else{
825
+			} else{
826 826
 				$return['part'] = 0;
827 827
 			}
828 828
 
829
-		}else{
829
+		} else{
830 830
 			$source_backup_file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
831 831
 			$start = $this->xcloner_sanitization->sanitize_input_as_int($_POST['start']);
832 832
 			$iv = $this->xcloner_sanitization->sanitize_input_as_raw($_POST['iv']);
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
 			$this->logger->info($iv);
849 849
 			$return = array_merge($return,
850 850
 				$this->xcloner_encryption->encrypt_file($backup_file, "", "", $start, base64_decode($iv)));
851
-		}catch(\Exception $e){
851
+		} catch(\Exception $e){
852 852
 			$return['error'] = true;
853 853
 			$return['message'] = $e->getMessage();
854 854
 			$return['error_message'] = $e->getMessage();
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
 		try {
906 906
 			$return = array_merge($return,
907 907
 				$this->xcloner_encryption->decrypt_file($backup_file, "", $decryption_key, $start, base64_decode($iv)));
908
-		}catch(\Exception $e){
908
+		} catch(\Exception $e){
909 909
 			$return['error'] = true;
910 910
 			$return['message'] = $e->getMessage();
911 911
 		}
@@ -1009,7 +1009,8 @@  discard block
 block discarded – undo
1009 1009
                                                    title="<?php echo __('Backup Decryption', 'xcloner-backup-and-restore') ?>">
1010 1010
                                                     <i class="material-icons">enhanced_encryption</i>
1011 1011
                                                 </a>
1012
-                                            <?php else: ?>
1012
+                                            <?php else {
1013
+	: ?>
1013 1014
                                                 <a href="#<?php echo $child[0] ?>" class="list-backup-content"
1014 1015
                                                    title="<?php echo __('List Backup Content',
1015 1016
 													   'xcloner-backup-and-restore') ?>"><i
@@ -1028,7 +1029,9 @@  discard block
 block discarded – undo
1028 1029
                                                         class="material-icons">file_upload</i></a>
1029 1030
                                         <?php endif ?>
1030 1031
                                     </li>
1031
-                                <?php endforeach; ?>
1032
+                                <?php endforeach;
1033
+}
1034
+?>
1032 1035
                             </ul>
1033 1036
                         <?php endif; ?>
1034 1037
                 <?php
@@ -1036,11 +1039,12 @@  discard block
 block discarded – undo
1036 1039
 				ob_end_clean();
1037 1040
 				?>
1038 1041
                     <?php ob_start(); ?>
1039
-                        <?php if (isset($file_info['timestamp']))
1042
+                        <?php if (isset($file_info['timestamp'])) {
1040 1043
 							echo date("Y-m-d H:i", $file_info['timestamp'])
1041 1044
 						?>
1042 1045
                     <?php
1043 1046
 						$return['data'][$i][] = ob_get_contents();
1047
+}
1044 1048
 						ob_end_clean();
1045 1049
 						?>
1046 1050
 
@@ -1065,15 +1069,17 @@  discard block
 block discarded – undo
1065 1069
                             <?php endif ?>
1066 1070
                             <?php
1067 1071
 							$basename = $file_info['basename'];
1068
-							if(isset($file_info['childs']) and sizeof($file_info['childs']))
1069
-								$basename = $file_info['childs'][0][0];
1072
+							if(isset($file_info['childs']) and sizeof($file_info['childs'])) {
1073
+															$basename = $file_info['childs'][0][0];
1074
+							}
1070 1075
 							?>
1071 1076
                             <?php if($this->xcloner_encryption->is_encrypted_file($basename)) :?>
1072 1077
                                 <a href="#<?php echo $file_info['basename'] ?>" class="backup-decryption"
1073 1078
                                    title="<?php echo __('Backup Decryption', 'xcloner-backup-and-restore') ?>">
1074 1079
                                     <i class="material-icons">enhanced_encryption</i>
1075 1080
                                 </a>
1076
-                            <?php else: ?>
1081
+                            <?php else {
1082
+	: ?>
1077 1083
                                 <a href="#<?php echo $file_info['basename'] ?>" class="list-backup-content"
1078 1084
                                     title="<?php echo __('List Backup Content', 'xcloner-backup-and-restore') ?>"><i
1079 1085
                                     class="material-icons">folder_open</i></a>
@@ -1083,7 +1089,9 @@  discard block
 block discarded – undo
1083 1089
                                     <i class="material-icons">no_encryption</i>
1084 1090
                                 </a>
1085 1091
                             <?php endif?>
1086
-                        <?php endif; ?>
1092
+                        <?php endif;
1093
+}
1094
+?>
1087 1095
 
1088 1096
                         <a href="#<?php echo $file_info['basename'] ?>" class="delete"
1089 1097
                            title="<?php echo __('Delete Backup', 'xcloner-backup-and-restore') ?>">
@@ -1335,7 +1343,7 @@  discard block
 block discarded – undo
1335 1343
 
1336 1344
 		try {
1337 1345
             unlink($tmp_file);
1338
-        }catch(Exception $e) {
1346
+        } catch(Exception $e) {
1339 1347
 		    //We are not interested in the error here
1340 1348
         }
1341 1349
 
Please login to merge, or discard this patch.