@@ -26,6 +26,6 @@ |
||
26 | 26 | */ |
27 | 27 | |
28 | 28 | // If uninstall not called from WordPress, then exit. |
29 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
29 | +if (!defined('WP_UNINSTALL_PLUGIN')) { |
|
30 | 30 | exit; |
31 | 31 | } |
@@ -37,7 +37,7 @@ |
||
37 | 37 | load_plugin_textdomain( |
38 | 38 | 'xcloner-backup-and-restore', |
39 | 39 | false, |
40 | - dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' |
|
40 | + dirname(dirname(plugin_basename(__FILE__))).'/languages/' |
|
41 | 41 | ); |
42 | 42 | |
43 | 43 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$xcloner_settings = $this->get_xcloner_container()->get_xcloner_settings(); |
|
4 | -$logger = $this->get_xcloner_container()->get_xcloner_logger(); |
|
5 | -$logger_content = $logger->getLastDebugLines(); |
|
3 | +$xcloner_settings = $this->get_xcloner_container()->get_xcloner_settings(); |
|
4 | +$logger = $this->get_xcloner_container()->get_xcloner_logger(); |
|
5 | +$logger_content = $logger->getLastDebugLines(); |
|
6 | 6 | ?> |
7 | 7 | <div class="col s12 "> |
8 | 8 | <div> |
@@ -10,12 +10,12 @@ discard block |
||
10 | 10 | <?php echo __('XCloner Debugger Dashboard', 'xcloner-backup-and-restore') ?> |
11 | 11 | </h5> |
12 | 12 | |
13 | - <?php if($xcloner_settings->get_xcloner_option('xcloner_enable_log')) :?> |
|
13 | + <?php if ($xcloner_settings->get_xcloner_option('xcloner_enable_log')) :?> |
|
14 | 14 | <ul class="collapsible xcloner-debugger" data-collapsible="accordion"> |
15 | 15 | <li class="active"> |
16 | 16 | <div class="collapsible-header active"><i class="material-icons">bug_report</i>XCloner Debugger</div> |
17 | 17 | <div class="collapsible-body"> |
18 | - <div class="console" id="xcloner-console"><?php if(isset($logger_content)) echo implode("<br />\n", $logger_content); ?></div> |
|
18 | + <div class="console" id="xcloner-console"><?php if (isset($logger_content)) echo implode("<br />\n", $logger_content); ?></div> |
|
19 | 19 | </div> |
20 | 20 | </li> |
21 | 21 | </ul> |
@@ -28,6 +28,6 @@ discard block |
||
28 | 28 | }, 2000);*/ |
29 | 29 | }) |
30 | 30 | </script> |
31 | - <?php endif;?> |
|
31 | + <?php endif; ?> |
|
32 | 32 | </div> |
33 | 33 | </div> |
@@ -58,19 +58,19 @@ discard block |
||
58 | 58 | |
59 | 59 | public function xcloner_backup_add_admin_menu() |
60 | 60 | { |
61 | - if ( function_exists('add_menu_page') ) |
|
62 | - add_menu_page( __('Site Backup','xcloner-backup-and-restore'), __('Site Backup','xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page', array($this->xcloner_container, 'xcloner_display'), 'dashicons-backup'); |
|
61 | + if (function_exists('add_menu_page')) |
|
62 | + add_menu_page(__('Site Backup', 'xcloner-backup-and-restore'), __('Site Backup', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page', array($this->xcloner_container, 'xcloner_display'), 'dashicons-backup'); |
|
63 | 63 | |
64 | - if ( function_exists('add_submenu_page') ) |
|
64 | + if (function_exists('add_submenu_page')) |
|
65 | 65 | { |
66 | 66 | |
67 | - add_submenu_page( 'xcloner_init_page', __('XCloner Dashboard','xcloner-backup-and-restore'), __('Dashboard','xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page', array($this->xcloner_container, 'xcloner_display')); |
|
68 | - add_submenu_page( 'xcloner_init_page', __('XCloner Backup Settings','xcloner-backup-and-restore'), __('Settings','xcloner-backup-and-restore'), 'manage_options', 'xcloner_settings_page', array($this->xcloner_container, 'xcloner_display')); |
|
69 | - add_submenu_page( 'xcloner_init_page', __('Remote Storage Settings','xcloner-backup-and-restore'), __('Remote Storage','xcloner-backup-and-restore'), 'manage_options', 'xcloner_remote_storage_page', array($this->xcloner_container, 'xcloner_display')); |
|
70 | - add_submenu_page( 'xcloner_init_page', __('Manage Backups','xcloner-backup-and-restore'), __('Manage Backups','xcloner-backup-and-restore'), 'manage_options', 'xcloner_manage_backups_page', array($this->xcloner_container, 'xcloner_display')); |
|
71 | - add_submenu_page( 'xcloner_init_page', __('Scheduled Backups','xcloner-backup-and-restore'), __('Scheduled Backups','xcloner-backup-and-restore'), 'manage_options', 'xcloner_scheduled_backups_page', array($this->xcloner_container, 'xcloner_display')); |
|
72 | - add_submenu_page( 'xcloner_init_page', __('Generate Backups','xcloner-backup-and-restore'), __('Generate Backups','xcloner-backup-and-restore'), 'manage_options', 'xcloner_generate_backups_page', array($this->xcloner_container, 'xcloner_display')); |
|
73 | - add_submenu_page( 'xcloner_init_page', __('Restore Backups','xcloner-backup-and-restore'), __('Restore Backups','xcloner-backup-and-restore'), 'manage_options', 'xcloner_restore_page', array($this->xcloner_container, 'xcloner_display')); |
|
67 | + add_submenu_page('xcloner_init_page', __('XCloner Dashboard', 'xcloner-backup-and-restore'), __('Dashboard', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_init_page', array($this->xcloner_container, 'xcloner_display')); |
|
68 | + add_submenu_page('xcloner_init_page', __('XCloner Backup Settings', 'xcloner-backup-and-restore'), __('Settings', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_settings_page', array($this->xcloner_container, 'xcloner_display')); |
|
69 | + add_submenu_page('xcloner_init_page', __('Remote Storage Settings', 'xcloner-backup-and-restore'), __('Remote Storage', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_remote_storage_page', array($this->xcloner_container, 'xcloner_display')); |
|
70 | + add_submenu_page('xcloner_init_page', __('Manage Backups', 'xcloner-backup-and-restore'), __('Manage Backups', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_manage_backups_page', array($this->xcloner_container, 'xcloner_display')); |
|
71 | + add_submenu_page('xcloner_init_page', __('Scheduled Backups', 'xcloner-backup-and-restore'), __('Scheduled Backups', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_scheduled_backups_page', array($this->xcloner_container, 'xcloner_display')); |
|
72 | + add_submenu_page('xcloner_init_page', __('Generate Backups', 'xcloner-backup-and-restore'), __('Generate Backups', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_generate_backups_page', array($this->xcloner_container, 'xcloner_display')); |
|
73 | + add_submenu_page('xcloner_init_page', __('Restore Backups', 'xcloner-backup-and-restore'), __('Restore Backups', 'xcloner-backup-and-restore'), 'manage_options', 'xcloner_restore_page', array($this->xcloner_container, 'xcloner_display')); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | } |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | * @param int $priority Optional. he priority at which the function should be fired. Default is 10. |
87 | 87 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. |
88 | 88 | */ |
89 | - public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
90 | - $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); |
|
89 | + public function add_action($hook, $component, $callback, $priority = 10, $accepted_args = 1) { |
|
90 | + $this->actions = $this->add($this->actions, $hook, $component, $callback, $priority, $accepted_args); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | * @param int $priority Optional. he priority at which the function should be fired. Default is 10. |
101 | 101 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1 |
102 | 102 | */ |
103 | - public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
104 | - $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); |
|
103 | + public function add_filter($hook, $component, $callback, $priority = 10, $accepted_args = 1) { |
|
104 | + $this->filters = $this->add($this->filters, $hook, $component, $callback, $priority, $accepted_args); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @param int $accepted_args The number of arguments that should be passed to the $callback. |
119 | 119 | * @return array The collection of actions and filters registered with WordPress. |
120 | 120 | */ |
121 | - private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { |
|
121 | + private function add($hooks, $hook, $component, $callback, $priority, $accepted_args) { |
|
122 | 122 | |
123 | 123 | $hooks[] = array( |
124 | 124 | 'hook' => $hook, |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function run() { |
141 | 141 | |
142 | - foreach ( $this->filters as $hook ) { |
|
143 | - add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
142 | + foreach ($this->filters as $hook) { |
|
143 | + add_filter($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']); |
|
144 | 144 | } |
145 | 145 | |
146 | - foreach ( $this->actions as $hook ) { |
|
147 | - add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
146 | + foreach ($this->actions as $hook) { |
|
147 | + add_action($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | |
4 | 4 | class Xcloner_Sanitization { |
5 | 5 | |
6 | - public function __construct(){} |
|
6 | + public function __construct() {} |
|
7 | 7 | |
8 | 8 | public function sanitize_input_as_int($option) |
9 | 9 | { |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | { |
25 | 25 | $path = filter_var($option, FILTER_SANITIZE_URL); |
26 | 26 | |
27 | - try{ |
|
27 | + try { |
|
28 | 28 | $option = Util::normalizePath($path); |
29 | - }catch(Exception $e){ |
|
29 | + }catch (Exception $e) { |
|
30 | 30 | add_settings_error('xcloner_error_message', '', __($e->getMessage()), 'error'); |
31 | 31 | } |
32 | 32 | |
33 | - if($path and !is_dir($path)){ |
|
34 | - add_settings_error('xcloner_error_message', '', __(sprintf('Invalid Server Path %s',$option)), 'error'); |
|
33 | + if ($path and !is_dir($path)) { |
|
34 | + add_settings_error('xcloner_error_message', '', __(sprintf('Invalid Server Path %s', $option)), 'error'); |
|
35 | 35 | return false; |
36 | 36 | } |
37 | 37 |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | class Xcloner_Requirements |
4 | 4 | { |
5 | 5 | |
6 | - var $min_php_version = "5.4.0"; |
|
7 | - var $safe_mode = "Off"; |
|
6 | + var $min_php_version = "5.4.0"; |
|
7 | + var $safe_mode = "Off"; |
|
8 | 8 | |
9 | 9 | private $xcloner_settings; |
10 | 10 | private $xcloner_container; |
@@ -22,19 +22,19 @@ discard block |
||
22 | 22 | |
23 | 23 | public function check_backup_ready_status() |
24 | 24 | { |
25 | - if(!$this->check_min_php_version(1)) |
|
25 | + if (!$this->check_min_php_version(1)) |
|
26 | 26 | return false; |
27 | 27 | |
28 | - if(!$this->check_safe_mode(1)) |
|
28 | + if (!$this->check_safe_mode(1)) |
|
29 | 29 | return false; |
30 | 30 | |
31 | - if(!$this->check_xcloner_start_path(1)) |
|
31 | + if (!$this->check_xcloner_start_path(1)) |
|
32 | 32 | return false; |
33 | 33 | |
34 | - if(!$this->check_xcloner_store_path(1)) |
|
34 | + if (!$this->check_xcloner_store_path(1)) |
|
35 | 35 | return false; |
36 | 36 | |
37 | - if(!$this->check_xcloner_tmp_path(1)) |
|
37 | + if (!$this->check_xcloner_tmp_path(1)) |
|
38 | 38 | return false; |
39 | 39 | |
40 | 40 | return true; |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | public function check_min_php_version($return_bool = 0) |
49 | 49 | { |
50 | 50 | |
51 | - if($return_bool == 1) |
|
51 | + if ($return_bool == 1) |
|
52 | 52 | { |
53 | - if(version_compare(phpversion(), $this->min_php_version, '<')) |
|
53 | + if (version_compare(phpversion(), $this->min_php_version, '<')) |
|
54 | 54 | return false; |
55 | 55 | else |
56 | 56 | return true; |
@@ -59,31 +59,31 @@ discard block |
||
59 | 59 | return phpversion(); |
60 | 60 | } |
61 | 61 | |
62 | - public function check_safe_mode($return_bool=0) |
|
62 | + public function check_safe_mode($return_bool = 0) |
|
63 | 63 | { |
64 | 64 | $safe_mode = "Off"; |
65 | 65 | |
66 | - if($return_bool) |
|
66 | + if ($return_bool) |
|
67 | 67 | { |
68 | - if( ini_get('safe_mode') ) |
|
68 | + if (ini_get('safe_mode')) |
|
69 | 69 | return false; |
70 | 70 | else |
71 | 71 | return true; |
72 | 72 | } |
73 | 73 | |
74 | - if( ini_get('safe_mode') ) |
|
74 | + if (ini_get('safe_mode')) |
|
75 | 75 | $safe_mode = "On"; |
76 | 76 | |
77 | 77 | return $safe_mode; |
78 | 78 | } |
79 | 79 | |
80 | - public function check_xcloner_start_path($return_bool=0) |
|
80 | + public function check_xcloner_start_path($return_bool = 0) |
|
81 | 81 | { |
82 | 82 | $path = $this->xcloner_settings->get_xcloner_start_path(); |
83 | 83 | |
84 | - if($return_bool) |
|
84 | + if ($return_bool) |
|
85 | 85 | { |
86 | - if(!file_exists($path)) |
|
86 | + if (!file_exists($path)) |
|
87 | 87 | return false; |
88 | 88 | |
89 | 89 | return is_readable($path); |
@@ -92,16 +92,16 @@ discard block |
||
92 | 92 | return $path; |
93 | 93 | } |
94 | 94 | |
95 | - public function check_xcloner_tmp_path($return_bool=0) |
|
95 | + public function check_xcloner_tmp_path($return_bool = 0) |
|
96 | 96 | { |
97 | 97 | $path = $this->xcloner_settings->get_xcloner_tmp_path(); |
98 | 98 | |
99 | - if($return_bool) |
|
99 | + if ($return_bool) |
|
100 | 100 | { |
101 | - if(!file_exists($path)) |
|
101 | + if (!file_exists($path)) |
|
102 | 102 | return false; |
103 | 103 | |
104 | - if(!is_writeable($path)) |
|
104 | + if (!is_writeable($path)) |
|
105 | 105 | @chmod($path, 0777); |
106 | 106 | |
107 | 107 | return is_writeable($path); |
@@ -110,16 +110,16 @@ discard block |
||
110 | 110 | return $path; |
111 | 111 | } |
112 | 112 | |
113 | - public function check_xcloner_store_path($return_bool=0) |
|
113 | + public function check_xcloner_store_path($return_bool = 0) |
|
114 | 114 | { |
115 | 115 | $path = $this->xcloner_settings->get_xcloner_store_path(); |
116 | 116 | |
117 | - if($return_bool) |
|
117 | + if ($return_bool) |
|
118 | 118 | { |
119 | - if(!file_exists($path)) |
|
119 | + if (!file_exists($path)) |
|
120 | 120 | return false; |
121 | 121 | |
122 | - if(!is_writeable($path)) |
|
122 | + if (!is_writeable($path)) |
|
123 | 123 | @chmod($path, 0777); |
124 | 124 | |
125 | 125 | return is_writeable($path); |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | |
141 | 141 | public function get_open_basedir() |
142 | 142 | { |
143 | - $open_basedir = ini_get('open_basedir'); |
|
143 | + $open_basedir = ini_get('open_basedir'); |
|
144 | 144 | |
145 | - if(!$open_basedir) |
|
145 | + if (!$open_basedir) |
|
146 | 146 | $open_basedir = "none"; |
147 | 147 | return $open_basedir; |
148 | 148 | } |
@@ -156,14 +156,14 @@ discard block |
||
156 | 156 | $unit_list = array('B', 'KB', 'MB', 'GB', 'PB'); |
157 | 157 | |
158 | 158 | if ($bytes == 0) { |
159 | - return $bytes . ' ' . $unit_list[0]; |
|
159 | + return $bytes.' '.$unit_list[0]; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | $unit_count = count($unit_list); |
163 | 163 | for ($i = $unit_count - 1; $i >= 0; $i--) { |
164 | 164 | $power = $i * 10; |
165 | 165 | if (($bytes >> $power) >= 1) |
166 | - return round($bytes / (1 << $power), $decimals) . ' ' . $unit_list[$i]; |
|
166 | + return round($bytes / (1 << $power), $decimals).' '.$unit_list[$i]; |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | } |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | * @param string $plugin_name The name of the plugin. |
48 | 48 | * @param string $version The version of this plugin. |
49 | 49 | */ |
50 | - public function __construct( Xcloner $xcloner_container ) { |
|
50 | + public function __construct(Xcloner $xcloner_container) { |
|
51 | 51 | |
52 | - $this->plugin_name = $xcloner_container->get_plugin_name(); |
|
53 | - $this->version = $xcloner_container->get_version(); |
|
52 | + $this->plugin_name = $xcloner_container->get_plugin_name(); |
|
53 | + $this->version = $xcloner_container->get_version(); |
|
54 | 54 | |
55 | 55 | } |
56 | 56 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * class. |
74 | 74 | */ |
75 | 75 | |
76 | - wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/xcloner-public.css', array(), $this->version, 'all' ); |
|
76 | + wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__).'css/xcloner-public.css', array(), $this->version, 'all'); |
|
77 | 77 | |
78 | 78 | } |
79 | 79 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * class. |
97 | 97 | */ |
98 | 98 | |
99 | - wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/xcloner-public.js', array( 'jquery' ), $this->version, false ); |
|
99 | + wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__).'js/xcloner-public.js', array('jquery'), $this->version, false); |
|
100 | 100 | |
101 | 101 | } |
102 | 102 |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$xcloner_file_system = $this->get_xcloner_container()->get_xcloner_filesystem(); |
|
4 | -$xcloner_sanitization = $this->get_xcloner_container()->get_xcloner_sanitization(); |
|
5 | -$xcloner_remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage(); |
|
6 | -$storage_selection = ""; |
|
3 | +$xcloner_file_system = $this->get_xcloner_container()->get_xcloner_filesystem(); |
|
4 | +$xcloner_sanitization = $this->get_xcloner_container()->get_xcloner_sanitization(); |
|
5 | +$xcloner_remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage(); |
|
6 | +$storage_selection = ""; |
|
7 | 7 | |
8 | -if(isset($_GET['storage_selection']) and $_GET['storage_selection']) |
|
8 | +if (isset($_GET['storage_selection']) and $_GET['storage_selection']) |
|
9 | 9 | { |
10 | 10 | $storage_selection = $xcloner_sanitization->sanitize_input_as_string($_GET['storage_selection']); |
11 | 11 | } |
@@ -21,18 +21,18 @@ discard block |
||
21 | 21 | <div class="col s12 m6 l9"> |
22 | 22 | <h1><?= esc_html(get_admin_page_title()); ?></h1> |
23 | 23 | </div> |
24 | - <?php if(sizeof($available_storages)):?> |
|
24 | + <?php if (sizeof($available_storages)):?> |
|
25 | 25 | <div class="col s12 m6 l3 remote-storage-selection"> |
26 | 26 | <select name="storage_selection" id="storage_selection" class="validate" required > |
27 | 27 | |
28 | - <?php if($storage_selection):?> |
|
28 | + <?php if ($storage_selection):?> |
|
29 | 29 | <option value="" selected><?php echo __('Change To Local Storage...', 'xcloner-backup-and-restore') ?></option> |
30 | 30 | <?php else: ?> |
31 | 31 | <option value="" selected><?php echo __('Change To Remote Storage...', 'xcloner-backup-and-restore') ?></option> |
32 | - <?php endif;?> |
|
32 | + <?php endif; ?> |
|
33 | 33 | |
34 | - <?php foreach($available_storages as $storage=>$text):?> |
|
35 | - <option value="<?php echo $storage?>"<?php if($storage == $storage_selection) echo "selected"?>><?php echo $text?></option> |
|
34 | + <?php foreach ($available_storages as $storage=>$text):?> |
|
35 | + <option value="<?php echo $storage?>"<?php if ($storage == $storage_selection) echo "selected"?>><?php echo $text?></option> |
|
36 | 36 | <?php endforeach?> |
37 | 37 | </select> |
38 | 38 | <?php endif?> |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | <label for="select_all"> </label> |
48 | 48 | </p> |
49 | 49 | </th> |
50 | - <th data-field="id"><?php echo __("Backup Name",'xcloner-backup-and-restore')?></th> |
|
51 | - <th data-field="name"><?php echo __("Created Time",'xcloner-backup-and-restore')?></th> |
|
52 | - <th data-field="name"><?php echo __("Size",'xcloner-backup-and-restore')?></th> |
|
53 | - <th class="no-sort" data-field="price"><?php echo __("Action",'xcloner-backup-and-restore')?></th> |
|
50 | + <th data-field="id"><?php echo __("Backup Name", 'xcloner-backup-and-restore')?></th> |
|
51 | + <th data-field="name"><?php echo __("Created Time", 'xcloner-backup-and-restore')?></th> |
|
52 | + <th data-field="name"><?php echo __("Size", 'xcloner-backup-and-restore')?></th> |
|
53 | + <th class="no-sort" data-field="price"><?php echo __("Action", 'xcloner-backup-and-restore')?></th> |
|
54 | 54 | |
55 | 55 | </tr> |
56 | 56 | </thead> |
@@ -60,20 +60,20 @@ discard block |
||
60 | 60 | |
61 | 61 | <?php |
62 | 62 | $i = 0; |
63 | -foreach($backup_list as $file_info):?> |
|
63 | +foreach ($backup_list as $file_info):?> |
|
64 | 64 | <?php |
65 | - if($storage_selection == "gdrive") |
|
65 | + if ($storage_selection == "gdrive") |
|
66 | 66 | $file_info['path'] = $file_info['filename'].".".$file_info['extension']; |
67 | 67 | $file_exists_on_local_storage = true; |
68 | 68 | |
69 | - if($storage_selection) |
|
69 | + if ($storage_selection) |
|
70 | 70 | { |
71 | - if(!$xcloner_file_system->get_storage_filesystem()->has($file_info['path'])) |
|
71 | + if (!$xcloner_file_system->get_storage_filesystem()->has($file_info['path'])) |
|
72 | 72 | $file_exists_on_local_storage = false; |
73 | 73 | } |
74 | 74 | |
75 | 75 | ?> |
76 | -<?php if(!isset($file_info['parent'])):?> |
|
76 | +<?php if (!isset($file_info['parent'])):?> |
|
77 | 77 | |
78 | 78 | <tr> |
79 | 79 | <td class="checkbox"> |
@@ -84,55 +84,55 @@ discard block |
||
84 | 84 | </td> |
85 | 85 | <td> |
86 | 86 | <span class=""><?php echo $file_info['path']?></span> |
87 | - <?php if(!$file_exists_on_local_storage): ?> |
|
88 | - <a href="#" title="<?php echo __("File does not exists on local storage","xcloner-backup-and-restore")?>"><i class="material-icons backup_warning">warning</i></a> |
|
87 | + <?php if (!$file_exists_on_local_storage): ?> |
|
88 | + <a href="#" title="<?php echo __("File does not exists on local storage", "xcloner-backup-and-restore")?>"><i class="material-icons backup_warning">warning</i></a> |
|
89 | 89 | <?php endif?> |
90 | 90 | <?php |
91 | - if(isset($file_info['childs']) and is_array($file_info['childs'])): |
|
91 | + if (isset($file_info['childs']) and is_array($file_info['childs'])): |
|
92 | 92 | ?> |
93 | 93 | <a href="#" title="expand" class="expand-multipart add"><i class="material-icons">add</i></a> |
94 | 94 | <a href="#" title="collapse" class="expand-multipart remove"><i class="material-icons">remove</i></a> |
95 | 95 | <ul class="multipart"> |
96 | - <?php foreach($file_info['childs'] as $child):?> |
|
96 | + <?php foreach ($file_info['childs'] as $child):?> |
|
97 | 97 | <li> |
98 | 98 | <?php echo $child[0]?> (<?php echo size_format($child[2])?>) |
99 | 99 | <?php |
100 | 100 | $child_exists_on_local_storage = true; |
101 | - if($storage_selection) |
|
101 | + if ($storage_selection) |
|
102 | 102 | { |
103 | - if(!$xcloner_file_system->get_storage_filesystem()->has($child[0])) |
|
103 | + if (!$xcloner_file_system->get_storage_filesystem()->has($child[0])) |
|
104 | 104 | $child_exists_on_local_storage = false; |
105 | 105 | } |
106 | 106 | ?> |
107 | - <?php if(!$child_exists_on_local_storage): ?> |
|
108 | - <a href="#" title="<?php echo __("File does not exists on local storage","xcloner-backup-and-restore")?>"><i class="material-icons backup_warning">warning</i></a> |
|
107 | + <?php if (!$child_exists_on_local_storage): ?> |
|
108 | + <a href="#" title="<?php echo __("File does not exists on local storage", "xcloner-backup-and-restore")?>"><i class="material-icons backup_warning">warning</i></a> |
|
109 | 109 | <?php endif?> |
110 | - <?php if(!$storage_selection) :?> |
|
111 | - <a href="#<?php echo $child[0];?>" class="download" title="Download Backup"><i class="material-icons">file_download</i></a> |
|
112 | - <a href="#<?php echo $child[0]?>" class="list-backup-content" title="<?php echo __('List Backup Content','xcloner-backup-and-restore')?>"><i class="material-icons">folder_open</i></a> |
|
113 | - <?php elseif($storage_selection != "gdrive" && !$xcloner_file_system->get_storage_filesystem()->has($child[0])): ?> |
|
114 | - <a href="#<?php echo $child[0]?>" class="copy-remote-to-local" title="<?php echo __('Push Backup To Local Storage','xcloner-backup-and-restore')?>"><i class="material-icons">file_upload</i></a> |
|
110 | + <?php if (!$storage_selection) :?> |
|
111 | + <a href="#<?php echo $child[0]; ?>" class="download" title="Download Backup"><i class="material-icons">file_download</i></a> |
|
112 | + <a href="#<?php echo $child[0]?>" class="list-backup-content" title="<?php echo __('List Backup Content', 'xcloner-backup-and-restore')?>"><i class="material-icons">folder_open</i></a> |
|
113 | + <?php elseif ($storage_selection != "gdrive" && !$xcloner_file_system->get_storage_filesystem()->has($child[0])): ?> |
|
114 | + <a href="#<?php echo $child[0]?>" class="copy-remote-to-local" title="<?php echo __('Push Backup To Local Storage', 'xcloner-backup-and-restore')?>"><i class="material-icons">file_upload</i></a> |
|
115 | 115 | <?php endif?> |
116 | 116 | </li> |
117 | - <?php endforeach;?> |
|
117 | + <?php endforeach; ?> |
|
118 | 118 | </ul> |
119 | - <?php endif;?> |
|
119 | + <?php endif; ?> |
|
120 | 120 | </td> |
121 | - <td><?php if(isset($file_info['timestamp'])) echo date("d M, Y H:i", $file_info['timestamp'])?></td> |
|
121 | + <td><?php if (isset($file_info['timestamp'])) echo date("d M, Y H:i", $file_info['timestamp'])?></td> |
|
122 | 122 | <td><?php echo size_format($file_info['size'])?></td> |
123 | 123 | <td> |
124 | - <?php if(!$storage_selection):?> |
|
125 | - <a href="#<?php echo $file_info['basename'];?>" class="download" title="<?php echo __('Download Backup','xcloner-backup-and-restore')?>"><i class="material-icons">file_download</i></a> |
|
124 | + <?php if (!$storage_selection):?> |
|
125 | + <a href="#<?php echo $file_info['basename']; ?>" class="download" title="<?php echo __('Download Backup', 'xcloner-backup-and-restore')?>"><i class="material-icons">file_download</i></a> |
|
126 | 126 | |
127 | - <?php if(sizeof($available_storages)):?> |
|
128 | - <a href="#<?php echo $file_info['basename']?>" class="cloud-upload" title="<?php echo __('Send Backup To Remote Storage','xcloner-backup-and-restore')?>"><i class="material-icons">cloud_upload</i></a> |
|
127 | + <?php if (sizeof($available_storages)):?> |
|
128 | + <a href="#<?php echo $file_info['basename']?>" class="cloud-upload" title="<?php echo __('Send Backup To Remote Storage', 'xcloner-backup-and-restore')?>"><i class="material-icons">cloud_upload</i></a> |
|
129 | 129 | <?php endif?> |
130 | - <a href="#<?php echo $file_info['basename']?>" class="list-backup-content" title="<?php echo __('List Backup Content','xcloner-backup-and-restore')?>"><i class="material-icons">folder_open</i></a> |
|
131 | - <?php endif;?> |
|
130 | + <a href="#<?php echo $file_info['basename']?>" class="list-backup-content" title="<?php echo __('List Backup Content', 'xcloner-backup-and-restore')?>"><i class="material-icons">folder_open</i></a> |
|
131 | + <?php endif; ?> |
|
132 | 132 | |
133 | - <a href="#<?php echo $file_info['basename']?>" class="delete" title="<?php echo __('Delete Backup','xcloner-backup-and-restore')?>"><i class="material-icons">delete</i></a> |
|
134 | - <?php if($storage_selection and !$file_exists_on_local_storage):?> |
|
135 | - <a href="#<?php echo $file_info['basename'];?>" class="copy-remote-to-local" title="<?php echo __('Push Backup To Local Storage','xcloner-backup-and-restore')?>"><i class="material-icons">file_upload</i></a> |
|
133 | + <a href="#<?php echo $file_info['basename']?>" class="delete" title="<?php echo __('Delete Backup', 'xcloner-backup-and-restore')?>"><i class="material-icons">delete</i></a> |
|
134 | + <?php if ($storage_selection and !$file_exists_on_local_storage):?> |
|
135 | + <a href="#<?php echo $file_info['basename']; ?>" class="copy-remote-to-local" title="<?php echo __('Push Backup To Local Storage', 'xcloner-backup-and-restore')?>"><i class="material-icons">file_upload</i></a> |
|
136 | 136 | <?php endif?> |
137 | 137 | |
138 | 138 | </td> |
@@ -145,12 +145,12 @@ discard block |
||
145 | 145 | </tbody> |
146 | 146 | </table> |
147 | 147 | |
148 | -<a class="waves-effect waves-light btn delete-all"><i class="material-icons left">delete</i><?php echo __("Delete",'xcloner-backup-and-restore')?></a> |
|
148 | +<a class="waves-effect waves-light btn delete-all"><i class="material-icons left">delete</i><?php echo __("Delete", 'xcloner-backup-and-restore')?></a> |
|
149 | 149 | |
150 | 150 | <!-- List Backup Content Modal--> |
151 | 151 | <div id="backup_cotent_modal" class="modal"> |
152 | 152 | <div class="modal-content"> |
153 | - <h4><?php echo sprintf(__("Listing Backup Content ",'xcloner-backup-and-restore'), "")?></h4> |
|
153 | + <h4><?php echo sprintf(__("Listing Backup Content ", 'xcloner-backup-and-restore'), "")?></h4> |
|
154 | 154 | <h5 class="backup-name"></h5> |
155 | 155 | |
156 | 156 | <div class="progress"> |
@@ -163,14 +163,14 @@ discard block |
||
163 | 163 | <!-- Local Transfer Modal--> |
164 | 164 | <div id="local_storage_upload_modal" class="modal"> |
165 | 165 | <div class="modal-content"> |
166 | - <h4><?php echo sprintf(__("Transfer Remote Backup To Local Storage",'xcloner-backup-and-restore'), "")?></h4> |
|
166 | + <h4><?php echo sprintf(__("Transfer Remote Backup To Local Storage", 'xcloner-backup-and-restore'), "")?></h4> |
|
167 | 167 | <h5 class="backup-name"></h5> |
168 | 168 | |
169 | 169 | <div class="row status"> |
170 | 170 | <div class="progress"> |
171 | 171 | <div class="indeterminate"></div> |
172 | 172 | </div> |
173 | - <?php echo __("Uploading backup to the local storage filesystem...",'xcloner-backup-and-restore')?> <span class="status-text"></span> |
|
173 | + <?php echo __("Uploading backup to the local storage filesystem...", 'xcloner-backup-and-restore')?> <span class="status-text"></span> |
|
174 | 174 | </div> |
175 | 175 | </div> |
176 | 176 | </div> |
@@ -180,17 +180,17 @@ discard block |
||
180 | 180 | <form method="POST" class="remote-storage-form"> |
181 | 181 | <input type="hidden" name="file" class="backup_name"> |
182 | 182 | <div class="modal-content"> |
183 | - <h4><?php echo __("Remote Storage Transfer",'xcloner-backup-and-restore')?></h4> |
|
183 | + <h4><?php echo __("Remote Storage Transfer", 'xcloner-backup-and-restore')?></h4> |
|
184 | 184 | <p> |
185 | - <?php if(sizeof($available_storages)):?> |
|
185 | + <?php if (sizeof($available_storages)):?> |
|
186 | 186 | <div class="row"> |
187 | 187 | <div class="col s12 label"> |
188 | - <label><?php echo sprintf(__('Send %s to remote storage','xcloner-backup-and-restore'), "<span class='backup_name'></span>") ?></label> |
|
188 | + <label><?php echo sprintf(__('Send %s to remote storage', 'xcloner-backup-and-restore'), "<span class='backup_name'></span>") ?></label> |
|
189 | 189 | </div> |
190 | 190 | <div class="input-field col s8 m10"> |
191 | 191 | <select name="transfer_storage" id="transfer_storage" class="validate" required > |
192 | 192 | <option value="" selected><?php echo __('please select...', 'xcloner-backup-and-restore') ?></option> |
193 | - <?php foreach($available_storages as $storage=>$text):?> |
|
193 | + <?php foreach ($available_storages as $storage=>$text):?> |
|
194 | 194 | <option value="<?php echo $storage?>"><?php echo $text?></option> |
195 | 195 | <?php endforeach?> |
196 | 196 | </select> |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | </div> |
202 | 202 | </div> |
203 | 203 | <div class="row status"> |
204 | - <?php echo __("Uploading backup to the selected remote storage...",'xcloner-backup-and-restore')?> <span class="status-text"></span> |
|
204 | + <?php echo __("Uploading backup to the selected remote storage...", 'xcloner-backup-and-restore')?> <span class="status-text"></span> |
|
205 | 205 | <div class="progress"> |
206 | 206 | <div class="indeterminate"></div> |
207 | 207 | </div> |
@@ -8,11 +8,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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); |