@@ -337,7 +337,7 @@ |
||
| 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 | |
@@ -96,7 +96,7 @@ |
||
| 96 | 96 | try { |
| 97 | 97 | mkdir($path); |
| 98 | 98 | chmod($path, 0777); |
| 99 | - }catch(Exception $e){ |
|
| 99 | + }catch (Exception $e) { |
|
| 100 | 100 | //silent catch |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -172,7 +172,7 @@ |
||
| 172 | 172 | |
| 173 | 173 | $property = str_replace("get_", "", $property); |
| 174 | 174 | |
| 175 | - if(property_exists($this, $property)){ |
|
| 175 | + if (property_exists($this, $property)) { |
|
| 176 | 176 | return $this->$property; |
| 177 | 177 | } |
| 178 | 178 | } |
@@ -905,7 +905,7 @@ discard block |
||
| 905 | 905 | $backup_file = $backup_parts[$return['part']]; |
| 906 | 906 | } |
| 907 | 907 | |
| 908 | - if( $this->is_encrypted_file($backup_file) ) { |
|
| 908 | + if ($this->is_encrypted_file($backup_file)) { |
|
| 909 | 909 | $message = sprintf('Backup file %s seems encrypted, please Decrypt it first from your Manage Backups panel.', $backup_file); |
| 910 | 910 | $this->logger->error($message); |
| 911 | 911 | $this->send_response(500, $message); |
@@ -962,7 +962,7 @@ discard block |
||
| 962 | 962 | * @return bool |
| 963 | 963 | */ |
| 964 | 964 | public function is_encrypted_file($filename) { |
| 965 | - $fp = $this->filesystem->readStream( $filename ); |
|
| 965 | + $fp = $this->filesystem->readStream($filename); |
|
| 966 | 966 | if (is_resource($fp)) { |
| 967 | 967 | $encryption_length = fread($fp, 16); |
| 968 | 968 | fclose($fp); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | $this->archive_name = $this->filesystem->process_backup_name($name); |
| 151 | 151 | |
| 152 | - if($encrypt_prefix) { |
|
| 152 | + if ($encrypt_prefix) { |
|
| 153 | 153 | $this->archive_name .= $this->encrypt_suffix; |
| 154 | 154 | } |
| 155 | 155 | |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | $this->set_archive_name($extra_params['backup_archive_name'], $return['extra']['backup_part']); |
| 368 | 368 | } else { |
| 369 | 369 | $encrypt = false; |
| 370 | - if(isset($backup_params['backup_encrypt']) && $backup_params['backup_encrypt']) { |
|
| 370 | + if (isset($backup_params['backup_encrypt']) && $backup_params['backup_encrypt']) { |
|
| 371 | 371 | $encrypt = true; |
| 372 | 372 | } |
| 373 | 373 | $this->set_archive_name($backup_params['backup_name'], 0, $encrypt); |
@@ -180,14 +180,14 @@ discard block |
||
| 180 | 180 | foreach ($array as $key => $type) { |
| 181 | 181 | |
| 182 | 182 | if ($type == "raw") { |
| 183 | - add_filter("pre_update_option_" . $this->storage_fields['option_prefix'] . $key, |
|
| 184 | - function ($value) { |
|
| 183 | + add_filter("pre_update_option_".$this->storage_fields['option_prefix'].$key, |
|
| 184 | + function($value) { |
|
| 185 | 185 | |
| 186 | 186 | return $this->simple_crypt($value, 'e'); |
| 187 | 187 | |
| 188 | 188 | }, 10, 1); |
| 189 | 189 | |
| 190 | - add_filter("option_" . $this->storage_fields['option_prefix'] . $key, function ($value) { |
|
| 190 | + add_filter("option_".$this->storage_fields['option_prefix'].$key, function($value) { |
|
| 191 | 191 | |
| 192 | 192 | return $this->simple_crypt($value, 'd'); |
| 193 | 193 | |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | { |
| 248 | 248 | $return = array(); |
| 249 | 249 | foreach ($this->storage_fields as $storage => $data) { |
| 250 | - $check_field = $this->storage_fields["option_prefix"] . $storage . "_enable"; |
|
| 250 | + $check_field = $this->storage_fields["option_prefix"].$storage."_enable"; |
|
| 251 | 251 | if (get_option($check_field)) { |
| 252 | 252 | $return[$storage] = $data['text']; |
| 253 | 253 | } |
@@ -267,8 +267,8 @@ discard block |
||
| 267 | 267 | |
| 268 | 268 | if (is_array($this->storage_fields[$storage])) { |
| 269 | 269 | foreach ($this->storage_fields[$storage] as $field => $validation) { |
| 270 | - $check_field = $this->storage_fields["option_prefix"] . $field; |
|
| 271 | - $sanitize_method = "sanitize_input_as_" . $validation; |
|
| 270 | + $check_field = $this->storage_fields["option_prefix"].$field; |
|
| 271 | + $sanitize_method = "sanitize_input_as_".$validation; |
|
| 272 | 272 | |
| 273 | 273 | if (!isset($_POST[$check_field])) { |
| 274 | 274 | $_POST[$check_field] = 0; |
@@ -295,8 +295,8 @@ discard block |
||
| 295 | 295 | $this->xcloner->trigger_message(__("%s connection is valid.", 'xcloner-backup-and-restore'), "success", |
| 296 | 296 | $this->storage_fields[$action]['text']); |
| 297 | 297 | $this->logger->debug(sprintf("Connection to remote storage %s is valid", strtoupper($action))); |
| 298 | - } catch (Exception $e) { |
|
| 299 | - $this->xcloner->trigger_message("%s connection error: " . $e->getMessage(), "error", |
|
| 298 | + }catch (Exception $e) { |
|
| 299 | + $this->xcloner->trigger_message("%s connection error: ".$e->getMessage(), "error", |
|
| 300 | 300 | $this->storage_fields[$action]['text']); |
| 301 | 301 | } |
| 302 | 302 | } |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | */ |
| 307 | 307 | public function verify_filesystem($storage_type) |
| 308 | 308 | { |
| 309 | - $method = "get_" . $storage_type . "_filesystem"; |
|
| 309 | + $method = "get_".$storage_type."_filesystem"; |
|
| 310 | 310 | |
| 311 | 311 | $this->logger->info(sprintf("Checking validity of the remote storage %s filesystem", |
| 312 | 312 | strtoupper($storage_type))); |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | |
| 318 | 318 | list($adapter, $filesystem) = $this->$method(); |
| 319 | 319 | |
| 320 | - $test_file = substr(".xcloner_" . md5(time()), 0, 15); |
|
| 320 | + $test_file = substr(".xcloner_".md5(time()), 0, 15); |
|
| 321 | 321 | |
| 322 | 322 | if ($storage_type == "gdrive") { |
| 323 | 323 | if (!is_array($filesystem->listContents())) { |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | return false; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - $method = "get_" . $storage . "_filesystem"; |
|
| 360 | + $method = "get_".$storage."_filesystem"; |
|
| 361 | 361 | |
| 362 | 362 | if (!method_exists($this, $method)) { |
| 363 | 363 | return false; |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | |
| 409 | 409 | public function copy_backup_remote_to_local($file, $storage) |
| 410 | 410 | { |
| 411 | - $method = "get_" . $storage . "_filesystem"; |
|
| 411 | + $method = "get_".$storage."_filesystem"; |
|
| 412 | 412 | |
| 413 | 413 | $target_filename = $file; |
| 414 | 414 | |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | |
| 427 | 427 | if ($storage == "gdrive") { |
| 428 | 428 | $metadata = $remote_storage_filesystem->getMetadata($file); |
| 429 | - $target_filename = $metadata['filename'] . "." . $metadata['extension']; |
|
| 429 | + $target_filename = $metadata['filename'].".".$metadata['extension']; |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | $this->logger->info(sprintf("Transferring backup %s to local storage from %s storage", $file, |
@@ -464,13 +464,13 @@ discard block |
||
| 464 | 464 | |
| 465 | 465 | public function clean_remote_storage($storage, $remote_storage_filesystem) |
| 466 | 466 | { |
| 467 | - $check_field = $this->storage_fields["option_prefix"] . $storage . "_cleanup_days"; |
|
| 467 | + $check_field = $this->storage_fields["option_prefix"].$storage."_cleanup_days"; |
|
| 468 | 468 | if ($expire_days = get_option($check_field)) { |
| 469 | 469 | $this->logger->info(sprintf("Doing %s remote storage cleanup for %s days limit", strtoupper($storage), |
| 470 | 470 | $expire_days)); |
| 471 | 471 | $files = $remote_storage_filesystem->listContents(); |
| 472 | 472 | |
| 473 | - $current_timestamp = strtotime("-" . $expire_days . " days"); |
|
| 473 | + $current_timestamp = strtotime("-".$expire_days." days"); |
|
| 474 | 474 | |
| 475 | 475 | if (is_array($files)) { |
| 476 | 476 | foreach ($files as $file) { |
@@ -478,9 +478,9 @@ discard block |
||
| 478 | 478 | |
| 479 | 479 | if ($current_timestamp >= $file['timestamp']) { |
| 480 | 480 | $remote_storage_filesystem->delete($file['path']); |
| 481 | - $this->logger->info("Deleting remote file " . $file['path'] . " matching rule", array( |
|
| 481 | + $this->logger->info("Deleting remote file ".$file['path']." matching rule", array( |
|
| 482 | 482 | "RETENTION LIMIT TIMESTAMP", |
| 483 | - $file['timestamp'] . " =< " . $expire_days |
|
| 483 | + $file['timestamp']." =< ".$expire_days |
|
| 484 | 484 | )); |
| 485 | 485 | } |
| 486 | 486 | |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | update_option("xcloner_gdrive_access_token", $token['access_token']); |
| 677 | 677 | update_option("xcloner_gdrive_refresh_token", $token['refresh_token']); |
| 678 | 678 | |
| 679 | - $redirect_url = ('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?page=xcloner_remote_storage_page#gdrive"); |
|
| 679 | + $redirect_url = ('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?page=xcloner_remote_storage_page#gdrive"); |
|
| 680 | 680 | |
| 681 | 681 | ?> |
| 682 | 682 | <script> |
@@ -798,7 +798,7 @@ discard block |
||
| 798 | 798 | |
| 799 | 799 | /** optional config settings */ |
| 800 | 800 | 'port' => get_option("xcloner_sftp_port", 22), |
| 801 | - 'root' => (get_option("xcloner_sftp_path")?get_option("xcloner_sftp_path"):'./'), |
|
| 801 | + 'root' => (get_option("xcloner_sftp_path") ?get_option("xcloner_sftp_path") : './'), |
|
| 802 | 802 | 'privateKey' => get_option("xcloner_sftp_private_key"), |
| 803 | 803 | 'timeout' => get_option("xcloner_ftp_timeout", 30), |
| 804 | 804 | ]); |