GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( e65d67...dc9fa8 )
by Liuta
03:08
created
restore/xcloner_restore.php 5 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -580,6 +580,9 @@  discard block
 block discarded – undo
580 580
 		
581 581
 	}
582 582
 	
583
+	/**
584
+	 * @param mysqli $mysqli
585
+	 */
583 586
 	private function update_wp_url($wp_path, $url, $mysqli)
584 587
 	{
585 588
 		$wp_config = $wp_path.DS."wp-config.php";
@@ -886,6 +889,9 @@  discard block
 block discarded – undo
886 889
 		$this->send_response(200, $return);
887 890
 	}
888 891
 	
892
+	/**
893
+	 * @param string $val
894
+	 */
889 895
 	private function return_bytes($val) {
890 896
 	    $val = trim($val);
891 897
 	    $last = strtolower($val[strlen($val)-1]);
@@ -943,6 +949,9 @@  discard block
 block discarded – undo
943 949
 		return $files;
944 950
 	}
945 951
 	
952
+	/**
953
+	 * @param string $field
954
+	 */
946 955
 	private function sort_by( &$array, $field, $direction = 'asc')
947 956
 	{
948 957
 		$direction = strtolower($direction);
@@ -988,6 +997,9 @@  discard block
 block discarded – undo
988 997
 	 * Serialize fix methods below for mysql query lines
989 998
 	 */ 
990 999
 	 
1000
+	/**
1001
+	 * @return string
1002
+	 */
991 1003
 	function do_serialized_fix($query)
992 1004
 	{
993 1005
 		//return preg_replace('!s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!e', "'s:'.strlen(unescape_mysql('$3')).':\"'.unescape_quotes('$3').'\";'", $query);
Please login to merge, or discard this patch.
Unused Use Statements   -5 removed lines patch added patch discarded remove patch
@@ -65,13 +65,8 @@
 block discarded – undo
65 65
 
66 66
 use League\Flysystem\Config;
67 67
 use League\Flysystem\Filesystem;
68
-use League\Flysystem\Util;
69 68
 use League\Flysystem\Adapter\Local;
70
-
71 69
 use splitbrain\PHPArchive\Tar;
72
-use splitbrain\PHPArchive\Archive;
73
-use splitbrain\PHPArchive\FileInfo;
74
-
75 70
 use Monolog\Logger;
76 71
 use Monolog\Handler\StreamHandler;
77 72
 
Please login to merge, or discard this patch.
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -158,15 +158,15 @@  discard block
 block discarded – undo
158 158
 	}
159 159
 	
160 160
 	private function friendly_error_type($type) {
161
-	    static $levels=null;
162
-	    if ($levels===null) {
163
-	        $levels=[];
164
-	        foreach (get_defined_constants() as $key=>$value) {
165
-	            if (strpos($key,'E_')!==0) {continue;}
161
+		static $levels=null;
162
+		if ($levels===null) {
163
+			$levels=[];
164
+			foreach (get_defined_constants() as $key=>$value) {
165
+				if (strpos($key,'E_')!==0) {continue;}
166 166
 					$levels[$value]= $key; //substr($key,2);
167
-	        }
168
-	    }
169
-	    return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}");
167
+			}
168
+		}
169
+		return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}");
170 170
 	}
171 171
 	
172 172
 	public function get_logger_filename()
@@ -887,19 +887,19 @@  discard block
 block discarded – undo
887 887
 	}
888 888
 	
889 889
 	private function return_bytes($val) {
890
-	    $val = trim($val);
891
-	    $last = strtolower($val[strlen($val)-1]);
892
-	    switch($last) {
893
-	        // The 'G' modifier is available since PHP 5.1.0
894
-	        case 'g':
895
-	            $val *= 1024;
896
-	        case 'm':
897
-	            $val *= 1024;
898
-	        case 'k':
899
-	            $val *= 1024;
900
-	    }
890
+		$val = trim($val);
891
+		$last = strtolower($val[strlen($val)-1]);
892
+		switch($last) {
893
+			// The 'G' modifier is available since PHP 5.1.0
894
+			case 'g':
895
+				$val *= 1024;
896
+			case 'm':
897
+				$val *= 1024;
898
+			case 'k':
899
+				$val *= 1024;
900
+		}
901 901
 	
902
-	    return $val;
902
+		return $val;
903 903
 	}
904 904
 	
905 905
 	public function is_multipart($backup_name)
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 	{
948 948
 		$direction = strtolower($direction);
949 949
 		
950
-	    usort($array, create_function('$a, $b', '
950
+		usort($array, create_function('$a, $b', '
951 951
 	        $a = $a["' . $field . '"];
952 952
 	        $b = $b["' . $field . '"];
953 953
 	
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 	        return ($a ' . ($direction == 'desc' ? '>' : '<') .' $b) ? -1 : 1;
960 960
 	    '));
961 961
 	
962
-	    return true;
962
+		return true;
963 963
 	}
964 964
 		
965 965
 	public static function send_response($status = 200, $response)
@@ -999,10 +999,10 @@  discard block
 block discarded – undo
999 999
 					$m[3] = "";
1000 1000
 					
1001 1001
 					$data = 's:'.strlen(($m[3])).':\"'.($m[3]).'\";';
1002
-	              //return $this->unescape_quotes($data);
1002
+				  //return $this->unescape_quotes($data);
1003 1003
 	              
1004
-	              return $data;
1005
-	            }, $query);
1004
+				  return $data;
1005
+				}, $query);
1006 1006
 	}
1007 1007
 	
1008 1008
 	private function unescape_quotes($value) {
@@ -1019,14 +1019,14 @@  discard block
 block discarded – undo
1019 1019
 	private function has_serialized($s)
1020 1020
 	{
1021 1021
 		if(
1022
-		    stristr($s, '{' ) != false &&
1023
-		    stristr($s, '}' ) != false &&
1024
-		    stristr($s, ';' ) != false &&
1025
-		    stristr($s, ':' ) != false
1026
-		    ){
1027
-		    return true;
1022
+			stristr($s, '{' ) != false &&
1023
+			stristr($s, '}' ) != false &&
1024
+			stristr($s, ';' ) != false &&
1025
+			stristr($s, ':' ) != false
1026
+			){
1027
+			return true;
1028 1028
 		}else{
1029
-		    return false;
1029
+			return false;
1030 1030
 		}
1031 1031
 
1032 1032
 	}
Please login to merge, or discard this patch.
Spacing   +189 added lines, -189 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;
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
 	{
112 112
 		register_shutdown_function(array($this, 'exception_handler'));
113 113
 
114
-		if(defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS)
114
+		if (defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS)
115 115
 		{
116 116
 			$dir = get_option("xcloner_store_path");
117 117
 		}
118 118
 		
119
-		if(!isset($dir) || !$dir){
119
+		if (!isset($dir) || !$dir) {
120 120
 			$dir = dirname(__FILE__);
121 121
 		}
122 122
 		
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 		
125 125
 		$this->backup_storage_dir = $dir;
126 126
 		
127
-		$this->adapter = new Local($dir ,LOCK_EX, 'SKIP_LINKS');
127
+		$this->adapter = new Local($dir, LOCK_EX, 'SKIP_LINKS');
128 128
 		$this->filesystem = new Filesystem($this->adapter, new Config([
129 129
 				'disable_asserts' => true,
130 130
 			]));
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
 		
134 134
 		$logger_path = $this->get_logger_filename();
135 135
 		
136
-		if(!is_writeable($logger_path) and !touch($logger_path))
136
+		if (!is_writeable($logger_path) and !touch($logger_path))
137 137
 		{
138 138
 			$logger_path = "php://stderr";
139 139
 		}
140 140
 		
141 141
 		$this->logger->pushHandler(new StreamHandler($logger_path, Logger::DEBUG));
142 142
 		
143
-		if(isset($_POST['API_ID'])){
144
-			$this->logger->info("Processing ajax request ID ".substr(filter_input(INPUT_POST, 'API_ID', FILTER_SANITIZE_STRING), 0 , 15));
143
+		if (isset($_POST['API_ID'])) {
144
+			$this->logger->info("Processing ajax request ID ".substr(filter_input(INPUT_POST, 'API_ID', FILTER_SANITIZE_STRING), 0, 15));
145 145
 		}
146 146
 
147 147
 	}
@@ -150,20 +150,20 @@  discard block
 block discarded – undo
150 150
 		
151 151
 		$error = error_get_last();
152 152
 		
153
-		if($error['type'] and $this->logger)
153
+		if ($error['type'] and $this->logger)
154 154
 		{
155
-			$this->logger->info($this->friendly_error_type ($error['type']).": ".var_export($error, true));
155
+			$this->logger->info($this->friendly_error_type($error['type']).": ".var_export($error, true));
156 156
 		}
157 157
 	
158 158
 	}
159 159
 	
160 160
 	private function friendly_error_type($type) {
161
-	    static $levels=null;
162
-	    if ($levels===null) {
163
-	        $levels=[];
161
+	    static $levels = null;
162
+	    if ($levels === null) {
163
+	        $levels = [];
164 164
 	        foreach (get_defined_constants() as $key=>$value) {
165
-	            if (strpos($key,'E_')!==0) {continue;}
166
-					$levels[$value]= $key; //substr($key,2);
165
+	            if (strpos($key, 'E_') !== 0) {continue; }
166
+					$levels[$value] = $key; //substr($key,2);
167 167
 	        }
168 168
 	    }
169 169
 	    return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}");
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
 	
172 172
 	public function get_logger_filename()
173 173
 	{
174
-		$filename = $this->backup_storage_dir .DS. "xcloner_restore.log";
174
+		$filename = $this->backup_storage_dir.DS."xcloner_restore.log";
175 175
 		
176 176
 		return $filename;
177 177
 	}
178 178
 	
179 179
 	public function init()
180 180
 	{
181
-		if(isset($_POST['xcloner_action']) and $_POST['xcloner_action'])
181
+		if (isset($_POST['xcloner_action']) and $_POST['xcloner_action'])
182 182
 		{
183 183
 			$method = filter_input(INPUT_POST, 'xcloner_action', FILTER_SANITIZE_STRING);
184 184
 			
@@ -186,13 +186,13 @@  discard block
 block discarded – undo
186 186
 			
187 187
 			$method .= "_action";
188 188
 			
189
-			if(method_exists($this, $method))
189
+			if (method_exists($this, $method))
190 190
 			{
191 191
 				$this->logger->debug(sprintf('Starting action %s', $method));
192 192
 				return call_user_func(array($this, $method));
193 193
 				
194
-			}else{
195
-				throw new Exception($method ." does not exists");
194
+			} else {
195
+				throw new Exception($method." does not exists");
196 196
 				}
197 197
 		}
198 198
 		
@@ -201,38 +201,38 @@  discard block
 block discarded – undo
201 201
 	
202 202
 	public function write_file_action()
203 203
 	{
204
-		if(isset($_POST['file']))
204
+		if (isset($_POST['file']))
205 205
 		{
206 206
 			$target_file = filter_input(INPUT_POST, 'file', FILTER_SANITIZE_STRING);
207 207
 			
208
-			if(!$_POST['start'])
208
+			if (!$_POST['start'])
209 209
 				$fp = fopen($target_file, "wb+");
210 210
 			else
211 211
 				$fp = fopen($target_file, "ab+");	
212 212
 			
213
-			if(!$fp)
213
+			if (!$fp)
214 214
 				throw new Exception("Unable to open $target_file file for writing");
215 215
 			
216 216
 			fseek($fp, $_POST['start']);
217 217
 			
218
-			if(isset($_FILES['blob']))
218
+			if (isset($_FILES['blob']))
219 219
 			{
220 220
 				$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']));
221 221
 				
222 222
 				$blob = file_get_contents($_FILES['blob']['tmp_name']);
223 223
 				
224
-				if(!$bytes_written = fwrite($fp, $blob))
224
+				if (!$bytes_written = fwrite($fp, $blob))
225 225
 					throw new Exception("Unable to write data to file $target_file");
226 226
 				
227 227
 				@unlink($_FILES['blob']['tmp_name']);
228
-			}elseif(isset($_POST['blob'])){
228
+			}elseif (isset($_POST['blob'])) {
229 229
 				$this->logger->debug(sprintf('Writing %s bytes to file %s starting position %s using POST blob', strlen($_POST['blob']), $target_file, $_POST['start']));
230 230
 				
231 231
 				$blob = $_POST['blob'];
232 232
 
233
-				if(!$bytes_written = fwrite($fp, $blob))
233
+				if (!$bytes_written = fwrite($fp, $blob))
234 234
 					throw new Exception("Unable to write data to file $target_file");
235
-			}else{
235
+			} else {
236 236
 				throw new Exception("Upload failed, did not receive any binary data");
237 237
 			}
238 238
 			
@@ -243,20 +243,20 @@  discard block
 block discarded – undo
243 243
 		
244 244
 	}
245 245
 	
246
-	public function mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db )
246
+	public function mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db)
247 247
 	{
248 248
 		$this->logger->info(sprintf('Connecting to mysql database %s with %s@%s', $remote_mysql_db, $remote_mysql_user, $remote_mysql_host));
249 249
 
250 250
 		$mysqli = new mysqli($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db);
251 251
 
252 252
 		if ($mysqli->connect_error) {
253
-			throw new Exception('Connect Error (' . $mysqli->connect_errno . ') '
253
+			throw new Exception('Connect Error ('.$mysqli->connect_errno.') '
254 254
 				. $mysqli->connect_error);
255 255
 		}
256 256
 		
257 257
 		$mysqli->query("SET sql_mode='';");
258 258
 		$mysqli->query("SET foreign_key_checks = 0;");
259
-		if(isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file'])
259
+		if (isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file'])
260 260
 			$mysqli->query("SET NAMES ".$_REQUEST['charset_of_file']."");
261 261
 		else
262 262
 			$mysqli->query("SET NAMES utf8;");
@@ -266,15 +266,15 @@  discard block
 block discarded – undo
266 266
 	
267 267
 	public function restore_mysql_backup_action()
268 268
 	{
269
-		$mysqldump_file 	= filter_input(INPUT_POST, 'mysqldump_file', FILTER_SANITIZE_STRING);
270
-		$remote_path 		= filter_input(INPUT_POST, 'remote_path', FILTER_SANITIZE_STRING);
269
+		$mysqldump_file = filter_input(INPUT_POST, 'mysqldump_file', FILTER_SANITIZE_STRING);
270
+		$remote_path = filter_input(INPUT_POST, 'remote_path', FILTER_SANITIZE_STRING);
271 271
 		$remote_mysql_user 	= filter_input(INPUT_POST, 'remote_mysql_user', FILTER_SANITIZE_STRING);
272 272
 		$remote_mysql_pass 	= filter_input(INPUT_POST, 'remote_mysql_pass', FILTER_SANITIZE_STRING);
273
-		$remote_mysql_db 	= filter_input(INPUT_POST, 'remote_mysql_db', FILTER_SANITIZE_STRING);
273
+		$remote_mysql_db = filter_input(INPUT_POST, 'remote_mysql_db', FILTER_SANITIZE_STRING);
274 274
 		$remote_mysql_host 	= filter_input(INPUT_POST, 'remote_mysql_host', FILTER_SANITIZE_STRING);
275
-		$execute_query 		= trim(stripslashes($_POST['query']));
276
-		$error_line			= filter_input(INPUT_POST, 'error_line', FILTER_SANITIZE_NUMBER_INT);
277
-		$start			 	= filter_input(INPUT_POST, 'start', FILTER_SANITIZE_NUMBER_INT);
275
+		$execute_query = trim(stripslashes($_POST['query']));
276
+		$error_line = filter_input(INPUT_POST, 'error_line', FILTER_SANITIZE_NUMBER_INT);
277
+		$start = filter_input(INPUT_POST, 'start', FILTER_SANITIZE_NUMBER_INT);
278 278
 		
279 279
 		$wp_home_url 		= filter_input(INPUT_POST, 'wp_home_url', FILTER_SANITIZE_STRING);
280 280
 		$remote_restore_url = filter_input(INPUT_POST, 'remote_restore_url', FILTER_SANITIZE_STRING);
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
 		
285 285
 		$mysql_backup_file = $remote_path.DS.$mysqldump_file;
286 286
 		
287
-		if(!file_exists($mysql_backup_file))
288
-			throw new Exception(sprintf("Mysql backup file %s does not exists",$mysql_backup_file));
287
+		if (!file_exists($mysql_backup_file))
288
+			throw new Exception(sprintf("Mysql backup file %s does not exists", $mysql_backup_file));
289 289
 		
290 290
 		
291 291
 		/*if(defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS)
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 		}*/
300 300
 		
301 301
 		{
302
-			$mysqli = $this->mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db );
302
+			$mysqli = $this->mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db);
303 303
 		}
304 304
 		
305 305
 		$line_count = 0;
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 		$return['backup_size']	= filesize($mysql_backup_file);
310 310
 		
311 311
 		$fp = fopen($mysql_backup_file, "r");
312
-		if($fp)
312
+		if ($fp)
313 313
 		{
314 314
 			$this->logger->info(sprintf("Opening mysql dump file %s at position %s.", $mysql_backup_file, $start));
315 315
 			fseek($fp, $start);
@@ -317,49 +317,49 @@  discard block
 block discarded – undo
317 317
 			// process the line read.
318 318
 									
319 319
 				//check if line is comment
320
-				if(substr($line, 0, 1) == "#")
320
+				if (substr($line, 0, 1) == "#")
321 321
 					continue;
322 322
 				
323 323
 				//check if line is empty	
324
-				if($line == "\n" or trim($line) == "")
324
+				if ($line == "\n" or trim($line) == "")
325 325
 					continue;
326 326
 					
327
-				if(substr($line, strlen($line)-2, strlen($line)) == ";\n")
327
+				if (substr($line, strlen($line) - 2, strlen($line)) == ";\n")
328 328
 					$query .= $line;
329
-				else{
329
+				else {
330 330
 					$query .= $line;
331 331
 					continue;
332 332
 				}
333 333
 				
334
-				if($execute_query)
334
+				if ($execute_query)
335 335
 				{
336
-					$query  = (($execute_query));
336
+					$query = (($execute_query));
337 337
 					$execute_query = "";
338 338
 				}	
339 339
 				
340 340
 				//Doing serialized url replace here
341 341
 				
342
-				if($wp_site_url and $wp_home_url and strlen($wp_home_url) < strlen($wp_site_url))
342
+				if ($wp_site_url and $wp_home_url and strlen($wp_home_url) < strlen($wp_site_url))
343 343
 				{
344
-					list($wp_home_url,$wp_site_url) 			= array($wp_site_url,$wp_home_url);
345
-					list($remote_restore_url,$restore_site_url) = array($restore_site_url,$remote_restore_url);
344
+					list($wp_home_url, $wp_site_url) = array($wp_site_url, $wp_home_url);
345
+					list($remote_restore_url, $restore_site_url) = array($restore_site_url, $remote_restore_url);
346 346
 					
347 347
 				}
348 348
 				
349
-				if($wp_home_url and $remote_restore_url and strpos($query, $wp_home_url) !== false)
349
+				if ($wp_home_url and $remote_restore_url and strpos($query, $wp_home_url) !== false)
350 350
 				{
351 351
 					$query = $this->url_replace($wp_home_url, $remote_restore_url, $query);
352 352
 				}
353 353
 				
354
-				if($wp_site_url and $restore_site_url and strpos($query, $wp_site_url) !== false)
354
+				if ($wp_site_url and $restore_site_url and strpos($query, $wp_site_url) !== false)
355 355
 				{
356 356
 					$query = $this->url_replace($wp_site_url, $restore_site_url, $query);
357 357
 				}
358 358
 				
359
-				if(!$mysqli->query($query) && !stristr($mysqli->error,"Duplicate entry"))
359
+				if (!$mysqli->query($query) && !stristr($mysqli->error, "Duplicate entry"))
360 360
 				{
361 361
 					//$return['error_line'] = $line_count;
362
-					$return['start'] = ftell($fp)-strlen($line);
362
+					$return['start'] = ftell($fp) - strlen($line);
363 363
 					$return['query_error'] = true;
364 364
 					$return['query'] = $query;
365 365
 					$return['message'] = sprintf("Mysql Error: %s\n", $mysqli->error);
@@ -380,12 +380,12 @@  discard block
 block discarded – undo
380 380
 		
381 381
 		$return['start'] = ftell($fp);
382 382
 		
383
-		$this->logger->info(sprintf("Executed %s queries of size %s bytes", $line_count, ($return['start']-$start)));
383
+		$this->logger->info(sprintf("Executed %s queries of size %s bytes", $line_count, ($return['start'] - $start)));
384 384
 		
385
-		if(!feof($fp))
385
+		if (!feof($fp))
386 386
 		{
387 387
 			$return['finished'] = 0;
388
-		}else{
388
+		} else {
389 389
 			$this->logger->info(sprintf("Mysql Import Done."));
390 390
 		}
391 391
 		
@@ -400,12 +400,12 @@  discard block
 block discarded – undo
400 400
 		$query = str_replace($search, $replace, $query);
401 401
 		$original_query = $query;
402 402
 		
403
-		if($this->has_serialized($query))
403
+		if ($this->has_serialized($query))
404 404
 		{
405 405
 			$this->logger->info(sprintf("Query contains serialized data, doing serialized size fix"), array("QUERY_REPLACE"));
406 406
 			$query = $this->do_serialized_fix($query);
407 407
 			
408
-			if(!$query)
408
+			if (!$query)
409 409
 			{
410 410
 				$this->logger->info(sprintf("Serialization probably failed here..."), array("QUERY_REPLACE"));
411 411
 				$query = $original_query;
@@ -421,37 +421,37 @@  discard block
 block discarded – undo
421 421
 		$backup_parts = array();
422 422
 		
423 423
 		$source_backup_file = filter_input(INPUT_POST, 'file', FILTER_SANITIZE_STRING);
424
-		$start 				= (int)filter_input(INPUT_POST, 'start', FILTER_SANITIZE_STRING);
425
-		$return['part'] 	= (int)filter_input(INPUT_POST, 'part', FILTER_SANITIZE_STRING);
424
+		$start = (int)filter_input(INPUT_POST, 'start', FILTER_SANITIZE_STRING);
425
+		$return['part'] = (int)filter_input(INPUT_POST, 'part', FILTER_SANITIZE_STRING);
426 426
 		
427 427
 		$backup_file = $source_backup_file;
428 428
 		
429
-		if($this->is_multipart($backup_file))
429
+		if ($this->is_multipart($backup_file))
430 430
 		{
431 431
 			$backup_parts = $this->get_multipart_files($backup_file);
432 432
 			$backup_file = $backup_parts[$return['part']];
433 433
 		}
434 434
 		
435
-		try{
435
+		try {
436 436
 			$tar = new Tar();
437 437
 			$tar->open($this->backup_storage_dir.DS.$backup_file, $start);
438 438
 		
439 439
 			$data = $tar->contents($this->process_files_limit_list);
440
-		}catch(Exception $e)
440
+		}catch (Exception $e)
441 441
 		{
442 442
 			$return['error'] = true;
443 443
 			$return['message'] = $e->getMessage();
444 444
 			$this->send_response(200, $return);
445 445
 		}
446 446
 		
447
-		$return['files'] 		= array();
448
-		$return['finished'] 	= 1;
449
-		$return['total_size'] 	= filesize($this->backup_storage_dir.DS.$backup_file);
447
+		$return['files'] = array();
448
+		$return['finished'] = 1;
449
+		$return['total_size'] = filesize($this->backup_storage_dir.DS.$backup_file);
450 450
 		$i = 0;
451 451
 		
452
-		if(isset($data['extracted_files']) and is_array($data['extracted_files']))
452
+		if (isset($data['extracted_files']) and is_array($data['extracted_files']))
453 453
 		{
454
-			foreach($data['extracted_files'] as $file)
454
+			foreach ($data['extracted_files'] as $file)
455 455
 			{
456 456
 				$return['files'][$i]['path'] = $file->getPath();
457 457
 				$return['files'][$i]['size'] = $file->getSize();
@@ -461,18 +461,18 @@  discard block
 block discarded – undo
461 461
 			}
462 462
 		}
463 463
 		
464
-		if(isset($data['start']))
464
+		if (isset($data['start']))
465 465
 		{
466 466
 			$return['start'] = $data['start'];
467 467
 			$return['finished'] = 0;	
468
-		}else{
469
-			if($this->is_multipart($source_backup_file))
468
+		} else {
469
+			if ($this->is_multipart($source_backup_file))
470 470
 			{
471 471
 				$return['start'] = 0;
472 472
 				
473 473
 				++$return['part'];
474 474
 			
475
-				if($return['part'] < sizeof($backup_parts))	
475
+				if ($return['part'] < sizeof($backup_parts))	
476 476
 					$return['finished'] = 0;
477 477
 				
478 478
 			}
@@ -490,28 +490,28 @@  discard block
 block discarded – undo
490 490
 		
491 491
 		$remote_mysql_user 	= filter_input(INPUT_POST, 'remote_mysql_user', FILTER_SANITIZE_STRING);
492 492
 		$remote_mysql_pass 	= filter_input(INPUT_POST, 'remote_mysql_pass', FILTER_SANITIZE_STRING);
493
-		$remote_mysql_db 	= filter_input(INPUT_POST, 'remote_mysql_db', FILTER_SANITIZE_STRING);
493
+		$remote_mysql_db = filter_input(INPUT_POST, 'remote_mysql_db', FILTER_SANITIZE_STRING);
494 494
 		$remote_mysql_host 	= filter_input(INPUT_POST, 'remote_mysql_host', FILTER_SANITIZE_STRING);
495 495
 		
496
-		$update_remote_site_url			 	= filter_input(INPUT_POST, 'update_remote_site_url', FILTER_SANITIZE_NUMBER_INT);
497
-		$delete_restore_script			 	= filter_input(INPUT_POST, 'delete_restore_script', FILTER_SANITIZE_NUMBER_INT);
498
-		$delete_backup_temporary_folder		= filter_input(INPUT_POST, 'delete_backup_temporary_folder', FILTER_SANITIZE_NUMBER_INT);
496
+		$update_remote_site_url = filter_input(INPUT_POST, 'update_remote_site_url', FILTER_SANITIZE_NUMBER_INT);
497
+		$delete_restore_script = filter_input(INPUT_POST, 'delete_restore_script', FILTER_SANITIZE_NUMBER_INT);
498
+		$delete_backup_temporary_folder = filter_input(INPUT_POST, 'delete_backup_temporary_folder', FILTER_SANITIZE_NUMBER_INT);
499 499
 				
500
-		if($update_remote_site_url)
500
+		if ($update_remote_site_url)
501 501
 		{
502
-			$mysqli = $this->mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db );
502
+			$mysqli = $this->mysql_connect($remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db);
503 503
 			$this->update_wp_config($remote_path, $remote_mysql_host, $remote_mysql_user, $remote_mysql_pass, $remote_mysql_db);
504 504
 			$this->update_wp_url($remote_path, $remote_restore_url, $mysqli);
505 505
 		}
506 506
 		
507
-		if($delete_backup_temporary_folder)
507
+		if ($delete_backup_temporary_folder)
508 508
 		{
509 509
 			$this->delete_backup_temporary_folder($remote_path);
510 510
 		}
511 511
 		
512
-		if(!defined('XCLONER_PLUGIN_ACCESS') || XCLONER_PLUGIN_ACCESS != 1)
512
+		if (!defined('XCLONER_PLUGIN_ACCESS') || XCLONER_PLUGIN_ACCESS != 1)
513 513
 		{
514
-			if($delete_restore_script)
514
+			if ($delete_restore_script)
515 515
 			{
516 516
 				$this->delete_self();
517 517
 			}
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 	
524 524
 	private function delete_backup_temporary_folder($remote_path)
525 525
 	{
526
-		$this->target_adapter = new Local($remote_path ,LOCK_EX, 'SKIP_LINKS');
526
+		$this->target_adapter = new Local($remote_path, LOCK_EX, 'SKIP_LINKS');
527 527
 		$this->target_filesystem = new Filesystem($this->target_adapter, new Config([
528 528
 				'disable_asserts' => true,
529 529
 			]));
@@ -531,13 +531,13 @@  discard block
 block discarded – undo
531 531
 		$mysqldump_list = array();
532 532
 		$list = $this->target_filesystem->listContents();
533 533
 		
534
-		foreach($list as $file)
534
+		foreach ($list as $file)
535 535
 		{
536 536
 			$matches = array();
537 537
 			
538
-			if($file['type'] == "dir")
538
+			if ($file['type'] == "dir")
539 539
 			{
540
-				if(preg_match("/xcloner-(\w*)/", $file['basename'], $matches)){
540
+				if (preg_match("/xcloner-(\w*)/", $file['basename'], $matches)) {
541 541
 					$this->logger->info(sprintf('Deleting temporary folder %s', $file['path']));
542 542
 					$this->target_filesystem->deleteDir($file['path']);
543 543
 				}
@@ -550,29 +550,29 @@  discard block
 block discarded – undo
550 550
 	
551 551
 	private function delete_self()
552 552
 	{
553
-		if($this->filesystem->has("vendor.phar"))
553
+		if ($this->filesystem->has("vendor.phar"))
554 554
 		{
555 555
 			$this->logger->info(sprintf('Deleting vendor.phar'));
556 556
 			$this->filesystem->delete("vendor.phar");
557 557
 		}
558
-		if($this->filesystem->has("vendor"))
558
+		if ($this->filesystem->has("vendor"))
559 559
 		{
560 560
 			$this->logger->info(sprintf('Deleting vendor folder'));
561 561
 			$this->filesystem->deleteDir("vendor");
562 562
 		}
563
-		if($this->filesystem->has("xcloner_restore.php"))
563
+		if ($this->filesystem->has("xcloner_restore.php"))
564 564
 		{
565 565
 			$this->logger->info(sprintf('Deleting xcloner_restore.php'));
566 566
 			$this->filesystem->delete("xcloner_restore.php");
567 567
 		}
568 568
 		
569
-		if($this->filesystem->has("xcloner_restore.log"))
569
+		if ($this->filesystem->has("xcloner_restore.log"))
570 570
 		{
571 571
 			$this->logger->info(sprintf('Deleting xcloner_restore.log'));
572 572
 			$this->filesystem->delete("xcloner_restore.log");
573 573
 		}
574 574
 		
575
-		if($this->filesystem->has($this->get_logger_filename()))
575
+		if ($this->filesystem->has($this->get_logger_filename()))
576 576
 		{
577 577
 			$this->logger->info(sprintf('Deleting logger file %s', $this->get_logger_filename()));
578 578
 			$this->filesystem->delete($this->get_logger_filename());
@@ -586,11 +586,11 @@  discard block
 block discarded – undo
586 586
 		
587 587
 		$this->logger->info(sprintf('Updating site url to %s', $url));
588 588
 		
589
-		if(file_exists($wp_config))
589
+		if (file_exists($wp_config))
590 590
 		{
591 591
 			$config = file_get_contents($wp_config);
592 592
 			preg_match("/.*table_prefix.*=.*'(.*)'/i", $config, $matches);
593
-			if(isset($matches[1]))
593
+			if (isset($matches[1]))
594 594
 				$table_prefix = $matches[1];
595 595
 			else
596 596
 				throw new Exception("Could not load wordpress table prefix from wp-config.php file.");
@@ -598,10 +598,10 @@  discard block
 block discarded – undo
598 598
 		else
599 599
 			throw new Exception("Could not update the SITEURL and HOME, wp-config.php file not found");
600 600
 			
601
-		if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='home'"))
601
+		if (!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='home'"))
602 602
 			throw new Exception(sprintf("Could not update the HOME option, error: %s\n", $mysqli->error));
603 603
 		
604
-		if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='siteurl'"))
604
+		if (!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='siteurl'"))
605 605
 			throw new Exception(sprintf("Could not update the SITEURL option, error: %s\n", $mysqli->error));
606 606
 		
607 607
 		return true;
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 	{
612 612
 		$wp_config = $remote_path.DS."wp-config.php";
613 613
 		
614
-		if(!file_exists($wp_config))
614
+		if (!file_exists($wp_config))
615 615
 		{
616 616
 			throw new Exception("Could not find the wp-config.php in ".$remote_path);
617 617
 		}
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 		
630 630
 		$this->logger->info(sprintf('Updating wp-config.php file with the new mysql details'));
631 631
 		
632
-		if(!file_put_contents($wp_config, $content))
632
+		if (!file_put_contents($wp_config, $content))
633 633
 			throw new Exception("Could not write updated config data to ".$wp_config);
634 634
 		
635 635
 		chmod($wp_config, $file_perms);
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 	
646 646
 		$hash = $this->get_hash_from_backup($source_backup_file);	
647 647
 		
648
-		$this->target_adapter = new Local($remote_path ,LOCK_EX, 'SKIP_LINKS');
648
+		$this->target_adapter = new Local($remote_path, LOCK_EX, 'SKIP_LINKS');
649 649
 		$this->target_filesystem = new Filesystem($this->target_adapter, new Config([
650 650
 				'disable_asserts' => true,
651 651
 			]));
@@ -653,25 +653,25 @@  discard block
 block discarded – undo
653 653
 		$mysqldump_list = array();
654 654
 		$list = $this->target_filesystem->listContents();
655 655
 		
656
-		foreach($list as $file)
656
+		foreach ($list as $file)
657 657
 		{
658 658
 			$matches = array();
659 659
 			
660
-			if($file['type'] == "dir")
660
+			if ($file['type'] == "dir")
661 661
 			{
662
-				if(preg_match("/xcloner-(\w*)/", $file['basename'], $matches))
662
+				if (preg_match("/xcloner-(\w*)/", $file['basename'], $matches))
663 663
 				{
664 664
 					$files = $this->target_filesystem->listContents($file['basename']);
665
-					foreach($files as $file)
665
+					foreach ($files as $file)
666 666
 					{
667
-						if($file['extension'] == "sql")
667
+						if ($file['extension'] == "sql")
668 668
 						{
669 669
 							$this->logger->info(sprintf('Found %s mysql backup file', $file['path']));
670 670
 							$mysqldump_list[$file['path']]['path'] = $file['path'];
671 671
 							$mysqldump_list[$file['path']]['size'] = $file['size'];
672
-							$mysqldump_list[$file['path']]['timestamp'] = date("d M,Y H:i",$file['timestamp']);
672
+							$mysqldump_list[$file['path']]['timestamp'] = date("d M,Y H:i", $file['timestamp']);
673 673
 							
674
-							if($hash and $hash == $matches[1])
674
+							if ($hash and $hash == $matches[1])
675 675
 								$mysqldump_list[$file['path']]['selected'] = "selected";
676 676
 							else
677 677
 								$mysqldump_list[$file['path']]['selected'] = "";	
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 			}	
682 682
 		}
683 683
 		
684
-		$this->sort_by($mysqldump_list, 'timestamp','desc');
684
+		$this->sort_by($mysqldump_list, 'timestamp', 'desc');
685 685
 		$return['files'] = $mysqldump_list;
686 686
 		
687 687
 		$this->send_response(200, $return);
@@ -689,12 +689,12 @@  discard block
 block discarded – undo
689 689
 	
690 690
 	private function get_hash_from_backup($backup_file)
691 691
 	{
692
-		if(!$backup_file)
692
+		if (!$backup_file)
693 693
 			return false;
694 694
 			
695
-		$result = preg_match("/-(\w*)./", substr($backup_file, strlen($backup_file)-10, strlen($backup_file)), $matches)	;
695
+		$result = preg_match("/-(\w*)./", substr($backup_file, strlen($backup_file) - 10, strlen($backup_file)), $matches);
696 696
 		
697
-		if($result and isset($matches[1]))
697
+		if ($result and isset($matches[1]))
698 698
 			return ($matches[1]);
699 699
 		
700 700
 		return false;
@@ -708,18 +708,18 @@  discard block
 block discarded – undo
708 708
 		$backup_files = array();
709 709
 		$parents = array();
710 710
 		
711
-		foreach($list as $file_info)
711
+		foreach ($list as $file_info)
712 712
 		{
713 713
 			$data = array();
714 714
 			
715
-			if(isset($file_info['extension']) and $file_info['extension'] == "csv")
715
+			if (isset($file_info['extension']) and $file_info['extension'] == "csv")
716 716
 			{
717 717
 				$lines = explode(PHP_EOL, $this->filesystem->read($file_info['path']));
718
-				foreach($lines as $line)
719
-					if($line)
718
+				foreach ($lines as $line)
719
+					if ($line)
720 720
 					{
721 721
 						$data = str_getcsv($line);
722
-						if(is_array($data)){
722
+						if (is_array($data)) {
723 723
 							$parents[$data[0]] = $file_info['path'];
724 724
 							$file_info['childs'][] = $data;
725 725
 							$file_info['size'] += $data[2];
@@ -728,19 +728,19 @@  discard block
 block discarded – undo
728 728
 						
729 729
 			}
730 730
 			
731
-			if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions))
731
+			if ($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions))
732 732
 				$backup_files[$file_info['path']] = $file_info;
733 733
 		}
734 734
 		
735 735
 		$new_list = array();
736 736
 		
737
-		foreach($backup_files as $key=>$file_info)
737
+		foreach ($backup_files as $key=>$file_info)
738 738
 		{
739
-			if(isset($parents[$file_info['path']]))
739
+			if (isset($parents[$file_info['path']]))
740 740
 				$backup_files[$key]['parent'] = $parents[$file_info['path']];
741
-			else{
741
+			else {
742 742
 				
743
-				if($local_backup_file and ($file_info['basename'] == $local_backup_file))
743
+				if ($local_backup_file and ($file_info['basename'] == $local_backup_file))
744 744
 					$file_info['selected'] = 'selected';
745 745
 				
746 746
 				$this->logger->info(sprintf('Found %s backup file', $file_info['path']));
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
 				
751 751
 		}
752 752
 		
753
-		$this->sort_by($new_list, "timestamp","desc");
753
+		$this->sort_by($new_list, "timestamp", "desc");
754 754
 		
755 755
 		$return['files'] = $new_list;
756 756
 		
@@ -760,15 +760,15 @@  discard block
 block discarded – undo
760 760
 	
761 761
 	public function restore_backup_to_path_action()
762 762
 	{
763
-		$source_backup_file 	= filter_input(INPUT_POST, 'backup_file', FILTER_SANITIZE_STRING);
764
-		$remote_path 			= filter_input(INPUT_POST, 'remote_path', FILTER_SANITIZE_STRING);
763
+		$source_backup_file = filter_input(INPUT_POST, 'backup_file', FILTER_SANITIZE_STRING);
764
+		$remote_path = filter_input(INPUT_POST, 'remote_path', FILTER_SANITIZE_STRING);
765 765
 		$include_filter_files 	= filter_input(INPUT_POST, 'filter_files', FILTER_SANITIZE_STRING);
766 766
 		$exclude_filter_files 	= "";
767
-		$start 					= filter_input(INPUT_POST, 'start', FILTER_SANITIZE_NUMBER_INT);
768
-		$return['part'] 		= (int)filter_input(INPUT_POST, 'part', FILTER_SANITIZE_NUMBER_INT);
767
+		$start = filter_input(INPUT_POST, 'start', FILTER_SANITIZE_NUMBER_INT);
768
+		$return['part'] = (int)filter_input(INPUT_POST, 'part', FILTER_SANITIZE_NUMBER_INT);
769 769
 		$return['processed'] 	= (int)filter_input(INPUT_POST, 'processed', FILTER_SANITIZE_NUMBER_INT);
770 770
 				
771
-		$this->target_adapter = new Local($remote_path ,LOCK_EX, 'SKIP_LINKS');
771
+		$this->target_adapter = new Local($remote_path, LOCK_EX, 'SKIP_LINKS');
772 772
 		$this->target_filesystem = new Filesystem($this->target_adapter, new Config([
773 773
 				'disable_asserts' => true,
774 774
 			]));
@@ -780,9 +780,9 @@  discard block
 block discarded – undo
780 780
 		$return['total_size'] = $this->get_backup_size($backup_file);
781 781
 		
782 782
 		$backup_archive = new Tar();
783
-		if($this->is_multipart($backup_file))
783
+		if ($this->is_multipart($backup_file))
784 784
 		{
785
-			if(!$return['part'])
785
+			if (!$return['part'])
786 786
 				$return['processed'] += $this->filesystem->getSize($backup_file);
787 787
 				
788 788
 			$backup_parts = $this->get_multipart_files($backup_file);
@@ -790,41 +790,41 @@  discard block
 block discarded – undo
790 790
 		}	
791 791
 		
792 792
 		$this->logger->info(sprintf('Opening backup archive %s at position %s', $backup_file, $start));
793
-		$backup_archive->open($this->backup_storage_dir .DS. $backup_file, $start);
793
+		$backup_archive->open($this->backup_storage_dir.DS.$backup_file, $start);
794 794
 
795
-		$data = $backup_archive->extract($remote_path, '',$exclude_filter_files,$include_filter_files, $this->process_files_limit);
795
+		$data = $backup_archive->extract($remote_path, '', $exclude_filter_files, $include_filter_files, $this->process_files_limit);
796 796
 		
797
-		if(isset($data['extracted_files']))
797
+		if (isset($data['extracted_files']))
798 798
 		{
799
-			foreach($data['extracted_files'] as $spl_fileinfo)
799
+			foreach ($data['extracted_files'] as $spl_fileinfo)
800 800
 			{
801 801
 				$this->logger->info(sprintf('Extracted %s file', $spl_fileinfo->getPath()));
802 802
 				$return['extracted_files'][] = $spl_fileinfo->getPath()." (".$spl_fileinfo->getSize()." bytes)";
803 803
 			}
804 804
 		}
805 805
 		
806
-		if(isset($data['start']))
806
+		if (isset($data['start']))
807 807
 		//if(isset($data['start']) and $data['start'] <= $this->filesystem->getSize($backup_file))
808 808
 		{
809 809
 			$return['finished'] = 0;
810 810
 			$return['start'] = $data['start'];
811
-		}else{
811
+		} else {
812 812
 			
813 813
 			$return['processed'] += $start;
814 814
 			
815
-			if($this->is_multipart($source_backup_file))
815
+			if ($this->is_multipart($source_backup_file))
816 816
 			{
817 817
 				$return['start'] = 0;
818 818
 				
819 819
 				++$return['part'];
820 820
 			
821
-				if($return['part'] < sizeof($backup_parts))	
821
+				if ($return['part'] < sizeof($backup_parts))	
822 822
 					$return['finished'] = 0;
823 823
 				
824 824
 			}
825 825
 		}
826 826
 		
827
-		if($return['finished'])
827
+		if ($return['finished'])
828 828
 			$this->logger->info(sprintf('Done extracting %s', $source_backup_file));
829 829
 		
830 830
 		$return['backup_file'] = $backup_file;
@@ -838,24 +838,24 @@  discard block
 block discarded – undo
838 838
 		
839 839
 		$restore_script_url = filter_input(INPUT_POST, 'restore_script_url', FILTER_SANITIZE_STRING);
840 840
 		
841
-		$pathinfo = pathinfo( __FILE__);
841
+		$pathinfo = pathinfo(__FILE__);
842 842
 		
843 843
 		$suffix = "";
844 844
 		$return['remote_mysql_host'] 	= "localhost";
845 845
 		$return['remote_mysql_user'] 	= "";
846 846
 		$return['remote_mysql_pass'] 	= "";
847
-		$return['remote_mysql_db'] 		= "";
847
+		$return['remote_mysql_db'] = "";
848 848
 		
849
-		if(defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS)
849
+		if (defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS)
850 850
 		{
851 851
 			$return['dir'] = realpath(get_home_path().DS.$suffix);
852
-			$return['restore_script_url']  	= get_site_url();
852
+			$return['restore_script_url'] = get_site_url();
853 853
 			$return['remote_mysql_host'] 	= $wpdb->dbhost;
854 854
 			$return['remote_mysql_user'] 	= $wpdb->dbuser;
855 855
 			$return['remote_mysql_pass'] 	= $wpdb->dbpassword;
856
-			$return['remote_mysql_db'] 		= $wpdb->dbname;
856
+			$return['remote_mysql_db'] = $wpdb->dbname;
857 857
 		}
858
-		else{
858
+		else {
859 859
 			$return['dir'] = ($pathinfo['dirname']).DS.$suffix;
860 860
 			$return['restore_script_url'] = str_replace($pathinfo['basename'], "", $restore_script_url).$suffix;
861 861
 		}	
@@ -869,17 +869,17 @@  discard block
 block discarded – undo
869 869
 	{
870 870
 		//check if i can write
871 871
 		$tmp_file = md5(time());
872
-		if(!file_put_contents($tmp_file, "++"))
872
+		if (!file_put_contents($tmp_file, "++"))
873 873
 			throw new Exception("Could not write to new host");
874 874
 		
875
-		if(!unlink($tmp_file))
875
+		if (!unlink($tmp_file))
876 876
 			throw new Exception("Could not delete temporary file from new host");
877 877
 		
878 878
 		$max_upload      = $this->return_bytes((ini_get('upload_max_filesize')));
879 879
 		$max_post        = $this->return_bytes((ini_get('post_max_size')));
880 880
 
881 881
 		$return['max_upload_size'] = min($max_upload, $max_post); // bytes
882
-		$return['status']		= true;
882
+		$return['status'] = true;
883 883
 		
884 884
 		$this->logger->info(sprintf('Current filesystem max upload size is %s bytes', $return['max_upload_size']));
885 885
 		
@@ -888,8 +888,8 @@  discard block
 block discarded – undo
888 888
 	
889 889
 	private function return_bytes($val) {
890 890
 	    $val = trim($val);
891
-	    $last = strtolower($val[strlen($val)-1]);
892
-	    switch($last) {
891
+	    $last = strtolower($val[strlen($val) - 1]);
892
+	    switch ($last) {
893 893
 	        // The 'G' modifier is available since PHP 5.1.0
894 894
 	        case 'g':
895 895
 	            $val *= 1024;
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
 	
905 905
 	public function is_multipart($backup_name)
906 906
 	{
907
-		if(stristr($backup_name, "-multipart"))
907
+		if (stristr($backup_name, "-multipart"))
908 908
 			return true;
909 909
 		
910 910
 		return false;	
@@ -913,10 +913,10 @@  discard block
 block discarded – undo
913 913
 	public function get_backup_size($backup_name)
914 914
 	{
915 915
 		$backup_size = $this->filesystem->getSize($backup_name);
916
-		if($this->is_multipart($backup_name))
916
+		if ($this->is_multipart($backup_name))
917 917
 		{
918 918
 			$backup_parts = $this->get_multipart_files($backup_name);
919
-			foreach($backup_parts as $part_file)
919
+			foreach ($backup_parts as $part_file)
920 920
 				$backup_size += $this->filesystem->getSize($part_file);
921 921
 		}
922 922
 		
@@ -927,12 +927,12 @@  discard block
 block discarded – undo
927 927
 	{
928 928
 		$files = array();
929 929
 		
930
-		if($this->is_multipart($backup_name))
930
+		if ($this->is_multipart($backup_name))
931 931
 		{
932 932
 			$lines = explode(PHP_EOL, $this->filesystem->read($backup_name));
933
-			foreach($lines as $line)
933
+			foreach ($lines as $line)
934 934
 			{
935
-				if($line)
935
+				if ($line)
936 936
 				{
937 937
 					$data = str_getcsv($line);
938 938
 					$files[] = $data[0];
@@ -943,20 +943,20 @@  discard block
 block discarded – undo
943 943
 		return $files;
944 944
 	}
945 945
 	
946
-	private function sort_by( &$array, $field, $direction = 'asc')
946
+	private function sort_by(&$array, $field, $direction = 'asc')
947 947
 	{
948 948
 		$direction = strtolower($direction);
949 949
 		
950 950
 	    usort($array, create_function('$a, $b', '
951
-	        $a = $a["' . $field . '"];
952
-	        $b = $b["' . $field . '"];
951
+	        $a = $a["' . $field.'"];
952
+	        $b = $b["' . $field.'"];
953 953
 	
954 954
 	        if ($a == $b)
955 955
 	        {
956 956
 	            return 0;
957 957
 	        }
958 958
 	
959
-	        return ($a ' . ($direction == 'desc' ? '>' : '<') .' $b) ? -1 : 1;
959
+	        return ($a ' . ($direction == 'desc' ? '>' : '<').' $b) ? -1 : 1;
960 960
 	    '));
961 961
 	
962 962
 	    return true;
@@ -970,11 +970,11 @@  discard block
 block discarded – undo
970 970
 		$return['status'] = $status;
971 971
 		$return['statusText'] = $response;
972 972
 		
973
-		if(isset($response['error']) && $response['error'])
973
+		if (isset($response['error']) && $response['error'])
974 974
 		{
975 975
 			$return['statusText'] = $response['message'];
976 976
 			$return['error'] = true;
977
-		}elseif($status != 200 and $status != 418)
977
+		}elseif ($status != 200 and $status != 418)
978 978
 		{
979 979
 			$return['error'] = true;
980 980
 			$return['message'] = $response;
@@ -992,10 +992,10 @@  discard block
 block discarded – undo
992 992
 	{
993 993
 		//return preg_replace('!s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!e', "'s:'.strlen(unescape_mysql('$3')).':\"'.unescape_quotes('$3').'\";'", $query);
994 994
 		
995
-		return preg_replace_callback('!s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!', function ($m) {
995
+		return preg_replace_callback('!s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!', function($m) {
996 996
 				  $data = "";
997 997
 				  	
998
-				  if(!isset($m[3]))
998
+				  if (!isset($m[3]))
999 999
 					$m[3] = "";
1000 1000
 					
1001 1001
 					$data = 's:'.strlen(($m[3])).':\"'.($m[3]).'\";';
@@ -1010,22 +1010,22 @@  discard block
 block discarded – undo
1010 1010
 	}
1011 1011
 	
1012 1012
 	private function unescape_mysql($value) {
1013
-		return str_replace(array("\\\\", "\\0", "\\n", "\\r", "\Z",  "\'", '\"'),
1014
-						   array("\\",   "\0",  "\n",  "\r",  "\x1a", "'", '"'), 
1013
+		return str_replace(array("\\\\", "\\0", "\\n", "\\r", "\Z", "\'", '\"'),
1014
+						   array("\\", "\0", "\n", "\r", "\x1a", "'", '"'), 
1015 1015
 						   $value);
1016 1016
 	}	
1017 1017
 	
1018 1018
 	
1019 1019
 	private function has_serialized($s)
1020 1020
 	{
1021
-		if(
1022
-		    stristr($s, '{' ) != false &&
1023
-		    stristr($s, '}' ) != false &&
1024
-		    stristr($s, ';' ) != false &&
1025
-		    stristr($s, ':' ) != false
1026
-		    ){
1021
+		if (
1022
+		    stristr($s, '{') != false &&
1023
+		    stristr($s, '}') != false &&
1024
+		    stristr($s, ';') != false &&
1025
+		    stristr($s, ':') != false
1026
+		    ) {
1027 1027
 		    return true;
1028
-		}else{
1028
+		} else {
1029 1029
 		    return false;
1030 1030
 		}
1031 1031
 
Please login to merge, or discard this patch.
Braces   +113 added lines, -87 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
 
@@ -191,7 +190,7 @@  discard block
 block discarded – undo
191 190
 				$this->logger->debug(sprintf('Starting action %s', $method));
192 191
 				return call_user_func(array($this, $method));
193 192
 				
194
-			}else{
193
+			} else{
195 194
 				throw new Exception($method ." does not exists");
196 195
 				}
197 196
 		}
@@ -205,13 +204,15 @@  discard block
 block discarded – undo
205 204
 		{
206 205
 			$target_file = filter_input(INPUT_POST, 'file', FILTER_SANITIZE_STRING);
207 206
 			
208
-			if(!$_POST['start'])
209
-				$fp = fopen($target_file, "wb+");
210
-			else
211
-				$fp = fopen($target_file, "ab+");	
207
+			if(!$_POST['start']) {
208
+							$fp = fopen($target_file, "wb+");
209
+			} else {
210
+							$fp = fopen($target_file, "ab+");
211
+			}
212 212
 			
213
-			if(!$fp)
214
-				throw new Exception("Unable to open $target_file file for writing");
213
+			if(!$fp) {
214
+							throw new Exception("Unable to open $target_file file for writing");
215
+			}
215 216
 			
216 217
 			fseek($fp, $_POST['start']);
217 218
 			
@@ -221,18 +222,20 @@  discard block
 block discarded – undo
221 222
 				
222 223
 				$blob = file_get_contents($_FILES['blob']['tmp_name']);
223 224
 				
224
-				if(!$bytes_written = fwrite($fp, $blob))
225
-					throw new Exception("Unable to write data to file $target_file");
225
+				if(!$bytes_written = fwrite($fp, $blob)) {
226
+									throw new Exception("Unable to write data to file $target_file");
227
+				}
226 228
 				
227 229
 				@unlink($_FILES['blob']['tmp_name']);
228
-			}elseif(isset($_POST['blob'])){
230
+			} elseif(isset($_POST['blob'])){
229 231
 				$this->logger->debug(sprintf('Writing %s bytes to file %s starting position %s using POST blob', strlen($_POST['blob']), $target_file, $_POST['start']));
230 232
 				
231 233
 				$blob = $_POST['blob'];
232 234
 
233
-				if(!$bytes_written = fwrite($fp, $blob))
234
-					throw new Exception("Unable to write data to file $target_file");
235
-			}else{
235
+				if(!$bytes_written = fwrite($fp, $blob)) {
236
+									throw new Exception("Unable to write data to file $target_file");
237
+				}
238
+			} else{
236 239
 				throw new Exception("Upload failed, did not receive any binary data");
237 240
 			}
238 241
 			
@@ -256,10 +259,11 @@  discard block
 block discarded – undo
256 259
 		
257 260
 		$mysqli->query("SET sql_mode='';");
258 261
 		$mysqli->query("SET foreign_key_checks = 0;");
259
-		if(isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file'])
260
-			$mysqli->query("SET NAMES ".$_REQUEST['charset_of_file']."");
261
-		else
262
-			$mysqli->query("SET NAMES utf8;");
262
+		if(isset($_REQUEST['charset_of_file']) and $_REQUEST['charset_of_file']) {
263
+					$mysqli->query("SET NAMES ".$_REQUEST['charset_of_file']."");
264
+		} else {
265
+					$mysqli->query("SET NAMES utf8;");
266
+		}
263 267
 			
264 268
 		return $mysqli;	
265 269
 	}
@@ -284,8 +288,9 @@  discard block
 block discarded – undo
284 288
 		
285 289
 		$mysql_backup_file = $remote_path.DS.$mysqldump_file;
286 290
 		
287
-		if(!file_exists($mysql_backup_file))
288
-			throw new Exception(sprintf("Mysql backup file %s does not exists",$mysql_backup_file));
291
+		if(!file_exists($mysql_backup_file)) {
292
+					throw new Exception(sprintf("Mysql backup file %s does not exists",$mysql_backup_file));
293
+		}
289 294
 		
290 295
 		
291 296
 		/*if(defined('XCLONER_PLUGIN_ACCESS') && XCLONER_PLUGIN_ACCESS)
@@ -317,16 +322,18 @@  discard block
 block discarded – undo
317 322
 			// process the line read.
318 323
 									
319 324
 				//check if line is comment
320
-				if(substr($line, 0, 1) == "#")
321
-					continue;
325
+				if(substr($line, 0, 1) == "#") {
326
+									continue;
327
+				}
322 328
 				
323 329
 				//check if line is empty	
324
-				if($line == "\n" or trim($line) == "")
325
-					continue;
330
+				if($line == "\n" or trim($line) == "") {
331
+									continue;
332
+				}
326 333
 					
327
-				if(substr($line, strlen($line)-2, strlen($line)) == ";\n")
328
-					$query .= $line;
329
-				else{
334
+				if(substr($line, strlen($line)-2, strlen($line)) == ";\n") {
335
+									$query .= $line;
336
+				} else{
330 337
 					$query .= $line;
331 338
 					continue;
332 339
 				}
@@ -385,7 +392,7 @@  discard block
 block discarded – undo
385 392
 		if(!feof($fp))
386 393
 		{
387 394
 			$return['finished'] = 0;
388
-		}else{
395
+		} else{
389 396
 			$this->logger->info(sprintf("Mysql Import Done."));
390 397
 		}
391 398
 		
@@ -437,7 +444,7 @@  discard block
 block discarded – undo
437 444
 			$tar->open($this->backup_storage_dir.DS.$backup_file, $start);
438 445
 		
439 446
 			$data = $tar->contents($this->process_files_limit_list);
440
-		}catch(Exception $e)
447
+		} catch(Exception $e)
441 448
 		{
442 449
 			$return['error'] = true;
443 450
 			$return['message'] = $e->getMessage();
@@ -465,15 +472,16 @@  discard block
 block discarded – undo
465 472
 		{
466 473
 			$return['start'] = $data['start'];
467 474
 			$return['finished'] = 0;	
468
-		}else{
475
+		} else{
469 476
 			if($this->is_multipart($source_backup_file))
470 477
 			{
471 478
 				$return['start'] = 0;
472 479
 				
473 480
 				++$return['part'];
474 481
 			
475
-				if($return['part'] < sizeof($backup_parts))	
476
-					$return['finished'] = 0;
482
+				if($return['part'] < sizeof($backup_parts)) {
483
+									$return['finished'] = 0;
484
+				}
477 485
 				
478 486
 			}
479 487
 		}	
@@ -590,19 +598,22 @@  discard block
 block discarded – undo
590 598
 		{
591 599
 			$config = file_get_contents($wp_config);
592 600
 			preg_match("/.*table_prefix.*=.*'(.*)'/i", $config, $matches);
593
-			if(isset($matches[1]))
594
-				$table_prefix = $matches[1];
595
-			else
596
-				throw new Exception("Could not load wordpress table prefix from wp-config.php file.");
601
+			if(isset($matches[1])) {
602
+							$table_prefix = $matches[1];
603
+			} else {
604
+							throw new Exception("Could not load wordpress table prefix from wp-config.php file.");
605
+			}
606
+		} else {
607
+					throw new Exception("Could not update the SITEURL and HOME, wp-config.php file not found");
597 608
 		}
598
-		else
599
-			throw new Exception("Could not update the SITEURL and HOME, wp-config.php file not found");
600 609
 			
601
-		if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='home'"))
602
-			throw new Exception(sprintf("Could not update the HOME option, error: %s\n", $mysqli->error));
610
+		if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='home'")) {
611
+					throw new Exception(sprintf("Could not update the HOME option, error: %s\n", $mysqli->error));
612
+		}
603 613
 		
604
-		if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='siteurl'"))
605
-			throw new Exception(sprintf("Could not update the SITEURL option, error: %s\n", $mysqli->error));
614
+		if(!$mysqli->query("update ".$table_prefix."options set option_value='".($url)."' where option_name='siteurl'")) {
615
+					throw new Exception(sprintf("Could not update the SITEURL option, error: %s\n", $mysqli->error));
616
+		}
606 617
 		
607 618
 		return true;
608 619
 	}
@@ -629,8 +640,9 @@  discard block
 block discarded – undo
629 640
 		
630 641
 		$this->logger->info(sprintf('Updating wp-config.php file with the new mysql details'));
631 642
 		
632
-		if(!file_put_contents($wp_config, $content))
633
-			throw new Exception("Could not write updated config data to ".$wp_config);
643
+		if(!file_put_contents($wp_config, $content)) {
644
+					throw new Exception("Could not write updated config data to ".$wp_config);
645
+		}
634 646
 		
635 647
 		chmod($wp_config, $file_perms);
636 648
 		
@@ -671,10 +683,11 @@  discard block
 block discarded – undo
671 683
 							$mysqldump_list[$file['path']]['size'] = $file['size'];
672 684
 							$mysqldump_list[$file['path']]['timestamp'] = date("d M,Y H:i",$file['timestamp']);
673 685
 							
674
-							if($hash and $hash == $matches[1])
675
-								$mysqldump_list[$file['path']]['selected'] = "selected";
676
-							else
677
-								$mysqldump_list[$file['path']]['selected'] = "";	
686
+							if($hash and $hash == $matches[1]) {
687
+															$mysqldump_list[$file['path']]['selected'] = "selected";
688
+							} else {
689
+															$mysqldump_list[$file['path']]['selected'] = "";
690
+							}
678 691
 						}
679 692
 					}
680 693
 				}
@@ -689,13 +702,15 @@  discard block
 block discarded – undo
689 702
 	
690 703
 	private function get_hash_from_backup($backup_file)
691 704
 	{
692
-		if(!$backup_file)
693
-			return false;
705
+		if(!$backup_file) {
706
+					return false;
707
+		}
694 708
 			
695 709
 		$result = preg_match("/-(\w*)./", substr($backup_file, strlen($backup_file)-10, strlen($backup_file)), $matches)	;
696 710
 		
697
-		if($result and isset($matches[1]))
698
-			return ($matches[1]);
711
+		if($result and isset($matches[1])) {
712
+					return ($matches[1]);
713
+		}
699 714
 		
700 715
 		return false;
701 716
 	}
@@ -715,10 +730,11 @@  discard block
 block discarded – undo
715 730
 			if(isset($file_info['extension']) and $file_info['extension'] == "csv")
716 731
 			{
717 732
 				$lines = explode(PHP_EOL, $this->filesystem->read($file_info['path']));
718
-				foreach($lines as $line)
719
-					if($line)
733
+				foreach($lines as $line) {
734
+									if($line)
720 735
 					{
721 736
 						$data = str_getcsv($line);
737
+				}
722 738
 						if(is_array($data)){
723 739
 							$parents[$data[0]] = $file_info['path'];
724 740
 							$file_info['childs'][] = $data;
@@ -728,20 +744,22 @@  discard block
 block discarded – undo
728 744
 						
729 745
 			}
730 746
 			
731
-			if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions))
732
-				$backup_files[$file_info['path']] = $file_info;
747
+			if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) {
748
+							$backup_files[$file_info['path']] = $file_info;
749
+			}
733 750
 		}
734 751
 		
735 752
 		$new_list = array();
736 753
 		
737 754
 		foreach($backup_files as $key=>$file_info)
738 755
 		{
739
-			if(isset($parents[$file_info['path']]))
740
-				$backup_files[$key]['parent'] = $parents[$file_info['path']];
741
-			else{
756
+			if(isset($parents[$file_info['path']])) {
757
+							$backup_files[$key]['parent'] = $parents[$file_info['path']];
758
+			} else{
742 759
 				
743
-				if($local_backup_file and ($file_info['basename'] == $local_backup_file))
744
-					$file_info['selected'] = 'selected';
760
+				if($local_backup_file and ($file_info['basename'] == $local_backup_file)) {
761
+									$file_info['selected'] = 'selected';
762
+				}
745 763
 				
746 764
 				$this->logger->info(sprintf('Found %s backup file', $file_info['path']));
747 765
 					
@@ -782,8 +800,9 @@  discard block
 block discarded – undo
782 800
 		$backup_archive = new Tar();
783 801
 		if($this->is_multipart($backup_file))
784 802
 		{
785
-			if(!$return['part'])
786
-				$return['processed'] += $this->filesystem->getSize($backup_file);
803
+			if(!$return['part']) {
804
+							$return['processed'] += $this->filesystem->getSize($backup_file);
805
+			}
787 806
 				
788 807
 			$backup_parts = $this->get_multipart_files($backup_file);
789 808
 			$backup_file = $backup_parts[$return['part']];	
@@ -803,12 +822,13 @@  discard block
 block discarded – undo
803 822
 			}
804 823
 		}
805 824
 		
806
-		if(isset($data['start']))
807
-		//if(isset($data['start']) and $data['start'] <= $this->filesystem->getSize($backup_file))
825
+		if(isset($data['start'])) {
826
+				//if(isset($data['start']) and $data['start'] <= $this->filesystem->getSize($backup_file))
808 827
 		{
809 828
 			$return['finished'] = 0;
829
+		}
810 830
 			$return['start'] = $data['start'];
811
-		}else{
831
+		} else{
812 832
 			
813 833
 			$return['processed'] += $start;
814 834
 			
@@ -818,14 +838,16 @@  discard block
 block discarded – undo
818 838
 				
819 839
 				++$return['part'];
820 840
 			
821
-				if($return['part'] < sizeof($backup_parts))	
822
-					$return['finished'] = 0;
841
+				if($return['part'] < sizeof($backup_parts)) {
842
+									$return['finished'] = 0;
843
+				}
823 844
 				
824 845
 			}
825 846
 		}
826 847
 		
827
-		if($return['finished'])
828
-			$this->logger->info(sprintf('Done extracting %s', $source_backup_file));
848
+		if($return['finished']) {
849
+					$this->logger->info(sprintf('Done extracting %s', $source_backup_file));
850
+		}
829 851
 		
830 852
 		$return['backup_file'] = $backup_file;
831 853
 		
@@ -854,8 +876,7 @@  discard block
 block discarded – undo
854 876
 			$return['remote_mysql_user'] 	= $wpdb->dbuser;
855 877
 			$return['remote_mysql_pass'] 	= $wpdb->dbpassword;
856 878
 			$return['remote_mysql_db'] 		= $wpdb->dbname;
857
-		}
858
-		else{
879
+		} else{
859 880
 			$return['dir'] = ($pathinfo['dirname']).DS.$suffix;
860 881
 			$return['restore_script_url'] = str_replace($pathinfo['basename'], "", $restore_script_url).$suffix;
861 882
 		}	
@@ -869,11 +890,13 @@  discard block
 block discarded – undo
869 890
 	{
870 891
 		//check if i can write
871 892
 		$tmp_file = md5(time());
872
-		if(!file_put_contents($tmp_file, "++"))
873
-			throw new Exception("Could not write to new host");
893
+		if(!file_put_contents($tmp_file, "++")) {
894
+					throw new Exception("Could not write to new host");
895
+		}
874 896
 		
875
-		if(!unlink($tmp_file))
876
-			throw new Exception("Could not delete temporary file from new host");
897
+		if(!unlink($tmp_file)) {
898
+					throw new Exception("Could not delete temporary file from new host");
899
+		}
877 900
 		
878 901
 		$max_upload      = $this->return_bytes((ini_get('upload_max_filesize')));
879 902
 		$max_post        = $this->return_bytes((ini_get('post_max_size')));
@@ -904,8 +927,9 @@  discard block
 block discarded – undo
904 927
 	
905 928
 	public function is_multipart($backup_name)
906 929
 	{
907
-		if(stristr($backup_name, "-multipart"))
908
-			return true;
930
+		if(stristr($backup_name, "-multipart")) {
931
+					return true;
932
+		}
909 933
 		
910 934
 		return false;	
911 935
 	}
@@ -916,8 +940,9 @@  discard block
 block discarded – undo
916 940
 		if($this->is_multipart($backup_name))
917 941
 		{
918 942
 			$backup_parts = $this->get_multipart_files($backup_name);
919
-			foreach($backup_parts as $part_file)
920
-				$backup_size += $this->filesystem->getSize($part_file);
943
+			foreach($backup_parts as $part_file) {
944
+							$backup_size += $this->filesystem->getSize($part_file);
945
+			}
921 946
 		}
922 947
 		
923 948
 		return $backup_size;
@@ -974,7 +999,7 @@  discard block
 block discarded – undo
974 999
 		{
975 1000
 			$return['statusText'] = $response['message'];
976 1001
 			$return['error'] = true;
977
-		}elseif($status != 200 and $status != 418)
1002
+		} elseif($status != 200 and $status != 418)
978 1003
 		{
979 1004
 			$return['error'] = true;
980 1005
 			$return['message'] = $response;
@@ -995,8 +1020,9 @@  discard block
 block discarded – undo
995 1020
 		return preg_replace_callback('!s:(\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!', function ($m) {
996 1021
 				  $data = "";
997 1022
 				  	
998
-				  if(!isset($m[3]))
999
-					$m[3] = "";
1023
+				  if(!isset($m[3])) {
1024
+				  					$m[3] = "";
1025
+				  }
1000 1026
 					
1001 1027
 					$data = 's:'.strlen(($m[3])).':\"'.($m[3]).'\";';
1002 1028
 	              //return $this->unescape_quotes($data);
@@ -1025,7 +1051,7 @@  discard block
 block discarded – undo
1025 1051
 		    stristr($s, ':' ) != false
1026 1052
 		    ){
1027 1053
 		    return true;
1028
-		}else{
1054
+		} else{
1029 1055
 		    return false;
1030 1056
 		}
1031 1057
 
Please login to merge, or discard this patch.
includes/class-xcloner-archive.php 2 patches
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -8,11 +8,11 @@  discard block
 block discarded – undo
8 8
 	/*
9 9
 	 * bytes
10 10
 	 */ 
11
-	private $file_size_per_request_limit	= 52428800 ; //50MB = 52428800; 1MB = 1048576
12
-	private $files_to_process_per_request 	= 250; //block of 512 bytes
13
-	private $compression_level 				= 0; //0-9 , 0 uncompressed
11
+	private $file_size_per_request_limit	= 52428800; //50MB = 52428800; 1MB = 1048576
12
+	private $files_to_process_per_request = 250; //block of 512 bytes
13
+	private $compression_level = 0; //0-9 , 0 uncompressed
14 14
 	private $xcloner_split_backup_limit		= 2048; //2048MB
15
-	private $processed_size_bytes			= 0 ;
15
+	private $processed_size_bytes = 0;
16 16
 	
17 17
 	private $archive_name;
18 18
 	private $backup_archive;
@@ -22,25 +22,25 @@  discard block
 block discarded – undo
22 22
 	
23 23
 	public function __construct(Xcloner $xcloner_container, $archive_name = "")
24 24
 	{
25
-		$this->filesystem 		= $xcloner_container->get_xcloner_filesystem();
26
-		$this->logger 			= $xcloner_container->get_xcloner_logger()->withName("xcloner_archive");
25
+		$this->filesystem = $xcloner_container->get_xcloner_filesystem();
26
+		$this->logger = $xcloner_container->get_xcloner_logger()->withName("xcloner_archive");
27 27
 		$this->xcloner_settings = $xcloner_container->get_xcloner_settings();
28 28
 		
29
-		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_size_limit_per_request'))
30
-			$this->file_size_per_request_limit = $value*1024*1024; //MB
29
+		if ($value = $this->xcloner_settings->get_xcloner_option('xcloner_size_limit_per_request'))
30
+			$this->file_size_per_request_limit = $value * 1024 * 1024; //MB
31 31
 			
32
-		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_files_to_process_per_request'))
32
+		if ($value = $this->xcloner_settings->get_xcloner_option('xcloner_files_to_process_per_request'))
33 33
 			$this->files_to_process_per_request = $value;
34 34
 		
35
-		if($value = get_option('xcloner_backup_compression_level'))
35
+		if ($value = get_option('xcloner_backup_compression_level'))
36 36
 			$this->compression_level = $value;
37 37
 		
38
-		if($value = get_option('xcloner_split_backup_limit'))
38
+		if ($value = get_option('xcloner_split_backup_limit'))
39 39
 			$this->xcloner_split_backup_limit = $value;
40 40
 		
41
-		$this->xcloner_split_backup_limit = $this->xcloner_split_backup_limit * 1024*1024; //transform to bytes
41
+		$this->xcloner_split_backup_limit = $this->xcloner_split_backup_limit * 1024 * 1024; //transform to bytes
42 42
 			
43
-		if(isset($archive_name) && $archive_name)
43
+		if (isset($archive_name) && $archive_name)
44 44
 		{
45 45
 			$this->set_archive_name($archive_name);
46 46
 		}
@@ -68,23 +68,23 @@  discard block
 block discarded – undo
68 68
 		
69 69
 		$this->archive_name = $this->filesystem->process_backup_name($name);
70 70
 		
71
-		if($diff_timestamp_start = $this->filesystem->get_diff_timestamp_start())
71
+		if ($diff_timestamp_start = $this->filesystem->get_diff_timestamp_start())
72 72
 		{
73 73
 			//$this->archive_name = $this->archive_name."-diff-".date("Y-m-d_H-i",$diff_timestamp_start);
74 74
 			$new_name = $this->archive_name;
75 75
 			
76
-			if(!stristr($new_name, "-diff"))
77
-				$new_name = $this->archive_name . "-diff".date("Y-m-d_H-i",$diff_timestamp_start);
76
+			if (!stristr($new_name, "-diff"))
77
+				$new_name = $this->archive_name."-diff".date("Y-m-d_H-i", $diff_timestamp_start);
78 78
 			
79 79
 			$this->archive_name = $new_name;
80 80
 			
81 81
 		}
82 82
 		
83
-		if(isset($part) and $part)
83
+		if (isset($part) and $part)
84 84
 		{
85
-			$new_name =  preg_replace('/-part(\d*)/', "-part".$part, $this->archive_name);
86
-			if(!stristr($new_name, "-part"))
87
-				$new_name = $this->archive_name . "-part".$part;
85
+			$new_name = preg_replace('/-part(\d*)/', "-part".$part, $this->archive_name);
86
+			if (!stristr($new_name, "-part"))
87
+				$new_name = $this->archive_name."-part".$part;
88 88
 			
89 89
 			$this->archive_name = $new_name;	
90 90
 		}
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 */ 
110 110
 	public function get_archive_name_multipart()
111 111
 	{
112
-		$new_name =  preg_replace('/-part(\d*)/', "", $this->archive_name);
112
+		$new_name = preg_replace('/-part(\d*)/', "", $this->archive_name);
113 113
 		return $new_name."-multipart".$this->xcloner_settings->get_backup_extension_name(".csv");
114 114
 	}
115 115
 	
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	public function send_notification_error($to, $from, $subject, $backup_name, $params, $error_message)
132 132
 	{
133 133
 		
134
-		$body  = $error_message; 
134
+		$body = $error_message; 
135 135
 		
136 136
 		$this->logger->info(sprintf("Sending backup error notification to %s", $to));
137 137
 		
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
 		
140 140
 		$headers = array('Content-Type: text/html; charset=UTF-8');
141 141
 		
142
-		if($admin_email and $from )
142
+		if ($admin_email and $from)
143 143
 			$headers[] = 'From: '.$from.' <'.$admin_email.'>';
144 144
 
145
-		$return = wp_mail( $to, $subject, $body, $headers );
145
+		$return = wp_mail($to, $subject, $body, $headers);
146 146
 		
147 147
 		return $return;
148 148
 	}
@@ -152,29 +152,29 @@  discard block
 block discarded – undo
152 152
 	 * Send backup archive notfication by E-Mail
153 153
 	 * 
154 154
 	 */ 
155
-	public function send_notification($to, $from, $subject, $backup_name, $params, $error_message="", $additional = array())
155
+	public function send_notification($to, $from, $subject, $backup_name, $params, $error_message = "", $additional = array())
156 156
 	{
157
-		if(!$from)
157
+		if (!$from)
158 158
 		{
159 159
 			$from = "XCloner Backup";
160 160
 		}
161 161
 			
162
-		if(($error_message))
162
+		if (($error_message))
163 163
 		{
164 164
 			return $this->send_notification_error($to, $from, $subject, $backup_name, $params, $error_message);
165 165
 		}
166 166
 		
167 167
 		$params = (array)$params;
168 168
 		
169
-		if(!$subject)
169
+		if (!$subject)
170 170
 		{
171
-			$subject = sprintf(__("New backup generated %s") ,$backup_name);
171
+			$subject = sprintf(__("New backup generated %s"), $backup_name);
172 172
 		}
173 173
 			
174 174
 		$body = sprintf(__("Generated Backup Size: %s"), size_format($this->filesystem->get_backup_size($backup_name)));
175 175
 		$body .= "<br /><br />";
176 176
 		
177
-		if(isset($additional['lines_total']))
177
+		if (isset($additional['lines_total']))
178 178
 		{
179 179
 			$body .= sprintf(__("Total files added: %s"), $additional['lines_total']);
180 180
 			$body .= "<br /><br />";
@@ -182,27 +182,27 @@  discard block
 block discarded – undo
182 182
 		
183 183
 		$backup_parts = $this->filesystem->get_multipart_files($backup_name);
184 184
 		
185
-		if(!$backups_counter = sizeof($backup_parts))
185
+		if (!$backups_counter = sizeof($backup_parts))
186 186
 			$backups_counter = 1;
187 187
 		
188 188
 		$body .= sprintf(__("Backup Parts: %s"), $backups_counter);
189 189
 		$body .= "<br />";
190 190
 		
191
-		if(sizeof($backup_parts))
191
+		if (sizeof($backup_parts))
192 192
 		{
193
-			$body .= implode("<br />",$backup_parts);
193
+			$body .= implode("<br />", $backup_parts);
194 194
 			$body .= "<br />";
195 195
 		}
196 196
 		
197
-		$body.= "<br />";
197
+		$body .= "<br />";
198 198
 		
199
-		if(isset($params['backup_params']->backup_comments))
199
+		if (isset($params['backup_params']->backup_comments))
200 200
 		{
201 201
 			$body .= __("Backup Comments: ").$params['backup_params']->backup_comments;
202 202
 			$body .= "<br /><br />";
203 203
 		}
204 204
 		
205
-		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log'))
205
+		if ($this->xcloner_settings->get_xcloner_option('xcloner_enable_log'))
206 206
 			$body .= __("Latest 50 Log Lines: ")."<br />".implode("<br />\n", $this->logger->getLastDebugLines(50));
207 207
 		
208 208
 		$attachments = $this->filesystem->get_backup_attachments();
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 		$tar = new Tar();
213 213
 		$tar->create($attachments_archive);
214 214
 			
215
-		foreach($attachments as $key => $file)
215
+		foreach ($attachments as $key => $file)
216 216
 		{
217 217
 			$tar->addFile($file, basename($file));
218 218
 		}
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		
225 225
 		$headers = array('Content-Type: text/html; charset=UTF-8', 'From: '.$from.' <'.$admin_email.'>');
226 226
 		
227
-		$return = wp_mail( $to, $subject, $body, $headers, array($attachments_archive) );
227
+		$return = wp_mail($to, $subject, $body, $headers, array($attachments_archive));
228 228
 	
229 229
 		return $return;
230 230
 	}
@@ -238,17 +238,17 @@  discard block
 block discarded – undo
238 238
 	{
239 239
 		$return = array();
240 240
 		
241
-		if(!isset($extra_params['backup_part']))
241
+		if (!isset($extra_params['backup_part']))
242 242
 			$extra_params['backup_part'] = 0;
243 243
 		
244 244
 		$return['extra']['backup_part'] = $extra_params['backup_part'];
245 245
 					
246
-		if(isset( $extra_params['backup_archive_name']))
246
+		if (isset($extra_params['backup_archive_name']))
247 247
 			$this->set_archive_name($extra_params['backup_archive_name'], $return['extra']['backup_part']);
248 248
 		else
249 249
 			$this->set_archive_name($backup_params['backup_name']);
250 250
 			
251
-		if(!$this->get_archive_name())
251
+		if (!$this->get_archive_name())
252 252
 			$this->set_archive_name();
253 253
 		
254 254
 		$this->backup_archive = new Tar();
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 		
257 257
 		$archive_info = $this->filesystem->get_storage_path_file_info($this->get_archive_name_with_extension());
258 258
 		
259
-		if($init)
259
+		if ($init)
260 260
 		{
261 261
 			$this->logger->info(sprintf(__("Initializing the backup archive %s"), $this->get_archive_name()));
262 262
 		
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 			
265 265
 			$return['extra']['backup_init'] = 1;
266 266
 			
267
-		}else{
267
+		} else {
268 268
 			$this->logger->info(sprintf(__("Opening for append the backup archive %s"), $this->get_archive_name()));
269 269
 			
270 270
 			$this->backup_archive->openForAppend($archive_info->getPath().DS.$archive_info->getFilename());
@@ -276,13 +276,13 @@  discard block
 block discarded – undo
276 276
 		$return['extra']['backup_archive_name'] = $this->get_archive_name();
277 277
 		$return['extra']['backup_archive_name_full'] = $this->get_archive_name_with_extension();
278 278
 		
279
-		if(!isset($extra_params['start_at_line']))
279
+		if (!isset($extra_params['start_at_line']))
280 280
 			$extra_params['start_at_line'] = 0;
281 281
 		
282
-		if(!isset($extra_params['start_at_byte']))
282
+		if (!isset($extra_params['start_at_byte']))
283 283
 			$extra_params['start_at_byte'] = 0;
284 284
 		
285
-		if(!$this->filesystem->get_tmp_filesystem()->has($this->filesystem->get_included_files_handler()))
285
+		if (!$this->filesystem->get_tmp_filesystem()->has($this->filesystem->get_included_files_handler()))
286 286
 		{
287 287
 			$this->logger->error(sprintf("Missing the includes file handler %s, aborting...", $this->filesystem->get_included_files_handler()));
288 288
 			
@@ -296,14 +296,14 @@  discard block
 block discarded – undo
296 296
 		
297 297
 		$file->seek(PHP_INT_MAX);
298 298
 
299
-		$return['extra']['lines_total'] = ($file->key()-1);
299
+		$return['extra']['lines_total'] = ($file->key() - 1);
300 300
 		
301 301
 		//we skip the first CSV line with headers 
302
-		if(!$extra_params['start_at_line'])
302
+		if (!$extra_params['start_at_line'])
303 303
 		{
304 304
 			$file->seek(1);
305
-		}else{
306
-			$file->seek($extra_params['start_at_line']+1);
305
+		} else {
306
+			$file->seek($extra_params['start_at_line'] + 1);
307 307
 		}
308 308
 		
309 309
 		$this->processed_size_bytes = 0;
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 		
315 315
 		$byte_limit = 0;
316 316
 		
317
-		while(!$file->eof() and $counter<=$this->files_to_process_per_request)
317
+		while (!$file->eof() and $counter <= $this->files_to_process_per_request)
318 318
 		{
319 319
 			$current_line_str = $file->current();
320 320
 			
@@ -324,15 +324,15 @@  discard block
 block discarded – undo
324 324
 			
325 325
 			$start_filesystem = "start_filesystem";
326 326
 			
327
-			if(isset($line[4])){
327
+			if (isset($line[4])) {
328 328
 				$start_filesystem = $line[4];
329 329
 			}
330 330
 			
331 331
 			//$adapter = $this->filesystem->get_adapter($start_filesystem);
332 332
 			
333
-			if(!$relative_path || !$this->filesystem->get_filesystem($start_filesystem)->has($relative_path))
333
+			if (!$relative_path || !$this->filesystem->get_filesystem($start_filesystem)->has($relative_path))
334 334
 			{
335
-				if($relative_path != "")
335
+				if ($relative_path != "")
336 336
 				{
337 337
 					$this->logger->error(sprintf("Could not add file %b to backup archive, file not found", $relative_path));
338 338
 				}
@@ -344,37 +344,37 @@  discard block
 block discarded – undo
344 344
 			
345 345
 			$file_info = $this->filesystem->get_filesystem($start_filesystem)->getMetadata($relative_path);
346 346
 			
347
-			if(!isset($file_info['size']))
347
+			if (!isset($file_info['size']))
348 348
 				$file_info['size'] = 0;
349 349
 			
350
-			if($start_filesystem == "tmp_filesystem")
350
+			if ($start_filesystem == "tmp_filesystem")
351 351
 			{	
352 352
 				$file_info['archive_prefix_path'] = $this->xcloner_settings->get_xcloner_tmp_path_suffix();
353 353
 			}
354 354
 			
355
-			$byte_limit = (int)$this->file_size_per_request_limit/512;
355
+			$byte_limit = (int)$this->file_size_per_request_limit / 512;
356 356
 			
357 357
 			$append = 0;
358 358
 			
359
-			if($file_info['size'] > $byte_limit*512 or $start_byte)
359
+			if ($file_info['size'] > $byte_limit * 512 or $start_byte)
360 360
 				$append = 1;
361 361
 						
362
-			if(!isset($return['extra']['backup_size']))
363
-				$return['extra']['backup_size'] =0;
362
+			if (!isset($return['extra']['backup_size']))
363
+				$return['extra']['backup_size'] = 0;
364 364
 			
365 365
 			$return['extra']['backup_size'] = $archive_info->getSize();
366 366
 			
367 367
 			$estimated_new_size = $return['extra']['backup_size'] + $file_info['size'];
368 368
 			
369 369
 			//we create a new backup part if we reach the Split Achive Limit
370
-			if($this->xcloner_split_backup_limit and ($estimated_new_size > $this->xcloner_split_backup_limit) and (!$start_byte))
370
+			if ($this->xcloner_split_backup_limit and ($estimated_new_size > $this->xcloner_split_backup_limit) and (!$start_byte))
371 371
 			{
372
-				$this->logger->info(sprintf("Backup size limit %s bytes reached, file add estimate %s, attempt to create a new archive ",$this->xcloner_split_backup_limit, $estimated_new_size));
372
+				$this->logger->info(sprintf("Backup size limit %s bytes reached, file add estimate %s, attempt to create a new archive ", $this->xcloner_split_backup_limit, $estimated_new_size));
373 373
 				list($archive_info, $return['extra']['backup_part']) = $this->create_new_backup_part($return['extra']['backup_part']);
374 374
 				
375
-				if($file_info['size'] > $this->xcloner_split_backup_limit)
375
+				if ($file_info['size'] > $this->xcloner_split_backup_limit)
376 376
 				{
377
-					$this->logger->info(sprintf("Excluding %s file as it's size(%s) is bigger than the backup split limit of %s and it won't fit a single backup file",$file_info['path'], $file_info['size'], $this->xcloner_split_backup_limit));
377
+					$this->logger->info(sprintf("Excluding %s file as it's size(%s) is bigger than the backup split limit of %s and it won't fit a single backup file", $file_info['path'], $file_info['size'], $this->xcloner_split_backup_limit));
378 378
 					$extra_params['start_at_line']++;
379 379
 				}
380 380
 				
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 				return $return;
387 387
 			}
388 388
 			
389
-			list($bytes_wrote, $last_position) = $this->add_file_to_archive( $file_info, $start_byte, $byte_limit, $append, $start_filesystem);
389
+			list($bytes_wrote, $last_position) = $this->add_file_to_archive($file_info, $start_byte, $byte_limit, $append, $start_filesystem);
390 390
 			$this->processed_size_bytes += $bytes_wrote;
391 391
 			
392 392
 			//echo" - processed ".$this->processed_size_bytes." bytes ".$this->file_size_per_request_limit." last_position:".$last_position." \n";
@@ -394,17 +394,17 @@  discard block
 block discarded – undo
394 394
 			$return['extra']['processed_file_size'] = $file_info['size'];
395 395
 			$return['extra']['backup_size'] = $archive_info->getSize();
396 396
 			
397
-			if($last_position>0){	
397
+			if ($last_position > 0) {	
398 398
 				$start_byte = $last_position;
399 399
 			}
400
-			else{	
400
+			else {	
401 401
 				$extra_params['start_at_line']++;
402 402
 				$file->next();
403 403
 				$start_byte = 0;
404 404
 				$counter++;
405 405
 			}
406 406
 			
407
-			if($this->processed_size_bytes >= $this->file_size_per_request_limit)
407
+			if ($this->processed_size_bytes >= $this->file_size_per_request_limit)
408 408
 			{
409 409
 				clearstatcache();
410 410
 				$return['extra']['backup_size'] = $archive_info->getSize();
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 			}
418 418
 		}
419 419
 		
420
-		if(!$file->eof())
420
+		if (!$file->eof())
421 421
 		{
422 422
 			clearstatcache();
423 423
 			$return['extra']['backup_size'] = $archive_info->getSize();
@@ -434,12 +434,12 @@  discard block
 block discarded – undo
434 434
 		$this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.", $this->get_archive_name_with_extension()));
435 435
 		$this->backup_archive->close();
436 436
 				
437
-		if($return['extra']['backup_part'])
437
+		if ($return['extra']['backup_part'])
438 438
 			$this->write_multipart_file($this->get_archive_name_with_extension());
439 439
 		
440
-		$return['extra']['start_at_line'] = $extra_params['start_at_line']-1;
440
+		$return['extra']['start_at_line'] = $extra_params['start_at_line'] - 1;
441 441
 		
442
-		if(isset($file_info))
442
+		if (isset($file_info))
443 443
 		{
444 444
 			$return['extra']['processed_file'] = $file_info['path'];
445 445
 			$return['extra']['processed_file_size'] = $file_info['size'];
@@ -481,20 +481,20 @@  discard block
 block discarded – undo
481 481
 		$this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.", $this->get_archive_name_with_extension()));
482 482
 		$this->backup_archive->close();		
483 483
 		
484
-		if(!$part)
484
+		if (!$part)
485 485
 		{
486 486
 			$old_name = $this->get_archive_name_with_extension();
487 487
 			$this->set_archive_name($this->get_archive_name(), ++$part);
488 488
 			$this->rename_archive($old_name, $this->get_archive_name_with_extension());
489 489
 			
490
-			if($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart()))
490
+			if ($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart()))
491 491
 				$this->filesystem->get_storage_filesystem()->delete($this->get_archive_name_multipart());
492 492
 				
493 493
 			$this->write_multipart_file($this->get_archive_name_with_extension());
494 494
 			
495
-		}else
495
+		} else
496 496
 		{
497
-			$this->logger->info(sprintf("Creating new multipart info file %s",$this->get_archive_name_with_extension()));
497
+			$this->logger->info(sprintf("Creating new multipart info file %s", $this->get_archive_name_with_extension()));
498 498
 			$this->write_multipart_file($this->get_archive_name_with_extension());
499 499
 		}
500 500
 				
@@ -522,10 +522,10 @@  discard block
 block discarded – undo
522 522
 		$start_adapter = $this->filesystem->get_adapter($filesystem);
523 523
 		$start_filesystem = $this->filesystem->get_adapter($filesystem);
524 524
 		
525
-		if(!$file_info['path'])
525
+		if (!$file_info['path'])
526 526
 			return;
527 527
 		
528
-		if(isset($file_info['archive_prefix_path']))	
528
+		if (isset($file_info['archive_prefix_path']))	
529 529
 			$file_info['target_path'] = $file_info['archive_prefix_path']."/".$file_info['path'];
530 530
 		else
531 531
 			$file_info['target_path'] = $file_info['path'];
@@ -534,36 +534,36 @@  discard block
 block discarded – undo
534 534
 		
535 535
 		//$start_adapter = $this->filesystem->get_start_adapter();
536 536
 
537
-		if(!$append){
537
+		if (!$append) {
538 538
 			$bytes_wrote = $file_info['size'];
539 539
 			$this->logger->info(sprintf("Adding %s bytes of file %s to archive %s ", $bytes_wrote, $file_info['target_path'], $this->get_archive_name_with_extension()));
540 540
 			$this->backup_archive->addFile($start_adapter->applyPathPrefix($file_info['path']), $file_info['target_path']);
541 541
 		}
542
-		else{	
542
+		else {	
543 543
 			$tmp_file = md5($file_info['path']);
544 544
 			
545 545
 			//we isolate file to tmp if we are at byte 0, the starting point of file reading
546
-			if(!$start_at_byte)
546
+			if (!$start_at_byte)
547 547
 			{
548 548
 				$this->logger->info(sprintf("Copying %s file to tmp filesystem file %s to prevent reading changes", $file_info['path'], $tmp_file));
549 549
 				$file_stream = $start_filesystem->readStream($file_info['path']);
550 550
 				
551
-				if(is_resource($file_stream['stream']))
551
+				if (is_resource($file_stream['stream']))
552 552
 					$this->filesystem->get_tmp_filesystem()->writeStream($tmp_file, $file_stream['stream']);
553 553
 			}
554 554
 			
555
-			if($this->filesystem->get_tmp_filesystem()->has($tmp_file))
555
+			if ($this->filesystem->get_tmp_filesystem()->has($tmp_file))
556 556
 			{
557 557
 				$is_tmp = 1;
558 558
 				$last_position = $this->backup_archive->appendFileData($this->filesystem->get_tmp_filesystem_adapter()->applyPathPrefix($tmp_file), $file_info['target_path'], $start_at_byte, $byte_limit);
559 559
 			}
560
-			else{
560
+			else {
561 561
 				$is_tmp = 0;
562 562
 				$last_position = $this->backup_archive->appendFileData($start_adapter->applyPathPrefix($file_info['path']), $file_info['target_path'], $start_at_byte, $byte_limit);
563 563
 			}
564 564
 				
565 565
 			
566
-			if($last_position == -1)
566
+			if ($last_position == -1)
567 567
 			{
568 568
 				$bytes_wrote = $file_info['size'] - $start_at_byte;
569 569
 			}
@@ -573,18 +573,18 @@  discard block
 block discarded – undo
573 573
 			}
574 574
 			
575 575
 			
576
-			if($is_tmp)
576
+			if ($is_tmp)
577 577
 			{
578 578
 				$this->logger->info(sprintf("Appended %s bytes, starting position %s, of tmp file %s (%s) to archive %s ", $bytes_wrote, $start_at_byte, $tmp_file, $file_info['target_path'], $this->get_archive_name()));
579 579
 			}
580
-			else{
580
+			else {
581 581
 				$this->logger->info(sprintf("Appended %s bytes, starting position %s, of original file %s to archive %s ", $bytes_wrote, $start_at_byte, $file_info['target_path'], $tmp_file, $this->get_archive_name()));
582 582
 			}
583 583
 			
584 584
 			//we delete here the isolated tmp file
585
-			if($last_position == -1)
585
+			if ($last_position == -1)
586 586
 			{
587
-				if($this->filesystem->get_tmp_filesystem_adapter()->has($tmp_file))
587
+				if ($this->filesystem->get_tmp_filesystem_adapter()->has($tmp_file))
588 588
 				{
589 589
 					$this->logger->info(sprintf("Deleting %s from the tmp filesystem", $tmp_file));
590 590
 					$this->filesystem->get_tmp_filesystem_adapter()->delete($tmp_file);
Please login to merge, or discard this patch.
Braces   +79 added lines, -61 removed lines patch added patch discarded remove patch
@@ -26,17 +26,22 @@  discard block
 block discarded – undo
26 26
 		$this->logger 			= $xcloner_container->get_xcloner_logger()->withName("xcloner_archive");
27 27
 		$this->xcloner_settings = $xcloner_container->get_xcloner_settings();
28 28
 		
29
-		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_size_limit_per_request'))
30
-			$this->file_size_per_request_limit = $value*1024*1024; //MB
29
+		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_size_limit_per_request')) {
30
+					$this->file_size_per_request_limit = $value*1024*1024;
31
+		}
32
+		//MB
31 33
 			
32
-		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_files_to_process_per_request'))
33
-			$this->files_to_process_per_request = $value;
34
+		if($value = $this->xcloner_settings->get_xcloner_option('xcloner_files_to_process_per_request')) {
35
+					$this->files_to_process_per_request = $value;
36
+		}
34 37
 		
35
-		if($value = get_option('xcloner_backup_compression_level'))
36
-			$this->compression_level = $value;
38
+		if($value = get_option('xcloner_backup_compression_level')) {
39
+					$this->compression_level = $value;
40
+		}
37 41
 		
38
-		if($value = get_option('xcloner_split_backup_limit'))
39
-			$this->xcloner_split_backup_limit = $value;
42
+		if($value = get_option('xcloner_split_backup_limit')) {
43
+					$this->xcloner_split_backup_limit = $value;
44
+		}
40 45
 		
41 46
 		$this->xcloner_split_backup_limit = $this->xcloner_split_backup_limit * 1024*1024; //transform to bytes
42 47
 			
@@ -73,8 +78,9 @@  discard block
 block discarded – undo
73 78
 			//$this->archive_name = $this->archive_name."-diff-".date("Y-m-d_H-i",$diff_timestamp_start);
74 79
 			$new_name = $this->archive_name;
75 80
 			
76
-			if(!stristr($new_name, "-diff"))
77
-				$new_name = $this->archive_name . "-diff".date("Y-m-d_H-i",$diff_timestamp_start);
81
+			if(!stristr($new_name, "-diff")) {
82
+							$new_name = $this->archive_name . "-diff".date("Y-m-d_H-i",$diff_timestamp_start);
83
+			}
78 84
 			
79 85
 			$this->archive_name = $new_name;
80 86
 			
@@ -83,8 +89,9 @@  discard block
 block discarded – undo
83 89
 		if(isset($part) and $part)
84 90
 		{
85 91
 			$new_name =  preg_replace('/-part(\d*)/', "-part".$part, $this->archive_name);
86
-			if(!stristr($new_name, "-part"))
87
-				$new_name = $this->archive_name . "-part".$part;
92
+			if(!stristr($new_name, "-part")) {
93
+							$new_name = $this->archive_name . "-part".$part;
94
+			}
88 95
 			
89 96
 			$this->archive_name = $new_name;	
90 97
 		}
@@ -139,8 +146,9 @@  discard block
 block discarded – undo
139 146
 		
140 147
 		$headers = array('Content-Type: text/html; charset=UTF-8');
141 148
 		
142
-		if($admin_email and $from )
143
-			$headers[] = 'From: '.$from.' <'.$admin_email.'>';
149
+		if($admin_email and $from ) {
150
+					$headers[] = 'From: '.$from.' <'.$admin_email.'>';
151
+		}
144 152
 
145 153
 		$return = wp_mail( $to, $subject, $body, $headers );
146 154
 		
@@ -182,8 +190,9 @@  discard block
 block discarded – undo
182 190
 		
183 191
 		$backup_parts = $this->filesystem->get_multipart_files($backup_name);
184 192
 		
185
-		if(!$backups_counter = sizeof($backup_parts))
186
-			$backups_counter = 1;
193
+		if(!$backups_counter = sizeof($backup_parts)) {
194
+					$backups_counter = 1;
195
+		}
187 196
 		
188 197
 		$body .= sprintf(__("Backup Parts: %s"), $backups_counter);
189 198
 		$body .= "<br />";
@@ -202,8 +211,9 @@  discard block
 block discarded – undo
202 211
 			$body .= "<br /><br />";
203 212
 		}
204 213
 		
205
-		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log'))
206
-			$body .= __("Latest 50 Log Lines: ")."<br />".implode("<br />\n", $this->logger->getLastDebugLines(50));
214
+		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) {
215
+					$body .= __("Latest 50 Log Lines: ")."<br />".implode("<br />\n", $this->logger->getLastDebugLines(50));
216
+		}
207 217
 		
208 218
 		$attachments = $this->filesystem->get_backup_attachments();
209 219
 		
@@ -238,18 +248,21 @@  discard block
 block discarded – undo
238 248
 	{
239 249
 		$return = array();
240 250
 		
241
-		if(!isset($extra_params['backup_part']))
242
-			$extra_params['backup_part'] = 0;
251
+		if(!isset($extra_params['backup_part'])) {
252
+					$extra_params['backup_part'] = 0;
253
+		}
243 254
 		
244 255
 		$return['extra']['backup_part'] = $extra_params['backup_part'];
245 256
 					
246
-		if(isset( $extra_params['backup_archive_name']))
247
-			$this->set_archive_name($extra_params['backup_archive_name'], $return['extra']['backup_part']);
248
-		else
249
-			$this->set_archive_name($backup_params['backup_name']);
257
+		if(isset( $extra_params['backup_archive_name'])) {
258
+					$this->set_archive_name($extra_params['backup_archive_name'], $return['extra']['backup_part']);
259
+		} else {
260
+					$this->set_archive_name($backup_params['backup_name']);
261
+		}
250 262
 			
251
-		if(!$this->get_archive_name())
252
-			$this->set_archive_name();
263
+		if(!$this->get_archive_name()) {
264
+					$this->set_archive_name();
265
+		}
253 266
 		
254 267
 		$this->backup_archive = new Tar();
255 268
 		$this->backup_archive->setCompression($this->compression_level);
@@ -264,7 +277,7 @@  discard block
 block discarded – undo
264 277
 			
265 278
 			$return['extra']['backup_init'] = 1;
266 279
 			
267
-		}else{
280
+		} else{
268 281
 			$this->logger->info(sprintf(__("Opening for append the backup archive %s"), $this->get_archive_name()));
269 282
 			
270 283
 			$this->backup_archive->openForAppend($archive_info->getPath().DS.$archive_info->getFilename());
@@ -276,11 +289,13 @@  discard block
 block discarded – undo
276 289
 		$return['extra']['backup_archive_name'] = $this->get_archive_name();
277 290
 		$return['extra']['backup_archive_name_full'] = $this->get_archive_name_with_extension();
278 291
 		
279
-		if(!isset($extra_params['start_at_line']))
280
-			$extra_params['start_at_line'] = 0;
292
+		if(!isset($extra_params['start_at_line'])) {
293
+					$extra_params['start_at_line'] = 0;
294
+		}
281 295
 		
282
-		if(!isset($extra_params['start_at_byte']))
283
-			$extra_params['start_at_byte'] = 0;
296
+		if(!isset($extra_params['start_at_byte'])) {
297
+					$extra_params['start_at_byte'] = 0;
298
+		}
284 299
 		
285 300
 		if(!$this->filesystem->get_tmp_filesystem()->has($this->filesystem->get_included_files_handler()))
286 301
 		{
@@ -302,7 +317,7 @@  discard block
 block discarded – undo
302 317
 		if(!$extra_params['start_at_line'])
303 318
 		{
304 319
 			$file->seek(1);
305
-		}else{
320
+		} else{
306 321
 			$file->seek($extra_params['start_at_line']+1);
307 322
 		}
308 323
 		
@@ -344,8 +359,9 @@  discard block
 block discarded – undo
344 359
 			
345 360
 			$file_info = $this->filesystem->get_filesystem($start_filesystem)->getMetadata($relative_path);
346 361
 			
347
-			if(!isset($file_info['size']))
348
-				$file_info['size'] = 0;
362
+			if(!isset($file_info['size'])) {
363
+							$file_info['size'] = 0;
364
+			}
349 365
 			
350 366
 			if($start_filesystem == "tmp_filesystem")
351 367
 			{	
@@ -356,11 +372,13 @@  discard block
 block discarded – undo
356 372
 			
357 373
 			$append = 0;
358 374
 			
359
-			if($file_info['size'] > $byte_limit*512 or $start_byte)
360
-				$append = 1;
375
+			if($file_info['size'] > $byte_limit*512 or $start_byte) {
376
+							$append = 1;
377
+			}
361 378
 						
362
-			if(!isset($return['extra']['backup_size']))
363
-				$return['extra']['backup_size'] =0;
379
+			if(!isset($return['extra']['backup_size'])) {
380
+							$return['extra']['backup_size'] =0;
381
+			}
364 382
 			
365 383
 			$return['extra']['backup_size'] = $archive_info->getSize();
366 384
 			
@@ -396,8 +414,7 @@  discard block
 block discarded – undo
396 414
 			
397 415
 			if($last_position>0){	
398 416
 				$start_byte = $last_position;
399
-			}
400
-			else{	
417
+			} else{	
401 418
 				$extra_params['start_at_line']++;
402 419
 				$file->next();
403 420
 				$start_byte = 0;
@@ -434,8 +451,9 @@  discard block
 block discarded – undo
434 451
 		$this->logger->info(sprintf("Closing the backup archive %s with 2*512 zero bytes blocks.", $this->get_archive_name_with_extension()));
435 452
 		$this->backup_archive->close();
436 453
 				
437
-		if($return['extra']['backup_part'])
438
-			$this->write_multipart_file($this->get_archive_name_with_extension());
454
+		if($return['extra']['backup_part']) {
455
+					$this->write_multipart_file($this->get_archive_name_with_extension());
456
+		}
439 457
 		
440 458
 		$return['extra']['start_at_line'] = $extra_params['start_at_line']-1;
441 459
 		
@@ -487,12 +505,13 @@  discard block
 block discarded – undo
487 505
 			$this->set_archive_name($this->get_archive_name(), ++$part);
488 506
 			$this->rename_archive($old_name, $this->get_archive_name_with_extension());
489 507
 			
490
-			if($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart()))
491
-				$this->filesystem->get_storage_filesystem()->delete($this->get_archive_name_multipart());
508
+			if($this->filesystem->get_storage_filesystem()->has($this->get_archive_name_multipart())) {
509
+							$this->filesystem->get_storage_filesystem()->delete($this->get_archive_name_multipart());
510
+			}
492 511
 				
493 512
 			$this->write_multipart_file($this->get_archive_name_with_extension());
494 513
 			
495
-		}else
514
+		} else
496 515
 		{
497 516
 			$this->logger->info(sprintf("Creating new multipart info file %s",$this->get_archive_name_with_extension()));
498 517
 			$this->write_multipart_file($this->get_archive_name_with_extension());
@@ -522,13 +541,15 @@  discard block
 block discarded – undo
522 541
 		$start_adapter = $this->filesystem->get_adapter($filesystem);
523 542
 		$start_filesystem = $this->filesystem->get_adapter($filesystem);
524 543
 		
525
-		if(!$file_info['path'])
526
-			return;
544
+		if(!$file_info['path']) {
545
+					return;
546
+		}
527 547
 		
528
-		if(isset($file_info['archive_prefix_path']))	
529
-			$file_info['target_path'] = $file_info['archive_prefix_path']."/".$file_info['path'];
530
-		else
531
-			$file_info['target_path'] = $file_info['path'];
548
+		if(isset($file_info['archive_prefix_path'])) {
549
+					$file_info['target_path'] = $file_info['archive_prefix_path']."/".$file_info['path'];
550
+		} else {
551
+					$file_info['target_path'] = $file_info['path'];
552
+		}
532 553
 			
533 554
 		$last_position = $start_at_byte;
534 555
 		
@@ -538,8 +559,7 @@  discard block
 block discarded – undo
538 559
 			$bytes_wrote = $file_info['size'];
539 560
 			$this->logger->info(sprintf("Adding %s bytes of file %s to archive %s ", $bytes_wrote, $file_info['target_path'], $this->get_archive_name_with_extension()));
540 561
 			$this->backup_archive->addFile($start_adapter->applyPathPrefix($file_info['path']), $file_info['target_path']);
541
-		}
542
-		else{	
562
+		} else{	
543 563
 			$tmp_file = md5($file_info['path']);
544 564
 			
545 565
 			//we isolate file to tmp if we are at byte 0, the starting point of file reading
@@ -548,16 +568,16 @@  discard block
 block discarded – undo
548 568
 				$this->logger->info(sprintf("Copying %s file to tmp filesystem file %s to prevent reading changes", $file_info['path'], $tmp_file));
549 569
 				$file_stream = $start_filesystem->readStream($file_info['path']);
550 570
 				
551
-				if(is_resource($file_stream['stream']))
552
-					$this->filesystem->get_tmp_filesystem()->writeStream($tmp_file, $file_stream['stream']);
571
+				if(is_resource($file_stream['stream'])) {
572
+									$this->filesystem->get_tmp_filesystem()->writeStream($tmp_file, $file_stream['stream']);
573
+				}
553 574
 			}
554 575
 			
555 576
 			if($this->filesystem->get_tmp_filesystem()->has($tmp_file))
556 577
 			{
557 578
 				$is_tmp = 1;
558 579
 				$last_position = $this->backup_archive->appendFileData($this->filesystem->get_tmp_filesystem_adapter()->applyPathPrefix($tmp_file), $file_info['target_path'], $start_at_byte, $byte_limit);
559
-			}
560
-			else{
580
+			} else{
561 581
 				$is_tmp = 0;
562 582
 				$last_position = $this->backup_archive->appendFileData($start_adapter->applyPathPrefix($file_info['path']), $file_info['target_path'], $start_at_byte, $byte_limit);
563 583
 			}
@@ -566,8 +586,7 @@  discard block
 block discarded – undo
566 586
 			if($last_position == -1)
567 587
 			{
568 588
 				$bytes_wrote = $file_info['size'] - $start_at_byte;
569
-			}
570
-			else
589
+			} else
571 590
 			{
572 591
 				$bytes_wrote = $last_position - $start_at_byte;
573 592
 			}
@@ -576,8 +595,7 @@  discard block
 block discarded – undo
576 595
 			if($is_tmp)
577 596
 			{
578 597
 				$this->logger->info(sprintf("Appended %s bytes, starting position %s, of tmp file %s (%s) to archive %s ", $bytes_wrote, $start_at_byte, $tmp_file, $file_info['target_path'], $this->get_archive_name()));
579
-			}
580
-			else{
598
+			} else{
581 599
 				$this->logger->info(sprintf("Appended %s bytes, starting position %s, of original file %s to archive %s ", $bytes_wrote, $start_at_byte, $file_info['target_path'], $tmp_file, $this->get_archive_name()));
582 600
 			}
583 601
 			
Please login to merge, or discard this patch.
includes/class-xcloner-settings.php 3 patches
Indentation   +250 added lines, -250 removed lines patch added patch discarded remove patch
@@ -209,262 +209,262 @@  discard block
 block discarded – undo
209 209
 	
210 210
 	public function settings_init()
211 211
 	{
212
-	    global $wpdb;
213
-	    $this->xcloner_sanitization = $this->get_xcloner_container()->get_xcloner_sanitization();
212
+		global $wpdb;
213
+		$this->xcloner_sanitization = $this->get_xcloner_container()->get_xcloner_sanitization();
214 214
 	    
215
-	    //ADDING MISSING OPTIONS
216
-	    if( false == get_option( 'xcloner_mysql_settings_page' ) ) {  
215
+		//ADDING MISSING OPTIONS
216
+		if( false == get_option( 'xcloner_mysql_settings_page' ) ) {  
217 217
 			add_option( 'xcloner_mysql_settings_page' );
218 218
 		} // end if
219 219
 		
220
-	    if( false == get_option( 'xcloner_cron_settings_page' ) ) {  
220
+		if( false == get_option( 'xcloner_cron_settings_page' ) ) {  
221 221
 			add_option( 'xcloner_cron_settings_page' );
222 222
 		} // end if
223 223
 	    
224
-	    if( false == get_option( 'xcloner_system_settings_page' ) ) {  
224
+		if( false == get_option( 'xcloner_system_settings_page' ) ) {  
225 225
 			add_option( 'xcloner_system_settings_page' );
226 226
 		} // end if
227 227
 		
228
-	    if( false == get_option( 'xcloner_cleanup_settings_page' ) ) {  
228
+		if( false == get_option( 'xcloner_cleanup_settings_page' ) ) {  
229 229
 			add_option( 'xcloner_cleanup_settings_page' );
230 230
 		} // end if
231 231
 	 
232 232
 	    
233
-	    //ADDING SETTING SECTIONS
234
-	    //GENERAL section
235
-	    add_settings_section(
236
-	        'xcloner_general_settings_group',
237
-	        __(' '),
238
-	        array($this, 'xcloner_settings_section_cb'),
239
-	        'xcloner_settings_page'
240
-	    );
241
-	    //MYSQL section
242
-	    add_settings_section(
243
-	        'xcloner_mysql_settings_group',
244
-	        __(' '),
245
-	        array($this, 'xcloner_settings_section_cb'),
246
-	        'xcloner_mysql_settings_page'
247
-	    );
233
+		//ADDING SETTING SECTIONS
234
+		//GENERAL section
235
+		add_settings_section(
236
+			'xcloner_general_settings_group',
237
+			__(' '),
238
+			array($this, 'xcloner_settings_section_cb'),
239
+			'xcloner_settings_page'
240
+		);
241
+		//MYSQL section
242
+		add_settings_section(
243
+			'xcloner_mysql_settings_group',
244
+			__(' '),
245
+			array($this, 'xcloner_settings_section_cb'),
246
+			'xcloner_mysql_settings_page'
247
+		);
248 248
 	    
249
-	    //SYSTEM section
250
-	    add_settings_section(
251
-	        'xcloner_system_settings_group',
252
-	        __('These are advanced options recommended for developers!','xcloner-backup-and-restore'),
253
-	        array($this, 'xcloner_settings_section_cb'),
254
-	        'xcloner_system_settings_page'
255
-	    );
249
+		//SYSTEM section
250
+		add_settings_section(
251
+			'xcloner_system_settings_group',
252
+			__('These are advanced options recommended for developers!','xcloner-backup-and-restore'),
253
+			array($this, 'xcloner_settings_section_cb'),
254
+			'xcloner_system_settings_page'
255
+		);
256 256
 	    
257
-	    //CLEANUP section
258
-	    add_settings_section(
259
-	        'xcloner_cleanup_settings_group',
260
-	        __(' '),
261
-	        array($this, 'xcloner_settings_section_cb'),
262
-	        'xcloner_cleanup_settings_page'
263
-	    );
257
+		//CLEANUP section
258
+		add_settings_section(
259
+			'xcloner_cleanup_settings_group',
260
+			__(' '),
261
+			array($this, 'xcloner_settings_section_cb'),
262
+			'xcloner_cleanup_settings_page'
263
+		);
264 264
 	    
265 265
 		
266 266
 		//CRON section
267
-	    add_settings_section(
268
-	        'xcloner_cron_settings_group',
269
-	        __(' '),
270
-	        array($this, 'xcloner_settings_section_cb'),
271
-	        'xcloner_cron_settings_page'
272
-	    );
267
+		add_settings_section(
268
+			'xcloner_cron_settings_group',
269
+			__(' '),
270
+			array($this, 'xcloner_settings_section_cb'),
271
+			'xcloner_cron_settings_page'
272
+		);
273 273
 	    
274 274
 	    
275 275
 	    
276 276
 		//REGISTERING THE 'GENERAL SECTION' FIELDS
277 277
 		register_setting('xcloner_general_settings_group', 'xcloner_backup_compression_level', array($this->xcloner_sanitization, "sanitize_input_as_int"));
278
-	    add_settings_field(
279
-	        'xcloner_backup_compression_level',
280
-	       __('Backup Compression Level','xcloner-backup-and-restore'),
281
-	        array($this, 'do_form_range_field'),
282
-	        'xcloner_settings_page',
283
-	        'xcloner_general_settings_group',
284
-	        array('xcloner_backup_compression_level',
285
-	         __('Options between [0-9]. Value 0 means no compression, while 9 is maximum compression affecting cpu load','xcloner-backup-and-restore'), 
286
-	         0,
287
-	         9
288
-	         )
289
-	    );
278
+		add_settings_field(
279
+			'xcloner_backup_compression_level',
280
+		   __('Backup Compression Level','xcloner-backup-and-restore'),
281
+			array($this, 'do_form_range_field'),
282
+			'xcloner_settings_page',
283
+			'xcloner_general_settings_group',
284
+			array('xcloner_backup_compression_level',
285
+			 __('Options between [0-9]. Value 0 means no compression, while 9 is maximum compression affecting cpu load','xcloner-backup-and-restore'), 
286
+			 0,
287
+			 9
288
+			 )
289
+		);
290 290
 	    
291
-	    register_setting('xcloner_general_settings_group', 'xcloner_start_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path"));
292
-	    add_settings_field(
293
-	        'xcloner_start_path',
294
-	        __('Backup Start Location','xcloner-backup-and-restore'),
295
-	        array($this, 'do_form_text_field'),
296
-	        'xcloner_settings_page',
297
-	        'xcloner_general_settings_group',
298
-	        array('xcloner_start_path',
291
+		register_setting('xcloner_general_settings_group', 'xcloner_start_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path"));
292
+		add_settings_field(
293
+			'xcloner_start_path',
294
+			__('Backup Start Location','xcloner-backup-and-restore'),
295
+			array($this, 'do_form_text_field'),
296
+			'xcloner_settings_page',
297
+			'xcloner_general_settings_group',
298
+			array('xcloner_start_path',
299 299
 				__('Base path location from where XCloner can start the Backup.','xcloner-backup-and-restore'),
300 300
 				$this->get_xcloner_start_path(),
301 301
 				//'disabled'
302 302
 				)
303
-	    );
303
+		);
304 304
 	    
305
-	    register_setting('xcloner_general_settings_group', 'xcloner_store_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path"));
306
-	    add_settings_field(
307
-	        'xcloner_store_path',
308
-	        __('Backup Storage Location','xcloner-backup-and-restore'),
309
-	        array($this, 'do_form_text_field'),
310
-	        'xcloner_settings_page',
311
-	        'xcloner_general_settings_group',
312
-	        array('xcloner_store_path',
305
+		register_setting('xcloner_general_settings_group', 'xcloner_store_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path"));
306
+		add_settings_field(
307
+			'xcloner_store_path',
308
+			__('Backup Storage Location','xcloner-backup-and-restore'),
309
+			array($this, 'do_form_text_field'),
310
+			'xcloner_settings_page',
311
+			'xcloner_general_settings_group',
312
+			array('xcloner_store_path',
313 313
 				__('Location where XCloner will store the Backup archives.','xcloner-backup-and-restore'),
314 314
 				$this->get_xcloner_store_path(), 
315 315
 				//'disabled'
316 316
 				)
317
-	    );
317
+		);
318 318
 	    
319
-	    register_setting('xcloner_general_settings_group', 'xcloner_enable_log', array($this->xcloner_sanitization, "sanitize_input_as_int"));
320
-	    add_settings_field(
321
-	        'xcloner_enable_log',
322
-	        __('Enable XCloner Backup Log','xcloner-backup-and-restore'),
323
-	        array($this, 'do_form_switch_field'),
324
-	        'xcloner_settings_page',
325
-	        'xcloner_general_settings_group',
326
-	        array('xcloner_enable_log',
319
+		register_setting('xcloner_general_settings_group', 'xcloner_enable_log', array($this->xcloner_sanitization, "sanitize_input_as_int"));
320
+		add_settings_field(
321
+			'xcloner_enable_log',
322
+			__('Enable XCloner Backup Log','xcloner-backup-and-restore'),
323
+			array($this, 'do_form_switch_field'),
324
+			'xcloner_settings_page',
325
+			'xcloner_general_settings_group',
326
+			array('xcloner_enable_log',
327 327
 				sprintf(__('Enable the XCloner Backup log. You will find it stored unde the Backup Storage Location, file %s','xcloner-backup-and-restore'), $this->get_logger_filename())
328 328
 				)
329 329
 		);	
330 330
 		
331 331
 		register_setting('xcloner_general_settings_group', 'xcloner_regex_exclude', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
332
-	    add_settings_field(
333
-	        'xcloner_regex_exclude',
334
-	        __('Regex Exclude Files','xcloner-backup-and-restore'),
335
-	        array($this, 'do_form_textarea_field'),
336
-	        'xcloner_settings_page',
337
-	        'xcloner_general_settings_group',
338
-	        array('xcloner_regex_exclude',
332
+		add_settings_field(
333
+			'xcloner_regex_exclude',
334
+			__('Regex Exclude Files','xcloner-backup-and-restore'),
335
+			array($this, 'do_form_textarea_field'),
336
+			'xcloner_settings_page',
337
+			'xcloner_general_settings_group',
338
+			array('xcloner_regex_exclude',
339 339
 				__('Regular expression match to exclude files and folders, example patterns provided below, one pattern per line','xcloner-backup-and-restore'),
340 340
 				//$this->get_xcloner_store_path(), 
341 341
 				//'disabled'
342 342
 				)
343
-	    );
343
+		);
344 344
 	 
345 345
 		//REGISTERING THE 'MYSQL SECTION' FIELDS
346 346
 		register_setting('xcloner_mysql_settings_group', 'xcloner_enable_mysql_backup', array($this->xcloner_sanitization, "sanitize_input_as_int"));
347
-	    add_settings_field(
348
-	        'xcloner_enable_mysql_backup',
349
-	        __('Enable Mysql Backup','xcloner-backup-and-restore'),
350
-	        array($this, 'do_form_switch_field'),
351
-	        'xcloner_mysql_settings_page',
352
-	        'xcloner_mysql_settings_group',
353
-	        array('xcloner_enable_mysql_backup',
347
+		add_settings_field(
348
+			'xcloner_enable_mysql_backup',
349
+			__('Enable Mysql Backup','xcloner-backup-and-restore'),
350
+			array($this, 'do_form_switch_field'),
351
+			'xcloner_mysql_settings_page',
352
+			'xcloner_mysql_settings_group',
353
+			array('xcloner_enable_mysql_backup',
354 354
 				__('Enable Mysql Backup Option. If you don\'t want to backup the database, you can disable this.','xcloner-backup-and-restore')
355 355
 				)
356
-	    );
356
+		);
357 357
 	    
358
-	    register_setting('xcloner_mysql_settings_group', 'xcloner_backup_only_wp_tables');
359
-	    add_settings_field(
360
-	        'xcloner_backup_only_wp_tables',
361
-	        __('Backup only WP tables','xcloner-backup-and-restore'),
362
-	        array($this, 'do_form_switch_field'),
363
-	        'xcloner_mysql_settings_page',
364
-	        'xcloner_mysql_settings_group',
365
-	        array('xcloner_backup_only_wp_tables',
358
+		register_setting('xcloner_mysql_settings_group', 'xcloner_backup_only_wp_tables');
359
+		add_settings_field(
360
+			'xcloner_backup_only_wp_tables',
361
+			__('Backup only WP tables','xcloner-backup-and-restore'),
362
+			array($this, 'do_form_switch_field'),
363
+			'xcloner_mysql_settings_page',
364
+			'xcloner_mysql_settings_group',
365
+			array('xcloner_backup_only_wp_tables',
366 366
 				sprintf(__('Enable this if you only want to Backup only tables starting with \'%s\' prefix','xcloner-backup-and-restore'), $this->get_table_prefix())
367 367
 				)
368
-	    );
368
+		);
369 369
 	    
370
-	    register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_hostname', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
371
-	    add_settings_field(
372
-	        'xcloner_mysql_hostname',
373
-	        __('Mysql Hostname','xcloner-backup-and-restore'),
374
-	        array($this, 'do_form_text_field'),
375
-	        'xcloner_mysql_settings_page',
376
-	        'xcloner_mysql_settings_group',
377
-	        array('xcloner_mysql_hostname',
370
+		register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_hostname', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
371
+		add_settings_field(
372
+			'xcloner_mysql_hostname',
373
+			__('Mysql Hostname','xcloner-backup-and-restore'),
374
+			array($this, 'do_form_text_field'),
375
+			'xcloner_mysql_settings_page',
376
+			'xcloner_mysql_settings_group',
377
+			array('xcloner_mysql_hostname',
378 378
 				__('Wordpress mysql hostname','xcloner-backup-and-restore'),
379 379
 				$this->get_db_hostname(),
380 380
 				'disabled'
381 381
 				)
382
-	    );
382
+		);
383 383
 
384
-	    register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_username', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
385
-	    add_settings_field(
386
-	        'xcloner_mysql_username',
387
-	        __('Mysql Username','xcloner-backup-and-restore'),
388
-	        array($this, 'do_form_text_field'),
389
-	        'xcloner_mysql_settings_page',
390
-	        'xcloner_mysql_settings_group',
391
-	        array('xcloner_mysql_username',
384
+		register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_username', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
385
+		add_settings_field(
386
+			'xcloner_mysql_username',
387
+			__('Mysql Username','xcloner-backup-and-restore'),
388
+			array($this, 'do_form_text_field'),
389
+			'xcloner_mysql_settings_page',
390
+			'xcloner_mysql_settings_group',
391
+			array('xcloner_mysql_username',
392 392
 				__('Wordpress mysql username','xcloner-backup-and-restore'),
393 393
 				$this->get_db_username(),
394 394
 				'disabled'
395 395
 				)
396
-	    );
396
+		);
397 397
 	    
398
-	    register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_database', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
399
-	    add_settings_field(
400
-	        'xcloner_mysql_database',
401
-	        __('Mysql Database','xcloner-backup-and-restore'),
402
-	        array($this, 'do_form_text_field'),
403
-	        'xcloner_mysql_settings_page',
404
-	        'xcloner_mysql_settings_group',
405
-	        array('xcloner_mysql_database',
398
+		register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_database', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
399
+		add_settings_field(
400
+			'xcloner_mysql_database',
401
+			__('Mysql Database','xcloner-backup-and-restore'),
402
+			array($this, 'do_form_text_field'),
403
+			'xcloner_mysql_settings_page',
404
+			'xcloner_mysql_settings_group',
405
+			array('xcloner_mysql_database',
406 406
 				__('Wordpress mysql database','xcloner-backup-and-restore'),
407 407
 				$this->get_db_database(),
408 408
 				'disabled'
409 409
 				)
410
-	    );
410
+		);
411 411
 	    
412
-	    //REGISTERING THE 'SYSTEM SECTION' FIELDS
413
-	    register_setting('xcloner_system_settings_group', 'xcloner_size_limit_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int"));
414
-	    add_settings_field(
415
-	        'xcloner_size_limit_per_request',
416
-	       __('Data Size Limit Per Request','xcloner-backup-and-restore'),
417
-	        array($this, 'do_form_range_field'),
418
-	        'xcloner_system_settings_page',
419
-	        'xcloner_system_settings_group',
420
-	        array('xcloner_size_limit_per_request',
421
-	         __('Use this option to set how much file data can XCloner backup in one AJAX request. Range 0-1024 MB','xcloner-backup-and-restore'), 
422
-	         0,
423
-	         1024
424
-	         )
425
-	    );
412
+		//REGISTERING THE 'SYSTEM SECTION' FIELDS
413
+		register_setting('xcloner_system_settings_group', 'xcloner_size_limit_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int"));
414
+		add_settings_field(
415
+			'xcloner_size_limit_per_request',
416
+		   __('Data Size Limit Per Request','xcloner-backup-and-restore'),
417
+			array($this, 'do_form_range_field'),
418
+			'xcloner_system_settings_page',
419
+			'xcloner_system_settings_group',
420
+			array('xcloner_size_limit_per_request',
421
+			 __('Use this option to set how much file data can XCloner backup in one AJAX request. Range 0-1024 MB','xcloner-backup-and-restore'), 
422
+			 0,
423
+			 1024
424
+			 )
425
+		);
426 426
 	    
427 427
 		register_setting('xcloner_system_settings_group', 'xcloner_files_to_process_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int"));
428
-	    add_settings_field(
429
-	        'xcloner_files_to_process_per_request',
430
-	       __('Files To Process Per Request','xcloner-backup-and-restore'),
431
-	        array($this, 'do_form_range_field'),
432
-	        'xcloner_system_settings_page',
433
-	        'xcloner_system_settings_group',
434
-	        array('xcloner_files_to_process_per_request',
435
-	         __('Use this option to set how many files XCloner should process at one time before doing another AJAX call','xcloner-backup-and-restore'), 
436
-	         0,
437
-	         1000
438
-	         )
439
-	    );
428
+		add_settings_field(
429
+			'xcloner_files_to_process_per_request',
430
+		   __('Files To Process Per Request','xcloner-backup-and-restore'),
431
+			array($this, 'do_form_range_field'),
432
+			'xcloner_system_settings_page',
433
+			'xcloner_system_settings_group',
434
+			array('xcloner_files_to_process_per_request',
435
+			 __('Use this option to set how many files XCloner should process at one time before doing another AJAX call','xcloner-backup-and-restore'), 
436
+			 0,
437
+			 1000
438
+			 )
439
+		);
440 440
 	    
441 441
 		register_setting('xcloner_system_settings_group', 'xcloner_directories_to_scan_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int"));
442
-	    add_settings_field(
443
-	        'xcloner_directories_to_scan_per_request',
444
-	       __('Directories To Scan Per Request','xcloner-backup-and-restore'),
445
-	        array($this, 'do_form_range_field'),
446
-	        'xcloner_system_settings_page',
447
-	        'xcloner_system_settings_group',
448
-	        array('xcloner_directories_to_scan_per_request',
449
-	         __('Use this option to set how many directories XCloner should scan at one time before doing another AJAX call','xcloner-backup-and-restore'), 
450
-	         0,
451
-	         1000
452
-	         )
453
-	    );
442
+		add_settings_field(
443
+			'xcloner_directories_to_scan_per_request',
444
+		   __('Directories To Scan Per Request','xcloner-backup-and-restore'),
445
+			array($this, 'do_form_range_field'),
446
+			'xcloner_system_settings_page',
447
+			'xcloner_system_settings_group',
448
+			array('xcloner_directories_to_scan_per_request',
449
+			 __('Use this option to set how many directories XCloner should scan at one time before doing another AJAX call','xcloner-backup-and-restore'), 
450
+			 0,
451
+			 1000
452
+			 )
453
+		);
454 454
 	    
455 455
 		register_setting('xcloner_system_settings_group', 'xcloner_database_records_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int"));
456
-	    add_settings_field(
457
-	        'xcloner_database_records_per_request',
458
-	       __('Database Records Per Request','xcloner-backup-and-restore'),
459
-	        array($this, 'do_form_range_field'),
460
-	        'xcloner_system_settings_page',
461
-	        'xcloner_system_settings_group',
462
-	        array('xcloner_database_records_per_request',
463
-	         __('Use this option to set how many database table records should be fetched per AJAX request, or set to 0 to fetch all.  Range 0-100000 records','xcloner-backup-and-restore'), 
464
-	         0,
465
-	         100000
466
-	         )
467
-	    );
456
+		add_settings_field(
457
+			'xcloner_database_records_per_request',
458
+		   __('Database Records Per Request','xcloner-backup-and-restore'),
459
+			array($this, 'do_form_range_field'),
460
+			'xcloner_system_settings_page',
461
+			'xcloner_system_settings_group',
462
+			array('xcloner_database_records_per_request',
463
+			 __('Use this option to set how many database table records should be fetched per AJAX request, or set to 0 to fetch all.  Range 0-100000 records','xcloner-backup-and-restore'), 
464
+			 0,
465
+			 100000
466
+			 )
467
+		);
468 468
 	    
469 469
 		/*register_setting('xcloner_system_settings_group', 'xcloner_diff_backup_recreate_period', array($this->xcloner_sanitization, "sanitize_input_as_int"));
470 470
 	    add_settings_field(
@@ -479,90 +479,90 @@  discard block
 block discarded – undo
479 479
 	    );*/
480 480
 	    
481 481
 		register_setting('xcloner_system_settings_group', 'xcloner_exclude_files_larger_than_mb', array($this->xcloner_sanitization, "sanitize_input_as_int"));
482
-	    add_settings_field(
483
-	        'xcloner_exclude_files_larger_than_mb',
484
-	       __('Exclude files larger than (MB)','xcloner-backup-and-restore'),
485
-	        array($this, 'do_form_number_field'),
486
-	        'xcloner_system_settings_page',
487
-	        'xcloner_system_settings_group',
488
-	        array('xcloner_exclude_files_larger_than_mb',
489
-	         __('Use this option to automatically exclude files larger than a certain size in MB, or set to 0 to include all. Range 0-1000 MB','xcloner-backup-and-restore'), 
490
-	         )
491
-	    );
482
+		add_settings_field(
483
+			'xcloner_exclude_files_larger_than_mb',
484
+		   __('Exclude files larger than (MB)','xcloner-backup-and-restore'),
485
+			array($this, 'do_form_number_field'),
486
+			'xcloner_system_settings_page',
487
+			'xcloner_system_settings_group',
488
+			array('xcloner_exclude_files_larger_than_mb',
489
+			 __('Use this option to automatically exclude files larger than a certain size in MB, or set to 0 to include all. Range 0-1000 MB','xcloner-backup-and-restore'), 
490
+			 )
491
+		);
492 492
 	    
493 493
 		register_setting('xcloner_system_settings_group', 'xcloner_split_backup_limit', array($this->xcloner_sanitization, "sanitize_input_as_int"));
494
-	    add_settings_field(
495
-	        'xcloner_split_backup_limit',
496
-	       __('Split Backup Archive Limit (MB)','xcloner-backup-and-restore'),
497
-	        array($this, 'do_form_number_field'),
498
-	        'xcloner_system_settings_page',
499
-	        'xcloner_system_settings_group',
500
-	        array('xcloner_split_backup_limit',
501
-	         __('Use this option to automatically split the backup archive into smaller parts. Range  0-10000 MB','xcloner-backup-and-restore'), 
502
-	         )
503
-	    );
494
+		add_settings_field(
495
+			'xcloner_split_backup_limit',
496
+		   __('Split Backup Archive Limit (MB)','xcloner-backup-and-restore'),
497
+			array($this, 'do_form_number_field'),
498
+			'xcloner_system_settings_page',
499
+			'xcloner_system_settings_group',
500
+			array('xcloner_split_backup_limit',
501
+			 __('Use this option to automatically split the backup archive into smaller parts. Range  0-10000 MB','xcloner-backup-and-restore'), 
502
+			 )
503
+		);
504 504
 	    
505
-	    register_setting('xcloner_system_settings_group', 'xcloner_force_tmp_path_site_root');
506
-	    add_settings_field(
507
-	        'xcloner_force_tmp_path_site_root',
508
-	        __('Force Temporary Path Within XCloner Storage','xcloner-backup-and-restore'),
509
-	        array($this, 'do_form_switch_field'),
510
-	        'xcloner_system_settings_page',
511
-	        'xcloner_system_settings_group',
512
-	        array('xcloner_force_tmp_path_site_root',
505
+		register_setting('xcloner_system_settings_group', 'xcloner_force_tmp_path_site_root');
506
+		add_settings_field(
507
+			'xcloner_force_tmp_path_site_root',
508
+			__('Force Temporary Path Within XCloner Storage','xcloner-backup-and-restore'),
509
+			array($this, 'do_form_switch_field'),
510
+			'xcloner_system_settings_page',
511
+			'xcloner_system_settings_group',
512
+			array('xcloner_force_tmp_path_site_root',
513 513
 				sprintf(__('Enable this option if you want the XCloner Temporary Path to be within your XCloner Storage Location','xcloner-backup-and-restore'), $this->get_table_prefix())
514 514
 				)
515
-	    );
515
+		);
516 516
 		
517 517
 		//REGISTERING THE 'CLEANUP SECTION' FIELDS
518 518
 		register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_days', array($this->xcloner_sanitization, "sanitize_input_as_int"));
519
-	    add_settings_field(
520
-	        'xcloner_cleanup_retention_limit_days',
521
-	        __('Cleanup by Date(days)','xcloner-backup-and-restore'),
522
-	        array($this, 'do_form_number_field'),
523
-	        'xcloner_cleanup_settings_page',
524
-	        'xcloner_cleanup_settings_group',
525
-	        array('xcloner_cleanup_retention_limit_days',
519
+		add_settings_field(
520
+			'xcloner_cleanup_retention_limit_days',
521
+			__('Cleanup by Date(days)','xcloner-backup-and-restore'),
522
+			array($this, 'do_form_number_field'),
523
+			'xcloner_cleanup_settings_page',
524
+			'xcloner_cleanup_settings_group',
525
+			array('xcloner_cleanup_retention_limit_days',
526 526
 				__('Specify the maximum number of days a backup archive can be kept on the server. 0 disables this option','xcloner-backup-and-restore')
527 527
 			)
528
-	    );
528
+		);
529 529
 	    
530 530
 		register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_archives', array($this->xcloner_sanitization, "sanitize_input_as_int"));
531
-	    add_settings_field(
532
-	        'xcloner_cleanup_retention_limit_archives',
533
-	        __('Cleanup by Quantity','xcloner-backup-and-restore'),
534
-	        array($this, 'do_form_number_field'),
535
-	        'xcloner_cleanup_settings_page',
536
-	        'xcloner_cleanup_settings_group',
537
-	        array('xcloner_cleanup_retention_limit_archives',
531
+		add_settings_field(
532
+			'xcloner_cleanup_retention_limit_archives',
533
+			__('Cleanup by Quantity','xcloner-backup-and-restore'),
534
+			array($this, 'do_form_number_field'),
535
+			'xcloner_cleanup_settings_page',
536
+			'xcloner_cleanup_settings_group',
537
+			array('xcloner_cleanup_retention_limit_archives',
538 538
 				__('Specify the maximum number of backup archives to keep on the server. 0 disables this option','xcloner-backup-and-restore')
539 539
 			)
540
-	    );
540
+		);
541 541
 	    
542 542
 		register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_capacity_limit', array($this->xcloner_sanitization, "sanitize_input_as_int"));
543
-	    add_settings_field(
544
-	        'xcloner_cleanup_capacity_limit',
545
-	        __('Cleanup by Capacity(MB)','xcloner-backup-and-restore'),
546
-	        array($this, 'do_form_number_field'),
547
-	        'xcloner_cleanup_settings_page',
548
-	        'xcloner_cleanup_settings_group',
549
-	        array('xcloner_cleanup_capacity_limit',
543
+		add_settings_field(
544
+			'xcloner_cleanup_capacity_limit',
545
+			__('Cleanup by Capacity(MB)','xcloner-backup-and-restore'),
546
+			array($this, 'do_form_number_field'),
547
+			'xcloner_cleanup_settings_page',
548
+			'xcloner_cleanup_settings_group',
549
+			array('xcloner_cleanup_capacity_limit',
550 550
 				__('Remove oldest backups if all created backups exceed the configured limit in Megabytes. 0 disables this option','xcloner-backup-and-restore')
551 551
 			)
552
-	    );
552
+		);
553 553
 		
554 554
 		//REGISTERING THE 'CRON SECTION' FIELDS
555 555
 		register_setting('xcloner_cron_settings_group', 'xcloner_cron_frequency');
556
-	    add_settings_field(
557
-	        'xcloner_cron_frequency',
558
-	        __('Cron frequency','xcloner-backup-and-restore'),
559
-	        array($this, 'do_form_text_field'),
560
-	        'xcloner_cron_settings_page',
561
-	        'xcloner_cron_settings_group',
562
-	        array('xcloner_cron_frequency',
556
+		add_settings_field(
557
+			'xcloner_cron_frequency',
558
+			__('Cron frequency','xcloner-backup-and-restore'),
559
+			array($this, 'do_form_text_field'),
560
+			'xcloner_cron_settings_page',
561
+			'xcloner_cron_settings_group',
562
+			array('xcloner_cron_frequency',
563 563
 				__('Cron frequency')
564 564
 			)
565
-	    );
565
+		);
566 566
 	}
567 567
 	 
568 568
 	
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 	// section content cb
576 576
 	public function xcloner_settings_section_cb()
577 577
 	{
578
-	    //echo '<p>WPOrg Section Introduction.</p>';
578
+		//echo '<p>WPOrg Section Introduction.</p>';
579 579
 	}
580 580
 	 
581 581
 	// text field content cb
@@ -590,8 +590,8 @@  discard block
 block discarded – undo
590 590
 		
591 591
 		if(!$value)
592 592
 			$value = get_option($fieldname);
593
-	    // output the field
594
-	    ?>
593
+		// output the field
594
+		?>
595 595
 	    <div class="row">
596 596
 	        <div class="input-field col s10 m10 l8">
597 597
 	          <input class="validate" <?php echo ($disabled)?"disabled":""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="text" class="validate" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>">
@@ -617,8 +617,8 @@  discard block
 block discarded – undo
617 617
 		
618 618
 		if(!$value)
619 619
 			$value = get_option($fieldname);
620
-	    // output the field
621
-	    ?>
620
+		// output the field
621
+		?>
622 622
 	    <div class="row">
623 623
 	        <div class="input-field col s10 m10 l8">
624 624
 	          <textarea class="validate" <?php echo ($disabled)?"disabled":""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="text" class="validate" value=""><?php echo isset($value) ? esc_attr($value) : ''; ?></textarea>
@@ -661,8 +661,8 @@  discard block
 block discarded – undo
661 661
 		
662 662
 		if(!$value)
663 663
 			$value = get_option($fieldname);
664
-	    // output the field
665
-	    ?>
664
+		// output the field
665
+		?>
666 666
 	    <div class="row">
667 667
 	        <div class="input-field col s10 m5 l3">
668 668
 	          <input class="validate" <?php echo ($disabled)?"disabled":""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="number" class="validate" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>">
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -4,14 +4,14 @@  discard block
 block discarded – undo
4 4
 {
5 5
 	private $logger_file = "xcloner_main_%s.log";
6 6
 	private $logger_file_hash = "xcloner%s.log";
7
-	private $hash ;
7
+	private $hash;
8 8
 	private $xcloner_sanitization;
9 9
 	private $xcloner_container;
10 10
 	
11 11
 	public function __construct(Xcloner $xcloner_container, $hash = "")
12 12
 	{
13 13
 		$this->xcloner_container = $xcloner_container;
14
-		if(isset($hash))
14
+		if (isset($hash))
15 15
 			$this->set_hash($hash);
16 16
 	}
17 17
 	
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	
23 23
 	public function get_logger_filename($include_hash = 0)
24 24
 	{
25
-		if($include_hash)
25
+		if ($include_hash)
26 26
 			$filename = sprintf($this->logger_file_hash, $this->get_hash()); 
27 27
 		else
28 28
 			$filename = sprintf($this->logger_file, $this->get_server_unique_hash(5));
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	
33 33
 	public function get_xcloner_start_path()
34 34
 	{
35
-		if(!get_option('xcloner_start_path') or !is_dir(get_option('xcloner_start_path')))
35
+		if (!get_option('xcloner_start_path') or !is_dir(get_option('xcloner_start_path')))
36 36
 			$path = realpath(ABSPATH);
37 37
 		else
38 38
 			$path = get_option('xcloner_start_path');
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	
50 50
 	public function get_xcloner_store_path()
51 51
 	{
52
-		if(!get_option('xcloner_store_path')  or !is_dir(get_option('xcloner_store_path')))
52
+		if (!get_option('xcloner_store_path') or !is_dir(get_option('xcloner_store_path')))
53 53
 			$path = realpath(XCLONER_STORAGE_PATH);
54 54
 		else
55 55
 			$path = get_option('xcloner_store_path');
@@ -66,18 +66,18 @@  discard block
 block discarded – undo
66 66
 	public function get_xcloner_tmp_path($suffix = true)
67 67
 	{
68 68
 		$path = sys_get_temp_dir();
69
-		if(!is_dir($path))
69
+		if (!is_dir($path))
70 70
 		{
71 71
 			@mkdir($path);
72 72
 			@chmod($path, 0777);
73 73
 		}
74 74
 		
75
-		if(!is_dir($path) or !is_writeable($path) or get_option('xcloner_force_tmp_path_site_root'))
75
+		if (!is_dir($path) or !is_writeable($path) or get_option('xcloner_force_tmp_path_site_root'))
76 76
 		{
77 77
 			$path = $this->get_xcloner_store_path();
78 78
 		}
79 79
 		
80
-		if($suffix)
80
+		if ($suffix)
81 81
 		{
82 82
 			$path = $path.DS.".".$this->get_xcloner_tmp_path_suffix();
83 83
 		}
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	
88 88
 	public function get_enable_mysql_backup()
89 89
 	{
90
-		if(get_option('xcloner_enable_mysql_backup'))
90
+		if (get_option('xcloner_enable_mysql_backup'))
91 91
 			return true;
92 92
 		
93 93
 		return false;	
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
 	
96 96
 	public function get_backup_extension_name($ext = "")
97 97
 	{
98
-		if(!$ext)
98
+		if (!$ext)
99 99
 		{
100
-			if(get_option('xcloner_backup_compression_level'))
100
+			if (get_option('xcloner_backup_compression_level'))
101 101
 				$ext = ".tgz";
102 102
 			else
103 103
 				$ext = ".tar";
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	
108 108
 	public function get_hash()
109 109
 	{
110
-		if(!$this->hash){
110
+		if (!$this->hash) {
111 111
 			$this->set_hash("-".$this->get_server_unique_hash(5));
112 112
 		}
113 113
 		
@@ -119,17 +119,17 @@  discard block
 block discarded – undo
119 119
 	{
120 120
 		$hash = "-".md5(rand());
121 121
 		
122
-		$this->set_hash(substr( $hash, 0, 6));
122
+		$this->set_hash(substr($hash, 0, 6));
123 123
 		
124 124
 		return $hash;
125 125
 	}
126 126
 	
127 127
 	public function set_hash($hash = "")
128 128
 	{
129
-		if(substr($hash, 0, 1) != "-" and strlen($hash))
129
+		if (substr($hash, 0, 1) != "-" and strlen($hash))
130 130
 			$hash = "-".$hash;
131 131
 			
132
-		$this->hash = substr( $hash, 0, 6);
132
+		$this->hash = substr($hash, 0, 6);
133 133
 		
134 134
 		return $this;
135 135
 	}
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	{
139 139
 		$data = parse_url(get_site_url());
140 140
 			
141
-		$backup_name = "backup_[domain]".(isset($data['port'])?"_".$data['port']:"")."-[time]-".($this->get_enable_mysql_backup()?"sql":"nosql");
141
+		$backup_name = "backup_[domain]".(isset($data['port']) ? "_".$data['port'] : "")."-[time]-".($this->get_enable_mysql_backup() ? "sql" : "nosql");
142 142
 		
143 143
 		return $backup_name;
144 144
 	}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	{
148 148
 		global $wpdb;
149 149
 		
150
-		if(!$data = get_option('xcloner_mysql_hostname'))
150
+		if (!$data = get_option('xcloner_mysql_hostname'))
151 151
 			$data = $wpdb->dbhost;
152 152
 		
153 153
 		return $data;
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	{
158 158
 		global $wpdb;
159 159
 		
160
-		if(!$data = get_option('xcloner_mysql_username'))
160
+		if (!$data = get_option('xcloner_mysql_username'))
161 161
 			$data = $wpdb->dbuser;
162 162
 		
163 163
 		return $data;
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	{
168 168
 		global $wpdb;
169 169
 		
170
-		if(!$data = get_option('xcloner_mysql_password'))
170
+		if (!$data = get_option('xcloner_mysql_password'))
171 171
 			$data = $wpdb->dbpassword;
172 172
 		
173 173
 		return $data;
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	{
178 178
 		global $wpdb;
179 179
 		
180
-		if(!$data = get_option('xcloner_mysql_database'))
180
+		if (!$data = get_option('xcloner_mysql_database'))
181 181
 			$data = $wpdb->dbname;
182 182
 		
183 183
 		return $data;
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	{
202 202
 		$hash = md5(get_home_url().__DIR__);
203 203
 		
204
-		if($strlen)
204
+		if ($strlen)
205 205
 			$hash = substr($hash, 0, $strlen);
206 206
 			
207 207
 		return $hash;
@@ -213,20 +213,20 @@  discard block
 block discarded – undo
213 213
 	    $this->xcloner_sanitization = $this->get_xcloner_container()->get_xcloner_sanitization();
214 214
 	    
215 215
 	    //ADDING MISSING OPTIONS
216
-	    if( false == get_option( 'xcloner_mysql_settings_page' ) ) {  
217
-			add_option( 'xcloner_mysql_settings_page' );
216
+	    if (false == get_option('xcloner_mysql_settings_page')) {  
217
+			add_option('xcloner_mysql_settings_page');
218 218
 		} // end if
219 219
 		
220
-	    if( false == get_option( 'xcloner_cron_settings_page' ) ) {  
221
-			add_option( 'xcloner_cron_settings_page' );
220
+	    if (false == get_option('xcloner_cron_settings_page')) {  
221
+			add_option('xcloner_cron_settings_page');
222 222
 		} // end if
223 223
 	    
224
-	    if( false == get_option( 'xcloner_system_settings_page' ) ) {  
225
-			add_option( 'xcloner_system_settings_page' );
224
+	    if (false == get_option('xcloner_system_settings_page')) {  
225
+			add_option('xcloner_system_settings_page');
226 226
 		} // end if
227 227
 		
228
-	    if( false == get_option( 'xcloner_cleanup_settings_page' ) ) {  
229
-			add_option( 'xcloner_cleanup_settings_page' );
228
+	    if (false == get_option('xcloner_cleanup_settings_page')) {  
229
+			add_option('xcloner_cleanup_settings_page');
230 230
 		} // end if
231 231
 	 
232 232
 	    
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 	    //SYSTEM section
250 250
 	    add_settings_section(
251 251
 	        'xcloner_system_settings_group',
252
-	        __('These are advanced options recommended for developers!','xcloner-backup-and-restore'),
252
+	        __('These are advanced options recommended for developers!', 'xcloner-backup-and-restore'),
253 253
 	        array($this, 'xcloner_settings_section_cb'),
254 254
 	        'xcloner_system_settings_page'
255 255
 	    );
@@ -277,12 +277,12 @@  discard block
 block discarded – undo
277 277
 		register_setting('xcloner_general_settings_group', 'xcloner_backup_compression_level', array($this->xcloner_sanitization, "sanitize_input_as_int"));
278 278
 	    add_settings_field(
279 279
 	        'xcloner_backup_compression_level',
280
-	       __('Backup Compression Level','xcloner-backup-and-restore'),
280
+	       __('Backup Compression Level', 'xcloner-backup-and-restore'),
281 281
 	        array($this, 'do_form_range_field'),
282 282
 	        'xcloner_settings_page',
283 283
 	        'xcloner_general_settings_group',
284 284
 	        array('xcloner_backup_compression_level',
285
-	         __('Options between [0-9]. Value 0 means no compression, while 9 is maximum compression affecting cpu load','xcloner-backup-and-restore'), 
285
+	         __('Options between [0-9]. Value 0 means no compression, while 9 is maximum compression affecting cpu load', 'xcloner-backup-and-restore'), 
286 286
 	         0,
287 287
 	         9
288 288
 	         )
@@ -291,12 +291,12 @@  discard block
 block discarded – undo
291 291
 	    register_setting('xcloner_general_settings_group', 'xcloner_start_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path"));
292 292
 	    add_settings_field(
293 293
 	        'xcloner_start_path',
294
-	        __('Backup Start Location','xcloner-backup-and-restore'),
294
+	        __('Backup Start Location', 'xcloner-backup-and-restore'),
295 295
 	        array($this, 'do_form_text_field'),
296 296
 	        'xcloner_settings_page',
297 297
 	        'xcloner_general_settings_group',
298 298
 	        array('xcloner_start_path',
299
-				__('Base path location from where XCloner can start the Backup.','xcloner-backup-and-restore'),
299
+				__('Base path location from where XCloner can start the Backup.', 'xcloner-backup-and-restore'),
300 300
 				$this->get_xcloner_start_path(),
301 301
 				//'disabled'
302 302
 				)
@@ -305,12 +305,12 @@  discard block
 block discarded – undo
305 305
 	    register_setting('xcloner_general_settings_group', 'xcloner_store_path', array($this->xcloner_sanitization, "sanitize_input_as_absolute_path"));
306 306
 	    add_settings_field(
307 307
 	        'xcloner_store_path',
308
-	        __('Backup Storage Location','xcloner-backup-and-restore'),
308
+	        __('Backup Storage Location', 'xcloner-backup-and-restore'),
309 309
 	        array($this, 'do_form_text_field'),
310 310
 	        'xcloner_settings_page',
311 311
 	        'xcloner_general_settings_group',
312 312
 	        array('xcloner_store_path',
313
-				__('Location where XCloner will store the Backup archives.','xcloner-backup-and-restore'),
313
+				__('Location where XCloner will store the Backup archives.', 'xcloner-backup-and-restore'),
314 314
 				$this->get_xcloner_store_path(), 
315 315
 				//'disabled'
316 316
 				)
@@ -319,24 +319,24 @@  discard block
 block discarded – undo
319 319
 	    register_setting('xcloner_general_settings_group', 'xcloner_enable_log', array($this->xcloner_sanitization, "sanitize_input_as_int"));
320 320
 	    add_settings_field(
321 321
 	        'xcloner_enable_log',
322
-	        __('Enable XCloner Backup Log','xcloner-backup-and-restore'),
322
+	        __('Enable XCloner Backup Log', 'xcloner-backup-and-restore'),
323 323
 	        array($this, 'do_form_switch_field'),
324 324
 	        'xcloner_settings_page',
325 325
 	        'xcloner_general_settings_group',
326 326
 	        array('xcloner_enable_log',
327
-				sprintf(__('Enable the XCloner Backup log. You will find it stored unde the Backup Storage Location, file %s','xcloner-backup-and-restore'), $this->get_logger_filename())
327
+				sprintf(__('Enable the XCloner Backup log. You will find it stored unde the Backup Storage Location, file %s', 'xcloner-backup-and-restore'), $this->get_logger_filename())
328 328
 				)
329 329
 		);	
330 330
 		
331 331
 		register_setting('xcloner_general_settings_group', 'xcloner_regex_exclude', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
332 332
 	    add_settings_field(
333 333
 	        'xcloner_regex_exclude',
334
-	        __('Regex Exclude Files','xcloner-backup-and-restore'),
334
+	        __('Regex Exclude Files', 'xcloner-backup-and-restore'),
335 335
 	        array($this, 'do_form_textarea_field'),
336 336
 	        'xcloner_settings_page',
337 337
 	        'xcloner_general_settings_group',
338 338
 	        array('xcloner_regex_exclude',
339
-				__('Regular expression match to exclude files and folders, example patterns provided below, one pattern per line','xcloner-backup-and-restore'),
339
+				__('Regular expression match to exclude files and folders, example patterns provided below, one pattern per line', 'xcloner-backup-and-restore'),
340 340
 				//$this->get_xcloner_store_path(), 
341 341
 				//'disabled'
342 342
 				)
@@ -346,36 +346,36 @@  discard block
 block discarded – undo
346 346
 		register_setting('xcloner_mysql_settings_group', 'xcloner_enable_mysql_backup', array($this->xcloner_sanitization, "sanitize_input_as_int"));
347 347
 	    add_settings_field(
348 348
 	        'xcloner_enable_mysql_backup',
349
-	        __('Enable Mysql Backup','xcloner-backup-and-restore'),
349
+	        __('Enable Mysql Backup', 'xcloner-backup-and-restore'),
350 350
 	        array($this, 'do_form_switch_field'),
351 351
 	        'xcloner_mysql_settings_page',
352 352
 	        'xcloner_mysql_settings_group',
353 353
 	        array('xcloner_enable_mysql_backup',
354
-				__('Enable Mysql Backup Option. If you don\'t want to backup the database, you can disable this.','xcloner-backup-and-restore')
354
+				__('Enable Mysql Backup Option. If you don\'t want to backup the database, you can disable this.', 'xcloner-backup-and-restore')
355 355
 				)
356 356
 	    );
357 357
 	    
358 358
 	    register_setting('xcloner_mysql_settings_group', 'xcloner_backup_only_wp_tables');
359 359
 	    add_settings_field(
360 360
 	        'xcloner_backup_only_wp_tables',
361
-	        __('Backup only WP tables','xcloner-backup-and-restore'),
361
+	        __('Backup only WP tables', 'xcloner-backup-and-restore'),
362 362
 	        array($this, 'do_form_switch_field'),
363 363
 	        'xcloner_mysql_settings_page',
364 364
 	        'xcloner_mysql_settings_group',
365 365
 	        array('xcloner_backup_only_wp_tables',
366
-				sprintf(__('Enable this if you only want to Backup only tables starting with \'%s\' prefix','xcloner-backup-and-restore'), $this->get_table_prefix())
366
+				sprintf(__('Enable this if you only want to Backup only tables starting with \'%s\' prefix', 'xcloner-backup-and-restore'), $this->get_table_prefix())
367 367
 				)
368 368
 	    );
369 369
 	    
370 370
 	    register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_hostname', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
371 371
 	    add_settings_field(
372 372
 	        'xcloner_mysql_hostname',
373
-	        __('Mysql Hostname','xcloner-backup-and-restore'),
373
+	        __('Mysql Hostname', 'xcloner-backup-and-restore'),
374 374
 	        array($this, 'do_form_text_field'),
375 375
 	        'xcloner_mysql_settings_page',
376 376
 	        'xcloner_mysql_settings_group',
377 377
 	        array('xcloner_mysql_hostname',
378
-				__('Wordpress mysql hostname','xcloner-backup-and-restore'),
378
+				__('Wordpress mysql hostname', 'xcloner-backup-and-restore'),
379 379
 				$this->get_db_hostname(),
380 380
 				'disabled'
381 381
 				)
@@ -384,12 +384,12 @@  discard block
 block discarded – undo
384 384
 	    register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_username', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
385 385
 	    add_settings_field(
386 386
 	        'xcloner_mysql_username',
387
-	        __('Mysql Username','xcloner-backup-and-restore'),
387
+	        __('Mysql Username', 'xcloner-backup-and-restore'),
388 388
 	        array($this, 'do_form_text_field'),
389 389
 	        'xcloner_mysql_settings_page',
390 390
 	        'xcloner_mysql_settings_group',
391 391
 	        array('xcloner_mysql_username',
392
-				__('Wordpress mysql username','xcloner-backup-and-restore'),
392
+				__('Wordpress mysql username', 'xcloner-backup-and-restore'),
393 393
 				$this->get_db_username(),
394 394
 				'disabled'
395 395
 				)
@@ -398,12 +398,12 @@  discard block
 block discarded – undo
398 398
 	    register_setting('xcloner_mysql_settings_group', 'xcloner_mysql_database', array($this->xcloner_sanitization, "sanitize_input_as_raw"));
399 399
 	    add_settings_field(
400 400
 	        'xcloner_mysql_database',
401
-	        __('Mysql Database','xcloner-backup-and-restore'),
401
+	        __('Mysql Database', 'xcloner-backup-and-restore'),
402 402
 	        array($this, 'do_form_text_field'),
403 403
 	        'xcloner_mysql_settings_page',
404 404
 	        'xcloner_mysql_settings_group',
405 405
 	        array('xcloner_mysql_database',
406
-				__('Wordpress mysql database','xcloner-backup-and-restore'),
406
+				__('Wordpress mysql database', 'xcloner-backup-and-restore'),
407 407
 				$this->get_db_database(),
408 408
 				'disabled'
409 409
 				)
@@ -413,12 +413,12 @@  discard block
 block discarded – undo
413 413
 	    register_setting('xcloner_system_settings_group', 'xcloner_size_limit_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int"));
414 414
 	    add_settings_field(
415 415
 	        'xcloner_size_limit_per_request',
416
-	       __('Data Size Limit Per Request','xcloner-backup-and-restore'),
416
+	       __('Data Size Limit Per Request', 'xcloner-backup-and-restore'),
417 417
 	        array($this, 'do_form_range_field'),
418 418
 	        'xcloner_system_settings_page',
419 419
 	        'xcloner_system_settings_group',
420 420
 	        array('xcloner_size_limit_per_request',
421
-	         __('Use this option to set how much file data can XCloner backup in one AJAX request. Range 0-1024 MB','xcloner-backup-and-restore'), 
421
+	         __('Use this option to set how much file data can XCloner backup in one AJAX request. Range 0-1024 MB', 'xcloner-backup-and-restore'), 
422 422
 	         0,
423 423
 	         1024
424 424
 	         )
@@ -427,12 +427,12 @@  discard block
 block discarded – undo
427 427
 		register_setting('xcloner_system_settings_group', 'xcloner_files_to_process_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int"));
428 428
 	    add_settings_field(
429 429
 	        'xcloner_files_to_process_per_request',
430
-	       __('Files To Process Per Request','xcloner-backup-and-restore'),
430
+	       __('Files To Process Per Request', 'xcloner-backup-and-restore'),
431 431
 	        array($this, 'do_form_range_field'),
432 432
 	        'xcloner_system_settings_page',
433 433
 	        'xcloner_system_settings_group',
434 434
 	        array('xcloner_files_to_process_per_request',
435
-	         __('Use this option to set how many files XCloner should process at one time before doing another AJAX call','xcloner-backup-and-restore'), 
435
+	         __('Use this option to set how many files XCloner should process at one time before doing another AJAX call', 'xcloner-backup-and-restore'), 
436 436
 	         0,
437 437
 	         1000
438 438
 	         )
@@ -441,12 +441,12 @@  discard block
 block discarded – undo
441 441
 		register_setting('xcloner_system_settings_group', 'xcloner_directories_to_scan_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int"));
442 442
 	    add_settings_field(
443 443
 	        'xcloner_directories_to_scan_per_request',
444
-	       __('Directories To Scan Per Request','xcloner-backup-and-restore'),
444
+	       __('Directories To Scan Per Request', 'xcloner-backup-and-restore'),
445 445
 	        array($this, 'do_form_range_field'),
446 446
 	        'xcloner_system_settings_page',
447 447
 	        'xcloner_system_settings_group',
448 448
 	        array('xcloner_directories_to_scan_per_request',
449
-	         __('Use this option to set how many directories XCloner should scan at one time before doing another AJAX call','xcloner-backup-and-restore'), 
449
+	         __('Use this option to set how many directories XCloner should scan at one time before doing another AJAX call', 'xcloner-backup-and-restore'), 
450 450
 	         0,
451 451
 	         1000
452 452
 	         )
@@ -455,12 +455,12 @@  discard block
 block discarded – undo
455 455
 		register_setting('xcloner_system_settings_group', 'xcloner_database_records_per_request', array($this->xcloner_sanitization, "sanitize_input_as_int"));
456 456
 	    add_settings_field(
457 457
 	        'xcloner_database_records_per_request',
458
-	       __('Database Records Per Request','xcloner-backup-and-restore'),
458
+	       __('Database Records Per Request', 'xcloner-backup-and-restore'),
459 459
 	        array($this, 'do_form_range_field'),
460 460
 	        'xcloner_system_settings_page',
461 461
 	        'xcloner_system_settings_group',
462 462
 	        array('xcloner_database_records_per_request',
463
-	         __('Use this option to set how many database table records should be fetched per AJAX request, or set to 0 to fetch all.  Range 0-100000 records','xcloner-backup-and-restore'), 
463
+	         __('Use this option to set how many database table records should be fetched per AJAX request, or set to 0 to fetch all.  Range 0-100000 records', 'xcloner-backup-and-restore'), 
464 464
 	         0,
465 465
 	         100000
466 466
 	         )
@@ -481,36 +481,36 @@  discard block
 block discarded – undo
481 481
 		register_setting('xcloner_system_settings_group', 'xcloner_exclude_files_larger_than_mb', array($this->xcloner_sanitization, "sanitize_input_as_int"));
482 482
 	    add_settings_field(
483 483
 	        'xcloner_exclude_files_larger_than_mb',
484
-	       __('Exclude files larger than (MB)','xcloner-backup-and-restore'),
484
+	       __('Exclude files larger than (MB)', 'xcloner-backup-and-restore'),
485 485
 	        array($this, 'do_form_number_field'),
486 486
 	        'xcloner_system_settings_page',
487 487
 	        'xcloner_system_settings_group',
488 488
 	        array('xcloner_exclude_files_larger_than_mb',
489
-	         __('Use this option to automatically exclude files larger than a certain size in MB, or set to 0 to include all. Range 0-1000 MB','xcloner-backup-and-restore'), 
489
+	         __('Use this option to automatically exclude files larger than a certain size in MB, or set to 0 to include all. Range 0-1000 MB', 'xcloner-backup-and-restore'), 
490 490
 	         )
491 491
 	    );
492 492
 	    
493 493
 		register_setting('xcloner_system_settings_group', 'xcloner_split_backup_limit', array($this->xcloner_sanitization, "sanitize_input_as_int"));
494 494
 	    add_settings_field(
495 495
 	        'xcloner_split_backup_limit',
496
-	       __('Split Backup Archive Limit (MB)','xcloner-backup-and-restore'),
496
+	       __('Split Backup Archive Limit (MB)', 'xcloner-backup-and-restore'),
497 497
 	        array($this, 'do_form_number_field'),
498 498
 	        'xcloner_system_settings_page',
499 499
 	        'xcloner_system_settings_group',
500 500
 	        array('xcloner_split_backup_limit',
501
-	         __('Use this option to automatically split the backup archive into smaller parts. Range  0-10000 MB','xcloner-backup-and-restore'), 
501
+	         __('Use this option to automatically split the backup archive into smaller parts. Range  0-10000 MB', 'xcloner-backup-and-restore'), 
502 502
 	         )
503 503
 	    );
504 504
 	    
505 505
 	    register_setting('xcloner_system_settings_group', 'xcloner_force_tmp_path_site_root');
506 506
 	    add_settings_field(
507 507
 	        'xcloner_force_tmp_path_site_root',
508
-	        __('Force Temporary Path Within XCloner Storage','xcloner-backup-and-restore'),
508
+	        __('Force Temporary Path Within XCloner Storage', 'xcloner-backup-and-restore'),
509 509
 	        array($this, 'do_form_switch_field'),
510 510
 	        'xcloner_system_settings_page',
511 511
 	        'xcloner_system_settings_group',
512 512
 	        array('xcloner_force_tmp_path_site_root',
513
-				sprintf(__('Enable this option if you want the XCloner Temporary Path to be within your XCloner Storage Location','xcloner-backup-and-restore'), $this->get_table_prefix())
513
+				sprintf(__('Enable this option if you want the XCloner Temporary Path to be within your XCloner Storage Location', 'xcloner-backup-and-restore'), $this->get_table_prefix())
514 514
 				)
515 515
 	    );
516 516
 		
@@ -518,36 +518,36 @@  discard block
 block discarded – undo
518 518
 		register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_days', array($this->xcloner_sanitization, "sanitize_input_as_int"));
519 519
 	    add_settings_field(
520 520
 	        'xcloner_cleanup_retention_limit_days',
521
-	        __('Cleanup by Date(days)','xcloner-backup-and-restore'),
521
+	        __('Cleanup by Date(days)', 'xcloner-backup-and-restore'),
522 522
 	        array($this, 'do_form_number_field'),
523 523
 	        'xcloner_cleanup_settings_page',
524 524
 	        'xcloner_cleanup_settings_group',
525 525
 	        array('xcloner_cleanup_retention_limit_days',
526
-				__('Specify the maximum number of days a backup archive can be kept on the server. 0 disables this option','xcloner-backup-and-restore')
526
+				__('Specify the maximum number of days a backup archive can be kept on the server. 0 disables this option', 'xcloner-backup-and-restore')
527 527
 			)
528 528
 	    );
529 529
 	    
530 530
 		register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_retention_limit_archives', array($this->xcloner_sanitization, "sanitize_input_as_int"));
531 531
 	    add_settings_field(
532 532
 	        'xcloner_cleanup_retention_limit_archives',
533
-	        __('Cleanup by Quantity','xcloner-backup-and-restore'),
533
+	        __('Cleanup by Quantity', 'xcloner-backup-and-restore'),
534 534
 	        array($this, 'do_form_number_field'),
535 535
 	        'xcloner_cleanup_settings_page',
536 536
 	        'xcloner_cleanup_settings_group',
537 537
 	        array('xcloner_cleanup_retention_limit_archives',
538
-				__('Specify the maximum number of backup archives to keep on the server. 0 disables this option','xcloner-backup-and-restore')
538
+				__('Specify the maximum number of backup archives to keep on the server. 0 disables this option', 'xcloner-backup-and-restore')
539 539
 			)
540 540
 	    );
541 541
 	    
542 542
 		register_setting('xcloner_cleanup_settings_group', 'xcloner_cleanup_capacity_limit', array($this->xcloner_sanitization, "sanitize_input_as_int"));
543 543
 	    add_settings_field(
544 544
 	        'xcloner_cleanup_capacity_limit',
545
-	        __('Cleanup by Capacity(MB)','xcloner-backup-and-restore'),
545
+	        __('Cleanup by Capacity(MB)', 'xcloner-backup-and-restore'),
546 546
 	        array($this, 'do_form_number_field'),
547 547
 	        'xcloner_cleanup_settings_page',
548 548
 	        'xcloner_cleanup_settings_group',
549 549
 	        array('xcloner_cleanup_capacity_limit',
550
-				__('Remove oldest backups if all created backups exceed the configured limit in Megabytes. 0 disables this option','xcloner-backup-and-restore')
550
+				__('Remove oldest backups if all created backups exceed the configured limit in Megabytes. 0 disables this option', 'xcloner-backup-and-restore')
551 551
 			)
552 552
 	    );
553 553
 		
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 		register_setting('xcloner_cron_settings_group', 'xcloner_cron_frequency');
556 556
 	    add_settings_field(
557 557
 	        'xcloner_cron_frequency',
558
-	        __('Cron frequency','xcloner-backup-and-restore'),
558
+	        __('Cron frequency', 'xcloner-backup-and-restore'),
559 559
 	        array($this, 'do_form_text_field'),
560 560
 	        'xcloner_cron_settings_page',
561 561
 	        'xcloner_cron_settings_group',
@@ -581,20 +581,20 @@  discard block
 block discarded – undo
581 581
 	// text field content cb
582 582
 	public function do_form_text_field($params)
583 583
 	{
584
-		if(!isset($params['3']))
584
+		if (!isset($params['3']))
585 585
 			$params[3] = 0;
586
-		if(!isset($params['2']))
586
+		if (!isset($params['2']))
587 587
 			$params[2] = 0;	
588 588
 			
589 589
 		list($fieldname, $label, $value, $disabled) = $params;
590 590
 		
591
-		if(!$value)
591
+		if (!$value)
592 592
 			$value = get_option($fieldname);
593 593
 	    // output the field
594 594
 	    ?>
595 595
 	    <div class="row">
596 596
 	        <div class="input-field col s10 m10 l8">
597
-	          <input class="validate" <?php echo ($disabled)?"disabled":""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="text" class="validate" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>">
597
+	          <input class="validate" <?php echo ($disabled) ? "disabled" : ""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="text" class="validate" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>">
598 598
 	        </div>
599 599
 	        <div class="col s2 m2 ">
600 600
 				<a class="btn-floating tooltipped btn-small" data-position="left" data-delay="50" data-tooltip="<?php echo $label?>" data-tooltip-id=""><i class="material-icons">help_outline</i></a>
@@ -608,20 +608,20 @@  discard block
 block discarded – undo
608 608
 	// textarea field content cb
609 609
 	public function do_form_textarea_field($params)
610 610
 	{
611
-		if(!isset($params['3']))
611
+		if (!isset($params['3']))
612 612
 			$params[3] = 0;
613
-		if(!isset($params['2']))
613
+		if (!isset($params['2']))
614 614
 			$params[2] = 0;	
615 615
 			
616 616
 		list($fieldname, $label, $value, $disabled) = $params;
617 617
 		
618
-		if(!$value)
618
+		if (!$value)
619 619
 			$value = get_option($fieldname);
620 620
 	    // output the field
621 621
 	    ?>
622 622
 	    <div class="row">
623 623
 	        <div class="input-field col s10 m10 l8">
624
-	          <textarea class="validate" <?php echo ($disabled)?"disabled":""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="text" class="validate" value=""><?php echo isset($value) ? esc_attr($value) : ''; ?></textarea>
624
+	          <textarea class="validate" <?php echo ($disabled) ? "disabled" : ""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="text" class="validate" value=""><?php echo isset($value) ? esc_attr($value) : ''; ?></textarea>
625 625
 	        </div>
626 626
 	        <div class="col s2 m2 ">
627 627
 				<a class="btn-floating tooltipped btn-small" data-position="center" data-html="true" data-delay="50" data-tooltip="<?php echo $label?>" data-tooltip-id=""><i class="material-icons">help_outline</i></a>
@@ -652,20 +652,20 @@  discard block
 block discarded – undo
652 652
 	// number field content cb
653 653
 	public function do_form_number_field($params)
654 654
 	{
655
-		if(!isset($params['3']))
655
+		if (!isset($params['3']))
656 656
 			$params[3] = 0;
657
-		if(!isset($params['2']))
657
+		if (!isset($params['2']))
658 658
 			$params[2] = 0;	
659 659
 			
660 660
 		list($fieldname, $label, $value, $disabled) = $params;
661 661
 		
662
-		if(!$value)
662
+		if (!$value)
663 663
 			$value = get_option($fieldname);
664 664
 	    // output the field
665 665
 	    ?>
666 666
 	    <div class="row">
667 667
 	        <div class="input-field col s10 m5 l3">
668
-	          <input class="validate" <?php echo ($disabled)?"disabled":""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="number" class="validate" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>">
668
+	          <input class="validate" <?php echo ($disabled) ? "disabled" : ""?> name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" type="number" class="validate" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>">
669 669
 	        </div>
670 670
 	        <div class="col s2 m2 ">
671 671
 				<a class="btn-floating tooltipped btn-small" data-html="true"  data-position="center" data-delay="50" data-tooltip="<?php echo $label?>" data-tooltip-id=""><i class="material-icons">help_outline</i></a>
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 	
679 679
 	public function do_form_range_field($params)
680 680
 	{
681
-		if(!isset($params['4']))
681
+		if (!isset($params['4']))
682 682
 			$params[4] = 0;
683 683
 			
684 684
 		list($fieldname, $label, $range_start, $range_end, $disabled) = $params;
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 		<div class="row">
688 688
 	        <div class="input-field col s10 m10 l8">
689 689
 				<p class="range-field">
690
-			      <input <?php echo ($disabled)?"disabled":""?> type="range" name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" min="<?php echo $range_start?>" max="<?php echo $range_end?>" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>" />
690
+			      <input <?php echo ($disabled) ? "disabled" : ""?> type="range" name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" min="<?php echo $range_start?>" max="<?php echo $range_end?>" value="<?php echo isset($value) ? esc_attr($value) : ''; ?>" />
691 691
 			    </p>
692 692
 			</div>
693 693
 			<div class="col s2 m2 ">
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 	
701 701
 	public function do_form_switch_field($params)
702 702
 	{
703
-		if(!isset($params['2']))
703
+		if (!isset($params['2']))
704 704
 			$params[2] = 0;
705 705
 		list($fieldname, $label, $disabled) = $params;
706 706
 		$value = get_option($fieldname);
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 			<div class="switch">
711 711
 				<label>
712 712
 				  Off
713
-				  <input <?php echo ($disabled)?"disabled":""?> type="checkbox" name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" value="1" <?php echo ($value) ? 'checked="checked"' : ''; ?>">
713
+				  <input <?php echo ($disabled) ? "disabled" : ""?> type="checkbox" name="<?php echo $fieldname?>" id="<?php echo $fieldname?>" value="1" <?php echo ($value) ? 'checked="checked"' : ''; ?>">
714 714
 				  <span class="lever"></span>
715 715
 				  On
716 716
 				</label>
Please login to merge, or discard this patch.
Braces   +77 added lines, -54 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
 	public function __construct(Xcloner $xcloner_container, $hash = "")
12 12
 	{
13 13
 		$this->xcloner_container = $xcloner_container;
14
-		if(isset($hash))
15
-			$this->set_hash($hash);
14
+		if(isset($hash)) {
15
+					$this->set_hash($hash);
16
+		}
16 17
 	}
17 18
 	
18 19
 	private function get_xcloner_container()
@@ -22,20 +23,22 @@  discard block
 block discarded – undo
22 23
 	
23 24
 	public function get_logger_filename($include_hash = 0)
24 25
 	{
25
-		if($include_hash)
26
-			$filename = sprintf($this->logger_file_hash, $this->get_hash()); 
27
-		else
28
-			$filename = sprintf($this->logger_file, $this->get_server_unique_hash(5));
26
+		if($include_hash) {
27
+					$filename = sprintf($this->logger_file_hash, $this->get_hash());
28
+		} else {
29
+					$filename = sprintf($this->logger_file, $this->get_server_unique_hash(5));
30
+		}
29 31
 		
30 32
 		return $filename;
31 33
 	}
32 34
 	
33 35
 	public function get_xcloner_start_path()
34 36
 	{
35
-		if(!get_option('xcloner_start_path') or !is_dir(get_option('xcloner_start_path')))
36
-			$path = realpath(ABSPATH);
37
-		else
38
-			$path = get_option('xcloner_start_path');
37
+		if(!get_option('xcloner_start_path') or !is_dir(get_option('xcloner_start_path'))) {
38
+					$path = realpath(ABSPATH);
39
+		} else {
40
+					$path = get_option('xcloner_start_path');
41
+		}
39 42
 		
40 43
 		return $path;
41 44
 	}
@@ -49,10 +52,11 @@  discard block
 block discarded – undo
49 52
 	
50 53
 	public function get_xcloner_store_path()
51 54
 	{
52
-		if(!get_option('xcloner_store_path')  or !is_dir(get_option('xcloner_store_path')))
53
-			$path = realpath(XCLONER_STORAGE_PATH);
54
-		else
55
-			$path = get_option('xcloner_store_path');
55
+		if(!get_option('xcloner_store_path')  or !is_dir(get_option('xcloner_store_path'))) {
56
+					$path = realpath(XCLONER_STORAGE_PATH);
57
+		} else {
58
+					$path = get_option('xcloner_store_path');
59
+		}
56 60
 		
57 61
 		return $path;
58 62
 	}
@@ -87,8 +91,9 @@  discard block
 block discarded – undo
87 91
 	
88 92
 	public function get_enable_mysql_backup()
89 93
 	{
90
-		if(get_option('xcloner_enable_mysql_backup'))
91
-			return true;
94
+		if(get_option('xcloner_enable_mysql_backup')) {
95
+					return true;
96
+		}
92 97
 		
93 98
 		return false;	
94 99
 	}
@@ -97,10 +102,11 @@  discard block
 block discarded – undo
97 102
 	{
98 103
 		if(!$ext)
99 104
 		{
100
-			if(get_option('xcloner_backup_compression_level'))
101
-				$ext = ".tgz";
102
-			else
103
-				$ext = ".tar";
105
+			if(get_option('xcloner_backup_compression_level')) {
106
+							$ext = ".tgz";
107
+			} else {
108
+							$ext = ".tar";
109
+			}
104 110
 		}	
105 111
 		return ($this->get_hash()).$ext;	
106 112
 	}
@@ -126,8 +132,9 @@  discard block
 block discarded – undo
126 132
 	
127 133
 	public function set_hash($hash = "")
128 134
 	{
129
-		if(substr($hash, 0, 1) != "-" and strlen($hash))
130
-			$hash = "-".$hash;
135
+		if(substr($hash, 0, 1) != "-" and strlen($hash)) {
136
+					$hash = "-".$hash;
137
+		}
131 138
 			
132 139
 		$this->hash = substr( $hash, 0, 6);
133 140
 		
@@ -147,8 +154,9 @@  discard block
 block discarded – undo
147 154
 	{
148 155
 		global $wpdb;
149 156
 		
150
-		if(!$data = get_option('xcloner_mysql_hostname'))
151
-			$data = $wpdb->dbhost;
157
+		if(!$data = get_option('xcloner_mysql_hostname')) {
158
+					$data = $wpdb->dbhost;
159
+		}
152 160
 		
153 161
 		return $data;
154 162
 	}
@@ -157,8 +165,9 @@  discard block
 block discarded – undo
157 165
 	{
158 166
 		global $wpdb;
159 167
 		
160
-		if(!$data = get_option('xcloner_mysql_username'))
161
-			$data = $wpdb->dbuser;
168
+		if(!$data = get_option('xcloner_mysql_username')) {
169
+					$data = $wpdb->dbuser;
170
+		}
162 171
 		
163 172
 		return $data;
164 173
 	}
@@ -167,8 +176,9 @@  discard block
 block discarded – undo
167 176
 	{
168 177
 		global $wpdb;
169 178
 		
170
-		if(!$data = get_option('xcloner_mysql_password'))
171
-			$data = $wpdb->dbpassword;
179
+		if(!$data = get_option('xcloner_mysql_password')) {
180
+					$data = $wpdb->dbpassword;
181
+		}
172 182
 		
173 183
 		return $data;
174 184
 	}
@@ -177,8 +187,9 @@  discard block
 block discarded – undo
177 187
 	{
178 188
 		global $wpdb;
179 189
 		
180
-		if(!$data = get_option('xcloner_mysql_database'))
181
-			$data = $wpdb->dbname;
190
+		if(!$data = get_option('xcloner_mysql_database')) {
191
+					$data = $wpdb->dbname;
192
+		}
182 193
 		
183 194
 		return $data;
184 195
 	}
@@ -201,8 +212,9 @@  discard block
 block discarded – undo
201 212
 	{
202 213
 		$hash = md5(get_home_url().__DIR__);
203 214
 		
204
-		if($strlen)
205
-			$hash = substr($hash, 0, $strlen);
215
+		if($strlen) {
216
+					$hash = substr($hash, 0, $strlen);
217
+		}
206 218
 			
207 219
 		return $hash;
208 220
 	}
@@ -581,15 +593,18 @@  discard block
 block discarded – undo
581 593
 	// text field content cb
582 594
 	public function do_form_text_field($params)
583 595
 	{
584
-		if(!isset($params['3']))
585
-			$params[3] = 0;
586
-		if(!isset($params['2']))
587
-			$params[2] = 0;	
596
+		if(!isset($params['3'])) {
597
+					$params[3] = 0;
598
+		}
599
+		if(!isset($params['2'])) {
600
+					$params[2] = 0;
601
+		}
588 602
 			
589 603
 		list($fieldname, $label, $value, $disabled) = $params;
590 604
 		
591
-		if(!$value)
592
-			$value = get_option($fieldname);
605
+		if(!$value) {
606
+					$value = get_option($fieldname);
607
+		}
593 608
 	    // output the field
594 609
 	    ?>
595 610
 	    <div class="row">
@@ -608,15 +623,18 @@  discard block
 block discarded – undo
608 623
 	// textarea field content cb
609 624
 	public function do_form_textarea_field($params)
610 625
 	{
611
-		if(!isset($params['3']))
612
-			$params[3] = 0;
613
-		if(!isset($params['2']))
614
-			$params[2] = 0;	
626
+		if(!isset($params['3'])) {
627
+					$params[3] = 0;
628
+		}
629
+		if(!isset($params['2'])) {
630
+					$params[2] = 0;
631
+		}
615 632
 			
616 633
 		list($fieldname, $label, $value, $disabled) = $params;
617 634
 		
618
-		if(!$value)
619
-			$value = get_option($fieldname);
635
+		if(!$value) {
636
+					$value = get_option($fieldname);
637
+		}
620 638
 	    // output the field
621 639
 	    ?>
622 640
 	    <div class="row">
@@ -652,15 +670,18 @@  discard block
 block discarded – undo
652 670
 	// number field content cb
653 671
 	public function do_form_number_field($params)
654 672
 	{
655
-		if(!isset($params['3']))
656
-			$params[3] = 0;
657
-		if(!isset($params['2']))
658
-			$params[2] = 0;	
673
+		if(!isset($params['3'])) {
674
+					$params[3] = 0;
675
+		}
676
+		if(!isset($params['2'])) {
677
+					$params[2] = 0;
678
+		}
659 679
 			
660 680
 		list($fieldname, $label, $value, $disabled) = $params;
661 681
 		
662
-		if(!$value)
663
-			$value = get_option($fieldname);
682
+		if(!$value) {
683
+					$value = get_option($fieldname);
684
+		}
664 685
 	    // output the field
665 686
 	    ?>
666 687
 	    <div class="row">
@@ -678,8 +699,9 @@  discard block
 block discarded – undo
678 699
 	
679 700
 	public function do_form_range_field($params)
680 701
 	{
681
-		if(!isset($params['4']))
682
-			$params[4] = 0;
702
+		if(!isset($params['4'])) {
703
+					$params[4] = 0;
704
+		}
683 705
 			
684 706
 		list($fieldname, $label, $range_start, $range_end, $disabled) = $params;
685 707
 		$value = get_option($fieldname);
@@ -700,8 +722,9 @@  discard block
 block discarded – undo
700 722
 	
701 723
 	public function do_form_switch_field($params)
702 724
 	{
703
-		if(!isset($params['2']))
704
-			$params[2] = 0;
725
+		if(!isset($params['2'])) {
726
+					$params[2] = 0;
727
+		}
705 728
 		list($fieldname, $label, $disabled) = $params;
706 729
 		$value = get_option($fieldname);
707 730
 	?>
Please login to merge, or discard this patch.
includes/class-xcloner-api.php 3 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -220,12 +220,12 @@  discard block
 block discarded – undo
220 220
 		}
221 221
 			
222 222
 		if( $wpdb->last_error ) {
223
-            $response['error'] = 1;
224
-            $response['error_message'] = $wpdb->last_error/*."--".$wpdb->last_query*/;
223
+			$response['error'] = 1;
224
+			$response['error_message'] = $wpdb->last_error/*."--".$wpdb->last_query*/;
225 225
             
226
-        }
226
+		}
227 227
         
228
-        $scheduler->update_wp_cron_hooks();
228
+		$scheduler->update_wp_cron_hooks();
229 229
 		$response['finished'] = 1;
230 230
 		
231 231
 		$this->send_response($response);
@@ -916,14 +916,14 @@  discard block
 block discarded – undo
916 916
 		$tar->close();
917 917
 		
918 918
 		if (file_exists($tmp_file)) {
919
-		    header('Content-Description: File Transfer');
920
-		    header('Content-Type: application/octet-stream');
921
-		    header('Content-Disposition: attachment; filename="'.basename($tmp_file).'"');
922
-		    header('Expires: 0');
923
-		    header('Cache-Control: must-revalidate');
924
-		    header('Pragma: public');
925
-		    header('Content-Length: ' . filesize($tmp_file));
926
-		    readfile($tmp_file);
919
+			header('Content-Description: File Transfer');
920
+			header('Content-Type: application/octet-stream');
921
+			header('Content-Disposition: attachment; filename="'.basename($tmp_file).'"');
922
+			header('Expires: 0');
923
+			header('Cache-Control: must-revalidate');
924
+			header('Pragma: public');
925
+			header('Content-Length: ' . filesize($tmp_file));
926
+			readfile($tmp_file);
927 927
 		    
928 928
 		}
929 929
 		
@@ -950,24 +950,24 @@  discard block
 block discarded – undo
950 950
 		
951 951
 		
952 952
 		header('Pragma: public');
953
-	    header('Expires: 0');
954
-	    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
955
-	    header('Cache-Control: private', false);
956
-	    header('Content-Transfer-Encoding: binary');
957
-	    header('Content-Disposition: attachment; filename="'.$metadata['path'].'";');
958
-	    header('Content-Type: application/octet-stream');
959
-	    header('Content-Length: ' . $metadata['size']);
953
+		header('Expires: 0');
954
+		header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
955
+		header('Cache-Control: private', false);
956
+		header('Content-Transfer-Encoding: binary');
957
+		header('Content-Disposition: attachment; filename="'.$metadata['path'].'";');
958
+		header('Content-Type: application/octet-stream');
959
+		header('Content-Length: ' . $metadata['size']);
960 960
 	    
961
-	    @ob_end_clean();
961
+		@ob_end_clean();
962 962
 	    
963
-	    $chunkSize = 1024 * 1024;
964
-	    while (!feof($read_stream))
965
-	    {
966
-	        $buffer = fread($read_stream, $chunkSize);
967
-	        echo $buffer;
968
-	    }
969
-	    fclose($read_stream);
970
-	    exit;
963
+		$chunkSize = 1024 * 1024;
964
+		while (!feof($read_stream))
965
+		{
966
+			$buffer = fread($read_stream, $chunkSize);
967
+			echo $buffer;
968
+		}
969
+		fclose($read_stream);
970
+		exit;
971 971
     
972 972
 	}
973 973
 	
Please login to merge, or discard this patch.
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 use splitbrain\PHPArchive\FileInfo;
12 12
 
13 13
 
14
-class Xcloner_Api{
14
+class Xcloner_Api {
15 15
 
16 16
 	private $xcloner_database;
17 17
 	private $xcloner_settings;
@@ -27,30 +27,30 @@  discard block
 block discarded – undo
27 27
 	{
28 28
 		global $wpdb;
29 29
 		
30
-		if(WP_DEBUG)
30
+		if (WP_DEBUG)
31 31
 		{
32 32
 			error_reporting(0);
33 33
 		}
34 34
 		
35
-		if( ob_get_length() )
35
+		if (ob_get_length())
36 36
 			ob_end_clean();
37 37
 		ob_start();
38 38
 		
39
-		$wpdb->show_errors			= false;
39
+		$wpdb->show_errors = false;
40 40
 			
41 41
 		$this->xcloner_container	= $xcloner_container;
42 42
 				
43 43
 		$this->xcloner_settings 	= $xcloner_container->get_xcloner_settings();
44
-		$this->logger				= $xcloner_container->get_xcloner_logger()->withName("xcloner_api");
44
+		$this->logger = $xcloner_container->get_xcloner_logger()->withName("xcloner_api");
45 45
 		$this->xcloner_file_system 	= $xcloner_container->get_xcloner_filesystem();
46 46
 		$this->xcloner_sanitization = $xcloner_container->get_xcloner_sanitization();
47 47
 		$this->xcloner_requirements = $xcloner_container->get_xcloner_requirements();
48
-		$this->archive_system 		=  $xcloner_container->get_archive_system();
49
-		$this->xcloner_database 	=  $xcloner_container->get_xcloner_database();
50
-		$this->xcloner_scheduler 	=  $xcloner_container->get_xcloner_scheduler();
48
+		$this->archive_system = $xcloner_container->get_archive_system();
49
+		$this->xcloner_database = $xcloner_container->get_xcloner_database();
50
+		$this->xcloner_scheduler = $xcloner_container->get_xcloner_scheduler();
51 51
 		
52
-		if(isset($_POST['API_ID'])){
53
-			$this->logger->info("Processing ajax request ID ".substr($this->xcloner_sanitization->sanitize_input_as_string($_POST['API_ID']), 0 , 15));
52
+		if (isset($_POST['API_ID'])) {
53
+			$this->logger->info("Processing ajax request ID ".substr($this->xcloner_sanitization->sanitize_input_as_string($_POST['API_ID']), 0, 15));
54 54
 		}
55 55
 		
56 56
 	}
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 		$data['dbDatabase'] = $this->xcloner_settings->get_db_database();
79 79
 		
80 80
 		
81
-		$data['recordsPerSession'] 		= $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request');
82
-		$data['TEMP_DBPROCESS_FILE'] 	= $this->xcloner_settings->get_xcloner_tmp_path().DS.".database";
83
-		$data['TEMP_DUMP_FILE'] 		= $this->xcloner_settings->get_xcloner_tmp_path().DS."database-sql.sql";
81
+		$data['recordsPerSession'] = $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request');
82
+		$data['TEMP_DBPROCESS_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path().DS.".database";
83
+		$data['TEMP_DUMP_FILE'] = $this->xcloner_settings->get_xcloner_tmp_path().DS."database-sql.sql";
84 84
 		
85 85
 		try
86 86
 		{
87 87
 			$this->xcloner_database->init($data);
88 88
 
89
-		}catch(Exception $e){
89
+		}catch (Exception $e) {
90 90
 			
91 91
 			$this->send_response($e->getMessage());
92 92
 			$this->logger->error($e->getMessage());
@@ -113,19 +113,19 @@  discard block
 block discarded – undo
113 113
 		$schedule = array();
114 114
 		$response = array();
115 115
 		
116
-		if(isset($_POST['data']))
116
+		if (isset($_POST['data']))
117 117
 			$params = json_decode(stripslashes($_POST['data']));
118 118
 		
119 119
 		$this->process_params($params);
120 120
 		
121
-		if(isset($_POST['id']))
121
+		if (isset($_POST['id']))
122 122
 		{
123 123
 			
124 124
 			$this->form_params['backup_params']['backup_name'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['backup_name']);
125 125
 			$this->form_params['backup_params']['email_notification'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['email_notification']);
126
-			if($_POST['diff_start_date']){
126
+			if ($_POST['diff_start_date']) {
127 127
 				$this->form_params['backup_params']['diff_start_date'] = strtotime($this->xcloner_sanitization->sanitize_input_as_string($_POST['diff_start_date']));
128
-			}else{
128
+			} else {
129 129
 				$this->form_params['backup_params']['diff_start_date'] = "";
130 130
 				}
131 131
 			$this->form_params['backup_params']['schedule_name'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['schedule_name']);
@@ -140,11 +140,11 @@  discard block
 block discarded – undo
140 140
 			$tables = explode(PHP_EOL, $this->form_params['database']);
141 141
 			$return = array();
142 142
 			
143
-			foreach($tables as $table)
143
+			foreach ($tables as $table)
144 144
 			{
145
-					$table = str_replace("\r","", $table);
145
+					$table = str_replace("\r", "", $table);
146 146
 					$data = explode(".", $table);
147
-					if(isset($data[1]))
147
+					if (isset($data[1]))
148 148
 						$return[$data[0]][] = $data[1];
149 149
 			}
150 150
 			
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
 			$excluded_files = explode(PHP_EOL, $this->form_params['excluded_files']);
154 154
 			$return = array();
155 155
 			
156
-			foreach($excluded_files as $file)
156
+			foreach ($excluded_files as $file)
157 157
 			{
158
-				$file = str_replace("\r","", $file);
159
-				if($file)
158
+				$file = str_replace("\r", "", $file);
159
+				if ($file)
160 160
 					$return[] = $file;
161 161
 			}
162 162
 			
@@ -164,27 +164,27 @@  discard block
 block discarded – undo
164 164
 			
165 165
 			$schedule['start_at'] = $this->form_params['backup_params']['start_at'];
166 166
 			
167
-			if(!isset($_POST['status']))
167
+			if (!isset($_POST['status']))
168 168
 				$schedule['status'] = 0;
169 169
 			else	
170 170
 				$schedule['status'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['status']);
171
-		}else{
171
+		} else {
172 172
 		
173 173
 			$schedule['status'] = 1;
174
-			$schedule['start_at'] = strtotime($this->form_params['backup_params']['schedule_start_date'] .
174
+			$schedule['start_at'] = strtotime($this->form_params['backup_params']['schedule_start_date'].
175 175
 								" ".$this->form_params['backup_params']['schedule_start_time']);
176 176
 			
177
-			if($schedule['start_at'] <= time())
177
+			if ($schedule['start_at'] <= time())
178 178
 			{
179 179
 				$schedule['start_at'] = "";
180 180
 			}
181 181
 		}
182 182
 		
183
-		if(!$schedule['start_at'])						
183
+		if (!$schedule['start_at'])						
184 184
 		{
185 185
 			$schedule['start_at'] = date('Y-m-d H:i:s', time());
186
-		}else{
187
-			$schedule['start_at'] = date('Y-m-d H:i:s', $schedule['start_at'] - (get_option( 'gmt_offset' ) * HOUR_IN_SECONDS) );	
186
+		} else {
187
+			$schedule['start_at'] = date('Y-m-d H:i:s', $schedule['start_at'] - (get_option('gmt_offset') * HOUR_IN_SECONDS));	
188 188
 		}
189 189
 		
190 190
 		$schedule['name'] = $this->form_params['backup_params']['schedule_name'];
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 		//$schedule['backup_type'] = $this->form_params['backup_params']['backup_type'];
194 194
 		$schedule['params'] = json_encode($this->form_params);
195 195
 
196
-		if(!isset($_POST['id']))
196
+		if (!isset($_POST['id']))
197 197
 		{
198 198
 			$wpdb->insert( 
199 199
 				$wpdb->prefix.'xcloner_scheduler', 
@@ -203,23 +203,23 @@  discard block
 block discarded – undo
203 203
 					'%s' 
204 204
 				) 
205 205
 			);
206
-		}else		{
206
+		} else {
207 207
 			$wpdb->update( 
208 208
 				$wpdb->prefix.'xcloner_scheduler', 
209 209
 				$schedule, 
210
-				array( 'id' => $_POST['id'] ), 
210
+				array('id' => $_POST['id']), 
211 211
 				array( 
212 212
 					'%s', 
213 213
 					'%s' 
214 214
 				) 
215 215
 			);
216 216
 		}
217
-		if(isset($_POST['id']))
217
+		if (isset($_POST['id']))
218 218
 		{
219 219
 			$scheduler->update_cron_hook($_POST['id']);
220 220
 		}
221 221
 			
222
-		if( $wpdb->last_error ) {
222
+		if ($wpdb->last_error) {
223 223
             $response['error'] = 1;
224 224
             $response['error_message'] = $wpdb->last_error/*."--".$wpdb->last_query*/;
225 225
             
@@ -242,19 +242,19 @@  discard block
 block discarded – undo
242 242
 		
243 243
 		$params = json_decode(stripslashes($_POST['data']));
244 244
 		
245
-		$init 	= (int)$_POST['init'];
245
+		$init = (int)$_POST['init'];
246 246
 		
247
-		if($params === NULL)
248
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
247
+		if ($params === NULL)
248
+			 die('{"status":false,"msg":"The post_data parameter must be valid JSON"}');
249 249
 			 
250 250
 		$this->process_params($params);
251 251
 		
252 252
 		$return['finished'] = 1;
253 253
 
254 254
 		//$return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], $this->form_params['extra'], $init);
255
-		try{
255
+		try {
256 256
 			$return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], $this->form_params['extra'], $init);
257
-		}catch(Exception $e)
257
+		}catch (Exception $e)
258 258
 		{
259 259
 			$return = array();
260 260
 			$return['error'] = true;
@@ -263,26 +263,26 @@  discard block
 block discarded – undo
263 263
 			return $this->send_response($return, $hash = 1);
264 264
 		}
265 265
 		
266
-		if($return['finished'])
266
+		if ($return['finished'])
267 267
 		{
268 268
 			$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_with_extension();
269
-			if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension()))
269
+			if ($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension()))
270 270
 				$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart();
271 271
 		}
272 272
 		
273 273
 		$data = $return;
274 274
 		
275 275
 		//check if backup is finished
276
-		if($return['finished'] )
276
+		if ($return['finished'])
277 277
 		{
278
-			if(isset($this->form_params['backup_params']['email_notification']) and $to=$this->form_params['backup_params']['email_notification'])
278
+			if (isset($this->form_params['backup_params']['email_notification']) and $to = $this->form_params['backup_params']['email_notification'])
279 279
 			{
280
-				try{
280
+				try {
281 281
 					$from = "";
282 282
 					$subject = "";
283 283
 					$additional['lines_total'] = $return['extra']['lines_total'];
284
-					$this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'], $this->form_params,"", $additional);
285
-				}catch(Exception $e)
284
+					$this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'], $this->form_params, "", $additional);
285
+				}catch (Exception $e)
286 286
 				{
287 287
 					$this->logger->error($e->getMessage());
288 288
 				}
@@ -304,17 +304,17 @@  discard block
 block discarded – undo
304 304
 		
305 305
 		$params = json_decode(stripslashes($_POST['data']));
306 306
 		
307
-		$init 	= (int)$_POST['init'];
307
+		$init = (int)$_POST['init'];
308 308
 		
309
-		if($params === NULL)
310
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
309
+		if ($params === NULL)
310
+			 die('{"status":false,"msg":"The post_data parameter must be valid JSON"}');
311 311
 		
312 312
 		$this->process_params($params);
313 313
 			
314 314
 		//$xcloner_database = $this->init_db();	
315 315
 		$return = $this->xcloner_database->start_database_recursion($this->form_params['database'], $this->form_params['extra'], $init);
316 316
 		
317
-		if(isset($return['error']) and $return['error'])
317
+		if (isset($return['error']) and $return['error'])
318 318
 			$data['finished'] = 1;
319 319
 		else	
320 320
 			$data['finished'] = $return['finished'];
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
 		$this->check_access();
335 335
 		
336 336
 		$params = json_decode(stripslashes($_POST['data']));
337
-		$init 	= (int)$_POST['init'];
337
+		$init = (int)$_POST['init'];
338 338
 		
339
-		if($params === NULL)
340
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
339
+		if ($params === NULL)
340
+			 die('{"status":false,"msg":"The post_data parameter must be valid JSON"}');
341 341
 			 
342 342
 		$hash = $this->process_params($params);
343 343
 		
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 		$data["finished"] = !$return;
349 349
 		$data["total_files_num"] = $this->xcloner_file_system->get_scanned_files_num();
350 350
 		$data["last_logged_file"] = $this->xcloner_file_system->last_logged_file();
351
-		$data["total_files_size"] = sprintf("%.2f",$this->xcloner_file_system->get_scanned_files_total_size()/(1024*1024));
351
+		$data["total_files_size"] = sprintf("%.2f", $this->xcloner_file_system->get_scanned_files_total_size() / (1024 * 1024));
352 352
 		
353 353
 		return $this->send_response($data, $hash = 1);
354 354
 	}
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	 */ 
361 361
 	private function process_params($params)
362 362
 	{
363
-		if(isset($params->hash))
363
+		if (isset($params->hash))
364 364
 			$this->xcloner_settings->set_hash($params->hash);
365 365
 			
366 366
 		$this->form_params['extra'] = array();
@@ -368,9 +368,9 @@  discard block
 block discarded – undo
368 368
 		
369 369
 		$this->form_params['database'] = array();
370 370
 		
371
-		if(isset($params->backup_params))
371
+		if (isset($params->backup_params))
372 372
 		{
373
-			foreach($params->backup_params as $param)
373
+			foreach ($params->backup_params as $param)
374 374
 			{
375 375
 				$this->form_params['backup_params'][$param->name] = $this->xcloner_sanitization->sanitize_input_as_string($param->value);
376 376
 				$this->logger->debug("Adding form parameter ".$param->name.".".$param->value."\n", array('POST', 'fields filter'));
@@ -379,28 +379,28 @@  discard block
 block discarded – undo
379 379
 		
380 380
 		$this->form_params['database'] = array();
381 381
 		
382
-		if(isset($params->table_params))
382
+		if (isset($params->table_params))
383 383
 		{
384
-			foreach($params->table_params as $param)
384
+			foreach ($params->table_params as $param)
385 385
 			{
386 386
 				$this->form_params['database'][$param->parent][] = $this->xcloner_sanitization->sanitize_input_as_raw($param->id);
387 387
 				$this->logger->debug("Adding database filter ".$param->parent.".".$param->id."\n", array('POST', 'database filter'));
388 388
 			}
389 389
 		}
390 390
 		
391
-		$this->form_params['excluded_files'] =  array();
392
-		if(isset($params->files_params))
391
+		$this->form_params['excluded_files'] = array();
392
+		if (isset($params->files_params))
393 393
 		{
394
-			foreach($params->files_params as $param)
394
+			foreach ($params->files_params as $param)
395 395
 			{
396 396
 				$this->form_params['excluded_files'][] = $this->xcloner_sanitization->sanitize_input_as_relative_path($param->id);
397 397
 			}
398 398
 			
399 399
 			$unique_exclude_files = array();
400 400
 			
401
-			foreach($params->files_params as $key=>$param)
401
+			foreach ($params->files_params as $key=>$param)
402 402
 			{
403
-				if(!in_array($param->parent, $this->form_params['excluded_files'])){
403
+				if (!in_array($param->parent, $this->form_params['excluded_files'])) {
404 404
 				//$this->form_params['excluded_files'][] = $this->xcloner_sanitization->sanitize_input_as_relative_path($param->id);
405 405
 					$unique_exclude_files[] = $param->id;
406 406
 					$this->logger->debug("Adding file filter ".$param->id."\n", array('POST', 'exclude files filter'));
@@ -412,13 +412,13 @@  discard block
 block discarded – undo
412 412
 		
413 413
 		//$this->form_params['excluded_files'] =  array_merge($this->form_params['excluded_files'], $this->exclude_files_by_default);
414 414
 		
415
-		if(isset($params->extra))
415
+		if (isset($params->extra))
416 416
 		{
417
-			foreach($params->extra as $key=>$value)
417
+			foreach ($params->extra as $key=>$value)
418 418
 				$this->form_params['extra'][$key] = $this->xcloner_sanitization->sanitize_input_as_raw($value);
419 419
 		}
420 420
 		
421
-		if(isset($this->form_params['backup_params']['diff_start_date']) and $this->form_params['backup_params']['diff_start_date'])
421
+		if (isset($this->form_params['backup_params']['diff_start_date']) and $this->form_params['backup_params']['diff_start_date'])
422 422
 		{
423 423
 			$this->form_params['backup_params']['diff_start_date'] = strtotime($this->form_params['backup_params']['diff_start_date']);
424 424
 			$this->xcloner_file_system->set_diff_timestamp_start($this->form_params['backup_params']['diff_start_date']);
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 		
441 441
 		$data = array();
442 442
 		
443
-		if($folder == "#"){
443
+		if ($folder == "#") {
444 444
 			
445 445
 			$folder = "/";
446 446
 			$data[] = array(
@@ -453,9 +453,9 @@  discard block
 block discarded – undo
453 453
 						);
454 454
 		}
455 455
 			
456
-			try{
456
+			try {
457 457
 				$files = $this->xcloner_file_system->list_directory($folder);
458
-			}catch(Exception $e){
458
+			}catch (Exception $e) {
459 459
 				
460 460
 				print $e->getMessage();
461 461
 				$this->logger->error($e->getMessage());
@@ -470,17 +470,17 @@  discard block
 block discarded – undo
470 470
 			}
471 471
 			array_multisort($type, SORT_ASC, $files);
472 472
 			
473
-			foreach($files as $file)
473
+			foreach ($files as $file)
474 474
 			{
475 475
 				$children = false;
476 476
 				$text = $file['basename'];
477 477
 				
478
-				if($file['type'] == "dir")
478
+				if ($file['type'] == "dir")
479 479
 					$children = true;
480 480
 				else
481
-					 $text .= " (". $this->xcloner_requirements->file_format_size($file['size']).")";
481
+					 $text .= " (".$this->xcloner_requirements->file_format_size($file['size']).")";
482 482
 				
483
-				if($this->xcloner_file_system->is_excluded($file))
483
+				if ($this->xcloner_file_system->is_excluded($file))
484 484
 					$selected = true;
485 485
 				else
486 486
 					$selected = false;
@@ -515,25 +515,25 @@  discard block
 block discarded – undo
515 515
 		
516 516
 		$xcloner_backup_only_wp_tables = $this->xcloner_settings->get_xcloner_option('xcloner_backup_only_wp_tables');
517 517
 	
518
-		if($database == "#")
518
+		if ($database == "#")
519 519
 		{
520
-			try{
520
+			try {
521 521
 				$return = $this->xcloner_database->get_all_databases();
522
-			}catch(Exception $e){
522
+			}catch (Exception $e) {
523 523
 				$this->logger->error($e->getMessage());
524 524
 			}
525 525
 			
526
-			foreach($return as $database)
526
+			foreach ($return as $database)
527 527
 			{
528
-				if($xcloner_backup_only_wp_tables and $database['name'] != $this->xcloner_settings->get_db_database())
528
+				if ($xcloner_backup_only_wp_tables and $database['name'] != $this->xcloner_settings->get_db_database())
529 529
 					continue;
530 530
 					
531 531
 				$state = array();
532 532
 				
533
-				if($database['name'] == $this->xcloner_settings->get_db_database())
533
+				if ($database['name'] == $this->xcloner_settings->get_db_database())
534 534
 				{
535 535
 					$state['selected'] = true;
536
-					if($database['num_tables'] < 25)
536
+					if ($database['num_tables'] < 25)
537 537
 						$state['opened'] = false;
538 538
 				}
539 539
 					
@@ -549,22 +549,22 @@  discard block
 block discarded – undo
549 549
 			
550 550
 		}
551 551
 		
552
-		else{
552
+		else {
553 553
 			
554
-			try{
554
+			try {
555 555
 				$return = $this->xcloner_database->list_tables($database, "", 1);
556
-			}catch(Exception $e){
556
+			}catch (Exception $e) {
557 557
 				$this->logger->error($e->getMessage());
558 558
 			}
559 559
 			
560
-			foreach($return as $table)
560
+			foreach ($return as $table)
561 561
 			{
562 562
 				$state = array();
563 563
 				
564
-				if($xcloner_backup_only_wp_tables and !stristr($table['name'], $this->xcloner_settings->get_table_prefix()))
564
+				if ($xcloner_backup_only_wp_tables and !stristr($table['name'], $this->xcloner_settings->get_table_prefix()))
565 565
 					continue;
566 566
 				
567
-				if(isset($database['name']) and $database['name'] == $this->xcloner_settings->get_db_database())
567
+				if (isset($database['name']) and $database['name'] == $this->xcloner_settings->get_db_database())
568 568
 					$state = array('selected' => true);
569 569
 					
570 570
 				$data[] = array(
@@ -592,12 +592,12 @@  discard block
 block discarded – undo
592 592
 		
593 593
 		$schedule_id = $this->xcloner_sanitization->sanitize_input_as_int($_GET['id']);
594 594
 		$scheduler = $this->xcloner_scheduler;
595
-		$data  = $scheduler->get_schedule_by_id($schedule_id);
595
+		$data = $scheduler->get_schedule_by_id($schedule_id);
596 596
 		
597
-		$data['start_at'] = date("Y-m-d H:i", strtotime($data['start_at']) + (get_option( 'gmt_offset' ) * HOUR_IN_SECONDS));
598
-		if(isset($data['backup_params']->diff_start_date) && $data['backup_params']->diff_start_date != "")
597
+		$data['start_at'] = date("Y-m-d H:i", strtotime($data['start_at']) + (get_option('gmt_offset') * HOUR_IN_SECONDS));
598
+		if (isset($data['backup_params']->diff_start_date) && $data['backup_params']->diff_start_date != "")
599 599
 		{
600
-			$data['backup_params']->diff_start_date = date("Y-m-d", ($data['backup_params']->diff_start_date) );
600
+			$data['backup_params']->diff_start_date = date("Y-m-d", ($data['backup_params']->diff_start_date));
601 601
 		}
602 602
 		
603 603
 		return $this->send_response($data);
@@ -613,14 +613,14 @@  discard block
 block discarded – undo
613 613
 		$this->check_access();
614 614
 		
615 615
 		$scheduler = $this->xcloner_scheduler;
616
-		$data  = $scheduler->get_scheduler_list();
616
+		$data = $scheduler->get_scheduler_list();
617 617
 		$return['data'] = array();
618 618
 		
619
-		foreach($data as $res)
619
+		foreach ($data as $res)
620 620
 		{
621 621
 			$action = "<a href=\"#".$res->id."\" class=\"edit\" title='Edit'> <i class=\"material-icons \">edit</i></a> 
622 622
 					<a href=\"#".$res->id."\" class=\"delete\" title='Delete'><i class=\"material-icons  \">delete</i></a>";
623
-			if($res->status)
623
+			if ($res->status)
624 624
 				$status = '<i class="material-icons active status">timer</i>';
625 625
 			else
626 626
 				$status = '<i class="material-icons status inactive">timer_off</i>';
@@ -631,14 +631,14 @@  discard block
 block discarded – undo
631 631
 			
632 632
 			$remote_storage = $res->remote_storage;
633 633
 			
634
-			if(!$next_run_time >= time())
634
+			if (!$next_run_time >= time())
635 635
 				$next_run = " ";
636 636
 			
637
-			if(trim($next_run))
637
+			if (trim($next_run))
638 638
 			{
639
-				$date_text = date(get_option('date_format')." ".get_option('time_format'), $next_run_time + (get_option( 'gmt_offset' ) * HOUR_IN_SECONDS));
639
+				$date_text = date(get_option('date_format')." ".get_option('time_format'), $next_run_time + (get_option('gmt_offset') * HOUR_IN_SECONDS));
640 640
 				
641
-				if($next_run_time >= time())
641
+				if ($next_run_time >= time())
642 642
 					$next_run = "in ".human_time_diff($next_run_time, time());
643 643
 				else
644 644
 					$next_run = __("executed", 'xcloner-backup-and-restore');
@@ -651,13 +651,13 @@  discard block
 block discarded – undo
651 651
 			$backup_size = "";
652 652
 			$backup_time = "";
653 653
 			
654
-			if($res->last_backup)
654
+			if ($res->last_backup)
655 655
 			{
656
-				if( $this->xcloner_file_system->get_storage_filesystem()->has($res->last_backup))
656
+				if ($this->xcloner_file_system->get_storage_filesystem()->has($res->last_backup))
657 657
 				{
658 658
 					$metadata = $this->xcloner_file_system->get_storage_filesystem()->getMetadata($res->last_backup);
659 659
 					$backup_size  = size_format($this->xcloner_file_system->get_backup_size($res->last_backup));
660
-					$backup_time  = date(get_option('date_format')." ".get_option('time_format'), $metadata['timestamp']+(get_option( 'gmt_offset' ) * HOUR_IN_SECONDS));
660
+					$backup_time  = date(get_option('date_format')." ".get_option('time_format'), $metadata['timestamp'] + (get_option('gmt_offset') * HOUR_IN_SECONDS));
661 661
 				}
662 662
 			
663 663
 				$backup_text = "<span title='".$backup_time."' class='shorten_string'>".$res->last_backup." (".$backup_size.")</span>";
@@ -665,12 +665,12 @@  discard block
 block discarded – undo
665 665
 			
666 666
 			$schedules = wp_get_schedules();
667 667
 
668
-			if(isset($schedules[$res->recurrence]))
668
+			if (isset($schedules[$res->recurrence]))
669 669
 			{
670 670
 				$res->recurrence = $schedules[$res->recurrence]['display'];
671 671
 			}
672 672
 				
673
-			$return['data'][] = array($res->id, $res->name, $res->recurrence,/*$res->start_at,*/ $next_run, $remote_storage, $backup_text, $status, $action);
673
+			$return['data'][] = array($res->id, $res->name, $res->recurrence, /*$res->start_at,*/ $next_run, $remote_storage, $backup_text, $status, $action);
674 674
 		}
675 675
 
676 676
 		return $this->send_response($return, 0);
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 		
688 688
 		$schedule_id = $this->xcloner_sanitization->sanitize_input_as_int($_GET['id']);
689 689
 		$scheduler = $this->xcloner_scheduler;
690
-		$data['finished']  = $scheduler->delete_schedule_by_id($schedule_id);
690
+		$data['finished'] = $scheduler->delete_schedule_by_id($schedule_id);
691 691
 		
692 692
 		return $this->send_response($data);
693 693
 	}
@@ -721,32 +721,32 @@  discard block
 block discarded – undo
721 721
 		
722 722
 		$backup_file = $source_backup_file;
723 723
 		
724
-		if($this->xcloner_file_system->is_multipart($backup_file))
724
+		if ($this->xcloner_file_system->is_multipart($backup_file))
725 725
 		{
726 726
 			$backup_parts = $this->xcloner_file_system->get_multipart_files($backup_file);
727 727
 			$backup_file = $backup_parts[$return['part']];
728 728
 		}
729 729
 		
730
-		try{
730
+		try {
731 731
 			$tar = new Tar();
732 732
 			$tar->open($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file, $start);
733 733
 		
734 734
 			$data = $tar->contents(get_option('xcloner_files_to_process_per_request'));
735
-		}catch(Exception $e)
735
+		}catch (Exception $e)
736 736
 		{
737 737
 			$return['error'] = true;
738 738
 			$return['message'] = $e->getMessage();
739 739
 			$this->send_response($return, 0);
740 740
 		}
741 741
 		
742
-		$return['files'] 		= array();
743
-		$return['finished'] 	= 1;
744
-		$return['total_size'] 	= filesize($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file);
742
+		$return['files'] = array();
743
+		$return['finished'] = 1;
744
+		$return['total_size'] = filesize($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file);
745 745
 		$i = 0;
746 746
 		
747
-		if(isset($data['extracted_files']) and is_array($data['extracted_files']))
747
+		if (isset($data['extracted_files']) and is_array($data['extracted_files']))
748 748
 		{
749
-			foreach($data['extracted_files'] as $file)
749
+			foreach ($data['extracted_files'] as $file)
750 750
 			{
751 751
 				$return['files'][$i]['path'] = $file->getPath();
752 752
 				$return['files'][$i]['size'] = $file->getSize();
@@ -756,18 +756,18 @@  discard block
 block discarded – undo
756 756
 			}
757 757
 		}
758 758
 		
759
-		if(isset($data['start']))
759
+		if (isset($data['start']))
760 760
 		{
761 761
 			$return['start'] = $data['start'];
762 762
 			$return['finished'] = 0;	
763
-		}else{
764
-			if($this->xcloner_file_system->is_multipart($source_backup_file))
763
+		} else {
764
+			if ($this->xcloner_file_system->is_multipart($source_backup_file))
765 765
 			{
766 766
 				$return['start'] = 0;
767 767
 				
768 768
 				++$return['part'];
769 769
 			
770
-				if($return['part'] < sizeof($backup_parts))	
770
+				if ($return['part'] < sizeof($backup_parts))	
771 771
 					$return['finished'] = 0;
772 772
 				
773 773
 			}
@@ -790,17 +790,17 @@  discard block
 block discarded – undo
790 790
 		
791 791
 		try
792 792
 		{
793
-			if(method_exists($xcloner_remote_storage, "copy_backup_remote_to_local"))
793
+			if (method_exists($xcloner_remote_storage, "copy_backup_remote_to_local"))
794 794
 			{
795 795
 				$return = call_user_func_array(array($xcloner_remote_storage, "copy_backup_remote_to_local"), array($backup_file, $storage_type));
796 796
 			}
797
-		}catch(Exception $e){
797
+		}catch (Exception $e) {
798 798
 		
799 799
 			$return['error'] = 1;
800 800
 			$return['message'] = $e->getMessage();
801 801
 		}
802 802
 		
803
-		if(!$return)
803
+		if (!$return)
804 804
 		{
805 805
 			$return['error'] = 1;
806 806
 			$return['message'] = "Upload failed, please check the error log for more information!";
@@ -829,17 +829,17 @@  discard block
 block discarded – undo
829 829
 		
830 830
 		try
831 831
 		{
832
-			if(method_exists($xcloner_remote_storage, "upload_backup_to_storage"))
832
+			if (method_exists($xcloner_remote_storage, "upload_backup_to_storage"))
833 833
 			{
834 834
 				$return = call_user_func_array(array($xcloner_remote_storage, "upload_backup_to_storage"), array($backup_file, $storage_type));
835 835
 			}
836
-		}catch(Exception $e){
836
+		}catch (Exception $e) {
837 837
 		
838 838
 			$return['error'] = 1;
839 839
 			$return['message'] = $e->getMessage();
840 840
 		}
841 841
 		
842
-		if(!$return)
842
+		if (!$return)
843 843
 		{
844 844
 			$return['error'] = 1;
845 845
 			$return['message'] = "Upload failed, please check the error log for more information!";
@@ -873,7 +873,7 @@  discard block
 block discarded – undo
873 873
 		
874 874
 		@ob_end_clean();
875 875
 		
876
-		$adapter = new Local(dirname(__DIR__) ,LOCK_EX, 'SKIP_LINKS');
876
+		$adapter = new Local(dirname(__DIR__), LOCK_EX, 'SKIP_LINKS');
877 877
 		$xcloner_plugin_filesystem = new Filesystem($adapter, new Config([
878 878
 				'disable_asserts' => true,
879 879
 			]));
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
 		//$tar->addFile(dirname(__DIR__)."/restore/vendor.tgz", "vendor.tgz");
904 904
 		
905 905
 		$files = $xcloner_plugin_filesystem->listContents("vendor/", true);
906
-		foreach($files as $file)
906
+		foreach ($files as $file)
907 907
 		{
908 908
 			$tar->addFile(dirname(__DIR__).DS.$file['path'], $file['path']);
909 909
 		}
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
 		    header('Expires: 0');
923 923
 		    header('Cache-Control: must-revalidate');
924 924
 		    header('Pragma: public');
925
-		    header('Content-Length: ' . filesize($tmp_file));
925
+		    header('Content-Length: '.filesize($tmp_file));
926 926
 		    readfile($tmp_file);
927 927
 		    
928 928
 		}
@@ -945,8 +945,8 @@  discard block
 block discarded – undo
945 945
 		$backup_name = $this->xcloner_sanitization->sanitize_input_as_string($_GET['name']);
946 946
 		
947 947
 		
948
-		$metadata  = $this->xcloner_file_system->get_storage_filesystem()->getMetadata($backup_name);
949
-		$read_stream  = $this->xcloner_file_system->get_storage_filesystem()->readStream($backup_name);
948
+		$metadata = $this->xcloner_file_system->get_storage_filesystem()->getMetadata($backup_name);
949
+		$read_stream = $this->xcloner_file_system->get_storage_filesystem()->readStream($backup_name);
950 950
 		
951 951
 		
952 952
 		header('Pragma: public');
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
 	    header('Content-Transfer-Encoding: binary');
957 957
 	    header('Content-Disposition: attachment; filename="'.$metadata['path'].'";');
958 958
 	    header('Content-Type: application/octet-stream');
959
-	    header('Content-Length: ' . $metadata['size']);
959
+	    header('Content-Length: '.$metadata['size']);
960 960
 	    
961 961
 	    @ob_end_clean();
962 962
 	    
@@ -984,10 +984,10 @@  discard block
 block discarded – undo
984 984
 		$file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
985 985
 		$hash = $this->xcloner_sanitization->sanitize_input_as_string($_POST['hash']);
986 986
 		
987
-		if(isset($_POST['part']))
987
+		if (isset($_POST['part']))
988 988
 			$return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
989 989
 		
990
-		if(isset($_POST['uploaded_size']))
990
+		if (isset($_POST['uploaded_size']))
991 991
 			$return['uploaded_size'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['uploaded_size']);
992 992
 		
993 993
 		$start = $this->xcloner_sanitization->sanitize_input_as_string($_POST['start']);
@@ -995,46 +995,46 @@  discard block
 block discarded – undo
995 995
 		
996 996
 		$return['total_size'] = $this->xcloner_file_system->get_backup_size($file);
997 997
 		
998
-		if($this->xcloner_file_system->is_multipart($file))
998
+		if ($this->xcloner_file_system->is_multipart($file))
999 999
 		{
1000 1000
 			$backup_parts = $this->xcloner_file_system->get_multipart_files($file);
1001 1001
 			
1002
-			$return['total_parts'] = sizeof($backup_parts)+1;
1002
+			$return['total_parts'] = sizeof($backup_parts) + 1;
1003 1003
 			
1004
-			if($return['part'] and isset($backup_parts[$return['part']-1]))
1004
+			if ($return['part'] and isset($backup_parts[$return['part'] - 1]))
1005 1005
 			{
1006
-				$file = $backup_parts[$return['part']-1];
1006
+				$file = $backup_parts[$return['part'] - 1];
1007 1007
 			}
1008 1008
 			
1009 1009
 			$is_multipart = 1;	
1010 1010
 		}
1011 1011
 		
1012
-		try{
1012
+		try {
1013 1013
 		
1014 1014
 			$xcloner_file_transfer = $this->get_xcloner_container()->get_xcloner_file_transfer();
1015 1015
 			$xcloner_file_transfer->set_target($target_url);
1016 1016
 			$return['start'] = $xcloner_file_transfer->transfer_file($file, $start, $hash);
1017 1017
 		
1018
-		}catch(Exception $e){
1018
+		}catch (Exception $e) {
1019 1019
 		
1020 1020
 			$return = array();
1021 1021
 			$return['error'] = true;
1022 1022
 			$return['status'] = 500;
1023 1023
 			$return['message'] = "CURL communication error with the restore host. ".$e->getMessage();
1024
-			$this->send_response( $return, 0);
1024
+			$this->send_response($return, 0);
1025 1025
 		
1026 1026
 		}
1027 1027
 		
1028 1028
 		$return['status'] = 200;
1029 1029
 		
1030 1030
 		//we have finished the upload
1031
-		if(!$return['start'] and $is_multipart)
1031
+		if (!$return['start'] and $is_multipart)
1032 1032
 		{
1033 1033
 			$return['part']++;
1034 1034
 			$return['uploaded_size'] += $this->xcloner_file_system->get_storage_filesystem()->getSize($file);
1035 1035
 		}
1036 1036
 		
1037
-		$this->send_response( $return, 0);
1037
+		$this->send_response($return, 0);
1038 1038
 	}
1039 1039
 	
1040 1040
 	public function restore_backup()
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
 		$this->check_access();
1043 1043
 		
1044 1044
 		define("XCLONER_PLUGIN_ACCESS", 1);
1045
-		include_once(dirname(__DIR__) .DS."restore".DS."xcloner_restore.php");
1045
+		include_once(dirname(__DIR__).DS."restore".DS."xcloner_restore.php");
1046 1046
 		return;
1047 1047
 	}
1048 1048
 	
@@ -1054,12 +1054,12 @@  discard block
 block discarded – undo
1054 1054
 	private function send_response($data, $attach_hash = 1)
1055 1055
 	{
1056 1056
 		
1057
-		if($attach_hash and null !== $this->xcloner_settings->get_hash())
1057
+		if ($attach_hash and null !== $this->xcloner_settings->get_hash())
1058 1058
 		{
1059 1059
 			$data['hash'] = $this->xcloner_settings->get_hash();
1060 1060
 		}
1061 1061
 			
1062
-		if( ob_get_length() )
1062
+		if (ob_get_length())
1063 1063
 			ob_clean();
1064 1064
 		wp_send_json($data);
1065 1065
 		
Please login to merge, or discard this patch.
Braces   +103 added lines, -80 removed lines patch added patch discarded remove patch
@@ -32,8 +32,9 @@  discard block
 block discarded – undo
32 32
 			error_reporting(0);
33 33
 		}
34 34
 		
35
-		if( ob_get_length() )
36
-			ob_end_clean();
35
+		if( ob_get_length() ) {
36
+					ob_end_clean();
37
+		}
37 38
 		ob_start();
38 39
 		
39 40
 		$wpdb->show_errors			= false;
@@ -86,7 +87,7 @@  discard block
 block discarded – undo
86 87
 		{
87 88
 			$this->xcloner_database->init($data);
88 89
 
89
-		}catch(Exception $e){
90
+		} catch(Exception $e){
90 91
 			
91 92
 			$this->send_response($e->getMessage());
92 93
 			$this->logger->error($e->getMessage());
@@ -113,8 +114,9 @@  discard block
 block discarded – undo
113 114
 		$schedule = array();
114 115
 		$response = array();
115 116
 		
116
-		if(isset($_POST['data']))
117
-			$params = json_decode(stripslashes($_POST['data']));
117
+		if(isset($_POST['data'])) {
118
+					$params = json_decode(stripslashes($_POST['data']));
119
+		}
118 120
 		
119 121
 		$this->process_params($params);
120 122
 		
@@ -125,7 +127,7 @@  discard block
 block discarded – undo
125 127
 			$this->form_params['backup_params']['email_notification'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['email_notification']);
126 128
 			if($_POST['diff_start_date']){
127 129
 				$this->form_params['backup_params']['diff_start_date'] = strtotime($this->xcloner_sanitization->sanitize_input_as_string($_POST['diff_start_date']));
128
-			}else{
130
+			} else{
129 131
 				$this->form_params['backup_params']['diff_start_date'] = "";
130 132
 				}
131 133
 			$this->form_params['backup_params']['schedule_name'] = $this->xcloner_sanitization->sanitize_input_as_string($_POST['schedule_name']);
@@ -144,8 +146,9 @@  discard block
 block discarded – undo
144 146
 			{
145 147
 					$table = str_replace("\r","", $table);
146 148
 					$data = explode(".", $table);
147
-					if(isset($data[1]))
148
-						$return[$data[0]][] = $data[1];
149
+					if(isset($data[1])) {
150
+											$return[$data[0]][] = $data[1];
151
+					}
149 152
 			}
150 153
 			
151 154
 			$this->form_params['database'] = ($return);
@@ -156,19 +159,21 @@  discard block
 block discarded – undo
156 159
 			foreach($excluded_files as $file)
157 160
 			{
158 161
 				$file = str_replace("\r","", $file);
159
-				if($file)
160
-					$return[] = $file;
162
+				if($file) {
163
+									$return[] = $file;
164
+				}
161 165
 			}
162 166
 			
163 167
 			$this->form_params['excluded_files'] = ($return);
164 168
 			
165 169
 			$schedule['start_at'] = $this->form_params['backup_params']['start_at'];
166 170
 			
167
-			if(!isset($_POST['status']))
168
-				$schedule['status'] = 0;
169
-			else	
170
-				$schedule['status'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['status']);
171
-		}else{
171
+			if(!isset($_POST['status'])) {
172
+							$schedule['status'] = 0;
173
+			} else {
174
+							$schedule['status'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['status']);
175
+			}
176
+		} else{
172 177
 		
173 178
 			$schedule['status'] = 1;
174 179
 			$schedule['start_at'] = strtotime($this->form_params['backup_params']['schedule_start_date'] .
@@ -183,7 +188,7 @@  discard block
 block discarded – undo
183 188
 		if(!$schedule['start_at'])						
184 189
 		{
185 190
 			$schedule['start_at'] = date('Y-m-d H:i:s', time());
186
-		}else{
191
+		} else{
187 192
 			$schedule['start_at'] = date('Y-m-d H:i:s', $schedule['start_at'] - (get_option( 'gmt_offset' ) * HOUR_IN_SECONDS) );	
188 193
 		}
189 194
 		
@@ -203,7 +208,7 @@  discard block
 block discarded – undo
203 208
 					'%s' 
204 209
 				) 
205 210
 			);
206
-		}else		{
211
+		} else		{
207 212
 			$wpdb->update( 
208 213
 				$wpdb->prefix.'xcloner_scheduler', 
209 214
 				$schedule, 
@@ -244,8 +249,9 @@  discard block
 block discarded – undo
244 249
 		
245 250
 		$init 	= (int)$_POST['init'];
246 251
 		
247
-		if($params === NULL)
248
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
252
+		if($params === NULL) {
253
+					 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
254
+		}
249 255
 			 
250 256
 		$this->process_params($params);
251 257
 		
@@ -254,7 +260,7 @@  discard block
 block discarded – undo
254 260
 		//$return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], $this->form_params['extra'], $init);
255 261
 		try{
256 262
 			$return = $this->archive_system->start_incremental_backup($this->form_params['backup_params'], $this->form_params['extra'], $init);
257
-		}catch(Exception $e)
263
+		} catch(Exception $e)
258 264
 		{
259 265
 			$return = array();
260 266
 			$return['error'] = true;
@@ -266,8 +272,9 @@  discard block
 block discarded – undo
266 272
 		if($return['finished'])
267 273
 		{
268 274
 			$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_with_extension();
269
-			if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension()))
270
-				$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart();
275
+			if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension())) {
276
+							$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart();
277
+			}
271 278
 		}
272 279
 		
273 280
 		$data = $return;
@@ -282,7 +289,7 @@  discard block
 block discarded – undo
282 289
 					$subject = "";
283 290
 					$additional['lines_total'] = $return['extra']['lines_total'];
284 291
 					$this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'], $this->form_params,"", $additional);
285
-				}catch(Exception $e)
292
+				} catch(Exception $e)
286 293
 				{
287 294
 					$this->logger->error($e->getMessage());
288 295
 				}
@@ -306,18 +313,20 @@  discard block
 block discarded – undo
306 313
 		
307 314
 		$init 	= (int)$_POST['init'];
308 315
 		
309
-		if($params === NULL)
310
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
316
+		if($params === NULL) {
317
+					 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
318
+		}
311 319
 		
312 320
 		$this->process_params($params);
313 321
 			
314 322
 		//$xcloner_database = $this->init_db();	
315 323
 		$return = $this->xcloner_database->start_database_recursion($this->form_params['database'], $this->form_params['extra'], $init);
316 324
 		
317
-		if(isset($return['error']) and $return['error'])
318
-			$data['finished'] = 1;
319
-		else	
320
-			$data['finished'] = $return['finished'];
325
+		if(isset($return['error']) and $return['error']) {
326
+					$data['finished'] = 1;
327
+		} else {
328
+					$data['finished'] = $return['finished'];
329
+		}
321 330
 			
322 331
 		$data['extra'] = $return;
323 332
 		
@@ -336,8 +345,9 @@  discard block
 block discarded – undo
336 345
 		$params = json_decode(stripslashes($_POST['data']));
337 346
 		$init 	= (int)$_POST['init'];
338 347
 		
339
-		if($params === NULL)
340
-			 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
348
+		if($params === NULL) {
349
+					 die( '{"status":false,"msg":"The post_data parameter must be valid JSON"}' );
350
+		}
341 351
 			 
342 352
 		$hash = $this->process_params($params);
343 353
 		
@@ -360,8 +370,9 @@  discard block
 block discarded – undo
360 370
 	 */ 
361 371
 	private function process_params($params)
362 372
 	{
363
-		if(isset($params->hash))
364
-			$this->xcloner_settings->set_hash($params->hash);
373
+		if(isset($params->hash)) {
374
+					$this->xcloner_settings->set_hash($params->hash);
375
+		}
365 376
 			
366 377
 		$this->form_params['extra'] = array();
367 378
 		$this->form_params['backup_params'] = array();
@@ -414,8 +425,9 @@  discard block
 block discarded – undo
414 425
 		
415 426
 		if(isset($params->extra))
416 427
 		{
417
-			foreach($params->extra as $key=>$value)
418
-				$this->form_params['extra'][$key] = $this->xcloner_sanitization->sanitize_input_as_raw($value);
428
+			foreach($params->extra as $key=>$value) {
429
+							$this->form_params['extra'][$key] = $this->xcloner_sanitization->sanitize_input_as_raw($value);
430
+			}
419 431
 		}
420 432
 		
421 433
 		if(isset($this->form_params['backup_params']['diff_start_date']) and $this->form_params['backup_params']['diff_start_date'])
@@ -455,7 +467,7 @@  discard block
 block discarded – undo
455 467
 			
456 468
 			try{
457 469
 				$files = $this->xcloner_file_system->list_directory($folder);
458
-			}catch(Exception $e){
470
+			} catch(Exception $e){
459 471
 				
460 472
 				print $e->getMessage();
461 473
 				$this->logger->error($e->getMessage());
@@ -475,15 +487,17 @@  discard block
 block discarded – undo
475 487
 				$children = false;
476 488
 				$text = $file['basename'];
477 489
 				
478
-				if($file['type'] == "dir")
479
-					$children = true;
480
-				else
481
-					 $text .= " (". $this->xcloner_requirements->file_format_size($file['size']).")";
490
+				if($file['type'] == "dir") {
491
+									$children = true;
492
+				} else {
493
+									 $text .= " (". $this->xcloner_requirements->file_format_size($file['size']).")";
494
+				}
482 495
 				
483
-				if($this->xcloner_file_system->is_excluded($file))
484
-					$selected = true;
485
-				else
486
-					$selected = false;
496
+				if($this->xcloner_file_system->is_excluded($file)) {
497
+									$selected = true;
498
+				} else {
499
+									$selected = false;
500
+				}
487 501
 					
488 502
 				$data[] = array(
489 503
 							'id' => $file['path'],
@@ -519,22 +533,24 @@  discard block
 block discarded – undo
519 533
 		{
520 534
 			try{
521 535
 				$return = $this->xcloner_database->get_all_databases();
522
-			}catch(Exception $e){
536
+			} catch(Exception $e){
523 537
 				$this->logger->error($e->getMessage());
524 538
 			}
525 539
 			
526 540
 			foreach($return as $database)
527 541
 			{
528
-				if($xcloner_backup_only_wp_tables and $database['name'] != $this->xcloner_settings->get_db_database())
529
-					continue;
542
+				if($xcloner_backup_only_wp_tables and $database['name'] != $this->xcloner_settings->get_db_database()) {
543
+									continue;
544
+				}
530 545
 					
531 546
 				$state = array();
532 547
 				
533 548
 				if($database['name'] == $this->xcloner_settings->get_db_database())
534 549
 				{
535 550
 					$state['selected'] = true;
536
-					if($database['num_tables'] < 25)
537
-						$state['opened'] = false;
551
+					if($database['num_tables'] < 25) {
552
+											$state['opened'] = false;
553
+					}
538 554
 				}
539 555
 					
540 556
 				$data[] = array(
@@ -547,13 +563,11 @@  discard block
 block discarded – undo
547 563
 						);
548 564
 			}
549 565
 			
550
-		}
551
-		
552
-		else{
566
+		} else{
553 567
 			
554 568
 			try{
555 569
 				$return = $this->xcloner_database->list_tables($database, "", 1);
556
-			}catch(Exception $e){
570
+			} catch(Exception $e){
557 571
 				$this->logger->error($e->getMessage());
558 572
 			}
559 573
 			
@@ -561,11 +575,13 @@  discard block
 block discarded – undo
561 575
 			{
562 576
 				$state = array();
563 577
 				
564
-				if($xcloner_backup_only_wp_tables and !stristr($table['name'], $this->xcloner_settings->get_table_prefix()))
565
-					continue;
578
+				if($xcloner_backup_only_wp_tables and !stristr($table['name'], $this->xcloner_settings->get_table_prefix())) {
579
+									continue;
580
+				}
566 581
 				
567
-				if(isset($database['name']) and $database['name'] == $this->xcloner_settings->get_db_database())
568
-					$state = array('selected' => true);
582
+				if(isset($database['name']) and $database['name'] == $this->xcloner_settings->get_db_database()) {
583
+									$state = array('selected' => true);
584
+				}
569 585
 					
570 586
 				$data[] = array(
571 587
 						'id' => $table['name'],
@@ -620,10 +636,11 @@  discard block
 block discarded – undo
620 636
 		{
621 637
 			$action = "<a href=\"#".$res->id."\" class=\"edit\" title='Edit'> <i class=\"material-icons \">edit</i></a> 
622 638
 					<a href=\"#".$res->id."\" class=\"delete\" title='Delete'><i class=\"material-icons  \">delete</i></a>";
623
-			if($res->status)
624
-				$status = '<i class="material-icons active status">timer</i>';
625
-			else
626
-				$status = '<i class="material-icons status inactive">timer_off</i>';
639
+			if($res->status) {
640
+							$status = '<i class="material-icons active status">timer</i>';
641
+			} else {
642
+							$status = '<i class="material-icons status inactive">timer_off</i>';
643
+			}
627 644
 				
628 645
 			$next_run_time = wp_next_scheduled('xcloner_scheduler_'.$res->id, array($res->id));
629 646
 				
@@ -631,17 +648,19 @@  discard block
 block discarded – undo
631 648
 			
632 649
 			$remote_storage = $res->remote_storage;
633 650
 			
634
-			if(!$next_run_time >= time())
635
-				$next_run = " ";
651
+			if(!$next_run_time >= time()) {
652
+							$next_run = " ";
653
+			}
636 654
 			
637 655
 			if(trim($next_run))
638 656
 			{
639 657
 				$date_text = date(get_option('date_format')." ".get_option('time_format'), $next_run_time + (get_option( 'gmt_offset' ) * HOUR_IN_SECONDS));
640 658
 				
641
-				if($next_run_time >= time())
642
-					$next_run = "in ".human_time_diff($next_run_time, time());
643
-				else
644
-					$next_run = __("executed", 'xcloner-backup-and-restore');
659
+				if($next_run_time >= time()) {
660
+									$next_run = "in ".human_time_diff($next_run_time, time());
661
+				} else {
662
+									$next_run = __("executed", 'xcloner-backup-and-restore');
663
+				}
645 664
 				
646 665
 				$next_run = "<a href='#' title='".$date_text."'>".$next_run."</a>";
647 666
 				//$next_run .=" ($date_text)";	
@@ -732,7 +751,7 @@  discard block
 block discarded – undo
732 751
 			$tar->open($this->xcloner_settings->get_xcloner_store_path().DS.$backup_file, $start);
733 752
 		
734 753
 			$data = $tar->contents(get_option('xcloner_files_to_process_per_request'));
735
-		}catch(Exception $e)
754
+		} catch(Exception $e)
736 755
 		{
737 756
 			$return['error'] = true;
738 757
 			$return['message'] = $e->getMessage();
@@ -760,15 +779,16 @@  discard block
 block discarded – undo
760 779
 		{
761 780
 			$return['start'] = $data['start'];
762 781
 			$return['finished'] = 0;	
763
-		}else{
782
+		} else{
764 783
 			if($this->xcloner_file_system->is_multipart($source_backup_file))
765 784
 			{
766 785
 				$return['start'] = 0;
767 786
 				
768 787
 				++$return['part'];
769 788
 			
770
-				if($return['part'] < sizeof($backup_parts))	
771
-					$return['finished'] = 0;
789
+				if($return['part'] < sizeof($backup_parts)) {
790
+									$return['finished'] = 0;
791
+				}
772 792
 				
773 793
 			}
774 794
 		}	
@@ -794,7 +814,7 @@  discard block
 block discarded – undo
794 814
 			{
795 815
 				$return = call_user_func_array(array($xcloner_remote_storage, "copy_backup_remote_to_local"), array($backup_file, $storage_type));
796 816
 			}
797
-		}catch(Exception $e){
817
+		} catch(Exception $e){
798 818
 		
799 819
 			$return['error'] = 1;
800 820
 			$return['message'] = $e->getMessage();
@@ -833,7 +853,7 @@  discard block
 block discarded – undo
833 853
 			{
834 854
 				$return = call_user_func_array(array($xcloner_remote_storage, "upload_backup_to_storage"), array($backup_file, $storage_type));
835 855
 			}
836
-		}catch(Exception $e){
856
+		} catch(Exception $e){
837 857
 		
838 858
 			$return['error'] = 1;
839 859
 			$return['message'] = $e->getMessage();
@@ -984,11 +1004,13 @@  discard block
 block discarded – undo
984 1004
 		$file = $this->xcloner_sanitization->sanitize_input_as_string($_POST['file']);
985 1005
 		$hash = $this->xcloner_sanitization->sanitize_input_as_string($_POST['hash']);
986 1006
 		
987
-		if(isset($_POST['part']))
988
-			$return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
1007
+		if(isset($_POST['part'])) {
1008
+					$return['part'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['part']);
1009
+		}
989 1010
 		
990
-		if(isset($_POST['uploaded_size']))
991
-			$return['uploaded_size'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['uploaded_size']);
1011
+		if(isset($_POST['uploaded_size'])) {
1012
+					$return['uploaded_size'] = $this->xcloner_sanitization->sanitize_input_as_int($_POST['uploaded_size']);
1013
+		}
992 1014
 		
993 1015
 		$start = $this->xcloner_sanitization->sanitize_input_as_string($_POST['start']);
994 1016
 		$target_url = $this->xcloner_sanitization->sanitize_input_as_string($_POST['target_url']);
@@ -1015,7 +1037,7 @@  discard block
 block discarded – undo
1015 1037
 			$xcloner_file_transfer->set_target($target_url);
1016 1038
 			$return['start'] = $xcloner_file_transfer->transfer_file($file, $start, $hash);
1017 1039
 		
1018
-		}catch(Exception $e){
1040
+		} catch(Exception $e){
1019 1041
 		
1020 1042
 			$return = array();
1021 1043
 			$return['error'] = true;
@@ -1059,8 +1081,9 @@  discard block
 block discarded – undo
1059 1081
 			$data['hash'] = $this->xcloner_settings->get_hash();
1060 1082
 		}
1061 1083
 			
1062
-		if( ob_get_length() )
1063
-			ob_clean();
1084
+		if( ob_get_length() ) {
1085
+					ob_clean();
1086
+		}
1064 1087
 		wp_send_json($data);
1065 1088
 		
1066 1089
 		die();
Please login to merge, or discard this patch.
includes/class-xcloner-activator.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -35,22 +35,22 @@  discard block
 block discarded – undo
35 35
 	
36 36
 		global $wpdb;
37 37
 		
38
-		if(version_compare(phpversion(), Xcloner_Activator::xcloner_minimum_version, '<'))
38
+		if (version_compare(phpversion(), Xcloner_Activator::xcloner_minimum_version, '<'))
39 39
 		{
40
-			wp_die('<p>'.sprintf(__("XCloner requires minimum PHP version %s in order to run correctly. We have detected your version as %s"),Xcloner_Activator::xcloner_minimum_version, phpversion()).'</p>',  __("XCloner Activation Error"), array( 'response'=>500, 'back_link'=>TRUE ) );
40
+			wp_die('<p>'.sprintf(__("XCloner requires minimum PHP version %s in order to run correctly. We have detected your version as %s"), Xcloner_Activator::xcloner_minimum_version, phpversion()).'</p>', __("XCloner Activation Error"), array('response'=>500, 'back_link'=>TRUE));
41 41
 		}
42 42
 		
43 43
 		$charset_collate = $wpdb->get_charset_collate();	
44 44
 		
45
-		$installed_ver = get_option( "xcloner_db_version" );
45
+		$installed_ver = get_option("xcloner_db_version");
46 46
 		
47 47
 		$xcloner_db_version = Xcloner_Activator::xcloner_db_version;
48 48
 		
49
-		$xcloner_scheduler_table = $wpdb->prefix . "xcloner_scheduler";
49
+		$xcloner_scheduler_table = $wpdb->prefix."xcloner_scheduler";
50 50
 		
51
-		if($installed_ver != $xcloner_db_version)		
51
+		if ($installed_ver != $xcloner_db_version)		
52 52
 		{
53
-			$xcloner_schedule_sql="CREATE TABLE `".$xcloner_scheduler_table."` (
53
+			$xcloner_schedule_sql = "CREATE TABLE `".$xcloner_scheduler_table."` (
54 54
 				  `id` int(11) NOT NULL AUTO_INCREMENT,
55 55
 				  `name` varchar(255) NOT NULL,
56 56
 				  `recurrence` varchar(25) NOT NULL,
@@ -64,53 +64,53 @@  discard block
 block discarded – undo
64 64
 				) ".$charset_collate.";
65 65
 				";
66 66
 			
67
-			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
68
-			dbDelta( $xcloner_schedule_sql );
67
+			require_once(ABSPATH.'wp-admin/includes/upgrade.php');
68
+			dbDelta($xcloner_schedule_sql);
69 69
 			
70
-			update_option( "xcloner_db_version", $xcloner_db_version );
70
+			update_option("xcloner_db_version", $xcloner_db_version);
71 71
 		}
72 72
 		
73
-		if(get_option('xcloner_backup_compression_level') === false)
73
+		if (get_option('xcloner_backup_compression_level') === false)
74 74
 			update_option('xcloner_backup_compression_level', 0);
75 75
 		
76
-		if(get_option('xcloner_enable_log') === false)
76
+		if (get_option('xcloner_enable_log') === false)
77 77
 			update_option('xcloner_enable_log', 1);
78 78
 			
79
-		if(get_option('xcloner_enable_mysql_backup') === false)
79
+		if (get_option('xcloner_enable_mysql_backup') === false)
80 80
 			update_option('xcloner_enable_mysql_backup', 1);
81 81
 		
82
-		if(get_option('xcloner_system_settings_page') === false)
82
+		if (get_option('xcloner_system_settings_page') === false)
83 83
 			update_option('xcloner_system_settings_page', 100);
84 84
 			
85
-		if(get_option('xcloner_files_to_process_per_request') === false)
85
+		if (get_option('xcloner_files_to_process_per_request') === false)
86 86
 			update_option('xcloner_files_to_process_per_request', 250);
87 87
 
88
-		if(get_option('xcloner_database_records_per_request') === false)
88
+		if (get_option('xcloner_database_records_per_request') === false)
89 89
 			update_option('xcloner_database_records_per_request', 10000);
90 90
 
91
-		if(get_option('xcloner_exclude_files_larger_than_mb') === false)
91
+		if (get_option('xcloner_exclude_files_larger_than_mb') === false)
92 92
 			update_option('xcloner_exclude_files_larger_than_mb', 0);
93 93
 		
94
-		if(get_option('xcloner_split_backup_limit') === false)
94
+		if (get_option('xcloner_split_backup_limit') === false)
95 95
 			update_option('xcloner_split_backup_limit', 2048);
96 96
 			
97
-		if(get_option('xcloner_size_limit_per_request') === false)
97
+		if (get_option('xcloner_size_limit_per_request') === false)
98 98
 			update_option('xcloner_size_limit_per_request', 50);
99 99
 			
100
-		if(get_option('xcloner_cleanup_retention_limit_days') === false)
100
+		if (get_option('xcloner_cleanup_retention_limit_days') === false)
101 101
 			update_option('xcloner_cleanup_retention_limit_days', 60);
102 102
 			
103
-		if(get_option('xcloner_cleanup_retention_limit_archives') === false)
103
+		if (get_option('xcloner_cleanup_retention_limit_archives') === false)
104 104
 			update_option('xcloner_cleanup_retention_limit_archives', 100);
105 105
 			
106
-		if(get_option('xcloner_directories_to_scan_per_request') === false)
106
+		if (get_option('xcloner_directories_to_scan_per_request') === false)
107 107
 			update_option('xcloner_directories_to_scan_per_request', 25);
108 108
 			
109 109
 		/*if(!get_option('xcloner_diff_backup_recreate_period'))
110 110
 			update_option('xcloner_diff_backup_recreate_period', 10);
111 111
 			* */
112 112
 			
113
-		if(!get_option('xcloner_regex_exclude'))
113
+		if (!get_option('xcloner_regex_exclude'))
114 114
 			update_option('xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$".PHP_EOL."(.*)\.(svn|git)(.*)$".PHP_EOL."wp-content\/cache(.*)$".PHP_EOL."(.*)error_log$");
115 115
 
116 116
 	}
Please login to merge, or discard this patch.
Braces   +39 added lines, -26 removed lines patch added patch discarded remove patch
@@ -70,48 +70,61 @@
 block discarded – undo
70 70
 			update_option( "xcloner_db_version", $xcloner_db_version );
71 71
 		}
72 72
 		
73
-		if(get_option('xcloner_backup_compression_level') === false)
74
-			update_option('xcloner_backup_compression_level', 0);
73
+		if(get_option('xcloner_backup_compression_level') === false) {
74
+					update_option('xcloner_backup_compression_level', 0);
75
+		}
75 76
 		
76
-		if(get_option('xcloner_enable_log') === false)
77
-			update_option('xcloner_enable_log', 1);
77
+		if(get_option('xcloner_enable_log') === false) {
78
+					update_option('xcloner_enable_log', 1);
79
+		}
78 80
 			
79
-		if(get_option('xcloner_enable_mysql_backup') === false)
80
-			update_option('xcloner_enable_mysql_backup', 1);
81
+		if(get_option('xcloner_enable_mysql_backup') === false) {
82
+					update_option('xcloner_enable_mysql_backup', 1);
83
+		}
81 84
 		
82
-		if(get_option('xcloner_system_settings_page') === false)
83
-			update_option('xcloner_system_settings_page', 100);
85
+		if(get_option('xcloner_system_settings_page') === false) {
86
+					update_option('xcloner_system_settings_page', 100);
87
+		}
84 88
 			
85
-		if(get_option('xcloner_files_to_process_per_request') === false)
86
-			update_option('xcloner_files_to_process_per_request', 250);
89
+		if(get_option('xcloner_files_to_process_per_request') === false) {
90
+					update_option('xcloner_files_to_process_per_request', 250);
91
+		}
87 92
 
88
-		if(get_option('xcloner_database_records_per_request') === false)
89
-			update_option('xcloner_database_records_per_request', 10000);
93
+		if(get_option('xcloner_database_records_per_request') === false) {
94
+					update_option('xcloner_database_records_per_request', 10000);
95
+		}
90 96
 
91
-		if(get_option('xcloner_exclude_files_larger_than_mb') === false)
92
-			update_option('xcloner_exclude_files_larger_than_mb', 0);
97
+		if(get_option('xcloner_exclude_files_larger_than_mb') === false) {
98
+					update_option('xcloner_exclude_files_larger_than_mb', 0);
99
+		}
93 100
 		
94
-		if(get_option('xcloner_split_backup_limit') === false)
95
-			update_option('xcloner_split_backup_limit', 2048);
101
+		if(get_option('xcloner_split_backup_limit') === false) {
102
+					update_option('xcloner_split_backup_limit', 2048);
103
+		}
96 104
 			
97
-		if(get_option('xcloner_size_limit_per_request') === false)
98
-			update_option('xcloner_size_limit_per_request', 50);
105
+		if(get_option('xcloner_size_limit_per_request') === false) {
106
+					update_option('xcloner_size_limit_per_request', 50);
107
+		}
99 108
 			
100
-		if(get_option('xcloner_cleanup_retention_limit_days') === false)
101
-			update_option('xcloner_cleanup_retention_limit_days', 60);
109
+		if(get_option('xcloner_cleanup_retention_limit_days') === false) {
110
+					update_option('xcloner_cleanup_retention_limit_days', 60);
111
+		}
102 112
 			
103
-		if(get_option('xcloner_cleanup_retention_limit_archives') === false)
104
-			update_option('xcloner_cleanup_retention_limit_archives', 100);
113
+		if(get_option('xcloner_cleanup_retention_limit_archives') === false) {
114
+					update_option('xcloner_cleanup_retention_limit_archives', 100);
115
+		}
105 116
 			
106
-		if(get_option('xcloner_directories_to_scan_per_request') === false)
107
-			update_option('xcloner_directories_to_scan_per_request', 25);
117
+		if(get_option('xcloner_directories_to_scan_per_request') === false) {
118
+					update_option('xcloner_directories_to_scan_per_request', 25);
119
+		}
108 120
 			
109 121
 		/*if(!get_option('xcloner_diff_backup_recreate_period'))
110 122
 			update_option('xcloner_diff_backup_recreate_period', 10);
111 123
 			* */
112 124
 			
113
-		if(!get_option('xcloner_regex_exclude'))
114
-			update_option('xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$".PHP_EOL."(.*)\.(svn|git)(.*)$".PHP_EOL."wp-content\/cache(.*)$".PHP_EOL."(.*)error_log$");
125
+		if(!get_option('xcloner_regex_exclude')) {
126
+					update_option('xcloner_regex_exclude', "(wp-content\/updraft|wp-content\/uploads\/wp_all_backup)(.*)$".PHP_EOL."(.*)\.(svn|git)(.*)$".PHP_EOL."wp-content\/cache(.*)$".PHP_EOL."(.*)error_log$");
127
+		}
115 128
 
116 129
 	}
117 130
 	
Please login to merge, or discard this patch.
includes/class-xcloner-database.php 2 patches
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
  */
22 22
 
23 23
 
24
-class Xcloner_Database extends wpdb{
24
+class Xcloner_Database extends wpdb {
25 25
 
26 26
 
27
-	public  $debug 						= 0;
28
-	public  $recordsPerSession			= 10000;
29
-	public  $dbCompatibility			= "";
27
+	public  $debug = 0;
28
+	public  $recordsPerSession = 10000;
29
+	public  $dbCompatibility = "";
30 30
 	public  $dbDropSyntax				= 1;
31 31
 	public  $countRecords				= 0;
32 32
 
@@ -38,24 +38,24 @@  discard block
 block discarded – undo
38 38
 	private   $TEMP_DBPROCESS_FILE = ".database";
39 39
 	private   $TEMP_DUMP_FILE = "database-backup.sql";
40 40
 	
41
-	public function __construct(Xcloner $xcloner_container, $wp_user="", $wp_pass="", $wp_db="", $wp_host="")
41
+	public function __construct(Xcloner $xcloner_container, $wp_user = "", $wp_pass = "", $wp_db = "", $wp_host = "")
42 42
 	{
43
-		$this->logger 					= $xcloner_container->get_xcloner_logger()->withName("xcloner_database");
44
-		$this->xcloner_settings 		= $xcloner_container->get_xcloner_settings();
45
-		$this->fs 						= $xcloner_container->get_xcloner_filesystem();
43
+		$this->logger = $xcloner_container->get_xcloner_logger()->withName("xcloner_database");
44
+		$this->xcloner_settings = $xcloner_container->get_xcloner_settings();
45
+		$this->fs = $xcloner_container->get_xcloner_filesystem();
46 46
 		
47
-		if($this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request'))
48
-			$this->recordsPerSession		= $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request');
47
+		if ($this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request'))
48
+			$this->recordsPerSession = $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request');
49 49
 		
50
-		if(!$this->recordsPerSession)
50
+		if (!$this->recordsPerSession)
51 51
 			$this->recordsPerSession = 100;
52 52
 		
53
-		if(!$wp_user && !$wp_pass && !$wp_host && !$wp_db )
53
+		if (!$wp_user && !$wp_pass && !$wp_host && !$wp_db)
54 54
 		{
55 55
 			$wp_host 	= $this->xcloner_settings->get_db_hostname();
56 56
 			$wp_user 	= $this->xcloner_settings->get_db_username();
57 57
 			$wp_pass 	= $this->xcloner_settings->get_db_password();
58
-			$wp_db 		= $this->xcloner_settings->get_db_database();
58
+			$wp_db = $this->xcloner_settings->get_db_database();
59 59
 		}
60 60
 		
61 61
 		parent::__construct($wp_user, $wp_pass, $wp_db, $wp_host);
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	public function init($data, $start = 0)
73 73
 	{
74
-		if($start and $this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)){
74
+		if ($start and $this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) {
75 75
 				$this->fs->get_tmp_filesystem()->delete($this->TEMP_DBPROCESS_FILE);
76 76
 		}
77 77
 		
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 				"database_count"=>0,
91 91
 		);
92 92
 		
93
-		if(!$this->xcloner_settings->get_enable_mysql_backup())
93
+		if (!$this->xcloner_settings->get_enable_mysql_backup())
94 94
 		{
95 95
 			$return['finished'] = 1;
96 96
 			return $return;
@@ -100,44 +100,44 @@  discard block
 block discarded – undo
100 100
 		
101 101
 		$this->init($params, $init);
102 102
 		
103
-		if($init)
103
+		if ($init)
104 104
 		{
105 105
 			$db_count = 0;
106 106
 			
107
-			if(isset($params['#']))
107
+			if (isset($params['#']))
108 108
 			{
109
-				foreach($params['#'] as $database)
109
+				foreach ($params['#'] as $database)
110 110
 				{
111
-					if(!isset($params[$database]) or !is_array($params[$database]))
111
+					if (!isset($params[$database]) or !is_array($params[$database]))
112 112
 						$params[$database] = array();
113 113
 				}
114 114
 				$db_count = -1;
115 115
 			}
116 116
 			
117
-			if(isset($params) and is_array($params))
118
-				foreach($params as $database=>$tables)
117
+			if (isset($params) and is_array($params))
118
+				foreach ($params as $database=>$tables)
119 119
 				{	
120
-					if($database != "#")
120
+					if ($database != "#")
121 121
 					{
122 122
 						$stats = $this->write_backup_process_list($database, $tables);	
123
-						$return['stats']['tables_count'] 	+= $stats['tables_count'];
124
-						$return['stats']['total_records'] 	+= $stats['total_records'];
123
+						$return['stats']['tables_count'] += $stats['tables_count'];
124
+						$return['stats']['total_records'] += $stats['total_records'];
125 125
 					}
126 126
 				}
127 127
 
128
-			if(sizeof($params))
129
-				$return['stats']['database_count'] = sizeof($params)+$db_count;
128
+			if (sizeof($params))
129
+				$return['stats']['database_count'] = sizeof($params) + $db_count;
130 130
 			else	
131 131
 				$return['stats']['database_count'] = 0;
132 132
 				
133 133
 			return $return;
134 134
 		}
135 135
 		
136
-		if(!isset($extra_params['startAtLine']))
136
+		if (!isset($extra_params['startAtLine']))
137 137
 			$extra_params['startAtLine'] = 0;
138
-		if(!isset($extra_params['startAtRecord']))
138
+		if (!isset($extra_params['startAtRecord']))
139 139
 			$extra_params['startAtRecord'] = 0;
140
-		if(!isset($extra_params['dumpfile']))
140
+		if (!isset($extra_params['dumpfile']))
141 141
 			$extra_params['dumpfile'] = "";
142 142
 		
143 143
 		$return = $this->process_incremental($extra_params['startAtLine'], $extra_params['startAtRecord'], $extra_params['dumpfile']);
@@ -148,13 +148,13 @@  discard block
 block discarded – undo
148 148
 	public function log($message = "")
149 149
 	{
150 150
 		
151
-		if($message){
152
-			$this->logger->info( $message, array(""));
153
-		}else{	
154
-			if($this->last_query)
155
-				$this->logger->debug( $this->last_query, array(""));
156
-			if($this->last_error)
157
-				$this->logger->error( $this->last_error, array(""));
151
+		if ($message) {
152
+			$this->logger->info($message, array(""));
153
+		} else {	
154
+			if ($this->last_query)
155
+				$this->logger->debug($this->last_query, array(""));
156
+			if ($this->last_error)
157
+				$this->logger->error($this->last_error, array(""));
158 158
 		}
159 159
 		
160 160
 		return;
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	*/
170 170
 	public function error($message)
171 171
 	{
172
-		$this->logger->error( $message, array(""));
172
+		$this->logger->error($message, array(""));
173 173
 		
174 174
 		return;
175 175
 	}
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 		
203 203
 		$query = "show tables in `".$database."`";
204 204
 		
205
-		$res =  $this->get_results($query);
205
+		$res = $this->get_results($query);
206 206
 		$this->log();
207 207
 			
208 208
 		return count($res);
@@ -225,9 +225,9 @@  discard block
 block discarded – undo
225 225
 		$databases_list[$i]['num_tables'] = $this->get_database_num_tables($this->dbname);
226 226
 		$i++;
227 227
 		
228
-		if(is_array($databases))
229
-		foreach( $databases as $db){
230
-			if($db->Database != $this->dbname)
228
+		if (is_array($databases))
229
+		foreach ($databases as $db) {
230
+			if ($db->Database != $this->dbname)
231 231
 			{
232 232
 				$databases_list[$i]['name'] = $db->Database;
233 233
 				$databases_list[$i]['num_tables'] = $this->get_database_num_tables($db->Database);
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 		$tablesList[0] = array( );
253 253
 		$inc = 0;
254 254
 
255
-		if(!$database)
255
+		if (!$database)
256 256
 			$database = $this->dbname;
257 257
 		
258 258
 		$this->logger->debug(sprintf(("Listing tables in %s database"), $database));
@@ -260,14 +260,14 @@  discard block
 block discarded – undo
260 260
 		$tables = $this->get_results("SHOW TABLES in `".$database."`");
261 261
 		$this->log();
262 262
 
263
-		foreach ($tables as $table){
263
+		foreach ($tables as $table) {
264 264
 			
265 265
 			$table = array_values((array)$table)[0];
266 266
 			
267 267
 			$tablesList[$inc]['name'] = $table;
268 268
 			$tablesList[$inc]['database'] = $database;
269 269
 
270
-			if($get_num_records)
270
+			if ($get_num_records)
271 271
 			{
272 272
 				$records_num_result = $this->get_var("SELECT count(*) FROM `".$database."`.`".$table."`");
273 273
 				$this->log();
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 			
278 278
 			$tablesList[$inc]['excluded'] = 0;
279 279
 						
280
-			if(sizeof($included) and is_array($included))
281
-				if(!in_array($table, $included) )
280
+			if (sizeof($included) and is_array($included))
281
+				if (!in_array($table, $included))
282 282
 				{
283 283
 					$tablesList[$inc]['excluded'] = 1;
284 284
 					$this->log(sprintf(__("Excluding table %s.%s from backup"), $table, $database));
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 		
300 300
 		$tables = $this->list_tables($dbname, $incl_tables, 1);
301 301
 		
302
-		if($this->dbname != $dbname)
302
+		if ($this->dbname != $dbname)
303 303
 			$dumpfile = $dbname."-backup.sql";
304 304
 		else
305 305
 			$dumpfile = $this->TEMP_DUMP_FILE;
@@ -308,8 +308,8 @@  discard block
 block discarded – undo
308 308
 		$this->fs->get_tmp_filesystem_append()->write($this->TEMP_DBPROCESS_FILE, $line);
309 309
 			
310 310
 		// write this to the class and write to $TEMP_DBPROCESS_FILE file as database.table records
311
-		foreach($tables as $key=>$table) 
312
-		if($table!= "" and !$tables[$key]['excluded']){
311
+		foreach ($tables as $key=>$table) 
312
+		if ($table != "" and !$tables[$key]['excluded']) {
313 313
 
314 314
 			$line = sprintf("`%s`.`%s`\t%s\t%s\n", $dbname, $tables[$key]['name'], $tables[$key]['records'], $tables[$key]['excluded']);
315 315
 			$this->fs->get_tmp_filesystem_append()->write($this->TEMP_DBPROCESS_FILE, $line);
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 
338 338
 			$result = $this->get_var("SELECT count(*) FROM $table;");
339 339
 
340
-			return intval($result) ;// not max limit on 32 bit systems 2147483647; on 64 bit 999999999999
340
+			return intval($result); // not max limit on 32 bit systems 2147483647; on 64 bit 999999999999
341 341
 
342 342
 	}
343 343
 
@@ -353,25 +353,25 @@  discard block
 block discarded – undo
353 353
 	 * 		int $dbDropSyntax	- check if the DROP TABLE syntax should be added
354 354
 	 * @return array $return
355 355
 	 */
356
-	public function process_incremental($startAtLine= 0, $startAtRecord = 0, $dumpfile = "", $dbCompatibility= ""){
356
+	public function process_incremental($startAtLine = 0, $startAtRecord = 0, $dumpfile = "", $dbCompatibility = "") {
357 357
 
358 358
 		$count = 0;
359 359
 		$return['finished'] = 0;
360 360
 		$lines = array();
361 361
 		
362
-		if($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE))
363
-			$lines = array_filter(explode("\n",$this->fs->get_tmp_filesystem()->read($this->TEMP_DBPROCESS_FILE)));
362
+		if ($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE))
363
+			$lines = array_filter(explode("\n", $this->fs->get_tmp_filesystem()->read($this->TEMP_DBPROCESS_FILE)));
364 364
 	
365
-		foreach ($lines as $buffer){
365
+		foreach ($lines as $buffer) {
366 366
 			
367
-			if($count == $startAtLine)
367
+			if ($count == $startAtLine)
368 368
 			{
369 369
 	
370
-				$tableInfo =explode("\t", $buffer);
370
+				$tableInfo = explode("\t", $buffer);
371 371
 				
372
-				if($tableInfo[0] == "###newdump###"){
372
+				if ($tableInfo[0] == "###newdump###") {
373 373
 						// we create a new mysql dump file
374
-						if($dumpfile != ""){
374
+						if ($dumpfile != "") {
375 375
 								// we finished a previous one and write the footers
376 376
 								$return['dumpsize'] = $this->data_footers($dumpfile);
377 377
 						}
@@ -385,13 +385,13 @@  discard block
 block discarded – undo
385 385
 						$startAtLine++;
386 386
 						$return['new_dump'] = 1;
387 387
 						//break;
388
-				}else{
388
+				} else {
389 389
 						//we export the table
390
-						if($tableInfo[0] == "###enddump###")
390
+						if ($tableInfo[0] == "###enddump###")
391 391
 							$return['endDump'] = 1;
392 392
 	
393 393
 						//table is excluded
394
-						if($tableInfo[2])
394
+						if ($tableInfo[2])
395 395
 							continue;
396 396
 							
397 397
 						$next = $startAtRecord + $this->recordsPerSession;
@@ -403,28 +403,28 @@  discard block
 block discarded – undo
403 403
 
404 404
 						//return something to the browser
405 405
 						$return['databaseName'] 	= $databaseName;
406
-						$return['tableName'] 		= $tableName;
406
+						$return['tableName'] = $tableName;
407 407
 						$return['totalRecords'] 	= $tableInfo[1];
408 408
 
409 409
 						$processed_records = 0;
410 410
 						
411
-						if(trim($tableName) !=""  and !$tableInfo[2])
411
+						if (trim($tableName) != "" and !$tableInfo[2])
412 412
 							$processed_records = $this->export_table($databaseName, $tableName, $startAtRecord, $this->recordsPerSession, $dumpfile);
413 413
 						
414
-						$return['processedRecords'] = $startAtRecord+$processed_records;
414
+						$return['processedRecords'] = $startAtRecord + $processed_records;
415 415
 						
416
-						if($next >= $tableInfo[1]) //we finished loading the records for next sessions, will go to the new record
416
+						if ($next >= $tableInfo[1]) //we finished loading the records for next sessions, will go to the new record
417 417
 						{
418
-								$startAtLine ++;
418
+								$startAtLine++;
419 419
 								$startAtRecord = 0;
420
-						}else{
420
+						} else {
421 421
 								$startAtRecord = $startAtRecord + $this->recordsPerSession;
422 422
 							}
423 423
 
424 424
 						//$return['dbCompatibility'] 	= self::$dbCompatibility;
425 425
 						
426
-						$return['startAtLine']		= $startAtLine;
427
-						$return['startAtRecord']	= $startAtRecord;
426
+						$return['startAtLine'] = $startAtLine;
427
+						$return['startAtRecord'] = $startAtRecord;
428 428
 						$return['dumpfile']			= $dumpfile;
429 429
 						$return['dumpsize']			= $this->fs->get_tmp_filesystem_append()->getSize($dumpfile);
430 430
 
@@ -442,15 +442,15 @@  discard block
 block discarded – undo
442 442
 		}
443 443
 	
444 444
 		//while is finished, lets go home...
445
-		if($dumpfile != ""){
445
+		if ($dumpfile != "") {
446 446
 			// we finished a previous one and write the footers
447 447
 			$return['dumpsize'] = $this->data_footers($dumpfile);
448 448
 			$return['dumpfile'] = ($dumpfile);
449 449
 		}
450 450
 		$return['finished'] = 1;
451
-		$return['startAtLine']	= $startAtLine;
451
+		$return['startAtLine'] = $startAtLine;
452 452
 		
453
-		if($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE))
453
+		if ($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE))
454 454
 			$this->fs->get_tmp_filesystem()->delete($this->TEMP_DBPROCESS_FILE);
455 455
 		
456 456
 		$this->logger->debug(sprintf(("Database backup finished!")));
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 		
480 480
 		$records = 0;
481 481
 		
482
-		if($start == 0)
482
+		if ($start == 0)
483 483
 			$this->dump_structure($databaseName, $tableName, $dumpfile);
484 484
 
485 485
 		$start = intval($start);
@@ -487,20 +487,20 @@  discard block
 block discarded – undo
487 487
 		//exporting the table content now
488 488
 
489 489
 		$query = "SELECT * from `$databaseName`.`$tableName` Limit $start, $limit ;";
490
-		if($this->use_mysqli)
490
+		if ($this->use_mysqli)
491 491
 		{
492 492
 			$result = mysqli_query($this->dbh, $query);
493 493
 			$mysql_fetch_function = "mysqli_fetch_array";
494 494
 		
495
-		}else{
495
+		} else {
496 496
 			$result = mysql_query($query, $this->dbh);
497 497
 			$mysql_fetch_function = "mysql_fetch_array";
498 498
 		}
499 499
 		//$result = $this->get_results($query, ARRAY_N);
500 500
 		//print_r($result); exit;
501 501
 		
502
-		if($result){
503
-			while($row = $mysql_fetch_function($result, MYSQLI_ASSOC)){
502
+		if ($result) {
503
+			while ($row = $mysql_fetch_function($result, MYSQLI_ASSOC)) {
504 504
 					
505 505
 					$this->fs->get_tmp_filesystem_append()->write($dumpfile, "INSERT INTO `$tableName` VALUES (");
506 506
 					$arr = $row;
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 						$value = $this->_real_escape($value);
512 512
 						$buffer .= "'".$value."', ";
513 513
 					}
514
-					$buffer = rtrim($buffer, ', ') . ");\n";
514
+					$buffer = rtrim($buffer, ', ').");\n";
515 515
 					$this->fs->get_tmp_filesystem_append()->write($dumpfile, $buffer);
516 516
 					unset($buffer);
517 517
 					
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 
527 527
 	}
528 528
 
529
-	public function dump_structure($databaseName, $tableName ,$dumpfile)
529
+	public function dump_structure($databaseName, $tableName, $dumpfile)
530 530
 	{
531 531
 		$this->log(sprintf(__("Dumping the structure for %s.%s table"), $databaseName, $tableName));
532 532
 		
@@ -541,14 +541,14 @@  discard block
 block discarded – undo
541 541
 
542 542
 		//$result = mysqli_query($this->dbh,"SHOW CREATE table `$databaseName`.`$tableName`;");
543 543
 		$result = $this->get_row("SHOW CREATE table `$databaseName`.`$tableName`;", ARRAY_N);
544
-		if($result){
544
+		if ($result) {
545 545
 			//$row = mysqli_fetch_row( $result);
546 546
 			$line = ($result[1].";\n");
547 547
 			$this->fs->get_tmp_filesystem_append()->write($dumpfile, $line);
548 548
 		}
549 549
 
550
-		$line = ( "\n#\n# End Structure for table `$tableName`\n#\n\n");
551
-		$line .=("#\n# Dumping data for table `$tableName`\n#\n\n");
550
+		$line = ("\n#\n# End Structure for table `$tableName`\n#\n\n");
551
+		$line .= ("#\n# Dumping data for table `$tableName`\n#\n\n");
552 552
 		$this->fs->get_tmp_filesystem_append()->write($dumpfile, $line);
553 553
 		
554 554
 		return;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 
572 572
 	}
573 573
 
574
-	public function resetcountRecords(){
574
+	public function resetcountRecords() {
575 575
 		
576 576
 		$this->countRecords = 0;
577 577
 
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 	
580 580
 	}
581 581
 
582
-	public function getcountRecords(){
582
+	public function getcountRecords() {
583 583
 		
584 584
 		return $this->countRecords;
585 585
 		
@@ -596,14 +596,14 @@  discard block
 block discarded – undo
596 596
 		$return .= "# Powered by XCloner Site Backup\n";
597 597
 		$return .= "# http://www.xcloner.com\n";
598 598
 		$return .= "#\n";
599
-		$return .= "# Host: " . get_site_url() . "\n";
600
-		$return .= "# Generation Time: " . date("M j, Y \a\\t H:i") . "\n";
601
-		$return .= "# PHP Version: " . phpversion() . "\n";
602
-		$return .= "# Database Charset: ". $this->charset . "\n";
599
+		$return .= "# Host: ".get_site_url()."\n";
600
+		$return .= "# Generation Time: ".date("M j, Y \a\\t H:i")."\n";
601
+		$return .= "# PHP Version: ".phpversion()."\n";
602
+		$return .= "# Database Charset: ".$this->charset."\n";
603 603
 		
604 604
 		$results = $this->get_results("SHOW VARIABLES LIKE \"%version%\";", ARRAY_N);
605
-		if(isset($results)){
606
-			foreach($results as $result){
605
+		if (isset($results)) {
606
+			foreach ($results as $result) {
607 607
 
608 608
 					$return .= "# MYSQL ".$result[0].": ".$result[1]."\n";
609 609
 
@@ -613,13 +613,13 @@  discard block
 block discarded – undo
613 613
 		$results = $this->get_results("SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME
614 614
 					FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '".$database."';");
615 615
 		
616
-		if(isset($results[0])){
616
+		if (isset($results[0])) {
617 617
 
618 618
 			$return .= "# MYSQL DEFAULT_CHARACTER_SET_NAME: ".$results[0]->DEFAULT_CHARACTER_SET_NAME."\n";
619 619
 			$return .= "# MYSQL SCHEMA_NAME: ".$results[0]->DEFAULT_COLLATION_NAME."\n";
620 620
 		}
621 621
 
622
-		$return .= "#\n# Database : `" . $database . "`\n# --------------------------------------------------------\n\n";
622
+		$return .= "#\n# Database : `".$database."`\n# --------------------------------------------------------\n\n";
623 623
 		
624 624
 		$this->log(sprintf(__("Writing %s database dump headers"), $database));
625 625
 		
Please login to merge, or discard this patch.
Braces   +75 added lines, -52 removed lines patch added patch discarded remove patch
@@ -44,11 +44,13 @@  discard block
 block discarded – undo
44 44
 		$this->xcloner_settings 		= $xcloner_container->get_xcloner_settings();
45 45
 		$this->fs 						= $xcloner_container->get_xcloner_filesystem();
46 46
 		
47
-		if($this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request'))
48
-			$this->recordsPerSession		= $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request');
47
+		if($this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request')) {
48
+					$this->recordsPerSession		= $this->xcloner_settings->get_xcloner_option('xcloner_database_records_per_request');
49
+		}
49 50
 		
50
-		if(!$this->recordsPerSession)
51
-			$this->recordsPerSession = 100;
51
+		if(!$this->recordsPerSession) {
52
+					$this->recordsPerSession = 100;
53
+		}
52 54
 		
53 55
 		if(!$wp_user && !$wp_pass && !$wp_host && !$wp_db )
54 56
 		{
@@ -108,37 +110,43 @@  discard block
 block discarded – undo
108 110
 			{
109 111
 				foreach($params['#'] as $database)
110 112
 				{
111
-					if(!isset($params[$database]) or !is_array($params[$database]))
112
-						$params[$database] = array();
113
+					if(!isset($params[$database]) or !is_array($params[$database])) {
114
+											$params[$database] = array();
115
+					}
113 116
 				}
114 117
 				$db_count = -1;
115 118
 			}
116 119
 			
117
-			if(isset($params) and is_array($params))
118
-				foreach($params as $database=>$tables)
120
+			if(isset($params) and is_array($params)) {
121
+							foreach($params as $database=>$tables)
119 122
 				{	
120 123
 					if($database != "#")
121 124
 					{
122
-						$stats = $this->write_backup_process_list($database, $tables);	
125
+						$stats = $this->write_backup_process_list($database, $tables);
126
+			}
123 127
 						$return['stats']['tables_count'] 	+= $stats['tables_count'];
124 128
 						$return['stats']['total_records'] 	+= $stats['total_records'];
125 129
 					}
126 130
 				}
127 131
 
128
-			if(sizeof($params))
129
-				$return['stats']['database_count'] = sizeof($params)+$db_count;
130
-			else	
131
-				$return['stats']['database_count'] = 0;
132
+			if(sizeof($params)) {
133
+							$return['stats']['database_count'] = sizeof($params)+$db_count;
134
+			} else {
135
+							$return['stats']['database_count'] = 0;
136
+			}
132 137
 				
133 138
 			return $return;
134 139
 		}
135 140
 		
136
-		if(!isset($extra_params['startAtLine']))
137
-			$extra_params['startAtLine'] = 0;
138
-		if(!isset($extra_params['startAtRecord']))
139
-			$extra_params['startAtRecord'] = 0;
140
-		if(!isset($extra_params['dumpfile']))
141
-			$extra_params['dumpfile'] = "";
141
+		if(!isset($extra_params['startAtLine'])) {
142
+					$extra_params['startAtLine'] = 0;
143
+		}
144
+		if(!isset($extra_params['startAtRecord'])) {
145
+					$extra_params['startAtRecord'] = 0;
146
+		}
147
+		if(!isset($extra_params['dumpfile'])) {
148
+					$extra_params['dumpfile'] = "";
149
+		}
142 150
 		
143 151
 		$return = $this->process_incremental($extra_params['startAtLine'], $extra_params['startAtRecord'], $extra_params['dumpfile']);
144 152
 		
@@ -150,11 +158,13 @@  discard block
 block discarded – undo
150 158
 		
151 159
 		if($message){
152 160
 			$this->logger->info( $message, array(""));
153
-		}else{	
154
-			if($this->last_query)
155
-				$this->logger->debug( $this->last_query, array(""));
156
-			if($this->last_error)
157
-				$this->logger->error( $this->last_error, array(""));
161
+		} else{	
162
+			if($this->last_query) {
163
+							$this->logger->debug( $this->last_query, array(""));
164
+			}
165
+			if($this->last_error) {
166
+							$this->logger->error( $this->last_error, array(""));
167
+			}
158 168
 		}
159 169
 		
160 170
 		return;
@@ -225,11 +235,12 @@  discard block
 block discarded – undo
225 235
 		$databases_list[$i]['num_tables'] = $this->get_database_num_tables($this->dbname);
226 236
 		$i++;
227 237
 		
228
-		if(is_array($databases))
229
-		foreach( $databases as $db){
238
+		if(is_array($databases)) {
239
+				foreach( $databases as $db){
230 240
 			if($db->Database != $this->dbname)
231 241
 			{
232 242
 				$databases_list[$i]['name'] = $db->Database;
243
+		}
233 244
 				$databases_list[$i]['num_tables'] = $this->get_database_num_tables($db->Database);
234 245
 				$i++;
235 246
 			}
@@ -252,8 +263,9 @@  discard block
 block discarded – undo
252 263
 		$tablesList[0] = array( );
253 264
 		$inc = 0;
254 265
 
255
-		if(!$database)
256
-			$database = $this->dbname;
266
+		if(!$database) {
267
+					$database = $this->dbname;
268
+		}
257 269
 		
258 270
 		$this->logger->debug(sprintf(("Listing tables in %s database"), $database));
259 271
 		
@@ -277,10 +289,11 @@  discard block
 block discarded – undo
277 289
 			
278 290
 			$tablesList[$inc]['excluded'] = 0;
279 291
 						
280
-			if(sizeof($included) and is_array($included))
281
-				if(!in_array($table, $included) )
292
+			if(sizeof($included) and is_array($included)) {
293
+							if(!in_array($table, $included) )
282 294
 				{
283 295
 					$tablesList[$inc]['excluded'] = 1;
296
+			}
284 297
 					$this->log(sprintf(__("Excluding table %s.%s from backup"), $table, $database));
285 298
 				}
286 299
 			$inc++;
@@ -299,19 +312,21 @@  discard block
 block discarded – undo
299 312
 		
300 313
 		$tables = $this->list_tables($dbname, $incl_tables, 1);
301 314
 		
302
-		if($this->dbname != $dbname)
303
-			$dumpfile = $dbname."-backup.sql";
304
-		else
305
-			$dumpfile = $this->TEMP_DUMP_FILE;
315
+		if($this->dbname != $dbname) {
316
+					$dumpfile = $dbname."-backup.sql";
317
+		} else {
318
+					$dumpfile = $this->TEMP_DUMP_FILE;
319
+		}
306 320
 		
307 321
 		$line = sprintf("###newdump###\t%s\t%s\n", $dbname, $dumpfile);
308 322
 		$this->fs->get_tmp_filesystem_append()->write($this->TEMP_DBPROCESS_FILE, $line);
309 323
 			
310 324
 		// write this to the class and write to $TEMP_DBPROCESS_FILE file as database.table records
311
-		foreach($tables as $key=>$table) 
312
-		if($table!= "" and !$tables[$key]['excluded']){
325
+		foreach($tables as $key=>$table) {
326
+				if($table!= "" and !$tables[$key]['excluded']){
313 327
 
314 328
 			$line = sprintf("`%s`.`%s`\t%s\t%s\n", $dbname, $tables[$key]['name'], $tables[$key]['records'], $tables[$key]['excluded']);
329
+		}
315 330
 			$this->fs->get_tmp_filesystem_append()->write($this->TEMP_DBPROCESS_FILE, $line);
316 331
 			$return['tables_count']++;
317 332
 			$return['total_records'] += $tables[$key]['records'];
@@ -359,8 +374,9 @@  discard block
 block discarded – undo
359 374
 		$return['finished'] = 0;
360 375
 		$lines = array();
361 376
 		
362
-		if($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE))
363
-			$lines = array_filter(explode("\n",$this->fs->get_tmp_filesystem()->read($this->TEMP_DBPROCESS_FILE)));
377
+		if($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) {
378
+					$lines = array_filter(explode("\n",$this->fs->get_tmp_filesystem()->read($this->TEMP_DBPROCESS_FILE)));
379
+		}
364 380
 	
365 381
 		foreach ($lines as $buffer){
366 382
 			
@@ -385,14 +401,16 @@  discard block
 block discarded – undo
385 401
 						$startAtLine++;
386 402
 						$return['new_dump'] = 1;
387 403
 						//break;
388
-				}else{
404
+				} else{
389 405
 						//we export the table
390
-						if($tableInfo[0] == "###enddump###")
391
-							$return['endDump'] = 1;
406
+						if($tableInfo[0] == "###enddump###") {
407
+													$return['endDump'] = 1;
408
+						}
392 409
 	
393 410
 						//table is excluded
394
-						if($tableInfo[2])
395
-							continue;
411
+						if($tableInfo[2]) {
412
+													continue;
413
+						}
396 414
 							
397 415
 						$next = $startAtRecord + $this->recordsPerSession;
398 416
 						
@@ -408,16 +426,19 @@  discard block
 block discarded – undo
408 426
 
409 427
 						$processed_records = 0;
410 428
 						
411
-						if(trim($tableName) !=""  and !$tableInfo[2])
412
-							$processed_records = $this->export_table($databaseName, $tableName, $startAtRecord, $this->recordsPerSession, $dumpfile);
429
+						if(trim($tableName) !=""  and !$tableInfo[2]) {
430
+													$processed_records = $this->export_table($databaseName, $tableName, $startAtRecord, $this->recordsPerSession, $dumpfile);
431
+						}
413 432
 						
414 433
 						$return['processedRecords'] = $startAtRecord+$processed_records;
415 434
 						
416
-						if($next >= $tableInfo[1]) //we finished loading the records for next sessions, will go to the new record
435
+						if($next >= $tableInfo[1]) {
436
+							//we finished loading the records for next sessions, will go to the new record
417 437
 						{
418 438
 								$startAtLine ++;
439
+						}
419 440
 								$startAtRecord = 0;
420
-						}else{
441
+						} else{
421 442
 								$startAtRecord = $startAtRecord + $this->recordsPerSession;
422 443
 							}
423 444
 
@@ -450,8 +471,9 @@  discard block
 block discarded – undo
450 471
 		$return['finished'] = 1;
451 472
 		$return['startAtLine']	= $startAtLine;
452 473
 		
453
-		if($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE))
454
-			$this->fs->get_tmp_filesystem()->delete($this->TEMP_DBPROCESS_FILE);
474
+		if($this->fs->get_tmp_filesystem()->has($this->TEMP_DBPROCESS_FILE)) {
475
+					$this->fs->get_tmp_filesystem()->delete($this->TEMP_DBPROCESS_FILE);
476
+		}
455 477
 		
456 478
 		$this->logger->debug(sprintf(("Database backup finished!")));
457 479
 		
@@ -479,8 +501,9 @@  discard block
 block discarded – undo
479 501
 		
480 502
 		$records = 0;
481 503
 		
482
-		if($start == 0)
483
-			$this->dump_structure($databaseName, $tableName, $dumpfile);
504
+		if($start == 0) {
505
+					$this->dump_structure($databaseName, $tableName, $dumpfile);
506
+		}
484 507
 
485 508
 		$start = intval($start);
486 509
 		$limit = intval($limit);
@@ -492,7 +515,7 @@  discard block
 block discarded – undo
492 515
 			$result = mysqli_query($this->dbh, $query);
493 516
 			$mysql_fetch_function = "mysqli_fetch_array";
494 517
 		
495
-		}else{
518
+		} else{
496 519
 			$result = mysql_query($query, $this->dbh);
497 520
 			$mysql_fetch_function = "mysql_fetch_array";
498 521
 		}
Please login to merge, or discard this patch.
includes/class-xcloner-file-system.php 3 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -299,12 +299,12 @@  discard block
 block discarded – undo
299 299
 	}
300 300
 	
301 301
 	public function getMetadataFull($adapter = "storage_adapter" , $path)
302
-    {
303
-        $location = $this->$adapter->applyPathPrefix($path);
304
-        $spl_info = new SplFileInfo($location);
302
+	{
303
+		$location = $this->$adapter->applyPathPrefix($path);
304
+		$spl_info = new SplFileInfo($location);
305 305
         
306
-        return ($spl_info);
307
-    }
306
+		return ($spl_info);
307
+	}
308 308
 	
309 309
 	
310 310
 	public function get_backup_archives_list($storage_selection = "")
@@ -697,27 +697,27 @@  discard block
 block discarded – undo
697 697
 	
698 698
 	private function array_orderby()
699 699
 	{
700
-	    $args = func_get_args();
701
-	    $data = array_shift($args);
700
+		$args = func_get_args();
701
+		$data = array_shift($args);
702 702
 	    
703
-	    foreach ($args as $n => $field) {
704
-	        if (is_string($field)) {
705
-	            $tmp = array();
706
-	            foreach ($data as $key => $row)
707
-	            {
703
+		foreach ($args as $n => $field) {
704
+			if (is_string($field)) {
705
+				$tmp = array();
706
+				foreach ($data as $key => $row)
707
+				{
708 708
 					if(is_array($row))
709 709
 						$tmp[$key] = $row[$field];
710 710
 					else
711 711
 						$tmp[$key] = $row->$field;
712 712
 				}
713
-	            $args[$n] = $tmp;
714
-	            }
715
-	    }
716
-	    $args[] = &$data;
713
+				$args[$n] = $tmp;
714
+				}
715
+		}
716
+		$args[] = &$data;
717 717
 	    
718
-	    call_user_func_array('array_multisort', $args);
718
+		call_user_func_array('array_multisort', $args);
719 719
 	    
720
-	    return array_pop($args);
720
+		return array_pop($args);
721 721
 	}
722 722
 	
723 723
 	private function check_file_diff_time($file)
Please login to merge, or discard this patch.
Spacing   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -4,18 +4,18 @@  discard block
 block discarded – undo
4 4
 use League\Flysystem\Util;
5 5
 use League\Flysystem\Adapter\Local;
6 6
 
7
-class Xcloner_File_System{
7
+class Xcloner_File_System {
8 8
 	
9
-	private $excluded_files 			= "";
10
-	private $excluded_files_by_default	= array("administrator/backups", "wp-content/backups");
11
-	private $included_files_handler 	= "backup_files.csv";
12
-	private $temp_dir_handler 			= ".dir";
9
+	private $excluded_files = "";
10
+	private $excluded_files_by_default = array("administrator/backups", "wp-content/backups");
11
+	private $included_files_handler = "backup_files.csv";
12
+	private $temp_dir_handler = ".dir";
13 13
 	public  $filesystem;
14 14
 	public  $tmp_filesystem;
15 15
 	public  $storage_filesystem;
16 16
 	private $xcloner_settings_append;
17 17
 	private $xcloner_container;
18
-	private $diff_timestamp_start		= "";
18
+	private $diff_timestamp_start = "";
19 19
 	
20 20
 	private $logger;
21 21
 	private $start_adapter;
@@ -38,47 +38,47 @@  discard block
 block discarded – undo
38 38
 	{
39 39
 		$this->xcloner_container = $xcloner_container;
40 40
 		
41
-		$this->logger 				= $xcloner_container->get_xcloner_logger()->withName("xcloner_file_system");
41
+		$this->logger = $xcloner_container->get_xcloner_logger()->withName("xcloner_file_system");
42 42
 		$this->xcloner_settings 	= $xcloner_container->get_xcloner_settings();
43 43
 
44
-		try{
44
+		try {
45 45
 			
46
-			$this->start_adapter = new Local($this->xcloner_settings->get_xcloner_start_path(),LOCK_EX, 'SKIP_LINKS');
46
+			$this->start_adapter = new Local($this->xcloner_settings->get_xcloner_start_path(), LOCK_EX, 'SKIP_LINKS');
47 47
 			$this->start_filesystem = new Filesystem($this->start_adapter, new Config([
48 48
 					'disable_asserts' => true,
49 49
 				]));
50 50
 			
51
-			$this->tmp_adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(),LOCK_EX, 'SKIP_LINKS');
51
+			$this->tmp_adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(), LOCK_EX, 'SKIP_LINKS');
52 52
 			$this->tmp_filesystem = new Filesystem($this->tmp_adapter, new Config([
53 53
 					'disable_asserts' => true,
54 54
 				]));
55
-			$adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(),LOCK_EX|FILE_APPEND, 'SKIP_LINKS');
55
+			$adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(), LOCK_EX | FILE_APPEND, 'SKIP_LINKS');
56 56
 			$this->tmp_filesystem_append = new Filesystem($adapter, new Config([
57 57
 					'disable_asserts' => true,
58 58
 				]));
59 59
 
60
-			$adapter = new Local($this->xcloner_settings->get_xcloner_store_path(),LOCK_EX, 'SKIP_LINKS');
60
+			$adapter = new Local($this->xcloner_settings->get_xcloner_store_path(), LOCK_EX, 'SKIP_LINKS');
61 61
 			$this->storage_filesystem = new Filesystem($adapter, new Config([
62 62
 					'disable_asserts' => true,
63 63
 				]));	
64 64
 			
65
-			$this->storage_adapter = new Local($this->xcloner_settings->get_xcloner_store_path(),FILE_APPEND, 'SKIP_LINKS');
65
+			$this->storage_adapter = new Local($this->xcloner_settings->get_xcloner_store_path(), FILE_APPEND, 'SKIP_LINKS');
66 66
 			$this->storage_filesystem_append = new Filesystem($this->storage_adapter, new Config([
67 67
 					'disable_asserts' => true,
68 68
 				]));
69
-		}catch(Exception $e){
69
+		}catch (Exception $e) {
70 70
 			$this->logger->error("Filesystem Initialization Error: ".$e->getMessage());
71 71
 		}
72 72
 		
73 73
 		
74
-		if($value = get_option('xcloner_directories_to_scan_per_request'))
74
+		if ($value = get_option('xcloner_directories_to_scan_per_request'))
75 75
 			$this->folders_to_process_per_session = $value;
76 76
 
77 77
 	}
78 78
 	
79 79
 	public function set_diff_timestamp_start($timestamp = "")
80 80
 	{
81
-		if($timestamp)
81
+		if ($timestamp)
82 82
 		{
83 83
 			$this->logger->info(sprintf("Setting Differential Timestamp To %s", date("Y-m-d", $timestamp)), array("FILESYSTEM", "DIFF"));
84 84
 			$this->diff_timestamp_start = $timestamp;
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
 	
114 114
 	public function get_storage_filesystem($remote_storage_selection = "")
115 115
 	{
116
-		if($remote_storage_selection != "")
116
+		if ($remote_storage_selection != "")
117 117
 		{
118 118
 			$remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage();
119 119
 			$method = "get_".$remote_storage_selection."_filesystem";
120 120
 			
121
-			if(!method_exists($remote_storage, $method))
121
+			if (!method_exists($remote_storage, $method))
122 122
 				return false;
123 123
 				
124 124
 			list($adapter, $filesystem) = $remote_storage->$method();	
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	
157 157
 	public function get_start_path_file_info($file)
158 158
 	{
159
-		$info= $this->getMetadataFull('start_adapter', $file);
159
+		$info = $this->getMetadataFull('start_adapter', $file);
160 160
 		return $this->start_filesystem->normalizeFileInfo($info);
161 161
 	}
162 162
 	
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
 		return $this->getMetadataFull('storage_adapter', $file);
166 166
 	}
167 167
 	
168
-	public function get_included_files_handler($metadata  = 0)
168
+	public function get_included_files_handler($metadata = 0)
169 169
 	{
170 170
 		$path = $this->included_files_handler;
171
-		if(!$metadata)
171
+		if (!$metadata)
172 172
 			return $path;
173 173
 		
174 174
 		$spl_info = $this->getMetadataFull('tmp_adapter', $path);
@@ -185,16 +185,16 @@  discard block
 block discarded – undo
185 185
 	{
186 186
 		$files = $this->get_backup_archives_list();
187 187
 		
188
-		if(is_array($files))
189
-			$this->sort_by($files, "timestamp","desc");
188
+		if (is_array($files))
189
+			$this->sort_by($files, "timestamp", "desc");
190 190
 		
191 191
 		$new_list = array();
192 192
 		
193
-		foreach($files as $key=>$file)
194
-			if(!isset($file['parent']))
193
+		foreach ($files as $key=>$file)
194
+			if (!isset($file['parent']))
195 195
 				$new_list[] = ($files[$key]);
196 196
 
197
-		if(isset($new_list[0]))
197
+		if (isset($new_list[0]))
198 198
 			return $new_list[0];
199 199
 	}
200 200
 	
@@ -202,13 +202,13 @@  discard block
 block discarded – undo
202 202
 	{
203 203
 		$files = $this->get_backup_archives_list();
204 204
 
205
-		if(is_array($files))
206
-			$this->sort_by($files, "timestamp","desc");
205
+		if (is_array($files))
206
+			$this->sort_by($files, "timestamp", "desc");
207 207
 		
208 208
 		$new_list = array();
209 209
 		
210
-		foreach($files as $key=>$file)
211
-			if(!isset($file['parent']))
210
+		foreach ($files as $key=>$file)
211
+			if (!isset($file['parent']))
212 212
 				$new_list[] = ($files[$key]);
213 213
 
214 214
 		return $new_list;
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
 		$files = $this->get_backup_archives_list();
220 220
 		$total = 0;
221 221
 		
222
-		if(is_array($files))
223
-			foreach($files as $file)
222
+		if (is_array($files))
223
+			foreach ($files as $file)
224 224
 				$total += $file['size'];
225 225
 				
226 226
 		return $total;		
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 	
229 229
 	public function is_part($backup_name)
230 230
 	{
231
-		if(stristr($backup_name, "-part"))
231
+		if (stristr($backup_name, "-part"))
232 232
 			return true;
233 233
 		
234 234
 		return false;	
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	
237 237
 	public function is_multipart($backup_name)
238 238
 	{
239
-		if(stristr($backup_name, "-multipart"))
239
+		if (stristr($backup_name, "-multipart"))
240 240
 			return true;
241 241
 		
242 242
 		return false;	
@@ -245,10 +245,10 @@  discard block
 block discarded – undo
245 245
 	public function get_backup_size($backup_name)
246 246
 	{
247 247
 		$backup_size = $this->get_storage_filesystem()->getSize($backup_name);
248
-		if($this->is_multipart($backup_name))
248
+		if ($this->is_multipart($backup_name))
249 249
 		{
250 250
 			$backup_parts = $this->get_multipart_files($backup_name);
251
-			foreach($backup_parts as $part_file)
251
+			foreach ($backup_parts as $part_file)
252 252
 				$backup_size += $this->get_storage_filesystem()->getSize($part_file);
253 253
 		}
254 254
 		
@@ -259,12 +259,12 @@  discard block
 block discarded – undo
259 259
 	{
260 260
 		$files = array();
261 261
 		
262
-		if($this->is_multipart($backup_name))
262
+		if ($this->is_multipart($backup_name))
263 263
 		{
264 264
 			$lines = explode(PHP_EOL, $this->get_storage_filesystem($storage_selection)->read($backup_name));
265
-			foreach($lines as $line)
265
+			foreach ($lines as $line)
266 266
 			{
267
-				if($line)
267
+				if ($line)
268 268
 				{
269 269
 					$data = str_getcsv($line);
270 270
 					$files[] = $data[0];
@@ -277,12 +277,12 @@  discard block
 block discarded – undo
277 277
 	
278 278
 	public function delete_backup_by_name($backup_name, $storage_selection = "")
279 279
 	{
280
-		if($this->is_multipart($backup_name))
280
+		if ($this->is_multipart($backup_name))
281 281
 		{
282 282
 			$lines = explode(PHP_EOL, $this->get_storage_filesystem($storage_selection)->read($backup_name));
283
-			foreach($lines as $line)
283
+			foreach ($lines as $line)
284 284
 			{
285
-				if($line)
285
+				if ($line)
286 286
 				{
287 287
 					$data = str_getcsv($line);
288 288
 					$this->get_storage_filesystem($storage_selection)->delete($data[0]);
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 			}
291 291
 		}
292 292
 		
293
-		if($this->get_storage_filesystem($storage_selection)->delete($backup_name))
293
+		if ($this->get_storage_filesystem($storage_selection)->delete($backup_name))
294 294
 			$return = true;
295 295
 		else
296 296
 			$return = false;
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 		return $return;	
299 299
 	}
300 300
 	
301
-	public function getMetadataFull($adapter = "storage_adapter" , $path)
301
+	public function getMetadataFull($adapter = "storage_adapter", $path)
302 302
     {
303 303
         $location = $this->$adapter->applyPathPrefix($path);
304 304
         $spl_info = new SplFileInfo($location);
@@ -312,25 +312,25 @@  discard block
 block discarded – undo
312 312
 		$list = array();
313 313
 		
314 314
 
315
-		if(method_exists($this->get_storage_filesystem($storage_selection), "listContents"))
315
+		if (method_exists($this->get_storage_filesystem($storage_selection), "listContents"))
316 316
 			$list = $this->get_storage_filesystem($storage_selection)->listContents();
317 317
 
318 318
 		
319 319
 		$backup_files = array();
320 320
 		$parents = array();
321 321
 		
322
-		foreach($list as $file_info)
322
+		foreach ($list as $file_info)
323 323
 		{
324
-			if(isset($file_info['extension']) and $file_info['extension'] == "csv")
324
+			if (isset($file_info['extension']) and $file_info['extension'] == "csv")
325 325
 			{
326 326
 				$data = array();
327 327
 				
328 328
 				$lines = explode(PHP_EOL, $this->get_storage_filesystem($storage_selection)->read($file_info['path']));
329
-				foreach($lines as $line)
330
-					if($line)
329
+				foreach ($lines as $line)
330
+					if ($line)
331 331
 					{
332 332
 						$data = str_getcsv($line);
333
-						if(is_array($data)){
333
+						if (is_array($data)) {
334 334
 							$parents[$data[0]] = $file_info['basename'];
335 335
 							$file_info['childs'][] = $data;
336 336
 							$file_info['size'] += $data[2];
@@ -339,18 +339,18 @@  discard block
 block discarded – undo
339 339
 						
340 340
 			}
341 341
 			
342
-			if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions))
342
+			if ($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions))
343 343
 				$backup_files[$file_info['path']] = $file_info;
344 344
 		}
345 345
 		
346
-		foreach($backup_files as $key=>$file_info)
346
+		foreach ($backup_files as $key=>$file_info)
347 347
 		{
348
-			if(!isset($backup_files[$key]['timestamp']))
348
+			if (!isset($backup_files[$key]['timestamp']))
349 349
 			{
350 350
 				//$backup_files[$key]['timestamp'] = $this->get_storage_filesystem($storage_selection)->getTimestamp($file_info['path']);
351 351
 			}
352 352
 			
353
-			if(isset($parents[$file_info['basename']]))
353
+			if (isset($parents[$file_info['basename']]))
354 354
 				$backup_files[$key]['parent'] = $parents[$file_info['basename']];
355 355
 		}
356 356
 		
@@ -359,40 +359,40 @@  discard block
 block discarded – undo
359 359
 	
360 360
 	public function start_file_recursion($init = 0)
361 361
 	{
362
-		if($init)
362
+		if ($init)
363 363
 		{
364 364
 			$this->logger->info(sprintf(__("Starting the filesystem scanner on root folder %s"), $this->xcloner_settings->get_xcloner_start_path()));
365 365
 			$this->do_system_init();
366 366
 		}
367 367
 		
368
-		if($this->tmp_filesystem->has($this->get_temp_dir_handler())){
368
+		if ($this->tmp_filesystem->has($this->get_temp_dir_handler())) {
369 369
 		//.dir exists, we presume we have files to iterate	
370 370
 			$content = $this->tmp_filesystem->read($this->get_temp_dir_handler());
371 371
 			$files = array_filter(explode("\n", $content));
372 372
 			$this->tmp_filesystem->delete($this->get_temp_dir_handler());
373 373
 			
374 374
 			$counter = 0;
375
-			foreach($files as $file)
375
+			foreach ($files as $file)
376 376
 			{
377
-				if($counter < $this->folders_to_process_per_session){
377
+				if ($counter < $this->folders_to_process_per_session) {
378 378
 					$this->build_files_list($file);
379 379
 					$counter++;
380
-				}else{
380
+				} else {
381 381
 					$this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file."\n");
382 382
 				}
383 383
 			}
384
-		}else{
384
+		} else {
385 385
 			$this->build_files_list();
386 386
 		}
387 387
 		
388
-		if($this->scan_finished())
388
+		if ($this->scan_finished())
389 389
 		{
390 390
 			$metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata("index.html");
391 391
 			$this->store_file($metadata_dumpfile, 'tmp_filesystem');
392 392
 			$this->files_counter++;
393 393
 		
394 394
 			//adding included dump file to the included files list
395
-			if($this->get_tmp_filesystem()->has($this->get_included_files_handler()))
395
+			if ($this->get_tmp_filesystem()->has($this->get_included_files_handler()))
396 396
 			{
397 397
 				$metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata($this->get_included_files_handler());
398 398
 				$this->store_file($metadata_dumpfile, 'tmp_filesystem');
@@ -400,13 +400,13 @@  discard block
 block discarded – undo
400 400
 			}
401 401
 		
402 402
 			//adding a default index.html to the temp xcloner folder
403
-			if(!$this->get_tmp_filesystem()->has("index.html"))
403
+			if (!$this->get_tmp_filesystem()->has("index.html"))
404 404
 			{
405
-				$this->get_tmp_filesystem()->write("index.html","");
405
+				$this->get_tmp_filesystem()->write("index.html", "");
406 406
 			}
407 407
 			
408 408
 			//adding the default log file
409
-			if($this->get_tmp_filesystem()->has($this->xcloner_settings->get_logger_filename(1)))
409
+			if ($this->get_tmp_filesystem()->has($this->xcloner_settings->get_logger_filename(1)))
410 410
 			{
411 411
 				$metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata($this->xcloner_settings->get_logger_filename(1));
412 412
 				$this->store_file($metadata_dumpfile, 'tmp_filesystem');
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 	{
424 424
 		$return = array();
425 425
 		$return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->get_included_files_handler();
426
-		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log'))
426
+		if ($this->xcloner_settings->get_xcloner_option('xcloner_enable_log'))
427 427
 			$return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->xcloner_settings->get_logger_filename(1);
428 428
 		
429 429
 		return $return;
@@ -436,8 +436,8 @@  discard block
 block discarded – undo
436 436
 		
437 437
 		$contents = $this->get_tmp_filesystem()->listContents();
438 438
 	
439
-		if(is_array($contents))
440
-		foreach($contents as $file_info)
439
+		if (is_array($contents))
440
+		foreach ($contents as $file_info)
441 441
 			$this->get_tmp_filesystem()->delete($file_info['path']);
442 442
 			
443 443
 		@rmdir($this->xcloner_settings->get_xcloner_tmp_path());
@@ -447,16 +447,16 @@  discard block
 block discarded – undo
447 447
 	
448 448
 	public function cleanup_tmp_directories()
449 449
 	{
450
-		$adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(false),LOCK_EX|FILE_APPEND, 'SKIP_LINKS');
450
+		$adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(false), LOCK_EX | FILE_APPEND, 'SKIP_LINKS');
451 451
 		$tmp_filesystem = new Filesystem($adapter, new Config([
452 452
 					'disable_asserts' => true,
453 453
 				]));
454 454
 				
455 455
 		$contents = $tmp_filesystem->listContents();
456 456
 		
457
-		foreach($contents as $file)
457
+		foreach ($contents as $file)
458 458
 		{
459
-			if(preg_match("/.xcloner-(.*)/",$file['path']))
459
+			if (preg_match("/.xcloner-(.*)/", $file['path']))
460 460
 			{
461 461
 				$tmp_filesystem->deleteDir($file['path']);
462 462
 				$this->logger->info(sprintf("Delete temporary directory %s", $file['path']));
@@ -470,16 +470,16 @@  discard block
 block discarded – undo
470 470
 	{
471 471
 		$this->files_counter = 0;
472 472
 		
473
-		if(!$this->storage_filesystem->has("index.html"))	
474
-			$this->storage_filesystem->write("index.html","");
473
+		if (!$this->storage_filesystem->has("index.html"))	
474
+			$this->storage_filesystem->write("index.html", "");
475 475
 		
476
-		if(!$this->tmp_filesystem->has("index.html"))	
477
-			$this->tmp_filesystem->write("index.html","");
476
+		if (!$this->tmp_filesystem->has("index.html"))	
477
+			$this->tmp_filesystem->write("index.html", "");
478 478
 			
479
-		if($this->tmp_filesystem->has($this->get_included_files_handler()))
479
+		if ($this->tmp_filesystem->has($this->get_included_files_handler()))
480 480
 			$this->tmp_filesystem->delete($this->get_included_files_handler());
481 481
 		
482
-		if($this->tmp_filesystem->has($this->get_temp_dir_handler()))	
482
+		if ($this->tmp_filesystem->has($this->get_temp_dir_handler()))	
483 483
 			$this->tmp_filesystem->delete($this->get_temp_dir_handler());
484 484
 	}
485 485
 	
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 	
501 501
 	public function set_excluded_files($excluded_files = array())
502 502
 	{
503
-		if(!is_array($excluded_files))
503
+		if (!is_array($excluded_files))
504 504
 			$excluded_files = array();
505 505
 			
506 506
 		$this->excluded_files = array_merge($excluded_files, $this->excluded_files_by_default);
@@ -523,35 +523,35 @@  discard block
 block discarded – undo
523 523
 		$this->logger->debug(sprintf(("Building the files system list")));
524 524
 		
525 525
 		//if we start with the root folder(empty value), we initializa the file system
526
-		if(!$folder){
526
+		if (!$folder) {
527 527
 			
528 528
 		}
529 529
 			
530
-		try{
530
+		try {
531 531
 			
532 532
 			$files = $this->start_filesystem->listContents($folder);
533
-			foreach($files as $file)
533
+			foreach ($files as $file)
534 534
 			{
535
-				if(!is_readable($this->xcloner_settings->get_xcloner_start_path().DS.$file['path']))
535
+				if (!is_readable($this->xcloner_settings->get_xcloner_start_path().DS.$file['path']))
536 536
 				{
537
-					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, file not readable"), $file['path']), array("FILESYSTEM SCAN","NOT READABLE"));
537
+					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, file not readable"), $file['path']), array("FILESYSTEM SCAN", "NOT READABLE"));
538 538
 				}
539
-				elseif(!$matching_pattern = $this->is_excluded($file) ){
540
-					$this->logger->info(sprintf(__("Adding %s to the filesystem list"), $file['path']), array("FILESYSTEM SCAN","INCLUDE"));
539
+				elseif (!$matching_pattern = $this->is_excluded($file)) {
540
+					$this->logger->info(sprintf(__("Adding %s to the filesystem list"), $file['path']), array("FILESYSTEM SCAN", "INCLUDE"));
541 541
 					$file['visibility'] = $this->start_filesystem->getVisibility($file['path']);
542
-					if($this->store_file($file))
542
+					if ($this->store_file($file))
543 543
 					{
544 544
 						$this->files_counter++;
545 545
 					}
546
-					if(isset($file['size']))
546
+					if (isset($file['size']))
547 547
 						$this->files_size += $file['size'];
548 548
 					
549
-				}else{
550
-					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, matching pattern %s"), $file['path'], $matching_pattern), array("FILESYSTEM SCAN","EXCLUDE"));
549
+				} else {
550
+					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, matching pattern %s"), $file['path'], $matching_pattern), array("FILESYSTEM SCAN", "EXCLUDE"));
551 551
 					}
552 552
 			}
553 553
 			
554
-		}catch(Exception $e){
554
+		}catch (Exception $e) {
555 555
 			
556 556
 			$this->logger->error($e->getMessage());
557 557
 		
@@ -565,9 +565,9 @@  discard block
 block discarded – undo
565 565
 				
566 566
 		$start_time = microtime();
567 567
 		
568
-		$data = str_repeat(rand(0,9), 1024*1024); //write 1MB data
568
+		$data = str_repeat(rand(0, 9), 1024 * 1024); //write 1MB data
569 569
 		
570
-		try{
570
+		try {
571 571
 			$this->tmp_filesystem->write($tmp_file, $data);
572 572
 			
573 573
 			$end_time = microtime() - $start_time;
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 		
579 579
 			$this->tmp_filesystem->delete($tmp_file);
580 580
 		
581
-		}catch(Exception $e){
581
+		}catch (Exception $e) {
582 582
 			
583 583
 			$this->logger->error($e->getMessage());
584 584
 			
@@ -599,10 +599,10 @@  discard block
 block discarded – undo
599 599
 		
600 600
 		$files = $this->storage_filesystem->listContents();
601 601
 		
602
-		if(is_array($files))
603
-			foreach($files as $file)
602
+		if (is_array($files))
603
+			foreach ($files as $file)
604 604
 			{
605
-				if(isset($file['extension']) and in_array($file['extension'], $this->backup_archive_extensions))
605
+				if (isset($file['extension']) and in_array($file['extension'], $this->backup_archive_extensions))
606 606
 				{
607 607
 					$_storage_size += $file['size']; //bytes
608 608
 					$_backup_files_list[] = $file;
@@ -610,15 +610,15 @@  discard block
 block discarded – undo
610 610
 			}
611 611
 		
612 612
 		
613
-		$this->sort_by($_backup_files_list, "timestamp","asc");
613
+		$this->sort_by($_backup_files_list, "timestamp", "asc");
614 614
 		
615 615
 		$_backups_counter = sizeof($_backup_files_list);
616 616
 				
617
-		foreach($_backup_files_list as $file)
617
+		foreach ($_backup_files_list as $file)
618 618
 		{
619 619
 			//processing rule folder capacity
620
-			if($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') &&
621
-			$_storage_size >= ($set_storage_limit = 1024*1024*$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit')))	//bytes	
620
+			if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') &&
621
+			$_storage_size >= ($set_storage_limit = 1024 * 1024 * $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit')))	//bytes	
622 622
 			{
623 623
 				$this->storage_filesystem->delete($file['path']);
624 624
 				$_storage_size -= $file['size'];
@@ -626,14 +626,14 @@  discard block
 block discarded – undo
626 626
 			}
627 627
 			
628 628
 			//processing rule days limit
629
-			if($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days') && $current_timestamp >= $file['timestamp'])
629
+			if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days') && $current_timestamp >= $file['timestamp'])
630 630
 			{
631 631
 				$this->storage_filesystem->delete($file['path']);
632 632
 				$this->logger->info("Deleting backup ".$file['path']." matching rule", array("RETENTION LIMIT TIMESTAMP", $file['timestamp']." =< ".$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days')));
633 633
 			}
634 634
 			
635 635
 			//processing backup countert limit
636
-			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'))
636
+			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'))
637 637
 			{
638 638
 				$this->storage_filesystem->delete($file['path']);
639 639
 				$_backups_counter--;
@@ -659,33 +659,33 @@  discard block
 block discarded – undo
659 659
 	
660 660
 	}
661 661
 	
662
-	public function process_backup_name($name = "", $max_length=100)
662
+	public function process_backup_name($name = "", $max_length = 100)
663 663
 	{
664
-		if(!$name)
664
+		if (!$name)
665 665
 			$name = $this->xcloner_settings->get_default_backup_name();
666 666
 		
667
-		foreach($this->backup_name_tags as $tag)
667
+		foreach ($this->backup_name_tags as $tag)
668 668
 		{
669
-			if($tag == '[time]')
670
-				$name = str_replace($tag, date("Y-m-d_H-i"),$name);
671
-			elseif($tag == '[hostname]')
672
-				$name = str_replace($tag, gethostname() ,$name);	
673
-			elseif($tag == '[domain]')
669
+			if ($tag == '[time]')
670
+				$name = str_replace($tag, date("Y-m-d_H-i"), $name);
671
+			elseif ($tag == '[hostname]')
672
+				$name = str_replace($tag, gethostname(), $name);	
673
+			elseif ($tag == '[domain]')
674 674
 			{
675 675
 				$domain = parse_url(admin_url(), PHP_URL_HOST);
676
-				$name = str_replace($tag, $domain ,$name);	
676
+				$name = str_replace($tag, $domain, $name);	
677 677
 			}
678 678
 		}
679 679
 		
680
-		if($max_length)
680
+		if ($max_length)
681 681
 			$name = substr($name, 0, $max_length);
682 682
 			
683 683
 		return $name;	
684 684
 	}
685 685
 	
686
-	public function sort_by( &$array, $field, $direction = 'asc')
686
+	public function sort_by(&$array, $field, $direction = 'asc')
687 687
 	{
688
-		if(strtolower($direction) == "desc" || $direction == SORT_DESC)
688
+		if (strtolower($direction) == "desc" || $direction == SORT_DESC)
689 689
 			$direction = SORT_DESC;
690 690
 		else
691 691
 			$direction = SORT_ASC;
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 	            $tmp = array();
706 706
 	            foreach ($data as $key => $row)
707 707
 	            {
708
-					if(is_array($row))
708
+					if (is_array($row))
709 709
 						$tmp[$key] = $row[$field];
710 710
 					else
711 711
 						$tmp[$key] = $row->$field;
@@ -722,18 +722,18 @@  discard block
 block discarded – undo
722 722
 	
723 723
 	private function check_file_diff_time($file)
724 724
 	{
725
-		if($this->get_diff_timestamp_start() != "")
725
+		if ($this->get_diff_timestamp_start() != "")
726 726
 		{
727 727
 			$fileMeta = $this->getMetadataFull("start_adapter", $file['path']);
728 728
 			$timestamp = $fileMeta->getMTime();
729
-			if($timestamp < $fileMeta->getCTime())
729
+			if ($timestamp < $fileMeta->getCTime())
730 730
 			{
731 731
 				$timestamp = $fileMeta->getCTime();
732 732
 			}
733 733
 			
734
-			if($timestamp <= $this->get_diff_timestamp_start())
734
+			if ($timestamp <= $this->get_diff_timestamp_start())
735 735
 			{
736
-				return  " file DIFF timestamp ".$timestamp." < ". $this->diff_timestamp_start;
736
+				return  " file DIFF timestamp ".$timestamp." < ".$this->diff_timestamp_start;
737 737
 			}
738 738
 		}
739 739
 		
@@ -744,35 +744,35 @@  discard block
 block discarded – undo
744 744
 	{
745 745
 		$this->logger->debug(sprintf(("Checking if %s is excluded"), $file['path']));
746 746
 		
747
-		if($xcloner_exclude_files_larger_than_mb = $this->xcloner_settings->get_xcloner_option('xcloner_exclude_files_larger_than_mb'))
747
+		if ($xcloner_exclude_files_larger_than_mb = $this->xcloner_settings->get_xcloner_option('xcloner_exclude_files_larger_than_mb'))
748 748
 		{
749
-			if(isset($file['size']) && $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb))
749
+			if (isset($file['size']) && $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb))
750 750
 				return "> ".$xcloner_exclude_files_larger_than_mb."MB";
751 751
 		}
752 752
 		
753
-		if(!sizeof($this->excluded_files))
753
+		if (!sizeof($this->excluded_files))
754 754
 			$this->set_excluded_files();
755 755
 				
756
-		if(is_array($this->excluded_files))
757
-		foreach($this->excluded_files as $excluded_file_pattern)
756
+		if (is_array($this->excluded_files))
757
+		foreach ($this->excluded_files as $excluded_file_pattern)
758 758
 		{
759
-			if($excluded_file_pattern == "/")
759
+			if ($excluded_file_pattern == "/")
760 760
 				$needle = "$";
761 761
 			else
762 762
 				$needle = "$".$excluded_file_pattern;
763 763
 				
764
-			if(strstr("$".$file['path'], $needle)){
764
+			if (strstr("$".$file['path'], $needle)) {
765 765
 				return $excluded_file_pattern;
766 766
 			}
767 767
 		}
768 768
 		
769
-		if( $regex = $this->is_excluded_regex($file))
769
+		if ($regex = $this->is_excluded_regex($file))
770 770
 			return $regex;
771 771
 		
772
-		if($file['type'] == "file")
772
+		if ($file['type'] == "file")
773 773
 		{
774 774
 			$check_file_diff_timestamp = $this->check_file_diff_time($file);
775
-			if($check_file_diff_timestamp)
775
+			if ($check_file_diff_timestamp)
776 776
 			{
777 777
 				return $check_file_diff_timestamp;
778 778
 			}
@@ -821,25 +821,25 @@  discard block
 block discarded – undo
821 821
 		
822 822
 		//print_r($regex_patterns);exit;
823 823
 		
824
-		if(is_array($regex_patterns))
824
+		if (is_array($regex_patterns))
825 825
 		{
826 826
 			//$this->excluded_files = array();
827 827
 			//$this->excluded_files[] ="(.*)\.(git)(.*)$";
828 828
 			//$this->excluded_files[] ="wp-content\/backups(.*)$";
829 829
 			
830
-			foreach($regex_patterns as $excluded_file_pattern)
830
+			foreach ($regex_patterns as $excluded_file_pattern)
831 831
 			{
832 832
 				
833
-				if( substr($excluded_file_pattern, strlen($excluded_file_pattern)-1, strlen($excluded_file_pattern)) == "\r")
834
-					$excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern)-1);
833
+				if (substr($excluded_file_pattern, strlen($excluded_file_pattern) - 1, strlen($excluded_file_pattern)) == "\r")
834
+					$excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern) - 1);
835 835
 					
836
-				if($file['path'] == "/")
836
+				if ($file['path'] == "/")
837 837
 					$needle = "/";
838 838
 				else
839 839
 					$needle = "/".$file['path'];
840 840
 				//echo $needle."---".$excluded_file_pattern."---\n";
841 841
 				
842
-				if(@preg_match("/(^|^\/)".$excluded_file_pattern."/i", $needle)){
842
+				if (@preg_match("/(^|^\/)".$excluded_file_pattern."/i", $needle)) {
843 843
 					return $excluded_file_pattern;
844 844
 				}
845 845
 			}
@@ -852,36 +852,36 @@  discard block
 block discarded – undo
852 852
 	{
853 853
 		$this->logger->debug(sprintf("Storing %s in the backup list", $file['path']));
854 854
 		
855
-		if(!isset($file['size']))
855
+		if (!isset($file['size']))
856 856
 			$file['size'] = 0;
857
-		if(!isset($file['visibility']))	
857
+		if (!isset($file['visibility']))	
858 858
 			$file['visibility'] = "private";
859 859
 		
860
-		$csv_filename = str_replace('"','""', $file['path']);
860
+		$csv_filename = str_replace('"', '""', $file['path']);
861 861
 		
862 862
 		$line = '"'.($csv_filename).'","'.$file['timestamp'].'","'.$file['size'].'","'.$file['visibility'].'","'.$storage.'"'.PHP_EOL;
863 863
 		
864 864
 		$this->last_logged_file = $file['path'];
865 865
 		
866
-		if($file['type'] == "dir"){
867
-			try{
866
+		if ($file['type'] == "dir") {
867
+			try {
868 868
 				$this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file['path']."\n");
869
-			}catch(Exception $e){
869
+			}catch (Exception $e) {
870 870
 				$this->logger->error($e->getMessage());	
871 871
 			}
872 872
 		}
873 873
 		
874
-		if($this->get_diff_timestamp_start())
874
+		if ($this->get_diff_timestamp_start())
875 875
 		{
876
-			if($file['type'] != "file" && $response = $this->check_file_diff_time($file))
876
+			if ($file['type'] != "file" && $response = $this->check_file_diff_time($file))
877 877
 			{
878
-				$this->logger->info(sprintf("Directory %s archiving skipped on differential backup %s", $file['path'], $response), array("FILESYSTEM SCAN","DIR DIFF"));
878
+				$this->logger->info(sprintf("Directory %s archiving skipped on differential backup %s", $file['path'], $response), array("FILESYSTEM SCAN", "DIR DIFF"));
879 879
 				return false;
880 880
 			}
881 881
 		}
882 882
 		
883
-		try{
884
-			if(!$this->tmp_filesystem_append->has($this->get_included_files_handler()))
883
+		try {
884
+			if (!$this->tmp_filesystem_append->has($this->get_included_files_handler()))
885 885
 			{
886 886
 				//adding fix for UTF-8 CSV preview
887 887
 				$start_line = "\xEF\xBB\xBF".'"Filename","Timestamp","Size","Visibility","Storage"'.PHP_EOL;
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
 			
891 891
 			$this->tmp_filesystem_append->write($this->get_included_files_handler(), $line);
892 892
 		
893
-		}catch(Exception $e){
893
+		}catch (Exception $e) {
894 894
 		
895 895
 			$this->logger->error($e->getMessage());	
896 896
 		}
@@ -905,13 +905,13 @@  discard block
 block discarded – undo
905 905
 	
906 906
 	public function get_filesystem($system = "")
907 907
 	{
908
-		if($system == "storage_filesystem_append")
908
+		if ($system == "storage_filesystem_append")
909 909
 			return $this->storage_filesystem_append;
910
-		elseif($system == "tmp_filesystem_append")
910
+		elseif ($system == "tmp_filesystem_append")
911 911
 			return $this->tmp_filesystem_append;
912
-		elseif($system == "tmp_filesystem")
912
+		elseif ($system == "tmp_filesystem")
913 913
 			return $this->tmp_filesystem;
914
-		elseif($system == "storage_filesystem")
914
+		elseif ($system == "storage_filesystem")
915 915
 			return $this->storage_filesystem;
916 916
 		else
917 917
 			return $this->start_filesystem;	
@@ -919,9 +919,9 @@  discard block
 block discarded – undo
919 919
 	
920 920
 	public function get_adapter($system)
921 921
 	{
922
-		if($system == "tmp_filesystem")
922
+		if ($system == "tmp_filesystem")
923 923
 			return $this->tmp_adapter;
924
-		elseif($system == "storage_filesystem")
924
+		elseif ($system == "storage_filesystem")
925 925
 			return $this->storage_adapter;
926 926
 		else
927 927
 			return $this->start_adapter;	
@@ -929,10 +929,10 @@  discard block
 block discarded – undo
929 929
 	
930 930
 	private function scan_finished()
931 931
 	{
932
-		if($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler()))
932
+		if ($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler()))
933 933
 			return false;
934 934
 		
935
-		if($this->tmp_filesystem->has($this->get_temp_dir_handler()))
935
+		if ($this->tmp_filesystem->has($this->get_temp_dir_handler()))
936 936
 			$this->tmp_filesystem->delete($this->get_temp_dir_handler());
937 937
 		
938 938
 		$this->logger->debug(sprintf(("File scan finished")));
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 	
943 943
 	private function calc_to_bytes($mb_size)
944 944
 	{
945
-		return $mb_size*(1024*1024);
945
+		return $mb_size * (1024 * 1024);
946 946
 	}
947 947
 	
948 948
 }
Please login to merge, or discard this patch.
Braces   +167 added lines, -123 removed lines patch added patch discarded remove patch
@@ -66,13 +66,14 @@  discard block
 block discarded – undo
66 66
 			$this->storage_filesystem_append = new Filesystem($this->storage_adapter, new Config([
67 67
 					'disable_asserts' => true,
68 68
 				]));
69
-		}catch(Exception $e){
69
+		} catch(Exception $e){
70 70
 			$this->logger->error("Filesystem Initialization Error: ".$e->getMessage());
71 71
 		}
72 72
 		
73 73
 		
74
-		if($value = get_option('xcloner_directories_to_scan_per_request'))
75
-			$this->folders_to_process_per_session = $value;
74
+		if($value = get_option('xcloner_directories_to_scan_per_request')) {
75
+					$this->folders_to_process_per_session = $value;
76
+		}
76 77
 
77 78
 	}
78 79
 	
@@ -118,8 +119,9 @@  discard block
 block discarded – undo
118 119
 			$remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage();
119 120
 			$method = "get_".$remote_storage_selection."_filesystem";
120 121
 			
121
-			if(!method_exists($remote_storage, $method))
122
-				return false;
122
+			if(!method_exists($remote_storage, $method)) {
123
+							return false;
124
+			}
123 125
 				
124 126
 			list($adapter, $filesystem) = $remote_storage->$method();	
125 127
 			
@@ -168,8 +170,9 @@  discard block
 block discarded – undo
168 170
 	public function get_included_files_handler($metadata  = 0)
169 171
 	{
170 172
 		$path = $this->included_files_handler;
171
-		if(!$metadata)
172
-			return $path;
173
+		if(!$metadata) {
174
+					return $path;
175
+		}
173 176
 		
174 177
 		$spl_info = $this->getMetadataFull('tmp_adapter', $path);
175 178
 		return $spl_info;
@@ -185,31 +188,36 @@  discard block
 block discarded – undo
185 188
 	{
186 189
 		$files = $this->get_backup_archives_list();
187 190
 		
188
-		if(is_array($files))
189
-			$this->sort_by($files, "timestamp","desc");
191
+		if(is_array($files)) {
192
+					$this->sort_by($files, "timestamp","desc");
193
+		}
190 194
 		
191 195
 		$new_list = array();
192 196
 		
193
-		foreach($files as $key=>$file)
194
-			if(!isset($file['parent']))
197
+		foreach($files as $key=>$file) {
198
+					if(!isset($file['parent']))
195 199
 				$new_list[] = ($files[$key]);
200
+		}
196 201
 
197
-		if(isset($new_list[0]))
198
-			return $new_list[0];
202
+		if(isset($new_list[0])) {
203
+					return $new_list[0];
204
+		}
199 205
 	}
200 206
 	
201 207
 	public function get_latest_backups()
202 208
 	{
203 209
 		$files = $this->get_backup_archives_list();
204 210
 
205
-		if(is_array($files))
206
-			$this->sort_by($files, "timestamp","desc");
211
+		if(is_array($files)) {
212
+					$this->sort_by($files, "timestamp","desc");
213
+		}
207 214
 		
208 215
 		$new_list = array();
209 216
 		
210
-		foreach($files as $key=>$file)
211
-			if(!isset($file['parent']))
217
+		foreach($files as $key=>$file) {
218
+					if(!isset($file['parent']))
212 219
 				$new_list[] = ($files[$key]);
220
+		}
213 221
 
214 222
 		return $new_list;
215 223
 	}
@@ -219,25 +227,28 @@  discard block
 block discarded – undo
219 227
 		$files = $this->get_backup_archives_list();
220 228
 		$total = 0;
221 229
 		
222
-		if(is_array($files))
223
-			foreach($files as $file)
230
+		if(is_array($files)) {
231
+					foreach($files as $file)
224 232
 				$total += $file['size'];
233
+		}
225 234
 				
226 235
 		return $total;		
227 236
 	}
228 237
 	
229 238
 	public function is_part($backup_name)
230 239
 	{
231
-		if(stristr($backup_name, "-part"))
232
-			return true;
240
+		if(stristr($backup_name, "-part")) {
241
+					return true;
242
+		}
233 243
 		
234 244
 		return false;	
235 245
 	}
236 246
 	
237 247
 	public function is_multipart($backup_name)
238 248
 	{
239
-		if(stristr($backup_name, "-multipart"))
240
-			return true;
249
+		if(stristr($backup_name, "-multipart")) {
250
+					return true;
251
+		}
241 252
 		
242 253
 		return false;	
243 254
 	}
@@ -248,8 +259,9 @@  discard block
 block discarded – undo
248 259
 		if($this->is_multipart($backup_name))
249 260
 		{
250 261
 			$backup_parts = $this->get_multipart_files($backup_name);
251
-			foreach($backup_parts as $part_file)
252
-				$backup_size += $this->get_storage_filesystem()->getSize($part_file);
262
+			foreach($backup_parts as $part_file) {
263
+							$backup_size += $this->get_storage_filesystem()->getSize($part_file);
264
+			}
253 265
 		}
254 266
 		
255 267
 		return $backup_size;
@@ -290,10 +302,11 @@  discard block
 block discarded – undo
290 302
 			}
291 303
 		}
292 304
 		
293
-		if($this->get_storage_filesystem($storage_selection)->delete($backup_name))
294
-			$return = true;
295
-		else
296
-			$return = false;
305
+		if($this->get_storage_filesystem($storage_selection)->delete($backup_name)) {
306
+					$return = true;
307
+		} else {
308
+					$return = false;
309
+		}
297 310
 			
298 311
 		return $return;	
299 312
 	}
@@ -312,8 +325,9 @@  discard block
 block discarded – undo
312 325
 		$list = array();
313 326
 		
314 327
 
315
-		if(method_exists($this->get_storage_filesystem($storage_selection), "listContents"))
316
-			$list = $this->get_storage_filesystem($storage_selection)->listContents();
328
+		if(method_exists($this->get_storage_filesystem($storage_selection), "listContents")) {
329
+					$list = $this->get_storage_filesystem($storage_selection)->listContents();
330
+		}
317 331
 
318 332
 		
319 333
 		$backup_files = array();
@@ -326,10 +340,11 @@  discard block
 block discarded – undo
326 340
 				$data = array();
327 341
 				
328 342
 				$lines = explode(PHP_EOL, $this->get_storage_filesystem($storage_selection)->read($file_info['path']));
329
-				foreach($lines as $line)
330
-					if($line)
343
+				foreach($lines as $line) {
344
+									if($line)
331 345
 					{
332 346
 						$data = str_getcsv($line);
347
+				}
333 348
 						if(is_array($data)){
334 349
 							$parents[$data[0]] = $file_info['basename'];
335 350
 							$file_info['childs'][] = $data;
@@ -339,8 +354,9 @@  discard block
 block discarded – undo
339 354
 						
340 355
 			}
341 356
 			
342
-			if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions))
343
-				$backup_files[$file_info['path']] = $file_info;
357
+			if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) {
358
+							$backup_files[$file_info['path']] = $file_info;
359
+			}
344 360
 		}
345 361
 		
346 362
 		foreach($backup_files as $key=>$file_info)
@@ -350,8 +366,9 @@  discard block
 block discarded – undo
350 366
 				//$backup_files[$key]['timestamp'] = $this->get_storage_filesystem($storage_selection)->getTimestamp($file_info['path']);
351 367
 			}
352 368
 			
353
-			if(isset($parents[$file_info['basename']]))
354
-				$backup_files[$key]['parent'] = $parents[$file_info['basename']];
369
+			if(isset($parents[$file_info['basename']])) {
370
+							$backup_files[$key]['parent'] = $parents[$file_info['basename']];
371
+			}
355 372
 		}
356 373
 		
357 374
 		return $backup_files;
@@ -377,11 +394,11 @@  discard block
 block discarded – undo
377 394
 				if($counter < $this->folders_to_process_per_session){
378 395
 					$this->build_files_list($file);
379 396
 					$counter++;
380
-				}else{
397
+				} else{
381 398
 					$this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file."\n");
382 399
 				}
383 400
 			}
384
-		}else{
401
+		} else{
385 402
 			$this->build_files_list();
386 403
 		}
387 404
 		
@@ -423,8 +440,9 @@  discard block
 block discarded – undo
423 440
 	{
424 441
 		$return = array();
425 442
 		$return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->get_included_files_handler();
426
-		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log'))
427
-			$return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->xcloner_settings->get_logger_filename(1);
443
+		if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) {
444
+					$return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->xcloner_settings->get_logger_filename(1);
445
+		}
428 446
 		
429 447
 		return $return;
430 448
 	}
@@ -436,9 +454,10 @@  discard block
 block discarded – undo
436 454
 		
437 455
 		$contents = $this->get_tmp_filesystem()->listContents();
438 456
 	
439
-		if(is_array($contents))
440
-		foreach($contents as $file_info)
457
+		if(is_array($contents)) {
458
+				foreach($contents as $file_info)
441 459
 			$this->get_tmp_filesystem()->delete($file_info['path']);
460
+		}
442 461
 			
443 462
 		@rmdir($this->xcloner_settings->get_xcloner_tmp_path());
444 463
 		
@@ -470,17 +489,21 @@  discard block
 block discarded – undo
470 489
 	{
471 490
 		$this->files_counter = 0;
472 491
 		
473
-		if(!$this->storage_filesystem->has("index.html"))	
474
-			$this->storage_filesystem->write("index.html","");
492
+		if(!$this->storage_filesystem->has("index.html")) {
493
+					$this->storage_filesystem->write("index.html","");
494
+		}
475 495
 		
476
-		if(!$this->tmp_filesystem->has("index.html"))	
477
-			$this->tmp_filesystem->write("index.html","");
496
+		if(!$this->tmp_filesystem->has("index.html")) {
497
+					$this->tmp_filesystem->write("index.html","");
498
+		}
478 499
 			
479
-		if($this->tmp_filesystem->has($this->get_included_files_handler()))
480
-			$this->tmp_filesystem->delete($this->get_included_files_handler());
500
+		if($this->tmp_filesystem->has($this->get_included_files_handler())) {
501
+					$this->tmp_filesystem->delete($this->get_included_files_handler());
502
+		}
481 503
 		
482
-		if($this->tmp_filesystem->has($this->get_temp_dir_handler()))	
483
-			$this->tmp_filesystem->delete($this->get_temp_dir_handler());
504
+		if($this->tmp_filesystem->has($this->get_temp_dir_handler())) {
505
+					$this->tmp_filesystem->delete($this->get_temp_dir_handler());
506
+		}
484 507
 	}
485 508
 	
486 509
 	public function get_scanned_files_num()
@@ -500,8 +523,9 @@  discard block
 block discarded – undo
500 523
 	
501 524
 	public function set_excluded_files($excluded_files = array())
502 525
 	{
503
-		if(!is_array($excluded_files))
504
-			$excluded_files = array();
526
+		if(!is_array($excluded_files)) {
527
+					$excluded_files = array();
528
+		}
505 529
 			
506 530
 		$this->excluded_files = array_merge($excluded_files, $this->excluded_files_by_default);
507 531
 		
@@ -535,23 +559,23 @@  discard block
 block discarded – undo
535 559
 				if(!is_readable($this->xcloner_settings->get_xcloner_start_path().DS.$file['path']))
536 560
 				{
537 561
 					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, file not readable"), $file['path']), array("FILESYSTEM SCAN","NOT READABLE"));
538
-				}
539
-				elseif(!$matching_pattern = $this->is_excluded($file) ){
562
+				} elseif(!$matching_pattern = $this->is_excluded($file) ){
540 563
 					$this->logger->info(sprintf(__("Adding %s to the filesystem list"), $file['path']), array("FILESYSTEM SCAN","INCLUDE"));
541 564
 					$file['visibility'] = $this->start_filesystem->getVisibility($file['path']);
542 565
 					if($this->store_file($file))
543 566
 					{
544 567
 						$this->files_counter++;
545 568
 					}
546
-					if(isset($file['size']))
547
-						$this->files_size += $file['size'];
569
+					if(isset($file['size'])) {
570
+											$this->files_size += $file['size'];
571
+					}
548 572
 					
549
-				}else{
573
+				} else{
550 574
 					$this->logger->info(sprintf(__("Excluding %s from the filesystem list, matching pattern %s"), $file['path'], $matching_pattern), array("FILESYSTEM SCAN","EXCLUDE"));
551 575
 					}
552 576
 			}
553 577
 			
554
-		}catch(Exception $e){
578
+		} catch(Exception $e){
555 579
 			
556 580
 			$this->logger->error($e->getMessage());
557 581
 		
@@ -578,7 +602,7 @@  discard block
 block discarded – undo
578 602
 		
579 603
 			$this->tmp_filesystem->delete($tmp_file);
580 604
 		
581
-		}catch(Exception $e){
605
+		} catch(Exception $e){
582 606
 			
583 607
 			$this->logger->error($e->getMessage());
584 608
 			
@@ -599,12 +623,14 @@  discard block
 block discarded – undo
599 623
 		
600 624
 		$files = $this->storage_filesystem->listContents();
601 625
 		
602
-		if(is_array($files))
603
-			foreach($files as $file)
626
+		if(is_array($files)) {
627
+					foreach($files as $file)
604 628
 			{
605 629
 				if(isset($file['extension']) and in_array($file['extension'], $this->backup_archive_extensions))
606 630
 				{
607
-					$_storage_size += $file['size']; //bytes
631
+					$_storage_size += $file['size'];
632
+		}
633
+		//bytes
608 634
 					$_backup_files_list[] = $file;
609 635
 				}
610 636
 			}
@@ -618,9 +644,11 @@  discard block
 block discarded – undo
618 644
 		{
619 645
 			//processing rule folder capacity
620 646
 			if($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') &&
621
-			$_storage_size >= ($set_storage_limit = 1024*1024*$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit')))	//bytes	
647
+			$_storage_size >= ($set_storage_limit = 1024*1024*$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit'))) {
648
+				//bytes	
622 649
 			{
623 650
 				$this->storage_filesystem->delete($file['path']);
651
+			}
624 652
 				$_storage_size -= $file['size'];
625 653
 				$this->logger->info("Deleting backup ".$file['path']." matching rule", array("STORAGE SIZE LIMIT", $_storage_size." >= ".$set_storage_limit));
626 654
 			}
@@ -661,34 +689,37 @@  discard block
 block discarded – undo
661 689
 	
662 690
 	public function process_backup_name($name = "", $max_length=100)
663 691
 	{
664
-		if(!$name)
665
-			$name = $this->xcloner_settings->get_default_backup_name();
692
+		if(!$name) {
693
+					$name = $this->xcloner_settings->get_default_backup_name();
694
+		}
666 695
 		
667 696
 		foreach($this->backup_name_tags as $tag)
668 697
 		{
669
-			if($tag == '[time]')
670
-				$name = str_replace($tag, date("Y-m-d_H-i"),$name);
671
-			elseif($tag == '[hostname]')
672
-				$name = str_replace($tag, gethostname() ,$name);	
673
-			elseif($tag == '[domain]')
698
+			if($tag == '[time]') {
699
+							$name = str_replace($tag, date("Y-m-d_H-i"),$name);
700
+			} elseif($tag == '[hostname]') {
701
+							$name = str_replace($tag, gethostname() ,$name);
702
+			} elseif($tag == '[domain]')
674 703
 			{
675 704
 				$domain = parse_url(admin_url(), PHP_URL_HOST);
676 705
 				$name = str_replace($tag, $domain ,$name);	
677 706
 			}
678 707
 		}
679 708
 		
680
-		if($max_length)
681
-			$name = substr($name, 0, $max_length);
709
+		if($max_length) {
710
+					$name = substr($name, 0, $max_length);
711
+		}
682 712
 			
683 713
 		return $name;	
684 714
 	}
685 715
 	
686 716
 	public function sort_by( &$array, $field, $direction = 'asc')
687 717
 	{
688
-		if(strtolower($direction) == "desc" || $direction == SORT_DESC)
689
-			$direction = SORT_DESC;
690
-		else
691
-			$direction = SORT_ASC;
718
+		if(strtolower($direction) == "desc" || $direction == SORT_DESC) {
719
+					$direction = SORT_DESC;
720
+		} else {
721
+					$direction = SORT_ASC;
722
+		}
692 723
 					
693 724
 	   $array = $this->array_orderby($array, $field, $direction);
694 725
 	    
@@ -705,10 +736,11 @@  discard block
 block discarded – undo
705 736
 	            $tmp = array();
706 737
 	            foreach ($data as $key => $row)
707 738
 	            {
708
-					if(is_array($row))
709
-						$tmp[$key] = $row[$field];
710
-					else
711
-						$tmp[$key] = $row->$field;
739
+					if(is_array($row)) {
740
+											$tmp[$key] = $row[$field];
741
+					} else {
742
+											$tmp[$key] = $row->$field;
743
+					}
712 744
 				}
713 745
 	            $args[$n] = $tmp;
714 746
 	            }
@@ -746,28 +778,32 @@  discard block
 block discarded – undo
746 778
 		
747 779
 		if($xcloner_exclude_files_larger_than_mb = $this->xcloner_settings->get_xcloner_option('xcloner_exclude_files_larger_than_mb'))
748 780
 		{
749
-			if(isset($file['size']) && $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb))
750
-				return "> ".$xcloner_exclude_files_larger_than_mb."MB";
781
+			if(isset($file['size']) && $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb)) {
782
+							return "> ".$xcloner_exclude_files_larger_than_mb."MB";
783
+			}
751 784
 		}
752 785
 		
753
-		if(!sizeof($this->excluded_files))
754
-			$this->set_excluded_files();
786
+		if(!sizeof($this->excluded_files)) {
787
+					$this->set_excluded_files();
788
+		}
755 789
 				
756
-		if(is_array($this->excluded_files))
757
-		foreach($this->excluded_files as $excluded_file_pattern)
790
+		if(is_array($this->excluded_files)) {
791
+				foreach($this->excluded_files as $excluded_file_pattern)
758 792
 		{
759 793
 			if($excluded_file_pattern == "/")
760 794
 				$needle = "$";
761
-			else
762
-				$needle = "$".$excluded_file_pattern;
795
+		} else {
796
+							$needle = "$".$excluded_file_pattern;
797
+			}
763 798
 				
764 799
 			if(strstr("$".$file['path'], $needle)){
765 800
 				return $excluded_file_pattern;
766 801
 			}
767 802
 		}
768 803
 		
769
-		if( $regex = $this->is_excluded_regex($file))
770
-			return $regex;
804
+		if( $regex = $this->is_excluded_regex($file)) {
805
+					return $regex;
806
+		}
771 807
 		
772 808
 		if($file['type'] == "file")
773 809
 		{
@@ -830,13 +866,15 @@  discard block
 block discarded – undo
830 866
 			foreach($regex_patterns as $excluded_file_pattern)
831 867
 			{
832 868
 				
833
-				if( substr($excluded_file_pattern, strlen($excluded_file_pattern)-1, strlen($excluded_file_pattern)) == "\r")
834
-					$excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern)-1);
869
+				if( substr($excluded_file_pattern, strlen($excluded_file_pattern)-1, strlen($excluded_file_pattern)) == "\r") {
870
+									$excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern)-1);
871
+				}
835 872
 					
836
-				if($file['path'] == "/")
837
-					$needle = "/";
838
-				else
839
-					$needle = "/".$file['path'];
873
+				if($file['path'] == "/") {
874
+									$needle = "/";
875
+				} else {
876
+									$needle = "/".$file['path'];
877
+				}
840 878
 				//echo $needle."---".$excluded_file_pattern."---\n";
841 879
 				
842 880
 				if(@preg_match("/(^|^\/)".$excluded_file_pattern."/i", $needle)){
@@ -852,10 +890,12 @@  discard block
 block discarded – undo
852 890
 	{
853 891
 		$this->logger->debug(sprintf("Storing %s in the backup list", $file['path']));
854 892
 		
855
-		if(!isset($file['size']))
856
-			$file['size'] = 0;
857
-		if(!isset($file['visibility']))	
858
-			$file['visibility'] = "private";
893
+		if(!isset($file['size'])) {
894
+					$file['size'] = 0;
895
+		}
896
+		if(!isset($file['visibility'])) {
897
+					$file['visibility'] = "private";
898
+		}
859 899
 		
860 900
 		$csv_filename = str_replace('"','""', $file['path']);
861 901
 		
@@ -866,7 +906,7 @@  discard block
 block discarded – undo
866 906
 		if($file['type'] == "dir"){
867 907
 			try{
868 908
 				$this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file['path']."\n");
869
-			}catch(Exception $e){
909
+			} catch(Exception $e){
870 910
 				$this->logger->error($e->getMessage());	
871 911
 			}
872 912
 		}
@@ -890,7 +930,7 @@  discard block
 block discarded – undo
890 930
 			
891 931
 			$this->tmp_filesystem_append->write($this->get_included_files_handler(), $line);
892 932
 		
893
-		}catch(Exception $e){
933
+		} catch(Exception $e){
894 934
 		
895 935
 			$this->logger->error($e->getMessage());	
896 936
 		}
@@ -905,35 +945,39 @@  discard block
 block discarded – undo
905 945
 	
906 946
 	public function get_filesystem($system = "")
907 947
 	{
908
-		if($system == "storage_filesystem_append")
909
-			return $this->storage_filesystem_append;
910
-		elseif($system == "tmp_filesystem_append")
911
-			return $this->tmp_filesystem_append;
912
-		elseif($system == "tmp_filesystem")
913
-			return $this->tmp_filesystem;
914
-		elseif($system == "storage_filesystem")
915
-			return $this->storage_filesystem;
916
-		else
917
-			return $this->start_filesystem;	
948
+		if($system == "storage_filesystem_append") {
949
+					return $this->storage_filesystem_append;
950
+		} elseif($system == "tmp_filesystem_append") {
951
+					return $this->tmp_filesystem_append;
952
+		} elseif($system == "tmp_filesystem") {
953
+					return $this->tmp_filesystem;
954
+		} elseif($system == "storage_filesystem") {
955
+					return $this->storage_filesystem;
956
+		} else {
957
+					return $this->start_filesystem;
958
+		}
918 959
 	}
919 960
 	
920 961
 	public function get_adapter($system)
921 962
 	{
922
-		if($system == "tmp_filesystem")
923
-			return $this->tmp_adapter;
924
-		elseif($system == "storage_filesystem")
925
-			return $this->storage_adapter;
926
-		else
927
-			return $this->start_adapter;	
963
+		if($system == "tmp_filesystem") {
964
+					return $this->tmp_adapter;
965
+		} elseif($system == "storage_filesystem") {
966
+					return $this->storage_adapter;
967
+		} else {
968
+					return $this->start_adapter;
969
+		}
928 970
 	}
929 971
 	
930 972
 	private function scan_finished()
931 973
 	{
932
-		if($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler()))
933
-			return false;
974
+		if($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler())) {
975
+					return false;
976
+		}
934 977
 		
935
-		if($this->tmp_filesystem->has($this->get_temp_dir_handler()))
936
-			$this->tmp_filesystem->delete($this->get_temp_dir_handler());
978
+		if($this->tmp_filesystem->has($this->get_temp_dir_handler())) {
979
+					$this->tmp_filesystem->delete($this->get_temp_dir_handler());
980
+		}
937 981
 		
938 982
 		$this->logger->debug(sprintf(("File scan finished")));
939 983
 			
Please login to merge, or discard this patch.
includes/class-xcloner-scheduler.php 2 patches
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class Xcloner_Scheduler{
3
+class Xcloner_Scheduler {
4 4
 	
5 5
 	private $db;
6 6
 	private $scheduler_table = "xcloner_scheduler";
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 	{
22 22
 		global $wpdb;
23 23
 		
24
-		$this->db 					= $wpdb;
25
-		$wpdb->show_errors			= false;
24
+		$this->db = $wpdb;
25
+		$wpdb->show_errors = false;
26 26
 		
27 27
 		$this->xcloner_container	= $xcloner_container;
28 28
 		$this->xcloner_settings 	= $xcloner_container->get_xcloner_settings();
@@ -40,18 +40,18 @@  discard block
 block discarded – undo
40 40
 		$this->xcloner_container = $container;
41 41
 	}
42 42
 	
43
-	public function get_scheduler_list($return_only_enabled = 0 )
43
+	public function get_scheduler_list($return_only_enabled = 0)
44 44
 	{
45 45
 		$list = $this->db->get_results("SELECT * FROM ".$this->scheduler_table);
46 46
 		
47
-		if($return_only_enabled)
47
+		if ($return_only_enabled)
48 48
 		{
49
-			$new_list= array();
49
+			$new_list = array();
50 50
 			
51
-			foreach($list as $res)
52
-				if($res->status)
51
+			foreach ($list as $res)
52
+				if ($res->status)
53 53
 				{
54
-					$res->next_run_time = wp_next_scheduled('xcloner_scheduler_'.$res->id, array($res->id))+(get_option( 'gmt_offset' ) * HOUR_IN_SECONDS);
54
+					$res->next_run_time = wp_next_scheduled('xcloner_scheduler_'.$res->id, array($res->id)) + (get_option('gmt_offset') * HOUR_IN_SECONDS);
55 55
 					$new_list[] = $res;
56 56
 				}
57 57
 			$list = $new_list;	
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	{
78 78
 		$data = $this->db->get_row("SELECT * FROM ".$this->scheduler_table." WHERE id=".$id, ARRAY_A);
79 79
 		
80
-		if(!$data)
80
+		if (!$data)
81 81
 			return false;
82 82
 		
83 83
 		$params = json_decode($data['params']);
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
 	
95 95
 	public function delete_schedule_by_id($id)
96 96
 	{
97
-		$hook =  'xcloner_scheduler_'.$id;
98
-		wp_clear_scheduled_hook( $hook, array($id) );
97
+		$hook = 'xcloner_scheduler_'.$id;
98
+		wp_clear_scheduled_hook($hook, array($id));
99 99
 		
100
-		$data = $this->db->delete( $this->scheduler_table , array( 'id' => $id ) );
100
+		$data = $this->db->delete($this->scheduler_table, array('id' => $id));
101 101
 		
102 102
 		return $data;
103 103
 	}
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 	{
107 107
 		$list = $this->get_scheduler_list();
108 108
 		
109
-		foreach($list as $schedule)
109
+		foreach ($list as $schedule)
110 110
 		{
111
-			$hook =  'xcloner_scheduler_'.$schedule->id;
111
+			$hook = 'xcloner_scheduler_'.$schedule->id;
112 112
 			
113
-			$timestamp = wp_next_scheduled( $hook , array($schedule->id) );
114
-			wp_unschedule_event( $timestamp, $hook, array($schedule->id) );
113
+			$timestamp = wp_next_scheduled($hook, array($schedule->id));
114
+			wp_unschedule_event($timestamp, $hook, array($schedule->id));
115 115
 		}
116 116
 	}
117 117
 	
@@ -119,26 +119,26 @@  discard block
 block discarded – undo
119 119
 	{
120 120
 		$list = $this->get_scheduler_list();
121 121
 		
122
-		foreach($list as $schedule)
122
+		foreach ($list as $schedule)
123 123
 		{
124
-			$hook =  'xcloner_scheduler_'.$schedule->id;
124
+			$hook = 'xcloner_scheduler_'.$schedule->id;
125 125
 			
126 126
 			//adding the xcloner_scheduler hook with xcloner_scheduler_callback callback
127
-			add_action( $hook, array($this, 'xcloner_scheduler_callback'), 10,  1 );
127
+			add_action($hook, array($this, 'xcloner_scheduler_callback'), 10, 1);
128 128
 			
129
-			if ( ! wp_next_scheduled( $hook, array($schedule->id) ) and $schedule->status) {
129
+			if (!wp_next_scheduled($hook, array($schedule->id)) and $schedule->status) {
130 130
 				
131
-				if($schedule->recurrence == "single")
131
+				if ($schedule->recurrence == "single")
132 132
 				{
133
-					wp_schedule_single_event( strtotime($schedule->start_at), $hook, array($schedule->id));
134
-				}else{	
135
-					wp_schedule_event( strtotime($schedule->start_at), $schedule->recurrence, $hook, array($schedule->id) );
133
+					wp_schedule_single_event(strtotime($schedule->start_at), $hook, array($schedule->id));
134
+				} else {	
135
+					wp_schedule_event(strtotime($schedule->start_at), $schedule->recurrence, $hook, array($schedule->id));
136 136
 				}
137 137
 					
138
-			}elseif(!$schedule->status)
138
+			}elseif (!$schedule->status)
139 139
 			{
140
-				$timestamp = wp_next_scheduled( $hook , array($schedule->id) );
141
-				wp_unschedule_event( $timestamp, $hook, array($schedule->id) );
140
+				$timestamp = wp_next_scheduled($hook, array($schedule->id));
141
+				wp_unschedule_event($timestamp, $hook, array($schedule->id));
142 142
 			}
143 143
 		}
144 144
 	
@@ -147,18 +147,18 @@  discard block
 block discarded – undo
147 147
 	public function update_cron_hook($id)
148 148
 	{
149 149
 		$schedule = $this->get_schedule_by_id_object($id);
150
-		$hook =  'xcloner_scheduler_'.$schedule->id;
150
+		$hook = 'xcloner_scheduler_'.$schedule->id;
151 151
 		
152
-		$timestamp = wp_next_scheduled( $hook , array($schedule->id) );
153
-		wp_unschedule_event( $timestamp, $hook, array($schedule->id) );
152
+		$timestamp = wp_next_scheduled($hook, array($schedule->id));
153
+		wp_unschedule_event($timestamp, $hook, array($schedule->id));
154 154
 		
155 155
 		if ($schedule->status) {
156 156
 			
157
-			if($schedule->recurrence == "single")
157
+			if ($schedule->recurrence == "single")
158 158
 			{
159
-				wp_schedule_single_event( strtotime($schedule->start_at), $hook, array($schedule->id));
160
-			}else{	
161
-				wp_schedule_event( strtotime($schedule->start_at), $schedule->recurrence, $hook, array($schedule->id) );
159
+				wp_schedule_single_event(strtotime($schedule->start_at), $hook, array($schedule->id));
160
+			} else {	
161
+				wp_schedule_event(strtotime($schedule->start_at), $schedule->recurrence, $hook, array($schedule->id));
162 162
 			}
163 163
 				
164 164
 		}
@@ -166,16 +166,16 @@  discard block
 block discarded – undo
166 166
 	
167 167
 	public function disable_single_cron($schedule_id)
168 168
 	{
169
-		$hook =  'xcloner_scheduler_'.$schedule_id;
170
-		$timestamp = wp_next_scheduled( $hook , array($schedule_id) );
171
-		wp_unschedule_event( $timestamp, $hook, array($schedule_id) );
169
+		$hook = 'xcloner_scheduler_'.$schedule_id;
170
+		$timestamp = wp_next_scheduled($hook, array($schedule_id));
171
+		wp_unschedule_event($timestamp, $hook, array($schedule_id));
172 172
 		
173 173
 		$schedule['status'] = 0;
174 174
 		
175 175
 		$update = $this->db->update( 
176 176
 				$this->scheduler_table, 
177 177
 				$schedule, 
178
-				array( 'id' => $schedule_id ), 
178
+				array('id' => $schedule_id), 
179 179
 				array( 
180 180
 					'%s', 
181 181
 					'%s' 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 		$update = $this->db->update( 
192 192
 				$this->scheduler_table, 
193 193
 				$schedule, 
194
-				array( 'id' => $schedule_id ), 
194
+				array('id' => $schedule_id), 
195 195
 				array( 
196 196
 					'%s', 
197 197
 					'%s' 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		$update = $this->db->update( 
208 208
 				$this->scheduler_table, 
209 209
 				$schedule, 
210
-				array( 'id' => $schedule_id ), 
210
+				array('id' => $schedule_id), 
211 211
 				array( 
212 212
 					'%s', 
213 213
 					'%s' 
@@ -224,25 +224,25 @@  discard block
 block discarded – undo
224 224
 		$xcloner->init();
225 225
 		$this->set_xcloner_container($xcloner);
226 226
 		
227
-		$this->xcloner_file_system 		= $this->get_xcloner_container()->get_xcloner_filesystem();
228
-		$this->xcloner_database 		= $this->get_xcloner_container()->get_xcloner_database();
229
-		$this->archive_system 			= $this->get_xcloner_container()->get_archive_system();
230
-		$this->logger 					= $this->get_xcloner_container()->get_xcloner_logger()->withName("xcloner_scheduler");
231
-		$this->xcloner_remote_storage 	= $this->get_xcloner_container()->get_xcloner_remote_storage();
227
+		$this->xcloner_file_system = $this->get_xcloner_container()->get_xcloner_filesystem();
228
+		$this->xcloner_database = $this->get_xcloner_container()->get_xcloner_database();
229
+		$this->archive_system = $this->get_xcloner_container()->get_archive_system();
230
+		$this->logger = $this->get_xcloner_container()->get_xcloner_logger()->withName("xcloner_scheduler");
231
+		$this->xcloner_remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage();
232 232
 		
233 233
 		$this->logger->info(sprintf("New schedule hash is %s", $this->xcloner_settings->get_hash()));
234 234
 		
235
-		if($schedule['backup_params']->diff_start_date)
235
+		if ($schedule['backup_params']->diff_start_date)
236 236
 		{
237 237
 			$this->xcloner_file_system->set_diff_timestamp_start($schedule['backup_params']->diff_start_date);
238 238
 		}
239 239
 				
240
-		if($schedule['recurrence'] == "single")
240
+		if ($schedule['recurrence'] == "single")
241 241
 		{
242 242
 			$this->disable_single_cron($schedule['id']);
243 243
 		}
244 244
 		
245
-		if(!$schedule)
245
+		if (!$schedule)
246 246
 		{
247 247
 			$this->logger->info(sprintf("Could not load schedule with id'%s'", $id), array("CRON"));
248 248
 			return;
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 		$init = 1;
258 258
 		$continue = 1;
259 259
 
260
-		while($continue)
260
+		while ($continue)
261 261
 		{
262 262
 			$continue = $this->xcloner_file_system->start_file_recursion($init);
263 263
 			
@@ -271,9 +271,9 @@  discard block
 block discarded – undo
271 271
 		$init = 1;
272 272
 		$return['finished'] = 0;
273 273
 		
274
-		while(!$return['finished'])
274
+		while (!$return['finished'])
275 275
 		{
276
-			$return  = $this->xcloner_database->start_database_recursion((array)json_decode($schedule['table_params']), $return, $init);
276
+			$return = $this->xcloner_database->start_database_recursion((array)json_decode($schedule['table_params']), $return, $init);
277 277
 			$init = 0;
278 278
 		}
279 279
 		
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 		$return['finished'] = 0;
286 286
 		$return['extra'] = array();
287 287
 		
288
-		while(!$return['finished'])
288
+		while (!$return['finished'])
289 289
 		{
290 290
 			$return = $this->archive_system->start_incremental_backup((array)$schedule['backup_params'], $return['extra'], $init);
291 291
 			$init = 0;
@@ -294,31 +294,31 @@  discard block
 block discarded – undo
294 294
 		
295 295
 		//getting the last backup archive file
296 296
 		$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_with_extension();
297
-		if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension()))
297
+		if ($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension()))
298 298
 				$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart();
299 299
 		
300 300
 		$this->update_last_backup($schedule['id'], $return['extra']['backup_parent']);
301 301
 		
302
-		if($schedule['remote_storage'] and array_key_exists($schedule['remote_storage'], $this->xcloner_remote_storage->get_available_storages()))
302
+		if ($schedule['remote_storage'] and array_key_exists($schedule['remote_storage'], $this->xcloner_remote_storage->get_available_storages()))
303 303
 		{
304 304
 			$backup_file = $return['extra']['backup_parent'];
305 305
 			
306 306
 			$this->logger->info(sprintf("Transferring backup to remote storage %s", strtoupper($schedule['remote_storage'])), array("CRON"));
307 307
 			
308
-			if(method_exists($this->xcloner_remote_storage, "upload_backup_to_storage"))
308
+			if (method_exists($this->xcloner_remote_storage, "upload_backup_to_storage"))
309 309
 				call_user_func_array(array($this->xcloner_remote_storage, "upload_backup_to_storage"), array($backup_file, $schedule['remote_storage']));
310 310
 		}
311 311
 		
312 312
 		
313
-		if(isset($schedule['backup_params']->email_notification) and $to=$schedule['backup_params']->email_notification)
313
+		if (isset($schedule['backup_params']->email_notification) and $to = $schedule['backup_params']->email_notification)
314 314
 		{	
315
-			try{
315
+			try {
316 316
 				$from = "XCloner Scheduler";
317 317
 				$additional['lines_total'] = $return['extra']['lines_total'];
318
-				$subject = sprintf(__("%s - new backup generated %s") , $schedule['name'], $return['extra']['backup_parent']);
318
+				$subject = sprintf(__("%s - new backup generated %s"), $schedule['name'], $return['extra']['backup_parent']);
319 319
 				
320 320
 				$this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'], $schedule, "", $additional);
321
-			}catch(Exception $e)
321
+			}catch (Exception $e)
322 322
 			{
323 323
 				$this->logger->error($e->getMessage());
324 324
 			}
@@ -333,22 +333,22 @@  discard block
 block discarded – undo
333 333
 	{
334 334
 		$schedule = $this->get_schedule_by_id($id);
335 335
 		
336
-		try{
336
+		try {
337 337
 
338 338
 			$this->__xcloner_scheduler_callback($id, $schedule);
339 339
 			
340
-		}catch(Exception $e){
340
+		}catch (Exception $e) {
341 341
 			
342 342
 			//send email to site admin if email notification is not set in the scheduler
343
-			if(!isset($schedule['backup_params']->email_notification) || !$schedule['backup_params']->email_notification)
343
+			if (!isset($schedule['backup_params']->email_notification) || !$schedule['backup_params']->email_notification)
344 344
 			{
345 345
 				$schedule['backup_params']->email_notification = get_option('admin_email');
346 346
 			}
347 347
 				
348
-			if(isset($schedule['backup_params']->email_notification) && $to=$schedule['backup_params']->email_notification)
348
+			if (isset($schedule['backup_params']->email_notification) && $to = $schedule['backup_params']->email_notification)
349 349
 			{
350 350
 				$from = "XCloner Scheduler";
351
-				$this->archive_system->send_notification($to, $from, $schedule['name']." - backup error","", "", $e->getMessage());
351
+				$this->archive_system->send_notification($to, $from, $schedule['name']." - backup error", "", "", $e->getMessage());
352 352
 			}
353 353
 			
354 354
 		}
@@ -361,10 +361,10 @@  discard block
 block discarded – undo
361 361
 		$new_schedules = array();
362 362
 		
363 363
 		foreach ($schedules as $key => $row) {
364
-			if(in_array($key, $this->allowed_schedules))
364
+			if (in_array($key, $this->allowed_schedules))
365 365
 			{
366 366
 				$new_schedules[$key] = $row;
367
-				$intervals[$key]  = $row['interval'];
367
+				$intervals[$key] = $row['interval'];
368 368
 			}
369 369
 		}
370 370
 		
Please login to merge, or discard this patch.
Braces   +17 added lines, -13 removed lines patch added patch discarded remove patch
@@ -48,10 +48,11 @@  discard block
 block discarded – undo
48 48
 		{
49 49
 			$new_list= array();
50 50
 			
51
-			foreach($list as $res)
52
-				if($res->status)
51
+			foreach($list as $res) {
52
+							if($res->status)
53 53
 				{
54 54
 					$res->next_run_time = wp_next_scheduled('xcloner_scheduler_'.$res->id, array($res->id))+(get_option( 'gmt_offset' ) * HOUR_IN_SECONDS);
55
+			}
55 56
 					$new_list[] = $res;
56 57
 				}
57 58
 			$list = $new_list;	
@@ -77,8 +78,9 @@  discard block
 block discarded – undo
77 78
 	{
78 79
 		$data = $this->db->get_row("SELECT * FROM ".$this->scheduler_table." WHERE id=".$id, ARRAY_A);
79 80
 		
80
-		if(!$data)
81
-			return false;
81
+		if(!$data) {
82
+					return false;
83
+		}
82 84
 		
83 85
 		$params = json_decode($data['params']);
84 86
 		
@@ -131,11 +133,11 @@  discard block
 block discarded – undo
131 133
 				if($schedule->recurrence == "single")
132 134
 				{
133 135
 					wp_schedule_single_event( strtotime($schedule->start_at), $hook, array($schedule->id));
134
-				}else{	
136
+				} else{	
135 137
 					wp_schedule_event( strtotime($schedule->start_at), $schedule->recurrence, $hook, array($schedule->id) );
136 138
 				}
137 139
 					
138
-			}elseif(!$schedule->status)
140
+			} elseif(!$schedule->status)
139 141
 			{
140 142
 				$timestamp = wp_next_scheduled( $hook , array($schedule->id) );
141 143
 				wp_unschedule_event( $timestamp, $hook, array($schedule->id) );
@@ -157,7 +159,7 @@  discard block
 block discarded – undo
157 159
 			if($schedule->recurrence == "single")
158 160
 			{
159 161
 				wp_schedule_single_event( strtotime($schedule->start_at), $hook, array($schedule->id));
160
-			}else{	
162
+			} else{	
161 163
 				wp_schedule_event( strtotime($schedule->start_at), $schedule->recurrence, $hook, array($schedule->id) );
162 164
 			}
163 165
 				
@@ -294,8 +296,9 @@  discard block
 block discarded – undo
294 296
 		
295 297
 		//getting the last backup archive file
296 298
 		$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_with_extension();
297
-		if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension()))
298
-				$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart();
299
+		if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension())) {
300
+						$return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart();
301
+		}
299 302
 		
300 303
 		$this->update_last_backup($schedule['id'], $return['extra']['backup_parent']);
301 304
 		
@@ -305,8 +308,9 @@  discard block
 block discarded – undo
305 308
 			
306 309
 			$this->logger->info(sprintf("Transferring backup to remote storage %s", strtoupper($schedule['remote_storage'])), array("CRON"));
307 310
 			
308
-			if(method_exists($this->xcloner_remote_storage, "upload_backup_to_storage"))
309
-				call_user_func_array(array($this->xcloner_remote_storage, "upload_backup_to_storage"), array($backup_file, $schedule['remote_storage']));
311
+			if(method_exists($this->xcloner_remote_storage, "upload_backup_to_storage")) {
312
+							call_user_func_array(array($this->xcloner_remote_storage, "upload_backup_to_storage"), array($backup_file, $schedule['remote_storage']));
313
+			}
310 314
 		}
311 315
 		
312 316
 		
@@ -318,7 +322,7 @@  discard block
 block discarded – undo
318 322
 				$subject = sprintf(__("%s - new backup generated %s") , $schedule['name'], $return['extra']['backup_parent']);
319 323
 				
320 324
 				$this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'], $schedule, "", $additional);
321
-			}catch(Exception $e)
325
+			} catch(Exception $e)
322 326
 			{
323 327
 				$this->logger->error($e->getMessage());
324 328
 			}
@@ -337,7 +341,7 @@  discard block
 block discarded – undo
337 341
 
338 342
 			$this->__xcloner_scheduler_callback($id, $schedule);
339 343
 			
340
-		}catch(Exception $e){
344
+		} catch(Exception $e){
341 345
 			
342 346
 			//send email to site admin if email notification is not set in the scheduler
343 347
 			if(!isset($schedule['backup_params']->email_notification) || !$schedule['backup_params']->email_notification)
Please login to merge, or discard this patch.
includes/class-xcloner.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
308 308
 		
309 309
 		//wp_localize_script( 'ajax-script', 'my_ajax_object',
310
-        //   array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
310
+		//   array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
311 311
 
312 312
 	}
313 313
 
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
 	
342 342
 	private function define_plugin_settings(){
343 343
 		/**
344
-		* register wporg_settings_init to the admin_init action hook
345
-		*/
344
+		 * register wporg_settings_init to the admin_init action hook
345
+		 */
346 346
 
347 347
 		$this->xcloner_settings = new XCloner_Settings($this);
348 348
 		
@@ -393,15 +393,15 @@  discard block
 block discarded – undo
393 393
 	}
394 394
 	
395 395
 	function friendly_error_type($type) {
396
-	    static $levels=null;
397
-	    if ($levels===null) {
398
-	        $levels=[];
399
-	        foreach (get_defined_constants() as $key=>$value) {
400
-	            if (strpos($key,'E_')!==0) {continue;}
396
+		static $levels=null;
397
+		if ($levels===null) {
398
+			$levels=[];
399
+			foreach (get_defined_constants() as $key=>$value) {
400
+				if (strpos($key,'E_')!==0) {continue;}
401 401
 					$levels[$value]= $key; //substr($key,2);
402
-	        }
403
-	    }
404
-	    return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}");
402
+			}
403
+		}
404
+		return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}");
405 405
 	}
406 406
 		
407 407
 	private function define_ajax_hooks()
@@ -441,19 +441,19 @@  discard block
 block discarded – undo
441 441
 			add_action( 'wp_ajax_restore_backup', 				array($xcloner_api,'restore_backup')  );
442 442
 			add_action( 'admin_notices', 						array($this, 'xcloner_error_admin_notices' ));
443 443
             
444
-        }
444
+		}
445 445
 		
446 446
 	}
447 447
 	
448 448
 	function add_plugin_action_links($links, $file) {
449
-        if ($file == plugin_basename(dirname(dirname(__FILE__)) . '/xcloner.php'))
449
+		if ($file == plugin_basename(dirname(dirname(__FILE__)) . '/xcloner.php'))
450 450
 		{	
451 451
 			$links[] = '<a href="admin.php?page=xcloner_settings_page">'.__('Settings', 'xcloner-backup-and-restore').'</a>';
452 452
 			$links[] = '<a href="admin.php?page=xcloner_generate_backups_page">'.__('Generate Backup', 'xcloner-backup-and-restore').'</a>';
453 453
 		}
454 454
         
455
-        return $links;
456
-    }
455
+		return $links;
456
+	}
457 457
 	
458 458
 	public function xcloner_error_admin_notices() {
459 459
 			settings_errors( 'xcloner_error_message' );
@@ -537,9 +537,9 @@  discard block
 block discarded – undo
537 537
 	function xcloner_display()
538 538
 	{	
539 539
 		// check user capabilities
540
-	    if (!current_user_can('manage_options')) {
541
-	        return;
542
-	    }
540
+		if (!current_user_can('manage_options')) {
541
+			return;
542
+		}
543 543
 	
544 544
 		$page = sanitize_key($_GET['page']);
545 545
 
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -148,15 +148,15 @@  discard block
 block discarded – undo
148 148
 		return $this->xcloner_file_transfer;
149 149
 	}
150 150
 	
151
-	public function check_dependencies(){
151
+	public function check_dependencies() {
152 152
 		
153 153
 		$backup_storage_path = realpath(__DIR__.DS."..".DS."..".DS."..").DS."backups".DS;
154 154
 		
155 155
 		define("XCLONER_STORAGE_PATH", realpath($backup_storage_path));
156 156
 
157
-		if(!is_dir($backup_storage_path))
157
+		if (!is_dir($backup_storage_path))
158 158
 		{
159
-			if(!@mkdir($backup_storage_path))
159
+			if (!@mkdir($backup_storage_path))
160 160
 			{
161 161
 				$status = "error";
162 162
 				$message = sprintf(__("Unable to create the Backup Storage Location Folder %s . Please fix this before starting the backup process."), $backup_storage_path);
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 				return;
165 165
 			}
166 166
 		}	
167
-		if(!is_writable($backup_storage_path))
167
+		if (!is_writable($backup_storage_path))
168 168
 		{
169 169
 			$status = "error";
170 170
 			$message = sprintf(__("Unable to write to the Backup Storage Location Folder %s . Please fix this before starting the backup process."), $backup_storage_path);
@@ -178,15 +178,15 @@  discard block
 block discarded – undo
178 178
 	public function trigger_message($message, $status = "error", $message_param1 = "", $message_param2 = "", $message_param3 = "")
179 179
 	{
180 180
 			$message = sprintf(__($message), $message_param1, $message_param2, $message_param3);
181
-			add_action( 'xcloner_admin_notices', array($this,"trigger_message_notice"), 10, 2);
182
-			do_action( 'xcloner_admin_notices', $message, $status);
181
+			add_action('xcloner_admin_notices', array($this, "trigger_message_notice"), 10, 2);
182
+			do_action('xcloner_admin_notices', $message, $status);
183 183
 	}
184 184
 	
185 185
 	public function trigger_message_notice($message, $status = "success")
186 186
 	{
187 187
 		?>
188 188
 		<div class="notice notice-<?php echo $status?> is-dismissible">
189
-	        <p><?php _e( $message, 'xcloner-backup-and-restore' ); ?></p>
189
+	        <p><?php _e($message, 'xcloner-backup-and-restore'); ?></p>
190 190
 	    </div>
191 191
 		<?php
192 192
 	}
@@ -213,79 +213,79 @@  discard block
 block discarded – undo
213 213
 		 * The class responsible for orchestrating the actions and filters of the
214 214
 		 * core plugin.
215 215
 		 */
216
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-loader.php';
216
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-loader.php';
217 217
 
218 218
 		/**
219 219
 		 * The class responsible for defining internationalization functionality
220 220
 		 * of the plugin.
221 221
 		 */
222
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-i18n.php';
222
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-i18n.php';
223 223
 
224 224
 		/**
225 225
 		 * The class responsible for defining all actions that occur in the admin area.
226 226
 		 */
227
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-xcloner-admin.php';
227
+		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-xcloner-admin.php';
228 228
 		
229 229
 		/**
230 230
 		 * The class responsible for debugging XCloner.
231 231
 		 */
232
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-logger.php';
232
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-logger.php';
233 233
 		
234 234
 		/**
235 235
 		 * The class responsible for defining the admin settings area.
236 236
 		 */
237
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-settings.php';
237
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-settings.php';
238 238
 		
239 239
 		/**
240 240
 		 * The class responsible for defining the Remote Storage settings area.
241 241
 		 */
242
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-remote-storage.php';
242
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-remote-storage.php';
243 243
 		
244 244
 		/**
245 245
 		 * The class responsible for implementing the database backup methods.
246 246
 		 */
247
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-database.php';
247
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-database.php';
248 248
 		
249 249
 		/**
250 250
 		 * The class responsible for sanitization of users input.
251 251
 		 */
252
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-sanitization.php';
252
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-sanitization.php';
253 253
 		
254 254
 		/**
255 255
 		 * The class responsible for XCloner system requirements validation.
256 256
 		 */
257
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-requirements.php';
257
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-requirements.php';
258 258
 		
259 259
 		/**
260 260
 		 * The class responsible for XCloner backup archive creation.
261 261
 		 */
262
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-archive.php';
262
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-archive.php';
263 263
 		
264 264
 		/**
265 265
 		 * The class responsible for XCloner API requests.
266 266
 		 */
267
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-api.php';
267
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-api.php';
268 268
 		
269 269
 		/**
270 270
 		 * The class responsible for the XCloner File System methods.
271 271
 		 */
272
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-file-system.php';
272
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-file-system.php';
273 273
 		
274 274
 		/**
275 275
 		 * The class responsible for the XCloner File Transfer methods.
276 276
 		 */
277
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-file-transfer.php';
277
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-file-transfer.php';
278 278
 		
279 279
 		/**
280 280
 		 * The class responsible for the XCloner Scheduler methods.
281 281
 		 */
282
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-scheduler.php';
282
+		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-scheduler.php';
283 283
 
284 284
 		/**
285 285
 		 * The class responsible for defining all actions that occur in the public-facing
286 286
 		 * side of the site.
287 287
 		 */
288
-		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-xcloner-public.php';
288
+		require_once plugin_dir_path(dirname(__FILE__)).'public/class-xcloner-public.php';
289 289
 		
290 290
 		$this->loader = new Xcloner_Loader($this);
291 291
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 
305 305
 		$plugin_i18n = new Xcloner_i18n();
306 306
 
307
-		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
307
+		$this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
308 308
 		
309 309
 		//wp_localize_script( 'ajax-script', 'my_ajax_object',
310 310
         //   array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
@@ -320,11 +320,11 @@  discard block
 block discarded – undo
320 320
 	 */
321 321
 	private function define_admin_hooks() {
322 322
 	
323
-		$plugin_admin = new Xcloner_Admin( $this );
323
+		$plugin_admin = new Xcloner_Admin($this);
324 324
 		$this->plugin_admin = $plugin_admin;
325 325
 
326
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
327
-		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
326
+		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
327
+		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
328 328
 		
329 329
 	}
330 330
 	
@@ -333,24 +333,24 @@  discard block
 block discarded – undo
333 333
 	 * 
334 334
 	 * @access 	private
335 335
 	 */
336
-	private function define_admin_menu(){
336
+	private function define_admin_menu() {
337 337
 		
338 338
 		add_action('admin_menu', array($this->loader, 'xcloner_backup_add_admin_menu'));
339 339
 		
340 340
 	}
341 341
 	
342
-	private function define_plugin_settings(){
342
+	private function define_plugin_settings() {
343 343
 		/**
344 344
 		* register wporg_settings_init to the admin_init action hook
345 345
 		*/
346 346
 
347 347
 		$this->xcloner_settings = new XCloner_Settings($this);
348 348
 		
349
-		if(defined('DOING_CRON') || isset($_POST['hash'])){
349
+		if (defined('DOING_CRON') || isset($_POST['hash'])) {
350 350
 			
351
-			if(defined('DOING_CRON') || $_POST['hash'] == "generate_hash"){
351
+			if (defined('DOING_CRON') || $_POST['hash'] == "generate_hash") {
352 352
 				$this->xcloner_settings->generate_new_hash();
353
-			}else{
353
+			} else {
354 354
 				$this->xcloner_settings->set_hash($_POST['hash']);
355 355
 			}
356 356
 		}
@@ -373,10 +373,10 @@  discard block
 block discarded – undo
373 373
 	 */
374 374
 	private function define_public_hooks() {
375 375
 
376
-		$plugin_public = new Xcloner_Public( $this );
376
+		$plugin_public = new Xcloner_Public($this);
377 377
 
378
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
379
-		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
378
+		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
379
+		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
380 380
 
381 381
 	}
382 382
 	
@@ -385,20 +385,20 @@  discard block
 block discarded – undo
385 385
 		$logger = new XCloner_Logger($this, "php_system");
386 386
 		$error = error_get_last();
387 387
 		
388
-		if($error['type'] and $logger)
388
+		if ($error['type'] and $logger)
389 389
 		{
390
-			$logger->info($this->friendly_error_type ($error['type']).": ".var_export($error, true));
390
+			$logger->info($this->friendly_error_type($error['type']).": ".var_export($error, true));
391 391
 		}
392 392
 	
393 393
 	}
394 394
 	
395 395
 	function friendly_error_type($type) {
396
-	    static $levels=null;
397
-	    if ($levels===null) {
398
-	        $levels=[];
396
+	    static $levels = null;
397
+	    if ($levels === null) {
398
+	        $levels = [];
399 399
 	        foreach (get_defined_constants() as $key=>$value) {
400
-	            if (strpos($key,'E_')!==0) {continue;}
401
-					$levels[$value]= $key; //substr($key,2);
400
+	            if (strpos($key, 'E_') !== 0) {continue; }
401
+					$levels[$value] = $key; //substr($key,2);
402 402
 	        }
403 403
 	    }
404 404
 	    return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}");
@@ -406,47 +406,47 @@  discard block
 block discarded – undo
406 406
 		
407 407
 	private function define_ajax_hooks()
408 408
 	{
409
-		if(is_admin() || defined('DOING_CRON'))
409
+		if (is_admin() || defined('DOING_CRON'))
410 410
 		{
411
-			$this->xcloner_logger 			= new XCloner_Logger($this, "xcloner_api");
412
-			$this->xcloner_filesystem 		= new Xcloner_File_System($this);
411
+			$this->xcloner_logger = new XCloner_Logger($this, "xcloner_api");
412
+			$this->xcloner_filesystem = new Xcloner_File_System($this);
413 413
 			
414 414
 			//$this->xcloner_filesystem->set_diff_timestamp_start (strtotime("-15 days"));
415 415
 			
416
-			$this->archive_system 			= new Xcloner_Archive($this);
417
-			$this->xcloner_database 		= new Xcloner_Database($this);
418
-			$this->xcloner_scheduler 		= new Xcloner_Scheduler($this);
419
-			$this->xcloner_remote_storage 	= new Xcloner_Remote_Storage($this);
420
-			$this->xcloner_file_transfer 	= new Xcloner_File_Transfer($this);
416
+			$this->archive_system = new Xcloner_Archive($this);
417
+			$this->xcloner_database = new Xcloner_Database($this);
418
+			$this->xcloner_scheduler = new Xcloner_Scheduler($this);
419
+			$this->xcloner_remote_storage = new Xcloner_Remote_Storage($this);
420
+			$this->xcloner_file_transfer = new Xcloner_File_Transfer($this);
421 421
 			
422
-			$xcloner_api 					= new Xcloner_Api($this);
422
+			$xcloner_api = new Xcloner_Api($this);
423 423
 
424
-			add_action( 'wp_ajax_get_database_tables_action', 	array($xcloner_api,'get_database_tables_action')  );
425
-			add_action( 'wp_ajax_get_file_system_action', 		array($xcloner_api,'get_file_system_action')  );
426
-			add_action( 'wp_ajax_scan_filesystem', 				array($xcloner_api,'scan_filesystem')  );
427
-			add_action( 'wp_ajax_backup_database', 				array($xcloner_api,'backup_database')  );
428
-			add_action( 'wp_ajax_backup_files'	, 				array($xcloner_api,'backup_files')  );
429
-			add_action( 'wp_ajax_save_schedule'	, 				array($xcloner_api,'save_schedule')  );
430
-			add_action( 'wp_ajax_get_schedule_by_id',	 		array($xcloner_api,'get_schedule_by_id')  );
431
-			add_action( 'wp_ajax_get_scheduler_list',	 		array($xcloner_api,'get_scheduler_list')  );
432
-			add_action( 'wp_ajax_delete_schedule_by_id'	, 		array($xcloner_api,'delete_schedule_by_id')  );
433
-			add_action( 'wp_ajax_delete_backup_by_name'	, 		array($xcloner_api,'delete_backup_by_name')  );
434
-			add_action( 'wp_ajax_download_backup_by_name', 		array($xcloner_api,'download_backup_by_name')  );
435
-			add_action( 'wp_ajax_remote_storage_save_status', 	array($xcloner_api,'remote_storage_save_status')  );
436
-			add_action( 'wp_ajax_upload_backup_to_remote', 		array($xcloner_api,'upload_backup_to_remote')  );
437
-			add_action( 'wp_ajax_list_backup_files'	,			array($xcloner_api,'list_backup_files')  );
438
-			add_action( 'wp_ajax_restore_upload_backup'	, 		array($xcloner_api,'restore_upload_backup')  );
439
-			add_action( 'wp_ajax_download_restore_script', 		array($xcloner_api,'download_restore_script')  );
440
-			add_action( 'wp_ajax_copy_backup_remote_to_local', 	array($xcloner_api,'copy_backup_remote_to_local')  );
441
-			add_action( 'wp_ajax_restore_backup', 				array($xcloner_api,'restore_backup')  );
442
-			add_action( 'admin_notices', 						array($this, 'xcloner_error_admin_notices' ));
424
+			add_action('wp_ajax_get_database_tables_action', array($xcloner_api, 'get_database_tables_action'));
425
+			add_action('wp_ajax_get_file_system_action', array($xcloner_api, 'get_file_system_action'));
426
+			add_action('wp_ajax_scan_filesystem', array($xcloner_api, 'scan_filesystem'));
427
+			add_action('wp_ajax_backup_database', array($xcloner_api, 'backup_database'));
428
+			add_action('wp_ajax_backup_files', array($xcloner_api, 'backup_files'));
429
+			add_action('wp_ajax_save_schedule', array($xcloner_api, 'save_schedule'));
430
+			add_action('wp_ajax_get_schedule_by_id', array($xcloner_api, 'get_schedule_by_id'));
431
+			add_action('wp_ajax_get_scheduler_list', array($xcloner_api, 'get_scheduler_list'));
432
+			add_action('wp_ajax_delete_schedule_by_id', array($xcloner_api, 'delete_schedule_by_id'));
433
+			add_action('wp_ajax_delete_backup_by_name', array($xcloner_api, 'delete_backup_by_name'));
434
+			add_action('wp_ajax_download_backup_by_name', array($xcloner_api, 'download_backup_by_name'));
435
+			add_action('wp_ajax_remote_storage_save_status', array($xcloner_api, 'remote_storage_save_status'));
436
+			add_action('wp_ajax_upload_backup_to_remote', array($xcloner_api, 'upload_backup_to_remote'));
437
+			add_action('wp_ajax_list_backup_files', array($xcloner_api, 'list_backup_files'));
438
+			add_action('wp_ajax_restore_upload_backup', array($xcloner_api, 'restore_upload_backup'));
439
+			add_action('wp_ajax_download_restore_script', array($xcloner_api, 'download_restore_script'));
440
+			add_action('wp_ajax_copy_backup_remote_to_local', array($xcloner_api, 'copy_backup_remote_to_local'));
441
+			add_action('wp_ajax_restore_backup', array($xcloner_api, 'restore_backup'));
442
+			add_action('admin_notices', array($this, 'xcloner_error_admin_notices'));
443 443
             
444 444
         }
445 445
 		
446 446
 	}
447 447
 	
448 448
 	function add_plugin_action_links($links, $file) {
449
-        if ($file == plugin_basename(dirname(dirname(__FILE__)) . '/xcloner.php'))
449
+        if ($file == plugin_basename(dirname(dirname(__FILE__)).'/xcloner.php'))
450 450
 		{	
451 451
 			$links[] = '<a href="admin.php?page=xcloner_settings_page">'.__('Settings', 'xcloner-backup-and-restore').'</a>';
452 452
 			$links[] = '<a href="admin.php?page=xcloner_generate_backups_page">'.__('Generate Backup', 'xcloner-backup-and-restore').'</a>';
@@ -456,13 +456,13 @@  discard block
 block discarded – undo
456 456
     }
457 457
 	
458 458
 	public function xcloner_error_admin_notices() {
459
-			settings_errors( 'xcloner_error_message' );
459
+			settings_errors('xcloner_error_message');
460 460
 		}
461 461
 	
462 462
 	public function define_cron_hooks()
463 463
 	{
464 464
 		//registering new schedule intervals
465
-		add_filter( 'cron_schedules', array($this, 'add_new_intervals'));
465
+		add_filter('cron_schedules', array($this, 'add_new_intervals'));
466 466
 			
467 467
 		
468 468
 		$xcloner_scheduler = $this->get_xcloner_scheduler();
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 	
544 544
 		$page = sanitize_key($_GET['page']);
545 545
 
546
-		if($page)
546
+		if ($page)
547 547
 		{
548 548
 			$this->display($page);
549 549
 		}
Please login to merge, or discard this patch.