@@ -12,22 +12,22 @@ discard block |
||
| 12 | 12 | * @subpackage Xcloner/admin/partials |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -$requirements = $this->get_xcloner_container()->get_xcloner_requirements(); |
|
| 16 | -$xcloner_settings = $this->get_xcloner_container()->get_xcloner_settings(); |
|
| 17 | -$xcloner_file_system = $this->get_xcloner_container()->get_xcloner_filesystem(); |
|
| 18 | -$logger = $this->get_xcloner_container()->get_xcloner_logger(); |
|
| 19 | -$xcloner_scheduler = $this->get_xcloner_container()->get_xcloner_scheduler(); |
|
| 15 | +$requirements = $this->get_xcloner_container()->get_xcloner_requirements(); |
|
| 16 | +$xcloner_settings = $this->get_xcloner_container()->get_xcloner_settings(); |
|
| 17 | +$xcloner_file_system = $this->get_xcloner_container()->get_xcloner_filesystem(); |
|
| 18 | +$logger = $this->get_xcloner_container()->get_xcloner_logger(); |
|
| 19 | +$xcloner_scheduler = $this->get_xcloner_container()->get_xcloner_scheduler(); |
|
| 20 | 20 | |
| 21 | 21 | $logger_content = $logger->getLastDebugLines(); |
| 22 | 22 | |
| 23 | -$date_format = get_option( 'date_format' ); |
|
| 24 | -$time_format = get_option( 'time_format' ); |
|
| 23 | +$date_format = get_option('date_format'); |
|
| 24 | +$time_format = get_option('time_format'); |
|
| 25 | 25 | |
| 26 | 26 | $xcloner_file_system->cleanup_tmp_directories(); |
| 27 | 27 | |
| 28 | -if($requirements->check_backup_ready_status()) |
|
| 28 | +if ($requirements->check_backup_ready_status()) |
|
| 29 | 29 | { |
| 30 | - $latest_backup = $xcloner_file_system->get_latest_backup(); |
|
| 30 | + $latest_backup = $xcloner_file_system->get_latest_backup(); |
|
| 31 | 31 | $xcloner_file_system->backup_storage_cleanup(); |
| 32 | 32 | } |
| 33 | 33 | ?> |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | </div> |
| 41 | 41 | </div> |
| 42 | 42 | |
| 43 | -<?php if(isset($latest_backup['timestamp']) and $latest_backup['timestamp'] < strtotime("-1 day")): ?> |
|
| 43 | +<?php if (isset($latest_backup['timestamp']) and $latest_backup['timestamp'] < strtotime("-1 day")): ?> |
|
| 44 | 44 | <div id="setting-error-" class="error settings-error notice is-dismissible"> |
| 45 | 45 | <p><strong> |
| 46 | 46 | <?php echo __('Your latest backup is older than 24 hours, please create a new backup to keep your site protected.', 'xcloner-backup-and-restore') ?> |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | </div> |
| 50 | 50 | <?php endif?> |
| 51 | 51 | |
| 52 | -<?php if(!isset($latest_backup['timestamp']) ): ?> |
|
| 52 | +<?php if (!isset($latest_backup['timestamp'])): ?> |
|
| 53 | 53 | <div id="setting-error-" class="error settings-error notice is-dismissible"> |
| 54 | 54 | <p><strong> |
| 55 | 55 | <?php echo __('You have no backup that I could find, please generate a new backup to keep your site protected.', 'xcloner-backup-and-restore') ?> |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | </div> |
| 59 | 59 | <?php endif?> |
| 60 | 60 | |
| 61 | -<?php if(!$requirements->check_backup_ready_status()):?> |
|
| 61 | +<?php if (!$requirements->check_backup_ready_status()):?> |
|
| 62 | 62 | <div id="setting-error-" class="error settings-error notice is-dismissible"> |
| 63 | 63 | <p><strong> |
| 64 | 64 | <?php echo __('Backup system not ready, please check and fix the issues marked in red', 'xcloner-backup-and-restore') ?> |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | <div class="row"> |
| 86 | 86 | <h5><?php echo __("Latest Backup", 'xcloner-backup-and-restore')?></h5> |
| 87 | 87 | <blockquote> |
| 88 | - <?php if($latest_backup):?> |
|
| 88 | + <?php if ($latest_backup):?> |
|
| 89 | 89 | <div class="item"> |
| 90 | 90 | <div class="title"><?php echo __("Backup Name", 'xcloner-backup-and-restore')?>:</div> |
| 91 | 91 | <?php echo $latest_backup['basename']?> |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | <div class="item"> |
| 100 | 100 | <div class="title"><?php echo __("Backup Date", 'xcloner-backup-and-restore')?>:</div> |
| 101 | 101 | <?php |
| 102 | - echo date($date_format." ".$time_format, $latest_backup['timestamp']+(get_option( 'gmt_offset' ) * HOUR_IN_SECONDS)) |
|
| 102 | + echo date($date_format." ".$time_format, $latest_backup['timestamp'] + (get_option('gmt_offset') * HOUR_IN_SECONDS)) |
|
| 103 | 103 | ?> |
| 104 | 104 | </div> |
| 105 | 105 | <?php else:?> |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | <blockquote> |
| 114 | 114 | <div class="item"> |
| 115 | 115 | <div class="title"><?php echo __("Total Size", 'xcloner-backup-and-restore')?>:</div> |
| 116 | - <?php echo size_format($xcloner_file_system->get_storage_usage());?> |
|
| 116 | + <?php echo size_format($xcloner_file_system->get_storage_usage()); ?> |
|
| 117 | 117 | </div> |
| 118 | 118 | </blockquote> |
| 119 | 119 | <h5><?php echo __("Next Scheduled Backup", 'xcloner-backup-and-restore')?></h5> |
@@ -122,25 +122,25 @@ discard block |
||
| 122 | 122 | <?php |
| 123 | 123 | $list = ($xcloner_scheduler->get_next_run_schedule()); |
| 124 | 124 | |
| 125 | - if(is_array($list)) |
|
| 125 | + if (is_array($list)) |
|
| 126 | 126 | { |
| 127 | - $xcloner_file_system->sort_by($list, "next_run_time","asc"); |
|
| 127 | + $xcloner_file_system->sort_by($list, "next_run_time", "asc"); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if(isset($list[0])) |
|
| 130 | + if (isset($list[0])) |
|
| 131 | 131 | $latest_schedule = $list[0]; |
| 132 | 132 | ?> |
| 133 | - <?php if(isset($latest_schedule->name)):?> |
|
| 133 | + <?php if (isset($latest_schedule->name)):?> |
|
| 134 | 134 | <div class="title"><?php echo __("Schedule Name", 'xcloner-backup-and-restore')?>:</div> |
| 135 | - <?php echo $latest_schedule->name;?> |
|
| 136 | - <?php endif;?> |
|
| 135 | + <?php echo $latest_schedule->name; ?> |
|
| 136 | + <?php endif; ?> |
|
| 137 | 137 | </div> |
| 138 | 138 | <div class="item"> |
| 139 | 139 | <div class="title"><?php echo __("Next Call", 'xcloner-backup-and-restore')?>:</div> |
| 140 | - <?php if(isset($latest_schedule->next_run_time)) |
|
| 140 | + <?php if (isset($latest_schedule->next_run_time)) |
|
| 141 | 141 | echo date($date_format." ".$time_format, $latest_schedule->next_run_time); |
| 142 | 142 | else |
| 143 | - echo __("Unscheduled",'xcloner-backup-and-restore'); |
|
| 143 | + echo __("Unscheduled", 'xcloner-backup-and-restore'); |
|
| 144 | 144 | ?> |
| 145 | 145 | </div> |
| 146 | 146 | </blockquote> |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | </div> |
| 149 | 149 | </li> |
| 150 | 150 | |
| 151 | - <?php if($xcloner_settings->get_xcloner_option('xcloner_enable_log')) :?> |
|
| 151 | + <?php if ($xcloner_settings->get_xcloner_option('xcloner_enable_log')) :?> |
|
| 152 | 152 | <li class="active"> |
| 153 | 153 | <div class="collapsible-header active"> |
| 154 | 154 | <i class="material-icons">bug_report</i><?php echo __('XCloner Debugger', 'xcloner-backup-and-restore')?> |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | </div> |
| 160 | 160 | </div> |
| 161 | 161 | <div class="collapsible-body"> |
| 162 | - <div class="console" id="xcloner-console"><?php if($logger_content) echo implode("<br />\n", array_reverse($logger_content)); ?></div> |
|
| 162 | + <div class="console" id="xcloner-console"><?php if ($logger_content) echo implode("<br />\n", array_reverse($logger_content)); ?></div> |
|
| 163 | 163 | </div> |
| 164 | 164 | </li> |
| 165 | 165 | <script> |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | }, 2000);*/ |
| 172 | 172 | }) |
| 173 | 173 | </script> |
| 174 | - <?php endif;?> |
|
| 174 | + <?php endif; ?> |
|
| 175 | 175 | |
| 176 | 176 | </ul> |
| 177 | 177 | |
@@ -183,59 +183,59 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | <div class="card blue-grey darken-1 z-depth-4 backup-ready"> |
| 185 | 185 | <div class="card-content white-text"> |
| 186 | - <span class="card-title"><?php echo __("System Check",'xcloner-backup-and-restore')?></span> |
|
| 186 | + <span class="card-title"><?php echo __("System Check", 'xcloner-backup-and-restore')?></span> |
|
| 187 | 187 | <ul> |
| 188 | - <li class="card-panel <?php echo ($requirements->check_xcloner_start_path(1)?"teal":"red")?> lighten-2" > |
|
| 189 | - <?php echo __('Backup Start Location','xcloner-backup-and-restore')?>: <span class="shorten_string "><?php echo $requirements->check_xcloner_start_path();?></span> |
|
| 188 | + <li class="card-panel <?php echo ($requirements->check_xcloner_start_path(1) ? "teal" : "red")?> lighten-2" > |
|
| 189 | + <?php echo __('Backup Start Location', 'xcloner-backup-and-restore')?>: <span class="shorten_string "><?php echo $requirements->check_xcloner_start_path(); ?></span> |
|
| 190 | 190 | </li> |
| 191 | - <li class="card-panel <?php echo ($requirements->check_xcloner_store_path(1)?"teal":"red")?> lighten-2" > |
|
| 192 | - <?php echo __('Backup Storage Location','xcloner-backup-and-restore')?>: <span class="shorten_string"><?php echo $requirements->check_xcloner_store_path();?></span> |
|
| 191 | + <li class="card-panel <?php echo ($requirements->check_xcloner_store_path(1) ? "teal" : "red")?> lighten-2" > |
|
| 192 | + <?php echo __('Backup Storage Location', 'xcloner-backup-and-restore')?>: <span class="shorten_string"><?php echo $requirements->check_xcloner_store_path(); ?></span> |
|
| 193 | 193 | </li> |
| 194 | - <li class="card-panel <?php echo ($requirements->check_xcloner_tmp_path(1)?"teal":"red")?> lighten-2" > |
|
| 195 | - <?php echo __('Temporary Location','xcloner-backup-and-restore')?>: <span class="shorten_string"><?php echo $requirements->check_xcloner_tmp_path();?></span> |
|
| 194 | + <li class="card-panel <?php echo ($requirements->check_xcloner_tmp_path(1) ? "teal" : "red")?> lighten-2" > |
|
| 195 | + <?php echo __('Temporary Location', 'xcloner-backup-and-restore')?>: <span class="shorten_string"><?php echo $requirements->check_xcloner_tmp_path(); ?></span> |
|
| 196 | 196 | </li> |
| 197 | 197 | |
| 198 | - <li class="card-panel <?php echo ($requirements->check_min_php_version(1)?"teal":"red")?> lighten-2" > |
|
| 199 | - <?php echo __('PHP Version Check','xcloner-backup-and-restore')?>: <?php echo $requirements->check_min_php_version();?> |
|
| 198 | + <li class="card-panel <?php echo ($requirements->check_min_php_version(1) ? "teal" : "red")?> lighten-2" > |
|
| 199 | + <?php echo __('PHP Version Check', 'xcloner-backup-and-restore')?>: <?php echo $requirements->check_min_php_version(); ?> |
|
| 200 | 200 | ( >= <?php echo $requirements->get_constant('min_php_version')?>) |
| 201 | 201 | </li> |
| 202 | - <li class="card-panel <?php echo ($requirements->check_safe_mode(1)?"teal":"orange")?> lighten-2" > |
|
| 203 | - <?php echo __('PHP Safe Mode','xcloner-backup-and-restore')?>: <?php echo $requirements->check_safe_mode();?> |
|
| 202 | + <li class="card-panel <?php echo ($requirements->check_safe_mode(1) ? "teal" : "orange")?> lighten-2" > |
|
| 203 | + <?php echo __('PHP Safe Mode', 'xcloner-backup-and-restore')?>: <?php echo $requirements->check_safe_mode(); ?> |
|
| 204 | 204 | ( <?php echo $requirements->get_constant('safe_mode')?>) |
| 205 | 205 | </li> |
| 206 | - <li class="card-panel <?php echo ($requirements->check_backup_ready_status()?"teal":"red")?> lighten-2"> |
|
| 207 | - <?php echo ($requirements->check_backup_ready_status()?__('BACKUP READY','xcloner-backup-and-restore'):__('Backup not ready, please check above requirements','xcloner-backup-and-restore'))?> |
|
| 208 | - <i class="material-icons right tiny"><?php echo ($requirements->check_backup_ready_status()?'thumb_up':'thumb_down')?></i> |
|
| 206 | + <li class="card-panel <?php echo ($requirements->check_backup_ready_status() ? "teal" : "red")?> lighten-2"> |
|
| 207 | + <?php echo ($requirements->check_backup_ready_status() ?__('BACKUP READY', 'xcloner-backup-and-restore') : __('Backup not ready, please check above requirements', 'xcloner-backup-and-restore'))?> |
|
| 208 | + <i class="material-icons right tiny"><?php echo ($requirements->check_backup_ready_status() ? 'thumb_up' : 'thumb_down')?></i> |
|
| 209 | 209 | </li> |
| 210 | 210 | </ul> |
| 211 | 211 | <ul class="additional_system_info"> |
| 212 | 212 | <li class="card-panel grey darken-1" > |
| 213 | - <?php echo __('PHP max_execution_time','xcloner-backup-and-restore')?>: <?php echo $requirements->get_max_execution_time();?> |
|
| 213 | + <?php echo __('PHP max_execution_time', 'xcloner-backup-and-restore')?>: <?php echo $requirements->get_max_execution_time(); ?> |
|
| 214 | 214 | </li> |
| 215 | 215 | <li class="card-panel grey darken-1" > |
| 216 | - <?php echo __('PHP memory_limit','xcloner-backup-and-restore')?>: <?php echo $requirements->get_memory_limit();?> |
|
| 216 | + <?php echo __('PHP memory_limit', 'xcloner-backup-and-restore')?>: <?php echo $requirements->get_memory_limit(); ?> |
|
| 217 | 217 | </li> |
| 218 | 218 | <li class="card-panel grey darken-1" > |
| 219 | - <?php echo __('PHP open_basedir','xcloner-backup-and-restore')?>: <?php echo $requirements->get_open_basedir();?> |
|
| 219 | + <?php echo __('PHP open_basedir', 'xcloner-backup-and-restore')?>: <?php echo $requirements->get_open_basedir(); ?> |
|
| 220 | 220 | </li> |
| 221 | 221 | <?php |
| 222 | 222 | $data = array(); |
| 223 | - if($requirements->check_backup_ready_status()) |
|
| 223 | + if ($requirements->check_backup_ready_status()) |
|
| 224 | 224 | $data = $xcloner_file_system->estimate_read_write_time(); |
| 225 | 225 | ?> |
| 226 | 226 | <li class="card-panel grey darken-1" > |
| 227 | - <?php echo __('Reading Time 1MB Block','xcloner-backup-and-restore')?>: <?php echo (isset($data['reading_time'])?$data['reading_time']:__("unknown"));?> |
|
| 227 | + <?php echo __('Reading Time 1MB Block', 'xcloner-backup-and-restore')?>: <?php echo (isset($data['reading_time']) ? $data['reading_time'] : __("unknown")); ?> |
|
| 228 | 228 | </li> |
| 229 | 229 | <li class="card-panel grey darken-1" > |
| 230 | - <?php echo __('Writing Time 1MB Block','xcloner-backup-and-restore')?>: <?php echo (isset($data['writing_time'])?$data['writing_time']:__("unknown"));?> |
|
| 230 | + <?php echo __('Writing Time 1MB Block', 'xcloner-backup-and-restore')?>: <?php echo (isset($data['writing_time']) ? $data['writing_time'] : __("unknown")); ?> |
|
| 231 | 231 | </li> |
| 232 | 232 | <li class="card-panel grey darken-1" > |
| 233 | - <?php echo __('Free Disk Space','xcloner-backup-and-restore')?>: <?php echo $requirements->get_free_disk_space();;?> |
|
| 233 | + <?php echo __('Free Disk Space', 'xcloner-backup-and-restore')?>: <?php echo $requirements->get_free_disk_space(); ;?> |
|
| 234 | 234 | </li> |
| 235 | 235 | </ul> |
| 236 | 236 | </div> |
| 237 | 237 | <div class="card-action"> |
| 238 | - <a class="waves-effect waves-light btn system_info_toggle blue darken-1"><i class="material-icons left">list</i><?php echo __('Toggle Additional System Info','xcloner-backup-and-restore')?></a> |
|
| 238 | + <a class="waves-effect waves-light btn system_info_toggle blue darken-1"><i class="material-icons left">list</i><?php echo __('Toggle Additional System Info', 'xcloner-backup-and-restore')?></a> |
|
| 239 | 239 | </div> |
| 240 | 240 | </div> |
| 241 | 241 | |
@@ -148,15 +148,15 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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,28 +333,28 @@ discard block |
||
| 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 | - }else{ |
|
| 357 | - add_action( 'shutdown', function(){ |
|
| 356 | + } else { |
|
| 357 | + add_action('shutdown', function() { |
|
| 358 | 358 | $this->xcloner_file_system = new Xcloner_File_System($this); |
| 359 | 359 | $this->xcloner_file_system->remove_tmp_filesystem(); |
| 360 | 360 | }); |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | */ |
| 378 | 378 | public function pre_auto_update($type, $item, $context) |
| 379 | 379 | { |
| 380 | - if(!$type) |
|
| 380 | + if (!$type) |
|
| 381 | 381 | { |
| 382 | 382 | return false; |
| 383 | 383 | } |
@@ -386,10 +386,10 @@ discard block |
||
| 386 | 386 | |
| 387 | 387 | $content_dir = str_replace(ABSPATH, "", WP_CONTENT_DIR); |
| 388 | 388 | $plugins_dir = str_replace(ABSPATH, "", WP_PLUGIN_DIR); |
| 389 | - $langs_dir = $content_dir . DS . "languages"; |
|
| 390 | - $themes_dir = $content_dir . DS . "themes"; |
|
| 389 | + $langs_dir = $content_dir.DS."languages"; |
|
| 390 | + $themes_dir = $content_dir.DS."themes"; |
|
| 391 | 391 | |
| 392 | - switch ( $type ) { |
|
| 392 | + switch ($type) { |
|
| 393 | 393 | case 'core': |
| 394 | 394 | $exclude_files = array( |
| 395 | 395 | "^(?!(wp-admin|wp-includes|(?!.*\/.*.php)))(.*)$", |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | |
| 400 | 400 | $dir_array = explode(DS, $plugins_dir); |
| 401 | 401 | |
| 402 | - foreach($dir_array as $dir) |
|
| 402 | + foreach ($dir_array as $dir) |
|
| 403 | 403 | { |
| 404 | 404 | $data .= "\/".$dir; |
| 405 | 405 | $regex .= $data."$|"; |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | |
| 416 | 416 | $dir_array = explode(DS, $themes_dir); |
| 417 | 417 | |
| 418 | - foreach($dir_array as $dir) |
|
| 418 | + foreach ($dir_array as $dir) |
|
| 419 | 419 | { |
| 420 | 420 | $data .= "\/".$dir; |
| 421 | 421 | $regex .= $data."$|"; |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | |
| 432 | 432 | $dir_array = explode(DS, $langs_dir); |
| 433 | 433 | |
| 434 | - foreach($dir_array as $dir) |
|
| 434 | + foreach ($dir_array as $dir) |
|
| 435 | 435 | { |
| 436 | 436 | $data .= "\/".$dir; |
| 437 | 437 | $regex .= $data."$|"; |
@@ -457,9 +457,9 @@ discard block |
||
| 457 | 457 | $schedule['backup_params']->email_notification = get_option('admin_email'); |
| 458 | 458 | $schedule['backup_params']->backup_name = "backup_pre_auto_update_".$type."_[domain]-[time]-sql"; |
| 459 | 459 | |
| 460 | - try{ |
|
| 460 | + try { |
|
| 461 | 461 | $this->xcloner_scheduler->xcloner_scheduler_callback(0, $schedule); |
| 462 | - }catch(Exception $e){ |
|
| 462 | + }catch (Exception $e) { |
|
| 463 | 463 | $this->get_xcloner_logger()->error($e->getMessage()); |
| 464 | 464 | } |
| 465 | 465 | |
@@ -474,10 +474,10 @@ discard block |
||
| 474 | 474 | */ |
| 475 | 475 | private function define_public_hooks() { |
| 476 | 476 | |
| 477 | - $plugin_public = new Xcloner_Public( $this ); |
|
| 477 | + $plugin_public = new Xcloner_Public($this); |
|
| 478 | 478 | |
| 479 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
| 480 | - $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
| 479 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles'); |
|
| 480 | + $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts'); |
|
| 481 | 481 | |
| 482 | 482 | } |
| 483 | 483 | |
@@ -486,20 +486,20 @@ discard block |
||
| 486 | 486 | $logger = new XCloner_Logger($this, "php_system"); |
| 487 | 487 | $error = error_get_last(); |
| 488 | 488 | |
| 489 | - if($error['type'] and $logger) |
|
| 489 | + if ($error['type'] and $logger) |
|
| 490 | 490 | { |
| 491 | - $logger->info($this->friendly_error_type ($error['type']).": ".var_export($error, true)); |
|
| 491 | + $logger->info($this->friendly_error_type($error['type']).": ".var_export($error, true)); |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | function friendly_error_type($type) { |
| 497 | - static $levels=null; |
|
| 498 | - if ($levels===null) { |
|
| 499 | - $levels=[]; |
|
| 497 | + static $levels = null; |
|
| 498 | + if ($levels === null) { |
|
| 499 | + $levels = []; |
|
| 500 | 500 | foreach (get_defined_constants() as $key=>$value) { |
| 501 | - if (strpos($key,'E_')!==0) {continue;} |
|
| 502 | - $levels[$value]= $key; //substr($key,2); |
|
| 501 | + if (strpos($key, 'E_') !== 0) {continue; } |
|
| 502 | + $levels[$value] = $key; //substr($key,2); |
|
| 503 | 503 | } |
| 504 | 504 | } |
| 505 | 505 | return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}"); |
@@ -509,52 +509,52 @@ discard block |
||
| 509 | 509 | { |
| 510 | 510 | //adding the pre-update hook |
| 511 | 511 | |
| 512 | - if(is_admin() || defined('DOING_CRON')) |
|
| 512 | + if (is_admin() || defined('DOING_CRON')) |
|
| 513 | 513 | { |
| 514 | - $this->xcloner_logger = new XCloner_Logger($this, "xcloner_api"); |
|
| 515 | - $this->xcloner_filesystem = new Xcloner_File_System($this); |
|
| 514 | + $this->xcloner_logger = new XCloner_Logger($this, "xcloner_api"); |
|
| 515 | + $this->xcloner_filesystem = new Xcloner_File_System($this); |
|
| 516 | 516 | |
| 517 | 517 | //$this->xcloner_filesystem->set_diff_timestamp_start (strtotime("-15 days")); |
| 518 | 518 | |
| 519 | - $this->archive_system = new Xcloner_Archive($this); |
|
| 520 | - $this->xcloner_database = new Xcloner_Database($this); |
|
| 521 | - $this->xcloner_scheduler = new Xcloner_Scheduler($this); |
|
| 522 | - $this->xcloner_remote_storage = new Xcloner_Remote_Storage($this); |
|
| 523 | - $this->xcloner_file_transfer = new Xcloner_File_Transfer($this); |
|
| 519 | + $this->archive_system = new Xcloner_Archive($this); |
|
| 520 | + $this->xcloner_database = new Xcloner_Database($this); |
|
| 521 | + $this->xcloner_scheduler = new Xcloner_Scheduler($this); |
|
| 522 | + $this->xcloner_remote_storage = new Xcloner_Remote_Storage($this); |
|
| 523 | + $this->xcloner_file_transfer = new Xcloner_File_Transfer($this); |
|
| 524 | 524 | |
| 525 | - $xcloner_api = new Xcloner_Api($this); |
|
| 525 | + $xcloner_api = new Xcloner_Api($this); |
|
| 526 | 526 | |
| 527 | - add_action( 'wp_ajax_get_database_tables_action', array($xcloner_api,'get_database_tables_action') ); |
|
| 528 | - add_action( 'wp_ajax_get_file_system_action', array($xcloner_api,'get_file_system_action') ); |
|
| 529 | - add_action( 'wp_ajax_scan_filesystem', array($xcloner_api,'scan_filesystem') ); |
|
| 530 | - add_action( 'wp_ajax_backup_database', array($xcloner_api,'backup_database') ); |
|
| 531 | - add_action( 'wp_ajax_backup_files' , array($xcloner_api,'backup_files') ); |
|
| 532 | - add_action( 'wp_ajax_save_schedule' , array($xcloner_api,'save_schedule') ); |
|
| 533 | - add_action( 'wp_ajax_get_schedule_by_id', array($xcloner_api,'get_schedule_by_id') ); |
|
| 534 | - add_action( 'wp_ajax_get_scheduler_list', array($xcloner_api,'get_scheduler_list') ); |
|
| 535 | - add_action( 'wp_ajax_delete_schedule_by_id' , array($xcloner_api,'delete_schedule_by_id') ); |
|
| 536 | - add_action( 'wp_ajax_delete_backup_by_name' , array($xcloner_api,'delete_backup_by_name') ); |
|
| 537 | - add_action( 'wp_ajax_download_backup_by_name', array($xcloner_api,'download_backup_by_name') ); |
|
| 538 | - add_action( 'wp_ajax_remote_storage_save_status', array($xcloner_api,'remote_storage_save_status') ); |
|
| 539 | - add_action( 'wp_ajax_upload_backup_to_remote', array($xcloner_api,'upload_backup_to_remote') ); |
|
| 540 | - add_action( 'wp_ajax_list_backup_files' , array($xcloner_api,'list_backup_files') ); |
|
| 541 | - add_action( 'wp_ajax_restore_upload_backup' , array($xcloner_api,'restore_upload_backup') ); |
|
| 542 | - add_action( 'wp_ajax_download_restore_script', array($xcloner_api,'download_restore_script') ); |
|
| 543 | - add_action( 'wp_ajax_copy_backup_remote_to_local', array($xcloner_api,'copy_backup_remote_to_local') ); |
|
| 544 | - add_action( 'wp_ajax_restore_backup', array($xcloner_api,'restore_backup') ); |
|
| 545 | - add_action( 'admin_notices', array($this, 'xcloner_error_admin_notices' )); |
|
| 527 | + add_action('wp_ajax_get_database_tables_action', array($xcloner_api, 'get_database_tables_action')); |
|
| 528 | + add_action('wp_ajax_get_file_system_action', array($xcloner_api, 'get_file_system_action')); |
|
| 529 | + add_action('wp_ajax_scan_filesystem', array($xcloner_api, 'scan_filesystem')); |
|
| 530 | + add_action('wp_ajax_backup_database', array($xcloner_api, 'backup_database')); |
|
| 531 | + add_action('wp_ajax_backup_files', array($xcloner_api, 'backup_files')); |
|
| 532 | + add_action('wp_ajax_save_schedule', array($xcloner_api, 'save_schedule')); |
|
| 533 | + add_action('wp_ajax_get_schedule_by_id', array($xcloner_api, 'get_schedule_by_id')); |
|
| 534 | + add_action('wp_ajax_get_scheduler_list', array($xcloner_api, 'get_scheduler_list')); |
|
| 535 | + add_action('wp_ajax_delete_schedule_by_id', array($xcloner_api, 'delete_schedule_by_id')); |
|
| 536 | + add_action('wp_ajax_delete_backup_by_name', array($xcloner_api, 'delete_backup_by_name')); |
|
| 537 | + add_action('wp_ajax_download_backup_by_name', array($xcloner_api, 'download_backup_by_name')); |
|
| 538 | + add_action('wp_ajax_remote_storage_save_status', array($xcloner_api, 'remote_storage_save_status')); |
|
| 539 | + add_action('wp_ajax_upload_backup_to_remote', array($xcloner_api, 'upload_backup_to_remote')); |
|
| 540 | + add_action('wp_ajax_list_backup_files', array($xcloner_api, 'list_backup_files')); |
|
| 541 | + add_action('wp_ajax_restore_upload_backup', array($xcloner_api, 'restore_upload_backup')); |
|
| 542 | + add_action('wp_ajax_download_restore_script', array($xcloner_api, 'download_restore_script')); |
|
| 543 | + add_action('wp_ajax_copy_backup_remote_to_local', array($xcloner_api, 'copy_backup_remote_to_local')); |
|
| 544 | + add_action('wp_ajax_restore_backup', array($xcloner_api, 'restore_backup')); |
|
| 545 | + add_action('admin_notices', array($this, 'xcloner_error_admin_notices')); |
|
| 546 | 546 | |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | //Do a pre-update backup of targeted files |
| 550 | - if($this->get_xcloner_settings()->get_xcloner_option('xcloner_enable_pre_update_backup')) |
|
| 550 | + if ($this->get_xcloner_settings()->get_xcloner_option('xcloner_enable_pre_update_backup')) |
|
| 551 | 551 | { |
| 552 | 552 | add_action("pre_auto_update", array($this, "pre_auto_update"), 1, 3); |
| 553 | 553 | } |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | function add_plugin_action_links($links, $file) { |
| 557 | - if ($file == plugin_basename(dirname(dirname(__FILE__)) . '/xcloner.php')) |
|
| 557 | + if ($file == plugin_basename(dirname(dirname(__FILE__)).'/xcloner.php')) |
|
| 558 | 558 | { |
| 559 | 559 | $links[] = '<a href="admin.php?page=xcloner_settings_page">'.__('Settings', 'xcloner-backup-and-restore').'</a>'; |
| 560 | 560 | $links[] = '<a href="admin.php?page=xcloner_generate_backups_page">'.__('Generate Backup', 'xcloner-backup-and-restore').'</a>'; |
@@ -564,13 +564,13 @@ discard block |
||
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | public function xcloner_error_admin_notices() { |
| 567 | - settings_errors( 'xcloner_error_message' ); |
|
| 567 | + settings_errors('xcloner_error_message'); |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | public function define_cron_hooks() |
| 571 | 571 | { |
| 572 | 572 | //registering new schedule intervals |
| 573 | - add_filter( 'cron_schedules', array($this, 'add_new_intervals')); |
|
| 573 | + add_filter('cron_schedules', array($this, 'add_new_intervals')); |
|
| 574 | 574 | |
| 575 | 575 | |
| 576 | 576 | $xcloner_scheduler = $this->get_xcloner_scheduler(); |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | |
| 652 | 652 | $page = sanitize_key($_GET['page']); |
| 653 | 653 | |
| 654 | - if($page) |
|
| 654 | + if ($page) |
|
| 655 | 655 | { |
| 656 | 656 | $this->display($page); |
| 657 | 657 | } |
@@ -350,10 +350,10 @@ discard block |
||
| 350 | 350 | |
| 351 | 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 | - }else{ |
|
| 356 | + } else{ |
|
| 357 | 357 | add_action( 'shutdown', function(){ |
| 358 | 358 | $this->xcloner_file_system = new Xcloner_File_System($this); |
| 359 | 359 | $this->xcloner_file_system->remove_tmp_filesystem(); |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | |
| 460 | 460 | try{ |
| 461 | 461 | $this->xcloner_scheduler->xcloner_scheduler_callback(0, $schedule); |
| 462 | - }catch(Exception $e){ |
|
| 462 | + } catch(Exception $e){ |
|
| 463 | 463 | $this->get_xcloner_logger()->error($e->getMessage()); |
| 464 | 464 | } |
| 465 | 465 | |
@@ -4,19 +4,19 @@ discard block |
||
| 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 = ""; |
|
| 9 | + private $excluded_files = ""; |
|
| 10 | 10 | private $additional_regex_patterns = array(); |
| 11 | 11 | private $excluded_files_by_default = array("administrator/backups", "wp-content/backups"); |
| 12 | - private $included_files_handler = "backup_files.csv"; |
|
| 13 | - private $temp_dir_handler = ".dir"; |
|
| 12 | + private $included_files_handler = "backup_files.csv"; |
|
| 13 | + private $temp_dir_handler = ".dir"; |
|
| 14 | 14 | public $filesystem; |
| 15 | 15 | public $tmp_filesystem; |
| 16 | 16 | public $storage_filesystem; |
| 17 | 17 | private $xcloner_settings_append; |
| 18 | 18 | private $xcloner_container; |
| 19 | - private $diff_timestamp_start = ""; |
|
| 19 | + private $diff_timestamp_start = ""; |
|
| 20 | 20 | |
| 21 | 21 | private $logger; |
| 22 | 22 | private $start_adapter; |
@@ -39,47 +39,47 @@ discard block |
||
| 39 | 39 | { |
| 40 | 40 | $this->xcloner_container = $xcloner_container; |
| 41 | 41 | |
| 42 | - $this->logger = $xcloner_container->get_xcloner_logger()->withName("xcloner_file_system"); |
|
| 42 | + $this->logger = $xcloner_container->get_xcloner_logger()->withName("xcloner_file_system"); |
|
| 43 | 43 | $this->xcloner_settings = $xcloner_container->get_xcloner_settings(); |
| 44 | 44 | |
| 45 | - try{ |
|
| 45 | + try { |
|
| 46 | 46 | |
| 47 | - $this->start_adapter = new Local($this->xcloner_settings->get_xcloner_start_path(),LOCK_EX, 'SKIP_LINKS'); |
|
| 47 | + $this->start_adapter = new Local($this->xcloner_settings->get_xcloner_start_path(), LOCK_EX, 'SKIP_LINKS'); |
|
| 48 | 48 | $this->start_filesystem = new Filesystem($this->start_adapter, new Config([ |
| 49 | 49 | 'disable_asserts' => true, |
| 50 | 50 | ])); |
| 51 | 51 | |
| 52 | - $this->tmp_adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(),LOCK_EX, 'SKIP_LINKS'); |
|
| 52 | + $this->tmp_adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(), LOCK_EX, 'SKIP_LINKS'); |
|
| 53 | 53 | $this->tmp_filesystem = new Filesystem($this->tmp_adapter, new Config([ |
| 54 | 54 | 'disable_asserts' => true, |
| 55 | 55 | ])); |
| 56 | - $adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(),LOCK_EX|FILE_APPEND, 'SKIP_LINKS'); |
|
| 56 | + $adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(), LOCK_EX | FILE_APPEND, 'SKIP_LINKS'); |
|
| 57 | 57 | $this->tmp_filesystem_append = new Filesystem($adapter, new Config([ |
| 58 | 58 | 'disable_asserts' => true, |
| 59 | 59 | ])); |
| 60 | 60 | |
| 61 | - $adapter = new Local($this->xcloner_settings->get_xcloner_store_path(),LOCK_EX, 'SKIP_LINKS'); |
|
| 61 | + $adapter = new Local($this->xcloner_settings->get_xcloner_store_path(), LOCK_EX, 'SKIP_LINKS'); |
|
| 62 | 62 | $this->storage_filesystem = new Filesystem($adapter, new Config([ |
| 63 | 63 | 'disable_asserts' => true, |
| 64 | 64 | ])); |
| 65 | 65 | |
| 66 | - $this->storage_adapter = new Local($this->xcloner_settings->get_xcloner_store_path(),FILE_APPEND, 'SKIP_LINKS'); |
|
| 66 | + $this->storage_adapter = new Local($this->xcloner_settings->get_xcloner_store_path(), FILE_APPEND, 'SKIP_LINKS'); |
|
| 67 | 67 | $this->storage_filesystem_append = new Filesystem($this->storage_adapter, new Config([ |
| 68 | 68 | 'disable_asserts' => true, |
| 69 | 69 | ])); |
| 70 | - }catch(Exception $e){ |
|
| 70 | + }catch (Exception $e) { |
|
| 71 | 71 | $this->logger->error("Filesystem Initialization Error: ".$e->getMessage()); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | |
| 75 | - if($value = get_option('xcloner_directories_to_scan_per_request')) |
|
| 75 | + if ($value = get_option('xcloner_directories_to_scan_per_request')) |
|
| 76 | 76 | $this->folders_to_process_per_session = $value; |
| 77 | 77 | |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | public function set_diff_timestamp_start($timestamp = "") |
| 81 | 81 | { |
| 82 | - if($timestamp) |
|
| 82 | + if ($timestamp) |
|
| 83 | 83 | { |
| 84 | 84 | $this->logger->info(sprintf("Setting Differential Timestamp To %s", date("Y-m-d", $timestamp)), array("FILESYSTEM", "DIFF")); |
| 85 | 85 | $this->diff_timestamp_start = $timestamp; |
@@ -114,12 +114,12 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | public function get_storage_filesystem($remote_storage_selection = "") |
| 116 | 116 | { |
| 117 | - if($remote_storage_selection != "") |
|
| 117 | + if ($remote_storage_selection != "") |
|
| 118 | 118 | { |
| 119 | 119 | $remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage(); |
| 120 | 120 | $method = "get_".$remote_storage_selection."_filesystem"; |
| 121 | 121 | |
| 122 | - if(!method_exists($remote_storage, $method)) |
|
| 122 | + if (!method_exists($remote_storage, $method)) |
|
| 123 | 123 | return false; |
| 124 | 124 | |
| 125 | 125 | list($adapter, $filesystem) = $remote_storage->$method(); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | public function get_start_path_file_info($file) |
| 159 | 159 | { |
| 160 | - $info= $this->getMetadataFull('start_adapter', $file); |
|
| 160 | + $info = $this->getMetadataFull('start_adapter', $file); |
|
| 161 | 161 | return $this->start_filesystem->normalizeFileInfo($info); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -166,10 +166,10 @@ discard block |
||
| 166 | 166 | return $this->getMetadataFull('storage_adapter', $file); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - public function get_included_files_handler($metadata = 0) |
|
| 169 | + public function get_included_files_handler($metadata = 0) |
|
| 170 | 170 | { |
| 171 | 171 | $path = $this->included_files_handler; |
| 172 | - if(!$metadata) |
|
| 172 | + if (!$metadata) |
|
| 173 | 173 | return $path; |
| 174 | 174 | |
| 175 | 175 | $spl_info = $this->getMetadataFull('tmp_adapter', $path); |
@@ -186,16 +186,16 @@ discard block |
||
| 186 | 186 | { |
| 187 | 187 | $files = $this->get_backup_archives_list(); |
| 188 | 188 | |
| 189 | - if(is_array($files)) |
|
| 190 | - $this->sort_by($files, "timestamp","desc"); |
|
| 189 | + if (is_array($files)) |
|
| 190 | + $this->sort_by($files, "timestamp", "desc"); |
|
| 191 | 191 | |
| 192 | 192 | $new_list = array(); |
| 193 | 193 | |
| 194 | - foreach($files as $key=>$file) |
|
| 195 | - if(!isset($file['parent'])) |
|
| 194 | + foreach ($files as $key=>$file) |
|
| 195 | + if (!isset($file['parent'])) |
|
| 196 | 196 | $new_list[] = ($files[$key]); |
| 197 | 197 | |
| 198 | - if(isset($new_list[0])) |
|
| 198 | + if (isset($new_list[0])) |
|
| 199 | 199 | return $new_list[0]; |
| 200 | 200 | } |
| 201 | 201 | |
@@ -203,13 +203,13 @@ discard block |
||
| 203 | 203 | { |
| 204 | 204 | $files = $this->get_backup_archives_list(); |
| 205 | 205 | |
| 206 | - if(is_array($files)) |
|
| 207 | - $this->sort_by($files, "timestamp","desc"); |
|
| 206 | + if (is_array($files)) |
|
| 207 | + $this->sort_by($files, "timestamp", "desc"); |
|
| 208 | 208 | |
| 209 | 209 | $new_list = array(); |
| 210 | 210 | |
| 211 | - foreach($files as $key=>$file) |
|
| 212 | - if(!isset($file['parent'])) |
|
| 211 | + foreach ($files as $key=>$file) |
|
| 212 | + if (!isset($file['parent'])) |
|
| 213 | 213 | $new_list[] = ($files[$key]); |
| 214 | 214 | |
| 215 | 215 | return $new_list; |
@@ -220,8 +220,8 @@ discard block |
||
| 220 | 220 | $files = $this->get_backup_archives_list(); |
| 221 | 221 | $total = 0; |
| 222 | 222 | |
| 223 | - if(is_array($files)) |
|
| 224 | - foreach($files as $file) |
|
| 223 | + if (is_array($files)) |
|
| 224 | + foreach ($files as $file) |
|
| 225 | 225 | $total += $file['size']; |
| 226 | 226 | |
| 227 | 227 | return $total; |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | |
| 230 | 230 | public function is_part($backup_name) |
| 231 | 231 | { |
| 232 | - if(stristr($backup_name, "-part")) |
|
| 232 | + if (stristr($backup_name, "-part")) |
|
| 233 | 233 | return true; |
| 234 | 234 | |
| 235 | 235 | return false; |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | public function is_multipart($backup_name) |
| 239 | 239 | { |
| 240 | - if(stristr($backup_name, "-multipart")) |
|
| 240 | + if (stristr($backup_name, "-multipart")) |
|
| 241 | 241 | return true; |
| 242 | 242 | |
| 243 | 243 | return false; |
@@ -246,10 +246,10 @@ discard block |
||
| 246 | 246 | public function get_backup_size($backup_name) |
| 247 | 247 | { |
| 248 | 248 | $backup_size = $this->get_storage_filesystem()->getSize($backup_name); |
| 249 | - if($this->is_multipart($backup_name)) |
|
| 249 | + if ($this->is_multipart($backup_name)) |
|
| 250 | 250 | { |
| 251 | 251 | $backup_parts = $this->get_multipart_files($backup_name); |
| 252 | - foreach($backup_parts as $part_file) |
|
| 252 | + foreach ($backup_parts as $part_file) |
|
| 253 | 253 | $backup_size += $this->get_storage_filesystem()->getSize($part_file); |
| 254 | 254 | } |
| 255 | 255 | |
@@ -260,12 +260,12 @@ discard block |
||
| 260 | 260 | { |
| 261 | 261 | $files = array(); |
| 262 | 262 | |
| 263 | - if($this->is_multipart($backup_name)) |
|
| 263 | + if ($this->is_multipart($backup_name)) |
|
| 264 | 264 | { |
| 265 | 265 | $lines = explode(PHP_EOL, $this->get_storage_filesystem($storage_selection)->read($backup_name)); |
| 266 | - foreach($lines as $line) |
|
| 266 | + foreach ($lines as $line) |
|
| 267 | 267 | { |
| 268 | - if($line) |
|
| 268 | + if ($line) |
|
| 269 | 269 | { |
| 270 | 270 | $data = str_getcsv($line); |
| 271 | 271 | $files[] = $data[0]; |
@@ -278,12 +278,12 @@ discard block |
||
| 278 | 278 | |
| 279 | 279 | public function delete_backup_by_name($backup_name, $storage_selection = "") |
| 280 | 280 | { |
| 281 | - if($this->is_multipart($backup_name)) |
|
| 281 | + if ($this->is_multipart($backup_name)) |
|
| 282 | 282 | { |
| 283 | 283 | $lines = explode(PHP_EOL, $this->get_storage_filesystem($storage_selection)->read($backup_name)); |
| 284 | - foreach($lines as $line) |
|
| 284 | + foreach ($lines as $line) |
|
| 285 | 285 | { |
| 286 | - if($line) |
|
| 286 | + if ($line) |
|
| 287 | 287 | { |
| 288 | 288 | $data = str_getcsv($line); |
| 289 | 289 | $this->get_storage_filesystem($storage_selection)->delete($data[0]); |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | } |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - if($this->get_storage_filesystem($storage_selection)->delete($backup_name)) |
|
| 294 | + if ($this->get_storage_filesystem($storage_selection)->delete($backup_name)) |
|
| 295 | 295 | $return = true; |
| 296 | 296 | else |
| 297 | 297 | $return = false; |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | return $return; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - public function getMetadataFull($adapter = "storage_adapter" , $path) |
|
| 302 | + public function getMetadataFull($adapter = "storage_adapter", $path) |
|
| 303 | 303 | { |
| 304 | 304 | $location = $this->$adapter->applyPathPrefix($path); |
| 305 | 305 | $spl_info = new SplFileInfo($location); |
@@ -313,25 +313,25 @@ discard block |
||
| 313 | 313 | $list = array(); |
| 314 | 314 | |
| 315 | 315 | |
| 316 | - if(method_exists($this->get_storage_filesystem($storage_selection), "listContents")) |
|
| 316 | + if (method_exists($this->get_storage_filesystem($storage_selection), "listContents")) |
|
| 317 | 317 | $list = $this->get_storage_filesystem($storage_selection)->listContents(); |
| 318 | 318 | |
| 319 | 319 | |
| 320 | 320 | $backup_files = array(); |
| 321 | 321 | $parents = array(); |
| 322 | 322 | |
| 323 | - foreach($list as $file_info) |
|
| 323 | + foreach ($list as $file_info) |
|
| 324 | 324 | { |
| 325 | - if(isset($file_info['extension']) and $file_info['extension'] == "csv") |
|
| 325 | + if (isset($file_info['extension']) and $file_info['extension'] == "csv") |
|
| 326 | 326 | { |
| 327 | 327 | $data = array(); |
| 328 | 328 | |
| 329 | 329 | $lines = explode(PHP_EOL, $this->get_storage_filesystem($storage_selection)->read($file_info['path'])); |
| 330 | - foreach($lines as $line) |
|
| 331 | - if($line) |
|
| 330 | + foreach ($lines as $line) |
|
| 331 | + if ($line) |
|
| 332 | 332 | { |
| 333 | 333 | $data = str_getcsv($line); |
| 334 | - if(is_array($data)){ |
|
| 334 | + if (is_array($data)) { |
|
| 335 | 335 | $parents[$data[0]] = $file_info['basename']; |
| 336 | 336 | $file_info['childs'][] = $data; |
| 337 | 337 | $file_info['size'] += $data[2]; |
@@ -340,18 +340,18 @@ discard block |
||
| 340 | 340 | |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) |
|
| 343 | + if ($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) |
|
| 344 | 344 | $backup_files[$file_info['path']] = $file_info; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - foreach($backup_files as $key=>$file_info) |
|
| 347 | + foreach ($backup_files as $key=>$file_info) |
|
| 348 | 348 | { |
| 349 | - if(!isset($backup_files[$key]['timestamp'])) |
|
| 349 | + if (!isset($backup_files[$key]['timestamp'])) |
|
| 350 | 350 | { |
| 351 | 351 | //$backup_files[$key]['timestamp'] = $this->get_storage_filesystem($storage_selection)->getTimestamp($file_info['path']); |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - if(isset($parents[$file_info['basename']])) |
|
| 354 | + if (isset($parents[$file_info['basename']])) |
|
| 355 | 355 | $backup_files[$key]['parent'] = $parents[$file_info['basename']]; |
| 356 | 356 | } |
| 357 | 357 | |
@@ -360,40 +360,40 @@ discard block |
||
| 360 | 360 | |
| 361 | 361 | public function start_file_recursion($init = 0) |
| 362 | 362 | { |
| 363 | - if($init) |
|
| 363 | + if ($init) |
|
| 364 | 364 | { |
| 365 | 365 | $this->logger->info(sprintf(__("Starting the filesystem scanner on root folder %s"), $this->xcloner_settings->get_xcloner_start_path())); |
| 366 | 366 | $this->do_system_init(); |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - if($this->tmp_filesystem->has($this->get_temp_dir_handler())){ |
|
| 369 | + if ($this->tmp_filesystem->has($this->get_temp_dir_handler())) { |
|
| 370 | 370 | //.dir exists, we presume we have files to iterate |
| 371 | 371 | $content = $this->tmp_filesystem->read($this->get_temp_dir_handler()); |
| 372 | 372 | $files = array_filter(explode("\n", $content)); |
| 373 | 373 | $this->tmp_filesystem->delete($this->get_temp_dir_handler()); |
| 374 | 374 | |
| 375 | 375 | $counter = 0; |
| 376 | - foreach($files as $file) |
|
| 376 | + foreach ($files as $file) |
|
| 377 | 377 | { |
| 378 | - if($counter < $this->folders_to_process_per_session){ |
|
| 378 | + if ($counter < $this->folders_to_process_per_session) { |
|
| 379 | 379 | $this->build_files_list($file); |
| 380 | 380 | $counter++; |
| 381 | - }else{ |
|
| 381 | + } else { |
|
| 382 | 382 | $this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file."\n"); |
| 383 | 383 | } |
| 384 | 384 | } |
| 385 | - }else{ |
|
| 385 | + } else { |
|
| 386 | 386 | $this->build_files_list(); |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - if($this->scan_finished()) |
|
| 389 | + if ($this->scan_finished()) |
|
| 390 | 390 | { |
| 391 | 391 | $metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata("index.html"); |
| 392 | 392 | $this->store_file($metadata_dumpfile, 'tmp_filesystem'); |
| 393 | 393 | $this->files_counter++; |
| 394 | 394 | |
| 395 | 395 | //adding included dump file to the included files list |
| 396 | - if($this->get_tmp_filesystem()->has($this->get_included_files_handler())) |
|
| 396 | + if ($this->get_tmp_filesystem()->has($this->get_included_files_handler())) |
|
| 397 | 397 | { |
| 398 | 398 | $metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata($this->get_included_files_handler()); |
| 399 | 399 | $this->store_file($metadata_dumpfile, 'tmp_filesystem'); |
@@ -401,13 +401,13 @@ discard block |
||
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | //adding a default index.html to the temp xcloner folder |
| 404 | - if(!$this->get_tmp_filesystem()->has("index.html")) |
|
| 404 | + if (!$this->get_tmp_filesystem()->has("index.html")) |
|
| 405 | 405 | { |
| 406 | - $this->get_tmp_filesystem()->write("index.html",""); |
|
| 406 | + $this->get_tmp_filesystem()->write("index.html", ""); |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | //adding the default log file |
| 410 | - if($this->get_tmp_filesystem()->has($this->xcloner_settings->get_logger_filename(1))) |
|
| 410 | + if ($this->get_tmp_filesystem()->has($this->xcloner_settings->get_logger_filename(1))) |
|
| 411 | 411 | { |
| 412 | 412 | $metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata($this->xcloner_settings->get_logger_filename(1)); |
| 413 | 413 | $this->store_file($metadata_dumpfile, 'tmp_filesystem'); |
@@ -425,20 +425,20 @@ discard block |
||
| 425 | 425 | $return = array(); |
| 426 | 426 | |
| 427 | 427 | $files_list_file = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->get_included_files_handler(); |
| 428 | - if(file_exists($files_list_file)) |
|
| 428 | + if (file_exists($files_list_file)) |
|
| 429 | 429 | { |
| 430 | 430 | $return[] = $files_list_file; |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) |
|
| 433 | + if ($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) |
|
| 434 | 434 | { |
| 435 | 435 | $log_file = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->xcloner_settings->get_logger_filename(1); |
| 436 | - if(!file_exists($log_file)) |
|
| 436 | + if (!file_exists($log_file)) |
|
| 437 | 437 | { |
| 438 | 438 | $log_file = $this->xcloner_settings->get_xcloner_store_path().DS.$this->xcloner_settings->get_logger_filename(); |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | - if(file_exists($log_file)) |
|
| 441 | + if (file_exists($log_file)) |
|
| 442 | 442 | { |
| 443 | 443 | $return[] = $log_file; |
| 444 | 444 | } |
@@ -454,8 +454,8 @@ discard block |
||
| 454 | 454 | |
| 455 | 455 | $contents = $this->get_tmp_filesystem()->listContents(); |
| 456 | 456 | |
| 457 | - if(is_array($contents)) |
|
| 458 | - foreach($contents as $file_info) |
|
| 457 | + if (is_array($contents)) |
|
| 458 | + foreach ($contents as $file_info) |
|
| 459 | 459 | $this->get_tmp_filesystem()->delete($file_info['path']); |
| 460 | 460 | |
| 461 | 461 | @rmdir($this->xcloner_settings->get_xcloner_tmp_path()); |
@@ -465,19 +465,19 @@ discard block |
||
| 465 | 465 | |
| 466 | 466 | public function cleanup_tmp_directories() |
| 467 | 467 | { |
| 468 | - $adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(false),LOCK_EX|FILE_APPEND, 'SKIP_LINKS'); |
|
| 468 | + $adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(false), LOCK_EX | FILE_APPEND, 'SKIP_LINKS'); |
|
| 469 | 469 | $tmp_filesystem = new Filesystem($adapter, new Config([ |
| 470 | 470 | 'disable_asserts' => true, |
| 471 | 471 | ])); |
| 472 | 472 | |
| 473 | 473 | $contents = $tmp_filesystem->listContents(); |
| 474 | 474 | |
| 475 | - foreach($contents as $file) |
|
| 475 | + foreach ($contents as $file) |
|
| 476 | 476 | { |
| 477 | 477 | |
| 478 | - if(preg_match("/.xcloner-(.*)/",$file['path'])) |
|
| 478 | + if (preg_match("/.xcloner-(.*)/", $file['path'])) |
|
| 479 | 479 | { |
| 480 | - if($file['timestamp'] < strtotime("-1days")) |
|
| 480 | + if ($file['timestamp'] < strtotime("-1days")) |
|
| 481 | 481 | { |
| 482 | 482 | $tmp_filesystem->deleteDir($file['path']); |
| 483 | 483 | $this->logger->info(sprintf("Delete temporary directory %s", $file['path'])); |
@@ -492,16 +492,16 @@ discard block |
||
| 492 | 492 | { |
| 493 | 493 | $this->files_counter = 0; |
| 494 | 494 | |
| 495 | - if(!$this->storage_filesystem->has("index.html")) |
|
| 496 | - $this->storage_filesystem->write("index.html",""); |
|
| 495 | + if (!$this->storage_filesystem->has("index.html")) |
|
| 496 | + $this->storage_filesystem->write("index.html", ""); |
|
| 497 | 497 | |
| 498 | - if(!$this->tmp_filesystem->has("index.html")) |
|
| 499 | - $this->tmp_filesystem->write("index.html",""); |
|
| 498 | + if (!$this->tmp_filesystem->has("index.html")) |
|
| 499 | + $this->tmp_filesystem->write("index.html", ""); |
|
| 500 | 500 | |
| 501 | - if($this->tmp_filesystem->has($this->get_included_files_handler())) |
|
| 501 | + if ($this->tmp_filesystem->has($this->get_included_files_handler())) |
|
| 502 | 502 | $this->tmp_filesystem->delete($this->get_included_files_handler()); |
| 503 | 503 | |
| 504 | - if($this->tmp_filesystem->has($this->get_temp_dir_handler())) |
|
| 504 | + if ($this->tmp_filesystem->has($this->get_temp_dir_handler())) |
|
| 505 | 505 | $this->tmp_filesystem->delete($this->get_temp_dir_handler()); |
| 506 | 506 | } |
| 507 | 507 | |
@@ -521,20 +521,20 @@ discard block |
||
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | public static function is_regex($regex) { |
| 524 | - return preg_match("/^\^(.*)\$$/i",$regex); |
|
| 524 | + return preg_match("/^\^(.*)\$$/i", $regex); |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | public function set_excluded_files($excluded_files = array()) |
| 528 | 528 | { |
| 529 | - if(!is_array($excluded_files)) |
|
| 529 | + if (!is_array($excluded_files)) |
|
| 530 | 530 | { |
| 531 | 531 | $excluded_files = array(); |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | - foreach($excluded_files as $excl) |
|
| 534 | + foreach ($excluded_files as $excl) |
|
| 535 | 535 | { |
| 536 | 536 | |
| 537 | - if($this->is_regex($excl)) |
|
| 537 | + if ($this->is_regex($excl)) |
|
| 538 | 538 | { |
| 539 | 539 | $this->additional_regex_patterns[] = $excl; |
| 540 | 540 | } |
@@ -560,35 +560,35 @@ discard block |
||
| 560 | 560 | $this->logger->debug(sprintf(("Building the files system list"))); |
| 561 | 561 | |
| 562 | 562 | //if we start with the root folder(empty value), we initializa the file system |
| 563 | - if(!$folder){ |
|
| 563 | + if (!$folder) { |
|
| 564 | 564 | |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | - try{ |
|
| 567 | + try { |
|
| 568 | 568 | |
| 569 | 569 | $files = $this->start_filesystem->listContents($folder); |
| 570 | - foreach($files as $file) |
|
| 570 | + foreach ($files as $file) |
|
| 571 | 571 | { |
| 572 | - if(!is_readable($this->xcloner_settings->get_xcloner_start_path().DS.$file['path'])) |
|
| 572 | + if (!is_readable($this->xcloner_settings->get_xcloner_start_path().DS.$file['path'])) |
|
| 573 | 573 | { |
| 574 | - $this->logger->info(sprintf(__("Excluding %s from the filesystem list, file not readable"), $file['path']), array("FILESYSTEM SCAN","NOT READABLE")); |
|
| 574 | + $this->logger->info(sprintf(__("Excluding %s from the filesystem list, file not readable"), $file['path']), array("FILESYSTEM SCAN", "NOT READABLE")); |
|
| 575 | 575 | } |
| 576 | - elseif(!$matching_pattern = $this->is_excluded($file) ){ |
|
| 577 | - $this->logger->info(sprintf(__("Adding %s to the filesystem list"), $file['path']), array("FILESYSTEM SCAN","INCLUDE")); |
|
| 576 | + elseif (!$matching_pattern = $this->is_excluded($file)) { |
|
| 577 | + $this->logger->info(sprintf(__("Adding %s to the filesystem list"), $file['path']), array("FILESYSTEM SCAN", "INCLUDE")); |
|
| 578 | 578 | $file['visibility'] = $this->start_filesystem->getVisibility($file['path']); |
| 579 | - if($this->store_file($file)) |
|
| 579 | + if ($this->store_file($file)) |
|
| 580 | 580 | { |
| 581 | 581 | $this->files_counter++; |
| 582 | 582 | } |
| 583 | - if(isset($file['size'])) |
|
| 583 | + if (isset($file['size'])) |
|
| 584 | 584 | $this->files_size += $file['size']; |
| 585 | 585 | |
| 586 | - }else{ |
|
| 587 | - $this->logger->info(sprintf(__("Excluding %s from the filesystem list, matching pattern %s"), $file['path'], $matching_pattern), array("FILESYSTEM SCAN","EXCLUDE")); |
|
| 586 | + } else { |
|
| 587 | + $this->logger->info(sprintf(__("Excluding %s from the filesystem list, matching pattern %s"), $file['path'], $matching_pattern), array("FILESYSTEM SCAN", "EXCLUDE")); |
|
| 588 | 588 | } |
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - }catch(Exception $e){ |
|
| 591 | + }catch (Exception $e) { |
|
| 592 | 592 | |
| 593 | 593 | $this->logger->error($e->getMessage()); |
| 594 | 594 | |
@@ -602,9 +602,9 @@ discard block |
||
| 602 | 602 | |
| 603 | 603 | $start_time = microtime(); |
| 604 | 604 | |
| 605 | - $data = str_repeat(rand(0,9), 1024*1024); //write 1MB data |
|
| 605 | + $data = str_repeat(rand(0, 9), 1024 * 1024); //write 1MB data |
|
| 606 | 606 | |
| 607 | - try{ |
|
| 607 | + try { |
|
| 608 | 608 | $this->tmp_filesystem->write($tmp_file, $data); |
| 609 | 609 | |
| 610 | 610 | $end_time = microtime() - $start_time; |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | |
| 616 | 616 | $this->tmp_filesystem->delete($tmp_file); |
| 617 | 617 | |
| 618 | - }catch(Exception $e){ |
|
| 618 | + }catch (Exception $e) { |
|
| 619 | 619 | |
| 620 | 620 | $this->logger->error($e->getMessage()); |
| 621 | 621 | |
@@ -636,10 +636,10 @@ discard block |
||
| 636 | 636 | |
| 637 | 637 | $files = $this->storage_filesystem->listContents(); |
| 638 | 638 | |
| 639 | - if(is_array($files)) |
|
| 640 | - foreach($files as $file) |
|
| 639 | + if (is_array($files)) |
|
| 640 | + foreach ($files as $file) |
|
| 641 | 641 | { |
| 642 | - if(isset($file['extension']) and in_array($file['extension'], $this->backup_archive_extensions)) |
|
| 642 | + if (isset($file['extension']) and in_array($file['extension'], $this->backup_archive_extensions)) |
|
| 643 | 643 | { |
| 644 | 644 | $_storage_size += $file['size']; //bytes |
| 645 | 645 | $_backup_files_list[] = $file; |
@@ -647,15 +647,15 @@ discard block |
||
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | |
| 650 | - $this->sort_by($_backup_files_list, "timestamp","asc"); |
|
| 650 | + $this->sort_by($_backup_files_list, "timestamp", "asc"); |
|
| 651 | 651 | |
| 652 | 652 | $_backups_counter = sizeof($_backup_files_list); |
| 653 | 653 | |
| 654 | - foreach($_backup_files_list as $file) |
|
| 654 | + foreach ($_backup_files_list as $file) |
|
| 655 | 655 | { |
| 656 | 656 | //processing rule folder capacity |
| 657 | - if($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') && |
|
| 658 | - $_storage_size >= ($set_storage_limit = 1024*1024*$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit'))) //bytes |
|
| 657 | + if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') && |
|
| 658 | + $_storage_size >= ($set_storage_limit = 1024 * 1024 * $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit'))) //bytes |
|
| 659 | 659 | { |
| 660 | 660 | $this->storage_filesystem->delete($file['path']); |
| 661 | 661 | $_storage_size -= $file['size']; |
@@ -663,14 +663,14 @@ discard block |
||
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | //processing rule days limit |
| 666 | - if($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days') && $current_timestamp >= $file['timestamp']) |
|
| 666 | + if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days') && $current_timestamp >= $file['timestamp']) |
|
| 667 | 667 | { |
| 668 | 668 | $this->storage_filesystem->delete($file['path']); |
| 669 | 669 | $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'))); |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | //processing backup countert limit |
| 673 | - 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')) |
|
| 673 | + 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')) |
|
| 674 | 674 | { |
| 675 | 675 | $this->storage_filesystem->delete($file['path']); |
| 676 | 676 | $_backups_counter--; |
@@ -696,33 +696,33 @@ discard block |
||
| 696 | 696 | |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | - public function process_backup_name($name = "", $max_length=100) |
|
| 699 | + public function process_backup_name($name = "", $max_length = 100) |
|
| 700 | 700 | { |
| 701 | - if(!$name) |
|
| 701 | + if (!$name) |
|
| 702 | 702 | $name = $this->xcloner_settings->get_default_backup_name(); |
| 703 | 703 | |
| 704 | - foreach($this->backup_name_tags as $tag) |
|
| 704 | + foreach ($this->backup_name_tags as $tag) |
|
| 705 | 705 | { |
| 706 | - if($tag == '[time]') |
|
| 707 | - $name = str_replace($tag, date("Y-m-d_H-i"),$name); |
|
| 708 | - elseif($tag == '[hostname]') |
|
| 709 | - $name = str_replace($tag, gethostname() ,$name); |
|
| 710 | - elseif($tag == '[domain]') |
|
| 706 | + if ($tag == '[time]') |
|
| 707 | + $name = str_replace($tag, date("Y-m-d_H-i"), $name); |
|
| 708 | + elseif ($tag == '[hostname]') |
|
| 709 | + $name = str_replace($tag, gethostname(), $name); |
|
| 710 | + elseif ($tag == '[domain]') |
|
| 711 | 711 | { |
| 712 | 712 | $domain = parse_url(admin_url(), PHP_URL_HOST); |
| 713 | - $name = str_replace($tag, $domain ,$name); |
|
| 713 | + $name = str_replace($tag, $domain, $name); |
|
| 714 | 714 | } |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | - if($max_length) |
|
| 717 | + if ($max_length) |
|
| 718 | 718 | $name = substr($name, 0, $max_length); |
| 719 | 719 | |
| 720 | 720 | return $name; |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | - public function sort_by( &$array, $field, $direction = 'asc') |
|
| 723 | + public function sort_by(&$array, $field, $direction = 'asc') |
|
| 724 | 724 | { |
| 725 | - if(strtolower($direction) == "desc" || $direction == SORT_DESC) |
|
| 725 | + if (strtolower($direction) == "desc" || $direction == SORT_DESC) |
|
| 726 | 726 | $direction = SORT_DESC; |
| 727 | 727 | else |
| 728 | 728 | $direction = SORT_ASC; |
@@ -742,7 +742,7 @@ discard block |
||
| 742 | 742 | $tmp = array(); |
| 743 | 743 | foreach ($data as $key => $row) |
| 744 | 744 | { |
| 745 | - if(is_array($row)) |
|
| 745 | + if (is_array($row)) |
|
| 746 | 746 | $tmp[$key] = $row[$field]; |
| 747 | 747 | else |
| 748 | 748 | $tmp[$key] = $row->$field; |
@@ -759,18 +759,18 @@ discard block |
||
| 759 | 759 | |
| 760 | 760 | private function check_file_diff_time($file) |
| 761 | 761 | { |
| 762 | - if($this->get_diff_timestamp_start() != "") |
|
| 762 | + if ($this->get_diff_timestamp_start() != "") |
|
| 763 | 763 | { |
| 764 | 764 | $fileMeta = $this->getMetadataFull("start_adapter", $file['path']); |
| 765 | 765 | $timestamp = $fileMeta->getMTime(); |
| 766 | - if($timestamp < $fileMeta->getCTime()) |
|
| 766 | + if ($timestamp < $fileMeta->getCTime()) |
|
| 767 | 767 | { |
| 768 | 768 | $timestamp = $fileMeta->getCTime(); |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | - if($timestamp <= $this->get_diff_timestamp_start()) |
|
| 771 | + if ($timestamp <= $this->get_diff_timestamp_start()) |
|
| 772 | 772 | { |
| 773 | - return " file DIFF timestamp ".$timestamp." < ". $this->diff_timestamp_start; |
|
| 773 | + return " file DIFF timestamp ".$timestamp." < ".$this->diff_timestamp_start; |
|
| 774 | 774 | } |
| 775 | 775 | } |
| 776 | 776 | |
@@ -781,37 +781,37 @@ discard block |
||
| 781 | 781 | { |
| 782 | 782 | $this->logger->debug(sprintf(("Checking if %s is excluded"), $file['path'])); |
| 783 | 783 | |
| 784 | - if($xcloner_exclude_files_larger_than_mb = $this->xcloner_settings->get_xcloner_option('xcloner_exclude_files_larger_than_mb')) |
|
| 784 | + if ($xcloner_exclude_files_larger_than_mb = $this->xcloner_settings->get_xcloner_option('xcloner_exclude_files_larger_than_mb')) |
|
| 785 | 785 | { |
| 786 | - if(isset($file['size']) && $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb)) |
|
| 786 | + if (isset($file['size']) && $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb)) |
|
| 787 | 787 | return "> ".$xcloner_exclude_files_larger_than_mb."MB"; |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | - if(!sizeof($this->excluded_files)) |
|
| 790 | + if (!sizeof($this->excluded_files)) |
|
| 791 | 791 | { |
| 792 | 792 | $this->set_excluded_files(); |
| 793 | 793 | } |
| 794 | 794 | |
| 795 | - if(is_array($this->excluded_files)) |
|
| 796 | - foreach($this->excluded_files as $excluded_file_pattern) |
|
| 795 | + if (is_array($this->excluded_files)) |
|
| 796 | + foreach ($this->excluded_files as $excluded_file_pattern) |
|
| 797 | 797 | { |
| 798 | - if($excluded_file_pattern == "/") |
|
| 798 | + if ($excluded_file_pattern == "/") |
|
| 799 | 799 | $needle = "$"; |
| 800 | 800 | else |
| 801 | 801 | $needle = "$".$excluded_file_pattern; |
| 802 | 802 | |
| 803 | - if(strstr("$".$file['path'], $needle)){ |
|
| 803 | + if (strstr("$".$file['path'], $needle)) { |
|
| 804 | 804 | return $excluded_file_pattern; |
| 805 | 805 | } |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | - if( $regex = $this->is_excluded_regex($file)) |
|
| 808 | + if ($regex = $this->is_excluded_regex($file)) |
|
| 809 | 809 | return $regex; |
| 810 | 810 | |
| 811 | - if($file['type'] == "file") |
|
| 811 | + if ($file['type'] == "file") |
|
| 812 | 812 | { |
| 813 | 813 | $check_file_diff_timestamp = $this->check_file_diff_time($file); |
| 814 | - if($check_file_diff_timestamp) |
|
| 814 | + if ($check_file_diff_timestamp) |
|
| 815 | 815 | { |
| 816 | 816 | return $check_file_diff_timestamp; |
| 817 | 817 | } |
@@ -858,32 +858,32 @@ discard block |
||
| 858 | 858 | |
| 859 | 859 | $regex_patterns = explode(PHP_EOL, $this->xcloner_settings->get_xcloner_option('xcloner_regex_exclude')); |
| 860 | 860 | |
| 861 | - if(is_array($this->additional_regex_patterns)) |
|
| 861 | + if (is_array($this->additional_regex_patterns)) |
|
| 862 | 862 | { |
| 863 | 863 | $regex_patterns = array_merge($regex_patterns, $this->additional_regex_patterns); |
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | //print_r($regex_patterns);exit; |
| 867 | 867 | |
| 868 | - if(is_array($regex_patterns)) |
|
| 868 | + if (is_array($regex_patterns)) |
|
| 869 | 869 | { |
| 870 | 870 | //$this->excluded_files = array(); |
| 871 | 871 | //$this->excluded_files[] ="(.*)\.(git)(.*)$"; |
| 872 | 872 | //$this->excluded_files[] ="wp-content\/backups(.*)$"; |
| 873 | 873 | |
| 874 | - foreach($regex_patterns as $excluded_file_pattern) |
|
| 874 | + foreach ($regex_patterns as $excluded_file_pattern) |
|
| 875 | 875 | { |
| 876 | 876 | |
| 877 | - if( substr($excluded_file_pattern, strlen($excluded_file_pattern)-1, strlen($excluded_file_pattern)) == "\r") |
|
| 878 | - $excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern)-1); |
|
| 877 | + if (substr($excluded_file_pattern, strlen($excluded_file_pattern) - 1, strlen($excluded_file_pattern)) == "\r") |
|
| 878 | + $excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern) - 1); |
|
| 879 | 879 | |
| 880 | - if($file['path'] == "/") |
|
| 880 | + if ($file['path'] == "/") |
|
| 881 | 881 | $needle = "/"; |
| 882 | 882 | else |
| 883 | 883 | $needle = "/".$file['path']; |
| 884 | 884 | //echo $needle."---".$excluded_file_pattern."---\n"; |
| 885 | 885 | |
| 886 | - if(@preg_match("/(^|^\/)".$excluded_file_pattern."/i", $needle)){ |
|
| 886 | + if (@preg_match("/(^|^\/)".$excluded_file_pattern."/i", $needle)) { |
|
| 887 | 887 | return $excluded_file_pattern; |
| 888 | 888 | } |
| 889 | 889 | } |
@@ -896,36 +896,36 @@ discard block |
||
| 896 | 896 | { |
| 897 | 897 | $this->logger->debug(sprintf("Storing %s in the backup list", $file['path'])); |
| 898 | 898 | |
| 899 | - if(!isset($file['size'])) |
|
| 899 | + if (!isset($file['size'])) |
|
| 900 | 900 | $file['size'] = 0; |
| 901 | - if(!isset($file['visibility'])) |
|
| 901 | + if (!isset($file['visibility'])) |
|
| 902 | 902 | $file['visibility'] = "private"; |
| 903 | 903 | |
| 904 | - $csv_filename = str_replace('"','""', $file['path']); |
|
| 904 | + $csv_filename = str_replace('"', '""', $file['path']); |
|
| 905 | 905 | |
| 906 | 906 | $line = '"'.($csv_filename).'","'.$file['timestamp'].'","'.$file['size'].'","'.$file['visibility'].'","'.$storage.'"'.PHP_EOL; |
| 907 | 907 | |
| 908 | 908 | $this->last_logged_file = $file['path']; |
| 909 | 909 | |
| 910 | - if($file['type'] == "dir"){ |
|
| 911 | - try{ |
|
| 910 | + if ($file['type'] == "dir") { |
|
| 911 | + try { |
|
| 912 | 912 | $this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file['path']."\n"); |
| 913 | - }catch(Exception $e){ |
|
| 913 | + }catch (Exception $e) { |
|
| 914 | 914 | $this->logger->error($e->getMessage()); |
| 915 | 915 | } |
| 916 | 916 | } |
| 917 | 917 | |
| 918 | - if($this->get_diff_timestamp_start()) |
|
| 918 | + if ($this->get_diff_timestamp_start()) |
|
| 919 | 919 | { |
| 920 | - if($file['type'] != "file" && $response = $this->check_file_diff_time($file)) |
|
| 920 | + if ($file['type'] != "file" && $response = $this->check_file_diff_time($file)) |
|
| 921 | 921 | { |
| 922 | - $this->logger->info(sprintf("Directory %s archiving skipped on differential backup %s", $file['path'], $response), array("FILESYSTEM SCAN","DIR DIFF")); |
|
| 922 | + $this->logger->info(sprintf("Directory %s archiving skipped on differential backup %s", $file['path'], $response), array("FILESYSTEM SCAN", "DIR DIFF")); |
|
| 923 | 923 | return false; |
| 924 | 924 | } |
| 925 | 925 | } |
| 926 | 926 | |
| 927 | - try{ |
|
| 928 | - if(!$this->tmp_filesystem_append->has($this->get_included_files_handler())) |
|
| 927 | + try { |
|
| 928 | + if (!$this->tmp_filesystem_append->has($this->get_included_files_handler())) |
|
| 929 | 929 | { |
| 930 | 930 | //adding fix for UTF-8 CSV preview |
| 931 | 931 | $start_line = "\xEF\xBB\xBF".'"Filename","Timestamp","Size","Visibility","Storage"'.PHP_EOL; |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | |
| 935 | 935 | $this->tmp_filesystem_append->write($this->get_included_files_handler(), $line); |
| 936 | 936 | |
| 937 | - }catch(Exception $e){ |
|
| 937 | + }catch (Exception $e) { |
|
| 938 | 938 | |
| 939 | 939 | $this->logger->error($e->getMessage()); |
| 940 | 940 | } |
@@ -949,13 +949,13 @@ discard block |
||
| 949 | 949 | |
| 950 | 950 | public function get_filesystem($system = "") |
| 951 | 951 | { |
| 952 | - if($system == "storage_filesystem_append") |
|
| 952 | + if ($system == "storage_filesystem_append") |
|
| 953 | 953 | return $this->storage_filesystem_append; |
| 954 | - elseif($system == "tmp_filesystem_append") |
|
| 954 | + elseif ($system == "tmp_filesystem_append") |
|
| 955 | 955 | return $this->tmp_filesystem_append; |
| 956 | - elseif($system == "tmp_filesystem") |
|
| 956 | + elseif ($system == "tmp_filesystem") |
|
| 957 | 957 | return $this->tmp_filesystem; |
| 958 | - elseif($system == "storage_filesystem") |
|
| 958 | + elseif ($system == "storage_filesystem") |
|
| 959 | 959 | return $this->storage_filesystem; |
| 960 | 960 | else |
| 961 | 961 | return $this->start_filesystem; |
@@ -963,9 +963,9 @@ discard block |
||
| 963 | 963 | |
| 964 | 964 | public function get_adapter($system) |
| 965 | 965 | { |
| 966 | - if($system == "tmp_filesystem") |
|
| 966 | + if ($system == "tmp_filesystem") |
|
| 967 | 967 | return $this->tmp_adapter; |
| 968 | - elseif($system == "storage_filesystem") |
|
| 968 | + elseif ($system == "storage_filesystem") |
|
| 969 | 969 | return $this->storage_adapter; |
| 970 | 970 | else |
| 971 | 971 | return $this->start_adapter; |
@@ -973,10 +973,10 @@ discard block |
||
| 973 | 973 | |
| 974 | 974 | private function scan_finished() |
| 975 | 975 | { |
| 976 | - if($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler())) |
|
| 976 | + if ($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler())) |
|
| 977 | 977 | return false; |
| 978 | 978 | |
| 979 | - if($this->tmp_filesystem->has($this->get_temp_dir_handler())) |
|
| 979 | + if ($this->tmp_filesystem->has($this->get_temp_dir_handler())) |
|
| 980 | 980 | $this->tmp_filesystem->delete($this->get_temp_dir_handler()); |
| 981 | 981 | |
| 982 | 982 | $this->logger->debug(sprintf(("File scan finished"))); |
@@ -986,7 +986,7 @@ discard block |
||
| 986 | 986 | |
| 987 | 987 | private function calc_to_bytes($mb_size) |
| 988 | 988 | { |
| 989 | - return $mb_size*(1024*1024); |
|
| 989 | + return $mb_size * (1024 * 1024); |
|
| 990 | 990 | } |
| 991 | 991 | |
| 992 | 992 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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' |
@@ -228,25 +228,25 @@ discard block |
||
| 228 | 228 | #$this->get_xcloner_container()->get_xcloner_settings()->set_hash($hash); |
| 229 | 229 | |
| 230 | 230 | //$this->xcloner_settings = $this->get_xcloner_container()->get_xcloner_settings(); |
| 231 | - $this->xcloner_file_system = $this->get_xcloner_container()->get_xcloner_filesystem(); |
|
| 232 | - $this->xcloner_database = $this->get_xcloner_container()->get_xcloner_database(); |
|
| 233 | - $this->archive_system = $this->get_xcloner_container()->get_archive_system(); |
|
| 234 | - $this->logger = $this->get_xcloner_container()->get_xcloner_logger()->withName("xcloner_scheduler"); |
|
| 235 | - $this->xcloner_remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage(); |
|
| 231 | + $this->xcloner_file_system = $this->get_xcloner_container()->get_xcloner_filesystem(); |
|
| 232 | + $this->xcloner_database = $this->get_xcloner_container()->get_xcloner_database(); |
|
| 233 | + $this->archive_system = $this->get_xcloner_container()->get_archive_system(); |
|
| 234 | + $this->logger = $this->get_xcloner_container()->get_xcloner_logger()->withName("xcloner_scheduler"); |
|
| 235 | + $this->xcloner_remote_storage = $this->get_xcloner_container()->get_xcloner_remote_storage(); |
|
| 236 | 236 | |
| 237 | 237 | $this->logger->info(sprintf("New schedule hash is %s", $this->xcloner_settings->get_hash())); |
| 238 | 238 | |
| 239 | - if(isset($schedule['backup_params']->diff_start_date) && $schedule['backup_params']->diff_start_date) |
|
| 239 | + if (isset($schedule['backup_params']->diff_start_date) && $schedule['backup_params']->diff_start_date) |
|
| 240 | 240 | { |
| 241 | 241 | $this->xcloner_file_system->set_diff_timestamp_start($schedule['backup_params']->diff_start_date); |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - if($schedule['recurrence'] == "single") |
|
| 244 | + if ($schedule['recurrence'] == "single") |
|
| 245 | 245 | { |
| 246 | 246 | $this->disable_single_cron($schedule['id']); |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - if(!$schedule) |
|
| 249 | + if (!$schedule) |
|
| 250 | 250 | { |
| 251 | 251 | $this->logger->info(sprintf("Could not load schedule with id'%s'", $id), array("CRON")); |
| 252 | 252 | return; |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | $init = 1; |
| 264 | 264 | $continue = 1; |
| 265 | 265 | |
| 266 | - while($continue) |
|
| 266 | + while ($continue) |
|
| 267 | 267 | { |
| 268 | 268 | $continue = $this->xcloner_file_system->start_file_recursion($init); |
| 269 | 269 | |
@@ -277,9 +277,9 @@ discard block |
||
| 277 | 277 | $init = 1; |
| 278 | 278 | $return['finished'] = 0; |
| 279 | 279 | |
| 280 | - while(!$return['finished']) |
|
| 280 | + while (!$return['finished']) |
|
| 281 | 281 | { |
| 282 | - $return = $this->xcloner_database->start_database_recursion((array)json_decode($schedule['table_params']), $return, $init); |
|
| 282 | + $return = $this->xcloner_database->start_database_recursion((array)json_decode($schedule['table_params']), $return, $init); |
|
| 283 | 283 | $init = 0; |
| 284 | 284 | } |
| 285 | 285 | |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | $return['finished'] = 0; |
| 292 | 292 | $return['extra'] = array(); |
| 293 | 293 | |
| 294 | - while(!$return['finished']) |
|
| 294 | + while (!$return['finished']) |
|
| 295 | 295 | { |
| 296 | 296 | $return = $this->archive_system->start_incremental_backup((array)$schedule['backup_params'], $return['extra'], $init); |
| 297 | 297 | $init = 0; |
@@ -300,40 +300,40 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | //getting the last backup archive file |
| 302 | 302 | $return['extra']['backup_parent'] = $this->archive_system->get_archive_name_with_extension(); |
| 303 | - if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension())) |
|
| 303 | + if ($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension())) |
|
| 304 | 304 | $return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart(); |
| 305 | 305 | |
| 306 | 306 | $this->update_last_backup($schedule['id'], $return['extra']['backup_parent']); |
| 307 | 307 | |
| 308 | - if(isset($schedule['remote_storage']) && $schedule['remote_storage'] && array_key_exists($schedule['remote_storage'], $this->xcloner_remote_storage->get_available_storages())) |
|
| 308 | + if (isset($schedule['remote_storage']) && $schedule['remote_storage'] && array_key_exists($schedule['remote_storage'], $this->xcloner_remote_storage->get_available_storages())) |
|
| 309 | 309 | { |
| 310 | 310 | $backup_file = $return['extra']['backup_parent']; |
| 311 | 311 | |
| 312 | 312 | $this->logger->info(sprintf("Transferring backup to remote storage %s", strtoupper($schedule['remote_storage'])), array("CRON")); |
| 313 | 313 | |
| 314 | - if(method_exists($this->xcloner_remote_storage, "upload_backup_to_storage")) |
|
| 314 | + if (method_exists($this->xcloner_remote_storage, "upload_backup_to_storage")) |
|
| 315 | 315 | call_user_func_array(array($this->xcloner_remote_storage, "upload_backup_to_storage"), array($backup_file, $schedule['remote_storage'])); |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - if(isset($schedule['backup_params']->email_notification) and $to=$schedule['backup_params']->email_notification) |
|
| 318 | + if (isset($schedule['backup_params']->email_notification) and $to = $schedule['backup_params']->email_notification) |
|
| 319 | 319 | { |
| 320 | - try{ |
|
| 320 | + try { |
|
| 321 | 321 | $from = ""; |
| 322 | 322 | $additional['lines_total'] = $return['extra']['lines_total']; |
| 323 | - $subject = sprintf(__("%s - new backup generated %s") , $schedule['name'], $return['extra']['backup_parent']); |
|
| 323 | + $subject = sprintf(__("%s - new backup generated %s"), $schedule['name'], $return['extra']['backup_parent']); |
|
| 324 | 324 | |
| 325 | 325 | $this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'], $schedule, "", $additional); |
| 326 | 326 | |
| 327 | - }catch(Exception $e) |
|
| 327 | + }catch (Exception $e) |
|
| 328 | 328 | { |
| 329 | 329 | $this->logger->error($e->getMessage()); |
| 330 | 330 | } |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | //CHECK IF WE SHOULD DELETE BACKUP AFTER REMOTE TRANSFER IS DONE |
| 334 | - if($schedule['remote_storage'] && $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_delete_after_remote_transfer')) |
|
| 334 | + if ($schedule['remote_storage'] && $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_delete_after_remote_transfer')) |
|
| 335 | 335 | { |
| 336 | - $this->logger->info(sprintf("Deleting %s from local storage matching rule xcloner_cleanup_delete_after_remote_transfer",$return['extra']['backup_parent'])); |
|
| 336 | + $this->logger->info(sprintf("Deleting %s from local storage matching rule xcloner_cleanup_delete_after_remote_transfer", $return['extra']['backup_parent'])); |
|
| 337 | 337 | $this->xcloner_file_system->delete_backup_by_name($return['extra']['backup_parent']); |
| 338 | 338 | |
| 339 | 339 | } |
@@ -345,27 +345,27 @@ discard block |
||
| 345 | 345 | |
| 346 | 346 | public function xcloner_scheduler_callback($id, $schedule = "") |
| 347 | 347 | { |
| 348 | - if($id) |
|
| 348 | + if ($id) |
|
| 349 | 349 | { |
| 350 | 350 | $schedule = $this->get_schedule_by_id($id); |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - try{ |
|
| 353 | + try { |
|
| 354 | 354 | |
| 355 | 355 | $this->__xcloner_scheduler_callback($id, $schedule); |
| 356 | 356 | |
| 357 | - }catch(Exception $e){ |
|
| 357 | + }catch (Exception $e) { |
|
| 358 | 358 | |
| 359 | 359 | //send email to site admin if email notification is not set in the scheduler |
| 360 | - if(!isset($schedule['backup_params']->email_notification) || !$schedule['backup_params']->email_notification) |
|
| 360 | + if (!isset($schedule['backup_params']->email_notification) || !$schedule['backup_params']->email_notification) |
|
| 361 | 361 | { |
| 362 | 362 | $schedule['backup_params']->email_notification = get_option('admin_email'); |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - if(isset($schedule['backup_params']->email_notification) && $to=$schedule['backup_params']->email_notification) |
|
| 365 | + if (isset($schedule['backup_params']->email_notification) && $to = $schedule['backup_params']->email_notification) |
|
| 366 | 366 | { |
| 367 | 367 | $from = ""; |
| 368 | - $this->archive_system->send_notification($to, $from, $schedule['name']." - backup error","", "", $e->getMessage()); |
|
| 368 | + $this->archive_system->send_notification($to, $from, $schedule['name']." - backup error", "", "", $e->getMessage()); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | } |
@@ -378,10 +378,10 @@ discard block |
||
| 378 | 378 | $new_schedules = array(); |
| 379 | 379 | |
| 380 | 380 | foreach ($schedules as $key => $row) { |
| 381 | - if(in_array($key, $this->allowed_schedules)) |
|
| 381 | + if (in_array($key, $this->allowed_schedules)) |
|
| 382 | 382 | { |
| 383 | 383 | $new_schedules[$key] = $row; |
| 384 | - $intervals[$key] = $row['interval']; |
|
| 384 | + $intervals[$key] = $row['interval']; |
|
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | |
@@ -48,10 +48,11 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -300,8 +302,9 @@ discard block |
||
| 300 | 302 | |
| 301 | 303 | //getting the last backup archive file |
| 302 | 304 | $return['extra']['backup_parent'] = $this->archive_system->get_archive_name_with_extension(); |
| 303 | - if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension())) |
|
| 304 | - $return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart(); |
|
| 305 | + if($this->xcloner_file_system->is_part($this->archive_system->get_archive_name_with_extension())) { |
|
| 306 | + $return['extra']['backup_parent'] = $this->archive_system->get_archive_name_multipart(); |
|
| 307 | + } |
|
| 305 | 308 | |
| 306 | 309 | $this->update_last_backup($schedule['id'], $return['extra']['backup_parent']); |
| 307 | 310 | |
@@ -311,8 +314,9 @@ discard block |
||
| 311 | 314 | |
| 312 | 315 | $this->logger->info(sprintf("Transferring backup to remote storage %s", strtoupper($schedule['remote_storage'])), array("CRON")); |
| 313 | 316 | |
| 314 | - if(method_exists($this->xcloner_remote_storage, "upload_backup_to_storage")) |
|
| 315 | - call_user_func_array(array($this->xcloner_remote_storage, "upload_backup_to_storage"), array($backup_file, $schedule['remote_storage'])); |
|
| 317 | + if(method_exists($this->xcloner_remote_storage, "upload_backup_to_storage")) { |
|
| 318 | + call_user_func_array(array($this->xcloner_remote_storage, "upload_backup_to_storage"), array($backup_file, $schedule['remote_storage'])); |
|
| 319 | + } |
|
| 316 | 320 | } |
| 317 | 321 | |
| 318 | 322 | if(isset($schedule['backup_params']->email_notification) and $to=$schedule['backup_params']->email_notification) |
@@ -324,7 +328,7 @@ discard block |
||
| 324 | 328 | |
| 325 | 329 | $this->archive_system->send_notification($to, $from, $subject, $return['extra']['backup_parent'], $schedule, "", $additional); |
| 326 | 330 | |
| 327 | - }catch(Exception $e) |
|
| 331 | + } catch(Exception $e) |
|
| 328 | 332 | { |
| 329 | 333 | $this->logger->error($e->getMessage()); |
| 330 | 334 | } |
@@ -354,7 +358,7 @@ discard block |
||
| 354 | 358 | |
| 355 | 359 | $this->__xcloner_scheduler_callback($id, $schedule); |
| 356 | 360 | |
| 357 | - }catch(Exception $e){ |
|
| 361 | + } catch(Exception $e){ |
|
| 358 | 362 | |
| 359 | 363 | //send email to site admin if email notification is not set in the scheduler |
| 360 | 364 | if(!isset($schedule['backup_params']->email_notification) || !$schedule['backup_params']->email_notification) |