GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Branch dev (953bb6)
by Liuta
01:57
created
includes/class-xcloner-archive.php 3 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -213,6 +213,10 @@  discard block
 block discarded – undo
213 213
      *
214 214
      * @return bool
215 215
      */
216
+
217
+    /**
218
+     * @param string $error_message
219
+     */
216 220
     public function send_notification_error($to, $from, $subject, $backup_name, $params, $error_message)
217 221
     {
218 222
 
@@ -638,6 +642,10 @@  discard block
 block discarded – undo
638 642
      * Add file to archive
639 643
      *
640 644
      */
645
+
646
+    /**
647
+     * @param integer $append
648
+     */
641 649
     public function add_file_to_archive($file_info, $start_at_byte, $byte_limit = 0, $append, $filesystem)
642 650
     {
643 651
 
Please login to merge, or discard this patch.
Indentation   +515 added lines, -515 removed lines patch added patch discarded remove patch
@@ -36,171 +36,171 @@  discard block
 block discarded – undo
36 36
  */
37 37
 class Xcloner_Archive extends Tar
38 38
 {
39
-    /**
40
-     * Process file size per API request
41
-     * @var float|int
42
-     */
43
-    private $file_size_per_request_limit = 52428800; //50MB = 52428800; 1MB = 1048576
44
-    /**
45
-     * Files count to process per API request
46
-     * @var int
47
-     */
48
-    private $files_to_process_per_request = 250; //block of 512 bytes
49
-    /**
50
-     * Compression level, 0-uncompressed, 9-maximum compression
51
-     * @var int
52
-     */
53
-    private $compression_level = 0; //0-9 , 0 uncompressed
54
-    /**
55
-     * Split backup size limit
56
-     * Create a new backup archive file once the set size is reached
57
-     * @var float|int
58
-     */
59
-    private $xcloner_split_backup_limit = 2048; //2048MB
60
-    /**
61
-     * Number of processed bytes
62
-     * @var int
63
-     */
64
-    private $processed_size_bytes = 0;
65
-
66
-    /**
67
-     * Archive name
68
-     * @var string
69
-     */
70
-    private $archive_name;
71
-    /**
72
-     * @var Tar
73
-     */
74
-    private $backup_archive;
75
-    /**
76
-     * @var Xcloner_File_System
77
-     */
78
-    private $filesystem;
79
-    /**
80
-     * @var Xcloner_Logger
81
-     */
82
-    private $logger;
83
-    /**
84
-     * @var Xcloner_Settings
85
-     */
86
-    private $xcloner_settings;
87
-
88
-    /**
89
-     * [__construct description]
90
-     * @param Xcloner $xcloner_container XCloner Container
91
-     * @param string $archive_name Achive Name
92
-     */
93
-    public function __construct(Xcloner $xcloner_container, $archive_name = "")
94
-    {
95
-        $this->filesystem = $xcloner_container->get_xcloner_filesystem();
96
-        $this->logger = $xcloner_container->get_xcloner_logger()->withName("xcloner_archive");
97
-        $this->xcloner_settings = $xcloner_container->get_xcloner_settings();
98
-
99
-        if ($value = $this->xcloner_settings->get_xcloner_option('xcloner_size_limit_per_request')) {
100
-            $this->file_size_per_request_limit = $value * 1024 * 1024;
101
-        } //MB
102
-
103
-        if ($value = $this->xcloner_settings->get_xcloner_option('xcloner_files_to_process_per_request')) {
104
-            $this->files_to_process_per_request = $value;
105
-        }
39
+	/**
40
+	 * Process file size per API request
41
+	 * @var float|int
42
+	 */
43
+	private $file_size_per_request_limit = 52428800; //50MB = 52428800; 1MB = 1048576
44
+	/**
45
+	 * Files count to process per API request
46
+	 * @var int
47
+	 */
48
+	private $files_to_process_per_request = 250; //block of 512 bytes
49
+	/**
50
+	 * Compression level, 0-uncompressed, 9-maximum compression
51
+	 * @var int
52
+	 */
53
+	private $compression_level = 0; //0-9 , 0 uncompressed
54
+	/**
55
+	 * Split backup size limit
56
+	 * Create a new backup archive file once the set size is reached
57
+	 * @var float|int
58
+	 */
59
+	private $xcloner_split_backup_limit = 2048; //2048MB
60
+	/**
61
+	 * Number of processed bytes
62
+	 * @var int
63
+	 */
64
+	private $processed_size_bytes = 0;
65
+
66
+	/**
67
+	 * Archive name
68
+	 * @var string
69
+	 */
70
+	private $archive_name;
71
+	/**
72
+	 * @var Tar
73
+	 */
74
+	private $backup_archive;
75
+	/**
76
+	 * @var Xcloner_File_System
77
+	 */
78
+	private $filesystem;
79
+	/**
80
+	 * @var Xcloner_Logger
81
+	 */
82
+	private $logger;
83
+	/**
84
+	 * @var Xcloner_Settings
85
+	 */
86
+	private $xcloner_settings;
87
+
88
+	/**
89
+	 * [__construct description]
90
+	 * @param Xcloner $xcloner_container XCloner Container
91
+	 * @param string $archive_name Achive Name
92
+	 */
93
+	public function __construct(Xcloner $xcloner_container, $archive_name = "")
94
+	{
95
+		$this->filesystem = $xcloner_container->get_xcloner_filesystem();
96
+		$this->logger = $xcloner_container->get_xcloner_logger()->withName("xcloner_archive");
97
+		$this->xcloner_settings = $xcloner_container->get_xcloner_settings();
98
+
99
+		if ($value = $this->xcloner_settings->get_xcloner_option('xcloner_size_limit_per_request')) {
100
+			$this->file_size_per_request_limit = $value * 1024 * 1024;
101
+		} //MB
102
+
103
+		if ($value = $this->xcloner_settings->get_xcloner_option('xcloner_files_to_process_per_request')) {
104
+			$this->files_to_process_per_request = $value;
105
+		}
106 106
 
107
-        if ($value = get_option('xcloner_backup_compression_level')) {
108
-            $this->compression_level = $value;
109
-        }
107
+		if ($value = get_option('xcloner_backup_compression_level')) {
108
+			$this->compression_level = $value;
109
+		}
110 110
 
111
-        if ($value = get_option('xcloner_split_backup_limit')) {
112
-            $this->xcloner_split_backup_limit = $value;
113
-        }
111
+		if ($value = get_option('xcloner_split_backup_limit')) {
112
+			$this->xcloner_split_backup_limit = $value;
113
+		}
114 114
 
115
-        $this->xcloner_split_backup_limit = $this->xcloner_split_backup_limit * 1024 * 1024; //transform to bytes
115
+		$this->xcloner_split_backup_limit = $this->xcloner_split_backup_limit * 1024 * 1024; //transform to bytes
116 116
 
117
-        if (isset($archive_name) && $archive_name) {
118
-            $this->set_archive_name($archive_name);
119
-        }
120
-    }
117
+		if (isset($archive_name) && $archive_name) {
118
+			$this->set_archive_name($archive_name);
119
+		}
120
+	}
121 121
 
122
-    /*
122
+	/*
123 123
      * Rename backup archive
124 124
      *
125 125
      * @param string $old_name
126 126
      * @param string $new_name
127 127
      *
128 128
      */
129
-    public function rename_archive($old_name, $new_name)
130
-    {
131
-        $this->logger->info(sprintf("Renaming backup archive %s to %s", $old_name, $new_name));
132
-        $storage_filesystem = $this->filesystem->get_storage_filesystem();
133
-        $storage_filesystem->rename($old_name, $new_name);
134
-    }
135
-
136
-    /*
129
+	public function rename_archive($old_name, $new_name)
130
+	{
131
+		$this->logger->info(sprintf("Renaming backup archive %s to %s", $old_name, $new_name));
132
+		$storage_filesystem = $this->filesystem->get_storage_filesystem();
133
+		$storage_filesystem->rename($old_name, $new_name);
134
+	}
135
+
136
+	/*
137 137
      *
138 138
      * Set the backup archive name
139 139
      *
140 140
      */
141
-    public function set_archive_name($name = "", $part = 0)
142
-    {
141
+	public function set_archive_name($name = "", $part = 0)
142
+	{
143 143
 
144
-        $this->archive_name = $this->filesystem->process_backup_name($name);
144
+		$this->archive_name = $this->filesystem->process_backup_name($name);
145 145
 
146
-        if ($diff_timestamp_start = $this->filesystem->get_diff_timestamp_start()) {
147
-            //$this->archive_name = $this->archive_name."-diff-".date("Y-m-d_H-i",$diff_timestamp_start);
148
-            $new_name = $this->archive_name;
146
+		if ($diff_timestamp_start = $this->filesystem->get_diff_timestamp_start()) {
147
+			//$this->archive_name = $this->archive_name."-diff-".date("Y-m-d_H-i",$diff_timestamp_start);
148
+			$new_name = $this->archive_name;
149 149
 
150
-            if (!stristr($new_name, "-diff")) {
151
-                $new_name = $this->archive_name . "-diff" . date("Y-m-d_H-i", $diff_timestamp_start);
152
-            }
150
+			if (!stristr($new_name, "-diff")) {
151
+				$new_name = $this->archive_name . "-diff" . date("Y-m-d_H-i", $diff_timestamp_start);
152
+			}
153 153
 
154
-            $this->archive_name = $new_name;
154
+			$this->archive_name = $new_name;
155 155
 
156
-        }
156
+		}
157 157
 
158
-        if (isset($part) and $part) {
159
-            $new_name = preg_replace('/-part(\d*)/', "-part" . $part, $this->archive_name);
160
-            if (!stristr($new_name, "-part")) {
161
-                $new_name = $this->archive_name . "-part" . $part;
162
-            }
158
+		if (isset($part) and $part) {
159
+			$new_name = preg_replace('/-part(\d*)/', "-part" . $part, $this->archive_name);
160
+			if (!stristr($new_name, "-part")) {
161
+				$new_name = $this->archive_name . "-part" . $part;
162
+			}
163 163
 
164
-            $this->archive_name = $new_name;
165
-        }
164
+			$this->archive_name = $new_name;
165
+		}
166 166
 
167
-        return $this;
168
-    }
167
+		return $this;
168
+	}
169 169
 
170
-    /*
170
+	/*
171 171
      *
172 172
      * Returns the backup archive name
173 173
      *
174 174
      * @return string archive name
175 175
      */
176
-    public function get_archive_name()
177
-    {
178
-        return $this->archive_name;
179
-    }
176
+	public function get_archive_name()
177
+	{
178
+		return $this->archive_name;
179
+	}
180 180
 
181
-    /*
181
+	/*
182 182
      *
183 183
      * Returns the multipart naming for the backup archive
184 184
      *
185 185
      * @return string multi-part backup name
186 186
      */
187
-    public function get_archive_name_multipart()
188
-    {
189
-        $new_name = preg_replace('/-part(\d*)/', "", $this->archive_name);
190
-        return $new_name . "-multipart" . $this->xcloner_settings->get_backup_extension_name(".csv");
191
-    }
187
+	public function get_archive_name_multipart()
188
+	{
189
+		$new_name = preg_replace('/-part(\d*)/', "", $this->archive_name);
190
+		return $new_name . "-multipart" . $this->xcloner_settings->get_backup_extension_name(".csv");
191
+	}
192 192
 
193
-    /*
193
+	/*
194 194
      *
195 195
      * Returns the full backup name including extension
196 196
      *
197 197
      */
198
-    public function get_archive_name_with_extension()
199
-    {
200
-        return $this->archive_name . $this->xcloner_settings->get_backup_extension_name();
201
-    }
198
+	public function get_archive_name_with_extension()
199
+	{
200
+		return $this->archive_name . $this->xcloner_settings->get_backup_extension_name();
201
+	}
202 202
 
203
-    /*
203
+	/*
204 204
      *
205 205
      * Send notification error by E-Mail
206 206
      *
@@ -213,31 +213,31 @@  discard block
 block discarded – undo
213 213
      *
214 214
      * @return bool
215 215
      */
216
-    public function send_notification_error($to, $from, $subject, $backup_name, $params, $error_message)
217
-    {
216
+	public function send_notification_error($to, $from, $subject, $backup_name, $params, $error_message)
217
+	{
218 218
 
219
-        $body = "";
220
-        $body .= sprintf(__("Backup Site Url: %s"), get_site_url());
221
-        $body .= "<br /><>";
219
+		$body = "";
220
+		$body .= sprintf(__("Backup Site Url: %s"), get_site_url());
221
+		$body .= "<br /><>";
222 222
 
223
-        $body .= sprintf(__("Error Message: %s"), $error_message);
223
+		$body .= sprintf(__("Error Message: %s"), $error_message);
224 224
 
225
-        $this->logger->info(sprintf("Sending backup error notification to %s", $to));
225
+		$this->logger->info(sprintf("Sending backup error notification to %s", $to));
226 226
 
227
-        $admin_email = get_option("admin_email");
227
+		$admin_email = get_option("admin_email");
228 228
 
229
-        $headers = array('Content-Type: text/html; charset=UTF-8');
229
+		$headers = array('Content-Type: text/html; charset=UTF-8');
230 230
 
231
-        if ($admin_email and $from) {
232
-            $headers[] = 'From: ' . $from . ' <' . $admin_email . '>';
233
-        }
231
+		if ($admin_email and $from) {
232
+			$headers[] = 'From: ' . $from . ' <' . $admin_email . '>';
233
+		}
234 234
 
235
-        $return = wp_mail($to, $subject, $body, $headers);
235
+		$return = wp_mail($to, $subject, $body, $headers);
236 236
 
237
-        return $return;
238
-    }
237
+		return $return;
238
+	}
239 239
 
240
-    /*
240
+	/*
241 241
      *
242 242
      * Send backup archive notfication by E-Mail
243 243
      *
@@ -251,482 +251,482 @@  discard block
 block discarded – undo
251 251
      *
252 252
      * @return bool
253 253
      */
254
-    public function send_notification(
255
-        $to,
256
-        $from,
257
-        $subject,
258
-        $backup_name,
259
-        $params,
260
-        $error_message = "",
261
-        $additional = array()
262
-    ) {
263
-        if (!$from) {
264
-            $from = "XCloner Backup";
265
-        }
254
+	public function send_notification(
255
+		$to,
256
+		$from,
257
+		$subject,
258
+		$backup_name,
259
+		$params,
260
+		$error_message = "",
261
+		$additional = array()
262
+	) {
263
+		if (!$from) {
264
+			$from = "XCloner Backup";
265
+		}
266 266
 
267
-        if (($error_message)) {
268
-            return $this->send_notification_error($to, $from, $subject, $backup_name, $params, $error_message);
269
-        }
267
+		if (($error_message)) {
268
+			return $this->send_notification_error($to, $from, $subject, $backup_name, $params, $error_message);
269
+		}
270 270
 
271
-        $params = (array)$params;
271
+		$params = (array)$params;
272 272
 
273
-        if (!$subject) {
274
-            $subject = sprintf(__("New backup generated %s"), $backup_name);
275
-        }
273
+		if (!$subject) {
274
+			$subject = sprintf(__("New backup generated %s"), $backup_name);
275
+		}
276 276
 
277
-        $body = sprintf(__("Generated Backup Size: %s"), size_format($this->filesystem->get_backup_size($backup_name)));
278
-        $body .= "<br /><br />";
277
+		$body = sprintf(__("Generated Backup Size: %s"), size_format($this->filesystem->get_backup_size($backup_name)));
278
+		$body .= "<br /><br />";
279 279
 
280
-        if (isset($additional['lines_total'])) {
281
-            $body .= sprintf(__("Total files added: %s"), $additional['lines_total']);
282
-            $body .= "<br /><br />";
283
-        }
280
+		if (isset($additional['lines_total'])) {
281
+			$body .= sprintf(__("Total files added: %s"), $additional['lines_total']);
282
+			$body .= "<br /><br />";
283
+		}
284 284
 
285
-        $backup_parts = $this->filesystem->get_multipart_files($backup_name);
285
+		$backup_parts = $this->filesystem->get_multipart_files($backup_name);
286 286
 
287
-        if (!$backups_counter = sizeof($backup_parts)) {
288
-            $backups_counter = 1;
289
-        }
287
+		if (!$backups_counter = sizeof($backup_parts)) {
288
+			$backups_counter = 1;
289
+		}
290 290
 
291
-        $body .= sprintf(__("Backup Parts: %s"), $backups_counter);
292
-        $body .= "<br />";
291
+		$body .= sprintf(__("Backup Parts: %s"), $backups_counter);
292
+		$body .= "<br />";
293 293
 
294
-        if (sizeof($backup_parts)) {
295
-            $body .= implode("<br />", $backup_parts);
296
-            $body .= "<br />";
297
-        }
294
+		if (sizeof($backup_parts)) {
295
+			$body .= implode("<br />", $backup_parts);
296
+			$body .= "<br />";
297
+		}
298 298
 
299
-        $body .= "<br />";
299
+		$body .= "<br />";
300 300
 
301
-        $body .= sprintf(__("Backup Site Url: %s"), get_site_url());
302
-        $body .= "<br />";
301
+		$body .= sprintf(__("Backup Site Url: %s"), get_site_url());
302
+		$body .= "<br />";
303 303
 
304
-        if (isset($params['backup_params']->backup_comments)) {
305
-            $body .= __("Backup Comments: ") . $params['backup_params']->backup_comments;
306
-            $body .= "<br /><br />";
307
-        }
304
+		if (isset($params['backup_params']->backup_comments)) {
305
+			$body .= __("Backup Comments: ") . $params['backup_params']->backup_comments;
306
+			$body .= "<br /><br />";
307
+		}
308 308
 
309
-        if ($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) {
310
-            $body .= __("Latest 50 Log Lines: ") . "<br />" . implode("<br />\n",
311
-                                                                        $this->logger->getLastDebugLines(50));
312
-        }
309
+		if ($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) {
310
+			$body .= __("Latest 50 Log Lines: ") . "<br />" . implode("<br />\n",
311
+																		$this->logger->getLastDebugLines(50));
312
+		}
313 313
 
314
-        $attachments = $this->filesystem->get_backup_attachments();
314
+		$attachments = $this->filesystem->get_backup_attachments();
315 315
 
316
-        $attachments_archive = $this->xcloner_settings->get_xcloner_tmp_path() . DS . "info.tgz";
316
+		$attachments_archive = $this->xcloner_settings->get_xcloner_tmp_path() . DS . "info.tgz";
317 317
 
318
-        $tar = new Tar();
319
-        $tar->create($attachments_archive);
318
+		$tar = new Tar();
319
+		$tar->create($attachments_archive);
320 320
 
321
-        foreach ($attachments as $key => $file) {
322
-            $tar->addFile($file, basename($file));
323
-        }
324
-        $tar->close();
321
+		foreach ($attachments as $key => $file) {
322
+			$tar->addFile($file, basename($file));
323
+		}
324
+		$tar->close();
325 325
 
326
-        $this->logger->info(sprintf("Sending backup notification to %s", $to));
326
+		$this->logger->info(sprintf("Sending backup notification to %s", $to));
327 327
 
328
-        $admin_email = get_option("admin_email");
328
+		$admin_email = get_option("admin_email");
329 329
 
330
-        $headers = array('Content-Type: text/html; charset=UTF-8', 'From: ' . $from . ' <' . $admin_email . '>');
330
+		$headers = array('Content-Type: text/html; charset=UTF-8', 'From: ' . $from . ' <' . $admin_email . '>');
331 331
 
332
-        $return = wp_mail($to, $subject, $body, $headers, array($attachments_archive));
332
+		$return = wp_mail($to, $subject, $body, $headers, array($attachments_archive));
333 333
 
334
-        return $return;
335
-    }
334
+		return $return;
335
+	}
336 336
 
337
-    /*
337
+	/*
338 338
      *
339 339
      * Incremental Backup method
340 340
      *
341 341
      */
342
-    public function start_incremental_backup($backup_params, $extra_params, $init)
343
-    {
344
-        $return = array();
342
+	public function start_incremental_backup($backup_params, $extra_params, $init)
343
+	{
344
+		$return = array();
345 345
 
346
-        if (!isset($extra_params['backup_part'])) {
347
-            $extra_params['backup_part'] = 0;
348
-        }
346
+		if (!isset($extra_params['backup_part'])) {
347
+			$extra_params['backup_part'] = 0;
348
+		}
349 349
 
350
-        $return['extra']['backup_part'] = $extra_params['backup_part'];
350
+		$return['extra']['backup_part'] = $extra_params['backup_part'];
351 351
 
352
-        if (isset($extra_params['backup_archive_name'])) {
353
-            $this->set_archive_name($extra_params['backup_archive_name'], $return['extra']['backup_part']);
354
-        } else {
355
-            $this->set_archive_name($backup_params['backup_name']);
356
-        }
352
+		if (isset($extra_params['backup_archive_name'])) {
353
+			$this->set_archive_name($extra_params['backup_archive_name'], $return['extra']['backup_part']);
354
+		} else {
355
+			$this->set_archive_name($backup_params['backup_name']);
356
+		}
357 357
 
358
-        if (!$this->get_archive_name()) {
359
-            $this->set_archive_name();
360
-        }
358
+		if (!$this->get_archive_name()) {
359
+			$this->set_archive_name();
360
+		}
361 361
 
362
-        $this->backup_archive = new Tar();
363
-        $this->backup_archive->setCompression($this->compression_level);
362
+		$this->backup_archive = new Tar();
363
+		$this->backup_archive->setCompression($this->compression_level);
364 364
 
365
-        $archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
365
+		$archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
366 366
 
367
-        if ($init) {
368
-            $this->logger->info(sprintf(__("Initializing the backup archive %s"), $this->get_archive_name()));
367
+		if ($init) {
368
+			$this->logger->info(sprintf(__("Initializing the backup archive %s"), $this->get_archive_name()));
369 369
 
370
-            $this->backup_archive->create($archive_info->getPath() . DS . $archive_info->getFilename());
370
+			$this->backup_archive->create($archive_info->getPath() . DS . $archive_info->getFilename());
371 371
 
372
-            $return['extra']['backup_init'] = 1;
372
+			$return['extra']['backup_init'] = 1;
373 373
 
374
-        } else {
375
-            $this->logger->info(sprintf(__("Opening for append the backup archive %s"), $this->get_archive_name()));
374
+		} else {
375
+			$this->logger->info(sprintf(__("Opening for append the backup archive %s"), $this->get_archive_name()));
376 376
 
377
-            $this->backup_archive->openForAppend($archive_info->getPath() . DS . $archive_info->getFilename());
377
+			$this->backup_archive->openForAppend($archive_info->getPath() . DS . $archive_info->getFilename());
378 378
 
379
-            $return['extra']['backup_init'] = 0;
379
+			$return['extra']['backup_init'] = 0;
380 380
 
381
-        }
381
+		}
382 382
 
383
-        $return['extra']['backup_archive_name'] = $this->get_archive_name();
384
-        $return['extra']['backup_archive_name_full'] = $this->get_archive_name_with_extension();
383
+		$return['extra']['backup_archive_name'] = $this->get_archive_name();
384
+		$return['extra']['backup_archive_name_full'] = $this->get_archive_name_with_extension();
385 385
 
386
-        if (!isset($extra_params['start_at_line'])) {
387
-            $extra_params['start_at_line'] = 0;
388
-        }
386
+		if (!isset($extra_params['start_at_line'])) {
387
+			$extra_params['start_at_line'] = 0;
388
+		}
389 389
 
390
-        if (!isset($extra_params['start_at_byte'])) {
391
-            $extra_params['start_at_byte'] = 0;
392
-        }
390
+		if (!isset($extra_params['start_at_byte'])) {
391
+			$extra_params['start_at_byte'] = 0;
392
+		}
393 393
 
394
-        if (!$this->filesystem->get_tmp_filesystem()->has($this->filesystem->get_included_files_handler())) {
395
-            $this->logger->error(sprintf("Missing the includes file handler %s, aborting...",
396
-                $this->filesystem->get_included_files_handler()));
394
+		if (!$this->filesystem->get_tmp_filesystem()->has($this->filesystem->get_included_files_handler())) {
395
+			$this->logger->error(sprintf("Missing the includes file handler %s, aborting...",
396
+				$this->filesystem->get_included_files_handler()));
397 397
 
398
-            $return['finished'] = 1;
399
-            return $return;
400
-        }
398
+			$return['finished'] = 1;
399
+			return $return;
400
+		}
401 401
 
402
-        $included_files_handler = $this->filesystem->get_included_files_handler(1);
402
+		$included_files_handler = $this->filesystem->get_included_files_handler(1);
403 403
 
404
-        $file = new SplFileObject($included_files_handler);
404
+		$file = new SplFileObject($included_files_handler);
405 405
 
406
-        $file->seek(PHP_INT_MAX);
406
+		$file->seek(PHP_INT_MAX);
407 407
 
408
-        $return['extra']['lines_total'] = ($file->key() - 1);
408
+		$return['extra']['lines_total'] = ($file->key() - 1);
409 409
 
410
-        //we skip the first CSV line with headers
411
-        if (!$extra_params['start_at_line']) {
412
-            $file->seek(1);
413
-        } else {
414
-            $file->seek($extra_params['start_at_line'] + 1);
415
-        }
410
+		//we skip the first CSV line with headers
411
+		if (!$extra_params['start_at_line']) {
412
+			$file->seek(1);
413
+		} else {
414
+			$file->seek($extra_params['start_at_line'] + 1);
415
+		}
416 416
 
417
-        $this->processed_size_bytes = 0;
417
+		$this->processed_size_bytes = 0;
418 418
 
419
-        $counter = 0;
419
+		$counter = 0;
420 420
 
421
-        $start_byte = $extra_params['start_at_byte'];
421
+		$start_byte = $extra_params['start_at_byte'];
422 422
 
423
-        $byte_limit = 0;
423
+		$byte_limit = 0;
424 424
 
425
-        while (!$file->eof() and $counter <= $this->files_to_process_per_request) {
426
-            $current_line_str = $file->current();
425
+		while (!$file->eof() and $counter <= $this->files_to_process_per_request) {
426
+			$current_line_str = $file->current();
427 427
 
428
-            $line = str_getcsv($current_line_str);
428
+			$line = str_getcsv($current_line_str);
429 429
 
430
-            $relative_path = stripslashes($line[0]);
430
+			$relative_path = stripslashes($line[0]);
431 431
 
432
-            $start_filesystem = "start_filesystem";
432
+			$start_filesystem = "start_filesystem";
433 433
 
434
-            if (isset($line[4])) {
435
-                $start_filesystem = $line[4];
436
-            }
434
+			if (isset($line[4])) {
435
+				$start_filesystem = $line[4];
436
+			}
437 437
 
438
-            //$adapter = $this->filesystem->get_adapter($start_filesystem);
438
+			//$adapter = $this->filesystem->get_adapter($start_filesystem);
439 439
 
440
-            if (!$relative_path || !$this->filesystem->get_filesystem($start_filesystem)->has($relative_path)) {
441
-                if ($relative_path != "") {
442
-                    $this->logger->error(sprintf("Could not add file %b to backup archive, file not found",
443
-                        $relative_path));
444
-                }
440
+			if (!$relative_path || !$this->filesystem->get_filesystem($start_filesystem)->has($relative_path)) {
441
+				if ($relative_path != "") {
442
+					$this->logger->error(sprintf("Could not add file %b to backup archive, file not found",
443
+						$relative_path));
444
+				}
445 445
 
446
-                $extra_params['start_at_line']++;
447
-                $file->next();
448
-                continue;
449
-            }
446
+				$extra_params['start_at_line']++;
447
+				$file->next();
448
+				continue;
449
+			}
450 450
 
451
-            $file_info = $this->filesystem->get_filesystem($start_filesystem)->getMetadata($relative_path);
451
+			$file_info = $this->filesystem->get_filesystem($start_filesystem)->getMetadata($relative_path);
452 452
 
453
-            if (!isset($file_info['size'])) {
454
-                $file_info['size'] = 0;
455
-            }
453
+			if (!isset($file_info['size'])) {
454
+				$file_info['size'] = 0;
455
+			}
456 456
 
457
-            if ($start_filesystem == "tmp_filesystem") {
458
-                $file_info['archive_prefix_path'] = $this->xcloner_settings->get_xcloner_tmp_path_suffix();
459
-            }
457
+			if ($start_filesystem == "tmp_filesystem") {
458
+				$file_info['archive_prefix_path'] = $this->xcloner_settings->get_xcloner_tmp_path_suffix();
459
+			}
460 460
 
461
-            $byte_limit = (int)$this->file_size_per_request_limit / 512;
461
+			$byte_limit = (int)$this->file_size_per_request_limit / 512;
462 462
 
463
-            $append = 0;
463
+			$append = 0;
464 464
 
465
-            if ($file_info['size'] > $byte_limit * 512 or $start_byte) {
466
-                $append = 1;
467
-            }
465
+			if ($file_info['size'] > $byte_limit * 512 or $start_byte) {
466
+				$append = 1;
467
+			}
468 468
 
469
-            if (!isset($return['extra']['backup_size'])) {
470
-                $return['extra']['backup_size'] = 0;
471
-            }
469
+			if (!isset($return['extra']['backup_size'])) {
470
+				$return['extra']['backup_size'] = 0;
471
+			}
472 472
 
473
-            $return['extra']['backup_size'] = $archive_info->getSize();
473
+			$return['extra']['backup_size'] = $archive_info->getSize();
474 474
 
475
-            $estimated_new_size = $return['extra']['backup_size'] + $file_info['size'];
475
+			$estimated_new_size = $return['extra']['backup_size'] + $file_info['size'];
476 476
 
477
-            //we create a new backup part if we reach the Split Achive Limit
478
-            if ($this->xcloner_split_backup_limit and ($estimated_new_size > $this->xcloner_split_backup_limit) and (!$start_byte)) {
479
-                $this->logger->info(sprintf("Backup size limit %s bytes reached, file add estimate %s, attempt to create a new archive ",
480
-                    $this->xcloner_split_backup_limit, $estimated_new_size));
481
-                list($archive_info, $return['extra']['backup_part']) = $this->create_new_backup_part($return['extra']['backup_part']);
477
+			//we create a new backup part if we reach the Split Achive Limit
478
+			if ($this->xcloner_split_backup_limit and ($estimated_new_size > $this->xcloner_split_backup_limit) and (!$start_byte)) {
479
+				$this->logger->info(sprintf("Backup size limit %s bytes reached, file add estimate %s, attempt to create a new archive ",
480
+					$this->xcloner_split_backup_limit, $estimated_new_size));
481
+				list($archive_info, $return['extra']['backup_part']) = $this->create_new_backup_part($return['extra']['backup_part']);
482 482
 
483
-                if ($file_info['size'] > $this->xcloner_split_backup_limit) {
484
-                    $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",
485
-                        $file_info['path'], $file_info['size'], $this->xcloner_split_backup_limit));
486
-                    $extra_params['start_at_line']++;
487
-                }
483
+				if ($file_info['size'] > $this->xcloner_split_backup_limit) {
484
+					$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",
485
+						$file_info['path'], $file_info['size'], $this->xcloner_split_backup_limit));
486
+					$extra_params['start_at_line']++;
487
+				}
488 488
 
489
-                $return['extra']['start_at_line'] = $extra_params['start_at_line'];
490
-                $return['extra']['start_at_byte'] = 0;
489
+				$return['extra']['start_at_line'] = $extra_params['start_at_line'];
490
+				$return['extra']['start_at_byte'] = 0;
491 491
 
492
-                $return['finished'] = 0;
492
+				$return['finished'] = 0;
493 493
 
494
-                return $return;
495
-            }
494
+				return $return;
495
+			}
496 496
 
497
-            list($bytes_wrote, $last_position) = $this->add_file_to_archive($file_info, $start_byte, $byte_limit,
498
-                $append, $start_filesystem);
499
-            $this->processed_size_bytes += $bytes_wrote;
497
+			list($bytes_wrote, $last_position) = $this->add_file_to_archive($file_info, $start_byte, $byte_limit,
498
+				$append, $start_filesystem);
499
+			$this->processed_size_bytes += $bytes_wrote;
500 500
 
501
-            //echo" - processed ".$this->processed_size_bytes." bytes ".$this->file_size_per_request_limit." last_position:".$last_position." \n";
502
-            $return['extra']['processed_file'] = $file_info['path'];
503
-            $return['extra']['processed_file_size'] = $file_info['size'];
504
-            $return['extra']['backup_size'] = $archive_info->getSize();
501
+			//echo" - processed ".$this->processed_size_bytes." bytes ".$this->file_size_per_request_limit." last_position:".$last_position." \n";
502
+			$return['extra']['processed_file'] = $file_info['path'];
503
+			$return['extra']['processed_file_size'] = $file_info['size'];
504
+			$return['extra']['backup_size'] = $archive_info->getSize();
505 505
 
506
-            if ($last_position > 0) {
507
-                $start_byte = $last_position;
508
-            } else {
509
-                $extra_params['start_at_line']++;
510
-                $file->next();
511
-                $start_byte = 0;
512
-                $counter++;
513
-            }
506
+			if ($last_position > 0) {
507
+				$start_byte = $last_position;
508
+			} else {
509
+				$extra_params['start_at_line']++;
510
+				$file->next();
511
+				$start_byte = 0;
512
+				$counter++;
513
+			}
514 514
 
515
-            if ($this->processed_size_bytes >= $this->file_size_per_request_limit) {
516
-                clearstatcache();
517
-                $return['extra']['backup_size'] = $archive_info->getSize();
515
+			if ($this->processed_size_bytes >= $this->file_size_per_request_limit) {
516
+				clearstatcache();
517
+				$return['extra']['backup_size'] = $archive_info->getSize();
518 518
 
519
-                $return['finished'] = 0;
520
-                $return['extra']['start_at_line'] = $extra_params['start_at_line'];
521
-                $return['extra']['start_at_byte'] = $last_position;
522
-                $this->logger->info(sprintf("Reached the maximum %s request data limit, returning response",
523
-                    $this->file_size_per_request_limit));
524
-                return $return;
525
-            }
526
-        }
519
+				$return['finished'] = 0;
520
+				$return['extra']['start_at_line'] = $extra_params['start_at_line'];
521
+				$return['extra']['start_at_byte'] = $last_position;
522
+				$this->logger->info(sprintf("Reached the maximum %s request data limit, returning response",
523
+					$this->file_size_per_request_limit));
524
+				return $return;
525
+			}
526
+		}
527 527
 
528
-        if (!$file->eof()) {
529
-            clearstatcache();
530
-            $return['extra']['backup_size'] = $archive_info->getSize();
528
+		if (!$file->eof()) {
529
+			clearstatcache();
530
+			$return['extra']['backup_size'] = $archive_info->getSize();
531 531
 
532
-            $return['finished'] = 0;
533
-            $return['extra']['start_at_line'] = $extra_params['start_at_line'];
534
-            $return['extra']['start_at_byte'] = $last_position;
535
-            $this->logger->info(sprintf("We have reached the maximum files to process per request limit of %s, returning response",
536
-                $this->files_to_process_per_request));
532
+			$return['finished'] = 0;
533
+			$return['extra']['start_at_line'] = $extra_params['start_at_line'];
534
+			$return['extra']['start_at_byte'] = $last_position;
535
+			$this->logger->info(sprintf("We have reached the maximum files to process per request limit of %s, returning response",
536
+				$this->files_to_process_per_request));
537 537
 
538
-            return $return;
539
-        }
538
+			return $return;
539
+		}
540 540
 
541
-        //close the backup archive by adding 2*512 blocks of zero bytes
542
-        $this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.",
543
-            $this->get_archive_name_with_extension()));
544
-        $this->backup_archive->close();
541
+		//close the backup archive by adding 2*512 blocks of zero bytes
542
+		$this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.",
543
+			$this->get_archive_name_with_extension()));
544
+		$this->backup_archive->close();
545 545
 
546
-        /**
547
-         * XCloner HOOK backup_archive_finished.
548
-         *
549
-         * This will get triggered when a backup archive is finished writing.
550
-         */
551
-        //do_action('backup_archive_finished', $this->backup_archive, $this);
546
+		/**
547
+		 * XCloner HOOK backup_archive_finished.
548
+		 *
549
+		 * This will get triggered when a backup archive is finished writing.
550
+		 */
551
+		//do_action('backup_archive_finished', $this->backup_archive, $this);
552 552
 
553
-        //updating archive_info
554
-        $archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
553
+		//updating archive_info
554
+		$archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
555 555
 
556
-        if ($return['extra']['backup_part']) {
557
-            $this->write_multipart_file($this->get_archive_name_with_extension());
558
-        }
556
+		if ($return['extra']['backup_part']) {
557
+			$this->write_multipart_file($this->get_archive_name_with_extension());
558
+		}
559 559
 
560
-        $return['extra']['start_at_line'] = $extra_params['start_at_line'] - 1;
560
+		$return['extra']['start_at_line'] = $extra_params['start_at_line'] - 1;
561 561
 
562
-        if (isset($file_info)) {
563
-            $return['extra']['processed_file'] = $file_info['path'];
564
-            $return['extra']['processed_file_size'] = $file_info['size'];
565
-        }
562
+		if (isset($file_info)) {
563
+			$return['extra']['processed_file'] = $file_info['path'];
564
+			$return['extra']['processed_file_size'] = $file_info['size'];
565
+		}
566 566
 
567
-        clearstatcache();
568
-        $return['extra']['backup_size'] = $archive_info->getSize();
567
+		clearstatcache();
568
+		$return['extra']['backup_size'] = $archive_info->getSize();
569 569
 
570
-        $return['finished'] = 1;
571
-        return $return;
572
-    }
570
+		$return['finished'] = 1;
571
+		return $return;
572
+	}
573 573
 
574
-    /*
574
+	/*
575 575
      *
576 576
      * Write multipart file components
577 577
      *
578 578
      */
579
-    private function write_multipart_file($path = "")
580
-    {
581
-        if(!$path) {
582
-            $path = $this->get_archive_name_with_extension();
583
-        }
579
+	private function write_multipart_file($path = "")
580
+	{
581
+		if(!$path) {
582
+			$path = $this->get_archive_name_with_extension();
583
+		}
584 584
 
585
-        $file = $this->filesystem->get_filesystem("storage_filesystem_append")->getMetadata($path);
586
-        //print_r($file_info);
587
-        $line = '"' . $file['path'] . '","' . $file['timestamp'] . '","' . $file['size'] . '"' . PHP_EOL;
585
+		$file = $this->filesystem->get_filesystem("storage_filesystem_append")->getMetadata($path);
586
+		//print_r($file_info);
587
+		$line = '"' . $file['path'] . '","' . $file['timestamp'] . '","' . $file['size'] . '"' . PHP_EOL;
588 588
 
589 589
 
590
-        $this->filesystem->get_filesystem("storage_filesystem_append")
591
-            ->write($this->get_archive_name_multipart(), $line);
592
-    }
590
+		$this->filesystem->get_filesystem("storage_filesystem_append")
591
+			->write($this->get_archive_name_multipart(), $line);
592
+	}
593 593
 
594
-    /*
594
+	/*
595 595
      *
596 596
      * Create a new backup part
597 597
      *
598 598
      */
599
-    private function create_new_backup_part($part = 0)
600
-    {
601
-        //close the backup archive by adding 2*512 blocks of zero bytes
602
-        $this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.",
603
-            $this->get_archive_name_with_extension()));
604
-        $this->backup_archive->close();
605
-
606
-        if (!$part) {
607
-            $old_name = $this->get_archive_name_with_extension();
608
-            $this->set_archive_name($this->get_archive_name(), ++$part);
609
-            $this->rename_archive($old_name, $this->get_archive_name_with_extension());
610
-
611
-            if ($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart())) {
612
-                $this->filesystem->get_storage_filesystem()->delete($this->get_archive_name_multipart());
613
-            }
614
-
615
-            $this->write_multipart_file($this->get_archive_name_with_extension());
616
-
617
-        } else {
618
-            $this->logger->info(sprintf("Creating new multipart info file %s",
619
-                $this->get_archive_name_with_extension()));
620
-            $this->write_multipart_file($this->get_archive_name_with_extension());
621
-        }
599
+	private function create_new_backup_part($part = 0)
600
+	{
601
+		//close the backup archive by adding 2*512 blocks of zero bytes
602
+		$this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.",
603
+			$this->get_archive_name_with_extension()));
604
+		$this->backup_archive->close();
605
+
606
+		if (!$part) {
607
+			$old_name = $this->get_archive_name_with_extension();
608
+			$this->set_archive_name($this->get_archive_name(), ++$part);
609
+			$this->rename_archive($old_name, $this->get_archive_name_with_extension());
610
+
611
+			if ($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart())) {
612
+				$this->filesystem->get_storage_filesystem()->delete($this->get_archive_name_multipart());
613
+			}
614
+
615
+			$this->write_multipart_file($this->get_archive_name_with_extension());
616
+
617
+		} else {
618
+			$this->logger->info(sprintf("Creating new multipart info file %s",
619
+				$this->get_archive_name_with_extension()));
620
+			$this->write_multipart_file($this->get_archive_name_with_extension());
621
+		}
622 622
 
623
-        $this->set_archive_name($this->get_archive_name(), ++$part);
623
+		$this->set_archive_name($this->get_archive_name(), ++$part);
624 624
 
625
-        $this->logger->info(sprintf("Creating new backup archive part %s", $this->get_archive_name_with_extension()));
625
+		$this->logger->info(sprintf("Creating new backup archive part %s", $this->get_archive_name_with_extension()));
626 626
 
627
-        $this->backup_archive = new Tar();
628
-        $this->backup_archive->setCompression($this->compression_level);
629
-        $archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
630
-        $this->backup_archive->create($archive_info->getPath() . DS . $archive_info->getFilename());
627
+		$this->backup_archive = new Tar();
628
+		$this->backup_archive->setCompression($this->compression_level);
629
+		$archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
630
+		$this->backup_archive->create($archive_info->getPath() . DS . $archive_info->getFilename());
631 631
 
632
-        return array($archive_info, $part);
632
+		return array($archive_info, $part);
633 633
 
634
-    }
634
+	}
635 635
 
636
-    /*
636
+	/*
637 637
      *
638 638
      * Add file to archive
639 639
      *
640 640
      */
641
-    public function add_file_to_archive($file_info, $start_at_byte, $byte_limit = 0, $append, $filesystem)
642
-    {
643
-
644
-        $start_adapter = $this->filesystem->get_adapter($filesystem);
645
-        $start_filesystem = $this->filesystem->get_adapter($filesystem);
646
-
647
-        if (!$file_info['path']) {
648
-            return;
649
-        }
650
-
651
-        if (isset($file_info['archive_prefix_path'])) {
652
-            $file_info['target_path'] = $file_info['archive_prefix_path'] . "/" . $file_info['path'];
653
-        } else {
654
-            $file_info['target_path'] = $file_info['path'];
655
-        }
656
-
657
-        $last_position = $start_at_byte;
658
-
659
-        //$start_adapter = $this->filesystem->get_start_adapter();
660
-
661
-        if (!$append) {
662
-            $bytes_wrote = $file_info['size'];
663
-            $this->logger->info(sprintf("Adding %s bytes of file %s to archive %s ", $bytes_wrote,
664
-                $file_info['target_path'], $this->get_archive_name_with_extension()));
665
-            $this->backup_archive->addFile($start_adapter->applyPathPrefix($file_info['path']),
666
-                $file_info['target_path']);
667
-        } else {
668
-            $tmp_file = md5($file_info['path']);
669
-
670
-            //we isolate file to tmp if we are at byte 0, the starting point of file reading
671
-            if (!$start_at_byte) {
672
-                $this->logger->info(sprintf("Copying %s file to tmp filesystem file %s to prevent reading changes",
673
-                    $file_info['path'], $tmp_file));
674
-                $file_stream = $start_filesystem->readStream($file_info['path']);
675
-
676
-                if (is_resource($file_stream['stream'])) {
677
-                    $this->filesystem->get_tmp_filesystem()->writeStream($tmp_file, $file_stream['stream']);
678
-                }
679
-            }
680
-
681
-            if ($this->filesystem->get_tmp_filesystem()->has($tmp_file)) {
682
-                $is_tmp = 1;
683
-                $last_position = $this->backup_archive->appendFileData($this->filesystem->get_tmp_filesystem_adapter()
684
-                                                        ->applyPathPrefix($tmp_file),
685
-                    $file_info['target_path'], $start_at_byte, $byte_limit);
686
-            } else {
687
-                $is_tmp = 0;
688
-                $last_position = $this->backup_archive->appendFileData($start_adapter->applyPathPrefix($file_info['path']),
689
-                    $file_info['target_path'], $start_at_byte, $byte_limit);
690
-            }
691
-
692
-
693
-            if ($last_position == -1) {
694
-                $bytes_wrote = $file_info['size'] - $start_at_byte;
695
-            } else {
696
-                $bytes_wrote = $last_position - $start_at_byte;
697
-            }
641
+	public function add_file_to_archive($file_info, $start_at_byte, $byte_limit = 0, $append, $filesystem)
642
+	{
698 643
 
644
+		$start_adapter = $this->filesystem->get_adapter($filesystem);
645
+		$start_filesystem = $this->filesystem->get_adapter($filesystem);
699 646
 
700
-            if ($is_tmp) {
701
-                $this->logger->info(sprintf("Appended %s bytes, starting position %s, of tmp file %s (%s) to archive %s ",
702
-                    $bytes_wrote, $start_at_byte, $tmp_file, $file_info['target_path'], $this->get_archive_name()));
703
-            } else {
704
-                $this->logger->info(sprintf("Appended %s bytes, starting position %s, of original file %s to archive %s ",
705
-                    $bytes_wrote, $start_at_byte, $file_info['target_path'], $tmp_file, $this->get_archive_name()));
706
-            }
647
+		if (!$file_info['path']) {
648
+			return;
649
+		}
707 650
 
708
-            //we delete here the isolated tmp file
709
-            if ($last_position == -1) {
710
-                if ($this->filesystem->get_tmp_filesystem_adapter()->has($tmp_file)) {
711
-                    $this->logger->info(sprintf("Deleting %s from the tmp filesystem", $tmp_file));
712
-                    $this->filesystem->get_tmp_filesystem_adapter()->delete($tmp_file);
713
-                }
714
-            }
651
+		if (isset($file_info['archive_prefix_path'])) {
652
+			$file_info['target_path'] = $file_info['archive_prefix_path'] . "/" . $file_info['path'];
653
+		} else {
654
+			$file_info['target_path'] = $file_info['path'];
655
+		}
715 656
 
716
-        }
657
+		$last_position = $start_at_byte;
658
+
659
+		//$start_adapter = $this->filesystem->get_start_adapter();
660
+
661
+		if (!$append) {
662
+			$bytes_wrote = $file_info['size'];
663
+			$this->logger->info(sprintf("Adding %s bytes of file %s to archive %s ", $bytes_wrote,
664
+				$file_info['target_path'], $this->get_archive_name_with_extension()));
665
+			$this->backup_archive->addFile($start_adapter->applyPathPrefix($file_info['path']),
666
+				$file_info['target_path']);
667
+		} else {
668
+			$tmp_file = md5($file_info['path']);
669
+
670
+			//we isolate file to tmp if we are at byte 0, the starting point of file reading
671
+			if (!$start_at_byte) {
672
+				$this->logger->info(sprintf("Copying %s file to tmp filesystem file %s to prevent reading changes",
673
+					$file_info['path'], $tmp_file));
674
+				$file_stream = $start_filesystem->readStream($file_info['path']);
675
+
676
+				if (is_resource($file_stream['stream'])) {
677
+					$this->filesystem->get_tmp_filesystem()->writeStream($tmp_file, $file_stream['stream']);
678
+				}
679
+			}
680
+
681
+			if ($this->filesystem->get_tmp_filesystem()->has($tmp_file)) {
682
+				$is_tmp = 1;
683
+				$last_position = $this->backup_archive->appendFileData($this->filesystem->get_tmp_filesystem_adapter()
684
+														->applyPathPrefix($tmp_file),
685
+					$file_info['target_path'], $start_at_byte, $byte_limit);
686
+			} else {
687
+				$is_tmp = 0;
688
+				$last_position = $this->backup_archive->appendFileData($start_adapter->applyPathPrefix($file_info['path']),
689
+					$file_info['target_path'], $start_at_byte, $byte_limit);
690
+			}
691
+
692
+
693
+			if ($last_position == -1) {
694
+				$bytes_wrote = $file_info['size'] - $start_at_byte;
695
+			} else {
696
+				$bytes_wrote = $last_position - $start_at_byte;
697
+			}
698
+
699
+
700
+			if ($is_tmp) {
701
+				$this->logger->info(sprintf("Appended %s bytes, starting position %s, of tmp file %s (%s) to archive %s ",
702
+					$bytes_wrote, $start_at_byte, $tmp_file, $file_info['target_path'], $this->get_archive_name()));
703
+			} else {
704
+				$this->logger->info(sprintf("Appended %s bytes, starting position %s, of original file %s to archive %s ",
705
+					$bytes_wrote, $start_at_byte, $file_info['target_path'], $tmp_file, $this->get_archive_name()));
706
+			}
707
+
708
+			//we delete here the isolated tmp file
709
+			if ($last_position == -1) {
710
+				if ($this->filesystem->get_tmp_filesystem_adapter()->has($tmp_file)) {
711
+					$this->logger->info(sprintf("Deleting %s from the tmp filesystem", $tmp_file));
712
+					$this->filesystem->get_tmp_filesystem_adapter()->delete($tmp_file);
713
+				}
714
+			}
717 715
 
718
-        return array($bytes_wrote, $last_position);
719
-    }
716
+		}
720 717
 
721
-    /**
722
-     * Open a TAR archive and put the file cursor at the end for data appending
723
-     *
724
-     * If $file is empty, the tar file will be created in memory
725
-     *
726
-     * @param string $file
727
-     * @throws ArchiveIOException
728
-     */
729
-    /*
718
+		return array($bytes_wrote, $last_position);
719
+	}
720
+
721
+	/**
722
+	 * Open a TAR archive and put the file cursor at the end for data appending
723
+	 *
724
+	 * If $file is empty, the tar file will be created in memory
725
+	 *
726
+	 * @param string $file
727
+	 * @throws ArchiveIOException
728
+	 */
729
+	/*
730 730
     public function openForAppend($file = '')
731 731
     {
732 732
         $this->file   = $file;
@@ -756,17 +756,17 @@  discard block
 block discarded – undo
756 756
     }
757 757
     */
758 758
 
759
-    /**
760
-     * Append data to a file to the current TAR archive using an existing file in the filesystem
761
-     *
762
-     * @param string $file path to the original file
763
-     * @param int $start starting reading position in file
764
-     * @param int $end end position in reading multiple with 512
765
-     * @param string|FileInfo $fileinfo either the name to us in archive (string) or a FileInfo oject with
766
-     * all meta data, empty to take from original
767
-     * @throws ArchiveIOException
768
-     */
769
-    /*
759
+	/**
760
+	 * Append data to a file to the current TAR archive using an existing file in the filesystem
761
+	 *
762
+	 * @param string $file path to the original file
763
+	 * @param int $start starting reading position in file
764
+	 * @param int $end end position in reading multiple with 512
765
+	 * @param string|FileInfo $fileinfo either the name to us in archive (string) or a FileInfo oject with
766
+	 * all meta data, empty to take from original
767
+	 * @throws ArchiveIOException
768
+	 */
769
+	/*
770 770
      * public function appendFileData($file, $fileinfo = '', $start = 0, $limit = 0)
771 771
     {
772 772
 		$end = $start+($limit*512);
@@ -822,15 +822,15 @@  discard block
 block discarded – undo
822 822
         return $last_position;
823 823
     }*/
824 824
 
825
-    /**
826
-     * Adds a file to a TAR archive by appending it's data
827
-     *
828
-     * @param string $archive name of the archive file
829
-     * @param string $file name of the file to read data from
830
-     * @param string $start start position from where to start reading data
831
-     * @throws ArchiveIOException
832
-     */
833
-    /*public function addFileToArchive($archive, $file, $start = 0)
825
+	/**
826
+	 * Adds a file to a TAR archive by appending it's data
827
+	 *
828
+	 * @param string $archive name of the archive file
829
+	 * @param string $file name of the file to read data from
830
+	 * @param string $start start position from where to start reading data
831
+	 * @throws ArchiveIOException
832
+	 */
833
+	/*public function addFileToArchive($archive, $file, $start = 0)
834 834
     {
835 835
         $this->openForAppend($archive);
836 836
         return $start = $this->appendFileData($file, $start, $this->file_size_per_request_limit);
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 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
     /*
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
         $headers = array('Content-Type: text/html; charset=UTF-8');
230 230
 
231 231
         if ($admin_email and $from) {
232
-            $headers[] = 'From: ' . $from . ' <' . $admin_email . '>';
232
+            $headers[] = 'From: '.$from.' <'.$admin_email.'>';
233 233
         }
234 234
 
235 235
         $return = wp_mail($to, $subject, $body, $headers);
@@ -302,18 +302,18 @@  discard block
 block discarded – undo
302 302
         $body .= "<br />";
303 303
 
304 304
         if (isset($params['backup_params']->backup_comments)) {
305
-            $body .= __("Backup Comments: ") . $params['backup_params']->backup_comments;
305
+            $body .= __("Backup Comments: ").$params['backup_params']->backup_comments;
306 306
             $body .= "<br /><br />";
307 307
         }
308 308
 
309 309
         if ($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) {
310
-            $body .= __("Latest 50 Log Lines: ") . "<br />" . implode("<br />\n",
310
+            $body .= __("Latest 50 Log Lines: ")."<br />".implode("<br />\n",
311 311
                                                                         $this->logger->getLastDebugLines(50));
312 312
         }
313 313
 
314 314
         $attachments = $this->filesystem->get_backup_attachments();
315 315
 
316
-        $attachments_archive = $this->xcloner_settings->get_xcloner_tmp_path() . DS . "info.tgz";
316
+        $attachments_archive = $this->xcloner_settings->get_xcloner_tmp_path().DS."info.tgz";
317 317
 
318 318
         $tar = new Tar();
319 319
         $tar->create($attachments_archive);
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 
328 328
         $admin_email = get_option("admin_email");
329 329
 
330
-        $headers = array('Content-Type: text/html; charset=UTF-8', 'From: ' . $from . ' <' . $admin_email . '>');
330
+        $headers = array('Content-Type: text/html; charset=UTF-8', 'From: '.$from.' <'.$admin_email.'>');
331 331
 
332 332
         $return = wp_mail($to, $subject, $body, $headers, array($attachments_archive));
333 333
 
@@ -367,14 +367,14 @@  discard block
 block discarded – undo
367 367
         if ($init) {
368 368
             $this->logger->info(sprintf(__("Initializing the backup archive %s"), $this->get_archive_name()));
369 369
 
370
-            $this->backup_archive->create($archive_info->getPath() . DS . $archive_info->getFilename());
370
+            $this->backup_archive->create($archive_info->getPath().DS.$archive_info->getFilename());
371 371
 
372 372
             $return['extra']['backup_init'] = 1;
373 373
 
374 374
         } else {
375 375
             $this->logger->info(sprintf(__("Opening for append the backup archive %s"), $this->get_archive_name()));
376 376
 
377
-            $this->backup_archive->openForAppend($archive_info->getPath() . DS . $archive_info->getFilename());
377
+            $this->backup_archive->openForAppend($archive_info->getPath().DS.$archive_info->getFilename());
378 378
 
379 379
             $return['extra']['backup_init'] = 0;
380 380
 
@@ -578,13 +578,13 @@  discard block
 block discarded – undo
578 578
      */
579 579
     private function write_multipart_file($path = "")
580 580
     {
581
-        if(!$path) {
581
+        if (!$path) {
582 582
             $path = $this->get_archive_name_with_extension();
583 583
         }
584 584
 
585 585
         $file = $this->filesystem->get_filesystem("storage_filesystem_append")->getMetadata($path);
586 586
         //print_r($file_info);
587
-        $line = '"' . $file['path'] . '","' . $file['timestamp'] . '","' . $file['size'] . '"' . PHP_EOL;
587
+        $line = '"'.$file['path'].'","'.$file['timestamp'].'","'.$file['size'].'"'.PHP_EOL;
588 588
 
589 589
 
590 590
         $this->filesystem->get_filesystem("storage_filesystem_append")
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
         $this->backup_archive = new Tar();
628 628
         $this->backup_archive->setCompression($this->compression_level);
629 629
         $archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
630
-        $this->backup_archive->create($archive_info->getPath() . DS . $archive_info->getFilename());
630
+        $this->backup_archive->create($archive_info->getPath().DS.$archive_info->getFilename());
631 631
 
632 632
         return array($archive_info, $part);
633 633
 
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
         }
650 650
 
651 651
         if (isset($file_info['archive_prefix_path'])) {
652
-            $file_info['target_path'] = $file_info['archive_prefix_path'] . "/" . $file_info['path'];
652
+            $file_info['target_path'] = $file_info['archive_prefix_path']."/".$file_info['path'];
653 653
         } else {
654 654
             $file_info['target_path'] = $file_info['path'];
655 655
         }
Please login to merge, or discard this patch.
includes/class-xcloner-encryption.php 4 patches
Doc Comments   +8 added lines, -5 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     /**
71 71
      * Returns the filename with encrypted suffix
72 72
      *
73
-     * @param $filename
73
+     * @param string $filename
74 74
      * @return string
75 75
      */
76 76
     public function get_encrypted_target_backup_file_name( $filename ) {
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
     /**
82 82
      * Returns the filename without encrypted suffix
83 83
      *
84
-     * @param $filename
84
+     * @param string $filename
85 85
      * @return string
86 86
      */
87 87
     public function get_decrypted_target_backup_file_name( $filename ) {
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
      * @param string $dest   File name where the encryped file should be written to.
97 97
      * @param string $key    The key used for the encryption
98 98
      * @param int $start   Start position for reading when doing incremental mode.
99
-     * @param string $iv   The IV key to use.
100
-     * @param bool $verfication   Weather we should we try to verify the decryption.
99
+     * @param integer $iv   The IV key to use.
100
+     * @param bool $verification   Weather we should we try to verify the decryption.
101 101
      * @return string|false  Returns the file name that has been created or FALSE if an error occured
102 102
     */
103 103
     public function encrypt_file($source, $dest = "" , $key= "", $start = 0, $iv = 0, $verification = true, $recursive = false)
@@ -206,6 +206,9 @@  discard block
 block discarded – undo
206 206
         return array("target_file" => $dest, "finished" => 1);
207 207
     }
208 208
 
209
+    /**
210
+     * @param string $file
211
+     */
209 212
     public function verify_encrypted_file($file) {
210 213
         if(is_object($this->logger)) {
211 214
             $this->logger->info(sprintf('Verifying encrypted file %s', $file));
@@ -224,7 +227,7 @@  discard block
 block discarded – undo
224 227
      * @param string $dest   File name where the decryped file should be written to.
225 228
      * @param string $key    The key used for the decryption (must be the same as for encryption)
226 229
      * @param int $start   Start position for reading when doing incremental mode.
227
-     * @param string $iv   The IV key to use.
230
+     * @param integer $iv   The IV key to use.
228 231
      * @return string|false  Returns the file name that has been created or FALSE if an error occured
229 232
      */
230 233
     public function decrypt_file($source, $dest = "", $key = "", $start = 0, $iv = 0, $recursive = false)
Please login to merge, or discard this patch.
Indentation   +359 added lines, -359 removed lines patch added patch discarded remove patch
@@ -10,370 +10,370 @@
 block discarded – undo
10 10
 
11 11
 class Xcloner_Encryption
12 12
 {
13
-    const FILE_ENCRYPTION_BLOCKS = 1024*1024;
14
-    const FILE_ENCRYPTION_SUFFIX = ".encrypted";
15
-    const FILE_DECRYPTION_SUFFIX = ".decrypted";
16
-
17
-    private $xcloner_settings;
18
-    private $logger;
19
-    private $verification = false;
20
-
21
-    public function __construct(Xcloner $xcloner_container)
22
-    {
23
-        $this->xcloner_container = $xcloner_container;
24
-        if(method_exists($xcloner_container, 'get_xcloner_settings')) {
25
-            $this->xcloner_settings = $xcloner_container->get_xcloner_settings();
26
-        }else{
27
-            $this->xcloner_settings = "";
28
-        }
29
-
30
-        if(method_exists($xcloner_container, 'get_xcloner_logger')) {
31
-            $this->logger = $xcloner_container->get_xcloner_logger()->withName("xcloner_encryption");
32
-        }else{
33
-            $this->logger = "";
34
-        }
35
-    }
36
-
37
-    /**
38
-     * Returns the backup encryption key
39
-     *
40
-     * @return SECURE_AUTH_SALT|null
41
-     */
42
-    public function get_backup_encryption_key()
43
-    {
44
-        if(is_object($this->xcloner_settings)) {
45
-            return $this->xcloner_settings->get_xcloner_encryption_key();
46
-        }
47
-
48
-        return false;
49
-
50
-    }
51
-
52
-    /**
53
-     * Check if provided filename has encrypted suffix
54
-     *
55
-     * @param $filename
56
-     * @return bool
57
-     */
58
-    public function is_encrypted_file($filename) {
59
-        $fp = fopen($this->get_xcloner_path() .$filename, 'r');
60
-        $encryption_length = fread($fp, 16);
61
-        fclose($fp);
62
-        if(is_numeric($encryption_length)) {
63
-            return true;
64
-        }
65
-
66
-        return false;
67
-
68
-    }
69
-
70
-    /**
71
-     * Returns the filename with encrypted suffix
72
-     *
73
-     * @param $filename
74
-     * @return string
75
-     */
76
-    public function get_encrypted_target_backup_file_name( $filename ) {
77
-
78
-        return str_replace(self::FILE_DECRYPTION_SUFFIX, "", $filename) . self::FILE_ENCRYPTION_SUFFIX;
79
-    }
80
-
81
-    /**
82
-     * Returns the filename without encrypted suffix
83
-     *
84
-     * @param $filename
85
-     * @return string
86
-     */
87
-    public function get_decrypted_target_backup_file_name( $filename ) {
88
-
89
-        return str_replace(self::FILE_ENCRYPTION_SUFFIX, "", $filename) . self::FILE_DECRYPTION_SUFFIX;
90
-    }
91
-
92
-    /**
93
-     * Encrypt the passed file and saves the result in a new file with ".enc" as suffix.
94
-     *
95
-     * @param string $source Path to file that should be encrypted
96
-     * @param string $dest   File name where the encryped file should be written to.
97
-     * @param string $key    The key used for the encryption
98
-     * @param int $start   Start position for reading when doing incremental mode.
99
-     * @param string $iv   The IV key to use.
100
-     * @param bool $verfication   Weather we should we try to verify the decryption.
101
-     * @return string|false  Returns the file name that has been created or FALSE if an error occured
102
-    */
103
-    public function encrypt_file($source, $dest = "" , $key= "", $start = 0, $iv = 0, $verification = true, $recursive = false)
104
-    {
105
-        if(is_object($this->logger)) {
106
-            $this->logger->info(sprintf('Encrypting file %s at position %d IV %s', $source, $start, base64_encode($iv)));
107
-        }
108
-
109
-        //$key = substr(sha1($key, true), 0, 16);
110
-        if(!$key){
111
-            $key = self::get_backup_encryption_key();
112
-        }
113
-        $key_digest = openssl_digest ($key, "md5", true);
114
-
115
-        $keep_local = 1;
116
-        if(!$dest) {
117
-            $dest = $this->get_encrypted_target_backup_file_name($source);
118
-            $keep_local = 0;
119
-        }
120
-
121
-        if(!$iv || !$start) {
122
-            //$iv = openssl_random_pseudo_bytes(16);
123
-            $iv = str_pad(self::FILE_ENCRYPTION_BLOCKS, 16, "0000000000000000", STR_PAD_LEFT);
124
-        }
125
-
126
-        if( !$start ) {
127
-            $fpOut = fopen($this->get_xcloner_path() .$dest, 'w');
128
-        }else{
129
-            $fpOut = fopen($this->get_xcloner_path() .$dest, 'a');
130
-        }
131
-
132
-        if ( $fpOut ) {
133
-
134
-            // Put the initialization vector to the beginning of the file
135
-            if(!$start) {
136
-                fwrite($fpOut, $iv);
137
-            }
138
-
139
-            if (file_exists($this->get_xcloner_path() .$source) &&
140
-                $fpIn = fopen($this->get_xcloner_path() .$source, 'rb')) {
141
-
142
-                fseek($fpIn, (int)$start);
143
-
144
-                if (!feof($fpIn)) {
145
-
146
-                    $plaintext = fread($fpIn, 16 * self::FILE_ENCRYPTION_BLOCKS);
147
-                    $ciphertext = openssl_encrypt($plaintext, 'AES-128-CBC', $key_digest, OPENSSL_RAW_DATA, $iv);
148
-
149
-                    // Use the first 16 bytes of the ciphertext as the next initialization vector
150
-                    $iv = substr($ciphertext, 0, 16);
151
-                    //$iv = openssl_random_pseudo_bytes(16);
152
-
153
-                    fwrite($fpOut, $ciphertext);
154
-
155
-                    $start = ftell($fpIn);
156
-
157
-                    fclose($fpOut );
158
-
159
-                    if(!feof($fpIn)) {
160
-                        fclose($fpIn);
161
-                        //echo "\n NEW:".$key.md5($iv);
162
-                        //self::encryptFile($source, $dest, $key, $start, $iv);
163
-                        if($recursive ){
164
-                            $this->encrypt_file($source, $dest, $key, $start, ($iv), $verification, $recursive);
165
-                        }else {
166
-
167
-                            if(($iv) != base64_decode(base64_encode($iv)))
168
-                            {
169
-                                throw new \Exception('Could not encode IV for transport');
170
-                            }
171
-
172
-                            return array(
173
-                                "start" => $start,
174
-                                "iv" => base64_encode($iv),
175
-                                "target_file" => $dest,
176
-                                "finished" => 0
177
-                            );
178
-                        }
179
-                    }
180
-
181
-                }
182
-            } else {
183
-                if(is_object($this->logger)) {
184
-                    $this->logger->error('Unable to read source file for encryption.');
185
-                }
186
-                throw new \Exception("Unable to read source file for encryption.");
187
-            }
188
-        } else {
189
-            if(is_object($this->logger)) {
190
-                $this->logger->error('Unable to write destination file for encryption.');
191
-            }
192
-            throw new \Exception("Unable to write destination file for encryption.");
193
-        }
194
-
195
-        if($verification) {
196
-            $this->verify_encrypted_file($dest);
197
-        }
198
-
199
-        //we replace the original backup with the encrypted one
200
-        if( !$keep_local && copy($this->get_xcloner_path() .$dest,
201
-             $this->get_xcloner_path() .$source) ) {
202
-            unlink($this->get_xcloner_path() .$dest);
203
-        }
204
-
205
-
206
-        return array("target_file" => $dest, "finished" => 1);
207
-    }
208
-
209
-    public function verify_encrypted_file($file) {
210
-        if(is_object($this->logger)) {
211
-            $this->logger->info(sprintf('Verifying encrypted file %s', $file));
212
-        }
213
-
214
-        $this->verification = true;
215
-        $this->decrypt_file($file);
216
-        $this->verification = false;
217
-    }
218
-
219
-    /**
220
-     * Dencrypt the passed file and saves the result in a new file, removing the
221
-     * last 4 characters from file name.
222
-     *
223
-     * @param string $source Path to file that should be decrypted
224
-     * @param string $dest   File name where the decryped file should be written to.
225
-     * @param string $key    The key used for the decryption (must be the same as for encryption)
226
-     * @param int $start   Start position for reading when doing incremental mode.
227
-     * @param string $iv   The IV key to use.
228
-     * @return string|false  Returns the file name that has been created or FALSE if an error occured
229
-     */
230
-    public function decrypt_file($source, $dest = "", $key = "", $start = 0, $iv = 0, $recursive = false)
231
-    {
232
-        if(is_object($this->logger)) {
233
-            $this->logger->info(sprintf('Decrypting file %s at position %d with IV %s', $source, $start, base64_encode($iv)));
234
-        }
235
-
236
-        //$key = substr(sha1($key, true), 0, 16);
237
-        if(!$key){
238
-            $key = self::get_backup_encryption_key();
239
-        }
240
-
241
-        $key_digest = openssl_digest ($key, "md5", true);
242
-
243
-        $keep_local = 1;
244
-        if(!$dest) {
245
-            $dest = $this->get_decrypted_target_backup_file_name($source);
246
-            $keep_local = 0;
247
-        }
248
-
249
-        if( !$start ) {
250
-            if($this->verification){
251
-                $fpOut = fopen("php://stdout", 'w');
252
-            }else {
253
-                $fpOut = fopen($this->get_xcloner_path() . $dest, 'w');
254
-            }
255
-        }else{
256
-            if($this->verification){
257
-                $fpOut = fopen("php://stdout", 'a');
258
-            }else {
259
-                $fpOut = fopen($this->get_xcloner_path() . $dest, 'a');
260
-            }
261
-        }
262
-
263
-        if ( $fpOut ) {
264
-            if ( file_exists($this->get_xcloner_path() .$source) &&
265
-                $fpIn = fopen($this->get_xcloner_path() .$source, 'rb')) {
266
-
267
-                $encryption_length = (int)fread($fpIn, 16);
268
-                if(!$encryption_length) {
269
-                    $encryption_length = self::FILE_ENCRYPTION_BLOCKS;
270
-                }
271
-
272
-                fseek($fpIn, (int)$start);
273
-
274
-                // Get the initialzation vector from the beginning of the file
275
-                if(!$iv) {
276
-                    $iv = fread($fpIn, 16);
277
-                }
278
-
279
-                if (!feof($fpIn)) {
280
-
281
-                    // we have to read one block more for decrypting than for encrypting
282
-                    $ciphertext = fread($fpIn, 16 * ($encryption_length + 1));
283
-                    $plaintext = openssl_decrypt($ciphertext, 'AES-128-CBC', $key_digest, OPENSSL_RAW_DATA, $iv);
284
-
285
-                    if(!$plaintext){
286
-                        unlink($this->get_xcloner_path() . $dest);
287
-                        if(is_object($this->logger)) {
288
-                            $this->logger->error('Backup decryption failed, please check your provided Encryption Key.');
289
-                        }
290
-                        throw new \Exception("Backup decryption failed, please check your provided Encryption Key.");
291
-                    }
292
-
293
-                    // Use the first 16 bytes of the ciphertext as the next initialization vector
294
-                    $iv = substr($ciphertext, 0, 16);
295
-
296
-                    if( !$this->verification) {
297
-                        fwrite($fpOut, $plaintext);
298
-                    }
299
-
300
-                    $start = ftell($fpIn);
301
-
302
-                    fclose($fpOut );
303
-
304
-                    if(!feof($fpIn)) {
305
-                        fclose($fpIn);
306
-                        if($this->verification || $recursive) {
307
-                            $ciphertext = "";
308
-                            $plaintext = "";
309
-                            $this->decrypt_file($source, $dest, $key, $start, $iv, $recursive);
310
-                        }else {
311
-                            if(($iv) != base64_decode(base64_encode($iv)))
312
-                            {
313
-                                throw new \Exception('Could not encode IV for transport');
314
-                            }
315
-
316
-                            return array(
317
-                                "start" => $start,
318
-                                "encryption_length" => $encryption_length,
319
-                                "iv" => base64_encode($iv),
320
-                                "target_file" => $dest,
321
-                                "finished" => 0
322
-                            );
323
-                    }
324
-                    }
325
-
326
-                }
327
-            } else {
328
-                if(is_object($this->logger)) {
329
-                    $this->logger->error('Unable to read source file for decryption');
330
-                }
331
-                throw new \Exception("Unable to read source file for decryption");
332
-            }
333
-        } else {
334
-            if(is_object($this->logger)) {
335
-                $this->logger->error('Unable to write destination file for decryption');
336
-            }
337
-            throw new \Exception("Unable to write destination file for decryption");
338
-        }
339
-
340
-        //we replace the original backup with the encrypted one
341
-        if( !$keep_local && !$this->verification && copy($this->get_xcloner_path()  .$dest,
342
-            $this->get_xcloner_path()  .$source) ) {
343
-            unlink($this->get_xcloner_path()  .$dest);
344
-        }
345
-
346
-        return array("target_file" => $dest, "finished" => 1);
347
-    }
348
-
349
-    public function get_xcloner_path(){
350
-        if(is_object($this->xcloner_settings)) {
351
-            return $this->xcloner_settings->get_xcloner_store_path() . DS;
352
-        }
353
-
354
-        return null;
355
-    }
13
+	const FILE_ENCRYPTION_BLOCKS = 1024*1024;
14
+	const FILE_ENCRYPTION_SUFFIX = ".encrypted";
15
+	const FILE_DECRYPTION_SUFFIX = ".decrypted";
16
+
17
+	private $xcloner_settings;
18
+	private $logger;
19
+	private $verification = false;
20
+
21
+	public function __construct(Xcloner $xcloner_container)
22
+	{
23
+		$this->xcloner_container = $xcloner_container;
24
+		if(method_exists($xcloner_container, 'get_xcloner_settings')) {
25
+			$this->xcloner_settings = $xcloner_container->get_xcloner_settings();
26
+		}else{
27
+			$this->xcloner_settings = "";
28
+		}
29
+
30
+		if(method_exists($xcloner_container, 'get_xcloner_logger')) {
31
+			$this->logger = $xcloner_container->get_xcloner_logger()->withName("xcloner_encryption");
32
+		}else{
33
+			$this->logger = "";
34
+		}
35
+	}
36
+
37
+	/**
38
+	 * Returns the backup encryption key
39
+	 *
40
+	 * @return SECURE_AUTH_SALT|null
41
+	 */
42
+	public function get_backup_encryption_key()
43
+	{
44
+		if(is_object($this->xcloner_settings)) {
45
+			return $this->xcloner_settings->get_xcloner_encryption_key();
46
+		}
47
+
48
+		return false;
49
+
50
+	}
51
+
52
+	/**
53
+	 * Check if provided filename has encrypted suffix
54
+	 *
55
+	 * @param $filename
56
+	 * @return bool
57
+	 */
58
+	public function is_encrypted_file($filename) {
59
+		$fp = fopen($this->get_xcloner_path() .$filename, 'r');
60
+		$encryption_length = fread($fp, 16);
61
+		fclose($fp);
62
+		if(is_numeric($encryption_length)) {
63
+			return true;
64
+		}
65
+
66
+		return false;
67
+
68
+	}
69
+
70
+	/**
71
+	 * Returns the filename with encrypted suffix
72
+	 *
73
+	 * @param $filename
74
+	 * @return string
75
+	 */
76
+	public function get_encrypted_target_backup_file_name( $filename ) {
77
+
78
+		return str_replace(self::FILE_DECRYPTION_SUFFIX, "", $filename) . self::FILE_ENCRYPTION_SUFFIX;
79
+	}
80
+
81
+	/**
82
+	 * Returns the filename without encrypted suffix
83
+	 *
84
+	 * @param $filename
85
+	 * @return string
86
+	 */
87
+	public function get_decrypted_target_backup_file_name( $filename ) {
88
+
89
+		return str_replace(self::FILE_ENCRYPTION_SUFFIX, "", $filename) . self::FILE_DECRYPTION_SUFFIX;
90
+	}
91
+
92
+	/**
93
+	 * Encrypt the passed file and saves the result in a new file with ".enc" as suffix.
94
+	 *
95
+	 * @param string $source Path to file that should be encrypted
96
+	 * @param string $dest   File name where the encryped file should be written to.
97
+	 * @param string $key    The key used for the encryption
98
+	 * @param int $start   Start position for reading when doing incremental mode.
99
+	 * @param string $iv   The IV key to use.
100
+	 * @param bool $verfication   Weather we should we try to verify the decryption.
101
+	 * @return string|false  Returns the file name that has been created or FALSE if an error occured
102
+	 */
103
+	public function encrypt_file($source, $dest = "" , $key= "", $start = 0, $iv = 0, $verification = true, $recursive = false)
104
+	{
105
+		if(is_object($this->logger)) {
106
+			$this->logger->info(sprintf('Encrypting file %s at position %d IV %s', $source, $start, base64_encode($iv)));
107
+		}
108
+
109
+		//$key = substr(sha1($key, true), 0, 16);
110
+		if(!$key){
111
+			$key = self::get_backup_encryption_key();
112
+		}
113
+		$key_digest = openssl_digest ($key, "md5", true);
114
+
115
+		$keep_local = 1;
116
+		if(!$dest) {
117
+			$dest = $this->get_encrypted_target_backup_file_name($source);
118
+			$keep_local = 0;
119
+		}
120
+
121
+		if(!$iv || !$start) {
122
+			//$iv = openssl_random_pseudo_bytes(16);
123
+			$iv = str_pad(self::FILE_ENCRYPTION_BLOCKS, 16, "0000000000000000", STR_PAD_LEFT);
124
+		}
125
+
126
+		if( !$start ) {
127
+			$fpOut = fopen($this->get_xcloner_path() .$dest, 'w');
128
+		}else{
129
+			$fpOut = fopen($this->get_xcloner_path() .$dest, 'a');
130
+		}
131
+
132
+		if ( $fpOut ) {
133
+
134
+			// Put the initialization vector to the beginning of the file
135
+			if(!$start) {
136
+				fwrite($fpOut, $iv);
137
+			}
138
+
139
+			if (file_exists($this->get_xcloner_path() .$source) &&
140
+				$fpIn = fopen($this->get_xcloner_path() .$source, 'rb')) {
141
+
142
+				fseek($fpIn, (int)$start);
143
+
144
+				if (!feof($fpIn)) {
145
+
146
+					$plaintext = fread($fpIn, 16 * self::FILE_ENCRYPTION_BLOCKS);
147
+					$ciphertext = openssl_encrypt($plaintext, 'AES-128-CBC', $key_digest, OPENSSL_RAW_DATA, $iv);
148
+
149
+					// Use the first 16 bytes of the ciphertext as the next initialization vector
150
+					$iv = substr($ciphertext, 0, 16);
151
+					//$iv = openssl_random_pseudo_bytes(16);
152
+
153
+					fwrite($fpOut, $ciphertext);
154
+
155
+					$start = ftell($fpIn);
156
+
157
+					fclose($fpOut );
158
+
159
+					if(!feof($fpIn)) {
160
+						fclose($fpIn);
161
+						//echo "\n NEW:".$key.md5($iv);
162
+						//self::encryptFile($source, $dest, $key, $start, $iv);
163
+						if($recursive ){
164
+							$this->encrypt_file($source, $dest, $key, $start, ($iv), $verification, $recursive);
165
+						}else {
166
+
167
+							if(($iv) != base64_decode(base64_encode($iv)))
168
+							{
169
+								throw new \Exception('Could not encode IV for transport');
170
+							}
171
+
172
+							return array(
173
+								"start" => $start,
174
+								"iv" => base64_encode($iv),
175
+								"target_file" => $dest,
176
+								"finished" => 0
177
+							);
178
+						}
179
+					}
180
+
181
+				}
182
+			} else {
183
+				if(is_object($this->logger)) {
184
+					$this->logger->error('Unable to read source file for encryption.');
185
+				}
186
+				throw new \Exception("Unable to read source file for encryption.");
187
+			}
188
+		} else {
189
+			if(is_object($this->logger)) {
190
+				$this->logger->error('Unable to write destination file for encryption.');
191
+			}
192
+			throw new \Exception("Unable to write destination file for encryption.");
193
+		}
194
+
195
+		if($verification) {
196
+			$this->verify_encrypted_file($dest);
197
+		}
198
+
199
+		//we replace the original backup with the encrypted one
200
+		if( !$keep_local && copy($this->get_xcloner_path() .$dest,
201
+			 $this->get_xcloner_path() .$source) ) {
202
+			unlink($this->get_xcloner_path() .$dest);
203
+		}
204
+
205
+
206
+		return array("target_file" => $dest, "finished" => 1);
207
+	}
208
+
209
+	public function verify_encrypted_file($file) {
210
+		if(is_object($this->logger)) {
211
+			$this->logger->info(sprintf('Verifying encrypted file %s', $file));
212
+		}
213
+
214
+		$this->verification = true;
215
+		$this->decrypt_file($file);
216
+		$this->verification = false;
217
+	}
218
+
219
+	/**
220
+	 * Dencrypt the passed file and saves the result in a new file, removing the
221
+	 * last 4 characters from file name.
222
+	 *
223
+	 * @param string $source Path to file that should be decrypted
224
+	 * @param string $dest   File name where the decryped file should be written to.
225
+	 * @param string $key    The key used for the decryption (must be the same as for encryption)
226
+	 * @param int $start   Start position for reading when doing incremental mode.
227
+	 * @param string $iv   The IV key to use.
228
+	 * @return string|false  Returns the file name that has been created or FALSE if an error occured
229
+	 */
230
+	public function decrypt_file($source, $dest = "", $key = "", $start = 0, $iv = 0, $recursive = false)
231
+	{
232
+		if(is_object($this->logger)) {
233
+			$this->logger->info(sprintf('Decrypting file %s at position %d with IV %s', $source, $start, base64_encode($iv)));
234
+		}
235
+
236
+		//$key = substr(sha1($key, true), 0, 16);
237
+		if(!$key){
238
+			$key = self::get_backup_encryption_key();
239
+		}
240
+
241
+		$key_digest = openssl_digest ($key, "md5", true);
242
+
243
+		$keep_local = 1;
244
+		if(!$dest) {
245
+			$dest = $this->get_decrypted_target_backup_file_name($source);
246
+			$keep_local = 0;
247
+		}
248
+
249
+		if( !$start ) {
250
+			if($this->verification){
251
+				$fpOut = fopen("php://stdout", 'w');
252
+			}else {
253
+				$fpOut = fopen($this->get_xcloner_path() . $dest, 'w');
254
+			}
255
+		}else{
256
+			if($this->verification){
257
+				$fpOut = fopen("php://stdout", 'a');
258
+			}else {
259
+				$fpOut = fopen($this->get_xcloner_path() . $dest, 'a');
260
+			}
261
+		}
262
+
263
+		if ( $fpOut ) {
264
+			if ( file_exists($this->get_xcloner_path() .$source) &&
265
+				$fpIn = fopen($this->get_xcloner_path() .$source, 'rb')) {
266
+
267
+				$encryption_length = (int)fread($fpIn, 16);
268
+				if(!$encryption_length) {
269
+					$encryption_length = self::FILE_ENCRYPTION_BLOCKS;
270
+				}
271
+
272
+				fseek($fpIn, (int)$start);
273
+
274
+				// Get the initialzation vector from the beginning of the file
275
+				if(!$iv) {
276
+					$iv = fread($fpIn, 16);
277
+				}
278
+
279
+				if (!feof($fpIn)) {
280
+
281
+					// we have to read one block more for decrypting than for encrypting
282
+					$ciphertext = fread($fpIn, 16 * ($encryption_length + 1));
283
+					$plaintext = openssl_decrypt($ciphertext, 'AES-128-CBC', $key_digest, OPENSSL_RAW_DATA, $iv);
284
+
285
+					if(!$plaintext){
286
+						unlink($this->get_xcloner_path() . $dest);
287
+						if(is_object($this->logger)) {
288
+							$this->logger->error('Backup decryption failed, please check your provided Encryption Key.');
289
+						}
290
+						throw new \Exception("Backup decryption failed, please check your provided Encryption Key.");
291
+					}
292
+
293
+					// Use the first 16 bytes of the ciphertext as the next initialization vector
294
+					$iv = substr($ciphertext, 0, 16);
295
+
296
+					if( !$this->verification) {
297
+						fwrite($fpOut, $plaintext);
298
+					}
299
+
300
+					$start = ftell($fpIn);
301
+
302
+					fclose($fpOut );
303
+
304
+					if(!feof($fpIn)) {
305
+						fclose($fpIn);
306
+						if($this->verification || $recursive) {
307
+							$ciphertext = "";
308
+							$plaintext = "";
309
+							$this->decrypt_file($source, $dest, $key, $start, $iv, $recursive);
310
+						}else {
311
+							if(($iv) != base64_decode(base64_encode($iv)))
312
+							{
313
+								throw new \Exception('Could not encode IV for transport');
314
+							}
315
+
316
+							return array(
317
+								"start" => $start,
318
+								"encryption_length" => $encryption_length,
319
+								"iv" => base64_encode($iv),
320
+								"target_file" => $dest,
321
+								"finished" => 0
322
+							);
323
+					}
324
+					}
325
+
326
+				}
327
+			} else {
328
+				if(is_object($this->logger)) {
329
+					$this->logger->error('Unable to read source file for decryption');
330
+				}
331
+				throw new \Exception("Unable to read source file for decryption");
332
+			}
333
+		} else {
334
+			if(is_object($this->logger)) {
335
+				$this->logger->error('Unable to write destination file for decryption');
336
+			}
337
+			throw new \Exception("Unable to write destination file for decryption");
338
+		}
339
+
340
+		//we replace the original backup with the encrypted one
341
+		if( !$keep_local && !$this->verification && copy($this->get_xcloner_path()  .$dest,
342
+			$this->get_xcloner_path()  .$source) ) {
343
+			unlink($this->get_xcloner_path()  .$dest);
344
+		}
345
+
346
+		return array("target_file" => $dest, "finished" => 1);
347
+	}
348
+
349
+	public function get_xcloner_path(){
350
+		if(is_object($this->xcloner_settings)) {
351
+			return $this->xcloner_settings->get_xcloner_store_path() . DS;
352
+		}
353
+
354
+		return null;
355
+	}
356 356
 
357 357
 }
358 358
 
359 359
 
360 360
 try {
361 361
 
362
-    if(isset($argv[1])) {
363
-
364
-        class Xcloner {
365
-            public function __construct()
366
-            {
367
-            }
368
-        }
369
-        $xcloner_encryption = new Xcloner_Encryption( new Xcloner() );
370
-
371
-        if ($argv[1] == "-e") {
372
-            $xcloner_encryption->encrypt_file($argv[2], $argv[2] . ".enc", $argv[4], '', '', '', true);
373
-        } elseif ($argv[1] == "-d") {
374
-            $xcloner_encryption->decrypt_file($argv[2], $argv[2] . ".dec", $argv[4], '', '', true);
375
-        }
376
-    }
362
+	if(isset($argv[1])) {
363
+
364
+		class Xcloner {
365
+			public function __construct()
366
+			{
367
+			}
368
+		}
369
+		$xcloner_encryption = new Xcloner_Encryption( new Xcloner() );
370
+
371
+		if ($argv[1] == "-e") {
372
+			$xcloner_encryption->encrypt_file($argv[2], $argv[2] . ".enc", $argv[4], '', '', '', true);
373
+		} elseif ($argv[1] == "-d") {
374
+			$xcloner_encryption->decrypt_file($argv[2], $argv[2] . ".dec", $argv[4], '', '', true);
375
+		}
376
+	}
377 377
 }catch(\Exception $e) {
378
-    echo "CAUGHT: " . $e->getMessage();
378
+	echo "CAUGHT: " . $e->getMessage();
379 379
 }
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
 class Xcloner_Encryption
12 12
 {
13
-    const FILE_ENCRYPTION_BLOCKS = 1024*1024;
13
+    const FILE_ENCRYPTION_BLOCKS = 1024 * 1024;
14 14
     const FILE_ENCRYPTION_SUFFIX = ".encrypted";
15 15
     const FILE_DECRYPTION_SUFFIX = ".decrypted";
16 16
 
@@ -21,15 +21,15 @@  discard block
 block discarded – undo
21 21
     public function __construct(Xcloner $xcloner_container)
22 22
     {
23 23
         $this->xcloner_container = $xcloner_container;
24
-        if(method_exists($xcloner_container, 'get_xcloner_settings')) {
24
+        if (method_exists($xcloner_container, 'get_xcloner_settings')) {
25 25
             $this->xcloner_settings = $xcloner_container->get_xcloner_settings();
26
-        }else{
26
+        } else {
27 27
             $this->xcloner_settings = "";
28 28
         }
29 29
 
30
-        if(method_exists($xcloner_container, 'get_xcloner_logger')) {
30
+        if (method_exists($xcloner_container, 'get_xcloner_logger')) {
31 31
             $this->logger = $xcloner_container->get_xcloner_logger()->withName("xcloner_encryption");
32
-        }else{
32
+        } else {
33 33
             $this->logger = "";
34 34
         }
35 35
     }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function get_backup_encryption_key()
43 43
     {
44
-        if(is_object($this->xcloner_settings)) {
44
+        if (is_object($this->xcloner_settings)) {
45 45
             return $this->xcloner_settings->get_xcloner_encryption_key();
46 46
         }
47 47
 
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
      * @return bool
57 57
      */
58 58
     public function is_encrypted_file($filename) {
59
-        $fp = fopen($this->get_xcloner_path() .$filename, 'r');
59
+        $fp = fopen($this->get_xcloner_path().$filename, 'r');
60 60
         $encryption_length = fread($fp, 16);
61 61
         fclose($fp);
62
-        if(is_numeric($encryption_length)) {
62
+        if (is_numeric($encryption_length)) {
63 63
             return true;
64 64
         }
65 65
 
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
      * @param $filename
74 74
      * @return string
75 75
      */
76
-    public function get_encrypted_target_backup_file_name( $filename ) {
76
+    public function get_encrypted_target_backup_file_name($filename) {
77 77
 
78
-        return str_replace(self::FILE_DECRYPTION_SUFFIX, "", $filename) . self::FILE_ENCRYPTION_SUFFIX;
78
+        return str_replace(self::FILE_DECRYPTION_SUFFIX, "", $filename).self::FILE_ENCRYPTION_SUFFIX;
79 79
     }
80 80
 
81 81
     /**
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
      * @param $filename
85 85
      * @return string
86 86
      */
87
-    public function get_decrypted_target_backup_file_name( $filename ) {
87
+    public function get_decrypted_target_backup_file_name($filename) {
88 88
 
89
-        return str_replace(self::FILE_ENCRYPTION_SUFFIX, "", $filename) . self::FILE_DECRYPTION_SUFFIX;
89
+        return str_replace(self::FILE_ENCRYPTION_SUFFIX, "", $filename).self::FILE_DECRYPTION_SUFFIX;
90 90
     }
91 91
 
92 92
     /**
@@ -100,44 +100,44 @@  discard block
 block discarded – undo
100 100
      * @param bool $verfication   Weather we should we try to verify the decryption.
101 101
      * @return string|false  Returns the file name that has been created or FALSE if an error occured
102 102
     */
103
-    public function encrypt_file($source, $dest = "" , $key= "", $start = 0, $iv = 0, $verification = true, $recursive = false)
103
+    public function encrypt_file($source, $dest = "", $key = "", $start = 0, $iv = 0, $verification = true, $recursive = false)
104 104
     {
105
-        if(is_object($this->logger)) {
105
+        if (is_object($this->logger)) {
106 106
             $this->logger->info(sprintf('Encrypting file %s at position %d IV %s', $source, $start, base64_encode($iv)));
107 107
         }
108 108
 
109 109
         //$key = substr(sha1($key, true), 0, 16);
110
-        if(!$key){
110
+        if (!$key) {
111 111
             $key = self::get_backup_encryption_key();
112 112
         }
113
-        $key_digest = openssl_digest ($key, "md5", true);
113
+        $key_digest = openssl_digest($key, "md5", true);
114 114
 
115 115
         $keep_local = 1;
116
-        if(!$dest) {
116
+        if (!$dest) {
117 117
             $dest = $this->get_encrypted_target_backup_file_name($source);
118 118
             $keep_local = 0;
119 119
         }
120 120
 
121
-        if(!$iv || !$start) {
121
+        if (!$iv || !$start) {
122 122
             //$iv = openssl_random_pseudo_bytes(16);
123 123
             $iv = str_pad(self::FILE_ENCRYPTION_BLOCKS, 16, "0000000000000000", STR_PAD_LEFT);
124 124
         }
125 125
 
126
-        if( !$start ) {
127
-            $fpOut = fopen($this->get_xcloner_path() .$dest, 'w');
128
-        }else{
129
-            $fpOut = fopen($this->get_xcloner_path() .$dest, 'a');
126
+        if (!$start) {
127
+            $fpOut = fopen($this->get_xcloner_path().$dest, 'w');
128
+        } else {
129
+            $fpOut = fopen($this->get_xcloner_path().$dest, 'a');
130 130
         }
131 131
 
132
-        if ( $fpOut ) {
132
+        if ($fpOut) {
133 133
 
134 134
             // Put the initialization vector to the beginning of the file
135
-            if(!$start) {
135
+            if (!$start) {
136 136
                 fwrite($fpOut, $iv);
137 137
             }
138 138
 
139
-            if (file_exists($this->get_xcloner_path() .$source) &&
140
-                $fpIn = fopen($this->get_xcloner_path() .$source, 'rb')) {
139
+            if (file_exists($this->get_xcloner_path().$source) &&
140
+                $fpIn = fopen($this->get_xcloner_path().$source, 'rb')) {
141 141
 
142 142
                 fseek($fpIn, (int)$start);
143 143
 
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
 
155 155
                     $start = ftell($fpIn);
156 156
 
157
-                    fclose($fpOut );
157
+                    fclose($fpOut);
158 158
 
159
-                    if(!feof($fpIn)) {
159
+                    if (!feof($fpIn)) {
160 160
                         fclose($fpIn);
161 161
                         //echo "\n NEW:".$key.md5($iv);
162 162
                         //self::encryptFile($source, $dest, $key, $start, $iv);
163
-                        if($recursive ){
163
+                        if ($recursive) {
164 164
                             $this->encrypt_file($source, $dest, $key, $start, ($iv), $verification, $recursive);
165
-                        }else {
165
+                        } else {
166 166
 
167
-                            if(($iv) != base64_decode(base64_encode($iv)))
167
+                            if (($iv) != base64_decode(base64_encode($iv)))
168 168
                             {
169 169
                                 throw new \Exception('Could not encode IV for transport');
170 170
                             }
@@ -180,26 +180,26 @@  discard block
 block discarded – undo
180 180
 
181 181
                 }
182 182
             } else {
183
-                if(is_object($this->logger)) {
183
+                if (is_object($this->logger)) {
184 184
                     $this->logger->error('Unable to read source file for encryption.');
185 185
                 }
186 186
                 throw new \Exception("Unable to read source file for encryption.");
187 187
             }
188 188
         } else {
189
-            if(is_object($this->logger)) {
189
+            if (is_object($this->logger)) {
190 190
                 $this->logger->error('Unable to write destination file for encryption.');
191 191
             }
192 192
             throw new \Exception("Unable to write destination file for encryption.");
193 193
         }
194 194
 
195
-        if($verification) {
195
+        if ($verification) {
196 196
             $this->verify_encrypted_file($dest);
197 197
         }
198 198
 
199 199
         //we replace the original backup with the encrypted one
200
-        if( !$keep_local && copy($this->get_xcloner_path() .$dest,
201
-             $this->get_xcloner_path() .$source) ) {
202
-            unlink($this->get_xcloner_path() .$dest);
200
+        if (!$keep_local && copy($this->get_xcloner_path().$dest,
201
+             $this->get_xcloner_path().$source)) {
202
+            unlink($this->get_xcloner_path().$dest);
203 203
         }
204 204
 
205 205
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     }
208 208
 
209 209
     public function verify_encrypted_file($file) {
210
-        if(is_object($this->logger)) {
210
+        if (is_object($this->logger)) {
211 211
             $this->logger->info(sprintf('Verifying encrypted file %s', $file));
212 212
         }
213 213
 
@@ -229,50 +229,50 @@  discard block
 block discarded – undo
229 229
      */
230 230
     public function decrypt_file($source, $dest = "", $key = "", $start = 0, $iv = 0, $recursive = false)
231 231
     {
232
-        if(is_object($this->logger)) {
232
+        if (is_object($this->logger)) {
233 233
             $this->logger->info(sprintf('Decrypting file %s at position %d with IV %s', $source, $start, base64_encode($iv)));
234 234
         }
235 235
 
236 236
         //$key = substr(sha1($key, true), 0, 16);
237
-        if(!$key){
237
+        if (!$key) {
238 238
             $key = self::get_backup_encryption_key();
239 239
         }
240 240
 
241
-        $key_digest = openssl_digest ($key, "md5", true);
241
+        $key_digest = openssl_digest($key, "md5", true);
242 242
 
243 243
         $keep_local = 1;
244
-        if(!$dest) {
244
+        if (!$dest) {
245 245
             $dest = $this->get_decrypted_target_backup_file_name($source);
246 246
             $keep_local = 0;
247 247
         }
248 248
 
249
-        if( !$start ) {
250
-            if($this->verification){
249
+        if (!$start) {
250
+            if ($this->verification) {
251 251
                 $fpOut = fopen("php://stdout", 'w');
252
-            }else {
253
-                $fpOut = fopen($this->get_xcloner_path() . $dest, 'w');
252
+            } else {
253
+                $fpOut = fopen($this->get_xcloner_path().$dest, 'w');
254 254
             }
255
-        }else{
256
-            if($this->verification){
255
+        } else {
256
+            if ($this->verification) {
257 257
                 $fpOut = fopen("php://stdout", 'a');
258
-            }else {
259
-                $fpOut = fopen($this->get_xcloner_path() . $dest, 'a');
258
+            } else {
259
+                $fpOut = fopen($this->get_xcloner_path().$dest, 'a');
260 260
             }
261 261
         }
262 262
 
263
-        if ( $fpOut ) {
264
-            if ( file_exists($this->get_xcloner_path() .$source) &&
265
-                $fpIn = fopen($this->get_xcloner_path() .$source, 'rb')) {
263
+        if ($fpOut) {
264
+            if (file_exists($this->get_xcloner_path().$source) &&
265
+                $fpIn = fopen($this->get_xcloner_path().$source, 'rb')) {
266 266
 
267 267
                 $encryption_length = (int)fread($fpIn, 16);
268
-                if(!$encryption_length) {
268
+                if (!$encryption_length) {
269 269
                     $encryption_length = self::FILE_ENCRYPTION_BLOCKS;
270 270
                 }
271 271
 
272 272
                 fseek($fpIn, (int)$start);
273 273
 
274 274
                 // Get the initialzation vector from the beginning of the file
275
-                if(!$iv) {
275
+                if (!$iv) {
276 276
                     $iv = fread($fpIn, 16);
277 277
                 }
278 278
 
@@ -282,9 +282,9 @@  discard block
 block discarded – undo
282 282
                     $ciphertext = fread($fpIn, 16 * ($encryption_length + 1));
283 283
                     $plaintext = openssl_decrypt($ciphertext, 'AES-128-CBC', $key_digest, OPENSSL_RAW_DATA, $iv);
284 284
 
285
-                    if(!$plaintext){
286
-                        unlink($this->get_xcloner_path() . $dest);
287
-                        if(is_object($this->logger)) {
285
+                    if (!$plaintext) {
286
+                        unlink($this->get_xcloner_path().$dest);
287
+                        if (is_object($this->logger)) {
288 288
                             $this->logger->error('Backup decryption failed, please check your provided Encryption Key.');
289 289
                         }
290 290
                         throw new \Exception("Backup decryption failed, please check your provided Encryption Key.");
@@ -293,22 +293,22 @@  discard block
 block discarded – undo
293 293
                     // Use the first 16 bytes of the ciphertext as the next initialization vector
294 294
                     $iv = substr($ciphertext, 0, 16);
295 295
 
296
-                    if( !$this->verification) {
296
+                    if (!$this->verification) {
297 297
                         fwrite($fpOut, $plaintext);
298 298
                     }
299 299
 
300 300
                     $start = ftell($fpIn);
301 301
 
302
-                    fclose($fpOut );
302
+                    fclose($fpOut);
303 303
 
304
-                    if(!feof($fpIn)) {
304
+                    if (!feof($fpIn)) {
305 305
                         fclose($fpIn);
306
-                        if($this->verification || $recursive) {
306
+                        if ($this->verification || $recursive) {
307 307
                             $ciphertext = "";
308 308
                             $plaintext = "";
309 309
                             $this->decrypt_file($source, $dest, $key, $start, $iv, $recursive);
310
-                        }else {
311
-                            if(($iv) != base64_decode(base64_encode($iv)))
310
+                        } else {
311
+                            if (($iv) != base64_decode(base64_encode($iv)))
312 312
                             {
313 313
                                 throw new \Exception('Could not encode IV for transport');
314 314
                             }
@@ -325,30 +325,30 @@  discard block
 block discarded – undo
325 325
 
326 326
                 }
327 327
             } else {
328
-                if(is_object($this->logger)) {
328
+                if (is_object($this->logger)) {
329 329
                     $this->logger->error('Unable to read source file for decryption');
330 330
                 }
331 331
                 throw new \Exception("Unable to read source file for decryption");
332 332
             }
333 333
         } else {
334
-            if(is_object($this->logger)) {
334
+            if (is_object($this->logger)) {
335 335
                 $this->logger->error('Unable to write destination file for decryption');
336 336
             }
337 337
             throw new \Exception("Unable to write destination file for decryption");
338 338
         }
339 339
 
340 340
         //we replace the original backup with the encrypted one
341
-        if( !$keep_local && !$this->verification && copy($this->get_xcloner_path()  .$dest,
342
-            $this->get_xcloner_path()  .$source) ) {
343
-            unlink($this->get_xcloner_path()  .$dest);
341
+        if (!$keep_local && !$this->verification && copy($this->get_xcloner_path().$dest,
342
+            $this->get_xcloner_path().$source)) {
343
+            unlink($this->get_xcloner_path().$dest);
344 344
         }
345 345
 
346 346
         return array("target_file" => $dest, "finished" => 1);
347 347
     }
348 348
 
349
-    public function get_xcloner_path(){
350
-        if(is_object($this->xcloner_settings)) {
351
-            return $this->xcloner_settings->get_xcloner_store_path() . DS;
349
+    public function get_xcloner_path() {
350
+        if (is_object($this->xcloner_settings)) {
351
+            return $this->xcloner_settings->get_xcloner_store_path().DS;
352 352
         }
353 353
 
354 354
         return null;
@@ -359,21 +359,21 @@  discard block
 block discarded – undo
359 359
 
360 360
 try {
361 361
 
362
-    if(isset($argv[1])) {
362
+    if (isset($argv[1])) {
363 363
 
364 364
         class Xcloner {
365 365
             public function __construct()
366 366
             {
367 367
             }
368 368
         }
369
-        $xcloner_encryption = new Xcloner_Encryption( new Xcloner() );
369
+        $xcloner_encryption = new Xcloner_Encryption(new Xcloner());
370 370
 
371 371
         if ($argv[1] == "-e") {
372
-            $xcloner_encryption->encrypt_file($argv[2], $argv[2] . ".enc", $argv[4], '', '', '', true);
372
+            $xcloner_encryption->encrypt_file($argv[2], $argv[2].".enc", $argv[4], '', '', '', true);
373 373
         } elseif ($argv[1] == "-d") {
374
-            $xcloner_encryption->decrypt_file($argv[2], $argv[2] . ".dec", $argv[4], '', '', true);
374
+            $xcloner_encryption->decrypt_file($argv[2], $argv[2].".dec", $argv[4], '', '', true);
375 375
         }
376 376
     }
377
-}catch(\Exception $e) {
378
-    echo "CAUGHT: " . $e->getMessage();
377
+}catch (\Exception $e) {
378
+    echo "CAUGHT: ".$e->getMessage();
379 379
 }
Please login to merge, or discard this patch.
Braces   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
         $this->xcloner_container = $xcloner_container;
24 24
         if(method_exists($xcloner_container, 'get_xcloner_settings')) {
25 25
             $this->xcloner_settings = $xcloner_container->get_xcloner_settings();
26
-        }else{
26
+        } else{
27 27
             $this->xcloner_settings = "";
28 28
         }
29 29
 
30 30
         if(method_exists($xcloner_container, 'get_xcloner_logger')) {
31 31
             $this->logger = $xcloner_container->get_xcloner_logger()->withName("xcloner_encryption");
32
-        }else{
32
+        } else{
33 33
             $this->logger = "";
34 34
         }
35 35
     }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
         if( !$start ) {
127 127
             $fpOut = fopen($this->get_xcloner_path() .$dest, 'w');
128
-        }else{
128
+        } else{
129 129
             $fpOut = fopen($this->get_xcloner_path() .$dest, 'a');
130 130
         }
131 131
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
                         //self::encryptFile($source, $dest, $key, $start, $iv);
163 163
                         if($recursive ){
164 164
                             $this->encrypt_file($source, $dest, $key, $start, ($iv), $verification, $recursive);
165
-                        }else {
165
+                        } else {
166 166
 
167 167
                             if(($iv) != base64_decode(base64_encode($iv)))
168 168
                             {
@@ -249,13 +249,13 @@  discard block
 block discarded – undo
249 249
         if( !$start ) {
250 250
             if($this->verification){
251 251
                 $fpOut = fopen("php://stdout", 'w');
252
-            }else {
252
+            } else {
253 253
                 $fpOut = fopen($this->get_xcloner_path() . $dest, 'w');
254 254
             }
255
-        }else{
255
+        } else{
256 256
             if($this->verification){
257 257
                 $fpOut = fopen("php://stdout", 'a');
258
-            }else {
258
+            } else {
259 259
                 $fpOut = fopen($this->get_xcloner_path() . $dest, 'a');
260 260
             }
261 261
         }
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
                             $ciphertext = "";
308 308
                             $plaintext = "";
309 309
                             $this->decrypt_file($source, $dest, $key, $start, $iv, $recursive);
310
-                        }else {
310
+                        } else {
311 311
                             if(($iv) != base64_decode(base64_encode($iv)))
312 312
                             {
313 313
                                 throw new \Exception('Could not encode IV for transport');
@@ -374,6 +374,6 @@  discard block
 block discarded – undo
374 374
             $xcloner_encryption->decrypt_file($argv[2], $argv[2] . ".dec", $argv[4], '', '', true);
375 375
         }
376 376
     }
377
-}catch(\Exception $e) {
377
+} catch(\Exception $e) {
378 378
     echo "CAUGHT: " . $e->getMessage();
379 379
 }
Please login to merge, or discard this patch.
includes/class-xcloner-file-system.php 2 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -207,6 +207,9 @@  discard block
 block discarded – undo
207 207
         return $this->start_filesystem->normalizeFileInfo($info);
208 208
     }
209 209
 
210
+    /**
211
+     * @param string $file
212
+     */
210 213
     public function get_storage_path_file_info($file)
211 214
     {
212 215
         return $this->getMetadataFull('storage_adapter', $file);
@@ -741,6 +744,9 @@  discard block
 block discarded – undo
741 744
 
742 745
     }
743 746
 
747
+    /**
748
+     * @param string $tmp_file
749
+     */
744 750
     public function estimate_reading_time($tmp_file)
745 751
     {
746 752
         $this->logger->debug(sprintf(("Estimating file system reading time")));
@@ -781,6 +787,9 @@  discard block
 block discarded – undo
781 787
         return $name;
782 788
     }
783 789
 
790
+    /**
791
+     * @param string $field
792
+     */
784 793
     public function sort_by(&$array, $field, $direction = 'asc')
785 794
     {
786 795
         if (strtolower($direction) == "desc" || $direction == SORT_DESC) {
Please login to merge, or discard this patch.
Indentation   +957 added lines, -957 removed lines patch added patch discarded remove patch
@@ -37,848 +37,848 @@  discard block
 block discarded – undo
37 37
 class Xcloner_File_System
38 38
 {
39 39
 
40
-    private $excluded_files = "";
41
-    private $additional_regex_patterns = array();
42
-    private $excluded_files_by_default = array("administrator/backups", "wp-content/backups");
43
-    private $included_files_handler = "backup_files.csv";
44
-    private $temp_dir_handler = ".dir";
45
-    public $filesystem;
46
-    public $tmp_filesystem;
47
-    public $storage_filesystem;
48
-    private $xcloner_container;
49
-    private $diff_timestamp_start = "";
50
-
51
-    private $logger;
52
-    private $start_adapter;
53
-    private $tmp_adapter;
54
-    private $storage_adapter;
55
-    private $xcloner_settings;
56
-    private $start_filesystem;
57
-    private $tmp_filesystem_append;
58
-    private $storage_filesystem_append;
59
-
60
-    private $files_counter;
61
-    private $files_size;
62
-    private $last_logged_file;
63
-    private $folders_to_process_per_session = 25;
64
-    private $backup_archive_extensions = array("tar", "tgz", "tar.gz", "gz", "csv", "encrypted", "decrypted");
65
-    private $backup_name_tags = array('[time]', '[hostname]', '[domain]');
66
-
67
-    /**
68
-     * Xcloner_File_System constructor.
69
-     * @param Xcloner $xcloner_container
70
-     * @param string $hash
71
-     */
72
-    public function __construct(Xcloner $xcloner_container, $hash = "")
73
-    {
74
-        $this->xcloner_container = $xcloner_container;
75
-
76
-        $this->logger = $xcloner_container->get_xcloner_logger()->withName("xcloner_file_system");
77
-        $this->xcloner_settings = $xcloner_container->get_xcloner_settings();
78
-
79
-        try {
80
-
81
-            $this->start_adapter = new Local($this->xcloner_settings->get_xcloner_start_path(), LOCK_EX, 'SKIP_LINKS');
82
-            $this->start_filesystem = new Filesystem($this->start_adapter, new Config([
83
-                'disable_asserts' => true,
84
-            ]));
85
-
86
-            $this->tmp_adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(), LOCK_EX, 'SKIP_LINKS');
87
-            $this->tmp_filesystem = new Filesystem($this->tmp_adapter, new Config([
88
-                'disable_asserts' => true,
89
-            ]));
90
-            $adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(), LOCK_EX | FILE_APPEND, 'SKIP_LINKS');
91
-            $this->tmp_filesystem_append = new Filesystem($adapter, new Config([
92
-                'disable_asserts' => true,
93
-            ]));
94
-
95
-            $adapter = new Local($this->xcloner_settings->get_xcloner_store_path(), LOCK_EX, 'SKIP_LINKS');
96
-            $this->storage_filesystem = new Filesystem($adapter, new Config([
97
-                'disable_asserts' => true,
98
-            ]));
99
-
100
-            $this->storage_adapter = new Local($this->xcloner_settings->get_xcloner_store_path(), FILE_APPEND,
101
-                'SKIP_LINKS');
102
-            $this->storage_filesystem_append = new Filesystem($this->storage_adapter, new Config([
103
-                'disable_asserts' => true,
104
-            ]));
105
-        } catch (Exception $e) {
106
-            $this->logger->error("Filesystem Initialization Error: " . $e->getMessage());
107
-        }
108
-
109
-
110
-        if ($value = get_option('xcloner_directories_to_scan_per_request')) {
111
-            $this->folders_to_process_per_session = $value;
112
-        }
113
-
114
-    }
115
-
116
-    /**
117
-     * Set differential timestamp date
118
-     * @param string $timestamp
119
-     */
120
-    public function set_diff_timestamp_start($timestamp = "")
121
-    {
122
-        if ($timestamp) {
123
-            $this->logger->info(sprintf("Setting Differential Timestamp To %s", date("Y-m-d", $timestamp)), array(
124
-                "FILESYSTEM",
125
-                "DIFF"
126
-            ));
127
-            $this->diff_timestamp_start = $timestamp;
128
-        }
129
-    }
130
-
131
-    /**
132
-     * Gets the differential timestamp date
133
-     * @return string
134
-     */
135
-    public function get_diff_timestamp_start()
136
-    {
137
-        return $this->diff_timestamp_start;
138
-    }
139
-
140
-    private function get_xcloner_container()
141
-    {
142
-        return $this->xcloner_container;
143
-    }
144
-
145
-    public function set_hash($hash)
146
-    {
147
-        $this->xcloner_settings->set_hash($hash);
148
-    }
149
-
150
-    public function get_hash($hash)
151
-    {
152
-        $this->xcloner_settings->get_hash();
153
-    }
154
-
155
-    public function get_tmp_filesystem()
156
-    {
157
-        return $this->tmp_filesystem;
158
-    }
159
-
160
-    public function get_storage_filesystem($remote_storage_selection = "")
161
-    {
162
-        if ($remote_storage_selection != "") {
163
-            $remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage();
164
-            $method = "get_" . $remote_storage_selection . "_filesystem";
165
-
166
-            if (!method_exists($remote_storage, $method)) {
167
-                return false;
168
-            }
169
-
170
-            list($adapter, $filesystem) = $remote_storage->$method();
171
-
172
-            return $filesystem;
173
-        }
174
-
175
-        return $this->storage_filesystem;
176
-    }
177
-
178
-    public function get_tmp_filesystem_adapter()
179
-    {
180
-        return $this->tmp_adapter;
181
-    }
182
-
183
-    public function get_tmp_filesystem_append()
184
-    {
185
-        return $this->tmp_filesystem_append;
186
-    }
187
-
188
-    public function get_start_adapter()
189
-    {
190
-        return $this->start_adapter;
191
-    }
192
-
193
-    public function get_start_filesystem()
194
-    {
195
-        return $this->start_filesystem;
196
-    }
197
-
198
-    public function get_logger()
199
-    {
200
-        return $this->logger;
201
-    }
202
-
203
-    public function get_start_path_file_info($file)
204
-    {
205
-        $info = $this->getMetadataFull('start_adapter', $file);
206
-
207
-        return $this->start_filesystem->normalizeFileInfo($info);
208
-    }
209
-
210
-    public function get_storage_path_file_info($file)
211
-    {
212
-        return $this->getMetadataFull('storage_adapter', $file);
213
-    }
214
-
215
-    public function get_included_files_handler($metadata = 0)
216
-    {
217
-        $path = $this->included_files_handler;
218
-        if (!$metadata) {
219
-            return $path;
220
-        }
221
-
222
-        $spl_info = $this->getMetadataFull('tmp_adapter', $path);
223
-
224
-        return $spl_info;
225
-
226
-    }
227
-
228
-    public function get_temp_dir_handler()
229
-    {
230
-        return $this->temp_dir_handler;
231
-    }
232
-
233
-    public function get_latest_backup()
234
-    {
235
-        $files = $this->get_backup_archives_list();
236
-
237
-        if (is_array($files)) {
238
-            $this->sort_by($files, "timestamp", "desc");
239
-        }
240
-
241
-        $new_list = array();
242
-
243
-        foreach ($files as $key => $file) {
244
-            if (!isset($file['parent'])) {
245
-                $new_list[] = ($files[$key]);
246
-            }
247
-        }
248
-
249
-        if (isset($new_list[0])) {
250
-            return $new_list[0];
251
-        }
252
-    }
253
-
254
-    public function get_latest_backups()
255
-    {
256
-        $files = $this->get_backup_archives_list();
257
-
258
-        if (is_array($files)) {
259
-            $this->sort_by($files, "timestamp", "desc");
260
-        }
261
-
262
-        $new_list = array();
263
-
264
-        foreach ($files as $key => $file) {
265
-            if (!isset($file['parent'])) {
266
-                $new_list[] = ($files[$key]);
267
-            }
268
-        }
269
-
270
-        return $new_list;
271
-    }
272
-
273
-    public function get_storage_usage()
274
-    {
275
-        $files = $this->get_backup_archives_list();
276
-        $total = 0;
277
-
278
-        if (is_array($files)) {
279
-            foreach ($files as $file) {
280
-                $total += $file['size'];
281
-            }
282
-        }
283
-
284
-        return $total;
285
-    }
286
-
287
-    public function is_part($backup_name)
288
-    {
289
-        if (stristr($backup_name, "-part")) {
290
-            return true;
291
-        }
292
-
293
-        return false;
294
-    }
295
-
296
-    public function is_multipart($backup_name)
297
-    {
298
-        if (stristr($backup_name, "-multipart")) {
299
-            return true;
300
-        }
301
-
302
-        return false;
303
-    }
304
-
305
-    public function get_backup_size($backup_name)
306
-    {
307
-        $backup_size = $this->get_storage_filesystem()->getSize($backup_name);
308
-        if ($this->is_multipart($backup_name)) {
309
-            $backup_parts = $this->get_multipart_files($backup_name);
310
-            foreach ($backup_parts as $part_file) {
311
-                $backup_size += $this->get_storage_filesystem()->getSize($part_file);
312
-            }
313
-        }
314
-
315
-        return $backup_size;
316
-    }
317
-
318
-    public function get_multipart_files($backup_name, $storage_selection = "")
319
-    {
320
-        $files = array();
321
-
322
-        if ($this->is_multipart($backup_name)) {
323
-            $lines = explode(PHP_EOL, $this->get_storage_filesystem($storage_selection)->read($backup_name));
324
-            foreach ($lines as $line) {
325
-                if ($line) {
326
-                    $data = str_getcsv($line);
327
-                    $files[] = $data[0];
328
-                }
329
-            }
330
-        }
331
-
332
-        return $files;
333
-    }
334
-
335
-    public function delete_backup_by_name($backup_name, $storage_selection = "")
336
-    {
337
-        if ($this->is_multipart($backup_name)) {
338
-            $lines = explode(PHP_EOL, $this->get_storage_filesystem($storage_selection)->read($backup_name));
339
-            foreach ($lines as $line) {
340
-                if ($line) {
341
-                    $data = str_getcsv($line);
342
-                    $this->get_storage_filesystem($storage_selection)->delete($data[0]);
343
-                }
344
-            }
345
-        }
346
-
347
-        if ($this->get_storage_filesystem($storage_selection)->delete($backup_name)) {
348
-            $return = true;
349
-        } else {
350
-            $return = false;
351
-        }
352
-
353
-        return $return;
354
-    }
355
-
356
-    public function getMetadataFull($adapter = "storage_adapter", $path)
357
-    {
358
-        $location = $this->$adapter->applyPathPrefix($path);
359
-        $spl_info = new SplFileInfo($location);
360
-
361
-        return ($spl_info);
362
-    }
363
-
364
-
365
-    public function get_backup_archives_list($storage_selection = "")
366
-    {
367
-        $list = array();
368
-
369
-
370
-        if (method_exists($this->get_storage_filesystem($storage_selection), "listContents")) {
371
-            $list = $this->get_storage_filesystem($storage_selection)->listContents();
372
-        }
373
-
374
-        $backup_files = array();
375
-        $parents = array();
376
-
377
-        foreach ($list as $file_info) {
378
-            if (isset($file_info['extension']) and $file_info['extension'] == "csv") {
379
-                $data = array();
380
-
381
-                $lines = explode(PHP_EOL, $this->get_storage_filesystem($storage_selection)->read($file_info['path']));
382
-                foreach ($lines as $line) {
383
-                    if ($line) {
384
-                        $data = str_getcsv($line);
385
-                        if (is_array($data)) {
386
-                            $parents[$data[0]] = $file_info['basename'];
387
-                            $file_info['childs'][] = $data;
388
-                            $file_info['size'] += $data[2];
389
-                        }
390
-                    }
391
-                }
392
-
393
-            }
394
-
395
-            if ($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'],
396
-                    $this->backup_archive_extensions)) {
397
-                $backup_files[$file_info['path']] = $file_info;
398
-            }
399
-        }
400
-
401
-        foreach ($backup_files as $key => $file_info) {
402
-            if (!isset($backup_files[$key]['timestamp'])) {
403
-                //$backup_files[$key]['timestamp'] = $this->get_storage_filesystem($storage_selection)->getTimestamp($file_info['path']);
404
-            }
405
-
406
-            if (isset($parents[$file_info['basename']])) {
407
-                $backup_files[$key]['parent'] = $parents[$file_info['basename']];
408
-            }
409
-        }
410
-
411
-        return $backup_files;
412
-    }
413
-
414
-    public function start_file_recursion($init = 0)
415
-    {
416
-        if ($init) {
417
-            $this->logger->info(sprintf(__("Starting the filesystem scanner on root folder %s"),
418
-                $this->xcloner_settings->get_xcloner_start_path()));
419
-            $this->do_system_init();
420
-        }
421
-
422
-        if ($this->tmp_filesystem->has($this->get_temp_dir_handler())) {
423
-            //.dir exists, we presume we have files to iterate
424
-            $content = $this->tmp_filesystem->read($this->get_temp_dir_handler());
425
-            $files = array_filter(explode("\n", $content));
426
-            $this->tmp_filesystem->delete($this->get_temp_dir_handler());
427
-
428
-            $counter = 0;
429
-            foreach ($files as $file) {
430
-                if ($counter < $this->folders_to_process_per_session) {
431
-                    $this->build_files_list($file);
432
-                    $counter++;
433
-                } else {
434
-                    $this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file . "\n");
435
-                }
436
-            }
437
-        } else {
438
-            $this->build_files_list();
439
-        }
440
-
441
-        if ($this->scan_finished()) {
442
-            $metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata("index.html");
443
-            $this->store_file($metadata_dumpfile, 'tmp_filesystem');
444
-            $this->files_counter++;
445
-
446
-            //adding included dump file to the included files list
447
-            if ($this->get_tmp_filesystem()->has($this->get_included_files_handler())) {
448
-                $metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata($this->get_included_files_handler());
449
-                $this->store_file($metadata_dumpfile, 'tmp_filesystem');
450
-                $this->files_counter++;
451
-            }
452
-
453
-            //adding a default index.html to the temp xcloner folder
454
-            if (!$this->get_tmp_filesystem()->has("index.html")) {
455
-                $this->get_tmp_filesystem()->write("index.html", "");
456
-            }
457
-
458
-            //adding the default log file
459
-            if ($this->get_tmp_filesystem()->has($this->xcloner_settings->get_logger_filename(1))) {
460
-                $metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata($this->xcloner_settings->get_logger_filename(1));
461
-                $this->store_file($metadata_dumpfile, 'tmp_filesystem');
462
-                $this->files_counter++;
463
-            }
464
-
465
-            return false;
466
-        }
467
-
468
-        return true;
469
-    }
470
-
471
-    public function get_backup_attachments()
472
-    {
473
-        $return = array();
474
-
475
-        $files_list_file = $this->xcloner_settings->get_xcloner_tmp_path() . DS . $this->get_included_files_handler();
476
-        if (file_exists($files_list_file)) {
477
-            $return[] = $files_list_file;
478
-        }
479
-
480
-        if ($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) {
481
-            $log_file = $this->xcloner_settings->get_xcloner_tmp_path() . DS . $this->xcloner_settings->get_logger_filename(1);
482
-            if (!file_exists($log_file)) {
483
-                $log_file = $this->xcloner_settings->get_xcloner_store_path() . DS . $this->xcloner_settings->get_logger_filename();
484
-            }
485
-
486
-            if (file_exists($log_file)) {
487
-                $return[] = $log_file;
488
-            }
489
-        }
490
-
491
-        return $return;
492
-    }
493
-
494
-    public function remove_tmp_filesystem()
495
-    {
496
-        //delete the temporary folder
497
-        $this->logger->debug(sprintf("Deleting the temporary storage folder %s",
498
-            $this->xcloner_settings->get_xcloner_tmp_path()));
499
-
500
-        $contents = $this->get_tmp_filesystem()->listContents();
501
-
502
-        if (is_array($contents)) {
503
-            foreach ($contents as $file_info) {
504
-                $this->get_tmp_filesystem()->delete($file_info['path']);
505
-            }
506
-        }
507
-
508
-        @rmdir($this->xcloner_settings->get_xcloner_tmp_path());
509
-
510
-        return;
511
-    }
512
-
513
-    public function cleanup_tmp_directories()
514
-    {
515
-        $adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(false), LOCK_EX | FILE_APPEND, 'SKIP_LINKS');
516
-        $tmp_filesystem = new Filesystem($adapter, new Config([
517
-            'disable_asserts' => true,
518
-        ]));
519
-
520
-        $contents = $tmp_filesystem->listContents();
521
-
522
-        foreach ($contents as $file) {
523
-
524
-            if (preg_match("/.xcloner-(.*)/", $file['path'])) {
525
-                if ($file['timestamp'] < strtotime("-1days")) {
526
-                    $tmp_filesystem->deleteDir($file['path']);
527
-                    $this->logger->debug(sprintf("Delete temporary directory %s", $file['path']));
528
-                }
529
-            }
530
-        }
531
-
532
-        return true;
533
-    }
534
-
535
-    private function do_system_init()
536
-    {
537
-        $this->files_counter = 0;
538
-
539
-        if (!$this->storage_filesystem->has("index.html")) {
540
-            $this->storage_filesystem->write("index.html", "");
541
-        }
542
-
543
-        if (!$this->tmp_filesystem->has("index.html")) {
544
-            $this->tmp_filesystem->write("index.html", "");
545
-        }
546
-
547
-        if ($this->tmp_filesystem->has($this->get_included_files_handler())) {
548
-            $this->tmp_filesystem->delete($this->get_included_files_handler());
549
-        }
550
-
551
-        if ($this->tmp_filesystem->has($this->get_temp_dir_handler())) {
552
-            $this->tmp_filesystem->delete($this->get_temp_dir_handler());
553
-        }
554
-    }
555
-
556
-    public function get_scanned_files_num()
557
-    {
558
-        return $this->files_counter;
559
-    }
560
-
561
-    public function get_scanned_files_total_size()
562
-    {
563
-        return $this->files_size;
564
-    }
565
-
566
-    public function last_logged_file()
567
-    {
568
-        return $this->last_logged_file;
569
-    }
570
-
571
-    public static function is_regex($regex)
572
-    {
573
-        return preg_match("/^\^(.*)\$$/i", $regex);
574
-    }
40
+	private $excluded_files = "";
41
+	private $additional_regex_patterns = array();
42
+	private $excluded_files_by_default = array("administrator/backups", "wp-content/backups");
43
+	private $included_files_handler = "backup_files.csv";
44
+	private $temp_dir_handler = ".dir";
45
+	public $filesystem;
46
+	public $tmp_filesystem;
47
+	public $storage_filesystem;
48
+	private $xcloner_container;
49
+	private $diff_timestamp_start = "";
50
+
51
+	private $logger;
52
+	private $start_adapter;
53
+	private $tmp_adapter;
54
+	private $storage_adapter;
55
+	private $xcloner_settings;
56
+	private $start_filesystem;
57
+	private $tmp_filesystem_append;
58
+	private $storage_filesystem_append;
59
+
60
+	private $files_counter;
61
+	private $files_size;
62
+	private $last_logged_file;
63
+	private $folders_to_process_per_session = 25;
64
+	private $backup_archive_extensions = array("tar", "tgz", "tar.gz", "gz", "csv", "encrypted", "decrypted");
65
+	private $backup_name_tags = array('[time]', '[hostname]', '[domain]');
66
+
67
+	/**
68
+	 * Xcloner_File_System constructor.
69
+	 * @param Xcloner $xcloner_container
70
+	 * @param string $hash
71
+	 */
72
+	public function __construct(Xcloner $xcloner_container, $hash = "")
73
+	{
74
+		$this->xcloner_container = $xcloner_container;
75
+
76
+		$this->logger = $xcloner_container->get_xcloner_logger()->withName("xcloner_file_system");
77
+		$this->xcloner_settings = $xcloner_container->get_xcloner_settings();
78
+
79
+		try {
80
+
81
+			$this->start_adapter = new Local($this->xcloner_settings->get_xcloner_start_path(), LOCK_EX, 'SKIP_LINKS');
82
+			$this->start_filesystem = new Filesystem($this->start_adapter, new Config([
83
+				'disable_asserts' => true,
84
+			]));
85
+
86
+			$this->tmp_adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(), LOCK_EX, 'SKIP_LINKS');
87
+			$this->tmp_filesystem = new Filesystem($this->tmp_adapter, new Config([
88
+				'disable_asserts' => true,
89
+			]));
90
+			$adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(), LOCK_EX | FILE_APPEND, 'SKIP_LINKS');
91
+			$this->tmp_filesystem_append = new Filesystem($adapter, new Config([
92
+				'disable_asserts' => true,
93
+			]));
94
+
95
+			$adapter = new Local($this->xcloner_settings->get_xcloner_store_path(), LOCK_EX, 'SKIP_LINKS');
96
+			$this->storage_filesystem = new Filesystem($adapter, new Config([
97
+				'disable_asserts' => true,
98
+			]));
99
+
100
+			$this->storage_adapter = new Local($this->xcloner_settings->get_xcloner_store_path(), FILE_APPEND,
101
+				'SKIP_LINKS');
102
+			$this->storage_filesystem_append = new Filesystem($this->storage_adapter, new Config([
103
+				'disable_asserts' => true,
104
+			]));
105
+		} catch (Exception $e) {
106
+			$this->logger->error("Filesystem Initialization Error: " . $e->getMessage());
107
+		}
108
+
109
+
110
+		if ($value = get_option('xcloner_directories_to_scan_per_request')) {
111
+			$this->folders_to_process_per_session = $value;
112
+		}
113
+
114
+	}
115
+
116
+	/**
117
+	 * Set differential timestamp date
118
+	 * @param string $timestamp
119
+	 */
120
+	public function set_diff_timestamp_start($timestamp = "")
121
+	{
122
+		if ($timestamp) {
123
+			$this->logger->info(sprintf("Setting Differential Timestamp To %s", date("Y-m-d", $timestamp)), array(
124
+				"FILESYSTEM",
125
+				"DIFF"
126
+			));
127
+			$this->diff_timestamp_start = $timestamp;
128
+		}
129
+	}
130
+
131
+	/**
132
+	 * Gets the differential timestamp date
133
+	 * @return string
134
+	 */
135
+	public function get_diff_timestamp_start()
136
+	{
137
+		return $this->diff_timestamp_start;
138
+	}
139
+
140
+	private function get_xcloner_container()
141
+	{
142
+		return $this->xcloner_container;
143
+	}
144
+
145
+	public function set_hash($hash)
146
+	{
147
+		$this->xcloner_settings->set_hash($hash);
148
+	}
149
+
150
+	public function get_hash($hash)
151
+	{
152
+		$this->xcloner_settings->get_hash();
153
+	}
154
+
155
+	public function get_tmp_filesystem()
156
+	{
157
+		return $this->tmp_filesystem;
158
+	}
159
+
160
+	public function get_storage_filesystem($remote_storage_selection = "")
161
+	{
162
+		if ($remote_storage_selection != "") {
163
+			$remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage();
164
+			$method = "get_" . $remote_storage_selection . "_filesystem";
165
+
166
+			if (!method_exists($remote_storage, $method)) {
167
+				return false;
168
+			}
169
+
170
+			list($adapter, $filesystem) = $remote_storage->$method();
171
+
172
+			return $filesystem;
173
+		}
174
+
175
+		return $this->storage_filesystem;
176
+	}
177
+
178
+	public function get_tmp_filesystem_adapter()
179
+	{
180
+		return $this->tmp_adapter;
181
+	}
182
+
183
+	public function get_tmp_filesystem_append()
184
+	{
185
+		return $this->tmp_filesystem_append;
186
+	}
187
+
188
+	public function get_start_adapter()
189
+	{
190
+		return $this->start_adapter;
191
+	}
192
+
193
+	public function get_start_filesystem()
194
+	{
195
+		return $this->start_filesystem;
196
+	}
197
+
198
+	public function get_logger()
199
+	{
200
+		return $this->logger;
201
+	}
202
+
203
+	public function get_start_path_file_info($file)
204
+	{
205
+		$info = $this->getMetadataFull('start_adapter', $file);
206
+
207
+		return $this->start_filesystem->normalizeFileInfo($info);
208
+	}
209
+
210
+	public function get_storage_path_file_info($file)
211
+	{
212
+		return $this->getMetadataFull('storage_adapter', $file);
213
+	}
214
+
215
+	public function get_included_files_handler($metadata = 0)
216
+	{
217
+		$path = $this->included_files_handler;
218
+		if (!$metadata) {
219
+			return $path;
220
+		}
221
+
222
+		$spl_info = $this->getMetadataFull('tmp_adapter', $path);
223
+
224
+		return $spl_info;
225
+
226
+	}
227
+
228
+	public function get_temp_dir_handler()
229
+	{
230
+		return $this->temp_dir_handler;
231
+	}
232
+
233
+	public function get_latest_backup()
234
+	{
235
+		$files = $this->get_backup_archives_list();
236
+
237
+		if (is_array($files)) {
238
+			$this->sort_by($files, "timestamp", "desc");
239
+		}
240
+
241
+		$new_list = array();
242
+
243
+		foreach ($files as $key => $file) {
244
+			if (!isset($file['parent'])) {
245
+				$new_list[] = ($files[$key]);
246
+			}
247
+		}
248
+
249
+		if (isset($new_list[0])) {
250
+			return $new_list[0];
251
+		}
252
+	}
253
+
254
+	public function get_latest_backups()
255
+	{
256
+		$files = $this->get_backup_archives_list();
257
+
258
+		if (is_array($files)) {
259
+			$this->sort_by($files, "timestamp", "desc");
260
+		}
261
+
262
+		$new_list = array();
263
+
264
+		foreach ($files as $key => $file) {
265
+			if (!isset($file['parent'])) {
266
+				$new_list[] = ($files[$key]);
267
+			}
268
+		}
269
+
270
+		return $new_list;
271
+	}
272
+
273
+	public function get_storage_usage()
274
+	{
275
+		$files = $this->get_backup_archives_list();
276
+		$total = 0;
277
+
278
+		if (is_array($files)) {
279
+			foreach ($files as $file) {
280
+				$total += $file['size'];
281
+			}
282
+		}
283
+
284
+		return $total;
285
+	}
286
+
287
+	public function is_part($backup_name)
288
+	{
289
+		if (stristr($backup_name, "-part")) {
290
+			return true;
291
+		}
292
+
293
+		return false;
294
+	}
295
+
296
+	public function is_multipart($backup_name)
297
+	{
298
+		if (stristr($backup_name, "-multipart")) {
299
+			return true;
300
+		}
301
+
302
+		return false;
303
+	}
304
+
305
+	public function get_backup_size($backup_name)
306
+	{
307
+		$backup_size = $this->get_storage_filesystem()->getSize($backup_name);
308
+		if ($this->is_multipart($backup_name)) {
309
+			$backup_parts = $this->get_multipart_files($backup_name);
310
+			foreach ($backup_parts as $part_file) {
311
+				$backup_size += $this->get_storage_filesystem()->getSize($part_file);
312
+			}
313
+		}
314
+
315
+		return $backup_size;
316
+	}
317
+
318
+	public function get_multipart_files($backup_name, $storage_selection = "")
319
+	{
320
+		$files = array();
321
+
322
+		if ($this->is_multipart($backup_name)) {
323
+			$lines = explode(PHP_EOL, $this->get_storage_filesystem($storage_selection)->read($backup_name));
324
+			foreach ($lines as $line) {
325
+				if ($line) {
326
+					$data = str_getcsv($line);
327
+					$files[] = $data[0];
328
+				}
329
+			}
330
+		}
331
+
332
+		return $files;
333
+	}
334
+
335
+	public function delete_backup_by_name($backup_name, $storage_selection = "")
336
+	{
337
+		if ($this->is_multipart($backup_name)) {
338
+			$lines = explode(PHP_EOL, $this->get_storage_filesystem($storage_selection)->read($backup_name));
339
+			foreach ($lines as $line) {
340
+				if ($line) {
341
+					$data = str_getcsv($line);
342
+					$this->get_storage_filesystem($storage_selection)->delete($data[0]);
343
+				}
344
+			}
345
+		}
346
+
347
+		if ($this->get_storage_filesystem($storage_selection)->delete($backup_name)) {
348
+			$return = true;
349
+		} else {
350
+			$return = false;
351
+		}
352
+
353
+		return $return;
354
+	}
355
+
356
+	public function getMetadataFull($adapter = "storage_adapter", $path)
357
+	{
358
+		$location = $this->$adapter->applyPathPrefix($path);
359
+		$spl_info = new SplFileInfo($location);
360
+
361
+		return ($spl_info);
362
+	}
363
+
364
+
365
+	public function get_backup_archives_list($storage_selection = "")
366
+	{
367
+		$list = array();
368
+
369
+
370
+		if (method_exists($this->get_storage_filesystem($storage_selection), "listContents")) {
371
+			$list = $this->get_storage_filesystem($storage_selection)->listContents();
372
+		}
373
+
374
+		$backup_files = array();
375
+		$parents = array();
376
+
377
+		foreach ($list as $file_info) {
378
+			if (isset($file_info['extension']) and $file_info['extension'] == "csv") {
379
+				$data = array();
380
+
381
+				$lines = explode(PHP_EOL, $this->get_storage_filesystem($storage_selection)->read($file_info['path']));
382
+				foreach ($lines as $line) {
383
+					if ($line) {
384
+						$data = str_getcsv($line);
385
+						if (is_array($data)) {
386
+							$parents[$data[0]] = $file_info['basename'];
387
+							$file_info['childs'][] = $data;
388
+							$file_info['size'] += $data[2];
389
+						}
390
+					}
391
+				}
392
+
393
+			}
394
+
395
+			if ($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'],
396
+					$this->backup_archive_extensions)) {
397
+				$backup_files[$file_info['path']] = $file_info;
398
+			}
399
+		}
400
+
401
+		foreach ($backup_files as $key => $file_info) {
402
+			if (!isset($backup_files[$key]['timestamp'])) {
403
+				//$backup_files[$key]['timestamp'] = $this->get_storage_filesystem($storage_selection)->getTimestamp($file_info['path']);
404
+			}
405
+
406
+			if (isset($parents[$file_info['basename']])) {
407
+				$backup_files[$key]['parent'] = $parents[$file_info['basename']];
408
+			}
409
+		}
410
+
411
+		return $backup_files;
412
+	}
413
+
414
+	public function start_file_recursion($init = 0)
415
+	{
416
+		if ($init) {
417
+			$this->logger->info(sprintf(__("Starting the filesystem scanner on root folder %s"),
418
+				$this->xcloner_settings->get_xcloner_start_path()));
419
+			$this->do_system_init();
420
+		}
421
+
422
+		if ($this->tmp_filesystem->has($this->get_temp_dir_handler())) {
423
+			//.dir exists, we presume we have files to iterate
424
+			$content = $this->tmp_filesystem->read($this->get_temp_dir_handler());
425
+			$files = array_filter(explode("\n", $content));
426
+			$this->tmp_filesystem->delete($this->get_temp_dir_handler());
427
+
428
+			$counter = 0;
429
+			foreach ($files as $file) {
430
+				if ($counter < $this->folders_to_process_per_session) {
431
+					$this->build_files_list($file);
432
+					$counter++;
433
+				} else {
434
+					$this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file . "\n");
435
+				}
436
+			}
437
+		} else {
438
+			$this->build_files_list();
439
+		}
440
+
441
+		if ($this->scan_finished()) {
442
+			$metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata("index.html");
443
+			$this->store_file($metadata_dumpfile, 'tmp_filesystem');
444
+			$this->files_counter++;
445
+
446
+			//adding included dump file to the included files list
447
+			if ($this->get_tmp_filesystem()->has($this->get_included_files_handler())) {
448
+				$metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata($this->get_included_files_handler());
449
+				$this->store_file($metadata_dumpfile, 'tmp_filesystem');
450
+				$this->files_counter++;
451
+			}
452
+
453
+			//adding a default index.html to the temp xcloner folder
454
+			if (!$this->get_tmp_filesystem()->has("index.html")) {
455
+				$this->get_tmp_filesystem()->write("index.html", "");
456
+			}
457
+
458
+			//adding the default log file
459
+			if ($this->get_tmp_filesystem()->has($this->xcloner_settings->get_logger_filename(1))) {
460
+				$metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata($this->xcloner_settings->get_logger_filename(1));
461
+				$this->store_file($metadata_dumpfile, 'tmp_filesystem');
462
+				$this->files_counter++;
463
+			}
464
+
465
+			return false;
466
+		}
467
+
468
+		return true;
469
+	}
470
+
471
+	public function get_backup_attachments()
472
+	{
473
+		$return = array();
474
+
475
+		$files_list_file = $this->xcloner_settings->get_xcloner_tmp_path() . DS . $this->get_included_files_handler();
476
+		if (file_exists($files_list_file)) {
477
+			$return[] = $files_list_file;
478
+		}
479
+
480
+		if ($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) {
481
+			$log_file = $this->xcloner_settings->get_xcloner_tmp_path() . DS . $this->xcloner_settings->get_logger_filename(1);
482
+			if (!file_exists($log_file)) {
483
+				$log_file = $this->xcloner_settings->get_xcloner_store_path() . DS . $this->xcloner_settings->get_logger_filename();
484
+			}
485
+
486
+			if (file_exists($log_file)) {
487
+				$return[] = $log_file;
488
+			}
489
+		}
490
+
491
+		return $return;
492
+	}
493
+
494
+	public function remove_tmp_filesystem()
495
+	{
496
+		//delete the temporary folder
497
+		$this->logger->debug(sprintf("Deleting the temporary storage folder %s",
498
+			$this->xcloner_settings->get_xcloner_tmp_path()));
499
+
500
+		$contents = $this->get_tmp_filesystem()->listContents();
501
+
502
+		if (is_array($contents)) {
503
+			foreach ($contents as $file_info) {
504
+				$this->get_tmp_filesystem()->delete($file_info['path']);
505
+			}
506
+		}
507
+
508
+		@rmdir($this->xcloner_settings->get_xcloner_tmp_path());
509
+
510
+		return;
511
+	}
512
+
513
+	public function cleanup_tmp_directories()
514
+	{
515
+		$adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(false), LOCK_EX | FILE_APPEND, 'SKIP_LINKS');
516
+		$tmp_filesystem = new Filesystem($adapter, new Config([
517
+			'disable_asserts' => true,
518
+		]));
519
+
520
+		$contents = $tmp_filesystem->listContents();
521
+
522
+		foreach ($contents as $file) {
523
+
524
+			if (preg_match("/.xcloner-(.*)/", $file['path'])) {
525
+				if ($file['timestamp'] < strtotime("-1days")) {
526
+					$tmp_filesystem->deleteDir($file['path']);
527
+					$this->logger->debug(sprintf("Delete temporary directory %s", $file['path']));
528
+				}
529
+			}
530
+		}
531
+
532
+		return true;
533
+	}
534
+
535
+	private function do_system_init()
536
+	{
537
+		$this->files_counter = 0;
538
+
539
+		if (!$this->storage_filesystem->has("index.html")) {
540
+			$this->storage_filesystem->write("index.html", "");
541
+		}
542
+
543
+		if (!$this->tmp_filesystem->has("index.html")) {
544
+			$this->tmp_filesystem->write("index.html", "");
545
+		}
546
+
547
+		if ($this->tmp_filesystem->has($this->get_included_files_handler())) {
548
+			$this->tmp_filesystem->delete($this->get_included_files_handler());
549
+		}
550
+
551
+		if ($this->tmp_filesystem->has($this->get_temp_dir_handler())) {
552
+			$this->tmp_filesystem->delete($this->get_temp_dir_handler());
553
+		}
554
+	}
555
+
556
+	public function get_scanned_files_num()
557
+	{
558
+		return $this->files_counter;
559
+	}
560
+
561
+	public function get_scanned_files_total_size()
562
+	{
563
+		return $this->files_size;
564
+	}
565
+
566
+	public function last_logged_file()
567
+	{
568
+		return $this->last_logged_file;
569
+	}
570
+
571
+	public static function is_regex($regex)
572
+	{
573
+		return preg_match("/^\^(.*)\$$/i", $regex);
574
+	}
575 575
 
576
-    public function set_excluded_files($excluded_files = array())
577
-    {
578
-        if (!is_array($excluded_files)) {
579
-            $excluded_files = array();
580
-        }
576
+	public function set_excluded_files($excluded_files = array())
577
+	{
578
+		if (!is_array($excluded_files)) {
579
+			$excluded_files = array();
580
+		}
581 581
 
582
-        foreach ($excluded_files as $excl) {
582
+		foreach ($excluded_files as $excl) {
583 583
 
584
-            if ($this->is_regex($excl)) {
585
-                $this->additional_regex_patterns[] = $excl;
586
-            }
587
-        }
584
+			if ($this->is_regex($excl)) {
585
+				$this->additional_regex_patterns[] = $excl;
586
+			}
587
+		}
588 588
 
589
-        $this->excluded_files = array_merge($excluded_files, $this->excluded_files_by_default);
589
+		$this->excluded_files = array_merge($excluded_files, $this->excluded_files_by_default);
590 590
 
591
-        return $this->excluded_files;
592
-    }
591
+		return $this->excluded_files;
592
+	}
593 593
 
594
-    public function get_excluded_files()
595
-    {
596
-        return $this->excluded_files_by_default;
597
-    }
594
+	public function get_excluded_files()
595
+	{
596
+		return $this->excluded_files_by_default;
597
+	}
598 598
 
599
-    public function list_directory($path)
600
-    {
601
-        return $this->start_filesystem->listContents($path);
602
-    }
599
+	public function list_directory($path)
600
+	{
601
+		return $this->start_filesystem->listContents($path);
602
+	}
603 603
 
604
-    public function build_files_list($folder = "")
605
-    {
606
-        $this->logger->debug(sprintf(("Building the files system list")));
604
+	public function build_files_list($folder = "")
605
+	{
606
+		$this->logger->debug(sprintf(("Building the files system list")));
607 607
 
608
-        //if we start with the root folder(empty value), we initializa the file system
609
-        if (!$folder) {
608
+		//if we start with the root folder(empty value), we initializa the file system
609
+		if (!$folder) {
610 610
 
611
-        }
611
+		}
612 612
 
613
-        try {
613
+		try {
614 614
 
615
-            $files = $this->start_filesystem->listContents($folder);
616
-            foreach ($files as $file) {
617
-                if (!is_readable($this->xcloner_settings->get_xcloner_start_path() . DS . $file['path'])) {
618
-                    $this->logger->info(sprintf(__("Excluding %s from the filesystem list, file not readable"),
619
-                        $file['path']), array(
620
-                        "FILESYSTEM SCAN",
621
-                        "NOT READABLE"
622
-                    ));
623
-                } elseif (!$matching_pattern = $this->is_excluded($file)) {
624
-                    $this->logger->info(sprintf(__("Adding %s to the filesystem list"), $file['path']), array(
625
-                        "FILESYSTEM SCAN",
626
-                        "INCLUDE"
627
-                    ));
628
-                    $file['visibility'] = $this->start_filesystem->getVisibility($file['path']);
629
-                    if ($this->store_file($file)) {
630
-                        $this->files_counter++;
631
-                    }
632
-                    if (isset($file['size'])) {
633
-                        $this->files_size += $file['size'];
634
-                    }
635
-
636
-                } else {
637
-                    $this->logger->info(sprintf(__("Excluding %s from the filesystem list, matching pattern %s"),
638
-                        $file['path'], $matching_pattern), array(
639
-                        "FILESYSTEM SCAN",
640
-                        "EXCLUDE"
641
-                    ));
642
-                }
643
-            }
615
+			$files = $this->start_filesystem->listContents($folder);
616
+			foreach ($files as $file) {
617
+				if (!is_readable($this->xcloner_settings->get_xcloner_start_path() . DS . $file['path'])) {
618
+					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, file not readable"),
619
+						$file['path']), array(
620
+						"FILESYSTEM SCAN",
621
+						"NOT READABLE"
622
+					));
623
+				} elseif (!$matching_pattern = $this->is_excluded($file)) {
624
+					$this->logger->info(sprintf(__("Adding %s to the filesystem list"), $file['path']), array(
625
+						"FILESYSTEM SCAN",
626
+						"INCLUDE"
627
+					));
628
+					$file['visibility'] = $this->start_filesystem->getVisibility($file['path']);
629
+					if ($this->store_file($file)) {
630
+						$this->files_counter++;
631
+					}
632
+					if (isset($file['size'])) {
633
+						$this->files_size += $file['size'];
634
+					}
635
+
636
+				} else {
637
+					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, matching pattern %s"),
638
+						$file['path'], $matching_pattern), array(
639
+						"FILESYSTEM SCAN",
640
+						"EXCLUDE"
641
+					));
642
+				}
643
+			}
644 644
 
645
-        } catch (Exception $e) {
645
+		} catch (Exception $e) {
646 646
 
647
-            $this->logger->error($e->getMessage());
647
+			$this->logger->error($e->getMessage());
648 648
 
649
-        }
649
+		}
650 650
 
651
-    }
651
+	}
652 652
 
653
-    public function estimate_read_write_time()
654
-    {
655
-        $tmp_file = ".xcloner" . substr(md5(time()), 0, 5);
653
+	public function estimate_read_write_time()
654
+	{
655
+		$tmp_file = ".xcloner" . substr(md5(time()), 0, 5);
656 656
 
657
-        $start_time = microtime(true);
657
+		$start_time = microtime(true);
658 658
 
659
-        $data = str_repeat(rand(0, 9), 1024 * 1024); //write 1MB data
659
+		$data = str_repeat(rand(0, 9), 1024 * 1024); //write 1MB data
660 660
 
661
-        try {
662
-            $this->tmp_filesystem->write($tmp_file, $data);
661
+		try {
662
+			$this->tmp_filesystem->write($tmp_file, $data);
663 663
 
664
-            $end_time = microtime(true) - $start_time;
664
+			$end_time = microtime(true) - $start_time;
665 665
 
666
-            $return['writing_time'] = $end_time;
666
+			$return['writing_time'] = $end_time;
667 667
 
668
-            $return['reading_time'] = $this->estimate_reading_time($tmp_file);
668
+			$return['reading_time'] = $this->estimate_reading_time($tmp_file);
669 669
 
670
-            $this->tmp_filesystem->delete($tmp_file);
670
+			$this->tmp_filesystem->delete($tmp_file);
671 671
 
672
-        } catch (Exception $e) {
672
+		} catch (Exception $e) {
673 673
 
674
-            $this->logger->error($e->getMessage());
674
+			$this->logger->error($e->getMessage());
675 675
 
676
-        }
676
+		}
677 677
 
678
-        return $return;
679
-    }
678
+		return $return;
679
+	}
680 680
 
681
-    public function backup_storage_cleanup()
682
-    {
683
-        $this->logger->info(sprintf(("Cleaning the backup storage on matching rules")));
681
+	public function backup_storage_cleanup()
682
+	{
683
+		$this->logger->info(sprintf(("Cleaning the backup storage on matching rules")));
684 684
 
685
-        $_storage_size = 0;
686
-        $_backup_files_list = array();
685
+		$_storage_size = 0;
686
+		$_backup_files_list = array();
687 687
 
688
-        //rule date limit
689
-        $current_timestamp = strtotime("-" . $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days') . " days");
688
+		//rule date limit
689
+		$current_timestamp = strtotime("-" . $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days') . " days");
690 690
 
691
-        $files = $this->storage_filesystem->listContents();
691
+		$files = $this->storage_filesystem->listContents();
692 692
 
693
-        if (is_array($files)) {
694
-            foreach ($files as $file) {
695
-                if (isset($file['extension']) and in_array($file['extension'], $this->backup_archive_extensions)) {
696
-                    $_storage_size += $file['size']; //bytes
697
-                    $_backup_files_list[] = $file;
698
-                }
699
-            }
700
-        }
693
+		if (is_array($files)) {
694
+			foreach ($files as $file) {
695
+				if (isset($file['extension']) and in_array($file['extension'], $this->backup_archive_extensions)) {
696
+					$_storage_size += $file['size']; //bytes
697
+					$_backup_files_list[] = $file;
698
+				}
699
+			}
700
+		}
701 701
 
702 702
 
703
-        $this->sort_by($_backup_files_list, "timestamp", "asc");
703
+		$this->sort_by($_backup_files_list, "timestamp", "asc");
704 704
 
705
-        $_backups_counter = sizeof($_backup_files_list);
705
+		$_backups_counter = sizeof($_backup_files_list);
706 706
 
707
-        foreach ($_backup_files_list as $file) {
708
-            //processing rule folder capacity
709
-            if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') &&
710
-                $_storage_size >= ($set_storage_limit = 1024 * 1024 * $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit')))    //bytes
711
-            {
712
-                $this->storage_filesystem->delete($file['path']);
713
-                $_storage_size -= $file['size'];
714
-                $this->logger->info("Deleting backup " . $file['path'] . " matching rule", array(
715
-                    "STORAGE SIZE LIMIT",
716
-                    $_storage_size . " >= " . $set_storage_limit
717
-                ));
718
-            }
719
-
720
-            //processing rule days limit
721
-            if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days') && $current_timestamp >= $file['timestamp']) {
722
-                $this->storage_filesystem->delete($file['path']);
723
-                $this->logger->info("Deleting backup " . $file['path'] . " matching rule", array(
724
-                    "RETENTION LIMIT TIMESTAMP",
725
-                    $file['timestamp'] . " =< " . $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days')
726
-                ));
727
-            }
728
-
729
-            //processing backup countert limit
730
-            if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_archives') && $_backups_counter >= $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_archives')) {
731
-                $this->storage_filesystem->delete($file['path']);
732
-                $_backups_counter--;
733
-                $this->logger->info("Deleting backup " . $file['path'] . " matching rule", array(
734
-                    "BACKUP QUANTITY LIMIT",
735
-                    $_backups_counter . " >= " . $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_archives')
736
-                ));
737
-            }
707
+		foreach ($_backup_files_list as $file) {
708
+			//processing rule folder capacity
709
+			if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') &&
710
+				$_storage_size >= ($set_storage_limit = 1024 * 1024 * $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit')))    //bytes
711
+			{
712
+				$this->storage_filesystem->delete($file['path']);
713
+				$_storage_size -= $file['size'];
714
+				$this->logger->info("Deleting backup " . $file['path'] . " matching rule", array(
715
+					"STORAGE SIZE LIMIT",
716
+					$_storage_size . " >= " . $set_storage_limit
717
+				));
718
+			}
719
+
720
+			//processing rule days limit
721
+			if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days') && $current_timestamp >= $file['timestamp']) {
722
+				$this->storage_filesystem->delete($file['path']);
723
+				$this->logger->info("Deleting backup " . $file['path'] . " matching rule", array(
724
+					"RETENTION LIMIT TIMESTAMP",
725
+					$file['timestamp'] . " =< " . $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days')
726
+				));
727
+			}
728
+
729
+			//processing backup countert limit
730
+			if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_archives') && $_backups_counter >= $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_archives')) {
731
+				$this->storage_filesystem->delete($file['path']);
732
+				$_backups_counter--;
733
+				$this->logger->info("Deleting backup " . $file['path'] . " matching rule", array(
734
+					"BACKUP QUANTITY LIMIT",
735
+					$_backups_counter . " >= " . $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_archives')
736
+				));
737
+			}
738 738
 
739 739
 
740
-        }
740
+		}
741 741
 
742
-    }
742
+	}
743 743
 
744
-    public function estimate_reading_time($tmp_file)
745
-    {
746
-        $this->logger->debug(sprintf(("Estimating file system reading time")));
744
+	public function estimate_reading_time($tmp_file)
745
+	{
746
+		$this->logger->debug(sprintf(("Estimating file system reading time")));
747 747
 
748
-        $start_time = microtime(true);
748
+		$start_time = microtime(true);
749 749
 
750
-        if ($this->tmp_filesystem->has($tmp_file)) {
751
-            $this->tmp_filesystem->read($tmp_file);
752
-        }
753
-
754
-        $end_time = microtime(true) - $start_time;
755
-
756
-        return $end_time;
757
-
758
-    }
759
-
760
-    public function process_backup_name($name = "", $max_length = 100)
761
-    {
762
-        if (!$name) {
763
-            $name = $this->xcloner_settings->get_default_backup_name();
764
-        }
765
-
766
-        foreach ($this->backup_name_tags as $tag) {
767
-            if ($tag == '[time]') {
768
-                $name = str_replace($tag, date("Y-m-d_H-i"), $name);
769
-            } elseif ($tag == '[hostname]') {
770
-                $name = str_replace($tag, gethostname(), $name);
771
-            } elseif ($tag == '[domain]') {
772
-                $domain = parse_url(admin_url(), PHP_URL_HOST);
773
-                $name = str_replace($tag, $domain, $name);
774
-            }
775
-        }
776
-
777
-        if ($max_length) {
778
-            $name = substr($name, 0, $max_length);
779
-        }
780
-
781
-        return $name;
782
-    }
783
-
784
-    public function sort_by(&$array, $field, $direction = 'asc')
785
-    {
786
-        if (strtolower($direction) == "desc" || $direction == SORT_DESC) {
787
-            $direction = SORT_DESC;
788
-        } else {
789
-            $direction = SORT_ASC;
790
-        }
791
-
792
-        $array = $this->array_orderby($array, $field, $direction);
793
-
794
-        return true;
795
-    }
796
-
797
-    private function array_orderby()
798
-    {
799
-        $args = func_get_args();
800
-        $data = array_shift($args);
801
-
802
-        foreach ($args as $n => $field) {
803
-            if (is_string($field)) {
804
-                $tmp = array();
805
-                foreach ($data as $key => $row) {
806
-                    if (is_array($row)) {
807
-                        $tmp[$key] = $row[$field];
808
-                    } else {
809
-                        $tmp[$key] = $row->$field;
810
-                    }
811
-                }
812
-                $args[$n] = $tmp;
813
-            }
814
-        }
815
-        $args[] = &$data;
816
-
817
-        call_user_func_array('array_multisort', $args);
818
-
819
-        return array_pop($args);
820
-    }
821
-
822
-    private function check_file_diff_time($file)
823
-    {
824
-        if ($this->get_diff_timestamp_start() != "") {
825
-            $fileMeta = $this->getMetadataFull("start_adapter", $file['path']);
826
-            $timestamp = $fileMeta->getMTime();
827
-            if ($timestamp < $fileMeta->getCTime()) {
828
-                $timestamp = $fileMeta->getCTime();
829
-            }
830
-
831
-            if ($timestamp <= $this->get_diff_timestamp_start()) {
832
-                return " file DIFF timestamp " . $timestamp . " < " . $this->diff_timestamp_start;
833
-            }
834
-        }
835
-
836
-        return false;
837
-    }
838
-
839
-    public function is_excluded($file)
840
-    {
841
-        $this->logger->debug(sprintf(("Checking if %s is excluded"), $file['path']));
842
-
843
-        if ($xcloner_exclude_files_larger_than_mb = $this->xcloner_settings->get_xcloner_option('xcloner_exclude_files_larger_than_mb')) {
844
-            if (isset($file['size']) && $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb)) {
845
-                return "> " . $xcloner_exclude_files_larger_than_mb . "MB";
846
-            }
847
-        }
848
-
849
-        if (!is_array($this->excluded_files) || !sizeof($this->excluded_files)) {
850
-            $this->set_excluded_files();
851
-        }
852
-
853
-        if (is_array($this->excluded_files)) {
854
-            foreach ($this->excluded_files as $excluded_file_pattern) {
855
-                if ($excluded_file_pattern == "/") {
856
-                    $needle = "$";
857
-                } else {
858
-                    $needle = "$" . $excluded_file_pattern;
859
-                }
860
-
861
-                if (strstr("$" . $file['path'], $needle)) {
862
-                    return $excluded_file_pattern;
863
-                }
864
-            }
865
-        }
866
-
867
-        if ($regex = $this->is_excluded_regex($file)) {
868
-            return $regex;
869
-        }
870
-
871
-        if ($file['type'] == "file") {
872
-            $check_file_diff_timestamp = $this->check_file_diff_time($file);
873
-            if ($check_file_diff_timestamp) {
874
-                return $check_file_diff_timestamp;
875
-            }
876
-        }
877
-
878
-        return false;
879
-    }
880
-
881
-    /*REGEX examples
750
+		if ($this->tmp_filesystem->has($tmp_file)) {
751
+			$this->tmp_filesystem->read($tmp_file);
752
+		}
753
+
754
+		$end_time = microtime(true) - $start_time;
755
+
756
+		return $end_time;
757
+
758
+	}
759
+
760
+	public function process_backup_name($name = "", $max_length = 100)
761
+	{
762
+		if (!$name) {
763
+			$name = $this->xcloner_settings->get_default_backup_name();
764
+		}
765
+
766
+		foreach ($this->backup_name_tags as $tag) {
767
+			if ($tag == '[time]') {
768
+				$name = str_replace($tag, date("Y-m-d_H-i"), $name);
769
+			} elseif ($tag == '[hostname]') {
770
+				$name = str_replace($tag, gethostname(), $name);
771
+			} elseif ($tag == '[domain]') {
772
+				$domain = parse_url(admin_url(), PHP_URL_HOST);
773
+				$name = str_replace($tag, $domain, $name);
774
+			}
775
+		}
776
+
777
+		if ($max_length) {
778
+			$name = substr($name, 0, $max_length);
779
+		}
780
+
781
+		return $name;
782
+	}
783
+
784
+	public function sort_by(&$array, $field, $direction = 'asc')
785
+	{
786
+		if (strtolower($direction) == "desc" || $direction == SORT_DESC) {
787
+			$direction = SORT_DESC;
788
+		} else {
789
+			$direction = SORT_ASC;
790
+		}
791
+
792
+		$array = $this->array_orderby($array, $field, $direction);
793
+
794
+		return true;
795
+	}
796
+
797
+	private function array_orderby()
798
+	{
799
+		$args = func_get_args();
800
+		$data = array_shift($args);
801
+
802
+		foreach ($args as $n => $field) {
803
+			if (is_string($field)) {
804
+				$tmp = array();
805
+				foreach ($data as $key => $row) {
806
+					if (is_array($row)) {
807
+						$tmp[$key] = $row[$field];
808
+					} else {
809
+						$tmp[$key] = $row->$field;
810
+					}
811
+				}
812
+				$args[$n] = $tmp;
813
+			}
814
+		}
815
+		$args[] = &$data;
816
+
817
+		call_user_func_array('array_multisort', $args);
818
+
819
+		return array_pop($args);
820
+	}
821
+
822
+	private function check_file_diff_time($file)
823
+	{
824
+		if ($this->get_diff_timestamp_start() != "") {
825
+			$fileMeta = $this->getMetadataFull("start_adapter", $file['path']);
826
+			$timestamp = $fileMeta->getMTime();
827
+			if ($timestamp < $fileMeta->getCTime()) {
828
+				$timestamp = $fileMeta->getCTime();
829
+			}
830
+
831
+			if ($timestamp <= $this->get_diff_timestamp_start()) {
832
+				return " file DIFF timestamp " . $timestamp . " < " . $this->diff_timestamp_start;
833
+			}
834
+		}
835
+
836
+		return false;
837
+	}
838
+
839
+	public function is_excluded($file)
840
+	{
841
+		$this->logger->debug(sprintf(("Checking if %s is excluded"), $file['path']));
842
+
843
+		if ($xcloner_exclude_files_larger_than_mb = $this->xcloner_settings->get_xcloner_option('xcloner_exclude_files_larger_than_mb')) {
844
+			if (isset($file['size']) && $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb)) {
845
+				return "> " . $xcloner_exclude_files_larger_than_mb . "MB";
846
+			}
847
+		}
848
+
849
+		if (!is_array($this->excluded_files) || !sizeof($this->excluded_files)) {
850
+			$this->set_excluded_files();
851
+		}
852
+
853
+		if (is_array($this->excluded_files)) {
854
+			foreach ($this->excluded_files as $excluded_file_pattern) {
855
+				if ($excluded_file_pattern == "/") {
856
+					$needle = "$";
857
+				} else {
858
+					$needle = "$" . $excluded_file_pattern;
859
+				}
860
+
861
+				if (strstr("$" . $file['path'], $needle)) {
862
+					return $excluded_file_pattern;
863
+				}
864
+			}
865
+		}
866
+
867
+		if ($regex = $this->is_excluded_regex($file)) {
868
+			return $regex;
869
+		}
870
+
871
+		if ($file['type'] == "file") {
872
+			$check_file_diff_timestamp = $this->check_file_diff_time($file);
873
+			if ($check_file_diff_timestamp) {
874
+				return $check_file_diff_timestamp;
875
+			}
876
+		}
877
+
878
+		return false;
879
+	}
880
+
881
+	/*REGEX examples
882 882
      *
883 883
     * exclude all except .php file
884 884
     * PATTERN: ^(.*)\.(.+)$(?<!(php))
@@ -910,163 +910,163 @@  discard block
 block discarded – undo
910 910
     * exclude the backup folders
911 911
     * PATTERN: (^|^\/)(wp-content\/backups|administrator\/backups)(.*)$";
912 912
     */
913
-    private function is_excluded_regex($file)
914
-    {
915
-        //$this->logger->debug(sprintf(("Checking if %s is excluded"), $file['path']));
916
-
917
-        $regex_patterns = explode(PHP_EOL, $this->xcloner_settings->get_xcloner_option('xcloner_regex_exclude'));
918
-
919
-        if (is_array($this->additional_regex_patterns)) {
920
-            $regex_patterns = array_merge($regex_patterns, $this->additional_regex_patterns);
921
-        }
922
-
923
-        //print_r($regex_patterns);exit;
924
-
925
-        if (is_array($regex_patterns)) {
926
-            //$this->excluded_files = array();
927
-            //$this->excluded_files[] ="(.*)\.(git)(.*)$";
928
-            //$this->excluded_files[] ="wp-content\/backups(.*)$";
929
-
930
-            foreach ($regex_patterns as $excluded_file_pattern) {
931
-
932
-                if (substr($excluded_file_pattern, strlen($excluded_file_pattern) - 1,
933
-                        strlen($excluded_file_pattern)) == "\r") {
934
-                    $excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern) - 1);
935
-                }
936
-
937
-                if ($file['path'] == "/") {
938
-                    $needle = "/";
939
-                } else {
940
-                    $needle = "/" . $file['path'];
941
-                }
942
-                //echo $needle."---".$excluded_file_pattern."---\n";
943
-
944
-                if (@preg_match("/(^|^\/)" . $excluded_file_pattern . "/i", $needle)) {
945
-                    return $excluded_file_pattern;
946
-                }
947
-            }
948
-        }
949
-
950
-        return false;
951
-    }
952
-
953
-    public function store_file($file, $storage = 'start_filesystem')
954
-    {
955
-        $this->logger->debug(sprintf("Storing %s in the backup list", $file['path']));
956
-
957
-        if (!isset($file['size'])) {
958
-            $file['size'] = 0;
959
-        }
960
-        if (!isset($file['visibility'])) {
961
-            $file['visibility'] = "private";
962
-        }
963
-
964
-        $csv_filename = str_replace('"', '""', $file['path']);
965
-
966
-        $line = '"' . ($csv_filename) . '","' . $file['timestamp'] . '","' . $file['size'] . '","' . $file['visibility'] . '","' . $storage . '"' . PHP_EOL;
967
-
968
-        $this->last_logged_file = $file['path'];
969
-
970
-        if ($file['type'] == "dir") {
971
-            try {
972
-                $this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file['path'] . "\n");
973
-            } catch (Exception $e) {
974
-                $this->logger->error($e->getMessage());
975
-            }
976
-        }
977
-
978
-        if ($this->get_diff_timestamp_start()) {
979
-            if ($file['type'] != "file" && $response = $this->check_file_diff_time($file)) {
980
-                $this->logger->info(sprintf("Directory %s archiving skipped on differential backup %s", $file['path'],
981
-                    $response), array(
982
-                    "FILESYSTEM SCAN",
983
-                    "DIR DIFF"
984
-                ));
985
-
986
-                return false;
987
-            }
988
-        }
989
-
990
-        try {
991
-            if (!$this->tmp_filesystem_append->has($this->get_included_files_handler())) {
992
-                //adding fix for UTF-8 CSV preview
993
-                $start_line = "\xEF\xBB\xBF" . '"Filename","Timestamp","Size","Visibility","Storage"' . PHP_EOL;
994
-                $this->tmp_filesystem_append->write($this->get_included_files_handler(), $start_line);
995
-            }
996
-
997
-            $this->tmp_filesystem_append->write($this->get_included_files_handler(), $line);
998
-
999
-        } catch (Exception $e) {
1000
-
1001
-            $this->logger->error($e->getMessage());
1002
-        }
1003
-
1004
-        return true;
1005
-    }
1006
-
1007
-    public function get_fileystem_handler()
1008
-    {
1009
-        return $this;
1010
-    }
1011
-
1012
-    public function get_filesystem($system = "")
1013
-    {
1014
-        if ($system == "storage_filesystem_append") {
1015
-            return $this->storage_filesystem_append;
1016
-        } elseif ($system == "tmp_filesystem_append") {
1017
-            return $this->tmp_filesystem_append;
1018
-        } elseif ($system == "tmp_filesystem") {
1019
-            return $this->tmp_filesystem;
1020
-        } elseif ($system == "storage_filesystem") {
1021
-            return $this->storage_filesystem;
1022
-        } else {
1023
-            return $this->start_filesystem;
1024
-        }
1025
-    }
1026
-
1027
-    public function get_adapter($system)
1028
-    {
1029
-        if ($system == "tmp_filesystem") {
1030
-            return $this->tmp_adapter;
1031
-        } elseif ($system == "storage_filesystem") {
1032
-            return $this->storage_adapter;
1033
-        } else {
1034
-            return $this->start_adapter;
1035
-        }
1036
-    }
1037
-
1038
-    /**
1039
-     * File scan finished
1040
-     * Method called when file scan is finished
1041
-     *
1042
-     * @return bool
1043
-     */
1044
-    private function scan_finished()
1045
-    {
1046
-        if ($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) &&
1047
-            $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler())) {
1048
-            return false;
1049
-        }
1050
-
1051
-        if ($this->tmp_filesystem->has($this->get_temp_dir_handler())) {
1052
-            $this->tmp_filesystem->delete($this->get_temp_dir_handler());
1053
-        }
1054
-
1055
-        $this->logger->debug(sprintf(("File scan finished")));
1056
-
1057
-        return true;
1058
-    }
1059
-
1060
-    /**
1061
-     * Calculate bytes from MB value
1062
-     *
1063
-     * @param int $mb_size
1064
-     *
1065
-     * @return float|int
1066
-     */
1067
-    private function calc_to_bytes($mb_size)
1068
-    {
1069
-        return $mb_size * (1024 * 1024);
1070
-    }
913
+	private function is_excluded_regex($file)
914
+	{
915
+		//$this->logger->debug(sprintf(("Checking if %s is excluded"), $file['path']));
916
+
917
+		$regex_patterns = explode(PHP_EOL, $this->xcloner_settings->get_xcloner_option('xcloner_regex_exclude'));
918
+
919
+		if (is_array($this->additional_regex_patterns)) {
920
+			$regex_patterns = array_merge($regex_patterns, $this->additional_regex_patterns);
921
+		}
922
+
923
+		//print_r($regex_patterns);exit;
924
+
925
+		if (is_array($regex_patterns)) {
926
+			//$this->excluded_files = array();
927
+			//$this->excluded_files[] ="(.*)\.(git)(.*)$";
928
+			//$this->excluded_files[] ="wp-content\/backups(.*)$";
929
+
930
+			foreach ($regex_patterns as $excluded_file_pattern) {
931
+
932
+				if (substr($excluded_file_pattern, strlen($excluded_file_pattern) - 1,
933
+						strlen($excluded_file_pattern)) == "\r") {
934
+					$excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern) - 1);
935
+				}
936
+
937
+				if ($file['path'] == "/") {
938
+					$needle = "/";
939
+				} else {
940
+					$needle = "/" . $file['path'];
941
+				}
942
+				//echo $needle."---".$excluded_file_pattern."---\n";
943
+
944
+				if (@preg_match("/(^|^\/)" . $excluded_file_pattern . "/i", $needle)) {
945
+					return $excluded_file_pattern;
946
+				}
947
+			}
948
+		}
949
+
950
+		return false;
951
+	}
952
+
953
+	public function store_file($file, $storage = 'start_filesystem')
954
+	{
955
+		$this->logger->debug(sprintf("Storing %s in the backup list", $file['path']));
956
+
957
+		if (!isset($file['size'])) {
958
+			$file['size'] = 0;
959
+		}
960
+		if (!isset($file['visibility'])) {
961
+			$file['visibility'] = "private";
962
+		}
963
+
964
+		$csv_filename = str_replace('"', '""', $file['path']);
965
+
966
+		$line = '"' . ($csv_filename) . '","' . $file['timestamp'] . '","' . $file['size'] . '","' . $file['visibility'] . '","' . $storage . '"' . PHP_EOL;
967
+
968
+		$this->last_logged_file = $file['path'];
969
+
970
+		if ($file['type'] == "dir") {
971
+			try {
972
+				$this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file['path'] . "\n");
973
+			} catch (Exception $e) {
974
+				$this->logger->error($e->getMessage());
975
+			}
976
+		}
977
+
978
+		if ($this->get_diff_timestamp_start()) {
979
+			if ($file['type'] != "file" && $response = $this->check_file_diff_time($file)) {
980
+				$this->logger->info(sprintf("Directory %s archiving skipped on differential backup %s", $file['path'],
981
+					$response), array(
982
+					"FILESYSTEM SCAN",
983
+					"DIR DIFF"
984
+				));
985
+
986
+				return false;
987
+			}
988
+		}
989
+
990
+		try {
991
+			if (!$this->tmp_filesystem_append->has($this->get_included_files_handler())) {
992
+				//adding fix for UTF-8 CSV preview
993
+				$start_line = "\xEF\xBB\xBF" . '"Filename","Timestamp","Size","Visibility","Storage"' . PHP_EOL;
994
+				$this->tmp_filesystem_append->write($this->get_included_files_handler(), $start_line);
995
+			}
996
+
997
+			$this->tmp_filesystem_append->write($this->get_included_files_handler(), $line);
998
+
999
+		} catch (Exception $e) {
1000
+
1001
+			$this->logger->error($e->getMessage());
1002
+		}
1003
+
1004
+		return true;
1005
+	}
1006
+
1007
+	public function get_fileystem_handler()
1008
+	{
1009
+		return $this;
1010
+	}
1011
+
1012
+	public function get_filesystem($system = "")
1013
+	{
1014
+		if ($system == "storage_filesystem_append") {
1015
+			return $this->storage_filesystem_append;
1016
+		} elseif ($system == "tmp_filesystem_append") {
1017
+			return $this->tmp_filesystem_append;
1018
+		} elseif ($system == "tmp_filesystem") {
1019
+			return $this->tmp_filesystem;
1020
+		} elseif ($system == "storage_filesystem") {
1021
+			return $this->storage_filesystem;
1022
+		} else {
1023
+			return $this->start_filesystem;
1024
+		}
1025
+	}
1026
+
1027
+	public function get_adapter($system)
1028
+	{
1029
+		if ($system == "tmp_filesystem") {
1030
+			return $this->tmp_adapter;
1031
+		} elseif ($system == "storage_filesystem") {
1032
+			return $this->storage_adapter;
1033
+		} else {
1034
+			return $this->start_adapter;
1035
+		}
1036
+	}
1037
+
1038
+	/**
1039
+	 * File scan finished
1040
+	 * Method called when file scan is finished
1041
+	 *
1042
+	 * @return bool
1043
+	 */
1044
+	private function scan_finished()
1045
+	{
1046
+		if ($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) &&
1047
+			$this->tmp_filesystem_append->getSize($this->get_temp_dir_handler())) {
1048
+			return false;
1049
+		}
1050
+
1051
+		if ($this->tmp_filesystem->has($this->get_temp_dir_handler())) {
1052
+			$this->tmp_filesystem->delete($this->get_temp_dir_handler());
1053
+		}
1054
+
1055
+		$this->logger->debug(sprintf(("File scan finished")));
1056
+
1057
+		return true;
1058
+	}
1059
+
1060
+	/**
1061
+	 * Calculate bytes from MB value
1062
+	 *
1063
+	 * @param int $mb_size
1064
+	 *
1065
+	 * @return float|int
1066
+	 */
1067
+	private function calc_to_bytes($mb_size)
1068
+	{
1069
+		return $mb_size * (1024 * 1024);
1070
+	}
1071 1071
 
1072 1072
 }
Please login to merge, or discard this patch.
restore/xcloner_restore.php 4 patches
Doc Comments   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
      * Update Wordpress url in wp-config.php method
652 652
      * @param $wp_path
653 653
      * @param $url
654
-     * @param $mysqli
654
+     * @param mysqli $mysqli
655 655
      * @return bool
656 656
      * @throws Exception
657 657
      */
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
      * Get backup hash method
782 782
      *
783 783
      * @param $backup_file
784
-     * @return bool
784
+     * @return false|string
785 785
      */
786 786
 	private function get_hash_from_backup($backup_file)
787 787
 	{
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
     /**
1005 1005
      * Return bytes from human readable value
1006 1006
      *
1007
-     * @param $val
1007
+     * @param string $val
1008 1008
      * @return int
1009 1009
      *
1010 1010
      */
@@ -1088,7 +1088,7 @@  discard block
 block discarded – undo
1088 1088
      * Sort_by method
1089 1089
      *
1090 1090
      * @param $array
1091
-     * @param $field
1091
+     * @param string $field
1092 1092
      * @param string $direction
1093 1093
      * @return bool
1094 1094
      */
@@ -1097,6 +1097,10 @@  discard block
 block discarded – undo
1097 1097
         $direction = strtolower($direction);
1098 1098
 
1099 1099
         usort($array,
1100
+
1101
+            /**
1102
+             * @param string $b
1103
+             */
1100 1104
             function($a, $b) use($field, $direction){
1101 1105
 
1102 1106
                 $a = $a[$field];
@@ -1162,7 +1166,7 @@  discard block
 block discarded – undo
1162 1166
      * Serialize fix methods below for mysql query lines
1163 1167
      *
1164 1168
      * @param $query
1165
-     * @return string|string[]|null
1169
+     * @return string
1166 1170
      */
1167 1171
 	 
1168 1172
 	function do_serialized_fix($query)
Please login to merge, or discard this patch.
Indentation   +243 added lines, -243 removed lines patch added patch discarded remove patch
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 	private $backup_storage_dir;
107 107
 	private $parent_api;
108 108
 
109
-    /**
110
-     * Xcloner_Restore constructor.
111
-     * @param string $parent_api
112
-     * @throws Exception
113
-     */
109
+	/**
110
+	 * Xcloner_Restore constructor.
111
+	 * @param string $parent_api
112
+	 * @throws Exception
113
+	 */
114 114
 	public function __construct($parent_api = "")
115 115
 	{
116 116
 		register_shutdown_function(array($this, 'exception_handler'));
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
 
151 151
 	}
152 152
 
153
-    /**
154
-     * Exception handler method
155
-     */
153
+	/**
154
+	 * Exception handler method
155
+	 */
156 156
 	public function exception_handler() {
157 157
 		
158 158
 		$error = error_get_last();
@@ -164,20 +164,20 @@  discard block
 block discarded – undo
164 164
 	
165 165
 	}
166 166
 
167
-    /**
168
-     * @param $type
169
-     * @return mixed|string
170
-     */
167
+	/**
168
+	 * @param $type
169
+	 * @return mixed|string
170
+	 */
171 171
 	private function friendly_error_type($type) {
172
-	    static $levels=null;
173
-	    if ($levels===null) {
174
-	        $levels=[];
175
-	        foreach (get_defined_constants() as $key=>$value) {
176
-	            if (strpos($key,'E_')!==0) {continue;}
172
+		static $levels=null;
173
+		if ($levels===null) {
174
+			$levels=[];
175
+			foreach (get_defined_constants() as $key=>$value) {
176
+				if (strpos($key,'E_')!==0) {continue;}
177 177
 					$levels[$value]= $key; //substr($key,2);
178
-	        }
179
-	    }
180
-	    return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}");
178
+			}
179
+		}
180
+		return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}");
181 181
 	}
182 182
 	
183 183
 	public function get_logger_filename()
@@ -187,12 +187,12 @@  discard block
 block discarded – undo
187 187
 		return $filename;
188 188
 	}
189 189
 
190
-    /**
191
-     * Init method
192
-     *
193
-     * @return mixed|void
194
-     * @throws Exception
195
-     */
190
+	/**
191
+	 * Init method
192
+	 *
193
+	 * @return mixed|void
194
+	 * @throws Exception
195
+	 */
196 196
 	public function init()
197 197
 	{
198 198
 		if(isset($_POST['xcloner_action']) and $_POST['xcloner_action'])
@@ -216,12 +216,12 @@  discard block
 block discarded – undo
216 216
 		return $this->check_system();
217 217
 	}
218 218
 
219
-    /**
220
-     * Write file method
221
-     *
222
-     * @return bool|int
223
-     * @throws Exception
224
-     */
219
+	/**
220
+	 * Write file method
221
+	 *
222
+	 * @return bool|int
223
+	 * @throws Exception
224
+	 */
225 225
 	public function write_file_action()
226 226
 	{
227 227
 		if(isset($_POST['file']))
@@ -266,16 +266,16 @@  discard block
 block discarded – undo
266 266
 		
267 267
 	}
268 268
 
269
-    /**
270
-     * Connect to mysql server method
271
-     *
272
-     * @param $remote_mysql_host
273
-     * @param $remote_mysql_user
274
-     * @param $remote_mysql_pass
275
-     * @param $remote_mysql_db
276
-     * @return mysqli
277
-     * @throws Exception
278
-     */
269
+	/**
270
+	 * Connect to mysql server method
271
+	 *
272
+	 * @param $remote_mysql_host
273
+	 * @param $remote_mysql_user
274
+	 * @param $remote_mysql_pass
275
+	 * @param $remote_mysql_db
276
+	 * @return mysqli
277
+	 * @throws Exception
278
+	 */
279 279
 	public function mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db )
280 280
 	{
281 281
 		$this->logger->info(sprintf('Connecting to mysql database %s with %s@%s', $remote_mysql_db, $remote_mysql_user, $remote_mysql_host));
@@ -297,11 +297,11 @@  discard block
 block discarded – undo
297 297
 		return $mysqli;	
298 298
 	}
299 299
 
300
-    /**
301
-     * Restore mysql backup file
302
-     *
303
-     * @throws Exception
304
-     */
300
+	/**
301
+	 * Restore mysql backup file
302
+	 *
303
+	 * @throws Exception
304
+	 */
305 305
 	public function restore_mysql_backup_action()
306 306
 	{
307 307
 		$mysqldump_file 	= filter_input(INPUT_POST, 'mysqldump_file', FILTER_SANITIZE_STRING);
@@ -432,14 +432,14 @@  discard block
 block discarded – undo
432 432
 		$this->send_response(200, $return);
433 433
 	}
434 434
 
435
-    /**
436
-     * Url replace method inside database backup file
437
-     *
438
-     * @param $search
439
-     * @param $replace
440
-     * @param $query
441
-     * @return mixed|string|string[]|null
442
-     */
435
+	/**
436
+	 * Url replace method inside database backup file
437
+	 *
438
+	 * @param $search
439
+	 * @param $replace
440
+	 * @param $query
441
+	 * @return mixed|string|string[]|null
442
+	 */
443 443
 	private function url_replace($search, $replace, $query)
444 444
 	{
445 445
 		$this->logger->info(sprintf("Doing url replace on query with length %s", strlen($query)), array("QUERY_REPLACE"));
@@ -462,11 +462,11 @@  discard block
 block discarded – undo
462 462
 		return $query;
463 463
 	}
464 464
 
465
-    /**
466
-     * List backup files method
467
-     *
468
-     * @throws \League\Flysystem\FileNotFoundException
469
-     */
465
+	/**
466
+	 * List backup files method
467
+	 *
468
+	 * @throws \League\Flysystem\FileNotFoundException
469
+	 */
470 470
 	public function list_backup_files_action()
471 471
 	{
472 472
 		$backup_parts = array();
@@ -532,11 +532,11 @@  discard block
 block discarded – undo
532 532
 		$this->send_response(200, $return);
533 533
 	}
534 534
 
535
-    /**
536
-     * Finish backup restore method
537
-     *
538
-     * @throws \League\Flysystem\FileNotFoundException
539
-     */
535
+	/**
536
+	 * Finish backup restore method
537
+	 *
538
+	 * @throws \League\Flysystem\FileNotFoundException
539
+	 */
540 540
 	public function restore_finish_action()
541 541
 	{
542 542
 		$remote_path 		= filter_input(INPUT_POST, 'remote_path', FILTER_SANITIZE_STRING);
@@ -577,12 +577,12 @@  discard block
 block discarded – undo
577 577
 		$this->send_response(200, $return);
578 578
 	}
579 579
 
580
-    /**
581
-     * Delete backup temporary folder
582
-     *
583
-     * @param $remote_path
584
-     * @return bool
585
-     */
580
+	/**
581
+	 * Delete backup temporary folder
582
+	 *
583
+	 * @param $remote_path
584
+	 * @return bool
585
+	 */
586 586
 	private function delete_backup_temporary_folder($remote_path)
587 587
 	{
588 588
 		$this->target_adapter = new Local($remote_path ,LOCK_EX, 'SKIP_LINKS');
@@ -610,11 +610,11 @@  discard block
 block discarded – undo
610 610
 	
611 611
 	}
612 612
 
613
-    /**
614
-     * Delete restore script method
615
-     *
616
-     * @throws \League\Flysystem\FileNotFoundException
617
-     */
613
+	/**
614
+	 * Delete restore script method
615
+	 *
616
+	 * @throws \League\Flysystem\FileNotFoundException
617
+	 */
618 618
 	private function delete_self()
619 619
 	{
620 620
 		if($this->filesystem->has("vendor.phar"))
@@ -647,14 +647,14 @@  discard block
 block discarded – undo
647 647
 		
648 648
 	}
649 649
 
650
-    /**
651
-     * Update Wordpress url in wp-config.php method
652
-     * @param $wp_path
653
-     * @param $url
654
-     * @param $mysqli
655
-     * @return bool
656
-     * @throws Exception
657
-     */
650
+	/**
651
+	 * Update Wordpress url in wp-config.php method
652
+	 * @param $wp_path
653
+	 * @param $url
654
+	 * @param $mysqli
655
+	 * @return bool
656
+	 * @throws Exception
657
+	 */
658 658
 	private function update_wp_url($wp_path, $url, $mysqli)
659 659
 	{
660 660
 		$wp_config = $wp_path.DS."wp-config.php";
@@ -682,17 +682,17 @@  discard block
 block discarded – undo
682 682
 		return true;
683 683
 	}
684 684
 
685
-    /**
686
-     * Update local wp-config.php file method
687
-     *
688
-     * @param $remote_path
689
-     * @param $remote_mysql_host
690
-     * @param $remote_mysql_user
691
-     * @param $remote_mysql_pass
692
-     * @param $remote_mysql_db
693
-     * @return string
694
-     * @throws Exception
695
-     */
685
+	/**
686
+	 * Update local wp-config.php file method
687
+	 *
688
+	 * @param $remote_path
689
+	 * @param $remote_mysql_host
690
+	 * @param $remote_mysql_user
691
+	 * @param $remote_mysql_pass
692
+	 * @param $remote_mysql_db
693
+	 * @return string
694
+	 * @throws Exception
695
+	 */
696 696
 	private function update_wp_config($remote_path, $remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db)
697 697
 	{
698 698
 		$wp_config = $remote_path.DS."wp-config.php";
@@ -724,10 +724,10 @@  discard block
 block discarded – undo
724 724
 		
725 725
 	}
726 726
 
727
-    /**
728
-     * List mysqldump database backup files
729
-     *
730
-     */
727
+	/**
728
+	 * List mysqldump database backup files
729
+	 *
730
+	 */
731 731
 	public function list_mysqldump_backups_action()
732 732
 	{
733 733
 		$source_backup_file = filter_input(INPUT_POST, 'backup_file', FILTER_SANITIZE_STRING);
@@ -777,12 +777,12 @@  discard block
 block discarded – undo
777 777
 		$this->send_response(200, $return);
778 778
 	}
779 779
 
780
-    /**
781
-     * Get backup hash method
782
-     *
783
-     * @param $backup_file
784
-     * @return bool
785
-     */
780
+	/**
781
+	 * Get backup hash method
782
+	 *
783
+	 * @param $backup_file
784
+	 * @return bool
785
+	 */
786 786
 	private function get_hash_from_backup($backup_file)
787 787
 	{
788 788
 		if(!$backup_file)
@@ -796,11 +796,11 @@  discard block
 block discarded – undo
796 796
 		return false;
797 797
 	}
798 798
 
799
-    /**
800
-     * List backup archives found on local system
801
-     *
802
-     * @throws \League\Flysystem\FileNotFoundException
803
-     */
799
+	/**
800
+	 * List backup archives found on local system
801
+	 *
802
+	 * @throws \League\Flysystem\FileNotFoundException
803
+	 */
804 804
 	public function list_backup_archives_action()
805 805
 	{
806 806
 		$local_backup_file = filter_input(INPUT_POST, 'local_backup_file', FILTER_SANITIZE_STRING);
@@ -859,12 +859,12 @@  discard block
 block discarded – undo
859 859
 		
860 860
 	}
861 861
 
862
-    /**
863
-     * Restore backup archive to local path
864
-     *
865
-     * @throws \League\Flysystem\FileNotFoundException
866
-     * @throws \splitbrain\PHPArchive\ArchiveIOException
867
-     */
862
+	/**
863
+	 * Restore backup archive to local path
864
+	 *
865
+	 * @throws \League\Flysystem\FileNotFoundException
866
+	 * @throws \splitbrain\PHPArchive\ArchiveIOException
867
+	 */
868 868
 	public function restore_backup_to_path_action()
869 869
 	{
870 870
 		$source_backup_file 	= filter_input(INPUT_POST, 'backup_file', FILTER_SANITIZE_STRING);
@@ -939,9 +939,9 @@  discard block
 block discarded – undo
939 939
 		$this->send_response(200, $return);
940 940
 	}
941 941
 
942
-    /**
943
-     * Get current directory method
944
-     */
942
+	/**
943
+	 * Get current directory method
944
+	 */
945 945
 	public function get_current_directory_action()
946 946
 	{	
947 947
 		global $wpdb;
@@ -975,11 +975,11 @@  discard block
 block discarded – undo
975 975
 		$this->send_response(200, $return);
976 976
 	}
977 977
 
978
-    /**
979
-     * Check current filesystem
980
-     *
981
-     * @throws Exception
982
-     */
978
+	/**
979
+	 * Check current filesystem
980
+	 *
981
+	 * @throws Exception
982
+	 */
983 983
 	public function check_system()
984 984
 	{
985 985
 		//check if i can write
@@ -1001,35 +1001,35 @@  discard block
 block discarded – undo
1001 1001
 		$this->send_response(200, $return);
1002 1002
 	}
1003 1003
 
1004
-    /**
1005
-     * Return bytes from human readable value
1006
-     *
1007
-     * @param $val
1008
-     * @return int
1009
-     *
1010
-     */
1011
-    private function return_bytes($val) {
1012
-        $numeric_val = (int)trim($val);
1013
-        $last = strtolower($val[strlen($val)-1]);
1014
-        switch($last) {
1015
-            // The 'G' modifier is available since PHP 5.1.0
1016
-            case 'g':
1017
-                $numeric_val *= 1024;
1018
-            case 'm':
1019
-                $numeric_val *= 1024;
1020
-            case 'k':
1021
-                $numeric_val *= 1024;
1022
-        }
1004
+	/**
1005
+	 * Return bytes from human readable value
1006
+	 *
1007
+	 * @param $val
1008
+	 * @return int
1009
+	 *
1010
+	 */
1011
+	private function return_bytes($val) {
1012
+		$numeric_val = (int)trim($val);
1013
+		$last = strtolower($val[strlen($val)-1]);
1014
+		switch($last) {
1015
+			// The 'G' modifier is available since PHP 5.1.0
1016
+			case 'g':
1017
+				$numeric_val *= 1024;
1018
+			case 'm':
1019
+				$numeric_val *= 1024;
1020
+			case 'k':
1021
+				$numeric_val *= 1024;
1022
+		}
1023 1023
 
1024
-        return $numeric_val;
1025
-    }
1024
+		return $numeric_val;
1025
+	}
1026 1026
 
1027
-    /**
1028
-     * Check if backup archive os multipart
1029
-     *
1030
-     * @param $backup_name
1031
-     * @return bool
1032
-     */
1027
+	/**
1028
+	 * Check if backup archive os multipart
1029
+	 *
1030
+	 * @param $backup_name
1031
+	 * @return bool
1032
+	 */
1033 1033
 	public function is_multipart($backup_name)
1034 1034
 	{
1035 1035
 		if(stristr($backup_name, "-multipart"))
@@ -1038,13 +1038,13 @@  discard block
 block discarded – undo
1038 1038
 		return false;	
1039 1039
 	}
1040 1040
 
1041
-    /**
1042
-     * Get backup archive size
1043
-     *
1044
-     * @param $backup_name
1045
-     * @return bool|false|int
1046
-     * @throws \League\Flysystem\FileNotFoundException
1047
-     */
1041
+	/**
1042
+	 * Get backup archive size
1043
+	 *
1044
+	 * @param $backup_name
1045
+	 * @return bool|false|int
1046
+	 * @throws \League\Flysystem\FileNotFoundException
1047
+	 */
1048 1048
 	public function get_backup_size($backup_name)
1049 1049
 	{
1050 1050
 		$backup_size = $this->filesystem->getSize($backup_name);
@@ -1058,12 +1058,12 @@  discard block
 block discarded – undo
1058 1058
 		return $backup_size;
1059 1059
 	}
1060 1060
 
1061
-    /**
1062
-     * Get multipart backup files list
1063
-     * @param $backup_name
1064
-     * @return array
1065
-     * @throws \League\Flysystem\FileNotFoundException
1066
-     */
1061
+	/**
1062
+	 * Get multipart backup files list
1063
+	 * @param $backup_name
1064
+	 * @return array
1065
+	 * @throws \League\Flysystem\FileNotFoundException
1066
+	 */
1067 1067
 	public function get_multipart_files($backup_name)
1068 1068
 	{
1069 1069
 		$files = array();
@@ -1084,58 +1084,58 @@  discard block
 block discarded – undo
1084 1084
 		return $files;
1085 1085
 	}
1086 1086
 
1087
-    /**
1088
-     * Sort_by method
1089
-     *
1090
-     * @param $array
1091
-     * @param $field
1092
-     * @param string $direction
1093
-     * @return bool
1094
-     */
1095
-    private function sort_by( &$array, $field, $direction = 'asc')
1096
-    {
1097
-        $direction = strtolower($direction);
1087
+	/**
1088
+	 * Sort_by method
1089
+	 *
1090
+	 * @param $array
1091
+	 * @param $field
1092
+	 * @param string $direction
1093
+	 * @return bool
1094
+	 */
1095
+	private function sort_by( &$array, $field, $direction = 'asc')
1096
+	{
1097
+		$direction = strtolower($direction);
1098 1098
 
1099
-        usort($array,
1100
-            function($a, $b) use($field, $direction){
1099
+		usort($array,
1100
+			function($a, $b) use($field, $direction){
1101 1101
 
1102
-                $a = $a[$field];
1103
-                $b = $b[$field];
1102
+				$a = $a[$field];
1103
+				$b = $b[$field];
1104 1104
 
1105
-                if ($a == $b)
1106
-                {
1107
-                    return 0;
1108
-                }
1105
+				if ($a == $b)
1106
+				{
1107
+					return 0;
1108
+				}
1109 1109
 
1110
-                if($direction == 'desc') {
1111
-                    if($a > $b) {
1112
-                        return -1;
1113
-                    }
1114
-                    else{
1115
-                        return 1;
1116
-                    }
1117
-                }else {
1118
-                    if($a < $b) {
1119
-                        return -1;
1120
-                    }
1121
-                    else{
1122
-                        return 1;
1123
-                    }
1124
-                }
1110
+				if($direction == 'desc') {
1111
+					if($a > $b) {
1112
+						return -1;
1113
+					}
1114
+					else{
1115
+						return 1;
1116
+					}
1117
+				}else {
1118
+					if($a < $b) {
1119
+						return -1;
1120
+					}
1121
+					else{
1122
+						return 1;
1123
+					}
1124
+				}
1125 1125
 
1126
-                //return ($a.($direction == 'desc' ? '>' : '<').$b) ? -1 : 1;
1127
-            }
1128
-        );
1126
+				//return ($a.($direction == 'desc' ? '>' : '<').$b) ? -1 : 1;
1127
+			}
1128
+		);
1129 1129
 
1130
-        return true;
1131
-    }
1130
+		return true;
1131
+	}
1132 1132
 
1133
-    /**
1134
-     * Send response method
1135
-     *
1136
-     * @param int $status
1137
-     * @param $response
1138
-     */
1133
+	/**
1134
+	 * Send response method
1135
+	 *
1136
+	 * @param int $status
1137
+	 * @param $response
1138
+	 */
1139 1139
 	public static function send_response($status = 200, $response)
1140 1140
 	{
1141 1141
 		header("Access-Control-Allow-Origin: *");
@@ -1158,12 +1158,12 @@  discard block
 block discarded – undo
1158 1158
 		exit;
1159 1159
 	}
1160 1160
 
1161
-    /**
1162
-     * Serialize fix methods below for mysql query lines
1163
-     *
1164
-     * @param $query
1165
-     * @return string|string[]|null
1166
-     */
1161
+	/**
1162
+	 * Serialize fix methods below for mysql query lines
1163
+	 *
1164
+	 * @param $query
1165
+	 * @return string|string[]|null
1166
+	 */
1167 1167
 	 
1168 1168
 	function do_serialized_fix($query)
1169 1169
 	{
@@ -1176,51 +1176,51 @@  discard block
 block discarded – undo
1176 1176
 					$m[3] = "";
1177 1177
 					
1178 1178
 					$data = 's:'.strlen(($m[3])).':\"'.($m[3]).'\";';
1179
-	              //return $this->unescape_quotes($data);
1179
+				  //return $this->unescape_quotes($data);
1180 1180
 	              
1181
-	              return $data;
1182
-	            }, $query);
1181
+				  return $data;
1182
+				}, $query);
1183 1183
 	}
1184 1184
 
1185
-    /**
1186
-     * Unescape quotes method
1187
-     *
1188
-     * @param $value
1189
-     * @return mixed
1190
-     */
1185
+	/**
1186
+	 * Unescape quotes method
1187
+	 *
1188
+	 * @param $value
1189
+	 * @return mixed
1190
+	 */
1191 1191
 	private function unescape_quotes($value) {
1192 1192
 		return str_replace('\"', '"', $value);
1193 1193
 	}
1194 1194
 
1195
-    /**
1196
-     * Unescape mysql method
1197
-     *
1198
-     * @param $value
1199
-     * @return mixed
1200
-     */
1195
+	/**
1196
+	 * Unescape mysql method
1197
+	 *
1198
+	 * @param $value
1199
+	 * @return mixed
1200
+	 */
1201 1201
 	private function unescape_mysql($value) {
1202 1202
 		return str_replace(array("\\\\", "\\0", "\\n", "\\r", "\Z",  "\'", '\"'),
1203 1203
 						   array("\\",   "\0",  "\n",  "\r",  "\x1a", "'", '"'), 
1204 1204
 						   $value);
1205 1205
 	}
1206 1206
 
1207
-    /**
1208
-     * Check if string is in serialized format
1209
-     *
1210
-     * @param $s
1211
-     * @return bool
1212
-     */
1207
+	/**
1208
+	 * Check if string is in serialized format
1209
+	 *
1210
+	 * @param $s
1211
+	 * @return bool
1212
+	 */
1213 1213
 	private function has_serialized($s)
1214 1214
 	{
1215 1215
 		if(
1216
-		    stristr($s, '{' ) != false &&
1217
-		    stristr($s, '}' ) != false &&
1218
-		    stristr($s, ';' ) != false &&
1219
-		    stristr($s, ':' ) != false
1220
-		    ){
1221
-		    return true;
1216
+			stristr($s, '{' ) != false &&
1217
+			stristr($s, '}' ) != false &&
1218
+			stristr($s, ';' ) != false &&
1219
+			stristr($s, ':' ) != false
1220
+			){
1221
+			return true;
1222 1222
 		}else{
1223
-		    return false;
1223
+			return false;
1224 1224
 		}
1225 1225
 
1226 1226
 	}
Please login to merge, or discard this patch.
Spacing   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -1,30 +1,30 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('AUTH_KEY'))
3
+if (!defined('AUTH_KEY'))
4 4
 {
5 5
 	define('AUTH_KEY', '');
6 6
 }
7 7
 
8
-if(!defined("DS"))
8
+if (!defined("DS"))
9 9
 {
10 10
 	define("DS", DIRECTORY_SEPARATOR);
11 11
 }
12 12
 
13
-if(!defined('XCLONER_PLUGIN_ACCESS') || XCLONER_PLUGIN_ACCESS != 1)
13
+if (!defined('XCLONER_PLUGIN_ACCESS') || XCLONER_PLUGIN_ACCESS != 1)
14 14
 {	
15
-	if(!AUTH_KEY)
15
+	if (!AUTH_KEY)
16 16
 	{
17 17
 			Xcloner_Restore::send_response("404", "Could not run restore script, AUTH_KEY not set!");
18 18
 			exit;
19 19
 	}
20 20
 	
21
-	if(!isset($_REQUEST['hash']))
21
+	if (!isset($_REQUEST['hash']))
22 22
 	{
23 23
 			Xcloner_Restore::send_response("404", "Could not run restore script, sent HASH is empty!");
24 24
 			exit;
25 25
 	}
26 26
 	
27
-	if($_REQUEST['hash'] != AUTH_KEY)
27
+	if ($_REQUEST['hash'] != AUTH_KEY)
28 28
 	{
29 29
 			Xcloner_Restore::send_response("404", "Could not run restore script, AUTH_KEY doesn't match the sent HASH!");
30 30
 			exit;
@@ -32,28 +32,28 @@  discard block
 block discarded – undo
32 32
 }
33 33
 
34 34
 //check minimum PHP version
35
-if(version_compare(phpversion(), Xcloner_Restore::xcloner_minimum_version, '<'))
35
+if (version_compare(phpversion(), Xcloner_Restore::xcloner_minimum_version, '<'))
36 36
 {
37
-	Xcloner_Restore::send_response(500, sprintf(("XCloner requires minimum PHP version %s in order to run correctly. We have detected your version as %s"),Xcloner_Restore::xcloner_minimum_version, phpversion()) );
37
+	Xcloner_Restore::send_response(500, sprintf(("XCloner requires minimum PHP version %s in order to run correctly. We have detected your version as %s"), Xcloner_Restore::xcloner_minimum_version, phpversion()));
38 38
 	exit;
39 39
 
40 40
 }
41 41
 
42
-$file = dirname( __DIR__ )  . DS.'vendor'.DS.'autoload.php';
42
+$file = dirname(__DIR__).DS.'vendor'.DS.'autoload.php';
43 43
 
44
-if(file_exists($file))
44
+if (file_exists($file))
45 45
 {
46 46
 	
47 47
 	require_once($file);
48 48
 }
49
-elseif(file_exists("vendor.phar") and extension_loaded('phar'))
49
+elseif (file_exists("vendor.phar") and extension_loaded('phar'))
50 50
 {
51 51
 	require_once(__DIR__.DS."vendor.phar");
52
-}else{	
52
+} else {	
53 53
 	
54
-	$file = dirname( __FILE__ )  . DS.'vendor'.DS.'autoload.php';
54
+	$file = dirname(__FILE__).DS.'vendor'.DS.'autoload.php';
55 55
 	
56
-	if(!file_exists($file))
56
+	if (!file_exists($file))
57 57
 	{
58 58
 		Xcloner_Restore::send_response("404", "File $file does not exists, please extract the vendor.tgz archive on the server or enable PHP Phar module!");
59 59
 		exit;
@@ -78,16 +78,16 @@  discard block
 block discarded – undo
78 78
 
79 79
 //do not modify below
80 80
 $that = "";
81
-if(defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS)
81
+if (defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS)
82 82
 {
83 83
 	$that = $this;
84 84
 }
85 85
 $xcloner_restore = new Xcloner_Restore($that);
86 86
 
87
-try{
87
+try {
88 88
 	$return = $xcloner_restore->init();
89 89
 	$xcloner_restore->send_response(200, $return);
90
-}catch(Exception $e){
90
+}catch (Exception $e) {
91 91
 	$xcloner_restore->send_response(417, $e->getMessage());
92 92
 }
93 93
 
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
 	
97 97
 	const 	xcloner_minimum_version = "5.4.0";
98 98
 	
99
-	private $backup_archive_extensions 		= array("zip", "tar", "tgz", "tar.gz", "gz", "csv");
100
-	private $process_files_limit 			= 150;
101
-	private $process_files_limit_list 		= 350;
102
-	private $process_mysql_records_limit 	= 250;
99
+	private $backup_archive_extensions = array("zip", "tar", "tgz", "tar.gz", "gz", "csv");
100
+	private $process_files_limit = 150;
101
+	private $process_files_limit_list = 350;
102
+	private $process_mysql_records_limit = 250;
103 103
 	private $adapter;
104 104
 	private $filesystem;
105 105
 	private $logger;
@@ -115,12 +115,12 @@  discard block
 block discarded – undo
115 115
 	{
116 116
 		register_shutdown_function(array($this, 'exception_handler'));
117 117
 
118
-		if(defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS)
118
+		if (defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS)
119 119
 		{
120 120
 			$dir = $parent_api->get_xcloner_container()->get_xcloner_settings()->get_xcloner_store_path();
121 121
 		}
122 122
 		
123
-		if(!isset($dir) || !$dir){
123
+		if (!isset($dir) || !$dir) {
124 124
 			$dir = dirname(__FILE__);
125 125
 		}
126 126
 		
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 		
129 129
 		$this->backup_storage_dir = $dir;
130 130
 		
131
-		$this->adapter = new Local($dir ,LOCK_EX, 'SKIP_LINKS');
131
+		$this->adapter = new Local($dir, LOCK_EX, 'SKIP_LINKS');
132 132
 		$this->filesystem = new Filesystem($this->adapter, new Config([
133 133
 				'disable_asserts' => true,
134 134
 			]));
@@ -137,15 +137,15 @@  discard block
 block discarded – undo
137 137
 		
138 138
 		$logger_path = $this->get_logger_filename();
139 139
 		
140
-		if(!is_writeable($logger_path) and !touch($logger_path))
140
+		if (!is_writeable($logger_path) and !touch($logger_path))
141 141
 		{
142 142
 			$logger_path = "php://stderr";
143 143
 		}
144 144
 		
145 145
 		$this->logger->pushHandler(new StreamHandler($logger_path, Logger::DEBUG));
146 146
 		
147
-		if(isset($_POST['API_ID'])){
148
-			$this->logger->info("Processing ajax request ID ".substr(filter_input(INPUT_POST, 'API_ID', FILTER_SANITIZE_STRING), 0 , 15));
147
+		if (isset($_POST['API_ID'])) {
148
+			$this->logger->info("Processing ajax request ID ".substr(filter_input(INPUT_POST, 'API_ID', FILTER_SANITIZE_STRING), 0, 15));
149 149
 		}
150 150
 
151 151
 	}
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
 		
158 158
 		$error = error_get_last();
159 159
 		
160
-		if($error['type'] and $this->logger)
160
+		if ($error['type'] and $this->logger)
161 161
 		{
162
-			$this->logger->info($this->friendly_error_type ($error['type']).": ".var_export($error, true));
162
+			$this->logger->info($this->friendly_error_type($error['type']).": ".var_export($error, true));
163 163
 		}
164 164
 	
165 165
 	}
@@ -169,12 +169,12 @@  discard block
 block discarded – undo
169 169
      * @return mixed|string
170 170
      */
171 171
 	private function friendly_error_type($type) {
172
-	    static $levels=null;
173
-	    if ($levels===null) {
174
-	        $levels=[];
172
+	    static $levels = null;
173
+	    if ($levels === null) {
174
+	        $levels = [];
175 175
 	        foreach (get_defined_constants() as $key=>$value) {
176
-	            if (strpos($key,'E_')!==0) {continue;}
177
-					$levels[$value]= $key; //substr($key,2);
176
+	            if (strpos($key, 'E_') !== 0) {continue; }
177
+					$levels[$value] = $key; //substr($key,2);
178 178
 	        }
179 179
 	    }
180 180
 	    return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}");
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	
183 183
 	public function get_logger_filename()
184 184
 	{
185
-		$filename = $this->backup_storage_dir .DS. "xcloner_restore.log";
185
+		$filename = $this->backup_storage_dir.DS."xcloner_restore.log";
186 186
 		
187 187
 		return $filename;
188 188
 	}
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
      */
196 196
 	public function init()
197 197
 	{
198
-		if(isset($_POST['xcloner_action']) and $_POST['xcloner_action'])
198
+		if (isset($_POST['xcloner_action']) and $_POST['xcloner_action'])
199 199
 		{
200 200
 			$method = filter_input(INPUT_POST, 'xcloner_action', FILTER_SANITIZE_STRING);
201 201
 			
@@ -203,13 +203,13 @@  discard block
 block discarded – undo
203 203
 			
204 204
 			$method .= "_action";
205 205
 			
206
-			if(method_exists($this, $method))
206
+			if (method_exists($this, $method))
207 207
 			{
208 208
 				$this->logger->debug(sprintf('Starting action %s', $method));
209 209
 				return call_user_func(array($this, $method));
210 210
 				
211
-			}else{
212
-				throw new Exception($method ." does not exists");
211
+			} else {
212
+				throw new Exception($method." does not exists");
213 213
 				}
214 214
 		}
215 215
 		
@@ -224,38 +224,38 @@  discard block
 block discarded – undo
224 224
      */
225 225
 	public function write_file_action()
226 226
 	{
227
-		if(isset($_POST['file']))
227
+		if (isset($_POST['file']))
228 228
 		{
229 229
 			$target_file = filter_input(INPUT_POST, 'file', FILTER_SANITIZE_STRING);
230 230
 			
231
-			if(!$_POST['start'])
231
+			if (!$_POST['start'])
232 232
 				$fp = fopen($target_file, "wb+");
233 233
 			else
234 234
 				$fp = fopen($target_file, "ab+");	
235 235
 			
236
-			if(!$fp)
236
+			if (!$fp)
237 237
 				throw new Exception("Unable to open $target_file file for writing");
238 238
 			
239 239
 			fseek($fp, $_POST['start']);
240 240
 			
241
-			if(isset($_FILES['blob']))
241
+			if (isset($_FILES['blob']))
242 242
 			{
243 243
 				$this->logger->debug(sprintf('Writing %s bytes to file %s starting position %s using FILES blob', filesize($_FILES['blob']['tmp_name']), $target_file, $_POST['start']));
244 244
 				
245 245
 				$blob = file_get_contents($_FILES['blob']['tmp_name']);
246 246
 				
247
-				if(!$bytes_written = fwrite($fp, $blob))
247
+				if (!$bytes_written = fwrite($fp, $blob))
248 248
 					throw new Exception("Unable to write data to file $target_file");
249 249
 				
250 250
 				@unlink($_FILES['blob']['tmp_name']);
251
-			}elseif(isset($_POST['blob'])){
251
+			}elseif (isset($_POST['blob'])) {
252 252
 				$this->logger->debug(sprintf('Writing %s bytes to file %s starting position %s using POST blob', strlen($_POST['blob']), $target_file, $_POST['start']));
253 253
 				
254 254
 				$blob = $_POST['blob'];
255 255
 
256
-				if(!$bytes_written = fwrite($fp, $blob))
256
+				if (!$bytes_written = fwrite($fp, $blob))
257 257
 					throw new Exception("Unable to write data to file $target_file");
258
-			}else{
258
+			} else {
259 259
 				throw new Exception("Upload failed, did not receive any binary data");
260 260
 			}
261 261
 			
@@ -276,20 +276,20 @@  discard block
 block discarded – undo
276 276
      * @return mysqli
277 277
      * @throws Exception
278 278
      */
279
-	public function mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db )
279
+	public function mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db)
280 280
 	{
281 281
 		$this->logger->info(sprintf('Connecting to mysql database %s with %s@%s', $remote_mysql_db, $remote_mysql_user, $remote_mysql_host));
282 282
 
283 283
 		$mysqli = new mysqli($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db);
284 284
 
285 285
 		if ($mysqli->connect_error) {
286
-			throw new Exception('Connect Error (' . $mysqli->connect_errno . ') '
286
+			throw new Exception('Connect Error ('.$mysqli->connect_errno.') '
287 287
 				. $mysqli->connect_error);
288 288
 		}
289 289
 		
290 290
 		$mysqli->query("SET sql_mode='';");
291 291
 		$mysqli->query("SET foreign_key_checks = 0;");
292
-		if(isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file'])
292
+		if (isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file'])
293 293
 			$mysqli->query("SET NAMES ".$_REQUEST['charset_of_file']."");
294 294
 		else
295 295
 			$mysqli->query("SET NAMES utf8;");
@@ -304,15 +304,15 @@  discard block
 block discarded – undo
304 304
      */
305 305
 	public function restore_mysql_backup_action()
306 306
 	{
307
-		$mysqldump_file 	= filter_input(INPUT_POST, 'mysqldump_file', FILTER_SANITIZE_STRING);
308
-		$remote_path 		= filter_input(INPUT_POST, 'remote_path', FILTER_SANITIZE_STRING);
307
+		$mysqldump_file = filter_input(INPUT_POST, 'mysqldump_file', FILTER_SANITIZE_STRING);
308
+		$remote_path = filter_input(INPUT_POST, 'remote_path', FILTER_SANITIZE_STRING);
309 309
 		$remote_mysql_user 	= filter_input(INPUT_POST, 'remote_mysql_user', FILTER_SANITIZE_STRING);
310 310
 		$remote_mysql_pass 	= filter_input(INPUT_POST, 'remote_mysql_pass', FILTER_SANITIZE_STRING);
311
-		$remote_mysql_db 	= filter_input(INPUT_POST, 'remote_mysql_db', FILTER_SANITIZE_STRING);
311
+		$remote_mysql_db = filter_input(INPUT_POST, 'remote_mysql_db', FILTER_SANITIZE_STRING);
312 312
 		$remote_mysql_host 	= filter_input(INPUT_POST, 'remote_mysql_host', FILTER_SANITIZE_STRING);
313
-		$execute_query 		= trim(stripslashes($_POST['query']));
314
-		$error_line			= filter_input(INPUT_POST, 'error_line', FILTER_SANITIZE_NUMBER_INT);
315
-		$start			 	= filter_input(INPUT_POST, 'start', FILTER_SANITIZE_NUMBER_INT);
313
+		$execute_query = trim(stripslashes($_POST['query']));
314
+		$error_line = filter_input(INPUT_POST, 'error_line', FILTER_SANITIZE_NUMBER_INT);
315
+		$start = filter_input(INPUT_POST, 'start', FILTER_SANITIZE_NUMBER_INT);
316 316
 		
317 317
 		$wp_home_url 		= filter_input(INPUT_POST, 'wp_home_url', FILTER_SANITIZE_STRING);
318 318
 		$remote_restore_url = filter_input(INPUT_POST, 'remote_restore_url', FILTER_SANITIZE_STRING);
@@ -322,8 +322,8 @@  discard block
 block discarded – undo
322 322
 		
323 323
 		$mysql_backup_file = $remote_path.DS.$mysqldump_file;
324 324
 		
325
-		if(!file_exists($mysql_backup_file))
326
-			throw new Exception(sprintf("Mysql backup file %s does not exists",$mysql_backup_file));
325
+		if (!file_exists($mysql_backup_file))
326
+			throw new Exception(sprintf("Mysql backup file %s does not exists", $mysql_backup_file));
327 327
 		
328 328
 		
329 329
 		/*if(defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS)
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 		}*/
338 338
 		
339 339
 		{
340
-			$mysqli = $this->mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db );
340
+			$mysqli = $this->mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db);
341 341
 		}
342 342
 		
343 343
 		$line_count = 0;
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 		$return['backup_size']	= filesize($mysql_backup_file);
348 348
 		
349 349
 		$fp = fopen($mysql_backup_file, "r");
350
-		if($fp)
350
+		if ($fp)
351 351
 		{
352 352
 			$this->logger->info(sprintf("Opening mysql dump file %s at position %s.", $mysql_backup_file, $start));
353 353
 			fseek($fp, $start);
@@ -355,49 +355,49 @@  discard block
 block discarded – undo
355 355
 			// process the line read.
356 356
 									
357 357
 				//check if line is comment
358
-				if(substr($line, 0, 1) == "#")
358
+				if (substr($line, 0, 1) == "#")
359 359
 					continue;
360 360
 				
361 361
 				//check if line is empty	
362
-				if($line == "\n" or trim($line) == "")
362
+				if ($line == "\n" or trim($line) == "")
363 363
 					continue;
364 364
 					
365
-				if(substr($line, strlen($line)-2, strlen($line)) == ";\n")
365
+				if (substr($line, strlen($line) - 2, strlen($line)) == ";\n")
366 366
 					$query .= $line;
367
-				else{
367
+				else {
368 368
 					$query .= $line;
369 369
 					continue;
370 370
 				}
371 371
 				
372
-				if($execute_query)
372
+				if ($execute_query)
373 373
 				{
374
-					$query  = (($execute_query));
374
+					$query = (($execute_query));
375 375
 					$execute_query = "";
376 376
 				}	
377 377
 				
378 378
 				//Doing serialized url replace here
379 379
 				
380
-				if($wp_site_url and $wp_home_url and strlen($wp_home_url) < strlen($wp_site_url))
380
+				if ($wp_site_url and $wp_home_url and strlen($wp_home_url) < strlen($wp_site_url))
381 381
 				{
382
-					list($wp_home_url,$wp_site_url) 			= array($wp_site_url,$wp_home_url);
383
-					list($remote_restore_url,$restore_site_url) = array($restore_site_url,$remote_restore_url);
382
+					list($wp_home_url, $wp_site_url) = array($wp_site_url, $wp_home_url);
383
+					list($remote_restore_url, $restore_site_url) = array($restore_site_url, $remote_restore_url);
384 384
 					
385 385
 				}
386 386
 				
387
-				if($wp_home_url and $remote_restore_url and strpos($query, $wp_home_url) !== false)
387
+				if ($wp_home_url and $remote_restore_url and strpos($query, $wp_home_url) !== false)
388 388
 				{
389 389
 					$query = $this->url_replace($wp_home_url, $remote_restore_url, $query);
390 390
 				}
391 391
 				
392
-				if($wp_site_url and $restore_site_url and strpos($query, $wp_site_url) !== false)
392
+				if ($wp_site_url and $restore_site_url and strpos($query, $wp_site_url) !== false)
393 393
 				{
394 394
 					$query = $this->url_replace($wp_site_url, $restore_site_url, $query);
395 395
 				}
396 396
 				
397
-				if(!$mysqli->query($query) && !stristr($mysqli->error,"Duplicate entry"))
397
+				if (!$mysqli->query($query) && !stristr($mysqli->error, "Duplicate entry"))
398 398
 				{
399 399
 					//$return['error_line'] = $line_count;
400
-					$return['start'] = ftell($fp)-strlen($line);
400
+					$return['start'] = ftell($fp) - strlen($line);
401 401
 					$return['query_error'] = true;
402 402
 					$return['query'] = $query;
403 403
 					$return['message'] = sprintf("Mysql Error: %s\n", $mysqli->error);
@@ -418,12 +418,12 @@  discard block
 block discarded – undo
418 418
 		
419 419
 		$return['start'] = ftell($fp);
420 420
 		
421
-		$this->logger->info(sprintf("Executed %s queries of size %s bytes", $line_count, ($return['start']-$start)));
421
+		$this->logger->info(sprintf("Executed %s queries of size %s bytes", $line_count, ($return['start'] - $start)));
422 422
 		
423
-		if(!feof($fp))
423
+		if (!feof($fp))
424 424
 		{
425 425
 			$return['finished'] = 0;
426
-		}else{
426
+		} else {
427 427
 			$this->logger->info(sprintf("Mysql Import Done."));
428 428
 		}
429 429
 		
@@ -446,12 +446,12 @@  discard block
 block discarded – undo
446 446
 		$query = str_replace($search, $replace, $query);
447 447
 		$original_query = $query;
448 448
 		
449
-		if($this->has_serialized($query))
449
+		if ($this->has_serialized($query))
450 450
 		{
451 451
 			$this->logger->info(sprintf("Query contains serialized data, doing serialized size fix"), array("QUERY_REPLACE"));
452 452
 			$query = $this->do_serialized_fix($query);
453 453
 			
454
-			if(!$query)
454
+			if (!$query)
455 455
 			{
456 456
 				$this->logger->info(sprintf("Serialization probably failed here..."), array("QUERY_REPLACE"));
457 457
 				$query = $original_query;
@@ -472,37 +472,37 @@  discard block
 block discarded – undo
472 472
 		$backup_parts = array();
473 473
 		
474 474
 		$source_backup_file = filter_input(INPUT_POST, 'file', FILTER_SANITIZE_STRING);
475
-		$start 				= (int)filter_input(INPUT_POST, 'start', FILTER_SANITIZE_STRING);
476
-		$return['part'] 	= (int)filter_input(INPUT_POST, 'part', FILTER_SANITIZE_STRING);
475
+		$start = (int)filter_input(INPUT_POST, 'start', FILTER_SANITIZE_STRING);
476
+		$return['part'] = (int)filter_input(INPUT_POST, 'part', FILTER_SANITIZE_STRING);
477 477
 		
478 478
 		$backup_file = $source_backup_file;
479 479
 		
480
-		if($this->is_multipart($backup_file))
480
+		if ($this->is_multipart($backup_file))
481 481
 		{
482 482
 			$backup_parts = $this->get_multipart_files($backup_file);
483 483
 			$backup_file = $backup_parts[$return['part']];
484 484
 		}
485 485
 		
486
-		try{
486
+		try {
487 487
 			$tar = new Tar();
488 488
 			$tar->open($this->backup_storage_dir.DS.$backup_file, $start);
489 489
 		
490 490
 			$data = $tar->contents($this->process_files_limit_list);
491
-		}catch(Exception $e)
491
+		}catch (Exception $e)
492 492
 		{
493 493
 			$return['error'] = true;
494 494
 			$return['message'] = $e->getMessage();
495 495
 			$this->send_response(200, $return);
496 496
 		}
497 497
 		
498
-		$return['files'] 		= array();
499
-		$return['finished'] 	= 1;
500
-		$return['total_size'] 	= filesize($this->backup_storage_dir.DS.$backup_file);
498
+		$return['files'] = array();
499
+		$return['finished'] = 1;
500
+		$return['total_size'] = filesize($this->backup_storage_dir.DS.$backup_file);
501 501
 		$i = 0;
502 502
 		
503
-		if(isset($data['extracted_files']) and is_array($data['extracted_files']))
503
+		if (isset($data['extracted_files']) and is_array($data['extracted_files']))
504 504
 		{
505
-			foreach($data['extracted_files'] as $file)
505
+			foreach ($data['extracted_files'] as $file)
506 506
 			{
507 507
 				$return['files'][$i]['path'] = $file->getPath();
508 508
 				$return['files'][$i]['size'] = $file->getSize();
@@ -512,18 +512,18 @@  discard block
 block discarded – undo
512 512
 			}
513 513
 		}
514 514
 		
515
-		if(isset($data['start']))
515
+		if (isset($data['start']))
516 516
 		{
517 517
 			$return['start'] = $data['start'];
518 518
 			$return['finished'] = 0;	
519
-		}else{
520
-			if($this->is_multipart($source_backup_file))
519
+		} else {
520
+			if ($this->is_multipart($source_backup_file))
521 521
 			{
522 522
 				$return['start'] = 0;
523 523
 				
524 524
 				++$return['part'];
525 525
 			
526
-				if($return['part'] < sizeof($backup_parts))	
526
+				if ($return['part'] < sizeof($backup_parts))	
527 527
 					$return['finished'] = 0;
528 528
 				
529 529
 			}
@@ -546,28 +546,28 @@  discard block
 block discarded – undo
546 546
 		
547 547
 		$remote_mysql_user 	= filter_input(INPUT_POST, 'remote_mysql_user', FILTER_SANITIZE_STRING);
548 548
 		$remote_mysql_pass 	= filter_input(INPUT_POST, 'remote_mysql_pass', FILTER_SANITIZE_STRING);
549
-		$remote_mysql_db 	= filter_input(INPUT_POST, 'remote_mysql_db', FILTER_SANITIZE_STRING);
549
+		$remote_mysql_db = filter_input(INPUT_POST, 'remote_mysql_db', FILTER_SANITIZE_STRING);
550 550
 		$remote_mysql_host 	= filter_input(INPUT_POST, 'remote_mysql_host', FILTER_SANITIZE_STRING);
551 551
 		
552
-		$update_remote_site_url			 	= filter_input(INPUT_POST, 'update_remote_site_url', FILTER_SANITIZE_NUMBER_INT);
553
-		$delete_restore_script			 	= filter_input(INPUT_POST, 'delete_restore_script', FILTER_SANITIZE_NUMBER_INT);
554
-		$delete_backup_temporary_folder		= filter_input(INPUT_POST, 'delete_backup_temporary_folder', FILTER_SANITIZE_NUMBER_INT);
552
+		$update_remote_site_url = filter_input(INPUT_POST, 'update_remote_site_url', FILTER_SANITIZE_NUMBER_INT);
553
+		$delete_restore_script = filter_input(INPUT_POST, 'delete_restore_script', FILTER_SANITIZE_NUMBER_INT);
554
+		$delete_backup_temporary_folder = filter_input(INPUT_POST, 'delete_backup_temporary_folder', FILTER_SANITIZE_NUMBER_INT);
555 555
 				
556
-		if($update_remote_site_url)
556
+		if ($update_remote_site_url)
557 557
 		{
558
-			$mysqli = $this->mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db );
558
+			$mysqli = $this->mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db);
559 559
 			$this->update_wp_config($remote_path, $remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db);
560 560
 			$this->update_wp_url($remote_path, $remote_restore_url, $mysqli);
561 561
 		}
562 562
 		
563
-		if($delete_backup_temporary_folder)
563
+		if ($delete_backup_temporary_folder)
564 564
 		{
565 565
 			$this->delete_backup_temporary_folder($remote_path);
566 566
 		}
567 567
 		
568
-		if(!defined('XCLONER_PLUGIN_ACCESS') || XCLONER_PLUGIN_ACCESS != 1)
568
+		if (!defined('XCLONER_PLUGIN_ACCESS') || XCLONER_PLUGIN_ACCESS != 1)
569 569
 		{
570
-			if($delete_restore_script)
570
+			if ($delete_restore_script)
571 571
 			{
572 572
 				$this->delete_self();
573 573
 			}
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
      */
586 586
 	private function delete_backup_temporary_folder($remote_path)
587 587
 	{
588
-		$this->target_adapter = new Local($remote_path ,LOCK_EX, 'SKIP_LINKS');
588
+		$this->target_adapter = new Local($remote_path, LOCK_EX, 'SKIP_LINKS');
589 589
 		$this->target_filesystem = new Filesystem($this->target_adapter, new Config([
590 590
 				'disable_asserts' => true,
591 591
 			]));
@@ -593,13 +593,13 @@  discard block
 block discarded – undo
593 593
 		$mysqldump_list = array();
594 594
 		$list = $this->target_filesystem->listContents();
595 595
 		
596
-		foreach($list as $file)
596
+		foreach ($list as $file)
597 597
 		{
598 598
 			$matches = array();
599 599
 			
600
-			if($file['type'] == "dir")
600
+			if ($file['type'] == "dir")
601 601
 			{
602
-				if(preg_match("/xcloner-(\w*)/", $file['basename'], $matches)){
602
+				if (preg_match("/xcloner-(\w*)/", $file['basename'], $matches)) {
603 603
 					$this->logger->info(sprintf('Deleting temporary folder %s', $file['path']));
604 604
 					$this->target_filesystem->deleteDir($file['path']);
605 605
 				}
@@ -617,29 +617,29 @@  discard block
 block discarded – undo
617 617
      */
618 618
 	private function delete_self()
619 619
 	{
620
-		if($this->filesystem->has("vendor.phar"))
620
+		if ($this->filesystem->has("vendor.phar"))
621 621
 		{
622 622
 			$this->logger->info(sprintf('Deleting vendor.phar'));
623 623
 			$this->filesystem->delete("vendor.phar");
624 624
 		}
625
-		if($this->filesystem->has("vendor"))
625
+		if ($this->filesystem->has("vendor"))
626 626
 		{
627 627
 			$this->logger->info(sprintf('Deleting vendor folder'));
628 628
 			$this->filesystem->deleteDir("vendor");
629 629
 		}
630
-		if($this->filesystem->has("xcloner_restore.php"))
630
+		if ($this->filesystem->has("xcloner_restore.php"))
631 631
 		{
632 632
 			$this->logger->info(sprintf('Deleting xcloner_restore.php'));
633 633
 			$this->filesystem->delete("xcloner_restore.php");
634 634
 		}
635 635
 		
636
-		if($this->filesystem->has("xcloner_restore.log"))
636
+		if ($this->filesystem->has("xcloner_restore.log"))
637 637
 		{
638 638
 			$this->logger->info(sprintf('Deleting xcloner_restore.log'));
639 639
 			$this->filesystem->delete("xcloner_restore.log");
640 640
 		}
641 641
 		
642
-		if($this->filesystem->has($this->get_logger_filename()))
642
+		if ($this->filesystem->has($this->get_logger_filename()))
643 643
 		{
644 644
 			$this->logger->info(sprintf('Deleting logger file %s', $this->get_logger_filename()));
645 645
 			$this->filesystem->delete($this->get_logger_filename());
@@ -661,11 +661,11 @@  discard block
 block discarded – undo
661 661
 		
662 662
 		$this->logger->info(sprintf('Updating site url to %s', $url));
663 663
 		
664
-		if(file_exists($wp_config))
664
+		if (file_exists($wp_config))
665 665
 		{
666 666
 			$config = file_get_contents($wp_config);
667 667
 			preg_match("/.*table_prefix.*=.*'(.*)'/i", $config, $matches);
668
-			if(isset($matches[1]))
668
+			if (isset($matches[1]))
669 669
 				$table_prefix = $matches[1];
670 670
 			else
671 671
 				throw new Exception("Could not load wordpress table prefix from wp-config.php file.");
@@ -673,10 +673,10 @@  discard block
 block discarded – undo
673 673
 		else
674 674
 			throw new Exception("Could not update the SITEURL and HOME, wp-config.php file not found");
675 675
 			
676
-		if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='home'"))
676
+		if (!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='home'"))
677 677
 			throw new Exception(sprintf("Could not update the HOME option, error: %s\n", $mysqli->error));
678 678
 		
679
-		if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='siteurl'"))
679
+		if (!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='siteurl'"))
680 680
 			throw new Exception(sprintf("Could not update the SITEURL option, error: %s\n", $mysqli->error));
681 681
 		
682 682
 		return true;
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 	{
698 698
 		$wp_config = $remote_path.DS."wp-config.php";
699 699
 		
700
-		if(!file_exists($wp_config))
700
+		if (!file_exists($wp_config))
701 701
 		{
702 702
 			throw new Exception("Could not find the wp-config.php in ".$remote_path);
703 703
 		}
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 		
716 716
 		$this->logger->info(sprintf('Updating wp-config.php file with the new mysql details'));
717 717
 		
718
-		if(!file_put_contents($wp_config, $content))
718
+		if (!file_put_contents($wp_config, $content))
719 719
 			throw new Exception("Could not write updated config data to ".$wp_config);
720 720
 		
721 721
 		chmod($wp_config, $file_perms);
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
 	
736 736
 		$hash = $this->get_hash_from_backup($source_backup_file);	
737 737
 		
738
-		$this->target_adapter = new Local($remote_path ,LOCK_EX, 'SKIP_LINKS');
738
+		$this->target_adapter = new Local($remote_path, LOCK_EX, 'SKIP_LINKS');
739 739
 		$this->target_filesystem = new Filesystem($this->target_adapter, new Config([
740 740
 				'disable_asserts' => true,
741 741
 			]));
@@ -743,25 +743,25 @@  discard block
 block discarded – undo
743 743
 		$mysqldump_list = array();
744 744
 		$list = $this->target_filesystem->listContents();
745 745
 		
746
-		foreach($list as $file)
746
+		foreach ($list as $file)
747 747
 		{
748 748
 			$matches = array();
749 749
 			
750
-			if($file['type'] == "dir")
750
+			if ($file['type'] == "dir")
751 751
 			{
752
-				if(preg_match("/xcloner-(\w*)/", $file['basename'], $matches))
752
+				if (preg_match("/xcloner-(\w*)/", $file['basename'], $matches))
753 753
 				{
754 754
 					$files = $this->target_filesystem->listContents($file['basename']);
755
-					foreach($files as $file)
755
+					foreach ($files as $file)
756 756
 					{
757
-						if($file['extension'] == "sql")
757
+						if ($file['extension'] == "sql")
758 758
 						{
759 759
 							$this->logger->info(sprintf('Found %s mysql backup file', $file['path']));
760 760
 							$mysqldump_list[$file['path']]['path'] = $file['path'];
761 761
 							$mysqldump_list[$file['path']]['size'] = $file['size'];
762
-							$mysqldump_list[$file['path']]['timestamp'] = date("d M,Y H:i",$file['timestamp']);
762
+							$mysqldump_list[$file['path']]['timestamp'] = date("d M,Y H:i", $file['timestamp']);
763 763
 							
764
-							if($hash and $hash == $matches[1])
764
+							if ($hash and $hash == $matches[1])
765 765
 								$mysqldump_list[$file['path']]['selected'] = "selected";
766 766
 							else
767 767
 								$mysqldump_list[$file['path']]['selected'] = "";	
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 			}	
772 772
 		}
773 773
 		
774
-		$this->sort_by($mysqldump_list, 'timestamp','desc');
774
+		$this->sort_by($mysqldump_list, 'timestamp', 'desc');
775 775
 		$return['files'] = $mysqldump_list;
776 776
 		
777 777
 		$this->send_response(200, $return);
@@ -785,12 +785,12 @@  discard block
 block discarded – undo
785 785
      */
786 786
 	private function get_hash_from_backup($backup_file)
787 787
 	{
788
-		if(!$backup_file)
788
+		if (!$backup_file)
789 789
 			return false;
790 790
 			
791
-		$result = preg_match("/-(\w*)./", substr($backup_file, strlen($backup_file)-10, strlen($backup_file)), $matches)	;
791
+		$result = preg_match("/-(\w*)./", substr($backup_file, strlen($backup_file) - 10, strlen($backup_file)), $matches);
792 792
 		
793
-		if($result and isset($matches[1]))
793
+		if ($result and isset($matches[1]))
794 794
 			return ($matches[1]);
795 795
 		
796 796
 		return false;
@@ -809,18 +809,18 @@  discard block
 block discarded – undo
809 809
 		$backup_files = array();
810 810
 		$parents = array();
811 811
 		
812
-		foreach($list as $file_info)
812
+		foreach ($list as $file_info)
813 813
 		{
814 814
 			$data = array();
815 815
 			
816
-			if(isset($file_info['extension']) and $file_info['extension'] == "csv")
816
+			if (isset($file_info['extension']) and $file_info['extension'] == "csv")
817 817
 			{
818 818
 				$lines = explode(PHP_EOL, $this->filesystem->read($file_info['path']));
819
-				foreach($lines as $line)
820
-					if($line)
819
+				foreach ($lines as $line)
820
+					if ($line)
821 821
 					{
822 822
 						$data = str_getcsv($line);
823
-						if(is_array($data)){
823
+						if (is_array($data)) {
824 824
 							$parents[$data[0]] = $file_info['path'];
825 825
 							$file_info['childs'][] = $data;
826 826
 							$file_info['size'] += $data[2];
@@ -829,19 +829,19 @@  discard block
 block discarded – undo
829 829
 						
830 830
 			}
831 831
 			
832
-			if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions))
832
+			if ($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions))
833 833
 				$backup_files[$file_info['path']] = $file_info;
834 834
 		}
835 835
 		
836 836
 		$new_list = array();
837 837
 		
838
-		foreach($backup_files as $key=>$file_info)
838
+		foreach ($backup_files as $key=>$file_info)
839 839
 		{
840
-			if(isset($parents[$file_info['path']]))
840
+			if (isset($parents[$file_info['path']]))
841 841
 				$backup_files[$key]['parent'] = $parents[$file_info['path']];
842
-			else{
842
+			else {
843 843
 				
844
-				if($local_backup_file and ($file_info['basename'] == $local_backup_file))
844
+				if ($local_backup_file and ($file_info['basename'] == $local_backup_file))
845 845
 					$file_info['selected'] = 'selected';
846 846
 				
847 847
 				$this->logger->info(sprintf('Found %s backup file', $file_info['path']));
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 				
852 852
 		}
853 853
 		
854
-		$this->sort_by($new_list, "timestamp","desc");
854
+		$this->sort_by($new_list, "timestamp", "desc");
855 855
 		
856 856
 		$return['files'] = $new_list;
857 857
 		
@@ -867,15 +867,15 @@  discard block
 block discarded – undo
867 867
      */
868 868
 	public function restore_backup_to_path_action()
869 869
 	{
870
-		$source_backup_file 	= filter_input(INPUT_POST, 'backup_file', FILTER_SANITIZE_STRING);
871
-		$remote_path 			= filter_input(INPUT_POST, 'remote_path', FILTER_SANITIZE_STRING);
870
+		$source_backup_file = filter_input(INPUT_POST, 'backup_file', FILTER_SANITIZE_STRING);
871
+		$remote_path = filter_input(INPUT_POST, 'remote_path', FILTER_SANITIZE_STRING);
872 872
 		$include_filter_files 	= filter_input(INPUT_POST, 'filter_files', FILTER_SANITIZE_STRING);
873 873
 		$exclude_filter_files 	= "";
874
-		$start 					= filter_input(INPUT_POST, 'start', FILTER_SANITIZE_NUMBER_INT);
875
-		$return['part'] 		= (int)filter_input(INPUT_POST, 'part', FILTER_SANITIZE_NUMBER_INT);
874
+		$start = filter_input(INPUT_POST, 'start', FILTER_SANITIZE_NUMBER_INT);
875
+		$return['part'] = (int)filter_input(INPUT_POST, 'part', FILTER_SANITIZE_NUMBER_INT);
876 876
 		$return['processed'] 	= (int)filter_input(INPUT_POST, 'processed', FILTER_SANITIZE_NUMBER_INT);
877 877
 				
878
-		$this->target_adapter = new Local($remote_path ,LOCK_EX, 'SKIP_LINKS');
878
+		$this->target_adapter = new Local($remote_path, LOCK_EX, 'SKIP_LINKS');
879 879
 		$this->target_filesystem = new Filesystem($this->target_adapter, new Config([
880 880
 				'disable_asserts' => true,
881 881
 			]));
@@ -887,9 +887,9 @@  discard block
 block discarded – undo
887 887
 		$return['total_size'] = $this->get_backup_size($backup_file);
888 888
 		
889 889
 		$backup_archive = new Tar();
890
-		if($this->is_multipart($backup_file))
890
+		if ($this->is_multipart($backup_file))
891 891
 		{
892
-			if(!$return['part'])
892
+			if (!$return['part'])
893 893
 				$return['processed'] += $this->filesystem->getSize($backup_file);
894 894
 				
895 895
 			$backup_parts = $this->get_multipart_files($backup_file);
@@ -897,41 +897,41 @@  discard block
 block discarded – undo
897 897
 		}	
898 898
 		
899 899
 		$this->logger->info(sprintf('Opening backup archive %s at position %s', $backup_file, $start));
900
-		$backup_archive->open($this->backup_storage_dir .DS. $backup_file, $start);
900
+		$backup_archive->open($this->backup_storage_dir.DS.$backup_file, $start);
901 901
 
902
-		$data = $backup_archive->extract($remote_path, '',$exclude_filter_files,$include_filter_files, $this->process_files_limit);
902
+		$data = $backup_archive->extract($remote_path, '', $exclude_filter_files, $include_filter_files, $this->process_files_limit);
903 903
 		
904
-		if(isset($data['extracted_files']))
904
+		if (isset($data['extracted_files']))
905 905
 		{
906
-			foreach($data['extracted_files'] as $spl_fileinfo)
906
+			foreach ($data['extracted_files'] as $spl_fileinfo)
907 907
 			{
908 908
 				$this->logger->info(sprintf('Extracted %s file', $spl_fileinfo->getPath()));
909 909
 				$return['extracted_files'][] = $spl_fileinfo->getPath()." (".$spl_fileinfo->getSize()." bytes)";
910 910
 			}
911 911
 		}
912 912
 		
913
-		if(isset($data['start']))
913
+		if (isset($data['start']))
914 914
 		//if(isset($data['start']) and $data['start'] <= $this->filesystem->getSize($backup_file))
915 915
 		{
916 916
 			$return['finished'] = 0;
917 917
 			$return['start'] = $data['start'];
918
-		}else{
918
+		} else {
919 919
 			
920 920
 			$return['processed'] += $start;
921 921
 			
922
-			if($this->is_multipart($source_backup_file))
922
+			if ($this->is_multipart($source_backup_file))
923 923
 			{
924 924
 				$return['start'] = 0;
925 925
 				
926 926
 				++$return['part'];
927 927
 			
928
-				if($return['part'] < sizeof($backup_parts))	
928
+				if ($return['part'] < sizeof($backup_parts))	
929 929
 					$return['finished'] = 0;
930 930
 				
931 931
 			}
932 932
 		}
933 933
 		
934
-		if($return['finished'])
934
+		if ($return['finished'])
935 935
 			$this->logger->info(sprintf('Done extracting %s', $source_backup_file));
936 936
 		
937 937
 		$return['backup_file'] = $backup_file;
@@ -948,24 +948,24 @@  discard block
 block discarded – undo
948 948
 		
949 949
 		$restore_script_url = filter_input(INPUT_POST, 'restore_script_url', FILTER_SANITIZE_STRING);
950 950
 		
951
-		$pathinfo = pathinfo( __FILE__);
951
+		$pathinfo = pathinfo(__FILE__);
952 952
 		
953 953
 		$suffix = "";
954 954
 		$return['remote_mysql_host'] 	= "localhost";
955 955
 		$return['remote_mysql_user'] 	= "";
956 956
 		$return['remote_mysql_pass'] 	= "";
957
-		$return['remote_mysql_db'] 		= "";
957
+		$return['remote_mysql_db'] = "";
958 958
 		
959
-		if(defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS)
959
+		if (defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS)
960 960
 		{
961 961
 			$return['dir'] = realpath(get_home_path().DS.$suffix);
962
-			$return['restore_script_url']  	= get_site_url();
962
+			$return['restore_script_url'] = get_site_url();
963 963
 			$return['remote_mysql_host'] 	= $wpdb->dbhost;
964 964
 			$return['remote_mysql_user'] 	= $wpdb->dbuser;
965 965
 			$return['remote_mysql_pass'] 	= $wpdb->dbpassword;
966
-			$return['remote_mysql_db'] 		= $wpdb->dbname;
966
+			$return['remote_mysql_db'] = $wpdb->dbname;
967 967
 		}
968
-		else{
968
+		else {
969 969
 			$return['dir'] = ($pathinfo['dirname']).DS.$suffix;
970 970
 			$return['restore_script_url'] = str_replace($pathinfo['basename'], "", $restore_script_url).$suffix;
971 971
 		}	
@@ -984,17 +984,17 @@  discard block
 block discarded – undo
984 984
 	{
985 985
 		//check if i can write
986 986
 		$tmp_file = md5(time());
987
-		if(!file_put_contents($tmp_file, "++"))
987
+		if (!file_put_contents($tmp_file, "++"))
988 988
 			throw new Exception("Could not write to new host");
989 989
 		
990
-		if(!unlink($tmp_file))
990
+		if (!unlink($tmp_file))
991 991
 			throw new Exception("Could not delete temporary file from new host");
992 992
 		
993 993
 		$max_upload      = $this->return_bytes((ini_get('upload_max_filesize')));
994 994
 		$max_post        = $this->return_bytes((ini_get('post_max_size')));
995 995
 
996 996
 		$return['max_upload_size'] = min($max_upload, $max_post); // bytes
997
-		$return['status']		= true;
997
+		$return['status'] = true;
998 998
 		
999 999
 		$this->logger->info(sprintf('Current filesystem max upload size is %s bytes', $return['max_upload_size']));
1000 1000
 		
@@ -1010,8 +1010,8 @@  discard block
 block discarded – undo
1010 1010
      */
1011 1011
     private function return_bytes($val) {
1012 1012
         $numeric_val = (int)trim($val);
1013
-        $last = strtolower($val[strlen($val)-1]);
1014
-        switch($last) {
1013
+        $last = strtolower($val[strlen($val) - 1]);
1014
+        switch ($last) {
1015 1015
             // The 'G' modifier is available since PHP 5.1.0
1016 1016
             case 'g':
1017 1017
                 $numeric_val *= 1024;
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
      */
1033 1033
 	public function is_multipart($backup_name)
1034 1034
 	{
1035
-		if(stristr($backup_name, "-multipart"))
1035
+		if (stristr($backup_name, "-multipart"))
1036 1036
 			return true;
1037 1037
 		
1038 1038
 		return false;	
@@ -1048,10 +1048,10 @@  discard block
 block discarded – undo
1048 1048
 	public function get_backup_size($backup_name)
1049 1049
 	{
1050 1050
 		$backup_size = $this->filesystem->getSize($backup_name);
1051
-		if($this->is_multipart($backup_name))
1051
+		if ($this->is_multipart($backup_name))
1052 1052
 		{
1053 1053
 			$backup_parts = $this->get_multipart_files($backup_name);
1054
-			foreach($backup_parts as $part_file)
1054
+			foreach ($backup_parts as $part_file)
1055 1055
 				$backup_size += $this->filesystem->getSize($part_file);
1056 1056
 		}
1057 1057
 		
@@ -1068,12 +1068,12 @@  discard block
 block discarded – undo
1068 1068
 	{
1069 1069
 		$files = array();
1070 1070
 		
1071
-		if($this->is_multipart($backup_name))
1071
+		if ($this->is_multipart($backup_name))
1072 1072
 		{
1073 1073
 			$lines = explode(PHP_EOL, $this->filesystem->read($backup_name));
1074
-			foreach($lines as $line)
1074
+			foreach ($lines as $line)
1075 1075
 			{
1076
-				if($line)
1076
+				if ($line)
1077 1077
 				{
1078 1078
 					$data = str_getcsv($line);
1079 1079
 					$files[] = $data[0];
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
      * @param string $direction
1093 1093
      * @return bool
1094 1094
      */
1095
-    private function sort_by( &$array, $field, $direction = 'asc')
1095
+    private function sort_by(&$array, $field, $direction = 'asc')
1096 1096
     {
1097 1097
         $direction = strtolower($direction);
1098 1098
 
@@ -1107,18 +1107,18 @@  discard block
 block discarded – undo
1107 1107
                     return 0;
1108 1108
                 }
1109 1109
 
1110
-                if($direction == 'desc') {
1111
-                    if($a > $b) {
1110
+                if ($direction == 'desc') {
1111
+                    if ($a > $b) {
1112 1112
                         return -1;
1113 1113
                     }
1114
-                    else{
1114
+                    else {
1115 1115
                         return 1;
1116 1116
                     }
1117
-                }else {
1118
-                    if($a < $b) {
1117
+                } else {
1118
+                    if ($a < $b) {
1119 1119
                         return -1;
1120 1120
                     }
1121
-                    else{
1121
+                    else {
1122 1122
                         return 1;
1123 1123
                     }
1124 1124
                 }
@@ -1144,11 +1144,11 @@  discard block
 block discarded – undo
1144 1144
 		$return['status'] = $status;
1145 1145
 		$return['statusText'] = $response;
1146 1146
 		
1147
-		if(isset($response['error']) && $response['error'])
1147
+		if (isset($response['error']) && $response['error'])
1148 1148
 		{
1149 1149
 			$return['statusText'] = $response['message'];
1150 1150
 			$return['error'] = true;
1151
-		}elseif($status != 200 and $status != 418)
1151
+		}elseif ($status != 200 and $status != 418)
1152 1152
 		{
1153 1153
 			$return['error'] = true;
1154 1154
 			$return['message'] = $response;
@@ -1167,12 +1167,12 @@  discard block
 block discarded – undo
1167 1167
 	 
1168 1168
 	function do_serialized_fix($query)
1169 1169
 	{
1170
-		$query = str_replace(array("\\n","\\r","\\'"), array("","","\""), ($query));
1170
+		$query = str_replace(array("\\n", "\\r", "\\'"), array("", "", "\""), ($query));
1171 1171
 		
1172
-		return preg_replace_callback('!s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!', function ($m) {
1172
+		return preg_replace_callback('!s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!', function($m) {
1173 1173
 				  $data = "";
1174 1174
 				  	
1175
-				  if(!isset($m[3]))
1175
+				  if (!isset($m[3]))
1176 1176
 					$m[3] = "";
1177 1177
 					
1178 1178
 					$data = 's:'.strlen(($m[3])).':\"'.($m[3]).'\";';
@@ -1199,8 +1199,8 @@  discard block
 block discarded – undo
1199 1199
      * @return mixed
1200 1200
      */
1201 1201
 	private function unescape_mysql($value) {
1202
-		return str_replace(array("\\\\", "\\0", "\\n", "\\r", "\Z",  "\'", '\"'),
1203
-						   array("\\",   "\0",  "\n",  "\r",  "\x1a", "'", '"'), 
1202
+		return str_replace(array("\\\\", "\\0", "\\n", "\\r", "\Z", "\'", '\"'),
1203
+						   array("\\", "\0", "\n", "\r", "\x1a", "'", '"'), 
1204 1204
 						   $value);
1205 1205
 	}
1206 1206
 
@@ -1212,14 +1212,14 @@  discard block
 block discarded – undo
1212 1212
      */
1213 1213
 	private function has_serialized($s)
1214 1214
 	{
1215
-		if(
1216
-		    stristr($s, '{' ) != false &&
1217
-		    stristr($s, '}' ) != false &&
1218
-		    stristr($s, ';' ) != false &&
1219
-		    stristr($s, ':' ) != false
1220
-		    ){
1215
+		if (
1216
+		    stristr($s, '{') != false &&
1217
+		    stristr($s, '}') != false &&
1218
+		    stristr($s, ';') != false &&
1219
+		    stristr($s, ':') != false
1220
+		    ) {
1221 1221
 		    return true;
1222
-		}else{
1222
+		} else {
1223 1223
 		    return false;
1224 1224
 		}
1225 1225
 
Please login to merge, or discard this patch.
Braces   +116 added lines, -92 removed lines patch added patch discarded remove patch
@@ -45,11 +45,10 @@  discard block
 block discarded – undo
45 45
 {
46 46
 	
47 47
 	require_once($file);
48
-}
49
-elseif(file_exists("vendor.phar") and extension_loaded('phar'))
48
+} elseif(file_exists("vendor.phar") and extension_loaded('phar'))
50 49
 {
51 50
 	require_once(__DIR__.DS."vendor.phar");
52
-}else{	
51
+} else{	
53 52
 	
54 53
 	$file = dirname( __FILE__ )  . DS.'vendor'.DS.'autoload.php';
55 54
 	
@@ -87,7 +86,7 @@  discard block
 block discarded – undo
87 86
 try{
88 87
 	$return = $xcloner_restore->init();
89 88
 	$xcloner_restore->send_response(200, $return);
90
-}catch(Exception $e){
89
+} catch(Exception $e){
91 90
 	$xcloner_restore->send_response(417, $e->getMessage());
92 91
 }
93 92
 
@@ -208,7 +207,7 @@  discard block
 block discarded – undo
208 207
 				$this->logger->debug(sprintf('Starting action %s', $method));
209 208
 				return call_user_func(array($this, $method));
210 209
 				
211
-			}else{
210
+			} else{
212 211
 				throw new Exception($method ." does not exists");
213 212
 				}
214 213
 		}
@@ -228,13 +227,15 @@  discard block
 block discarded – undo
228 227
 		{
229 228
 			$target_file = filter_input(INPUT_POST, 'file', FILTER_SANITIZE_STRING);
230 229
 			
231
-			if(!$_POST['start'])
232
-				$fp = fopen($target_file, "wb+");
233
-			else
234
-				$fp = fopen($target_file, "ab+");	
230
+			if(!$_POST['start']) {
231
+							$fp = fopen($target_file, "wb+");
232
+			} else {
233
+							$fp = fopen($target_file, "ab+");
234
+			}
235 235
 			
236
-			if(!$fp)
237
-				throw new Exception("Unable to open $target_file file for writing");
236
+			if(!$fp) {
237
+							throw new Exception("Unable to open $target_file file for writing");
238
+			}
238 239
 			
239 240
 			fseek($fp, $_POST['start']);
240 241
 			
@@ -244,18 +245,20 @@  discard block
 block discarded – undo
244 245
 				
245 246
 				$blob = file_get_contents($_FILES['blob']['tmp_name']);
246 247
 				
247
-				if(!$bytes_written = fwrite($fp, $blob))
248
-					throw new Exception("Unable to write data to file $target_file");
248
+				if(!$bytes_written = fwrite($fp, $blob)) {
249
+									throw new Exception("Unable to write data to file $target_file");
250
+				}
249 251
 				
250 252
 				@unlink($_FILES['blob']['tmp_name']);
251
-			}elseif(isset($_POST['blob'])){
253
+			} elseif(isset($_POST['blob'])){
252 254
 				$this->logger->debug(sprintf('Writing %s bytes to file %s starting position %s using POST blob', strlen($_POST['blob']), $target_file, $_POST['start']));
253 255
 				
254 256
 				$blob = $_POST['blob'];
255 257
 
256
-				if(!$bytes_written = fwrite($fp, $blob))
257
-					throw new Exception("Unable to write data to file $target_file");
258
-			}else{
258
+				if(!$bytes_written = fwrite($fp, $blob)) {
259
+									throw new Exception("Unable to write data to file $target_file");
260
+				}
261
+			} else{
259 262
 				throw new Exception("Upload failed, did not receive any binary data");
260 263
 			}
261 264
 			
@@ -289,10 +292,11 @@  discard block
 block discarded – undo
289 292
 		
290 293
 		$mysqli->query("SET sql_mode='';");
291 294
 		$mysqli->query("SET foreign_key_checks = 0;");
292
-		if(isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file'])
293
-			$mysqli->query("SET NAMES ".$_REQUEST['charset_of_file']."");
294
-		else
295
-			$mysqli->query("SET NAMES utf8;");
295
+		if(isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file']) {
296
+					$mysqli->query("SET NAMES ".$_REQUEST['charset_of_file']."");
297
+		} else {
298
+					$mysqli->query("SET NAMES utf8;");
299
+		}
296 300
 			
297 301
 		return $mysqli;	
298 302
 	}
@@ -322,8 +326,9 @@  discard block
 block discarded – undo
322 326
 		
323 327
 		$mysql_backup_file = $remote_path.DS.$mysqldump_file;
324 328
 		
325
-		if(!file_exists($mysql_backup_file))
326
-			throw new Exception(sprintf("Mysql backup file %s does not exists",$mysql_backup_file));
329
+		if(!file_exists($mysql_backup_file)) {
330
+					throw new Exception(sprintf("Mysql backup file %s does not exists",$mysql_backup_file));
331
+		}
327 332
 		
328 333
 		
329 334
 		/*if(defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS)
@@ -355,16 +360,18 @@  discard block
 block discarded – undo
355 360
 			// process the line read.
356 361
 									
357 362
 				//check if line is comment
358
-				if(substr($line, 0, 1) == "#")
359
-					continue;
363
+				if(substr($line, 0, 1) == "#") {
364
+									continue;
365
+				}
360 366
 				
361 367
 				//check if line is empty	
362
-				if($line == "\n" or trim($line) == "")
363
-					continue;
368
+				if($line == "\n" or trim($line) == "") {
369
+									continue;
370
+				}
364 371
 					
365
-				if(substr($line, strlen($line)-2, strlen($line)) == ";\n")
366
-					$query .= $line;
367
-				else{
372
+				if(substr($line, strlen($line)-2, strlen($line)) == ";\n") {
373
+									$query .= $line;
374
+				} else{
368 375
 					$query .= $line;
369 376
 					continue;
370 377
 				}
@@ -423,7 +430,7 @@  discard block
 block discarded – undo
423 430
 		if(!feof($fp))
424 431
 		{
425 432
 			$return['finished'] = 0;
426
-		}else{
433
+		} else{
427 434
 			$this->logger->info(sprintf("Mysql Import Done."));
428 435
 		}
429 436
 		
@@ -488,7 +495,7 @@  discard block
 block discarded – undo
488 495
 			$tar->open($this->backup_storage_dir.DS.$backup_file, $start);
489 496
 		
490 497
 			$data = $tar->contents($this->process_files_limit_list);
491
-		}catch(Exception $e)
498
+		} catch(Exception $e)
492 499
 		{
493 500
 			$return['error'] = true;
494 501
 			$return['message'] = $e->getMessage();
@@ -516,15 +523,16 @@  discard block
 block discarded – undo
516 523
 		{
517 524
 			$return['start'] = $data['start'];
518 525
 			$return['finished'] = 0;	
519
-		}else{
526
+		} else{
520 527
 			if($this->is_multipart($source_backup_file))
521 528
 			{
522 529
 				$return['start'] = 0;
523 530
 				
524 531
 				++$return['part'];
525 532
 			
526
-				if($return['part'] < sizeof($backup_parts))	
527
-					$return['finished'] = 0;
533
+				if($return['part'] < sizeof($backup_parts)) {
534
+									$return['finished'] = 0;
535
+				}
528 536
 				
529 537
 			}
530 538
 		}	
@@ -665,19 +673,22 @@  discard block
 block discarded – undo
665 673
 		{
666 674
 			$config = file_get_contents($wp_config);
667 675
 			preg_match("/.*table_prefix.*=.*'(.*)'/i", $config, $matches);
668
-			if(isset($matches[1]))
669
-				$table_prefix = $matches[1];
670
-			else
671
-				throw new Exception("Could not load wordpress table prefix from wp-config.php file.");
676
+			if(isset($matches[1])) {
677
+							$table_prefix = $matches[1];
678
+			} else {
679
+							throw new Exception("Could not load wordpress table prefix from wp-config.php file.");
680
+			}
681
+		} else {
682
+					throw new Exception("Could not update the SITEURL and HOME, wp-config.php file not found");
672 683
 		}
673
-		else
674
-			throw new Exception("Could not update the SITEURL and HOME, wp-config.php file not found");
675 684
 			
676
-		if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='home'"))
677
-			throw new Exception(sprintf("Could not update the HOME option, error: %s\n", $mysqli->error));
685
+		if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='home'")) {
686
+					throw new Exception(sprintf("Could not update the HOME option, error: %s\n", $mysqli->error));
687
+		}
678 688
 		
679
-		if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='siteurl'"))
680
-			throw new Exception(sprintf("Could not update the SITEURL option, error: %s\n", $mysqli->error));
689
+		if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='siteurl'")) {
690
+					throw new Exception(sprintf("Could not update the SITEURL option, error: %s\n", $mysqli->error));
691
+		}
681 692
 		
682 693
 		return true;
683 694
 	}
@@ -715,8 +726,9 @@  discard block
 block discarded – undo
715 726
 		
716 727
 		$this->logger->info(sprintf('Updating wp-config.php file with the new mysql details'));
717 728
 		
718
-		if(!file_put_contents($wp_config, $content))
719
-			throw new Exception("Could not write updated config data to ".$wp_config);
729
+		if(!file_put_contents($wp_config, $content)) {
730
+					throw new Exception("Could not write updated config data to ".$wp_config);
731
+		}
720 732
 		
721 733
 		chmod($wp_config, $file_perms);
722 734
 		
@@ -761,10 +773,11 @@  discard block
 block discarded – undo
761 773
 							$mysqldump_list[$file['path']]['size'] = $file['size'];
762 774
 							$mysqldump_list[$file['path']]['timestamp'] = date("d M,Y H:i",$file['timestamp']);
763 775
 							
764
-							if($hash and $hash == $matches[1])
765
-								$mysqldump_list[$file['path']]['selected'] = "selected";
766
-							else
767
-								$mysqldump_list[$file['path']]['selected'] = "";	
776
+							if($hash and $hash == $matches[1]) {
777
+															$mysqldump_list[$file['path']]['selected'] = "selected";
778
+							} else {
779
+															$mysqldump_list[$file['path']]['selected'] = "";
780
+							}
768 781
 						}
769 782
 					}
770 783
 				}
@@ -785,13 +798,15 @@  discard block
 block discarded – undo
785 798
      */
786 799
 	private function get_hash_from_backup($backup_file)
787 800
 	{
788
-		if(!$backup_file)
789
-			return false;
801
+		if(!$backup_file) {
802
+					return false;
803
+		}
790 804
 			
791 805
 		$result = preg_match("/-(\w*)./", substr($backup_file, strlen($backup_file)-10, strlen($backup_file)), $matches)	;
792 806
 		
793
-		if($result and isset($matches[1]))
794
-			return ($matches[1]);
807
+		if($result and isset($matches[1])) {
808
+					return ($matches[1]);
809
+		}
795 810
 		
796 811
 		return false;
797 812
 	}
@@ -816,10 +831,11 @@  discard block
 block discarded – undo
816 831
 			if(isset($file_info['extension']) and $file_info['extension'] == "csv")
817 832
 			{
818 833
 				$lines = explode(PHP_EOL, $this->filesystem->read($file_info['path']));
819
-				foreach($lines as $line)
820
-					if($line)
834
+				foreach($lines as $line) {
835
+									if($line)
821 836
 					{
822 837
 						$data = str_getcsv($line);
838
+				}
823 839
 						if(is_array($data)){
824 840
 							$parents[$data[0]] = $file_info['path'];
825 841
 							$file_info['childs'][] = $data;
@@ -829,20 +845,22 @@  discard block
 block discarded – undo
829 845
 						
830 846
 			}
831 847
 			
832
-			if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions))
833
-				$backup_files[$file_info['path']] = $file_info;
848
+			if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) {
849
+							$backup_files[$file_info['path']] = $file_info;
850
+			}
834 851
 		}
835 852
 		
836 853
 		$new_list = array();
837 854
 		
838 855
 		foreach($backup_files as $key=>$file_info)
839 856
 		{
840
-			if(isset($parents[$file_info['path']]))
841
-				$backup_files[$key]['parent'] = $parents[$file_info['path']];
842
-			else{
857
+			if(isset($parents[$file_info['path']])) {
858
+							$backup_files[$key]['parent'] = $parents[$file_info['path']];
859
+			} else{
843 860
 				
844
-				if($local_backup_file and ($file_info['basename'] == $local_backup_file))
845
-					$file_info['selected'] = 'selected';
861
+				if($local_backup_file and ($file_info['basename'] == $local_backup_file)) {
862
+									$file_info['selected'] = 'selected';
863
+				}
846 864
 				
847 865
 				$this->logger->info(sprintf('Found %s backup file', $file_info['path']));
848 866
 					
@@ -889,8 +907,9 @@  discard block
 block discarded – undo
889 907
 		$backup_archive = new Tar();
890 908
 		if($this->is_multipart($backup_file))
891 909
 		{
892
-			if(!$return['part'])
893
-				$return['processed'] += $this->filesystem->getSize($backup_file);
910
+			if(!$return['part']) {
911
+							$return['processed'] += $this->filesystem->getSize($backup_file);
912
+			}
894 913
 				
895 914
 			$backup_parts = $this->get_multipart_files($backup_file);
896 915
 			$backup_file = $backup_parts[$return['part']];	
@@ -910,12 +929,13 @@  discard block
 block discarded – undo
910 929
 			}
911 930
 		}
912 931
 		
913
-		if(isset($data['start']))
914
-		//if(isset($data['start']) and $data['start'] <= $this->filesystem->getSize($backup_file))
932
+		if(isset($data['start'])) {
933
+				//if(isset($data['start']) and $data['start'] <= $this->filesystem->getSize($backup_file))
915 934
 		{
916 935
 			$return['finished'] = 0;
936
+		}
917 937
 			$return['start'] = $data['start'];
918
-		}else{
938
+		} else{
919 939
 			
920 940
 			$return['processed'] += $start;
921 941
 			
@@ -925,14 +945,16 @@  discard block
 block discarded – undo
925 945
 				
926 946
 				++$return['part'];
927 947
 			
928
-				if($return['part'] < sizeof($backup_parts))	
929
-					$return['finished'] = 0;
948
+				if($return['part'] < sizeof($backup_parts)) {
949
+									$return['finished'] = 0;
950
+				}
930 951
 				
931 952
 			}
932 953
 		}
933 954
 		
934
-		if($return['finished'])
935
-			$this->logger->info(sprintf('Done extracting %s', $source_backup_file));
955
+		if($return['finished']) {
956
+					$this->logger->info(sprintf('Done extracting %s', $source_backup_file));
957
+		}
936 958
 		
937 959
 		$return['backup_file'] = $backup_file;
938 960
 		
@@ -964,8 +986,7 @@  discard block
 block discarded – undo
964 986
 			$return['remote_mysql_user'] 	= $wpdb->dbuser;
965 987
 			$return['remote_mysql_pass'] 	= $wpdb->dbpassword;
966 988
 			$return['remote_mysql_db'] 		= $wpdb->dbname;
967
-		}
968
-		else{
989
+		} else{
969 990
 			$return['dir'] = ($pathinfo['dirname']).DS.$suffix;
970 991
 			$return['restore_script_url'] = str_replace($pathinfo['basename'], "", $restore_script_url).$suffix;
971 992
 		}	
@@ -984,11 +1005,13 @@  discard block
 block discarded – undo
984 1005
 	{
985 1006
 		//check if i can write
986 1007
 		$tmp_file = md5(time());
987
-		if(!file_put_contents($tmp_file, "++"))
988
-			throw new Exception("Could not write to new host");
1008
+		if(!file_put_contents($tmp_file, "++")) {
1009
+					throw new Exception("Could not write to new host");
1010
+		}
989 1011
 		
990
-		if(!unlink($tmp_file))
991
-			throw new Exception("Could not delete temporary file from new host");
1012
+		if(!unlink($tmp_file)) {
1013
+					throw new Exception("Could not delete temporary file from new host");
1014
+		}
992 1015
 		
993 1016
 		$max_upload      = $this->return_bytes((ini_get('upload_max_filesize')));
994 1017
 		$max_post        = $this->return_bytes((ini_get('post_max_size')));
@@ -1032,8 +1055,9 @@  discard block
 block discarded – undo
1032 1055
      */
1033 1056
 	public function is_multipart($backup_name)
1034 1057
 	{
1035
-		if(stristr($backup_name, "-multipart"))
1036
-			return true;
1058
+		if(stristr($backup_name, "-multipart")) {
1059
+					return true;
1060
+		}
1037 1061
 		
1038 1062
 		return false;	
1039 1063
 	}
@@ -1051,8 +1075,9 @@  discard block
 block discarded – undo
1051 1075
 		if($this->is_multipart($backup_name))
1052 1076
 		{
1053 1077
 			$backup_parts = $this->get_multipart_files($backup_name);
1054
-			foreach($backup_parts as $part_file)
1055
-				$backup_size += $this->filesystem->getSize($part_file);
1078
+			foreach($backup_parts as $part_file) {
1079
+							$backup_size += $this->filesystem->getSize($part_file);
1080
+			}
1056 1081
 		}
1057 1082
 		
1058 1083
 		return $backup_size;
@@ -1110,15 +1135,13 @@  discard block
 block discarded – undo
1110 1135
                 if($direction == 'desc') {
1111 1136
                     if($a > $b) {
1112 1137
                         return -1;
1113
-                    }
1114
-                    else{
1138
+                    } else{
1115 1139
                         return 1;
1116 1140
                     }
1117
-                }else {
1141
+                } else {
1118 1142
                     if($a < $b) {
1119 1143
                         return -1;
1120
-                    }
1121
-                    else{
1144
+                    } else{
1122 1145
                         return 1;
1123 1146
                     }
1124 1147
                 }
@@ -1148,7 +1171,7 @@  discard block
 block discarded – undo
1148 1171
 		{
1149 1172
 			$return['statusText'] = $response['message'];
1150 1173
 			$return['error'] = true;
1151
-		}elseif($status != 200 and $status != 418)
1174
+		} elseif($status != 200 and $status != 418)
1152 1175
 		{
1153 1176
 			$return['error'] = true;
1154 1177
 			$return['message'] = $response;
@@ -1172,8 +1195,9 @@  discard block
 block discarded – undo
1172 1195
 		return preg_replace_callback('!s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!', function ($m) {
1173 1196
 				  $data = "";
1174 1197
 				  	
1175
-				  if(!isset($m[3]))
1176
-					$m[3] = "";
1198
+				  if(!isset($m[3])) {
1199
+				  					$m[3] = "";
1200
+				  }
1177 1201
 					
1178 1202
 					$data = 's:'.strlen(($m[3])).':\"'.($m[3]).'\";';
1179 1203
 	              //return $this->unescape_quotes($data);
@@ -1219,7 +1243,7 @@  discard block
 block discarded – undo
1219 1243
 		    stristr($s, ':' ) != false
1220 1244
 		    ){
1221 1245
 		    return true;
1222
-		}else{
1246
+		} else{
1223 1247
 		    return false;
1224 1248
 		}
1225 1249
 
Please login to merge, or discard this patch.
admin/partials/xcloner_init_page.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
 
21 21
 $logger_content = $logger->getLastDebugLines();
22 22
 
23
-$date_format = get_option( 'date_format' );
24
-$time_format = get_option( 'time_format' );
23
+$date_format = get_option('date_format');
24
+$time_format = get_option('time_format');
25 25
 
26 26
 //$xcloner_file_system->cleanup_tmp_directories();
27 27
 
28
-if ( $requirements->check_backup_ready_status() ) {
28
+if ($requirements->check_backup_ready_status()) {
29 29
 	$latest_backup = $xcloner_file_system->get_latest_backup();
30 30
 	$xcloner_file_system->backup_storage_cleanup();
31 31
 }
@@ -34,15 +34,15 @@  discard block
 block discarded – undo
34 34
 <div class="row">
35 35
     <div class="col s12">
36 36
         <h5 class="left-align">
37
-			<?php echo __( 'Backup Dashboard', 'xcloner-backup-and-restore' ) ?>
37
+			<?php echo __('Backup Dashboard', 'xcloner-backup-and-restore') ?>
38 38
         </h5>
39 39
     </div>
40 40
 </div>
41 41
 
42
-<?php if ( isset( $latest_backup['timestamp'] ) and $latest_backup['timestamp'] < strtotime( "-1 day" ) ): ?>
42
+<?php if (isset($latest_backup['timestamp']) and $latest_backup['timestamp'] < strtotime("-1 day")): ?>
43 43
     <div id="setting-error-" class="error settings-error notice is-dismissible">
44 44
         <p><strong>
45
-				<?php echo __( 'Your latest backup is older than 24 hours, please create a new backup to keep your site protected.', 'xcloner-backup-and-restore' ) ?>
45
+				<?php echo __('Your latest backup is older than 24 hours, please create a new backup to keep your site protected.', 'xcloner-backup-and-restore') ?>
46 46
             </strong>
47 47
         </p>
48 48
         <button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span>
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
     </div>
51 51
 <?php endif ?>
52 52
 
53
-<?php if ( ! isset( $latest_backup['timestamp'] ) ): ?>
53
+<?php if (!isset($latest_backup['timestamp'])): ?>
54 54
     <div id="setting-error-" class="error settings-error notice is-dismissible">
55 55
         <p><strong>
56
-				<?php echo __( 'You have no backup that I could find, please generate a new backup to keep your site protected.', 'xcloner-backup-and-restore' ) ?>
56
+				<?php echo __('You have no backup that I could find, please generate a new backup to keep your site protected.', 'xcloner-backup-and-restore') ?>
57 57
             </strong>
58 58
         </p>
59 59
         <button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span>
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
     </div>
62 62
 <?php endif ?>
63 63
 
64
-<?php if ( ! $requirements->check_backup_ready_status() ): ?>
64
+<?php if (!$requirements->check_backup_ready_status()): ?>
65 65
     <div id="setting-error-" class="error settings-error notice is-dismissible">
66 66
         <p><strong>
67
-				<?php echo __( 'Backup system not ready, please check and fix the issues marked in red', 'xcloner-backup-and-restore' ) ?>
67
+				<?php echo __('Backup system not ready, please check and fix the issues marked in red', 'xcloner-backup-and-restore') ?>
68 68
             </strong>
69 69
         </p>
70 70
         <button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span>
@@ -87,74 +87,74 @@  discard block
 block discarded – undo
87 87
                     <div class="collapsible-body">
88 88
                         <div class="" id="backup-status">
89 89
                             <div class="row">
90
-                                <h5><?php echo __( "Latest Backup", 'xcloner-backup-and-restore' ) ?></h5>
90
+                                <h5><?php echo __("Latest Backup", 'xcloner-backup-and-restore') ?></h5>
91 91
                                 <blockquote>
92
-									<?php if ( isset($latest_backup) ): ?>
92
+									<?php if (isset($latest_backup)): ?>
93 93
                                         <div class="item">
94
-                                            <div class="title"><?php echo __( "Backup Name", 'xcloner-backup-and-restore' ) ?>
94
+                                            <div class="title"><?php echo __("Backup Name", 'xcloner-backup-and-restore') ?>
95 95
                                                 :
96 96
                                             </div>
97 97
 											<?php echo $latest_backup['basename'] ?>
98 98
                                         </div>
99 99
                                         <div class="item">
100 100
                                             <div class="title">
101
-												<?php echo __( "Backup Size", 'xcloner-backup-and-restore' ) ?>:
101
+												<?php echo __("Backup Size", 'xcloner-backup-and-restore') ?>:
102 102
                                             </div>
103
-											<?php echo size_format( $latest_backup['size'] ) ?>
103
+											<?php echo size_format($latest_backup['size']) ?>
104 104
                                         </div>
105 105
                                         <div class="item">
106
-                                            <div class="title"><?php echo __( "Backup Date", 'xcloner-backup-and-restore' ) ?>
106
+                                            <div class="title"><?php echo __("Backup Date", 'xcloner-backup-and-restore') ?>
107 107
                                                 :
108 108
                                             </div>
109 109
 											<?php
110
-											echo date( $date_format . " " . $time_format, $latest_backup['timestamp'] + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) )
110
+											echo date($date_format." ".$time_format, $latest_backup['timestamp'] + (get_option('gmt_offset') * HOUR_IN_SECONDS))
111 111
 											?>
112 112
                                         </div>
113 113
 									<?php else: ?>
114 114
                                         <div class="item">
115
-                                            <div class="title"><?php echo __( "No Backup Yet", 'xcloner-backup-and-restore' ) ?></div>
115
+                                            <div class="title"><?php echo __("No Backup Yet", 'xcloner-backup-and-restore') ?></div>
116 116
                                         </div>
117 117
 									<?php endif ?>
118 118
                                 </blockquote>
119 119
                                 <div>
120
-                                    <h5><?php echo __( "Backup Storage Usage", 'xcloner-backup-and-restore' ) ?></h5>
120
+                                    <h5><?php echo __("Backup Storage Usage", 'xcloner-backup-and-restore') ?></h5>
121 121
                                     <blockquote>
122 122
                                         <div class="item">
123
-                                            <div class="title"><?php echo __( "Total Size", 'xcloner-backup-and-restore' ) ?>
123
+                                            <div class="title"><?php echo __("Total Size", 'xcloner-backup-and-restore') ?>
124 124
                                                 :
125 125
                                             </div>
126
-											<?php echo size_format( $xcloner_file_system->get_storage_usage() ); ?>
126
+											<?php echo size_format($xcloner_file_system->get_storage_usage()); ?>
127 127
                                         </div>
128 128
                                     </blockquote>
129
-                                    <h5><?php echo __( "Next Scheduled Backup", 'xcloner-backup-and-restore' ) ?></h5>
129
+                                    <h5><?php echo __("Next Scheduled Backup", 'xcloner-backup-and-restore') ?></h5>
130 130
                                     <blockquote>
131 131
                                         <div class="item">
132 132
 											<?php
133
-											$list = ( $xcloner_scheduler->get_next_run_schedule() );
133
+											$list = ($xcloner_scheduler->get_next_run_schedule());
134 134
 
135
-											if ( is_array( $list ) ) {
136
-												$xcloner_file_system->sort_by( $list, "next_run_time", "asc" );
135
+											if (is_array($list)) {
136
+												$xcloner_file_system->sort_by($list, "next_run_time", "asc");
137 137
 											}
138 138
 
139
-											if ( isset( $list[0] ) ) {
139
+											if (isset($list[0])) {
140 140
 												$latest_schedule = $list[0];
141 141
 											}
142 142
 											?>
143
-											<?php if ( isset( $latest_schedule->name ) ): ?>
144
-                                                <div class="title"><?php echo __( "Schedule Name", 'xcloner-backup-and-restore' ) ?>
143
+											<?php if (isset($latest_schedule->name)): ?>
144
+                                                <div class="title"><?php echo __("Schedule Name", 'xcloner-backup-and-restore') ?>
145 145
                                                     :
146 146
                                                 </div>
147 147
 												<?php echo $latest_schedule->name; ?>
148 148
 											<?php endif; ?>
149 149
                                         </div>
150 150
                                         <div class="item">
151
-                                            <div class="title"><?php echo __( "Next Call", 'xcloner-backup-and-restore' ) ?>
151
+                                            <div class="title"><?php echo __("Next Call", 'xcloner-backup-and-restore') ?>
152 152
                                                 :
153 153
                                             </div>
154
-											<?php if ( isset( $latest_schedule->next_run_time ) ) {
155
-												echo date( $date_format . " " . $time_format, $latest_schedule->next_run_time );
154
+											<?php if (isset($latest_schedule->next_run_time)) {
155
+												echo date($date_format." ".$time_format, $latest_schedule->next_run_time);
156 156
 											} else {
157
-												echo __( "Unscheduled", 'xcloner-backup-and-restore' );
157
+												echo __("Unscheduled", 'xcloner-backup-and-restore');
158 158
 											}
159 159
 											?>
160 160
                                         </div>
@@ -163,20 +163,20 @@  discard block
 block discarded – undo
163 163
                             </div>
164 164
                 </li>
165 165
 
166
-				<?php if ( $xcloner_settings->get_xcloner_option( 'xcloner_enable_log' ) ) : ?>
166
+				<?php if ($xcloner_settings->get_xcloner_option('xcloner_enable_log')) : ?>
167 167
                     <li class="active">
168 168
                         <div class="collapsible-header active">
169
-                            <i class="material-icons">bug_report</i><?php echo __( 'XCloner Debugger', 'xcloner-backup-and-restore' ) ?>
169
+                            <i class="material-icons">bug_report</i><?php echo __('XCloner Debugger', 'xcloner-backup-and-restore') ?>
170 170
                             <div class="right">
171
-                                <a href="#<?php echo $logger_basename = basename( $logger->get_main_logger_url() ) ?>"
171
+                                <a href="#<?php echo $logger_basename = basename($logger->get_main_logger_url()) ?>"
172 172
                                    class="download-logger" title="<?php echo $logger_basename ?>">
173 173
                                     <span class="shorten_string"><?php echo $logger_basename ?>&nbsp;&nbsp;&nbsp;</span>
174 174
                                 </a>
175 175
                             </div>
176 176
                         </div>
177 177
                         <div class="collapsible-body">
178
-                            <div class="console" id="xcloner-console"><?php if ( $logger_content ) {
179
-									echo implode( "<br />\n", array_reverse( $logger_content ) );
178
+                            <div class="console" id="xcloner-console"><?php if ($logger_content) {
179
+									echo implode("<br />\n", array_reverse($logger_content));
180 180
 								} ?></div>
181 181
                         </div>
182 182
                     </li>
@@ -201,71 +201,71 @@  discard block
 block discarded – undo
201 201
 
202 202
         <div class="card blue-grey darken-1 z-depth-4 backup-ready">
203 203
             <div class="card-content white-text">
204
-                <span class="card-title"><?php echo __( "System Check", 'xcloner-backup-and-restore' ) ?></span>
204
+                <span class="card-title"><?php echo __("System Check", 'xcloner-backup-and-restore') ?></span>
205 205
                 <ul>
206
-                    <li class="card-panel <?php echo( $requirements->check_xcloner_start_path( 1 ) ? "teal" : "red" ) ?> lighten-2">
207
-						<?php echo __( 'Backup Start Location', 'xcloner-backup-and-restore' ) ?>: <span
206
+                    <li class="card-panel <?php echo($requirements->check_xcloner_start_path(1) ? "teal" : "red") ?> lighten-2">
207
+						<?php echo __('Backup Start Location', 'xcloner-backup-and-restore') ?>: <span
208 208
                                 class="shorten_string "><?php echo $requirements->check_xcloner_start_path(); ?></span>
209 209
                     </li>
210
-                    <li class="card-panel <?php echo( $requirements->check_xcloner_store_path( 1 ) ? "teal" : "red" ) ?> lighten-2">
211
-						<?php echo __( 'Backup Storage Location', 'xcloner-backup-and-restore' ) ?>: <span
210
+                    <li class="card-panel <?php echo($requirements->check_xcloner_store_path(1) ? "teal" : "red") ?> lighten-2">
211
+						<?php echo __('Backup Storage Location', 'xcloner-backup-and-restore') ?>: <span
212 212
                                 class="shorten_string"><?php echo $requirements->check_xcloner_store_path(); ?></span>
213 213
                     </li>
214
-                    <li class="card-panel <?php echo( $requirements->check_xcloner_tmp_path( 1 ) ? "teal" : "red" ) ?> lighten-2">
215
-						<?php echo __( 'Temporary Location', 'xcloner-backup-and-restore' ) ?>: <span
214
+                    <li class="card-panel <?php echo($requirements->check_xcloner_tmp_path(1) ? "teal" : "red") ?> lighten-2">
215
+						<?php echo __('Temporary Location', 'xcloner-backup-and-restore') ?>: <span
216 216
                                 class="shorten_string"><?php echo $requirements->check_xcloner_tmp_path(); ?></span>
217 217
                     </li>
218 218
 
219
-                    <li class="card-panel <?php echo( $requirements->check_min_php_version( 1 ) ? "teal" : "red" ) ?> lighten-2">
220
-						<?php echo __( 'PHP Version Check', 'xcloner-backup-and-restore' ) ?>
219
+                    <li class="card-panel <?php echo($requirements->check_min_php_version(1) ? "teal" : "red") ?> lighten-2">
220
+						<?php echo __('PHP Version Check', 'xcloner-backup-and-restore') ?>
221 221
                         : <?php echo $requirements->check_min_php_version(); ?>
222
-                        ( >= <?php echo $requirements->get_constant( 'min_php_version' ) ?>)
222
+                        ( >= <?php echo $requirements->get_constant('min_php_version') ?>)
223 223
                     </li>
224
-                    <li class="card-panel <?php echo( $requirements->check_safe_mode( 1 ) ? "teal" : "orange" ) ?> lighten-2">
225
-						<?php echo __( 'PHP Safe Mode', 'xcloner-backup-and-restore' ) ?>
224
+                    <li class="card-panel <?php echo($requirements->check_safe_mode(1) ? "teal" : "orange") ?> lighten-2">
225
+						<?php echo __('PHP Safe Mode', 'xcloner-backup-and-restore') ?>
226 226
                         : <?php echo $requirements->check_safe_mode(); ?>
227
-                        ( <?php echo $requirements->get_constant( 'safe_mode' ) ?>)
227
+                        ( <?php echo $requirements->get_constant('safe_mode') ?>)
228 228
                     </li>
229
-                    <li class="card-panel <?php echo( $requirements->check_backup_ready_status() ? "teal" : "red" ) ?> lighten-2">
230
-						<?php echo( $requirements->check_backup_ready_status() ? __( 'BACKUP READY', 'xcloner-backup-and-restore' ) : __( 'Backup not ready, please check above requirements', 'xcloner-backup-and-restore' ) ) ?>
231
-                        <i class="material-icons right tiny"><?php echo( $requirements->check_backup_ready_status() ? 'thumb_up' : 'thumb_down' ) ?></i>
229
+                    <li class="card-panel <?php echo($requirements->check_backup_ready_status() ? "teal" : "red") ?> lighten-2">
230
+						<?php echo($requirements->check_backup_ready_status() ? __('BACKUP READY', 'xcloner-backup-and-restore') : __('Backup not ready, please check above requirements', 'xcloner-backup-and-restore')) ?>
231
+                        <i class="material-icons right tiny"><?php echo($requirements->check_backup_ready_status() ? 'thumb_up' : 'thumb_down') ?></i>
232 232
                     </li>
233 233
                 </ul>
234 234
                 <ul class="additional_system_info">
235 235
                     <li class="card-panel grey darken-1">
236
-						<?php echo __( 'PHP max_execution_time', 'xcloner-backup-and-restore' ) ?>
236
+						<?php echo __('PHP max_execution_time', 'xcloner-backup-and-restore') ?>
237 237
                         : <?php echo $requirements->get_max_execution_time(); ?>
238 238
                     </li>
239 239
                     <li class="card-panel grey darken-1">
240
-						<?php echo __( 'PHP memory_limit', 'xcloner-backup-and-restore' ) ?>
240
+						<?php echo __('PHP memory_limit', 'xcloner-backup-and-restore') ?>
241 241
                         : <?php echo $requirements->get_memory_limit(); ?>
242 242
                     </li>
243 243
                     <li class="card-panel grey darken-1">
244
-						<?php echo __( 'PHP open_basedir', 'xcloner-backup-and-restore' ) ?>
244
+						<?php echo __('PHP open_basedir', 'xcloner-backup-and-restore') ?>
245 245
                         : <?php echo $requirements->get_open_basedir(); ?>
246 246
                     </li>
247 247
 					<?php
248 248
 					$data = array();
249
-					if ( $requirements->check_backup_ready_status() ) {
249
+					if ($requirements->check_backup_ready_status()) {
250 250
 						$data = $xcloner_file_system->estimate_read_write_time();
251 251
 					}
252 252
 					?>
253 253
                     <li class="card-panel grey darken-1">
254
-						<?php echo __( 'Reading Time 1MB Block', 'xcloner-backup-and-restore' ) ?>
255
-                        : <?php echo( isset( $data['reading_time'] ) ? $data['reading_time'] : __( "unknown" ) ); ?>
254
+						<?php echo __('Reading Time 1MB Block', 'xcloner-backup-and-restore') ?>
255
+                        : <?php echo(isset($data['reading_time']) ? $data['reading_time'] : __("unknown")); ?>
256 256
                     </li>
257 257
                     <li class="card-panel grey darken-1">
258
-						<?php echo __( 'Writing Time 1MB Block', 'xcloner-backup-and-restore' ) ?>
259
-                        : <?php echo( isset( $data['writing_time'] ) ? $data['writing_time'] : __( "unknown" ) ); ?>
258
+						<?php echo __('Writing Time 1MB Block', 'xcloner-backup-and-restore') ?>
259
+                        : <?php echo(isset($data['writing_time']) ? $data['writing_time'] : __("unknown")); ?>
260 260
                     </li>
261 261
                     <li class="card-panel grey darken-1">
262
-						<?php echo __( 'Free Disk Space', 'xcloner-backup-and-restore' ) ?>
263
-                        : <?php echo $requirements->get_free_disk_space();; ?>
262
+						<?php echo __('Free Disk Space', 'xcloner-backup-and-restore') ?>
263
+                        : <?php echo $requirements->get_free_disk_space(); ; ?>
264 264
                     </li>
265 265
                 </ul>
266 266
             </div>
267 267
             <div class="card-action">
268
-                <a class="waves-effect waves-light btn system_info_toggle blue darken-1"><i class="material-icons left">list</i><?php echo __( 'Toggle Additional System Info', 'xcloner-backup-and-restore' ) ?>
268
+                <a class="waves-effect waves-light btn system_info_toggle blue darken-1"><i class="material-icons left">list</i><?php echo __('Toggle Additional System Info', 'xcloner-backup-and-restore') ?>
269 269
                 </a>
270 270
             </div>
271 271
         </div>
Please login to merge, or discard this patch.
admin/partials/xcloner_scheduled_backups_page.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -4,10 +4,10 @@  discard block
 block discarded – undo
4 4
 $xcloner_remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage();
5 5
 $available_storages     = $xcloner_remote_storage->get_available_storages();
6 6
 ?>
7
-<?php if ( ! defined( "DISABLE_WP_CRON" ) || ! DISABLE_WP_CRON ): ?>
7
+<?php if (!defined("DISABLE_WP_CRON") || !DISABLE_WP_CRON): ?>
8 8
     <div id="setting-error-" class="error settings-error notice is-dismissible">
9 9
         <p><strong>
10
-				<?php echo sprintf( __( 'We have noticed that DISABLE_WP_CRON is disabled, we recommend enabling that and setting up wp-cron.php to run manually through your hosting account scheduler as explained <a href="%s" target="_blank">here</a>', 'xcloner-backup-and-restore' ), "http://www.inmotionhosting.com/support/website/wordpress/disabling-the-wp-cronphp-in-wordpress" ) ?>
10
+				<?php echo sprintf(__('We have noticed that DISABLE_WP_CRON is disabled, we recommend enabling that and setting up wp-cron.php to run manually through your hosting account scheduler as explained <a href="%s" target="_blank">here</a>', 'xcloner-backup-and-restore'), "http://www.inmotionhosting.com/support/website/wordpress/disabling-the-wp-cronphp-in-wordpress") ?>
11 11
             </strong>
12 12
         </p>
13 13
         <button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span>
@@ -15,32 +15,32 @@  discard block
 block discarded – undo
15 15
     </div>
16 16
 <?php endif ?>
17 17
 
18
-<h1><?= esc_html( get_admin_page_title() ); ?></h1>
18
+<h1><?= esc_html(get_admin_page_title()); ?></h1>
19 19
 
20 20
 <div class="row">
21 21
     <table id="scheduled_backups" class="col s12" cellspacing="0" width="100%">
22 22
         <thead>
23 23
         <tr class="grey lighten-2">
24
-            <th><?php echo __( 'ID', 'xcloner-backup-and-restore' ) ?></th>
25
-            <th><?php echo __( 'Schedule Name', 'xcloner-backup-and-restore' ) ?></th>
26
-            <th><?php echo __( 'Recurrence', 'xcloner-backup-and-restore' ) ?></th>
27
-            <th class="hide-on-med-and-down"><?php echo __( 'Next Execution', 'xcloner-backup-and-restore' ) ?></th>
28
-            <th><?php echo __( 'Remote Storage', 'xcloner-backup-and-restore' ) ?></th>
29
-            <th class="hide-on-med-and-down"><?php echo __( 'Last Backup', 'xcloner-backup-and-restore' ) ?></th>
30
-            <th><?php echo __( 'Status', 'xcloner-backup-and-restore' ) ?></th>
31
-            <th class="no-sort"><?php echo __( 'Action', 'xcloner-backup-and-restore' ) ?></th>
24
+            <th><?php echo __('ID', 'xcloner-backup-and-restore') ?></th>
25
+            <th><?php echo __('Schedule Name', 'xcloner-backup-and-restore') ?></th>
26
+            <th><?php echo __('Recurrence', 'xcloner-backup-and-restore') ?></th>
27
+            <th class="hide-on-med-and-down"><?php echo __('Next Execution', 'xcloner-backup-and-restore') ?></th>
28
+            <th><?php echo __('Remote Storage', 'xcloner-backup-and-restore') ?></th>
29
+            <th class="hide-on-med-and-down"><?php echo __('Last Backup', 'xcloner-backup-and-restore') ?></th>
30
+            <th><?php echo __('Status', 'xcloner-backup-and-restore') ?></th>
31
+            <th class="no-sort"><?php echo __('Action', 'xcloner-backup-and-restore') ?></th>
32 32
         </tr>
33 33
         </thead>
34 34
         <tfoot>
35 35
         <tr>
36
-            <th><?php echo __( 'ID', 'xcloner-backup-and-restore' ) ?></th>
37
-            <th><?php echo __( 'Schedule Name', 'xcloner-backup-and-restore' ) ?></th>
38
-            <th><?php echo __( 'Recurrence', 'xcloner-backup-and-restore' ) ?></th>
39
-            <th class="hide-on-med-and-down"><?php echo __( 'Next Execution', 'xcloner-backup-and-restore' ) ?></th>
40
-            <th><?php echo __( 'Remote Storage', 'xcloner-backup-and-restore' ) ?></th>
41
-            <th class="hide-on-med-and-down"><?php echo __( 'Last Backup', 'xcloner-backup-and-restore' ) ?></th>
42
-            <th><?php echo __( 'Status', 'xcloner-backup-and-restore' ) ?></th>
43
-            <th><?php echo __( 'Action', 'xcloner-backup-and-restore' ) ?></th>
36
+            <th><?php echo __('ID', 'xcloner-backup-and-restore') ?></th>
37
+            <th><?php echo __('Schedule Name', 'xcloner-backup-and-restore') ?></th>
38
+            <th><?php echo __('Recurrence', 'xcloner-backup-and-restore') ?></th>
39
+            <th class="hide-on-med-and-down"><?php echo __('Next Execution', 'xcloner-backup-and-restore') ?></th>
40
+            <th><?php echo __('Remote Storage', 'xcloner-backup-and-restore') ?></th>
41
+            <th class="hide-on-med-and-down"><?php echo __('Last Backup', 'xcloner-backup-and-restore') ?></th>
42
+            <th><?php echo __('Status', 'xcloner-backup-and-restore') ?></th>
43
+            <th><?php echo __('Action', 'xcloner-backup-and-restore') ?></th>
44 44
         </tr>
45 45
         </tfoot>
46 46
         <tbody>
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 
51 51
 <div class="row">
52 52
     <div class="col s12 m6 offset-m6 teal lighten-1" id="server_time">
53
-        <h2><?php echo __( 'Current Server Time', 'xcloner-backup-and-restore' ) ?>: <span
54
-                    class="right"><?php echo current_time( 'mysql' ); ?></span></h2>
53
+        <h2><?php echo __('Current Server Time', 'xcloner-backup-and-restore') ?>: <span
54
+                    class="right"><?php echo current_time('mysql'); ?></span></h2>
55 55
     </div>
56 56
 </div>
57 57
 
@@ -65,17 +65,17 @@  discard block
 block discarded – undo
65 65
 
66 66
             <div class="row">
67 67
                 <div class="col s12 m6">
68
-                    <h4><?php echo __( 'Edit Schedule', 'xcloner-backup-and-restore' ) ?> #<span
68
+                    <h4><?php echo __('Edit Schedule', 'xcloner-backup-and-restore') ?> #<span
69 69
                                 id="schedule_id"></span></h4>
70 70
                 </div>
71 71
 
72 72
                 <div class="col s12 m6 right-align">
73 73
                     <div class="switch">
74 74
                         <label>
75
-							<?php echo __( 'Off', 'xcloner-backup-and-restore' ) ?>
75
+							<?php echo __('Off', 'xcloner-backup-and-restore') ?>
76 76
                             <input type="checkbox" id="status" name="status" value="1">
77 77
                             <span class="lever"></span>
78
-							<?php echo __( 'On', 'xcloner-backup-and-restore' ) ?>
78
+							<?php echo __('On', 'xcloner-backup-and-restore') ?>
79 79
                         </label>
80 80
                     </div>
81 81
                 </div>
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
 
86 86
             <ul class="nav-tab-wrapper content row">
87 87
                 <li><a href="#scheduler_settings"
88
-                       class="nav-tab col s12 m6 nav-tab-active"><?php echo __( 'Scheduler Settings', 'xcloner-backup-and-restore' ) ?></a>
88
+                       class="nav-tab col s12 m6 nav-tab-active"><?php echo __('Scheduler Settings', 'xcloner-backup-and-restore') ?></a>
89 89
                 </li>
90 90
                 <li><a href="#advanced_scheduler_settings"
91
-                       class="nav-tab col s12 m6"><?php echo __( 'Advanced', 'xcloner-backup-and-restore' ) ?></a></li>
91
+                       class="nav-tab col s12 m6"><?php echo __('Advanced', 'xcloner-backup-and-restore') ?></a></li>
92 92
             </ul>
93 93
 
94 94
             <div class="nav-tab-wrapper-content">
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
                     <div class="row">
98 98
                         <div class="input-field col s12 l6">
99 99
                             <input placeholder="" name="schedule_name" id="schedule_name" type="text" required value="">
100
-                            <label for="schedule_name"><?php echo __( 'Schedule Name', 'xcloner-backup-and-restore' ) ?></label>
100
+                            <label for="schedule_name"><?php echo __('Schedule Name', 'xcloner-backup-and-restore') ?></label>
101 101
                         </div>
102 102
                         <div class="input-field col s12 l6">
103 103
                             <div class="switch">
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
                         </div>
113 113
                         <!--<div class="input-field inline col s12 l6">
114 114
 						<select id="backup_type" class="" name="backup_type" id="backup_type">
115
-							<option value=""><?php echo __( "Full Backup", "xcloner-backup-and-restore" ); ?></option>
116
-							<option value="diff"><?php echo __( "Differential Backups", "xcloner-backup-and-restore" ); ?></option>
117
-							<option value="full_diff"><?php echo __( "Full Backup + Differential Backups", "xcloner-backup-and-restore" ); ?></option>
115
+							<option value=""><?php echo __("Full Backup", "xcloner-backup-and-restore"); ?></option>
116
+							<option value="diff"><?php echo __("Differential Backups", "xcloner-backup-and-restore"); ?></option>
117
+							<option value="full_diff"><?php echo __("Full Backup + Differential Backups", "xcloner-backup-and-restore"); ?></option>
118 118
 						</select>
119
-						<label for="backup_type"><?php echo __( 'Scheduled Backup Type', 'xcloner-backup-and-restore' ) ?></label>
119
+						<label for="backup_type"><?php echo __('Scheduled Backup Type', 'xcloner-backup-and-restore') ?></label>
120 120
 					</div>-->
121 121
                     </div>
122 122
 
@@ -125,18 +125,18 @@  discard block
 block discarded – undo
125 125
                             <input placeholder="" name="schedule_start_date" id="schedule_start_date" type="datetime"
126 126
                                    value="">
127 127
                             <label for="schedule_start_date"
128
-                                   class="active"><?php echo __( 'Schedule Start At', 'xcloner-backup-and-restore' ) ?>
128
+                                   class="active"><?php echo __('Schedule Start At', 'xcloner-backup-and-restore') ?>
129 129
                                 :</label>
130 130
                         </div>
131 131
 
132 132
                         <div class="input-field col s12 l6">
133 133
                             <select name="schedule_frequency" id="schedule_frequency" class="validate" required>
134 134
                                 <option value="" disabled
135
-                                        selected><?php echo __( 'Schedule Recurrence', 'xcloner-backup-and-restore' ) ?></option>
135
+                                        selected><?php echo __('Schedule Recurrence', 'xcloner-backup-and-restore') ?></option>
136 136
 								<?php
137 137
 								$schedules = $xcloner_scheduler->get_available_intervals();
138 138
 
139
-								foreach ( $schedules as $key => $schedule ) {
139
+								foreach ($schedules as $key => $schedule) {
140 140
 									?>
141 141
                                     <option value="<?php echo $key ?>"><?php echo $schedule['display'] ?></option>
142 142
 									<?php
@@ -146,17 +146,17 @@  discard block
 block discarded – undo
146 146
                         </div>
147 147
                     </div>
148 148
 
149
-					<?php if ( sizeof( $available_storages ) ): ?>
149
+					<?php if (sizeof($available_storages)): ?>
150 150
                         <div class="row">
151 151
                             <div class="input-field col s12 l12">
152 152
                                 <select name="schedule_storage" id="schedule_storage" class="validate">
153 153
                                     <option value=""
154
-                                            selected><?php echo __( 'none', 'xcloner-backup-and-restore' ) ?></option>
155
-									<?php foreach ( $available_storages as $storage => $text ): ?>
154
+                                            selected><?php echo __('none', 'xcloner-backup-and-restore') ?></option>
155
+									<?php foreach ($available_storages as $storage => $text): ?>
156 156
                                         <option value="<?php echo $storage ?>"><?php echo $text ?></option>
157 157
 									<?php endforeach ?>
158 158
                                 </select>
159
-                                <label><?php echo __( 'Send To Remote Storage ', 'xcloner-backup-and-restore' ) ?></label>
159
+                                <label><?php echo __('Send To Remote Storage ', 'xcloner-backup-and-restore') ?></label>
160 160
                             </div>
161 161
                         </div>
162 162
 					<?php endif ?>
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
                         <div class="input-field col s12 l12">
166 166
                             <input placeholder="" name="email_notification" id="email_notification" type="text"
167 167
                                    value="">
168
-                            <label for="email_notification"><?php echo __( 'Email Notification Address', 'xcloner-backup-and-restore' ) ?></label>
168
+                            <label for="email_notification"><?php echo __('Email Notification Address', 'xcloner-backup-and-restore') ?></label>
169 169
                         </div>
170 170
                     </div>
171 171
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
                         <div class="input-field col s12 l12">
174 174
                             <input placeholder="" name="diff_start_date" id="diff_start_date" type="text"
175 175
                                    class="datepicker_max_today" value="">
176
-                            <label for="diff_start_date"><?php echo __( 'Backup Only Files Modified/Created After', 'xcloner-backup-and-restore' ) ?></label>
176
+                            <label for="diff_start_date"><?php echo __('Backup Only Files Modified/Created After', 'xcloner-backup-and-restore') ?></label>
177 177
                         </div>
178 178
                     </div>
179 179
                 </div>
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
                     <div class="row">
183 183
                         <div class="input-field col s12 l12">
184 184
                             <input placeholder="" name="backup_name" id="backup_name" type="text" required value="">
185
-                            <label for="backup_name"><?php echo __( 'Backup Name', 'xcloner-backup-and-restore' ) ?></label>
185
+                            <label for="backup_name"><?php echo __('Backup Name', 'xcloner-backup-and-restore') ?></label>
186 186
                         </div>
187 187
                     </div>
188 188
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
                             <textarea id="table_params" name="table_params" class="materialize-textarea"
192 192
                                       rows="15"></textarea>
193 193
                             <label for="table_params"
194
-                                   class="active"><?php echo __( 'Included Database Data', 'xcloner-backup-and-restore' ) ?></label>
194
+                                   class="active"><?php echo __('Included Database Data', 'xcloner-backup-and-restore') ?></label>
195 195
                         </div>
196 196
                     </div>
197 197
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
                             <textarea id="excluded_files" name="excluded_files" class="materialize-textarea"
201 201
                                       rows="15"></textarea>
202 202
                             <label for="excluded_files"
203
-                                   class="active"><?php echo __( 'Excluded Files', 'xcloner-backup-and-restore' ) ?></label>
203
+                                   class="active"><?php echo __('Excluded Files', 'xcloner-backup-and-restore') ?></label>
204 204
                         </div>
205 205
                     </div>
206 206
                 </div>
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 
211 211
                 <div class="input-field col s12 ">
212 212
                     <button class="right btn waves-effect waves-light" type="submit"
213
-                            name="action"><?php echo __( 'Save', 'xcloner-backup-and-restore' ) ?>
213
+                            name="action"><?php echo __('Save', 'xcloner-backup-and-restore') ?>
214 214
                         <i class="material-icons right">send</i>
215 215
                     </button>
216 216
                 </div>
Please login to merge, or discard this patch.
admin/partials/xcloner_manage_backups_page.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 $storage_selection = "";
8 8
 
9 9
 if (isset($_GET['storage_selection']) and $_GET['storage_selection']) {
10
-    $storage_selection = $xcloner_sanitization->sanitize_input_as_string($_GET['storage_selection']);
10
+	$storage_selection = $xcloner_sanitization->sanitize_input_as_string($_GET['storage_selection']);
11 11
 }
12 12
 
13 13
 //$backup_list = $xcloner_file_system->get_backup_archives_list($storage_selection);
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
             <?php foreach ($available_storages as $storage => $text): ?>
40 40
                 <option value="<?php echo $storage ?>"<?php if ($storage == $storage_selection)
41
-                    echo "selected" ?>><?php echo $text ?></option>
41
+					echo "selected" ?>><?php echo $text ?></option>
42 42
             <?php endforeach ?>
43 43
         </select>
44 44
         <?php endif ?>
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 
66 66
 
67 67
         <?php
68
-        /*$i = 0;
68
+		/*$i = 0;
69 69
         foreach ($backup_list as $file_info):?>
70 70
             <?php
71 71
             if ($storage_selection == "gdrive") {
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
                 <div class="row">
303 303
                     <div class="col s12 label">
304 304
                         <label><?php echo sprintf(__('Send %s to remote storage', 'xcloner-backup-and-restore'),
305
-                                "<span class='backup_name'></span>") ?></label>
305
+								"<span class='backup_name'></span>") ?></label>
306 306
                     </div>
307 307
                     <div class="input-field col s8 m10">
308 308
                         <select name="transfer_storage" id="transfer_storage" class="validate" required>
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -261,7 +261,7 @@
 block discarded – undo
261 261
                     <input type="text"
262 262
                            name="decryption_key"
263 263
                            id="decryption_key"
264
-                           placeholder="<?=__('Decryption Key', 'xcloner-backup-and-restore' )?>" />
264
+                           placeholder="<?=__('Decryption Key', 'xcloner-backup-and-restore')?>" />
265 265
                 </p>
266 266
                 <p class="center-align">
267 267
                     <a class="waves-effect waves-light btn"><?php echo __("START DECRYPTION", 'xcloner-backup-and-restore') ?></a>
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,10 +31,13 @@
 block discarded – undo
31 31
             <?php if ($storage_selection): ?>
32 32
                 <option value=""
33 33
                         selected><?php echo __('Change To Local Storage...', 'xcloner-backup-and-restore') ?></option>
34
-            <?php else: ?>
34
+            <?php else {
35
+	: ?>
35 36
                 <option value=""
36 37
                         selected><?php echo __('Change To Remote Storage...', 'xcloner-backup-and-restore') ?></option>
37
-            <?php endif; ?>
38
+            <?php endif;
39
+}
40
+?>
38 41
 
39 42
             <?php foreach ($available_storages as $storage => $text): ?>
40 43
                 <option value="<?php echo $storage ?>"<?php if ($storage == $storage_selection)
Please login to merge, or discard this patch.
admin/partials/xcloner_generate_backups_page.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -8,25 +8,25 @@  discard block
 block discarded – undo
8 8
 
9 9
 <script>var xcloner_backup = new Xcloner_Backup();</script>
10 10
 
11
-<h1><?= esc_html( get_admin_page_title() ); ?></h1>
11
+<h1><?= esc_html(get_admin_page_title()); ?></h1>
12 12
 
13 13
 <ul class="nav-tab-wrapper content row">
14 14
     <li><a href="#backup_options"
15
-           class="nav-tab col s12 m3 l2 nav-tab-active"><?php echo $tab . ". " . __( 'Backup Options', 'xcloner-backup-and-restore' ) ?></a>
15
+           class="nav-tab col s12 m3 l2 nav-tab-active"><?php echo $tab.". ".__('Backup Options', 'xcloner-backup-and-restore') ?></a>
16 16
     </li>
17
-	<?php if ( $xcloner_settings->get_enable_mysql_backup() ): ?>
17
+	<?php if ($xcloner_settings->get_enable_mysql_backup()): ?>
18 18
         <li><a href="#database_options"
19
-               class="nav-tab col s12 m3 l2 "><?php echo ++ $tab . ". " . __( 'Database Options', 'xcloner-backup-and-restore' ) ?></a>
19
+               class="nav-tab col s12 m3 l2 "><?php echo ++$tab.". ".__('Database Options', 'xcloner-backup-and-restore') ?></a>
20 20
         </li>
21 21
 	<?php endif ?>
22 22
     <li><a href="#files_options"
23
-           class="nav-tab col s12 m3 l2 "><?php echo ++ $tab . ". " . __( 'Files Options', 'xcloner-backup-and-restore' ) ?></a>
23
+           class="nav-tab col s12 m3 l2 "><?php echo ++$tab.". ".__('Files Options', 'xcloner-backup-and-restore') ?></a>
24 24
     </li>
25 25
     <li><a href="#generate_backup"
26
-           class="nav-tab col s12 m3 l2 "><?php echo ++ $tab . ". " . __( 'Generate Backup', 'xcloner-backup-and-restore' ) ?></a>
26
+           class="nav-tab col s12 m3 l2 "><?php echo ++$tab.". ".__('Generate Backup', 'xcloner-backup-and-restore') ?></a>
27 27
     </li>
28 28
     <li><a href="#schedule_backup"
29
-           class="nav-tab col s12 m3 l2 "><?php echo ++ $tab . ". " . __( 'Schedule Backup', 'xcloner-backup-and-restore' ) ?></a>
29
+           class="nav-tab col s12 m3 l2 "><?php echo ++$tab.". ".__('Schedule Backup', 'xcloner-backup-and-restore') ?></a>
30 30
     </li>
31 31
 </ul>
32 32
 
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
                     <i class="material-icons prefix">input</i>
40 40
                     <input name="backup_name" id="backup_name" type="text"
41 41
                            value=<?php echo $xcloner_settings->get_default_backup_name() ?>>
42
-                    <label for="backup_name"><?php echo __( 'Backup Name', 'xcloner-backup-and-restore' ) ?></label>
42
+                    <label for="backup_name"><?php echo __('Backup Name', 'xcloner-backup-and-restore') ?></label>
43 43
                 </div>
44 44
                 <div class="hide-on-small-only m2">
45 45
                     <a class="btn-floating tooltipped btn-small" data-position="right" data-delay="50"
46
-                       data-tooltip="<?php echo __( 'The default backup name, supported tags [time], [hostname], [domain]', 'xcloner-backup-and-restore' ) ?>"
46
+                       data-tooltip="<?php echo __('The default backup name, supported tags [time], [hostname], [domain]', 'xcloner-backup-and-restore') ?>"
47 47
                        data-tooltip-id=""><i class="material-icons">help_outline</i></a>
48 48
                 </div>
49 49
             </div>
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
                 <div class="input-field inline col s12 m10 l6">
53 53
                     <i class="material-icons prefix">email</i>
54 54
                     <input name="email_notification" id="email_notification" type="text"
55
-                           value="<?php echo get_option( 'admin_email' ); ?>">
56
-                    <label for="email_notification"><?php echo __( 'Send Email Notification To', 'xcloner-backup-and-restore' ) ?></label>
55
+                           value="<?php echo get_option('admin_email'); ?>">
56
+                    <label for="email_notification"><?php echo __('Send Email Notification To', 'xcloner-backup-and-restore') ?></label>
57 57
                 </div>
58 58
                 <div class="hide-on-small-only m2">
59 59
                     <a class="btn-floating tooltipped btn-small" data-position="right" data-delay="50"
60
-                       data-tooltip="<?php echo __( 'If left blank, no notification will be sent', 'xcloner-backup-and-restore' ) ?>"
60
+                       data-tooltip="<?php echo __('If left blank, no notification will be sent', 'xcloner-backup-and-restore') ?>"
61 61
                        data-tooltip-id=""><i class="material-icons">help_outline</i></a>
62 62
                 </div>
63 63
             </div>
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
                     <i class="material-icons prefix">access_time</i>
68 68
                     <input type="datetime-local" id="diff_start_date" class="datepicker_max_today"
69 69
                            name="diff_start_date">
70
-                    <label for="diff_start_date"><?php echo __( 'Backup Only Files Modified/Created After', 'xcloner-backup-and-restore' ) ?></label>
70
+                    <label for="diff_start_date"><?php echo __('Backup Only Files Modified/Created After', 'xcloner-backup-and-restore') ?></label>
71 71
                 </div>
72 72
                 <div class="hide-on-small-only m2">
73 73
                     <a class="btn-floating tooltipped btn-small" data-html="true" data-position="center" data-delay="50"
74
-                       data-tooltip="<?php echo __( "This option allows you to create a differential backup that will include only <br> changed files since the set date, leave blank to include all files", "xcloner-backup-and-restore" ) ?>"><i
74
+                       data-tooltip="<?php echo __("This option allows you to create a differential backup that will include only <br> changed files since the set date, leave blank to include all files", "xcloner-backup-and-restore") ?>"><i
75 75
                                 class="material-icons">help_outline</i></a>
76 76
                 </div>
77 77
             </div>
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
             <div class="row">
80 80
                 <div class="input-field col s6 m5 l4">
81 81
                     <i class="material-icons prefix">enhanced_encryption</i>
82
-                    <label for="backup_comments"><?php echo __( 'Encrypt Backup', 'xcloner-backup-and-restore' ) ?></label>
82
+                    <label for="backup_comments"><?php echo __('Encrypt Backup', 'xcloner-backup-and-restore') ?></label>
83 83
 
84 84
                 </div>
85 85
                 <div class="input-field col s6 m5 l2">
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
                 <div class="hide-on-small-only s12 m2">
97 97
                     <a class="btn-floating tooltipped btn-small" data-position="right" data-delay="50"
98
-                       data-tooltip="<?php echo __( 'Enable this option if you want to encrypt the final backup', 'xcloner-backup-and-restore' ) ?>"
98
+                       data-tooltip="<?php echo __('Enable this option if you want to encrypt the final backup', 'xcloner-backup-and-restore') ?>"
99 99
                        data-tooltip-id=""><i class="material-icons">help_outline</i></a>
100 100
                 </div>
101 101
             </div>
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
                 <div class="input-field col s12 m10 l6">
105 105
                     <i class="material-icons prefix">input</i>
106 106
                     <textarea name="backup_comments" id="backup_comments" class="materialize-textarea"></textarea>
107
-                    <label for="backup_comments"><?php echo __( 'Backup Comments', 'xcloner-backup-and-restore' ) ?></label>
107
+                    <label for="backup_comments"><?php echo __('Backup Comments', 'xcloner-backup-and-restore') ?></label>
108 108
                 </div>
109 109
                 <div class="hide-on-small-only m2">
110 110
                     <a class="btn-floating tooltipped btn-small" data-position="right" data-delay="50"
111
-                       data-tooltip="<?php echo __( 'Some default backup comments that will be stored inside the backup archive', 'xcloner-backup-and-restore' ) ?>"
111
+                       data-tooltip="<?php echo __('Some default backup comments that will be stored inside the backup archive', 'xcloner-backup-and-restore') ?>"
112 112
                        data-tooltip-id=""><i class="material-icons">help_outline</i></a>
113 113
                 </div>
114 114
             </div>
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
             </div>
122 122
         </div>
123 123
 
124
-		<?php if ( $xcloner_settings->get_enable_mysql_backup() ): ?>
124
+		<?php if ($xcloner_settings->get_enable_mysql_backup()): ?>
125 125
             <div id="database_options" class="tab-content">
126
-                <h2><?php echo __( 'Select database data to include in the backup', 'xcloner-backup-and-restore' ) ?>:
126
+                <h2><?php echo __('Select database data to include in the backup', 'xcloner-backup-and-restore') ?>:
127 127
                     <a class="btn-floating tooltipped btn-small" data-position="right" data-delay="50"
128
-                       data-tooltip="<?php echo __( 'Enable the \'Backup only WP tables\' setting if you don\'t want to show all other databases and tables not related to this Wordpress install', 'xcloner-backup-and-restore' ); ?>"
128
+                       data-tooltip="<?php echo __('Enable the \'Backup only WP tables\' setting if you don\'t want to show all other databases and tables not related to this Wordpress install', 'xcloner-backup-and-restore'); ?>"
129 129
                        data-tooltip-id=""><i class="material-icons">help_outline</i></a>
130 130
                 </h2>
131 131
 
@@ -147,10 +147,10 @@  discard block
 block discarded – undo
147 147
 		<?php endif ?>
148 148
 
149 149
         <div id="files_options" class="tab-content">
150
-            <h2><?php echo __( 'Select from below the files/folders you want to exclude from your Backup Archive', 'xcloner-backup-and-restore' ) ?>
150
+            <h2><?php echo __('Select from below the files/folders you want to exclude from your Backup Archive', 'xcloner-backup-and-restore') ?>
151 151
                 :
152 152
                 <a class="btn-floating tooltipped btn-small" data-position="bottom" data-delay="50" data-html="true"
153
-                   data-tooltip="<?php echo __( 'You can navigate below through all your site structure(Backup Start Location) to exclude any file/folder you need by clicking the checkbox near it. <br />If the checkobx is disabled, then it matches a Regex Exclude File option and it can\'t be unchecked', 'xcloner-backup-and-restore' ); ?>"
153
+                   data-tooltip="<?php echo __('You can navigate below through all your site structure(Backup Start Location) to exclude any file/folder you need by clicking the checkbox near it. <br />If the checkobx is disabled, then it matches a Regex Exclude File option and it can\'t be unchecked', 'xcloner-backup-and-restore'); ?>"
154 154
                    data-tooltip-id=""><i class="material-icons">help_outline</i></a>
155 155
             </h2>
156 156
 
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
                     <ul class="backup-status collapsible" data-collapsible="accordion">
186 186
                         <li class="file-system">
187 187
                             <div class="collapsible-header">
188
-                                <i class="material-icons">folder</i><?php echo __( 'Scanning The File System...', 'xcloner-backup-and-restore' ) ?>
188
+                                <i class="material-icons">folder</i><?php echo __('Scanning The File System...', 'xcloner-backup-and-restore') ?>
189 189
 
190
-                                <p class="right"><?php echo sprintf( __( 'Found %s files (%s)', 'xcloner-backup-and-restore' ), '<span class="file-counter">0</span>', '<span  class="file-size-total">0</span>MB' ) ?></p>
190
+                                <p class="right"><?php echo sprintf(__('Found %s files (%s)', 'xcloner-backup-and-restore'), '<span class="file-counter">0</span>', '<span  class="file-size-total">0</span>MB') ?></p>
191 191
 
192 192
                                 <div>
193 193
                                     <p class="right"><span class="last-logged-file"></span></p>
@@ -199,12 +199,12 @@  discard block
 block discarded – undo
199 199
                             </div>
200 200
                             <div class="collapsible-body status-body"></div>
201 201
                         </li>
202
-						<?php if ( $xcloner_settings->get_enable_mysql_backup() ): ?>
202
+						<?php if ($xcloner_settings->get_enable_mysql_backup()): ?>
203 203
                             <li class="database-backup">
204 204
                                 <div class="collapsible-header">
205
-                                    <i class="material-icons">storage</i><?php echo __( 'Generating the Mysql Backup...', 'xcloner-backup-and-restore' ) ?>
205
+                                    <i class="material-icons">storage</i><?php echo __('Generating the Mysql Backup...', 'xcloner-backup-and-restore') ?>
206 206
 
207
-                                    <p class="right"><?php echo sprintf( __( 'Found %s tables in %s databases (%s)', 'xcloner-backup-and-restore' ), '<span class="table-counter">0</span>', '<span class="database-counter">0</span>', '<span data-processed="0" class="total-records">0</span> records', 'xcloner-backup-and-restore' ) ?></p>
207
+                                    <p class="right"><?php echo sprintf(__('Found %s tables in %s databases (%s)', 'xcloner-backup-and-restore'), '<span class="table-counter">0</span>', '<span class="database-counter">0</span>', '<span data-processed="0" class="total-records">0</span> records', 'xcloner-backup-and-restore') ?></p>
208 208
 
209 209
                                     <div>
210 210
                                         <p class="right"><span class="last-logged-table"></span></p>
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
 						<?php endif ?>
229 229
                         <li class="files-backup">
230 230
                             <div class="collapsible-header">
231
-                                <i class="material-icons">archive</i><?php echo __( 'Adding Files to Archive...', 'xcloner-backup-and-restore' ) ?>
231
+                                <i class="material-icons">archive</i><?php echo __('Adding Files to Archive...', 'xcloner-backup-and-restore') ?>
232 232
 
233
-                                <p class="right"><?php echo sprintf( __( 'Adding %s files (%s)', 'xcloner-backup-and-restore' ), '<span class="file-counter">0</span>', '<span  data-processed="0" class="file-size-total">0</span>MB' ) ?></p>
233
+                                <p class="right"><?php echo sprintf(__('Adding %s files (%s)', 'xcloner-backup-and-restore'), '<span class="file-counter">0</span>', '<span  data-processed="0" class="file-size-total">0</span>MB') ?></p>
234 234
 
235 235
                                 <div>
236 236
                                     <p class="right"><span class="last-logged-file"></span></p>
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
                             <div class="collapsible-body status-body">
244 244
                                 <div class="row">
245 245
                                     <div class="col l3 s12">
246
-                                        <h2><?php echo __( "Backup Parts", 'xcloner-backup-and-restore' ) ?>: </h2>
246
+                                        <h2><?php echo __("Backup Parts", 'xcloner-backup-and-restore') ?>: </h2>
247 247
                                     </div>
248 248
                                     <div class="col l9 s12">
249 249
                                         <ul class="backup-name"></ul>
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
                         </li>
254 254
                         <li class="backup-encryption">
255 255
                             <div class="collapsible-header">
256
-                                <i class="material-icons">enhanced_encryption</i><?php echo __( 'Encrypting Backup Data...', 'xcloner-backup-and-restore' ) ?>
256
+                                <i class="material-icons">enhanced_encryption</i><?php echo __('Encrypting Backup Data...', 'xcloner-backup-and-restore') ?>
257 257
 
258 258
                                 <p class="right"><span class="status"></span></p>
259 259
 
@@ -268,19 +268,19 @@  discard block
 block discarded – undo
268 268
                         </li>
269 269
                         <li class="backup-done">
270 270
                             <div class="collapsible-header">
271
-                                <i class="material-icons">done</i><?php echo __( 'Backup Done', 'xcloner-backup-and-restore' ) ?>
271
+                                <i class="material-icons">done</i><?php echo __('Backup Done', 'xcloner-backup-and-restore') ?>
272 272
 
273 273
                                 <p class="right">
274
-									<?php if ( sizeof( $available_storages ) ): ?>
274
+									<?php if (sizeof($available_storages)): ?>
275 275
                                         <a href="#" class="cloud-upload"
276
-                                           title="<?php echo __( "Send Backup To Remote Storage", 'xcloner-backup-and-restore' ) ?>"><i
276
+                                           title="<?php echo __("Send Backup To Remote Storage", 'xcloner-backup-and-restore') ?>"><i
277 277
                                                     class="material-icons">cloud_upload</i></a>
278 278
 									<?php endif ?>
279 279
                                     <a href="#" class="download"
280
-                                       title="<?php echo __( "Download Backup", 'xcloner-backup-and-restore' ) ?>"><i
280
+                                       title="<?php echo __("Download Backup", 'xcloner-backup-and-restore') ?>"><i
281 281
                                                 class="material-icons">file_download</i></a>
282 282
                                     <a href="#" class="list-backup-content"
283
-                                       title="<?php echo __( "List Backup Content", 'xcloner-backup-and-restore' ) ?>"><i
283
+                                       title="<?php echo __("List Backup Content", 'xcloner-backup-and-restore') ?>"><i
284 284
                                                 class="material-icons">folder_open</i></a>
285 285
                                 </p>
286 286
 
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
                             </div>
292 292
                             <div class="collapsible-body center-align">
293 293
                                 <div class="row">
294
-                                    <h5><?php echo __( "Thank you for using XCloner.", 'xcloner-backup-and-restore' ) ?></h5>
295
-                                    <h6><?php echo sprintf( __( "We would love to hear about your experience in the %s.", 'xcloner-backup-and-restore' ), '<a href="https://wordpress.org/support/plugin/xcloner-backup-and-restore/reviews/" target="_blank">Wordpress XCloner Reviews Section</a>' ) ?></h6>
294
+                                    <h5><?php echo __("Thank you for using XCloner.", 'xcloner-backup-and-restore') ?></h5>
295
+                                    <h6><?php echo sprintf(__("We would love to hear about your experience in the %s.", 'xcloner-backup-and-restore'), '<a href="https://wordpress.org/support/plugin/xcloner-backup-and-restore/reviews/" target="_blank">Wordpress XCloner Reviews Section</a>') ?></h6>
296 296
                                     <a class="twitter-follow-button" href="https://twitter.com/thinkovi"
297 297
                                        data-show-count="false">Follow @thinkovi</a>
298 298
                                     <script src="//platform.twitter.com/widgets.js" async="" charset="utf-8"></script>
@@ -313,9 +313,9 @@  discard block
 block discarded – undo
313 313
 
314 314
             <div class="row">
315 315
                 <div id="schedule_backup_success" class="col s12 l6 updated settings-error notice is-dismissible">
316
-                    <p><strong><?php echo __( 'Schedule Saved', 'xcloner-backup-and-restore' ) ?></strong></p>
316
+                    <p><strong><?php echo __('Schedule Saved', 'xcloner-backup-and-restore') ?></strong></p>
317 317
                     <button type="button" class="notice-dismiss"><span
318
-                                class="screen-reader-text"><?php echo __( '(Dismiss this notice.', 'xcloner-backup-and-restore' ) ?></span>
318
+                                class="screen-reader-text"><?php echo __('(Dismiss this notice.', 'xcloner-backup-and-restore') ?></span>
319 319
                     </button>
320 320
                 </div>
321 321
             </div>
@@ -323,18 +323,18 @@  discard block
 block discarded – undo
323 323
             <div class="row">
324 324
                 <div class="input-field inline col s12 l7">
325 325
                     <input type="text" id="schedule_name" class="" name="schedule_name" required>
326
-                    <label for="schedule_name"><?php echo __( 'Schedule Name', 'xcloner-backup-and-restore' ) ?></label>
326
+                    <label for="schedule_name"><?php echo __('Schedule Name', 'xcloner-backup-and-restore') ?></label>
327 327
                 </div>
328 328
             </div>
329 329
 
330 330
             <div class="row">
331 331
                 <div class="input-field inline col s12 m8 l4">
332 332
                     <input type="datetime-local" id="datepicker" class="datepicker" name="schedule_start_date">
333
-                    <label for="datepicker"><?php echo __( 'Schedule Backup To Start On:', 'xcloner-backup-and-restore' ) ?></label>
333
+                    <label for="datepicker"><?php echo __('Schedule Backup To Start On:', 'xcloner-backup-and-restore') ?></label>
334 334
                 </div>
335 335
                 <div class="input-field inline col s12 m4 l3">
336 336
                     <input id="timepicker_ampm_dark" class="timepicker" type="time" name="schedule_start_time">
337
-                    <label for="timepicker_ampm_dark"><?php echo __( 'At:', 'xcloner-backup-and-restore' ) ?></label>
337
+                    <label for="timepicker_ampm_dark"><?php echo __('At:', 'xcloner-backup-and-restore') ?></label>
338 338
                 </div>
339 339
             </div>
340 340
 
@@ -342,17 +342,17 @@  discard block
 block discarded – undo
342 342
 			<div class="row">
343 343
 				<div class="input-field inline col s10 m11 l7">
344 344
 					<select id="backup_type" class="" name="backup_type">
345
-						<option value=""><?php echo __( "Full Backup", "xcloner-backup-and-restore" ); ?></option>
346
-						<option value="diff"><?php echo __( "Differential Backups", "xcloner-backup-and-restore" ); ?></option>
347
-						<option value="full_diff"><?php echo __( "Full Backup + Differential Backups", "xcloner-backup-and-restore" ); ?></option>
345
+						<option value=""><?php echo __("Full Backup", "xcloner-backup-and-restore"); ?></option>
346
+						<option value="diff"><?php echo __("Differential Backups", "xcloner-backup-and-restore"); ?></option>
347
+						<option value="full_diff"><?php echo __("Full Backup + Differential Backups", "xcloner-backup-and-restore"); ?></option>
348 348
 					</select>
349
-					<label for="backup_type"><?php echo __( 'Scheduled Backup Type', 'xcloner-backup-and-restore' ) ?></label>
349
+					<label for="backup_type"><?php echo __('Scheduled Backup Type', 'xcloner-backup-and-restore') ?></label>
350 350
 				</div>
351 351
 				<div class="col s2 m1">	
352 352
 					<a class="btn-floating tooltipped btn-small" data-html="true" data-position="center" data-delay="50" data-tooltip="<ul style='max-width:760px; text-align:left;'>
353
-						<li><?php echo __( "Full Backup = it will generate a full backup of all included files each time schedule runs", "xcloner-backup-and-restore" ); ?></li>
354
-						<li><?php echo __( "Differentials Backups = backups will include only changed files since the schedule started to run", "xcloner-backup-and-restore" ); ?></li>
355
-						<li><?php echo __( "Full Backup +  Differential Backups = the first time schedule runs, it will create a full backup and all next scheduled backups will include only files created/modified since that last full backup; a full backup is recreated when the number of changed files is bigger than the 'Differetial Backups Max Days' XCloner option.", "xcloner-backup-and-restore" ); ?></li>
353
+						<li><?php echo __("Full Backup = it will generate a full backup of all included files each time schedule runs", "xcloner-backup-and-restore"); ?></li>
354
+						<li><?php echo __("Differentials Backups = backups will include only changed files since the schedule started to run", "xcloner-backup-and-restore"); ?></li>
355
+						<li><?php echo __("Full Backup +  Differential Backups = the first time schedule runs, it will create a full backup and all next scheduled backups will include only files created/modified since that last full backup; a full backup is recreated when the number of changed files is bigger than the 'Differetial Backups Max Days' XCloner option.", "xcloner-backup-and-restore"); ?></li>
356 356
 					</ul>"><i class="material-icons">help_outline</i></a>
357 357
 				</div>
358 358
 			</div>	
@@ -361,38 +361,38 @@  discard block
 block discarded – undo
361 361
                 <div class="input-field col s12 l7">
362 362
                     <select name="schedule_frequency" id="schedule_frequency" class="validate" required>
363 363
                         <option value="" disabled
364
-                                selected><?php echo __( 'please select', 'xcloner-backup-and-restore' ) ?></option>
364
+                                selected><?php echo __('please select', 'xcloner-backup-and-restore') ?></option>
365 365
 						<?php
366 366
 						$schedules = $xcloner_scheduler->get_available_intervals();
367 367
 
368
-						foreach ( $schedules as $key => $schedule ) {
368
+						foreach ($schedules as $key => $schedule) {
369 369
 							?>
370 370
                             <option value="<?php echo $key ?>"><?php echo $schedule['display'] ?></option>
371 371
 							<?php
372 372
 						}
373 373
 						?>
374 374
                     </select>
375
-                    <label><?php echo __( 'Schedule Frequency', 'xcloner-backup-and-restore' ) ?></label>
375
+                    <label><?php echo __('Schedule Frequency', 'xcloner-backup-and-restore') ?></label>
376 376
                 </div>
377 377
             </div>
378 378
 
379
-			<?php if ( sizeof( $available_storages ) ): ?>
379
+			<?php if (sizeof($available_storages)): ?>
380 380
                 <div class="row">
381 381
                     <div class="input-field col s12 m12 l7">
382 382
                         <select name="schedule_storage" id="schedule_storage" class="validate">
383
-                            <option value="" selected><?php echo __( 'none', 'xcloner-backup-and-restore' ) ?></option>
384
-							<?php foreach ( $available_storages as $storage => $text ): ?>
383
+                            <option value="" selected><?php echo __('none', 'xcloner-backup-and-restore') ?></option>
384
+							<?php foreach ($available_storages as $storage => $text): ?>
385 385
                                 <option value="<?php echo $storage ?>"><?php echo $text ?></option>
386 386
 							<?php endforeach ?>
387 387
                         </select>
388
-                        <label><?php echo __( 'Send To Remote Storage', 'xcloner-backup-and-restore' ) ?></label>
388
+                        <label><?php echo __('Send To Remote Storage', 'xcloner-backup-and-restore') ?></label>
389 389
                     </div>
390 390
                 </div>
391 391
 			<?php endif ?>
392 392
             <div class="row">
393 393
                 <div class="col s12 l7">
394 394
                     <button class="right btn waves-effect waves-light submit_schedule" type="submit"
395
-                            name="action"><?php echo __( "Submit", 'xcloner-backup-and-restore' ) ?>
395
+                            name="action"><?php echo __("Submit", 'xcloner-backup-and-restore') ?>
396 396
                         <i class="material-icons right">send</i>
397 397
                     </button>
398 398
                 </div>
@@ -407,19 +407,19 @@  discard block
 block discarded – undo
407 407
                 class="material-icons medium right">help</i></a>
408 408
     <div class="modal-content">
409 409
         <h4 class="title_line"><span class="title"></span></h4>
410
-        <!--<h5 class="title_line"><?php echo __( 'Message' ) ?>: <span class="msg.old"></span></h5>-->
411
-        <h5><?php echo __( 'Response Code', 'xcloner-backup-and-restore' ) ?>: <span class="status"></span></h5>
410
+        <!--<h5 class="title_line"><?php echo __('Message') ?>: <span class="msg.old"></span></h5>-->
411
+        <h5><?php echo __('Response Code', 'xcloner-backup-and-restore') ?>: <span class="status"></span></h5>
412 412
         <textarea class="body" rows="5"></textarea>
413 413
     </div>
414 414
     <div class="modal-footer">
415
-        <a class=" modal-action modal-close waves-effect waves-green btn-flat  red darken-2"><?php echo __( 'Close', 'xcloner-backup-and-restore' ) ?></a>
415
+        <a class=" modal-action modal-close waves-effect waves-green btn-flat  red darken-2"><?php echo __('Close', 'xcloner-backup-and-restore') ?></a>
416 416
     </div>
417 417
 </div>
418 418
 
419 419
 <!-- List Backup Content Modal-->
420 420
 <div id="backup_cotent_modal" class="modal">
421 421
     <div class="modal-content">
422
-        <h4><?php echo sprintf( __( "Listing Backup Content ", 'xcloner-backup-and-restore' ), "" ) ?></h4>
422
+        <h4><?php echo sprintf(__("Listing Backup Content ", 'xcloner-backup-and-restore'), "") ?></h4>
423 423
         <h5 class="backup-name"></h5>
424 424
 
425 425
         <div class="progress">
@@ -434,18 +434,18 @@  discard block
 block discarded – undo
434 434
     <form method="POST" class="remote-storage-form">
435 435
         <input type="hidden" name="file" class="backup_name">
436 436
         <div class="modal-content">
437
-            <h4><?php echo __( "Remote Storage Transfer", 'xcloner-backup-and-restore' ) ?></h4>
437
+            <h4><?php echo __("Remote Storage Transfer", 'xcloner-backup-and-restore') ?></h4>
438 438
             <p>
439
-				<?php if ( sizeof( $available_storages ) ): ?>
439
+				<?php if (sizeof($available_storages)): ?>
440 440
             <div class="row">
441 441
                 <div class="col s12 label">
442
-                    <label><?php echo __( sprintf( 'Send %s to remote storage', "<span class='backup_name'></span>" ), 'xcloner-backup-and-restore' ) ?></label>
442
+                    <label><?php echo __(sprintf('Send %s to remote storage', "<span class='backup_name'></span>"), 'xcloner-backup-and-restore') ?></label>
443 443
                 </div>
444 444
                 <div class="input-field col s8 m10">
445 445
                     <select name="transfer_storage" id="transfer_storage" class="validate" required>
446 446
                         <option value=""
447
-                                selected><?php echo __( 'please select...', 'xcloner-backup-and-restore' ) ?></option>
448
-						<?php foreach ( $available_storages as $storage => $text ): ?>
447
+                                selected><?php echo __('please select...', 'xcloner-backup-and-restore') ?></option>
448
+						<?php foreach ($available_storages as $storage => $text): ?>
449 449
                             <option value="<?php echo $storage ?>"><?php echo $text ?></option>
450 450
 						<?php endforeach ?>
451 451
                     </select>
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
                 </div>
458 458
             </div>
459 459
             <div class="row status">
460
-				<?php echo __( "Uploading backup to the selected remote storage...", 'xcloner-backup-and-restore' ) ?>
460
+				<?php echo __("Uploading backup to the selected remote storage...", 'xcloner-backup-and-restore') ?>
461 461
                 <span class="status-text"></span>
462 462
                 <div class="progress">
463 463
                     <div class="indeterminate"></div>
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
             }
542 542
         });
543 543
 
544
-		<?php if($xcloner_settings->get_enable_mysql_backup()):?>
544
+		<?php if ($xcloner_settings->get_enable_mysql_backup()):?>
545 545
         jQuery('#jstree_database_container').jstree({
546 546
             'core': {
547 547
                 'check_callback': true,
Please login to merge, or discard this patch.
admin/partials/xcloner_remote_storage_page.php 1 patch
Spacing   +197 added lines, -197 removed lines patch added patch discarded remove patch
@@ -3,13 +3,13 @@  discard block
 block discarded – undo
3 3
 
4 4
 $gdrive_auth_url = "";
5 5
 
6
-if ( method_exists( $remote_storage, "get_gdrive_auth_url" ) ) {
6
+if (method_exists($remote_storage, "get_gdrive_auth_url")) {
7 7
 	$gdrive_auth_url = $remote_storage->get_gdrive_auth_url();
8 8
 }
9 9
 
10 10
 $gdrive_construct = $remote_storage->gdrive_construct();
11 11
 ?>
12
-<h1><?= esc_html( get_admin_page_title() ); ?></h1>
12
+<h1><?= esc_html(get_admin_page_title()); ?></h1>
13 13
 
14 14
 <form class="remote-storage-form" method="POST">
15 15
 
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
                 <!-- FTP STORAGE-->
22 22
                 <li id="ftp">
23 23
                     <div class="collapsible-header">
24
-                        <i class="material-icons">computer</i><?php echo __( "FTP Storage", 'xcloner-backup-and-restore' ) ?>
24
+                        <i class="material-icons">computer</i><?php echo __("FTP Storage", 'xcloner-backup-and-restore') ?>
25 25
                         <div class="switch right">
26 26
                             <label>
27 27
                                 Off
28 28
                                 <input type="checkbox" name="xcloner_ftp_enable" class="status"
29
-                                       value="1" <?php if ( get_option( "xcloner_ftp_enable" ) )
29
+                                       value="1" <?php if (get_option("xcloner_ftp_enable"))
30 30
 									echo "checked" ?> \>
31 31
                                 <span class="lever"></span>
32 32
                                 On
@@ -36,121 +36,121 @@  discard block
 block discarded – undo
36 36
                     <div class="collapsible-body">
37 37
                         <div class="row">
38 38
                             <div class="col s12 m3 label">
39
-                                <label for="ftp_host"><?php echo __( "Ftp Hostname", 'xcloner-backup-and-restore' ) ?></label>
39
+                                <label for="ftp_host"><?php echo __("Ftp Hostname", 'xcloner-backup-and-restore') ?></label>
40 40
                             </div>
41 41
                             <div class="col s12 m6">
42
-                                <input placeholder="<?php echo __( "Ftp Hostname", 'xcloner-backup-and-restore' ) ?>"
42
+                                <input placeholder="<?php echo __("Ftp Hostname", 'xcloner-backup-and-restore') ?>"
43 43
                                        id="ftp_host" type="text" name="xcloner_ftp_hostname" class="validate"
44
-                                       value="<?php echo get_option( "xcloner_ftp_hostname" ) ?>">
44
+                                       value="<?php echo get_option("xcloner_ftp_hostname") ?>">
45 45
                             </div>
46 46
                             <div class=" col s12 m2">
47
-                                <input placeholder="<?php echo __( "Ftp Port", 'xcloner-backup-and-restore' ) ?>"
47
+                                <input placeholder="<?php echo __("Ftp Port", 'xcloner-backup-and-restore') ?>"
48 48
                                        id="ftp_port" type="text" name="xcloner_ftp_port" class="validate"
49
-                                       value="<?php echo get_option( "xcloner_ftp_port", 21 ) ?>">
49
+                                       value="<?php echo get_option("xcloner_ftp_port", 21) ?>">
50 50
                             </div>
51 51
                         </div>
52 52
 
53 53
                         <div class="row">
54 54
                             <div class="col s12 m3 label">
55
-                                <label for="ftp_username"><?php echo __( "Ftp Username", 'xcloner-backup-and-restore' ) ?></label>
55
+                                <label for="ftp_username"><?php echo __("Ftp Username", 'xcloner-backup-and-restore') ?></label>
56 56
                             </div>
57 57
                             <div class=" col s12 m6">
58
-                                <input placeholder="<?php echo __( "Ftp Username", 'xcloner-backup-and-restore' ) ?>"
58
+                                <input placeholder="<?php echo __("Ftp Username", 'xcloner-backup-and-restore') ?>"
59 59
                                        id="ftp_username" type="text" name="xcloner_ftp_username" class="validate"
60
-                                       value="<?php echo get_option( "xcloner_ftp_username" ) ?>" autocomplete="off">
60
+                                       value="<?php echo get_option("xcloner_ftp_username") ?>" autocomplete="off">
61 61
                             </div>
62 62
                         </div>
63 63
 
64 64
 
65 65
                         <div class="row">
66 66
                             <div class="col s12 m3 label">
67
-                                <label for="ftp_password"><?php echo __( "Ftp Password", 'xcloner-backup-and-restore' ) ?></label>
67
+                                <label for="ftp_password"><?php echo __("Ftp Password", 'xcloner-backup-and-restore') ?></label>
68 68
                             </div>
69 69
                             <div class=" col s12 m6">
70
-                                <input placeholder="<?php echo __( "Ftp Password", 'xcloner-backup-and-restore' ) ?>"
70
+                                <input placeholder="<?php echo __("Ftp Password", 'xcloner-backup-and-restore') ?>"
71 71
                                        id="ftp_password" type="password" name="xcloner_ftp_password" class="validate"
72
-                                       value="<?php echo get_option( "xcloner_ftp_password" ) ?>" autocomplete="off">
72
+                                       value="<?php echo get_option("xcloner_ftp_password") ?>" autocomplete="off">
73 73
                             </div>
74 74
                         </div>
75 75
 
76 76
                         <div class="row">
77 77
                             <div class="col s12 m3 label">
78
-                                <label for="ftp_root"><?php echo __( "Ftp Storage Folder", 'xcloner-backup-and-restore' ) ?></label>
78
+                                <label for="ftp_root"><?php echo __("Ftp Storage Folder", 'xcloner-backup-and-restore') ?></label>
79 79
                             </div>
80 80
                             <div class=" col s12 m6">
81
-                                <input placeholder="<?php echo __( "Ftp Storage Folder", 'xcloner-backup-and-restore' ) ?>"
81
+                                <input placeholder="<?php echo __("Ftp Storage Folder", 'xcloner-backup-and-restore') ?>"
82 82
                                        id="ftp_root" type="text" name="xcloner_ftp_path" class="validate"
83
-                                       value="<?php echo get_option( "xcloner_ftp_path" ) ?>">
83
+                                       value="<?php echo get_option("xcloner_ftp_path") ?>">
84 84
                             </div>
85 85
                         </div>
86 86
 
87 87
                         <div class="row">
88 88
                             <div class="col s12 m3 label">
89
-                                <label for="ftp_root"><?php echo __( "Ftp Transfer Mode", 'xcloner-backup-and-restore' ) ?></label>
89
+                                <label for="ftp_root"><?php echo __("Ftp Transfer Mode", 'xcloner-backup-and-restore') ?></label>
90 90
                             </div>
91 91
                             <div class=" col s12 m6 input-field inline">
92 92
                                 <input name="xcloner_ftp_transfer_mode" type="radio" id="passive"
93
-                                       value="1" <?php if ( get_option( "xcloner_ftp_transfer_mode", 1 ) )
93
+                                       value="1" <?php if (get_option("xcloner_ftp_transfer_mode", 1))
94 94
 									echo "checked" ?> />
95
-                                <label for="passive"><?php echo __( "Passive", 'xcloner-backup-and-restore' ) ?></label>
95
+                                <label for="passive"><?php echo __("Passive", 'xcloner-backup-and-restore') ?></label>
96 96
 
97 97
                                 <input name="xcloner_ftp_transfer_mode" type="radio" id="active"
98
-                                       value="0" <?php if ( ! get_option( "xcloner_ftp_transfer_mode", 1 ) )
98
+                                       value="0" <?php if (!get_option("xcloner_ftp_transfer_mode", 1))
99 99
 									echo "checked" ?> />
100
-                                <label for="active"><?php echo __( "Active", 'xcloner-backup-and-restore' ) ?></label>
100
+                                <label for="active"><?php echo __("Active", 'xcloner-backup-and-restore') ?></label>
101 101
                             </div>
102 102
                         </div>
103 103
 
104 104
                         <div class="row">
105 105
                             <div class="col s12 m3 label">
106
-                                <label for="ftp_ssl_mode"><?php echo __( "Ftp Secure Connection", 'xcloner-backup-and-restore' ) ?></label>
106
+                                <label for="ftp_ssl_mode"><?php echo __("Ftp Secure Connection", 'xcloner-backup-and-restore') ?></label>
107 107
                             </div>
108 108
                             <div class=" col s12 m6 input-field inline">
109 109
                                 <input name="xcloner_ftp_ssl_mode" type="radio" id="ftp_ssl_mode_inactive"
110
-                                       value="0" <?php if ( ! get_option( "xcloner_ftp_ssl_mode" ) )
110
+                                       value="0" <?php if (!get_option("xcloner_ftp_ssl_mode"))
111 111
 									echo "checked" ?> />
112
-                                <label for="ftp_ssl_mode_inactive"><?php echo __( "Disable", 'xcloner-backup-and-restore' ) ?></label>
112
+                                <label for="ftp_ssl_mode_inactive"><?php echo __("Disable", 'xcloner-backup-and-restore') ?></label>
113 113
 
114 114
                                 <input name="xcloner_ftp_ssl_mode" type="radio" id="ftp_ssl_mode_active"
115
-                                       value="1" <?php if ( get_option( "xcloner_ftp_ssl_mode" ) )
115
+                                       value="1" <?php if (get_option("xcloner_ftp_ssl_mode"))
116 116
 									echo "checked" ?> />
117
-                                <label for="ftp_ssl_mode_active"><?php echo __( "Enable", 'xcloner-backup-and-restore' ) ?></label>
117
+                                <label for="ftp_ssl_mode_active"><?php echo __("Enable", 'xcloner-backup-and-restore') ?></label>
118 118
                             </div>
119 119
                         </div>
120 120
 
121 121
                         <div class="row">
122 122
                             <div class="col s12 m3 label">
123
-                                <label for="ftp_timeout"><?php echo __( "Ftp Timeout", 'xcloner-backup-and-restore' ) ?></label>
123
+                                <label for="ftp_timeout"><?php echo __("Ftp Timeout", 'xcloner-backup-and-restore') ?></label>
124 124
                             </div>
125 125
                             <div class=" col s12 m2">
126
-                                <input placeholder="<?php echo __( "Ftp Timeout", 'xcloner-backup-and-restore' ) ?>"
126
+                                <input placeholder="<?php echo __("Ftp Timeout", 'xcloner-backup-and-restore') ?>"
127 127
                                        id="ftp_timeout" type="text" name="xcloner_ftp_timeout" class="validate"
128
-                                       value="<?php echo get_option( "xcloner_ftp_timeout", 30 ) ?>">
128
+                                       value="<?php echo get_option("xcloner_ftp_timeout", 30) ?>">
129 129
                             </div>
130 130
                         </div>
131 131
 
132 132
                         <div class="row">
133 133
                             <div class="col s12 m3 label">
134
-                                <label for="ftp_cleanup_days"><?php echo __( "Ftp Cleanup (days)", 'xcloner-backup-and-restore' ) ?></label>
134
+                                <label for="ftp_cleanup_days"><?php echo __("Ftp Cleanup (days)", 'xcloner-backup-and-restore') ?></label>
135 135
                             </div>
136 136
                             <div class=" col s12 m6">
137
-                                <input placeholder="<?php echo __( "how many days to keep the backups for", 'xcloner-backup-and-restore' ) ?>"
137
+                                <input placeholder="<?php echo __("how many days to keep the backups for", 'xcloner-backup-and-restore') ?>"
138 138
                                        id="ftp_cleanup_days" type="text" name="xcloner_ftp_cleanup_days"
139
-                                       class="validate" value="<?php echo get_option( "xcloner_ftp_cleanup_days" ) ?>">
139
+                                       class="validate" value="<?php echo get_option("xcloner_ftp_cleanup_days") ?>">
140 140
                             </div>
141 141
                         </div>
142 142
 
143 143
                         <div class="row">
144 144
                             <div class="col s6 m4">
145 145
                                 <button class="btn waves-effect waves-light" type="submit" name="action" id="action"
146
-                                        value="ftp"><?php echo __( "Save Settings", 'xcloner-backup-and-restore' ) ?>
146
+                                        value="ftp"><?php echo __("Save Settings", 'xcloner-backup-and-restore') ?>
147 147
                                     <i class="material-icons right">save</i>
148 148
                                 </button>
149 149
                             </div>
150 150
                             <div class="col s6 m4">
151 151
                                 <button class="btn waves-effect waves-light orange" type="submit" name="action"
152 152
                                         id="action" value="ftp"
153
-                                        onclick="jQuery('#connection_check').val('1')"><?php echo __( "Verify", 'xcloner-backup-and-restore' ) ?>
153
+                                        onclick="jQuery('#connection_check').val('1')"><?php echo __("Verify", 'xcloner-backup-and-restore') ?>
154 154
                                     <i class="material-icons right">import_export</i>
155 155
                                 </button>
156 156
                             </div>
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
                 <!-- SFTP STORAGE-->
162 162
                 <li id="sftp">
163 163
                     <div class="collapsible-header">
164
-                        <i class="material-icons">computer</i><?php echo __( "SFTP Storage", 'xcloner-backup-and-restore' ) ?>
164
+                        <i class="material-icons">computer</i><?php echo __("SFTP Storage", 'xcloner-backup-and-restore') ?>
165 165
                         <div class="switch right">
166 166
                             <label>
167 167
                                 Off
168 168
                                 <input type="checkbox" name="xcloner_sftp_enable" class="status"
169
-                                       value="1" <?php if ( get_option( "xcloner_sftp_enable" ) )
169
+                                       value="1" <?php if (get_option("xcloner_sftp_enable"))
170 170
 									echo "checked" ?> \>
171 171
                                 <span class="lever"></span>
172 172
                                 On
@@ -176,100 +176,100 @@  discard block
 block discarded – undo
176 176
                     <div class="collapsible-body">
177 177
                         <div class="row">
178 178
                             <div class="col s12 m3 label">
179
-                                <label for="sftp_host"><?php echo __( "SFTP Hostname", 'xcloner-backup-and-restore' ) ?></label>
179
+                                <label for="sftp_host"><?php echo __("SFTP Hostname", 'xcloner-backup-and-restore') ?></label>
180 180
                             </div>
181 181
                             <div class="col s12 m6">
182
-                                <input placeholder="<?php echo __( "SFTP Hostname", 'xcloner-backup-and-restore' ) ?>"
182
+                                <input placeholder="<?php echo __("SFTP Hostname", 'xcloner-backup-and-restore') ?>"
183 183
                                        id="sftp_host" type="text" name="xcloner_sftp_hostname" class="validate"
184
-                                       value="<?php echo get_option( "xcloner_sftp_hostname" ) ?>">
184
+                                       value="<?php echo get_option("xcloner_sftp_hostname") ?>">
185 185
                             </div>
186 186
                             <div class=" col s12 m2">
187
-                                <input placeholder="<?php echo __( "SFTP Port", 'xcloner-backup-and-restore' ) ?>"
187
+                                <input placeholder="<?php echo __("SFTP Port", 'xcloner-backup-and-restore') ?>"
188 188
                                        id="sftp_port" type="text" name="xcloner_sftp_port" class="validate"
189
-                                       value="<?php echo get_option( "xcloner_sftp_port", 22 ) ?>">
189
+                                       value="<?php echo get_option("xcloner_sftp_port", 22) ?>">
190 190
                             </div>
191 191
                         </div>
192 192
 
193 193
                         <div class="row">
194 194
                             <div class="col s12 m3 label">
195
-                                <label for="sftp_username"><?php echo __( "SFTP Username", 'xcloner-backup-and-restore' ) ?></label>
195
+                                <label for="sftp_username"><?php echo __("SFTP Username", 'xcloner-backup-and-restore') ?></label>
196 196
                             </div>
197 197
                             <div class=" col s12 m6">
198
-                                <input placeholder="<?php echo __( "SFTP Username", 'xcloner-backup-and-restore' ) ?>"
198
+                                <input placeholder="<?php echo __("SFTP Username", 'xcloner-backup-and-restore') ?>"
199 199
                                        id="sftp_username" type="text" name="xcloner_sftp_username" class="validate"
200
-                                       value="<?php echo get_option( "xcloner_sftp_username" ) ?>" autocomplete="off">
200
+                                       value="<?php echo get_option("xcloner_sftp_username") ?>" autocomplete="off">
201 201
                             </div>
202 202
                         </div>
203 203
 
204 204
 
205 205
                         <div class="row">
206 206
                             <div class="col s12 m3 label">
207
-                                <label for="sftp_password"><?php echo __( "SFTP or Private Key Password", 'xcloner-backup-and-restore' ) ?></label>
207
+                                <label for="sftp_password"><?php echo __("SFTP or Private Key Password", 'xcloner-backup-and-restore') ?></label>
208 208
                             </div>
209 209
                             <div class=" col s12 m6">
210
-                                <input placeholder="<?php echo __( "SFTP or Private Key Password", 'xcloner-backup-and-restore' ) ?>"
210
+                                <input placeholder="<?php echo __("SFTP or Private Key Password", 'xcloner-backup-and-restore') ?>"
211 211
                                        id="ftp_spassword" type="password" name="xcloner_sftp_password" class="validate"
212
-                                       value="<?php echo get_option( "xcloner_sftp_password" ) ?>" autocomplete="off">
212
+                                       value="<?php echo get_option("xcloner_sftp_password") ?>" autocomplete="off">
213 213
                             </div>
214 214
                         </div>
215 215
 
216 216
                         <div class="row">
217 217
                             <div class="col s12 m3 label">
218
-                                <label for="sftp_private_key"><?php echo __( "SFTP Private Key(RSA)", 'xcloner-backup-and-restore' ) ?></label>
218
+                                <label for="sftp_private_key"><?php echo __("SFTP Private Key(RSA)", 'xcloner-backup-and-restore') ?></label>
219 219
                             </div>
220 220
                             <div class=" col s12 m6">
221 221
                                 <textarea rows="5"
222
-                                          placeholder="<?php echo __( "Local Server Path or Contents of the SFTP Private Key RSA File", 'xcloner-backup-and-restore' ) ?>"
222
+                                          placeholder="<?php echo __("Local Server Path or Contents of the SFTP Private Key RSA File", 'xcloner-backup-and-restore') ?>"
223 223
                                           id="sftp_private_key" type="text" name="xcloner_sftp_private_key"
224 224
                                           class="validate"
225
-                                          value=""><?php echo get_option( "xcloner_sftp_private_key" ) ?></textarea>
225
+                                          value=""><?php echo get_option("xcloner_sftp_private_key") ?></textarea>
226 226
                             </div>
227 227
                         </div>
228 228
 
229 229
                         <div class="row">
230 230
                             <div class="col s12 m3 label">
231
-                                <label for="sftp_root"><?php echo __( "SFTP Storage Folder", 'xcloner-backup-and-restore' ) ?></label>
231
+                                <label for="sftp_root"><?php echo __("SFTP Storage Folder", 'xcloner-backup-and-restore') ?></label>
232 232
                             </div>
233 233
                             <div class=" col s12 m6">
234
-                                <input placeholder="<?php echo __( "SFTP Storage Folder", 'xcloner-backup-and-restore' ) ?>"
234
+                                <input placeholder="<?php echo __("SFTP Storage Folder", 'xcloner-backup-and-restore') ?>"
235 235
                                        id="sftp_root" type="text" name="xcloner_sftp_path" class="validate"
236
-                                       value="<?php echo get_option( "xcloner_sftp_path" ) ?>">
236
+                                       value="<?php echo get_option("xcloner_sftp_path") ?>">
237 237
                             </div>
238 238
                         </div>
239 239
 
240 240
                         <div class="row">
241 241
                             <div class="col s12 m3 label">
242
-                                <label for="sftp_timeout"><?php echo __( "SFTP Timeout", 'xcloner-backup-and-restore' ) ?></label>
242
+                                <label for="sftp_timeout"><?php echo __("SFTP Timeout", 'xcloner-backup-and-restore') ?></label>
243 243
                             </div>
244 244
                             <div class=" col s12 m2">
245
-                                <input placeholder="<?php echo __( "SFTP Timeout", 'xcloner-backup-and-restore' ) ?>"
245
+                                <input placeholder="<?php echo __("SFTP Timeout", 'xcloner-backup-and-restore') ?>"
246 246
                                        id="sftp_timeout" type="text" name="xcloner_sftp_timeout" class="validate"
247
-                                       value="<?php echo get_option( "xcloner_sftp_timeout", 30 ) ?>">
247
+                                       value="<?php echo get_option("xcloner_sftp_timeout", 30) ?>">
248 248
                             </div>
249 249
                         </div>
250 250
 
251 251
                         <div class="row">
252 252
                             <div class="col s12 m3 label">
253
-                                <label for="sftp_cleanup_days"><?php echo __( "SFTP Cleanup (days)", 'xcloner-backup-and-restore' ) ?></label>
253
+                                <label for="sftp_cleanup_days"><?php echo __("SFTP Cleanup (days)", 'xcloner-backup-and-restore') ?></label>
254 254
                             </div>
255 255
                             <div class=" col s12 m6">
256
-                                <input placeholder="<?php echo __( "how many days to keep the backups for", 'xcloner-backup-and-restore' ) ?>"
256
+                                <input placeholder="<?php echo __("how many days to keep the backups for", 'xcloner-backup-and-restore') ?>"
257 257
                                        id="sftp_cleanup_days" type="text" name="xcloner_sftp_cleanup_days"
258
-                                       class="validate" value="<?php echo get_option( "xcloner_sftp_cleanup_days" ) ?>">
258
+                                       class="validate" value="<?php echo get_option("xcloner_sftp_cleanup_days") ?>">
259 259
                             </div>
260 260
                         </div>
261 261
 
262 262
                         <div class="row">
263 263
                             <div class="col s6 m4">
264 264
                                 <button class="btn waves-effect waves-light" type="submit" name="action" id="action"
265
-                                        value="sftp"><?php echo __( "Save Settings", 'xcloner-backup-and-restore' ) ?>
265
+                                        value="sftp"><?php echo __("Save Settings", 'xcloner-backup-and-restore') ?>
266 266
                                     <i class="material-icons right">save</i>
267 267
                                 </button>
268 268
                             </div>
269 269
                             <div class="col s6 m4">
270 270
                                 <button class="btn waves-effect waves-light orange" type="submit" name="action"
271 271
                                         id="action" value="sftp"
272
-                                        onclick="jQuery('#connection_check').val('1')"><?php echo __( "Verify", 'xcloner-backup-and-restore' ) ?>
272
+                                        onclick="jQuery('#connection_check').val('1')"><?php echo __("Verify", 'xcloner-backup-and-restore') ?>
273 273
                                     <i class="material-icons right">import_export</i>
274 274
                                 </button>
275 275
                             </div>
@@ -281,12 +281,12 @@  discard block
 block discarded – undo
281 281
                 <!-- AWS STORAGE-->
282 282
                 <li id="aws">
283 283
                     <div class="collapsible-header">
284
-                        <i class="material-icons">computer</i><?php echo __( "S3 Storage", 'xcloner-backup-and-restore' ) ?>
284
+                        <i class="material-icons">computer</i><?php echo __("S3 Storage", 'xcloner-backup-and-restore') ?>
285 285
                         <div class="switch right">
286 286
                             <label>
287 287
                                 Off
288 288
                                 <input type="checkbox" name="xcloner_aws_enable" class="status"
289
-                                       value="1" <?php if ( get_option( "xcloner_aws_enable" ) )
289
+                                       value="1" <?php if (get_option("xcloner_aws_enable"))
290 290
 									echo "checked" ?> \>
291 291
                                 <span class="lever"></span>
292 292
                                 On
@@ -301,49 +301,49 @@  discard block
 block discarded – undo
301 301
                             </div>
302 302
                             <div class=" col s12 m6">
303 303
                                 <p>
304
-									<?php echo sprintf( __( 'Visit %s and get your "Key" and "Secret <br />Visit %s to install your own S3 like service.' ), "<a href='https://aws.amazon.com/s3/' target='_blank'>https://aws.amazon.com/s3/</a>", "<a href='https://minio.io/' target='_blank'>https://minio.io/</a>" ) ?>
304
+									<?php echo sprintf(__('Visit %s and get your "Key" and "Secret <br />Visit %s to install your own S3 like service.'), "<a href='https://aws.amazon.com/s3/' target='_blank'>https://aws.amazon.com/s3/</a>", "<a href='https://minio.io/' target='_blank'>https://minio.io/</a>") ?>
305 305
                                 </p>
306 306
                             </div>
307 307
                         </div>
308 308
 
309 309
                         <div class="row">
310 310
                             <div class="col s12 m3 label">
311
-                                <label for="aws_key"><?php echo __( "S3 Key", 'xcloner-backup-and-restore' ) ?></label>
311
+                                <label for="aws_key"><?php echo __("S3 Key", 'xcloner-backup-and-restore') ?></label>
312 312
                             </div>
313 313
                             <div class=" col s12 m6">
314
-                                <input placeholder="<?php echo __( "S3 Key", 'xcloner-backup-and-restore' ) ?>"
314
+                                <input placeholder="<?php echo __("S3 Key", 'xcloner-backup-and-restore') ?>"
315 315
                                        id="aws_key" type="text" name="xcloner_aws_key" class="validate"
316
-                                       value="<?php echo get_option( "xcloner_aws_key" ) ?>" autocomplete="off">
316
+                                       value="<?php echo get_option("xcloner_aws_key") ?>" autocomplete="off">
317 317
                             </div>
318 318
                         </div>
319 319
 
320 320
                         <div class="row">
321 321
                             <div class="col s12 m3 label">
322
-                                <label for="aws_secret"><?php echo __( "S3 Secret", 'xcloner-backup-and-restore' ) ?></label>
322
+                                <label for="aws_secret"><?php echo __("S3 Secret", 'xcloner-backup-and-restore') ?></label>
323 323
                             </div>
324 324
                             <div class=" col s12 m6">
325
-                                <input placeholder="<?php echo __( "S3 Secret", 'xcloner-backup-and-restore' ) ?>"
325
+                                <input placeholder="<?php echo __("S3 Secret", 'xcloner-backup-and-restore') ?>"
326 326
                                        id="aws_secret" type="text" name="xcloner_aws_secret" class="validate"
327
-                                       value="<?php echo get_option( "xcloner_aws_secret" ) ?>" autocomplete="off">
327
+                                       value="<?php echo get_option("xcloner_aws_secret") ?>" autocomplete="off">
328 328
                             </div>
329 329
                         </div>
330 330
 
331 331
                         <div class="row">
332 332
                             <div class="col s12 m3 label">
333
-                                <label for="aws_region"><?php echo __( "S3 Region", 'xcloner-backup-and-restore' ) ?></label>
333
+                                <label for="aws_region"><?php echo __("S3 Region", 'xcloner-backup-and-restore') ?></label>
334 334
                             </div>
335 335
                             <div class=" col s12 m6">
336
-                                <select placeholder="<?php echo __( "example: us-east-1", 'xcloner-backup-and-restore' ) ?>"
336
+                                <select placeholder="<?php echo __("example: us-east-1", 'xcloner-backup-and-restore') ?>"
337 337
                                         id="aws_region" type="text" name="xcloner_aws_region" class="validate"
338
-                                        value="<?php echo get_option( "xcloner_aws_region" ) ?>" autocomplete="off">
338
+                                        value="<?php echo get_option("xcloner_aws_region") ?>" autocomplete="off">
339 339
                                     <option readonly
340
-                                            value=""><?php echo __( "Please Select AWS S3 Region or Leave Unselected for Custom Endpoint" ) ?></option>
340
+                                            value=""><?php echo __("Please Select AWS S3 Region or Leave Unselected for Custom Endpoint") ?></option>
341 341
 									<?php
342 342
 									$aws_regions = $remote_storage->get_aws_regions();
343 343
 
344
-									foreach ( $aws_regions as $key => $region ) {
344
+									foreach ($aws_regions as $key => $region) {
345 345
 										?>
346
-                                        <option value="<?php echo $key ?>" <?php echo( $key == get_option( 'xcloner_aws_region' ) ? "selected" : "" ) ?>><?php echo $region ?>
346
+                                        <option value="<?php echo $key ?>" <?php echo($key == get_option('xcloner_aws_region') ? "selected" : "") ?>><?php echo $region ?>
347 347
                                             = <?php echo $key ?></option>
348 348
 										<?php
349 349
 									}
@@ -354,59 +354,59 @@  discard block
 block discarded – undo
354 354
 
355 355
                         <div class="row">
356 356
                             <div class="col s12 m3 label">
357
-                                <label for="aws_endpoint"><?php echo __( "S3 EndPoint", 'xcloner-backup-and-restore' ) ?></label>
357
+                                <label for="aws_endpoint"><?php echo __("S3 EndPoint", 'xcloner-backup-and-restore') ?></label>
358 358
                             </div>
359 359
                             <div class=" col s12 m6">
360
-                                <input placeholder="<?php echo __( "S3 EndPoint, leave blank if you want to use the default Amazon AWS Service", 'xcloner-backup-and-restore' ) ?>"
360
+                                <input placeholder="<?php echo __("S3 EndPoint, leave blank if you want to use the default Amazon AWS Service", 'xcloner-backup-and-restore') ?>"
361 361
                                        id="aws_endpoint" type="text" name="xcloner_aws_endpoint" class="validate"
362
-                                       value="<?php echo get_option( "xcloner_aws_endpoint" ) ?>" autocomplete="off">
362
+                                       value="<?php echo get_option("xcloner_aws_endpoint") ?>" autocomplete="off">
363 363
                             </div>
364 364
                         </div>
365 365
 
366 366
                         <div class="row">
367 367
                             <div class="col s12 m3 label">
368
-                                <label for="aws_bucket_name"><?php echo __( "S3 Bucket Name", 'xcloner-backup-and-restore' ) ?></label>
368
+                                <label for="aws_bucket_name"><?php echo __("S3 Bucket Name", 'xcloner-backup-and-restore') ?></label>
369 369
                             </div>
370 370
                             <div class=" col s12 m6">
371
-                                <input placeholder="<?php echo __( "S3 Bucket Name", 'xcloner-backup-and-restore' ) ?>"
371
+                                <input placeholder="<?php echo __("S3 Bucket Name", 'xcloner-backup-and-restore') ?>"
372 372
                                        id="aws_bucket_name" type="text" name="xcloner_aws_bucket_name" class="validate"
373
-                                       value="<?php echo get_option( "xcloner_aws_bucket_name" ) ?>" autocomplete="off">
373
+                                       value="<?php echo get_option("xcloner_aws_bucket_name") ?>" autocomplete="off">
374 374
                             </div>
375 375
                         </div>
376 376
 
377 377
                         <div class="row">
378 378
                             <div class="col s12 m3 label">
379
-                                <label for="aws_prefix"><?php echo __( "S3 Prefix", 'xcloner-backup-and-restore' ) ?></label>
379
+                                <label for="aws_prefix"><?php echo __("S3 Prefix", 'xcloner-backup-and-restore') ?></label>
380 380
                             </div>
381 381
                             <div class=" col s12 m6">
382
-                                <input placeholder="<?php echo __( "S3 Prefix, use / ending to define a folder", 'xcloner-backup-and-restore' ) ?>"
382
+                                <input placeholder="<?php echo __("S3 Prefix, use / ending to define a folder", 'xcloner-backup-and-restore') ?>"
383 383
                                        id="aws_prefix" type="text" name="xcloner_aws_prefix" class="validate"
384
-                                       value="<?php echo get_option( "xcloner_aws_prefix" ) ?>" autocomplete="off">
384
+                                       value="<?php echo get_option("xcloner_aws_prefix") ?>" autocomplete="off">
385 385
                             </div>
386 386
                         </div>
387 387
 
388 388
                         <div class="row">
389 389
                             <div class="col s12 m3 label">
390
-                                <label for="aws_cleanup_days"><?php echo __( "S3 Cleanup (days)", 'xcloner-backup-and-restore' ) ?></label>
390
+                                <label for="aws_cleanup_days"><?php echo __("S3 Cleanup (days)", 'xcloner-backup-and-restore') ?></label>
391 391
                             </div>
392 392
                             <div class=" col s12 m6">
393
-                                <input placeholder="<?php echo __( "how many days to keep the backups for", 'xcloner-backup-and-restore' ) ?>"
393
+                                <input placeholder="<?php echo __("how many days to keep the backups for", 'xcloner-backup-and-restore') ?>"
394 394
                                        id="aws_cleanup_days" type="text" name="xcloner_aws_cleanup_days"
395
-                                       class="validate" value="<?php echo get_option( "xcloner_aws_cleanup_days" ) ?>">
395
+                                       class="validate" value="<?php echo get_option("xcloner_aws_cleanup_days") ?>">
396 396
                             </div>
397 397
                         </div>
398 398
 
399 399
                         <div class="row">
400 400
                             <div class="col s6 m4">
401 401
                                 <button class="btn waves-effect waves-light" type="submit" name="action" id="action"
402
-                                        value="aws"><?php echo __( "Save Settings", 'xcloner-backup-and-restore' ) ?>
402
+                                        value="aws"><?php echo __("Save Settings", 'xcloner-backup-and-restore') ?>
403 403
                                     <i class="material-icons right">save</i>
404 404
                                 </button>
405 405
                             </div>
406 406
                             <div class="col s6 m4">
407 407
                                 <button class="btn waves-effect waves-light orange" type="submit" name="action"
408 408
                                         id="action" value="aws"
409
-                                        onclick="jQuery('#connection_check').val('1')"><?php echo __( "Verify", 'xcloner-backup-and-restore' ) ?>
409
+                                        onclick="jQuery('#connection_check').val('1')"><?php echo __("Verify", 'xcloner-backup-and-restore') ?>
410 410
                                     <i class="material-icons right">import_export</i>
411 411
                                 </button>
412 412
                             </div>
@@ -418,12 +418,12 @@  discard block
 block discarded – undo
418 418
                 <!-- DROPBOX STORAGE-->
419 419
                 <li id="dropbox">
420 420
                     <div class="collapsible-header">
421
-                        <i class="material-icons">computer</i><?php echo __( "Dropbox Storage", 'xcloner-backup-and-restore' ) ?>
421
+                        <i class="material-icons">computer</i><?php echo __("Dropbox Storage", 'xcloner-backup-and-restore') ?>
422 422
                         <div class="switch right">
423 423
                             <label>
424 424
                                 Off
425 425
                                 <input type="checkbox" name="xcloner_dropbox_enable" class="status"
426
-                                       value="1" <?php if ( get_option( "xcloner_dropbox_enable" ) )
426
+                                       value="1" <?php if (get_option("xcloner_dropbox_enable"))
427 427
 									echo "checked" ?> \>
428 428
                                 <span class="lever"></span>
429 429
                                 On
@@ -438,20 +438,20 @@  discard block
 block discarded – undo
438 438
                             </div>
439 439
                             <div class=" col s12 m6">
440 440
                                 <p>
441
-									<?php echo sprintf( __( 'Visit %s and get your "App secret".' ), "<a href='https://www.dropbox.com/developers/apps' target='_blank'>https://www.dropbox.com/developers/apps</a>" ) ?>
441
+									<?php echo sprintf(__('Visit %s and get your "App secret".'), "<a href='https://www.dropbox.com/developers/apps' target='_blank'>https://www.dropbox.com/developers/apps</a>") ?>
442 442
                                 </p>
443 443
                             </div>
444 444
                         </div>
445 445
 
446 446
                         <div class="row">
447 447
                             <div class="col s12 m3 label">
448
-                                <label for="dropbox_access_token"><?php echo __( "Dropbox Access Token", 'xcloner-backup-and-restore' ) ?></label>
448
+                                <label for="dropbox_access_token"><?php echo __("Dropbox Access Token", 'xcloner-backup-and-restore') ?></label>
449 449
                             </div>
450 450
                             <div class=" col s12 m6">
451
-                                <input placeholder="<?php echo __( "Dropbox Access Token", 'xcloner-backup-and-restore' ) ?>"
451
+                                <input placeholder="<?php echo __("Dropbox Access Token", 'xcloner-backup-and-restore') ?>"
452 452
                                        id="dropbox_access_token" type="text" name="xcloner_dropbox_access_token"
453 453
                                        class="validate"
454
-                                       value="<?php echo get_option( "xcloner_dropbox_access_token" ) ?>"
454
+                                       value="<?php echo get_option("xcloner_dropbox_access_token") ?>"
455 455
                                        autocomplete="off">
456 456
                             </div>
457 457
                         </div>
@@ -459,50 +459,50 @@  discard block
 block discarded – undo
459 459
 
460 460
                         <div class="row">
461 461
                             <div class="col s12 m3 label">
462
-                                <label for="dropbox_app_secret"><?php echo __( "Dropbox App Secret", 'xcloner-backup-and-restore' ) ?></label>
462
+                                <label for="dropbox_app_secret"><?php echo __("Dropbox App Secret", 'xcloner-backup-and-restore') ?></label>
463 463
                             </div>
464 464
                             <div class=" col s12 m6">
465
-                                <input placeholder="<?php echo __( "Dropbox App Secret", 'xcloner-backup-and-restore' ) ?>"
465
+                                <input placeholder="<?php echo __("Dropbox App Secret", 'xcloner-backup-and-restore') ?>"
466 466
                                        id="dropbox_app_secret" type="text" name="xcloner_dropbox_app_secret"
467
-                                       class="validate" value="<?php echo get_option( "xcloner_dropbox_app_secret" ) ?>"
467
+                                       class="validate" value="<?php echo get_option("xcloner_dropbox_app_secret") ?>"
468 468
                                        autocomplete="off">
469 469
                             </div>
470 470
                         </div>
471 471
 
472 472
                         <div class="row">
473 473
                             <div class="col s12 m3 label">
474
-                                <label for="dropbox_prefix"><?php echo __( "Dropbox Prefix", 'xcloner-backup-and-restore' ) ?></label>
474
+                                <label for="dropbox_prefix"><?php echo __("Dropbox Prefix", 'xcloner-backup-and-restore') ?></label>
475 475
                             </div>
476 476
                             <div class=" col s12 m6">
477
-                                <input placeholder="<?php echo __( "Dropbox Prefix", 'xcloner-backup-and-restore' ) ?>"
477
+                                <input placeholder="<?php echo __("Dropbox Prefix", 'xcloner-backup-and-restore') ?>"
478 478
                                        id="dropbox_prefix" type="text" name="xcloner_dropbox_prefix" class="validate"
479
-                                       value="<?php echo get_option( "xcloner_dropbox_prefix" ) ?>">
479
+                                       value="<?php echo get_option("xcloner_dropbox_prefix") ?>">
480 480
                             </div>
481 481
                         </div>
482 482
 
483 483
                         <div class="row">
484 484
                             <div class="col s12 m3 label">
485
-                                <label for="dropbox_cleanup_days"><?php echo __( "Dropbox Cleanup (days)", 'xcloner-backup-and-restore' ) ?></label>
485
+                                <label for="dropbox_cleanup_days"><?php echo __("Dropbox Cleanup (days)", 'xcloner-backup-and-restore') ?></label>
486 486
                             </div>
487 487
                             <div class=" col s12 m6">
488
-                                <input placeholder="<?php echo __( "how many days to keep the backups for", 'xcloner-backup-and-restore' ) ?>"
488
+                                <input placeholder="<?php echo __("how many days to keep the backups for", 'xcloner-backup-and-restore') ?>"
489 489
                                        id="dropbox_cleanup_days" type="text" name="xcloner_dropbox_cleanup_days"
490 490
                                        class="validate"
491
-                                       value="<?php echo get_option( "xcloner_dropbox_cleanup_days" ) ?>">
491
+                                       value="<?php echo get_option("xcloner_dropbox_cleanup_days") ?>">
492 492
                             </div>
493 493
                         </div>
494 494
 
495 495
                         <div class="row">
496 496
                             <div class="col s6 m4">
497 497
                                 <button class="btn waves-effect waves-light" type="submit" name="action" id="action"
498
-                                        value="dropbox"><?php echo __( "Save Settings", 'xcloner-backup-and-restore' ) ?>
498
+                                        value="dropbox"><?php echo __("Save Settings", 'xcloner-backup-and-restore') ?>
499 499
                                     <i class="material-icons right">save</i>
500 500
                                 </button>
501 501
                             </div>
502 502
                             <div class="col s6 m4">
503 503
                                 <button class="btn waves-effect waves-light orange" type="submit" name="action"
504 504
                                         id="action" value="dropbox"
505
-                                        onclick="jQuery('#connection_check').val('1')"><?php echo __( "Verify", 'xcloner-backup-and-restore' ) ?>
505
+                                        onclick="jQuery('#connection_check').val('1')"><?php echo __("Verify", 'xcloner-backup-and-restore') ?>
506 506
                                     <i class="material-icons right">import_export</i>
507 507
                                 </button>
508 508
                             </div>
@@ -514,12 +514,12 @@  discard block
 block discarded – undo
514 514
                 <!-- AZURE STORAGE-->
515 515
                 <li id="azure">
516 516
                     <div class="collapsible-header">
517
-                        <i class="material-icons">computer</i><?php echo __( "Azure Blob Storage", 'xcloner-backup-and-restore' ) ?>
517
+                        <i class="material-icons">computer</i><?php echo __("Azure Blob Storage", 'xcloner-backup-and-restore') ?>
518 518
                         <div class="switch right">
519 519
                             <label>
520 520
                                 Off
521 521
                                 <input type="checkbox" name="xcloner_azure_enable" class="status"
522
-                                       value="1" <?php if ( get_option( "xcloner_azure_enable" ) )
522
+                                       value="1" <?php if (get_option("xcloner_azure_enable"))
523 523
 									echo "checked" ?> \>
524 524
                                 <span class="lever"></span>
525 525
                                 On
@@ -534,19 +534,19 @@  discard block
 block discarded – undo
534 534
                             </div>
535 535
                             <div class=" col s12 m6">
536 536
                                 <p>
537
-									<?php echo sprintf( __( 'Visit %s and get your "Api Key".', 'xcloner-backup-and-restore' ), '<a href="https://azure.microsoft.com/en-us/services/storage/blobs/" target="_blank">https://azure.microsoft.com/en-us/services/storage/blobs/</a>' ) ?>
537
+									<?php echo sprintf(__('Visit %s and get your "Api Key".', 'xcloner-backup-and-restore'), '<a href="https://azure.microsoft.com/en-us/services/storage/blobs/" target="_blank">https://azure.microsoft.com/en-us/services/storage/blobs/</a>') ?>
538 538
                                 </p>
539 539
                             </div>
540 540
                         </div>
541 541
 
542 542
                         <div class="row">
543 543
                             <div class="col s12 m3 label">
544
-                                <label for="azure_account_name"><?php echo __( "Azure Account Name", 'xcloner-backup-and-restore' ) ?></label>
544
+                                <label for="azure_account_name"><?php echo __("Azure Account Name", 'xcloner-backup-and-restore') ?></label>
545 545
                             </div>
546 546
                             <div class=" col s12 m6">
547
-                                <input placeholder="<?php echo __( "Azure Account Name", 'xcloner-backup-and-restore' ) ?>"
547
+                                <input placeholder="<?php echo __("Azure Account Name", 'xcloner-backup-and-restore') ?>"
548 548
                                        id="azure_account_name" type="text" name="xcloner_azure_account_name"
549
-                                       class="validate" value="<?php echo get_option( "xcloner_azure_account_name" ) ?>"
549
+                                       class="validate" value="<?php echo get_option("xcloner_azure_account_name") ?>"
550 550
                                        autocomplete="off">
551 551
                             </div>
552 552
                         </div>
@@ -554,49 +554,49 @@  discard block
 block discarded – undo
554 554
 
555 555
                         <div class="row">
556 556
                             <div class="col s12 m3 label">
557
-                                <label for="azure_api_key"><?php echo __( "Azure Api Key", 'xcloner-backup-and-restore' ) ?></label>
557
+                                <label for="azure_api_key"><?php echo __("Azure Api Key", 'xcloner-backup-and-restore') ?></label>
558 558
                             </div>
559 559
                             <div class=" col s12 m6">
560
-                                <input placeholder="<?php echo __( "Azure Api Key", 'xcloner-backup-and-restore' ) ?>"
560
+                                <input placeholder="<?php echo __("Azure Api Key", 'xcloner-backup-and-restore') ?>"
561 561
                                        id="azure_api_key" type="text" name="xcloner_azure_api_key" class="validate"
562
-                                       value="<?php echo get_option( "xcloner_azure_api_key" ) ?>" autocomplete="off">
562
+                                       value="<?php echo get_option("xcloner_azure_api_key") ?>" autocomplete="off">
563 563
                             </div>
564 564
                         </div>
565 565
 
566 566
                         <div class="row">
567 567
                             <div class="col s12 m3 label">
568
-                                <label for="azure_container"><?php echo __( "Azure Container", 'xcloner-backup-and-restore' ) ?></label>
568
+                                <label for="azure_container"><?php echo __("Azure Container", 'xcloner-backup-and-restore') ?></label>
569 569
                             </div>
570 570
                             <div class=" col s12 m6">
571
-                                <input placeholder="<?php echo __( "Azure Container", 'xcloner-backup-and-restore' ) ?>"
571
+                                <input placeholder="<?php echo __("Azure Container", 'xcloner-backup-and-restore') ?>"
572 572
                                        id="azure_container" type="text" name="xcloner_azure_container" class="validate"
573
-                                       value="<?php echo get_option( "xcloner_azure_container" ) ?>">
573
+                                       value="<?php echo get_option("xcloner_azure_container") ?>">
574 574
                             </div>
575 575
                         </div>
576 576
 
577 577
                         <div class="row">
578 578
                             <div class="col s12 m3 label">
579
-                                <label for="azure_cleanup_days"><?php echo __( "Azure Cleanup (days)", 'xcloner-backup-and-restore' ) ?></label>
579
+                                <label for="azure_cleanup_days"><?php echo __("Azure Cleanup (days)", 'xcloner-backup-and-restore') ?></label>
580 580
                             </div>
581 581
                             <div class=" col s12 m6">
582
-                                <input placeholder="<?php echo __( "how many days to keep the backups for", 'xcloner-backup-and-restore' ) ?>"
582
+                                <input placeholder="<?php echo __("how many days to keep the backups for", 'xcloner-backup-and-restore') ?>"
583 583
                                        id="azure_cleanup_days" type="text" name="xcloner_azure_cleanup_days"
584 584
                                        class="validate"
585
-                                       value="<?php echo get_option( "xcloner_azure_cleanup_days" ) ?>">
585
+                                       value="<?php echo get_option("xcloner_azure_cleanup_days") ?>">
586 586
                             </div>
587 587
                         </div>
588 588
 
589 589
                         <div class="row">
590 590
                             <div class="col s6 m4">
591 591
                                 <button class="btn waves-effect waves-light" type="submit" name="action" id="action"
592
-                                        value="azure"><?php echo __( "Save Settings", 'xcloner-backup-and-restore' ) ?>
592
+                                        value="azure"><?php echo __("Save Settings", 'xcloner-backup-and-restore') ?>
593 593
                                     <i class="material-icons right">save</i>
594 594
                                 </button>
595 595
                             </div>
596 596
                             <div class="col s6 m4">
597 597
                                 <button class="btn waves-effect waves-light orange" type="submit" name="action"
598 598
                                         id="action" value="azure"
599
-                                        onclick="jQuery('#connection_check').val('1')"><?php echo __( "Verify", 'xcloner-backup-and-restore' ) ?>
599
+                                        onclick="jQuery('#connection_check').val('1')"><?php echo __("Verify", 'xcloner-backup-and-restore') ?>
600 600
                                     <i class="material-icons right">import_export</i>
601 601
                                 </button>
602 602
                             </div>
@@ -608,12 +608,12 @@  discard block
 block discarded – undo
608 608
                 <!-- BACKBLAZE STORAGE-->
609 609
                 <li id="backblaze">
610 610
                     <div class="collapsible-header">
611
-                        <i class="material-icons">computer</i><?php echo __( "Backblaze Storage", 'xcloner-backup-and-restore' ) ?>
611
+                        <i class="material-icons">computer</i><?php echo __("Backblaze Storage", 'xcloner-backup-and-restore') ?>
612 612
                         <div class="switch right">
613 613
                             <label>
614 614
                                 Off
615 615
                                 <input type="checkbox" name="xcloner_backblaze_enable" class="status"
616
-                                       value="1" <?php if ( get_option( "xcloner_backblaze_enable" ) )
616
+                                       value="1" <?php if (get_option("xcloner_backblaze_enable"))
617 617
 									echo "checked" ?> \>
618 618
                                 <span class="lever"></span>
619 619
                                 On
@@ -628,20 +628,20 @@  discard block
 block discarded – undo
628 628
                             </div>
629 629
                             <div class=" col s12 m6">
630 630
                                 <p>
631
-									<?php echo sprintf( __( 'Visit %s and get your Account Id and  Application Key.', 'xcloner-backup-and-restore' ), '<a href="https://secure.backblaze.com/b2_buckets.htm" target="_blank">https://secure.backblaze.com/b2_buckets.htm</a>' ) ?>
631
+									<?php echo sprintf(__('Visit %s and get your Account Id and  Application Key.', 'xcloner-backup-and-restore'), '<a href="https://secure.backblaze.com/b2_buckets.htm" target="_blank">https://secure.backblaze.com/b2_buckets.htm</a>') ?>
632 632
                                 </p>
633 633
                             </div>
634 634
                         </div>
635 635
 
636 636
                         <div class="row">
637 637
                             <div class="col s12 m3 label">
638
-                                <label for="backblaze_account_id"><?php echo __( "Backblaze Account Id", 'xcloner-backup-and-restore' ) ?></label>
638
+                                <label for="backblaze_account_id"><?php echo __("Backblaze Account Id", 'xcloner-backup-and-restore') ?></label>
639 639
                             </div>
640 640
                             <div class=" col s12 m6">
641
-                                <input placeholder="<?php echo __( "Backblaze Account Id", 'xcloner-backup-and-restore' ) ?>"
641
+                                <input placeholder="<?php echo __("Backblaze Account Id", 'xcloner-backup-and-restore') ?>"
642 642
                                        id="backblaze_account_id" type="text" name="xcloner_backblaze_account_id"
643 643
                                        class="validate"
644
-                                       value="<?php echo get_option( "xcloner_backblaze_account_id" ) ?>"
644
+                                       value="<?php echo get_option("xcloner_backblaze_account_id") ?>"
645 645
                                        autocomplete="off">
646 646
                             </div>
647 647
                         </div>
@@ -649,53 +649,53 @@  discard block
 block discarded – undo
649 649
 
650 650
                         <div class="row">
651 651
                             <div class="col s12 m3 label">
652
-                                <label for="backblaze_application_key"><?php echo __( "Backblaze Application Key", 'xcloner-backup-and-restore' ) ?></label>
652
+                                <label for="backblaze_application_key"><?php echo __("Backblaze Application Key", 'xcloner-backup-and-restore') ?></label>
653 653
                             </div>
654 654
                             <div class=" col s12 m6">
655
-                                <input placeholder="<?php echo __( "Backblaze Application Key", 'xcloner-backup-and-restore' ) ?>"
655
+                                <input placeholder="<?php echo __("Backblaze Application Key", 'xcloner-backup-and-restore') ?>"
656 656
                                        id="backblaze_application_key" type="text"
657 657
                                        name="xcloner_backblaze_application_key" class="validate"
658
-                                       value="<?php echo get_option( "xcloner_backblaze_application_key" ) ?>"
658
+                                       value="<?php echo get_option("xcloner_backblaze_application_key") ?>"
659 659
                                        autocomplete="off">
660 660
                             </div>
661 661
                         </div>
662 662
 
663 663
                         <div class="row">
664 664
                             <div class="col s12 m3 label">
665
-                                <label for="backblaze_bucket_name"><?php echo __( "Backblaze Bucket Name", 'xcloner-backup-and-restore' ) ?></label>
665
+                                <label for="backblaze_bucket_name"><?php echo __("Backblaze Bucket Name", 'xcloner-backup-and-restore') ?></label>
666 666
                             </div>
667 667
                             <div class=" col s12 m6">
668
-                                <input placeholder="<?php echo __( "Backblaze Bucket Name", 'xcloner-backup-and-restore' ) ?>"
668
+                                <input placeholder="<?php echo __("Backblaze Bucket Name", 'xcloner-backup-and-restore') ?>"
669 669
                                        id="backblaze_bucket_name" type="text" name="xcloner_backblaze_bucket_name"
670 670
                                        class="validate"
671
-                                       value="<?php echo get_option( "xcloner_backblaze_bucket_name" ) ?>"
671
+                                       value="<?php echo get_option("xcloner_backblaze_bucket_name") ?>"
672 672
                                        autocomplete="off">
673 673
                             </div>
674 674
                         </div>
675 675
 
676 676
                         <div class="row">
677 677
                             <div class="col s12 m3 label">
678
-                                <label for="backblaze_cleanup_days"><?php echo __( "Backblaze Cleanup (days)", 'xcloner-backup-and-restore' ) ?></label>
678
+                                <label for="backblaze_cleanup_days"><?php echo __("Backblaze Cleanup (days)", 'xcloner-backup-and-restore') ?></label>
679 679
                             </div>
680 680
                             <div class=" col s12 m6">
681
-                                <input placeholder="<?php echo __( "how many days to keep the backups for", 'xcloner-backup-and-restore' ) ?>"
681
+                                <input placeholder="<?php echo __("how many days to keep the backups for", 'xcloner-backup-and-restore') ?>"
682 682
                                        id="backblaze_cleanup_days" type="text" name="xcloner_backblaze_cleanup_days"
683 683
                                        class="validate"
684
-                                       value="<?php echo get_option( "xcloner_backblaze_cleanup_days" ) ?>">
684
+                                       value="<?php echo get_option("xcloner_backblaze_cleanup_days") ?>">
685 685
                             </div>
686 686
                         </div>
687 687
 
688 688
                         <div class="row">
689 689
                             <div class="col s6 m4">
690 690
                                 <button class="btn waves-effect waves-light" type="submit" name="action" id="action"
691
-                                        value="backblaze"><?php echo __( "Save Settings", 'xcloner-backup-and-restore' ) ?>
691
+                                        value="backblaze"><?php echo __("Save Settings", 'xcloner-backup-and-restore') ?>
692 692
                                     <i class="material-icons right">save</i>
693 693
                                 </button>
694 694
                             </div>
695 695
                             <div class="col s6 m4">
696 696
                                 <button class="btn waves-effect waves-light orange" type="submit" name="action"
697 697
                                         id="action" value="backblaze"
698
-                                        onclick="jQuery('#connection_check').val('1')"><?php echo __( "Verify", 'xcloner-backup-and-restore' ) ?>
698
+                                        onclick="jQuery('#connection_check').val('1')"><?php echo __("Verify", 'xcloner-backup-and-restore') ?>
699 699
                                     <i class="material-icons right">import_export</i>
700 700
                                 </button>
701 701
                             </div>
@@ -707,12 +707,12 @@  discard block
 block discarded – undo
707 707
                 <!-- WEBDAV STORAGE-->
708 708
                 <li id="webdav">
709 709
                     <div class="collapsible-header">
710
-                        <i class="material-icons">computer</i><?php echo __( "WebDAV Storage", 'xcloner-backup-and-restore' ) ?>
710
+                        <i class="material-icons">computer</i><?php echo __("WebDAV Storage", 'xcloner-backup-and-restore') ?>
711 711
                         <div class="switch right">
712 712
                             <label>
713 713
                                 Off
714 714
                                 <input type="checkbox" name="xcloner_webdav_enable" class="status"
715
-                                       value="1" <?php if ( get_option( "xcloner_webdav_enable" ) )
715
+                                       value="1" <?php if (get_option("xcloner_webdav_enable"))
716 716
 									echo "checked" ?> \>
717 717
                                 <span class="lever"></span>
718 718
                                 On
@@ -734,74 +734,74 @@  discard block
 block discarded – undo
734 734
 
735 735
                         <div class="row">
736 736
                             <div class="col s12 m3 label">
737
-                                <label for="webdav_url"><?php echo __( "WebDAV Base Url", 'xcloner-backup-and-restore' ) ?></label>
737
+                                <label for="webdav_url"><?php echo __("WebDAV Base Url", 'xcloner-backup-and-restore') ?></label>
738 738
                             </div>
739 739
                             <div class=" col s12 m6">
740
-                                <input placeholder="<?php echo __( "WebDAV Base Url", 'xcloner-backup-and-restore' ) ?>"
740
+                                <input placeholder="<?php echo __("WebDAV Base Url", 'xcloner-backup-and-restore') ?>"
741 741
                                        id="webdav_url" type="text" name="xcloner_webdav_url" class="validate"
742
-                                       value="<?php echo get_option( "xcloner_webdav_url" ) ?>" autocomplete="off">
742
+                                       value="<?php echo get_option("xcloner_webdav_url") ?>" autocomplete="off">
743 743
                             </div>
744 744
                         </div>
745 745
 
746 746
                         <div class="row">
747 747
                             <div class="col s12 m3 label">
748
-                                <label for="webdav_username"><?php echo __( "WebDAV Username", 'xcloner-backup-and-restore' ) ?></label>
748
+                                <label for="webdav_username"><?php echo __("WebDAV Username", 'xcloner-backup-and-restore') ?></label>
749 749
                             </div>
750 750
                             <div class=" col s12 m6">
751
-                                <input placeholder="<?php echo __( "WebDAV Username", 'xcloner-backup-and-restore' ) ?>"
751
+                                <input placeholder="<?php echo __("WebDAV Username", 'xcloner-backup-and-restore') ?>"
752 752
                                        id="webdav_username" type="text" name="xcloner_webdav_username" class="validate"
753
-                                       value="<?php echo get_option( "xcloner_webdav_username" ) ?>" autocomplete="off">
753
+                                       value="<?php echo get_option("xcloner_webdav_username") ?>" autocomplete="off">
754 754
                             </div>
755 755
                         </div>
756 756
 
757 757
                         <div class="row">
758 758
                             <div class="col s12 m3 label">
759
-                                <label for="webdav_password"><?php echo __( "WebDAV Password", 'xcloner-backup-and-restore' ) ?></label>
759
+                                <label for="webdav_password"><?php echo __("WebDAV Password", 'xcloner-backup-and-restore') ?></label>
760 760
                             </div>
761 761
                             <div class=" col s12 m6">
762
-                                <input placeholder="<?php echo __( "WebDAV Password", 'xcloner-backup-and-restore' ) ?>"
762
+                                <input placeholder="<?php echo __("WebDAV Password", 'xcloner-backup-and-restore') ?>"
763 763
                                        id="webdav_password" type="password" name="xcloner_webdav_password"
764
-                                       class="validate" value="<?php echo get_option( "xcloner_webdav_password" ) ?>"
764
+                                       class="validate" value="<?php echo get_option("xcloner_webdav_password") ?>"
765 765
                                        autocomplete="off">
766 766
                             </div>
767 767
                         </div>
768 768
 
769 769
                         <div class="row">
770 770
                             <div class="col s12 m3 label">
771
-                                <label for="webdav_target_folder"><?php echo __( "WebDAV Target Folder", 'xcloner-backup-and-restore' ) ?></label>
771
+                                <label for="webdav_target_folder"><?php echo __("WebDAV Target Folder", 'xcloner-backup-and-restore') ?></label>
772 772
                             </div>
773 773
                             <div class=" col s12 m6">
774
-                                <input placeholder="<?php echo __( "WebDAV Target Folder", 'xcloner-backup-and-restore' ) ?>"
774
+                                <input placeholder="<?php echo __("WebDAV Target Folder", 'xcloner-backup-and-restore') ?>"
775 775
                                        id="webdav_target_folder" type="text" name="xcloner_webdav_target_folder"
776 776
                                        class="validate"
777
-                                       value="<?php echo get_option( "xcloner_webdav_target_folder" ) ?>"
777
+                                       value="<?php echo get_option("xcloner_webdav_target_folder") ?>"
778 778
                                        autocomplete="off">
779 779
                             </div>
780 780
                         </div>
781 781
 
782 782
                         <div class="row">
783 783
                             <div class="col s12 m3 label">
784
-                                <label for="webdav_cleanup_days"><?php echo __( "WebDAV Cleanup (days)", 'xcloner-backup-and-restore' ) ?></label>
784
+                                <label for="webdav_cleanup_days"><?php echo __("WebDAV Cleanup (days)", 'xcloner-backup-and-restore') ?></label>
785 785
                             </div>
786 786
                             <div class=" col s12 m6">
787
-                                <input placeholder="<?php echo __( "how many days to keep the backups for", 'xcloner-backup-and-restore' ) ?>"
787
+                                <input placeholder="<?php echo __("how many days to keep the backups for", 'xcloner-backup-and-restore') ?>"
788 788
                                        id="webdav_cleanup_days" type="text" name="xcloner_webdav_cleanup_days"
789 789
                                        class="validate"
790
-                                       value="<?php echo get_option( "xcloner_webdav_cleanup_days" ) ?>">
790
+                                       value="<?php echo get_option("xcloner_webdav_cleanup_days") ?>">
791 791
                             </div>
792 792
                         </div>
793 793
 
794 794
                         <div class="row">
795 795
                             <div class="col s6 m4">
796 796
                                 <button class="btn waves-effect waves-light" type="submit" name="action" id="action"
797
-                                        value="webdav"><?php echo __( "Save Settings", 'xcloner-backup-and-restore' ) ?>
797
+                                        value="webdav"><?php echo __("Save Settings", 'xcloner-backup-and-restore') ?>
798 798
                                     <i class="material-icons right">save</i>
799 799
                                 </button>
800 800
                             </div>
801 801
                             <div class="col s6 m4">
802 802
                                 <button class="btn waves-effect waves-light orange" type="submit" name="action"
803 803
                                         id="action" value="webdav"
804
-                                        onclick="jQuery('#connection_check').val('1')"><?php echo __( "Verify", 'xcloner-backup-and-restore' ) ?>
804
+                                        onclick="jQuery('#connection_check').val('1')"><?php echo __("Verify", 'xcloner-backup-and-restore') ?>
805 805
                                     <i class="material-icons right">import_export</i>
806 806
                                 </button>
807 807
                             </div>
@@ -813,13 +813,13 @@  discard block
 block discarded – undo
813 813
                 <!-- Google DRIVE STORAGE-->
814 814
                 <li id="gdrive">
815 815
                     <div class="collapsible-header">
816
-                        <i class="material-icons">computer</i><?php echo __( "Google Drive Storage", 'xcloner-backup-and-restore' ) ?>
817
-						<?php if ( $gdrive_construct ): ?>
816
+                        <i class="material-icons">computer</i><?php echo __("Google Drive Storage", 'xcloner-backup-and-restore') ?>
817
+						<?php if ($gdrive_construct): ?>
818 818
                             <div class="switch right">
819 819
                                 <label>
820 820
                                     Off
821 821
                                     <input type="checkbox" name="xcloner_gdrive_enable" class="status"
822
-                                           value="1" <?php if ( get_option( "xcloner_gdrive_enable" ) )
822
+                                           value="1" <?php if (get_option("xcloner_gdrive_enable"))
823 823
 										echo "checked" ?> \>
824 824
                                     <span class="lever"></span>
825 825
                                     On
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
                     </div>
830 830
                     <div class="collapsible-body">
831 831
 
832
-						<?php if ( $gdrive_construct ) : ?>
832
+						<?php if ($gdrive_construct) : ?>
833 833
 
834 834
                             <div class="row">
835 835
                                 <div class="col s12 m3 label">
@@ -837,11 +837,11 @@  discard block
 block discarded – undo
837 837
                                 </div>
838 838
                                 <div class=" col s12 m9">
839 839
                                     <p>
840
-										<?php echo sprintf( __( 'Visit %s to create a new application and get your Client ID and Client Secret.', 'xcloner-backup-and-restore' ), '<a href="https://console.developers.google.com" target="_blank">https://console.developers.google.com</a>' ) ?>
840
+										<?php echo sprintf(__('Visit %s to create a new application and get your Client ID and Client Secret.', 'xcloner-backup-and-restore'), '<a href="https://console.developers.google.com" target="_blank">https://console.developers.google.com</a>') ?>
841 841
                                         <a href="https://youtu.be/YXUVPUVgG8k" target="_blank"
842 842
                                            class="btn-floating tooltipped btn-small" data-position="right"
843 843
                                            data-delay="50" data-html="true"
844
-                                           data-tooltip="<?php echo sprintf( __( 'Click here to view a short video explaining how to create the Client ID and Client Secret as well as connecting XCloner with the Google Drive API %s', 'xcloner-backup-and-restore' ), "<br />https://youtu.be/YXUVPUVgG8k" ) ?>"
844
+                                           data-tooltip="<?php echo sprintf(__('Click here to view a short video explaining how to create the Client ID and Client Secret as well as connecting XCloner with the Google Drive API %s', 'xcloner-backup-and-restore'), "<br />https://youtu.be/YXUVPUVgG8k") ?>"
845 845
                                            data-tooltip-id="92c95730-94e9-7b59-bd52-14adc30d5e3e"><i
846 846
                                                     class="material-icons">help_outline</i></a>
847 847
                                     </p>
@@ -850,25 +850,25 @@  discard block
 block discarded – undo
850 850
 
851 851
                             <div class="row">
852 852
                                 <div class="col s12 m3 label">
853
-                                    <label for="gdrive_client_id"><?php echo __( "Client ID", 'xcloner-backup-and-restore' ) ?></label>
853
+                                    <label for="gdrive_client_id"><?php echo __("Client ID", 'xcloner-backup-and-restore') ?></label>
854 854
                                 </div>
855 855
                                 <div class=" col s12 m6">
856
-                                    <input placeholder="<?php echo __( "Google Client ID", 'xcloner-backup-and-restore' ) ?>"
856
+                                    <input placeholder="<?php echo __("Google Client ID", 'xcloner-backup-and-restore') ?>"
857 857
                                            id="gdrive_client_id" type="text" name="xcloner_gdrive_client_id"
858 858
                                            class="validate"
859
-                                           value="<?php echo get_option( "xcloner_gdrive_client_id" ) ?>">
859
+                                           value="<?php echo get_option("xcloner_gdrive_client_id") ?>">
860 860
                                 </div>
861 861
                             </div>
862 862
 
863 863
                             <div class="row">
864 864
                                 <div class="col s12 m3 label">
865
-                                    <label for="gdrive_client_secret"><?php echo __( "Client Secret", 'xcloner-backup-and-restore' ) ?></label>
865
+                                    <label for="gdrive_client_secret"><?php echo __("Client Secret", 'xcloner-backup-and-restore') ?></label>
866 866
                                 </div>
867 867
                                 <div class=" col s12 m6">
868
-                                    <input placeholder="<?php echo __( "Google Client Secret", 'xcloner-backup-and-restore' ) ?>"
868
+                                    <input placeholder="<?php echo __("Google Client Secret", 'xcloner-backup-and-restore') ?>"
869 869
                                            id="gdrive_client_secret" type="text" name="xcloner_gdrive_client_secret"
870 870
                                            class="validate"
871
-                                           value="<?php echo get_option( "xcloner_gdrive_client_secret" ) ?>">
871
+                                           value="<?php echo get_option("xcloner_gdrive_client_secret") ?>">
872 872
                                 </div>
873 873
                             </div>
874 874
 
@@ -880,72 +880,72 @@  discard block
 block discarded – undo
880 880
                                 <div class=" col s12 m6">
881 881
                                     <a class="btn" target="_blank" id="gdrive_authorization_click"
882 882
                                        onclick="jQuery('#authentification_code').show()"
883
-                                       href="<?php echo $gdrive_auth_url ?>"><?php echo sprintf( __( 'Authorize Google Drive', 'xcloner-backup-and-restore' ) ) ?></a>
883
+                                       href="<?php echo $gdrive_auth_url ?>"><?php echo sprintf(__('Authorize Google Drive', 'xcloner-backup-and-restore')) ?></a>
884 884
                                     <input type="text" name="authentification_code" id="authentification_code"
885
-                                           placeholder="<?php echo __( "Paste Authorization Code Here", "xcloner-backup-and-restore" ) ?>">
885
+                                           placeholder="<?php echo __("Paste Authorization Code Here", "xcloner-backup-and-restore") ?>">
886 886
                                 </div>
887 887
                             </div>
888 888
 
889 889
                             <div class="row">
890 890
                                 <div class="col s12 m3 label">
891
-                                    <label for="gdrive_target_folder"><?php echo __( "Folder ID or Root Path", 'xcloner-backup-and-restore' ) ?>
891
+                                    <label for="gdrive_target_folder"><?php echo __("Folder ID or Root Path", 'xcloner-backup-and-restore') ?>
892 892
                                         <a class="btn-floating tooltipped btn-small" data-position="right"
893 893
                                            data-delay="50" data-html="true" \
894
-                                           data-tooltip="<?php echo __( 'Folder ID can be found by right clicking on the folder name and selecting \'Get shareable link\' menu, format https://drive.google.com/open?id={FOLDER_ID}<br />
895
-									If you supply a folder name, it has to exists in the drive root and start with / , example /backups.xcloner.com/', 'xcloner-backup-and-restore' ) ?>"
894
+                                           data-tooltip="<?php echo __('Folder ID can be found by right clicking on the folder name and selecting \'Get shareable link\' menu, format https://drive.google.com/open?id={FOLDER_ID}<br />
895
+									If you supply a folder name, it has to exists in the drive root and start with / , example /backups.xcloner.com/', 'xcloner-backup-and-restore') ?>"
896 896
                                            data-tooltip-id="92c95730-94e9-7b59-bd52-14adc30d5e3e"><i
897 897
                                                     class="material-icons">help_outline</i></a>
898 898
                                     </label>
899 899
                                 </div>
900 900
                                 <div class=" col s12 m6">
901
-                                    <input placeholder="<?php echo __( "Target Folder ID or Root Path", 'xcloner-backup-and-restore' ) ?>"
901
+                                    <input placeholder="<?php echo __("Target Folder ID or Root Path", 'xcloner-backup-and-restore') ?>"
902 902
                                            id="gdrive_target_folder" type="text" name="xcloner_gdrive_target_folder"
903 903
                                            class="validate"
904
-                                           value="<?php echo get_option( "xcloner_gdrive_target_folder" ) ?>"
904
+                                           value="<?php echo get_option("xcloner_gdrive_target_folder") ?>"
905 905
                                            autocomplete="off">
906 906
                                 </div>
907 907
                             </div>
908 908
 
909 909
                             <div class="row">
910 910
                                 <div class="col s12 m3 label">
911
-                                    <label for="gdrive_cleanup_days"><?php echo __( "Google Drive Cleanup (days)", 'xcloner-backup-and-restore' ) ?></label>
911
+                                    <label for="gdrive_cleanup_days"><?php echo __("Google Drive Cleanup (days)", 'xcloner-backup-and-restore') ?></label>
912 912
                                 </div>
913 913
                                 <div class=" col s12 m6">
914
-                                    <input placeholder="<?php echo __( "how many days to keep the backups for", 'xcloner-backup-and-restore' ) ?>"
914
+                                    <input placeholder="<?php echo __("how many days to keep the backups for", 'xcloner-backup-and-restore') ?>"
915 915
                                            id="gdrive_cleanup_days" type="text" name="xcloner_gdrive_cleanup_days"
916 916
                                            class="validate"
917
-                                           value="<?php echo get_option( "xcloner_gdrive_cleanup_days" ) ?>">
917
+                                           value="<?php echo get_option("xcloner_gdrive_cleanup_days") ?>">
918 918
                                 </div>
919 919
                             </div>
920 920
 
921 921
                             <div class="row">
922 922
                                 <div class="col s12 m3 label">
923
-                                    <label for="gdrive_empty_trash"><?php echo __( "Automatically Empty Trash?", 'xcloner-backup-and-restore' ) ?></label>
923
+                                    <label for="gdrive_empty_trash"><?php echo __("Automatically Empty Trash?", 'xcloner-backup-and-restore') ?></label>
924 924
                                 </div>
925 925
                                 <div class=" col s12 m6 input-field inline">
926 926
                                     <input name="xcloner_gdrive_empty_trash" type="radio" value="0"
927
-                                           id="gdrive_empty_trash_off" <?php if ( ! get_option( "xcloner_gdrive_empty_trash", 0 ) )
927
+                                           id="gdrive_empty_trash_off" <?php if (!get_option("xcloner_gdrive_empty_trash", 0))
928 928
 										echo "checked" ?> />
929
-                                    <label for="gdrive_empty_trash_off"><?php echo __( "Disabled", 'xcloner-backup-and-restore' ) ?></label>
929
+                                    <label for="gdrive_empty_trash_off"><?php echo __("Disabled", 'xcloner-backup-and-restore') ?></label>
930 930
 
931 931
                                     <input name="xcloner_gdrive_empty_trash" type="radio" value="1"
932
-                                           id="gdrive_empty_trash_on" <?php if ( get_option( "xcloner_gdrive_empty_trash", 0 ) )
932
+                                           id="gdrive_empty_trash_on" <?php if (get_option("xcloner_gdrive_empty_trash", 0))
933 933
 										echo "checked" ?> />
934
-                                    <label for="gdrive_empty_trash_on"><?php echo __( "Enabled", 'xcloner-backup-and-restore' ) ?></label>
934
+                                    <label for="gdrive_empty_trash_on"><?php echo __("Enabled", 'xcloner-backup-and-restore') ?></label>
935 935
                                 </div>
936 936
                             </div>
937 937
 
938 938
                             <div class="row">
939 939
                                 <div class="col s6 m4">
940 940
                                     <button class="btn waves-effect waves-light" type="submit" name="action" id="action"
941
-                                            value="gdrive"><?php echo __( "Save Settings", 'xcloner-backup-and-restore' ) ?>
941
+                                            value="gdrive"><?php echo __("Save Settings", 'xcloner-backup-and-restore') ?>
942 942
                                         <i class="material-icons right">save</i>
943 943
                                     </button>
944 944
                                 </div>
945 945
                                 <div class="col s6 m4">
946 946
                                     <button class="btn waves-effect waves-light orange" type="submit" name="action"
947 947
                                             id="action" value="gdrive"
948
-                                            onclick="jQuery('#connection_check').val('1')"><?php echo __( "Verify", 'xcloner-backup-and-restore' ) ?>
948
+                                            onclick="jQuery('#connection_check').val('1')"><?php echo __("Verify", 'xcloner-backup-and-restore') ?>
949 949
                                         <i class="material-icons right">import_export</i>
950 950
                                     </button>
951 951
                                 </div>
@@ -956,26 +956,26 @@  discard block
 block discarded – undo
956 956
                                 <div class=" col s12">
957 957
                                     <div class="center">
958 958
 										<?php
959
-										$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=xcloner-google-drive' ), 'install-plugin_xcloner-google-drive' );
959
+										$url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=xcloner-google-drive'), 'install-plugin_xcloner-google-drive');
960 960
 										?>
961
-                                        <h6><?php echo __( "This storage option requires the XCloner-Google-Drive Wordpress Plugin to be installed and activated." ) ?></h6>
962
-                                        <h6><?php echo __( "PHP 5.5 minimum version is required." ) ?></h6>
961
+                                        <h6><?php echo __("This storage option requires the XCloner-Google-Drive Wordpress Plugin to be installed and activated.") ?></h6>
962
+                                        <h6><?php echo __("PHP 5.5 minimum version is required.") ?></h6>
963 963
                                         <br/>
964 964
                                         <a class="install-now btn" data-slug="xcloner-google-drive"
965 965
                                            href="<?php echo $url; ?>"
966 966
                                            aria-label="Install XCloner Google Drive 1.0.0 now"
967 967
                                            data-name="XCloner Google Drive 1.0.0">
968
-											<?php echo sprintf( __( 'Install Now', 'xcloner-backup-and-restore' ) ) ?>
968
+											<?php echo sprintf(__('Install Now', 'xcloner-backup-and-restore')) ?>
969 969
                                         </a>
970 970
 
971
-                                        <a href="<?php echo admin_url( "plugin-install.php" ) ?>?tab=plugin-information&amp;plugin=xcloner-google-drive&amp;TB_iframe=true&amp;width=772&amp;height=499"
971
+                                        <a href="<?php echo admin_url("plugin-install.php") ?>?tab=plugin-information&amp;plugin=xcloner-google-drive&amp;TB_iframe=true&amp;width=772&amp;height=499"
972 972
                                            class="btn thickbox open-plugin-details-modal"
973 973
                                            aria-label="More information about Theme Check 20160523.1"
974 974
                                            data-title="Theme Check 20160523.1">
975 975
                                             <!--
976 976
 											<a class="btn" href="https://github.com/ovidiul/XCloner-Google-Drive/archive/master.zip">
977 977
 											-->
978
-											<?php echo sprintf( __( 'More Details', 'xcloner-backup-and-restore' ) ) ?>
978
+											<?php echo sprintf(__('More Details', 'xcloner-backup-and-restore')) ?>
979 979
                                         </a>
980 980
                                     </div>
981 981
                                 </div>
Please login to merge, or discard this patch.