Refactoring

This commit is contained in:
thanghv 2020-05-19 01:15:36 +07:00
parent bfea2ad02f
commit 9d8ed1259c
7 changed files with 813 additions and 802 deletions

View file

@ -268,6 +268,21 @@ class MainWP_Backup {
}
if ( $addConfig ) {
$this->add_config();
}
$return = $this->zip->close();
foreach ( $db_files as $db_file ) {
unlink( $db_file );
}
return true;
}
return false;
}
public function add_config(){
global $wpdb;
$plugins = array();
$dir = WP_CONTENT_DIR . '/plugins/';
@ -332,17 +347,6 @@ class MainWP_Backup {
$this->add_file_from_string_to_zip( 'clone/config.txt', $string );
}
$return = $this->zip->close();
foreach ( $db_files as $db_file ) {
unlink( $db_file );
}
return true;
}
return false;
}
public function copy_dir( $nodes, $excludes, $backupfolder, $excludenonwp, $root ) {
if ( ! is_array( $nodes ) ) {
return;

View file

@ -81,7 +81,6 @@ class MainWP_Child_Back_Up_WordPress {
$information['error'] = 'NO_BACKUPWORDPRESS';
mainwp_child_helper()->write( $information );
}
if ( isset( $_POST['mwp_action'] ) ) {
switch ( $_POST['mwp_action'] ) {
case 'set_showhide':
@ -547,6 +546,52 @@ class MainWP_Child_Back_Up_WordPress {
<div class="hmbkp-exclude-settings">
<h3><?php esc_html_e( 'Currently Excluded', 'mainwp-child' ); ?></h3>
<p><?php esc_html_e( 'We automatically detect and ignore common <abbr title="Version Control Systems">VCS</abbr> folders and other backup plugin folders.', 'mainwp-child' ); ?></p>
<?php
$this->render_table_excluded( $root_dir, $schedule, $excludes, $user_excludes, $new_version )
?>
<h3 id="directory-listing"><?php esc_html_e( 'Your Site', 'mainwp-child' ); ?></h3>
<p><?php esc_html_e( 'Here\'s a directory listing of all files on your site, you can browse through and exclude files or folders that you don\'t want included in your backup.', 'mainwp-child' ); ?></p>
<?php
$directory = $root_dir;
if ( isset( $browse_dir ) ) {
$untrusted_directory = rawurldecode( $browse_dir );
// Only allow real sub directories of the site root to be browsed.
if ( false !== strpos( $untrusted_directory, $root_dir ) && is_dir( $untrusted_directory ) ) {
$directory = $untrusted_directory;
}
}
// Kick off a recursive filesize scan.
if ( $new_version ) {
$site_size = new HM\BackUpWordPress\Site_Size();
$exclude_string = implode( '|', $excludes->get_excludes_for_regex() );
if ( function_exists( 'HM\BackUpWordPress\list_directory_by_total_filesize' ) ) {
$files = HM\BackUpWordPress\list_directory_by_total_filesize( $directory, $excludes );
}
} else {
$files = $schedule->list_directory_by_total_filesize( $directory );
$exclude_string = $schedule->backup->exclude_string( 'regex' );
}
if ( $files ) {
$this->render_table_files( $files, $schedule, $directory, $root_dir, $new_version, $site_size, $is_size_calculated );
}
?>
<p class="submit">
<a href="#" onclick="event.preventDefault(); mainwp_backupwp_edit_exclude_done()" class="button-primary"><?php esc_html_e( 'Done', 'mainwp-child' ); ?></a>
</p>
</div>
<?php
$output = ob_get_clean();
$information['e'] = $output;
return $information;
}
private function render_table_excluded( $root_dir, $schedule, $excludes, $user_excludes, $new_version ){
?>
<table class="widefat">
<tbody>
<?php foreach ( $user_excludes as $key => $exclude ) : ?>
@ -582,36 +627,28 @@ class MainWP_Child_Back_Up_WordPress {
<?php endforeach; ?>
</tbody>
</table>
<h3 id="directory-listing"><?php esc_html_e( 'Your Site', 'mainwp-child' ); ?></h3>
<p><?php esc_html_e( 'Here\'s a directory listing of all files on your site, you can browse through and exclude files or folders that you don\'t want included in your backup.', 'mainwp-child' ); ?></p>
<?php
$directory = $root_dir;
if ( isset( $browse_dir ) ) {
$untrusted_directory = rawurldecode( $browse_dir );
// Only allow real sub directories of the site root to be browsed.
if ( false !== strpos( $untrusted_directory, $root_dir ) && is_dir( $untrusted_directory ) ) {
$directory = $untrusted_directory;
}
}
// Kick off a recursive filesize scan.
if ( $new_version ) {
$site_size = new HM\BackUpWordPress\Site_Size();
$exclude_string = implode( '|', $excludes->get_excludes_for_regex() );
if ( function_exists( 'HM\BackUpWordPress\list_directory_by_total_filesize' ) ) {
$files = HM\BackUpWordPress\list_directory_by_total_filesize( $directory, $excludes );
}
} else {
$files = $schedule->list_directory_by_total_filesize( $directory );
$exclude_string = $schedule->backup->exclude_string( 'regex' );
}
if ( $files ) {
private function render_table_files( $files, $schedule, $directory, $root_dir, $new_version, $site_size, $is_size_calculated ){
?>
<table class="widefat">
<thead>
<?php
$this->render_table_header_files( $root_dir, $directory, $schedule, $new_version, $site_size, $is_size_calculated );
?>
</thead>
<tbody>
<?php
$this->render_table_body_files( $files, $schedule, $root_dir, $new_version, $site_size, $is_size_calculated );
?>
</tbody>
</table>
<?php
}
private function render_table_header_files( $root_dir, $directory, $schedule, $new_version, $site_size, $is_size_calculated ){
?>
<tr>
<th></th>
<th scope="col"><?php esc_html_e( 'Name', 'mainwp-child' ); ?></th>
@ -680,9 +717,11 @@ class MainWP_Child_Back_Up_WordPress {
</td>
<td></td>
</tr>
</thead>
<tbody>
<?php
}
private function render_table_body_files( $files, $schedule, $root_dir, $new_version, $site_size, $is_size_calculated ){
foreach ( $files as $size => $file ) {
$is_excluded = false;
$is_unreadable = false;
@ -799,19 +838,7 @@ class MainWP_Child_Back_Up_WordPress {
<?php endif; ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<?php } ?>
<p class="submit">
<a href="#" onclick="event.preventDefault(); mainwp_backupwp_edit_exclude_done()" class="button-primary"><?php esc_html_e( 'Done', 'mainwp-child' ); ?></a>
</p>
</div>
<?php
$output = ob_get_clean();
$information['e'] = $output;
return $information;
<?php }
}
public function directory_browse() {

View file

@ -695,8 +695,6 @@ class MainWP_Child_Posts {
$post_author = ! empty( $post_author ) ? $post_author : $current_uid;
$new_post['post_author'] = $post_author;
unset( $new_post['_ezin_post_category'] );
// post plus extension process.
$is_post_plus = isset( $post_custom['_mainwp_post_plus'] ) ? true : false;
@ -777,10 +775,23 @@ class MainWP_Child_Posts {
);
}
$this->update_post_data( $new_post_id, $post_custom, $post_category, $post_featured_image, $check_image_existed, $is_post_plus );
// unlock if edit post.
if ( $edit_post_id ) {
update_post_meta( $edit_post_id, '_edit_lock', '' );
}
$permalink = get_permalink( $new_post_id );
$ret['success'] = true;
$ret['link'] = $permalink;
$ret['added_id'] = $new_post_id;
return $ret;
}
private function update_post_data( $new_post_id, $post_custom, $post_category, $post_featured_image, $check_image_existed, $is_post_plus ){
$seo_ext_activated = false;
if ( class_exists( 'WPSEO_Meta' ) && class_exists( 'WPSEO_Admin' ) ) {
$seo_ext_activated = true;
}
@ -813,20 +824,8 @@ class MainWP_Child_Posts {
)
);
}
// unlock if edit post.
if ( $edit_post_id ) {
update_post_meta( $edit_post_id, '_edit_lock', '' );
}
$ret['success'] = true;
$ret['link'] = $permalink;
$ret['added_id'] = $new_post_id;
return $ret;
}
private function create_wp_rocket( &$post_custom ) {
// Options fields.
$wprocket_fields = array(
@ -1079,13 +1078,6 @@ class MainWP_Child_Posts {
'_mainwp_spin_me',
);
$not_allowed[] = '_mainwp_boilerplate_sites_posts';
$not_allowed[] = '_ezine_post_keyword';
$not_allowed[] = '_ezine_post_display_sig';
$not_allowed[] = '_ezine_post_remove_link';
$not_allowed[] = '_ezine_post_grab_image';
$not_allowed[] = '_ezine_post_grab_image_placement';
$not_allowed[] = '_ezine_post_template_id';
$not_allowed[] = '_mainwp_post_plus';
$not_allowed[] = '_saved_as_draft';
$not_allowed[] = '_saved_draft_categories';

View file

@ -947,10 +947,27 @@ class MainWP_Child_Timecapsule {
$is_general = $_POST['is_general'];
$saved = false;
$config = WPTC_Factory::get( 'config' );
if ( 'backup' == $tabName ) {
$this->save_settings_backup_tab( $config, $data );
$saved = true;
} elseif ( 'backup_auto' == $tabName ) {
$this->save_settings_backup_auto_tab( $config, $data, $is_general );
$saved = true;
} elseif ( 'vulns_update' == $tabName ) {
$this->save_settings_vulns_update_tab( $config, $data, $is_general );
$saved = true;
} elseif ( 'staging_opts' == $tabName ) {
$this->save_settings_staging_opts_tab( $config, $data, $is_general );
$saved = true;
}
if ( ! $saved ) {
return array( 'error' => 'Error: Not saved settings' );
}
return array( 'result' => 'ok' );
}
private function save_settings_backup_tab( $config, $data ){
$config->set_option( 'user_excluded_extenstions', $data['user_excluded_extenstions'] );
$config->set_option( 'user_excluded_files_more_than_size_settings', $data['user_excluded_files_more_than_size_settings'] );
@ -977,16 +994,13 @@ class MainWP_Child_Timecapsule {
$notice = apply_filters( 'save_settings_revision_limit_wptc', $data['revision_limit'] );
}
$saved = true;
} elseif ( 'backup_auto' == $tabName ) {
}
private function save_settings_backup_auto_tab( $config, $data, $is_general ) {
$config->set_option( 'backup_before_update_setting', $data['backup_before_update_setting'] );
$current = $config->get_option( 'wptc_auto_update_settings' );
$current = unserialize( $current ); // phpcs:ignore -- third party credit.
$new = unserialize( $data['wptc_auto_update_settings'] ); // phpcs:ignore -- third party credit.
$current['update_settings']['status'] = $new['update_settings']['status'];
$current['update_settings']['schedule']['enabled'] = $new['update_settings']['schedule']['enabled'];
$current['update_settings']['schedule']['time'] = $new['update_settings']['schedule']['time'];
@ -1009,9 +1023,9 @@ class MainWP_Child_Timecapsule {
}
}
$config->set_option( 'wptc_auto_update_settings', serialize( $current ) ); // phpcs:ignore -- third party credit.
$saved = true;
}
} elseif ( 'vulns_update' == $tabName ) {
private function save_settings_vulns_update_tab( $config, $data, $is_general ){
$current = $config->get_option( 'vulns_settings' );
$current = unserialize( $current ); // phpcs:ignore -- third party credit.
$new = unserialize( $data['vulns_settings'] ); // phpcs:ignore -- third party credit.
@ -1051,10 +1065,9 @@ class MainWP_Child_Timecapsule {
$current['themes']['excluded'] = serialize( $included_themes ); // phpcs:ignore -- third party credit.
}
$config->set_option( 'vulns_settings', serialize( $current ) ); // phpcs:ignore -- third party credit.
}
$saved = true;
} elseif ( 'staging_opts' == $tabName ) {
private function save_settings_staging_opts_tab( $config, $data, $is_general ){
$config->set_option( 'user_excluded_extenstions_staging', $data['user_excluded_extenstions_staging'] );
$config->set_option( 'internal_staging_db_rows_copy_limit', $data['internal_staging_db_rows_copy_limit'] );
$config->set_option( 'internal_staging_file_copy_limit', $data['internal_staging_file_copy_limit'] );
@ -1064,14 +1077,6 @@ class MainWP_Child_Timecapsule {
if ( ! $is_general ) {
$config->set_option( 'staging_login_custom_link', $data['staging_login_custom_link'] );
}
$saved = true;
}
if ( ! $saved ) {
return array( 'error' => 'Error: Not saved settings' );
}
return array( 'result' => 'ok' );
}
private function filter_plugins( $included_plugins ) {

View file

@ -271,65 +271,7 @@ class MainWP_Client_Report {
}
}
$exclude_connector_posts = true;
if ( isset( $sections['body'] ) && isset( $sections['body']['section_token'] ) && is_array( $sections['body']['section_token'] ) ) {
foreach ( $sections['body']['section_token'] as $sec ) {
if ( false !== strpos( $sec, '[section.posts' ) || false !== strpos( $sec, '[section.pages' ) ) {
$exclude_connector_posts = false;
break;
}
}
}
if ( $exclude_connector_posts ) {
if ( isset( $sections['header'] ) && isset( $sections['header']['section_token'] ) && is_array( $sections['header']['section_token'] ) ) {
foreach ( $sections['header']['section_token'] as $sec ) {
if ( false !== strpos( $sec, '[section.posts' ) || false !== strpos( $sec, '[section.pages' ) ) {
$exclude_connector_posts = false;
break;
}
}
}
}
if ( $exclude_connector_posts ) {
if ( isset( $sections['footer'] ) && isset( $sections['footer']['section_token'] ) && is_array( $sections['footer']['section_token'] ) ) {
foreach ( $sections['footer']['section_token'] as $sec ) {
if ( false !== strpos( $sec, '[section.posts' ) || false !== strpos( $sec, '[section.pages' ) ) {
$exclude_connector_posts = false;
break;
}
}
}
}
if ( $exclude_connector_posts ) {
if ( isset( $other_tokens['body'] ) && is_array( $other_tokens['body'] ) ) {
foreach ( $other_tokens['body'] as $sec ) {
if ( false !== strpos( $sec, '[post.' ) || false !== strpos( $sec, '[page.' ) ) {
$exclude_connector_posts = false;
break;
}
}
}
}
if ( $exclude_connector_posts ) {
if ( isset( $other_tokens['header'] ) && is_array( $other_tokens['header'] ) ) {
foreach ( $other_tokens['header'] as $sec ) {
if ( false !== strpos( $sec, '[post.' ) || false !== strpos( $sec, '[page.' ) ) {
$exclude_connector_posts = false;
break;
}
}
}
}
if ( $exclude_connector_posts ) {
if ( isset( $other_tokens['footer'] ) && is_array( $other_tokens['footer'] ) ) {
foreach ( $other_tokens['footer'] as $sec ) {
if ( false !== strpos( $sec, '[post.' ) || false !== strpos( $sec, '[page.' ) ) {
$exclude_connector_posts = false;
break;
}
}
}
}
$exclude_connector_posts = $this->get_stream_get_not_in_params( $sections, $other_tokens );
if ( $exclude_connector_posts ) {
$args['connector__not_in'] = array( 'posts' );
}
@ -355,6 +297,41 @@ class MainWP_Client_Report {
return $args;
}
private function get_stream_get_not_in_params( $sections, $other_tokens ){
$exclude_connector_posts = true;
$parts = array( 'header', 'body', 'footer' );
foreach( $parts as $part) {
if ( isset( $sections[ $part ] ) && isset( $sections[ $part ]['section_token'] ) && is_array( $sections[ $part ]['section_token'] ) ) {
foreach ( $sections[ $part ]['section_token'] as $sec ) {
if ( false !== strpos( $sec, '[section.posts' ) || false !== strpos( $sec, '[section.pages' ) ) {
$exclude_connector_posts = false;
break;
}
}
}
if ( ! $exclude_connector_posts )
break;
}
if ( $exclude_connector_posts ) {
foreach( $parts as $part) {
if ( isset( $other_tokens[ $part ] ) && is_array( $other_tokens[ $part ] ) ) {
foreach ( $other_tokens[ $part ] as $sec ) {
if ( false !== strpos( $sec, '[post.' ) || false !== strpos( $sec, '[page.' ) ) {
$exclude_connector_posts = false;
break;
}
}
}
if ( ! $exclude_connector_posts )
break;
}
}
return $exclude_connector_posts;
}
private function get_stream_others_tokens( $records, $other_tokens, $skip_records ) {
$other_tokens_data = array();
$parts = array( 'header', 'body', 'footer' );
@ -443,15 +420,13 @@ class MainWP_Client_Report {
}
$backups_created_time_to_fix = array();
foreach ( $tokens as $token ) {
foreach ( $tokens as $token ) {
if ( isset( $token_values[ $token ] ) ) {
continue;
}
$str_tmp = str_replace( array( '[', ']' ), '', $token );
$array_tmp = explode( '.', $str_tmp );
if ( is_array( $array_tmp ) ) {
$context = '';
$action = '';
@ -461,27 +436,32 @@ class MainWP_Client_Report {
} elseif ( 3 === count( $array_tmp ) ) {
list( $context, $action, $data ) = $array_tmp;
}
$context = $this->get_compatible_context( $context );
// to compatible with new version of child report.
// to check condition for grabbing report data.
$connector = $this->get_connector_by_compatible_context( $context );
$action = $this->get_compatible_action( $action, $context );
// custom values.
if ( 'profiles' == $context ) {
if ( 'created' == $action || 'deleted' == $action ) {
$context = 'users'; // see class-connector-user.php.
}
}
switch ( $data ) {
case 'count':
$count = 0;
foreach ( $records as $record ) {
$token_values[ $token ] = $this->get_other_tokens_count( $records, $connector, $context, $action, $skip_records, $backups_created_time_to_fix );
break;
}
}
}
return $token_values;
}
private function get_other_tokens_count( $records, $connector, $context, $action, &$skip_records, &$backups_created_time_to_fix ){
$count = 0;
foreach ( $records as $record ) {
// check connector.
if ( 'editor' == $record->connector ) {
if ( ! in_array( $context, array( 'plugins', 'themes' ) ) || 'updated' !== $action ) {
@ -570,13 +550,7 @@ class MainWP_Client_Report {
}
$count ++;
}
$token_values[ $token ] = $count;
break;
}
}
}
return $token_values;
return $count;
}
public function get_section_loop_data( $records, $tokens, $section, $skip_records = array() ) {
@ -672,11 +646,19 @@ class MainWP_Client_Report {
continue;
}
}
$token_values = $this->get_section_loop_token_values( $record, $context, $tokens );
if ( ! empty( $token_values ) ) {
$loops[ $loop_count ] = $token_values;
$loop_count ++;
}
}
return $loops;
}
private function get_section_loop_token_values( $record, $context, $tokens ){
$token_values = array();
foreach ( $tokens as $token ) {
$data = '';
$token_name = str_replace( array( '[', ']' ), '', $token );
$array_tmp = explode( '.', $token_name );
@ -714,19 +696,11 @@ class MainWP_Client_Report {
MainWP_Helper::log_debug( $msg );
}
}
if ( ! empty( $token_values ) ) {
$loops[ $loop_count ] = $token_values;
$loop_count ++;
}
}
return $loops;
return $token_values;
}
public function get_section_loop_token_value( $record, $data, $context, $token ) {
$tok_value = '';
switch ( $data ) {
case 'ID':
$tok_value = $record->ID;
@ -767,52 +741,19 @@ class MainWP_Client_Report {
}
break;
case 'author':
if ( 'comment' == $connector ) {
$data = 'user_name';
} else {
$data = 'user_meta';
}
$value = $this->get_stream_meta_data( $record, $data );
if ( empty( $value ) && 'comments' === $context ) {
$value = __( 'Guest', 'mainwp-child' );
}
// check compatibility with old meta data.
if ( empty( $value ) ) {
$value = $this->get_stream_meta_data( $record, 'author_meta' );
}
$tok_value = $value;
$tok_value = $this->get_author_data_token_value( $record, $connector, $context, $data );;
break;
case 'status':
case 'webtrust':
$value = '';
if ( 'sucuri_scan' === $context ) {
$tok_value = $this->get_sucuri_scan_token_value( $record, $data );
} else {
$tok_value = $value;
$value = $this->get_sucuri_scan_token_value( $record, $data );
}
$tok_value = $value;
break;
case 'details':
case 'result':
if ( 'mainwp_maintenance' === $context && 'details' == $data ) {
$tok_value = $this->get_mainwp_maintenance_token_value( $record, $data );
} elseif ( 'wordfence_scan' === $context || 'mainwp_maintenance' === $context ) {
$meta_value = $this->get_stream_meta_data( $record, $data );
if ( 'wordfence_scan' === $context && 'result' == $data ) {
// SUM_FINAL:Scan complete. You have xxx new issues to fix. See below.
// SUM_FINAL:Scan complete. Congratulations, no new problems found.
if ( stripos( $meta_value, 'Congratulations' ) ) {
$meta_value = 'No issues detected';
} elseif ( stripos( $meta_value, 'You have' ) ) {
$meta_value = 'Issues Detected';
} else {
$meta_value = '';
}
}
$tok_value = $meta_value;
}
$tok_value = $this->get_result_data_token_value( $record, $context, $data );
break;
case 'type':
if ( 'backups' === $context ) {
@ -825,7 +766,6 @@ class MainWP_Client_Report {
$tok_value = 'N/A';
break;
}
return $tok_value;
}
@ -867,7 +807,49 @@ class MainWP_Client_Report {
return $value;
}
private function get_author_data_token_value( $record, $connector, $context, $data ){
if ( 'comment' == $connector ) {
$data = 'user_name';
} else {
$data = 'user_meta';
}
$value = $this->get_stream_meta_data( $record, $data );
if ( empty( $value ) && 'comments' === $context ) {
$value = __( 'Guest', 'mainwp-child' );
}
// check compatibility with old meta data.
if ( empty( $value ) ) {
$value = $this->get_stream_meta_data( $record, 'author_meta' );
}
return $value;
}
private function get_result_data_token_value( $record, $context, $data ){
if ( 'mainwp_maintenance' === $context && 'details' == $data ) {
$tok_value = $this->get_mainwp_maintenance_token_value( $record, $data );
} elseif ( 'wordfence_scan' === $context || 'mainwp_maintenance' === $context ) {
$meta_value = $this->get_stream_meta_data( $record, $data );
if ( 'wordfence_scan' === $context && 'result' == $data ) {
// SUM_FINAL:Scan complete. You have xxx new issues to fix. See below.
// SUM_FINAL:Scan complete. Congratulations, no new problems found.
if ( stripos( $meta_value, 'Congratulations' ) ) {
$meta_value = 'No issues detected';
} elseif ( stripos( $meta_value, 'You have' ) ) {
$meta_value = 'Issues Detected';
} else {
$meta_value = '';
}
}
$tok_value = $meta_value;
}
return $tok_value;
}
private function get_sucuri_scan_token_value( $record, $data ) {
$tok_value = '';
$scan_data = $this->get_stream_meta_data( $record, 'scan_data' );
if ( ! empty( $scan_data ) ) {
$scan_data = maybe_unserialize( base64_decode( $scan_data ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for begin reasons.

View file

@ -647,8 +647,13 @@ class MainWP_Clone_Install {
mainwp_child_helper()->write( array( 'size' => filesize( $archiveFile ) ) );
} elseif ( 'createCloneBackup' === $_POST['cloneFunc'] ) {
MainWP_Helper::end_session();
$this->create_clone_backup();
}
return true;
}
private function create_clone_backup(){
MainWP_Helper::end_session();
$files = glob( WP_CONTENT_DIR . '/dbBackup*.sql' );
foreach ( $files as $file ) {
unlink( $file );
@ -721,10 +726,6 @@ class MainWP_Clone_Install {
}
closedir( $fh );
$information['themes'] = $themes;
mainwp_child_helper()->write( $information );
}
return true;
}
}

View file

@ -814,11 +814,25 @@ class Tar_Archiver {
}
} elseif ( 0 == $file['type'] ) {
if ( 0 == strcmp( trim( $file['name'] ), trim( $entryName ) ) ) {
$previousFtell = ftell( $this->archive );
return $this->read_next_bytes( $file );
} else {
$this->log( 'Unexpected file [' . $file['name'] . ']' );
throw new \Exception( 'Unexpected file' );
}
}
$this->log( 'ERROR' );
throw new \Exception( 'Should never get here?' );
} catch ( \Exception $e ) {
$this->log( $e->getMessage() );
throw $e;
}
}
private function read_next_bytes( $file ){
$previousFtell = ftell( $this->archive );
$bytes = $file['stat'][7] + ( 512 == ( 512 - $file['stat'][7] % 512 ) ? 0 : ( 512 - $file['stat'][7] % 512 ) );
fseek( $this->archive, ftell( $this->archive ) + $bytes );
$ftell = ftell( $this->archive );
if ( 'tar.gz' == $this->type ) {
if ( ( false === $ftell ) || ( -1 == $ftell ) ) {
@ -859,22 +873,8 @@ class Tar_Archiver {
return $rslt;
}
$this->log( 'Skipping file [' . $file['name'] . ']' );
return true;
} else {
$this->log( 'Unexpected file [' . $file['name'] . ']' );
throw new \Exception( 'Unexpected file' );
}
}
$this->log( 'ERROR' );
throw new \Exception( 'Should never get here?' );
} catch ( \Exception $e ) {
$this->log( $e->getMessage() );
throw $e;
}
}
public function log( $text ) {