@@ -7,31 +7,31 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | /** Load WordPress Administration Bootstrap */ |
| 10 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
| 11 | -if ( ! current_user_can( 'manage_links' ) ) |
|
| 12 | - wp_die( __( 'Sorry, you are not allowed to edit the links for this site.' ) ); |
|
| 10 | +require_once(dirname(__FILE__).'/admin.php'); |
|
| 11 | +if ( ! current_user_can('manage_links')) |
|
| 12 | + wp_die(__('Sorry, you are not allowed to edit the links for this site.')); |
|
| 13 | 13 | |
| 14 | 14 | $wp_list_table = _get_list_table('WP_Links_List_Table'); |
| 15 | 15 | |
| 16 | 16 | // Handle bulk deletes |
| 17 | 17 | $doaction = $wp_list_table->current_action(); |
| 18 | 18 | |
| 19 | -if ( $doaction && isset( $_REQUEST['linkcheck'] ) ) { |
|
| 20 | - check_admin_referer( 'bulk-bookmarks' ); |
|
| 19 | +if ($doaction && isset($_REQUEST['linkcheck'])) { |
|
| 20 | + check_admin_referer('bulk-bookmarks'); |
|
| 21 | 21 | |
| 22 | - if ( 'delete' == $doaction ) { |
|
| 22 | + if ('delete' == $doaction) { |
|
| 23 | 23 | $bulklinks = (array) $_REQUEST['linkcheck']; |
| 24 | - foreach ( $bulklinks as $link_id ) { |
|
| 24 | + foreach ($bulklinks as $link_id) { |
|
| 25 | 25 | $link_id = (int) $link_id; |
| 26 | 26 | |
| 27 | - wp_delete_link( $link_id ); |
|
| 27 | + wp_delete_link($link_id); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - wp_redirect( add_query_arg('deleted', count( $bulklinks ), admin_url( 'link-manager.php' ) ) ); |
|
| 30 | + wp_redirect(add_query_arg('deleted', count($bulklinks), admin_url('link-manager.php'))); |
|
| 31 | 31 | exit; |
| 32 | 32 | } |
| 33 | -} elseif ( ! empty( $_GET['_wp_http_referer'] ) ) { |
|
| 34 | - wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); |
|
| 33 | +} elseif ( ! empty($_GET['_wp_http_referer'])) { |
|
| 34 | + wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']))); |
|
| 35 | 35 | exit; |
| 36 | 36 | } |
| 37 | 37 | |
@@ -40,49 +40,49 @@ discard block |
||
| 40 | 40 | $title = __('Links'); |
| 41 | 41 | $this_file = $parent_file = 'link-manager.php'; |
| 42 | 42 | |
| 43 | -get_current_screen()->add_help_tab( array( |
|
| 43 | +get_current_screen()->add_help_tab(array( |
|
| 44 | 44 | 'id' => 'overview', |
| 45 | 45 | 'title' => __('Overview'), |
| 46 | 46 | 'content' => |
| 47 | - '<p>' . sprintf(__('You can add links here to be displayed on your site, usually using <a href="%s">Widgets</a>. By default, links to several sites in the WordPress community are included as examples.'), 'widgets.php') . '</p>' . |
|
| 48 | - '<p>' . __('Links may be separated into Link Categories; these are different than the categories used on your posts.') . '</p>' . |
|
| 49 | - '<p>' . __('You can customize the display of this screen using the Screen Options tab and/or the dropdown filters above the links table.') . '</p>' |
|
| 50 | -) ); |
|
| 51 | -get_current_screen()->add_help_tab( array( |
|
| 47 | + '<p>'.sprintf(__('You can add links here to be displayed on your site, usually using <a href="%s">Widgets</a>. By default, links to several sites in the WordPress community are included as examples.'), 'widgets.php').'</p>'. |
|
| 48 | + '<p>'.__('Links may be separated into Link Categories; these are different than the categories used on your posts.').'</p>'. |
|
| 49 | + '<p>'.__('You can customize the display of this screen using the Screen Options tab and/or the dropdown filters above the links table.').'</p>' |
|
| 50 | +)); |
|
| 51 | +get_current_screen()->add_help_tab(array( |
|
| 52 | 52 | 'id' => 'deleting-links', |
| 53 | 53 | 'title' => __('Deleting Links'), |
| 54 | 54 | 'content' => |
| 55 | - '<p>' . __('If you delete a link, it will be removed permanently, as Links do not have a Trash function yet.') . '</p>' |
|
| 56 | -) ); |
|
| 55 | + '<p>'.__('If you delete a link, it will be removed permanently, as Links do not have a Trash function yet.').'</p>' |
|
| 56 | +)); |
|
| 57 | 57 | |
| 58 | 58 | get_current_screen()->set_help_sidebar( |
| 59 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
| 60 | - '<p>' . __('<a href="https://codex.wordpress.org/Links_Screen" target="_blank">Documentation on Managing Links</a>') . '</p>' . |
|
| 61 | - '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
|
| 59 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
| 60 | + '<p>'.__('<a href="https://codex.wordpress.org/Links_Screen" target="_blank">Documentation on Managing Links</a>').'</p>'. |
|
| 61 | + '<p>'.__('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>').'</p>' |
|
| 62 | 62 | ); |
| 63 | 63 | |
| 64 | -get_current_screen()->set_screen_reader_content( array( |
|
| 65 | - 'heading_list' => __( 'Links list' ), |
|
| 66 | -) ); |
|
| 64 | +get_current_screen()->set_screen_reader_content(array( |
|
| 65 | + 'heading_list' => __('Links list'), |
|
| 66 | +)); |
|
| 67 | 67 | |
| 68 | -include_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
| 68 | +include_once(ABSPATH.'wp-admin/admin-header.php'); |
|
| 69 | 69 | |
| 70 | -if ( ! current_user_can('manage_links') ) |
|
| 70 | +if ( ! current_user_can('manage_links')) |
|
| 71 | 71 | wp_die(__('Sorry, you are not allowed to edit the links for this site.')); |
| 72 | 72 | |
| 73 | 73 | ?> |
| 74 | 74 | |
| 75 | 75 | <div class="wrap nosubsub"> |
| 76 | -<h1><?php echo esc_html( $title ); ?> <a href="link-add.php" class="page-title-action"><?php echo esc_html_x('Add New', 'link'); ?></a> <?php |
|
| 77 | -if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { |
|
| 76 | +<h1><?php echo esc_html($title); ?> <a href="link-add.php" class="page-title-action"><?php echo esc_html_x('Add New', 'link'); ?></a> <?php |
|
| 77 | +if (isset($_REQUEST['s']) && strlen($_REQUEST['s'])) { |
|
| 78 | 78 | /* translators: %s: search keywords */ |
| 79 | - printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( wp_unslash( $_REQUEST['s'] ) ) ); |
|
| 79 | + printf('<span class="subtitle">'.__('Search results for “%s”').'</span>', esc_html(wp_unslash($_REQUEST['s']))); |
|
| 80 | 80 | } |
| 81 | 81 | ?> |
| 82 | 82 | </h1> |
| 83 | 83 | |
| 84 | 84 | <?php |
| 85 | -if ( isset($_REQUEST['deleted']) ) { |
|
| 85 | +if (isset($_REQUEST['deleted'])) { |
|
| 86 | 86 | echo '<div id="message" class="updated notice is-dismissible"><p>'; |
| 87 | 87 | $deleted = (int) $_REQUEST['deleted']; |
| 88 | 88 | printf(_n('%s link deleted.', '%s links deleted', $deleted), $deleted); |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | <form id="posts-filter" method="get"> |
| 95 | 95 | |
| 96 | -<?php $wp_list_table->search_box( __( 'Search Links' ), 'link' ); ?> |
|
| 96 | +<?php $wp_list_table->search_box(__('Search Links'), 'link'); ?> |
|
| 97 | 97 | |
| 98 | 98 | <?php $wp_list_table->display(); ?> |
| 99 | 99 | |
@@ -103,4 +103,4 @@ discard block |
||
| 103 | 103 | </div> |
| 104 | 104 | |
| 105 | 105 | <?php |
| 106 | -include( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
| 106 | +include(ABSPATH.'wp-admin/admin-footer.php'); |
|
@@ -7,60 +7,60 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | /** WordPress Administration Bootstrap */ |
| 10 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
| 11 | -require( ABSPATH . 'wp-admin/includes/theme-install.php' ); |
|
| 10 | +require_once(dirname(__FILE__).'/admin.php'); |
|
| 11 | +require(ABSPATH.'wp-admin/includes/theme-install.php'); |
|
| 12 | 12 | |
| 13 | -wp_reset_vars( array( 'tab' ) ); |
|
| 13 | +wp_reset_vars(array('tab')); |
|
| 14 | 14 | |
| 15 | -if ( ! current_user_can('install_themes') ) |
|
| 16 | - wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) ); |
|
| 15 | +if ( ! current_user_can('install_themes')) |
|
| 16 | + wp_die(__('Sorry, you are not allowed to install themes on this site.')); |
|
| 17 | 17 | |
| 18 | -if ( is_multisite() && ! is_network_admin() ) { |
|
| 19 | - wp_redirect( network_admin_url( 'theme-install.php' ) ); |
|
| 18 | +if (is_multisite() && ! is_network_admin()) { |
|
| 19 | + wp_redirect(network_admin_url('theme-install.php')); |
|
| 20 | 20 | exit(); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | -$title = __( 'Add Themes' ); |
|
| 23 | +$title = __('Add Themes'); |
|
| 24 | 24 | $parent_file = 'themes.php'; |
| 25 | 25 | |
| 26 | -if ( ! is_network_admin() ) { |
|
| 26 | +if ( ! is_network_admin()) { |
|
| 27 | 27 | $submenu_file = 'themes.php'; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | $installed_themes = search_theme_directories(); |
| 31 | -foreach ( $installed_themes as $k => $v ) { |
|
| 32 | - if ( false !== strpos( $k, '/' ) ) { |
|
| 33 | - unset( $installed_themes[ $k ] ); |
|
| 31 | +foreach ($installed_themes as $k => $v) { |
|
| 32 | + if (false !== strpos($k, '/')) { |
|
| 33 | + unset($installed_themes[$k]); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | -wp_localize_script( 'theme', '_wpThemeSettings', array( |
|
| 37 | +wp_localize_script('theme', '_wpThemeSettings', array( |
|
| 38 | 38 | 'themes' => false, |
| 39 | 39 | 'settings' => array( |
| 40 | 40 | 'isInstall' => true, |
| 41 | - 'canInstall' => current_user_can( 'install_themes' ), |
|
| 42 | - 'installURI' => current_user_can( 'install_themes' ) ? self_admin_url( 'theme-install.php' ) : null, |
|
| 43 | - 'adminUrl' => parse_url( self_admin_url(), PHP_URL_PATH ) |
|
| 41 | + 'canInstall' => current_user_can('install_themes'), |
|
| 42 | + 'installURI' => current_user_can('install_themes') ? self_admin_url('theme-install.php') : null, |
|
| 43 | + 'adminUrl' => parse_url(self_admin_url(), PHP_URL_PATH) |
|
| 44 | 44 | ), |
| 45 | 45 | 'l10n' => array( |
| 46 | - 'addNew' => __( 'Add New Theme' ), |
|
| 47 | - 'search' => __( 'Search Themes' ), |
|
| 48 | - 'searchPlaceholder' => __( 'Search themes...' ), // placeholder (no ellipsis) |
|
| 49 | - 'upload' => __( 'Upload Theme' ), |
|
| 50 | - 'back' => __( 'Back' ), |
|
| 51 | - 'error' => __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), |
|
| 52 | - 'themesFound' => __( 'Number of Themes found: %d' ), |
|
| 53 | - 'noThemesFound' => __( 'No themes found. Try a different search.' ), |
|
| 54 | - 'collapseSidebar' => __( 'Collapse Sidebar' ), |
|
| 55 | - 'expandSidebar' => __( 'Expand Sidebar' ), |
|
| 46 | + 'addNew' => __('Add New Theme'), |
|
| 47 | + 'search' => __('Search Themes'), |
|
| 48 | + 'searchPlaceholder' => __('Search themes...'), // placeholder (no ellipsis) |
|
| 49 | + 'upload' => __('Upload Theme'), |
|
| 50 | + 'back' => __('Back'), |
|
| 51 | + 'error' => __('An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.'), |
|
| 52 | + 'themesFound' => __('Number of Themes found: %d'), |
|
| 53 | + 'noThemesFound' => __('No themes found. Try a different search.'), |
|
| 54 | + 'collapseSidebar' => __('Collapse Sidebar'), |
|
| 55 | + 'expandSidebar' => __('Expand Sidebar'), |
|
| 56 | 56 | ), |
| 57 | - 'installedThemes' => array_keys( $installed_themes ), |
|
| 58 | -) ); |
|
| 57 | + 'installedThemes' => array_keys($installed_themes), |
|
| 58 | +)); |
|
| 59 | 59 | |
| 60 | -wp_enqueue_script( 'theme' ); |
|
| 61 | -wp_enqueue_script( 'updates' ); |
|
| 60 | +wp_enqueue_script('theme'); |
|
| 61 | +wp_enqueue_script('updates'); |
|
| 62 | 62 | |
| 63 | -if ( $tab ) { |
|
| 63 | +if ($tab) { |
|
| 64 | 64 | /** |
| 65 | 65 | * Fires before each of the tabs are rendered on the Install Themes page. |
| 66 | 66 | * |
@@ -70,51 +70,51 @@ discard block |
||
| 70 | 70 | * |
| 71 | 71 | * @since 2.8.0 |
| 72 | 72 | */ |
| 73 | - do_action( "install_themes_pre_{$tab}" ); |
|
| 73 | + do_action("install_themes_pre_{$tab}"); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $help_overview = |
| 77 | - '<p>' . sprintf( |
|
| 77 | + '<p>'.sprintf( |
|
| 78 | 78 | /* translators: %s: Theme Directory URL */ |
| 79 | - __( 'You can find additional themes for your site by using the Theme Browser/Installer on this screen, which will display themes from the <a href="%s" target="_blank">WordPress Theme Directory</a>. These themes are designed and developed by third parties, are available free of charge, and are compatible with the license WordPress uses.' ), |
|
| 80 | - __( 'https://wordpress.org/themes/' ) |
|
| 81 | - ) . '</p>' . |
|
| 82 | - '<p>' . __( 'You can Search for themes by keyword, author, or tag, or can get more specific and search by criteria listed in the feature filter.' ) . ' <span id="live-search-desc">' . __( 'The search results will be updated as you type.' ) . '</span></p>' . |
|
| 83 | - '<p>' . __( 'Alternately, you can browse the themes that are Featured, Popular, or Latest. When you find a theme you like, you can preview it or install it.' ) . '</p>' . |
|
| 84 | - '<p>' . sprintf( |
|
| 79 | + __('You can find additional themes for your site by using the Theme Browser/Installer on this screen, which will display themes from the <a href="%s" target="_blank">WordPress Theme Directory</a>. These themes are designed and developed by third parties, are available free of charge, and are compatible with the license WordPress uses.'), |
|
| 80 | + __('https://wordpress.org/themes/') |
|
| 81 | + ).'</p>'. |
|
| 82 | + '<p>'.__('You can Search for themes by keyword, author, or tag, or can get more specific and search by criteria listed in the feature filter.').' <span id="live-search-desc">'.__('The search results will be updated as you type.').'</span></p>'. |
|
| 83 | + '<p>'.__('Alternately, you can browse the themes that are Featured, Popular, or Latest. When you find a theme you like, you can preview it or install it.').'</p>'. |
|
| 84 | + '<p>'.sprintf( |
|
| 85 | 85 | /* translators: %s: /wp-content/themes */ |
| 86 | - __( 'You can Upload a theme manually if you have already downloaded its ZIP archive onto your computer (make sure it is from a trusted and original source). You can also do it the old-fashioned way and copy a downloaded theme’s folder via FTP into your %s directory.' ), |
|
| 86 | + __('You can Upload a theme manually if you have already downloaded its ZIP archive onto your computer (make sure it is from a trusted and original source). You can also do it the old-fashioned way and copy a downloaded theme’s folder via FTP into your %s directory.'), |
|
| 87 | 87 | '<code>/wp-content/themes</code>' |
| 88 | - ) . '</p>'; |
|
| 88 | + ).'</p>'; |
|
| 89 | 89 | |
| 90 | -get_current_screen()->add_help_tab( array( |
|
| 90 | +get_current_screen()->add_help_tab(array( |
|
| 91 | 91 | 'id' => 'overview', |
| 92 | 92 | 'title' => __('Overview'), |
| 93 | 93 | 'content' => $help_overview |
| 94 | -) ); |
|
| 94 | +)); |
|
| 95 | 95 | |
| 96 | 96 | $help_installing = |
| 97 | - '<p>' . __('Once you have generated a list of themes, you can preview and install any of them. Click on the thumbnail of the theme you’re interested in previewing. It will open up in a full-screen Preview page to give you a better idea of how that theme will look.') . '</p>' . |
|
| 98 | - '<p>' . __('To install the theme so you can preview it with your site’s content and customize its theme options, click the "Install" button at the top of the left-hand pane. The theme files will be downloaded to your website automatically. When this is complete, the theme is now available for activation, which you can do by clicking the "Activate" link, or by navigating to your Manage Themes screen and clicking the "Live Preview" link under any installed theme’s thumbnail image.') . '</p>'; |
|
| 97 | + '<p>'.__('Once you have generated a list of themes, you can preview and install any of them. Click on the thumbnail of the theme you’re interested in previewing. It will open up in a full-screen Preview page to give you a better idea of how that theme will look.').'</p>'. |
|
| 98 | + '<p>'.__('To install the theme so you can preview it with your site’s content and customize its theme options, click the "Install" button at the top of the left-hand pane. The theme files will be downloaded to your website automatically. When this is complete, the theme is now available for activation, which you can do by clicking the "Activate" link, or by navigating to your Manage Themes screen and clicking the "Live Preview" link under any installed theme’s thumbnail image.').'</p>'; |
|
| 99 | 99 | |
| 100 | -get_current_screen()->add_help_tab( array( |
|
| 100 | +get_current_screen()->add_help_tab(array( |
|
| 101 | 101 | 'id' => 'installing', |
| 102 | 102 | 'title' => __('Previewing and Installing'), |
| 103 | 103 | 'content' => $help_installing |
| 104 | -) ); |
|
| 104 | +)); |
|
| 105 | 105 | |
| 106 | 106 | get_current_screen()->set_help_sidebar( |
| 107 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
| 108 | - '<p>' . __('<a href="https://codex.wordpress.org/Using_Themes#Adding_New_Themes" target="_blank">Documentation on Adding New Themes</a>') . '</p>' . |
|
| 109 | - '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
|
| 107 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
| 108 | + '<p>'.__('<a href="https://codex.wordpress.org/Using_Themes#Adding_New_Themes" target="_blank">Documentation on Adding New Themes</a>').'</p>'. |
|
| 109 | + '<p>'.__('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>').'</p>' |
|
| 110 | 110 | ); |
| 111 | 111 | |
| 112 | -include(ABSPATH . 'wp-admin/admin-header.php'); |
|
| 112 | +include(ABSPATH.'wp-admin/admin-header.php'); |
|
| 113 | 113 | |
| 114 | 114 | ?> |
| 115 | 115 | <div class="wrap"> |
| 116 | 116 | <h1><?php |
| 117 | - echo esc_html( $title ); |
|
| 117 | + echo esc_html($title); |
|
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * Filters the tabs shown on the Add Themes screen. |
@@ -125,20 +125,20 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @param array $tabs The tabs shown on the Add Themes screen. Default is 'upload'. |
| 127 | 127 | */ |
| 128 | - $tabs = apply_filters( 'install_themes_tabs', array( 'upload' => __( 'Upload Theme' ) ) ); |
|
| 129 | - if ( ! empty( $tabs['upload'] ) && current_user_can( 'upload_themes' ) ) { |
|
| 130 | - echo ' <button type="button" class="upload-view-toggle page-title-action hide-if-no-js" aria-expanded="false">' . __( 'Upload Theme' ) . '</button>'; |
|
| 128 | + $tabs = apply_filters('install_themes_tabs', array('upload' => __('Upload Theme'))); |
|
| 129 | + if ( ! empty($tabs['upload']) && current_user_can('upload_themes')) { |
|
| 130 | + echo ' <button type="button" class="upload-view-toggle page-title-action hide-if-no-js" aria-expanded="false">'.__('Upload Theme').'</button>'; |
|
| 131 | 131 | } |
| 132 | 132 | ?></h1> |
| 133 | 133 | <div class="error hide-if-js"> |
| 134 | - <p><?php _e( 'The Theme Installer screen requires JavaScript.' ); ?></p> |
|
| 134 | + <p><?php _e('The Theme Installer screen requires JavaScript.'); ?></p> |
|
| 135 | 135 | </div> |
| 136 | 136 | |
| 137 | 137 | <div class="upload-theme"> |
| 138 | 138 | <?php install_themes_upload(); ?> |
| 139 | 139 | </div> |
| 140 | 140 | |
| 141 | - <h2 class="screen-reader-text hide-if-no-js"><?php _e( 'Filter themes list' ); ?></h2> |
|
| 141 | + <h2 class="screen-reader-text hide-if-no-js"><?php _e('Filter themes list'); ?></h2> |
|
| 142 | 142 | |
| 143 | 143 | <div class="wp-filter hide-if-no-js"> |
| 144 | 144 | <div class="filter-count"> |
@@ -146,73 +146,73 @@ discard block |
||
| 146 | 146 | </div> |
| 147 | 147 | |
| 148 | 148 | <ul class="filter-links"> |
| 149 | - <li><a href="#" data-sort="featured"><?php _ex( 'Featured', 'themes' ); ?></a></li> |
|
| 150 | - <li><a href="#" data-sort="popular"><?php _ex( 'Popular', 'themes' ); ?></a></li> |
|
| 151 | - <li><a href="#" data-sort="new"><?php _ex( 'Latest', 'themes' ); ?></a></li> |
|
| 152 | - <li><a href="#" data-sort="favorites"><?php _ex( 'Favorites', 'themes' ); ?></a></li> |
|
| 149 | + <li><a href="#" data-sort="featured"><?php _ex('Featured', 'themes'); ?></a></li> |
|
| 150 | + <li><a href="#" data-sort="popular"><?php _ex('Popular', 'themes'); ?></a></li> |
|
| 151 | + <li><a href="#" data-sort="new"><?php _ex('Latest', 'themes'); ?></a></li> |
|
| 152 | + <li><a href="#" data-sort="favorites"><?php _ex('Favorites', 'themes'); ?></a></li> |
|
| 153 | 153 | </ul> |
| 154 | 154 | |
| 155 | - <a class="drawer-toggle" href="#"><?php _e( 'Feature Filter' ); ?></a> |
|
| 155 | + <a class="drawer-toggle" href="#"><?php _e('Feature Filter'); ?></a> |
|
| 156 | 156 | |
| 157 | 157 | <div class="search-form"></div> |
| 158 | 158 | |
| 159 | 159 | <div class="favorites-form"> |
| 160 | 160 | <?php |
| 161 | - $action = 'save_wporg_username_' . get_current_user_id(); |
|
| 162 | - if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( wp_unslash( $_GET['_wpnonce'] ), $action ) ) { |
|
| 163 | - $user = isset( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' ); |
|
| 164 | - update_user_meta( get_current_user_id(), 'wporg_favorites', $user ); |
|
| 161 | + $action = 'save_wporg_username_'.get_current_user_id(); |
|
| 162 | + if (isset($_GET['_wpnonce']) && wp_verify_nonce(wp_unslash($_GET['_wpnonce']), $action)) { |
|
| 163 | + $user = isset($_GET['user']) ? wp_unslash($_GET['user']) : get_user_option('wporg_favorites'); |
|
| 164 | + update_user_meta(get_current_user_id(), 'wporg_favorites', $user); |
|
| 165 | 165 | } else { |
| 166 | - $user = get_user_option( 'wporg_favorites' ); |
|
| 166 | + $user = get_user_option('wporg_favorites'); |
|
| 167 | 167 | } |
| 168 | 168 | ?> |
| 169 | - <p class="install-help"><?php _e( 'If you have marked themes as favorites on WordPress.org, you can browse them here.' ); ?></p> |
|
| 169 | + <p class="install-help"><?php _e('If you have marked themes as favorites on WordPress.org, you can browse them here.'); ?></p> |
|
| 170 | 170 | |
| 171 | 171 | <p> |
| 172 | - <label for="wporg-username-input"><?php _e( 'Your WordPress.org username:' ); ?></label> |
|
| 173 | - <input type="hidden" id="wporg-username-nonce" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( $action ) ); ?>" /> |
|
| 174 | - <input type="search" id="wporg-username-input" value="<?php echo esc_attr( $user ); ?>" /> |
|
| 175 | - <input type="button" class="button button-secondary favorites-form-submit" value="<?php esc_attr_e( 'Get Favorites' ); ?>" /> |
|
| 172 | + <label for="wporg-username-input"><?php _e('Your WordPress.org username:'); ?></label> |
|
| 173 | + <input type="hidden" id="wporg-username-nonce" name="_wpnonce" value="<?php echo esc_attr(wp_create_nonce($action)); ?>" /> |
|
| 174 | + <input type="search" id="wporg-username-input" value="<?php echo esc_attr($user); ?>" /> |
|
| 175 | + <input type="button" class="button button-secondary favorites-form-submit" value="<?php esc_attr_e('Get Favorites'); ?>" /> |
|
| 176 | 176 | </p> |
| 177 | 177 | </div> |
| 178 | 178 | |
| 179 | 179 | <div class="filter-drawer"> |
| 180 | 180 | <div class="buttons"> |
| 181 | - <a class="apply-filters button button-secondary" href="#"><?php _e( 'Apply Filters' ); ?><span></span></a> |
|
| 182 | - <a class="clear-filters button button-secondary" href="#"><?php _e( 'Clear' ); ?></a> |
|
| 181 | + <a class="apply-filters button button-secondary" href="#"><?php _e('Apply Filters'); ?><span></span></a> |
|
| 182 | + <a class="clear-filters button button-secondary" href="#"><?php _e('Clear'); ?></a> |
|
| 183 | 183 | </div> |
| 184 | 184 | <?php |
| 185 | 185 | $feature_list = get_theme_feature_list(); |
| 186 | - foreach ( $feature_list as $feature_name => $features ) { |
|
| 186 | + foreach ($feature_list as $feature_name => $features) { |
|
| 187 | 187 | echo '<fieldset class="filter-group">'; |
| 188 | - $feature_name = esc_html( $feature_name ); |
|
| 189 | - echo '<legend>' . $feature_name . '</legend>'; |
|
| 188 | + $feature_name = esc_html($feature_name); |
|
| 189 | + echo '<legend>'.$feature_name.'</legend>'; |
|
| 190 | 190 | echo '<div class="filter-group-feature">'; |
| 191 | - foreach ( $features as $feature => $feature_name ) { |
|
| 192 | - $feature = esc_attr( $feature ); |
|
| 193 | - echo '<input type="checkbox" id="filter-id-' . $feature . '" value="' . $feature . '" /> '; |
|
| 194 | - echo '<label for="filter-id-' . $feature . '">' . $feature_name . '</label><br>'; |
|
| 191 | + foreach ($features as $feature => $feature_name) { |
|
| 192 | + $feature = esc_attr($feature); |
|
| 193 | + echo '<input type="checkbox" id="filter-id-'.$feature.'" value="'.$feature.'" /> '; |
|
| 194 | + echo '<label for="filter-id-'.$feature.'">'.$feature_name.'</label><br>'; |
|
| 195 | 195 | } |
| 196 | 196 | echo '</div>'; |
| 197 | 197 | echo '</fieldset>'; |
| 198 | 198 | } |
| 199 | 199 | ?> |
| 200 | 200 | <div class="filtered-by"> |
| 201 | - <span><?php _e( 'Filtering by:' ); ?></span> |
|
| 201 | + <span><?php _e('Filtering by:'); ?></span> |
|
| 202 | 202 | <div class="tags"></div> |
| 203 | - <a href="#"><?php _e( 'Edit' ); ?></a> |
|
| 203 | + <a href="#"><?php _e('Edit'); ?></a> |
|
| 204 | 204 | </div> |
| 205 | 205 | </div> |
| 206 | 206 | </div> |
| 207 | - <h2 class="screen-reader-text hide-if-no-js"><?php _e( 'Themes list' ); ?></h2> |
|
| 207 | + <h2 class="screen-reader-text hide-if-no-js"><?php _e('Themes list'); ?></h2> |
|
| 208 | 208 | <div class="theme-browser content-filterable"></div> |
| 209 | 209 | <div class="theme-install-overlay wp-full-overlay expanded"></div> |
| 210 | 210 | |
| 211 | - <p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p> |
|
| 211 | + <p class="no-themes"><?php _e('No themes found. Try a different search.'); ?></p> |
|
| 212 | 212 | <span class="spinner"></span> |
| 213 | 213 | |
| 214 | 214 | <?php |
| 215 | -if ( $tab ) { |
|
| 215 | +if ($tab) { |
|
| 216 | 216 | /** |
| 217 | 217 | * Fires at the top of each of the tabs on the Install Themes page. |
| 218 | 218 | * |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | * |
| 225 | 225 | * @param int $paged Number of the current page of results being viewed. |
| 226 | 226 | */ |
| 227 | - do_action( "install_themes_{$tab}", $paged ); |
|
| 227 | + do_action("install_themes_{$tab}", $paged); |
|
| 228 | 228 | } |
| 229 | 229 | ?> |
| 230 | 230 | </div> |
@@ -237,11 +237,11 @@ discard block |
||
| 237 | 237 | <# } else { #> |
| 238 | 238 | <div class="theme-screenshot blank"></div> |
| 239 | 239 | <# } #> |
| 240 | - <span class="more-details"><?php _ex( 'Details & Preview', 'theme' ); ?></span> |
|
| 240 | + <span class="more-details"><?php _ex('Details & Preview', 'theme'); ?></span> |
|
| 241 | 241 | <div class="theme-author"> |
| 242 | 242 | <?php |
| 243 | 243 | /* translators: %s: Theme author name */ |
| 244 | - printf( __( 'By %s' ), '{{ data.author }}' ); |
|
| 244 | + printf(__('By %s'), '{{ data.author }}'); |
|
| 245 | 245 | ?> |
| 246 | 246 | </div> |
| 247 | 247 | <h3 class="theme-name">{{ data.name }}</h3> |
@@ -250,41 +250,41 @@ discard block |
||
| 250 | 250 | <# if ( data.installed ) { #> |
| 251 | 251 | <?php |
| 252 | 252 | /* translators: %s: Theme name */ |
| 253 | - $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' ); |
|
| 253 | + $aria_label = sprintf(_x('Activate %s', 'theme'), '{{ data.name }}'); |
|
| 254 | 254 | ?> |
| 255 | 255 | <# if ( data.activate_url ) { #> |
| 256 | - <a class="button button-primary activate" href="{{ data.activate_url }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a> |
|
| 256 | + <a class="button button-primary activate" href="{{ data.activate_url }}" aria-label="<?php echo esc_attr($aria_label); ?>"><?php _e('Activate'); ?></a> |
|
| 257 | 257 | <# } #> |
| 258 | 258 | <# if ( data.customize_url ) { #> |
| 259 | - <a class="button button-secondary load-customize" href="{{ data.customize_url }}"><?php _e( 'Live Preview' ); ?></a> |
|
| 259 | + <a class="button button-secondary load-customize" href="{{ data.customize_url }}"><?php _e('Live Preview'); ?></a> |
|
| 260 | 260 | <# } else { #> |
| 261 | - <button class="button-secondary preview install-theme-preview"><?php _e( 'Preview' ); ?></button> |
|
| 261 | + <button class="button-secondary preview install-theme-preview"><?php _e('Preview'); ?></button> |
|
| 262 | 262 | <# } #> |
| 263 | 263 | <# } else { #> |
| 264 | 264 | <?php |
| 265 | 265 | /* translators: %s: Theme name */ |
| 266 | - $aria_label = sprintf( __( 'Install %s' ), '{{ data.name }}' ); |
|
| 266 | + $aria_label = sprintf(__('Install %s'), '{{ data.name }}'); |
|
| 267 | 267 | ?> |
| 268 | - <a class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}" href="{{ data.install_url }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Install' ); ?></a> |
|
| 269 | - <button class="button-secondary preview install-theme-preview"><?php _e( 'Preview' ); ?></button> |
|
| 268 | + <a class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}" href="{{ data.install_url }}" aria-label="<?php echo esc_attr($aria_label); ?>"><?php _e('Install'); ?></a> |
|
| 269 | + <button class="button-secondary preview install-theme-preview"><?php _e('Preview'); ?></button> |
|
| 270 | 270 | <# } #> |
| 271 | 271 | </div> |
| 272 | 272 | |
| 273 | 273 | <# if ( data.installed ) { #> |
| 274 | - <div class="notice notice-success notice-alt"><p><?php _ex( 'Installed', 'theme' ); ?></p></div> |
|
| 274 | + <div class="notice notice-success notice-alt"><p><?php _ex('Installed', 'theme'); ?></p></div> |
|
| 275 | 275 | <# } #> |
| 276 | 276 | </script> |
| 277 | 277 | |
| 278 | 278 | <script id="tmpl-theme-preview" type="text/template"> |
| 279 | 279 | <div class="wp-full-overlay-sidebar"> |
| 280 | 280 | <div class="wp-full-overlay-header"> |
| 281 | - <button class="close-full-overlay"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button> |
|
| 282 | - <button class="previous-theme"><span class="screen-reader-text"><?php _ex( 'Previous', 'Button label for a theme' ); ?></span></button> |
|
| 283 | - <button class="next-theme"><span class="screen-reader-text"><?php _ex( 'Next', 'Button label for a theme' ); ?></span></button> |
|
| 281 | + <button class="close-full-overlay"><span class="screen-reader-text"><?php _e('Close'); ?></span></button> |
|
| 282 | + <button class="previous-theme"><span class="screen-reader-text"><?php _ex('Previous', 'Button label for a theme'); ?></span></button> |
|
| 283 | + <button class="next-theme"><span class="screen-reader-text"><?php _ex('Next', 'Button label for a theme'); ?></span></button> |
|
| 284 | 284 | <# if ( data.installed ) { #> |
| 285 | - <a class="button button-primary activate" href="{{ data.activate_url }}"><?php _e( 'Activate' ); ?></a> |
|
| 285 | + <a class="button button-primary activate" href="{{ data.activate_url }}"><?php _e('Activate'); ?></a> |
|
| 286 | 286 | <# } else { #> |
| 287 | - <a href="{{ data.install_url }}" class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></a> |
|
| 287 | + <a href="{{ data.install_url }}" class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}"><?php _e('Install'); ?></a> |
|
| 288 | 288 | <# } #> |
| 289 | 289 | </div> |
| 290 | 290 | <div class="wp-full-overlay-sidebar-content"> |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | <span class="theme-by"> |
| 294 | 294 | <?php |
| 295 | 295 | /* translators: %s: Theme author name */ |
| 296 | - printf( __( 'By %s' ), '{{ data.author }}' ); |
|
| 296 | + printf(__('By %s'), '{{ data.author }}'); |
|
| 297 | 297 | ?> |
| 298 | 298 | </span> |
| 299 | 299 | |
@@ -306,12 +306,12 @@ discard block |
||
| 306 | 306 | <span class="num-ratings">({{ data.num_ratings }})</span> |
| 307 | 307 | </div> |
| 308 | 308 | <# } else { #> |
| 309 | - <span class="no-rating"><?php _e( 'This theme has not been rated yet.' ); ?></span> |
|
| 309 | + <span class="no-rating"><?php _e('This theme has not been rated yet.'); ?></span> |
|
| 310 | 310 | <# } #> |
| 311 | 311 | <div class="theme-version"> |
| 312 | 312 | <?php |
| 313 | 313 | /* translators: %s: Theme version */ |
| 314 | - printf( __( 'Version: %s' ), '{{ data.version }}' ); |
|
| 314 | + printf(__('Version: %s'), '{{ data.version }}'); |
|
| 315 | 315 | ?> |
| 316 | 316 | </div> |
| 317 | 317 | <div class="theme-description">{{{ data.description }}}</div> |
@@ -319,14 +319,14 @@ discard block |
||
| 319 | 319 | </div> |
| 320 | 320 | </div> |
| 321 | 321 | <div class="wp-full-overlay-footer"> |
| 322 | - <button type="button" class="collapse-sidebar button-secondary" aria-expanded="true" aria-label="<?php esc_attr_e( 'Collapse Sidebar' ); ?>"> |
|
| 322 | + <button type="button" class="collapse-sidebar button-secondary" aria-expanded="true" aria-label="<?php esc_attr_e('Collapse Sidebar'); ?>"> |
|
| 323 | 323 | <span class="collapse-sidebar-arrow"></span> |
| 324 | - <span class="collapse-sidebar-label"><?php _e( 'Collapse' ); ?></span> |
|
| 324 | + <span class="collapse-sidebar-label"><?php _e('Collapse'); ?></span> |
|
| 325 | 325 | </button> |
| 326 | 326 | </div> |
| 327 | 327 | </div> |
| 328 | 328 | <div class="wp-full-overlay-main"> |
| 329 | - <iframe src="{{ data.preview_url }}" title="<?php esc_attr_e( 'Preview' ); ?>"></iframe> |
|
| 329 | + <iframe src="{{ data.preview_url }}" title="<?php esc_attr_e('Preview'); ?>"></iframe> |
|
| 330 | 330 | </div> |
| 331 | 331 | </script> |
| 332 | 332 | |
@@ -334,4 +334,4 @@ discard block |
||
| 334 | 334 | wp_print_request_filesystem_credentials_modal(); |
| 335 | 335 | wp_print_admin_notice_templates(); |
| 336 | 336 | |
| 337 | -include(ABSPATH . 'wp-admin/admin-footer.php'); |
|
| 337 | +include(ABSPATH.'wp-admin/admin-footer.php'); |
|
@@ -7,56 +7,56 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | /** WordPress Administration Bootstrap */ |
| 10 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
| 10 | +require_once(dirname(__FILE__).'/admin.php'); |
|
| 11 | 11 | |
| 12 | -if ( ! current_user_can( 'manage_options' ) ) |
|
| 13 | - wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) ); |
|
| 12 | +if ( ! current_user_can('manage_options')) |
|
| 13 | + wp_die(__('Sorry, you are not allowed to manage options for this site.')); |
|
| 14 | 14 | |
| 15 | 15 | $title = __('Writing Settings'); |
| 16 | 16 | $parent_file = 'options-general.php'; |
| 17 | 17 | |
| 18 | -get_current_screen()->add_help_tab( array( |
|
| 18 | +get_current_screen()->add_help_tab(array( |
|
| 19 | 19 | 'id' => 'overview', |
| 20 | 20 | 'title' => __('Overview'), |
| 21 | - 'content' => '<p>' . __('You can submit content in several different ways; this screen holds the settings for all of them. The top section controls the editor within the dashboard, while the rest control external publishing methods. For more information on any of these methods, use the documentation links.') . '</p>' . |
|
| 22 | - '<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>', |
|
| 23 | -) ); |
|
| 21 | + 'content' => '<p>'.__('You can submit content in several different ways; this screen holds the settings for all of them. The top section controls the editor within the dashboard, while the rest control external publishing methods. For more information on any of these methods, use the documentation links.').'</p>'. |
|
| 22 | + '<p>'.__('You must click the Save Changes button at the bottom of the screen for new settings to take effect.').'</p>', |
|
| 23 | +)); |
|
| 24 | 24 | |
| 25 | 25 | /** This filter is documented in wp-admin/options.php */ |
| 26 | -if ( apply_filters( 'enable_post_by_email_configuration', true ) ) { |
|
| 27 | - get_current_screen()->add_help_tab( array( |
|
| 26 | +if (apply_filters('enable_post_by_email_configuration', true)) { |
|
| 27 | + get_current_screen()->add_help_tab(array( |
|
| 28 | 28 | 'id' => 'options-postemail', |
| 29 | - 'title' => __( 'Post Via Email' ), |
|
| 30 | - 'content' => '<p>' . __( 'Post via email settings allow you to send your WordPress install an email with the content of your post. You must set up a secret email account with POP3 access to use this, and any mail received at this address will be posted, so it’s a good idea to keep this address very secret.' ) . '</p>', |
|
| 31 | - ) ); |
|
| 29 | + 'title' => __('Post Via Email'), |
|
| 30 | + 'content' => '<p>'.__('Post via email settings allow you to send your WordPress install an email with the content of your post. You must set up a secret email account with POP3 access to use this, and any mail received at this address will be posted, so it’s a good idea to keep this address very secret.').'</p>', |
|
| 31 | + )); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** This filter is documented in wp-admin/options-writing.php */ |
| 35 | -if ( apply_filters( 'enable_update_services_configuration', true ) ) { |
|
| 36 | - get_current_screen()->add_help_tab( array( |
|
| 35 | +if (apply_filters('enable_update_services_configuration', true)) { |
|
| 36 | + get_current_screen()->add_help_tab(array( |
|
| 37 | 37 | 'id' => 'options-services', |
| 38 | - 'title' => __( 'Update Services' ), |
|
| 39 | - 'content' => '<p>' . __( 'If desired, WordPress will automatically alert various services of your new posts.' ) . '</p>', |
|
| 40 | - ) ); |
|
| 38 | + 'title' => __('Update Services'), |
|
| 39 | + 'content' => '<p>'.__('If desired, WordPress will automatically alert various services of your new posts.').'</p>', |
|
| 40 | + )); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | get_current_screen()->set_help_sidebar( |
| 44 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
| 45 | - '<p>' . __('<a href="https://codex.wordpress.org/Settings_Writing_Screen" target="_blank">Documentation on Writing Settings</a>') . '</p>' . |
|
| 46 | - '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
|
| 44 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
| 45 | + '<p>'.__('<a href="https://codex.wordpress.org/Settings_Writing_Screen" target="_blank">Documentation on Writing Settings</a>').'</p>'. |
|
| 46 | + '<p>'.__('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>').'</p>' |
|
| 47 | 47 | ); |
| 48 | 48 | |
| 49 | -include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
| 49 | +include(ABSPATH.'wp-admin/admin-header.php'); |
|
| 50 | 50 | ?> |
| 51 | 51 | |
| 52 | 52 | <div class="wrap"> |
| 53 | -<h1><?php echo esc_html( $title ); ?></h1> |
|
| 53 | +<h1><?php echo esc_html($title); ?></h1> |
|
| 54 | 54 | |
| 55 | 55 | <form method="post" action="options.php"> |
| 56 | 56 | <?php settings_fields('writing'); ?> |
| 57 | 57 | |
| 58 | 58 | <table class="form-table"> |
| 59 | -<?php if ( get_site_option( 'initial_db_version' ) < 32453 ) : ?> |
|
| 59 | +<?php if (get_site_option('initial_db_version') < 32453) : ?> |
|
| 60 | 60 | <tr> |
| 61 | 61 | <th scope="row"><?php _e('Formatting') ?></th> |
| 62 | 62 | <td><fieldset><legend class="screen-reader-text"><span><?php _e('Formatting') ?></span></legend> |
@@ -77,21 +77,21 @@ discard block |
||
| 77 | 77 | </tr> |
| 78 | 78 | <?php |
| 79 | 79 | $post_formats = get_post_format_strings(); |
| 80 | -unset( $post_formats['standard'] ); |
|
| 80 | +unset($post_formats['standard']); |
|
| 81 | 81 | ?> |
| 82 | 82 | <tr> |
| 83 | 83 | <th scope="row"><label for="default_post_format"><?php _e('Default Post Format') ?></label></th> |
| 84 | 84 | <td> |
| 85 | 85 | <select name="default_post_format" id="default_post_format"> |
| 86 | - <option value="0"><?php echo get_post_format_string( 'standard' ); ?></option> |
|
| 87 | -<?php foreach ( $post_formats as $format_slug => $format_name ): ?> |
|
| 88 | - <option<?php selected( get_option( 'default_post_format' ), $format_slug ); ?> value="<?php echo esc_attr( $format_slug ); ?>"><?php echo esc_html( $format_name ); ?></option> |
|
| 86 | + <option value="0"><?php echo get_post_format_string('standard'); ?></option> |
|
| 87 | +<?php foreach ($post_formats as $format_slug => $format_name): ?> |
|
| 88 | + <option<?php selected(get_option('default_post_format'), $format_slug); ?> value="<?php echo esc_attr($format_slug); ?>"><?php echo esc_html($format_name); ?></option> |
|
| 89 | 89 | <?php endforeach; ?> |
| 90 | 90 | </select> |
| 91 | 91 | </td> |
| 92 | 92 | </tr> |
| 93 | 93 | <?php |
| 94 | -if ( get_option( 'link_manager_enabled' ) ) : |
|
| 94 | +if (get_option('link_manager_enabled')) : |
|
| 95 | 95 | ?> |
| 96 | 96 | <tr> |
| 97 | 97 | <th scope="row"><label for="default_link_category"><?php _e('Default Link Category') ?></label></th> |
@@ -111,16 +111,16 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | <?php |
| 113 | 113 | /** This filter is documented in wp-admin/options.php */ |
| 114 | -if ( apply_filters( 'enable_post_by_email_configuration', true ) ) { |
|
| 114 | +if (apply_filters('enable_post_by_email_configuration', true)) { |
|
| 115 | 115 | ?> |
| 116 | -<h2 class="title"><?php _e( 'Post via email' ) ?></h2> |
|
| 116 | +<h2 class="title"><?php _e('Post via email') ?></h2> |
|
| 117 | 117 | <p><?php |
| 118 | 118 | printf( |
| 119 | 119 | /* translators: 1, 2, 3: examples of random email addresses */ |
| 120 | - __( 'To post to WordPress by email you must set up a secret email account with POP3 access. Any mail received at this address will be posted, so it’s a good idea to keep this address very secret. Here are three random strings you could use: %1$s, %2$s, %3$s.' ), |
|
| 121 | - sprintf( '<kbd>%s</kbd>', wp_generate_password( 8, false ) ), |
|
| 122 | - sprintf( '<kbd>%s</kbd>', wp_generate_password( 8, false ) ), |
|
| 123 | - sprintf( '<kbd>%s</kbd>', wp_generate_password( 8, false ) ) |
|
| 120 | + __('To post to WordPress by email you must set up a secret email account with POP3 access. Any mail received at this address will be posted, so it’s a good idea to keep this address very secret. Here are three random strings you could use: %1$s, %2$s, %3$s.'), |
|
| 121 | + sprintf('<kbd>%s</kbd>', wp_generate_password(8, false)), |
|
| 122 | + sprintf('<kbd>%s</kbd>', wp_generate_password(8, false)), |
|
| 123 | + sprintf('<kbd>%s</kbd>', wp_generate_password(8, false)) |
|
| 124 | 124 | ); |
| 125 | 125 | ?></p> |
| 126 | 126 | |
@@ -162,15 +162,15 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | * @param bool $enable Whether to enable the Update Services settings area. Default true. |
| 164 | 164 | */ |
| 165 | -if ( apply_filters( 'enable_update_services_configuration', true ) ) { |
|
| 165 | +if (apply_filters('enable_update_services_configuration', true)) { |
|
| 166 | 166 | ?> |
| 167 | -<h2 class="title"><?php _e( 'Update Services' ) ?></h2> |
|
| 167 | +<h2 class="title"><?php _e('Update Services') ?></h2> |
|
| 168 | 168 | |
| 169 | -<?php if ( 1 == get_option('blog_public') ) : ?> |
|
| 169 | +<?php if (1 == get_option('blog_public')) : ?> |
|
| 170 | 170 | |
| 171 | -<p><label for="ping_sites"><?php _e( 'When you publish a new post, WordPress automatically notifies the following site update services. For more about this, see <a href="https://codex.wordpress.org/Update_Services">Update Services</a> on the Codex. Separate multiple service URLs with line breaks.' ) ?></label></p> |
|
| 171 | +<p><label for="ping_sites"><?php _e('When you publish a new post, WordPress automatically notifies the following site update services. For more about this, see <a href="https://codex.wordpress.org/Update_Services">Update Services</a> on the Codex. Separate multiple service URLs with line breaks.') ?></label></p> |
|
| 172 | 172 | |
| 173 | -<textarea name="ping_sites" id="ping_sites" class="large-text code" rows="3"><?php echo esc_textarea( get_option('ping_sites') ); ?></textarea> |
|
| 173 | +<textarea name="ping_sites" id="ping_sites" class="large-text code" rows="3"><?php echo esc_textarea(get_option('ping_sites')); ?></textarea> |
|
| 174 | 174 | |
| 175 | 175 | <?php else : ?> |
| 176 | 176 | |
@@ -185,4 +185,4 @@ discard block |
||
| 185 | 185 | </form> |
| 186 | 186 | </div> |
| 187 | 187 | |
| 188 | -<?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?> |
|
| 188 | +<?php include(ABSPATH.'wp-admin/admin-footer.php'); ?> |
|
@@ -13,54 +13,54 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | /** The descriptions for theme files. */ |
| 15 | 15 | $wp_file_descriptions = array( |
| 16 | - 'functions.php' => __( 'Theme Functions' ), |
|
| 17 | - 'header.php' => __( 'Theme Header' ), |
|
| 18 | - 'footer.php' => __( 'Theme Footer' ), |
|
| 19 | - 'sidebar.php' => __( 'Sidebar' ), |
|
| 20 | - 'comments.php' => __( 'Comments' ), |
|
| 21 | - 'searchform.php' => __( 'Search Form' ), |
|
| 22 | - '404.php' => __( '404 Template' ), |
|
| 23 | - 'link.php' => __( 'Links Template' ), |
|
| 16 | + 'functions.php' => __('Theme Functions'), |
|
| 17 | + 'header.php' => __('Theme Header'), |
|
| 18 | + 'footer.php' => __('Theme Footer'), |
|
| 19 | + 'sidebar.php' => __('Sidebar'), |
|
| 20 | + 'comments.php' => __('Comments'), |
|
| 21 | + 'searchform.php' => __('Search Form'), |
|
| 22 | + '404.php' => __('404 Template'), |
|
| 23 | + 'link.php' => __('Links Template'), |
|
| 24 | 24 | // Archives |
| 25 | - 'index.php' => __( 'Main Index Template' ), |
|
| 26 | - 'archive.php' => __( 'Archives' ), |
|
| 27 | - 'author.php' => __( 'Author Template' ), |
|
| 28 | - 'taxonomy.php' => __( 'Taxonomy Template' ), |
|
| 29 | - 'category.php' => __( 'Category Template' ), |
|
| 30 | - 'tag.php' => __( 'Tag Template' ), |
|
| 31 | - 'home.php' => __( 'Posts Page' ), |
|
| 32 | - 'search.php' => __( 'Search Results' ), |
|
| 33 | - 'date.php' => __( 'Date Template' ), |
|
| 25 | + 'index.php' => __('Main Index Template'), |
|
| 26 | + 'archive.php' => __('Archives'), |
|
| 27 | + 'author.php' => __('Author Template'), |
|
| 28 | + 'taxonomy.php' => __('Taxonomy Template'), |
|
| 29 | + 'category.php' => __('Category Template'), |
|
| 30 | + 'tag.php' => __('Tag Template'), |
|
| 31 | + 'home.php' => __('Posts Page'), |
|
| 32 | + 'search.php' => __('Search Results'), |
|
| 33 | + 'date.php' => __('Date Template'), |
|
| 34 | 34 | // Content |
| 35 | - 'singular.php' => __( 'Singular Template' ), |
|
| 36 | - 'single.php' => __( 'Single Post' ), |
|
| 37 | - 'page.php' => __( 'Single Page' ), |
|
| 38 | - 'front-page.php' => __( 'Static Front Page' ), |
|
| 35 | + 'singular.php' => __('Singular Template'), |
|
| 36 | + 'single.php' => __('Single Post'), |
|
| 37 | + 'page.php' => __('Single Page'), |
|
| 38 | + 'front-page.php' => __('Static Front Page'), |
|
| 39 | 39 | // Attachments |
| 40 | - 'attachment.php' => __( 'Attachment Template' ), |
|
| 41 | - 'image.php' => __( 'Image Attachment Template' ), |
|
| 42 | - 'video.php' => __( 'Video Attachment Template' ), |
|
| 43 | - 'audio.php' => __( 'Audio Attachment Template' ), |
|
| 44 | - 'application.php' => __( 'Application Attachment Template' ), |
|
| 40 | + 'attachment.php' => __('Attachment Template'), |
|
| 41 | + 'image.php' => __('Image Attachment Template'), |
|
| 42 | + 'video.php' => __('Video Attachment Template'), |
|
| 43 | + 'audio.php' => __('Audio Attachment Template'), |
|
| 44 | + 'application.php' => __('Application Attachment Template'), |
|
| 45 | 45 | // Embeds |
| 46 | - 'embed.php' => __( 'Embed Template' ), |
|
| 47 | - 'embed-404.php' => __( 'Embed 404 Template' ), |
|
| 48 | - 'embed-content.php' => __( 'Embed Content Template' ), |
|
| 49 | - 'header-embed.php' => __( 'Embed Header Template' ), |
|
| 50 | - 'footer-embed.php' => __( 'Embed Footer Template' ), |
|
| 46 | + 'embed.php' => __('Embed Template'), |
|
| 47 | + 'embed-404.php' => __('Embed 404 Template'), |
|
| 48 | + 'embed-content.php' => __('Embed Content Template'), |
|
| 49 | + 'header-embed.php' => __('Embed Header Template'), |
|
| 50 | + 'footer-embed.php' => __('Embed Footer Template'), |
|
| 51 | 51 | // Stylesheets |
| 52 | - 'style.css' => __( 'Stylesheet' ), |
|
| 53 | - 'editor-style.css' => __( 'Visual Editor Stylesheet' ), |
|
| 54 | - 'editor-style-rtl.css' => __( 'Visual Editor RTL Stylesheet' ), |
|
| 55 | - 'rtl.css' => __( 'RTL Stylesheet' ), |
|
| 52 | + 'style.css' => __('Stylesheet'), |
|
| 53 | + 'editor-style.css' => __('Visual Editor Stylesheet'), |
|
| 54 | + 'editor-style-rtl.css' => __('Visual Editor RTL Stylesheet'), |
|
| 55 | + 'rtl.css' => __('RTL Stylesheet'), |
|
| 56 | 56 | // Other |
| 57 | - 'my-hacks.php' => __( 'my-hacks.php (legacy hacks support)' ), |
|
| 58 | - '.htaccess' => __( '.htaccess (for rewrite rules )' ), |
|
| 57 | + 'my-hacks.php' => __('my-hacks.php (legacy hacks support)'), |
|
| 58 | + '.htaccess' => __('.htaccess (for rewrite rules )'), |
|
| 59 | 59 | // Deprecated files |
| 60 | - 'wp-layout.css' => __( 'Stylesheet' ), |
|
| 61 | - 'wp-comments.php' => __( 'Comments Template' ), |
|
| 62 | - 'wp-comments-popup.php' => __( 'Popup Comments Template' ), |
|
| 63 | - 'comments-popup.php' => __( 'Popup Comments' ), |
|
| 60 | + 'wp-layout.css' => __('Stylesheet'), |
|
| 61 | + 'wp-comments.php' => __('Comments Template'), |
|
| 62 | + 'wp-comments-popup.php' => __('Popup Comments Template'), |
|
| 63 | + 'comments-popup.php' => __('Popup Comments'), |
|
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -74,21 +74,21 @@ discard block |
||
| 74 | 74 | * @return string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist. |
| 75 | 75 | * Appends 'Page Template' to basename of $file if the file is a page template |
| 76 | 76 | */ |
| 77 | -function get_file_description( $file ) { |
|
| 77 | +function get_file_description($file) { |
|
| 78 | 78 | global $wp_file_descriptions, $allowed_files; |
| 79 | 79 | |
| 80 | - $relative_pathinfo = pathinfo( $file ); |
|
| 81 | - $file_path = $allowed_files[ $file ]; |
|
| 82 | - if ( isset( $wp_file_descriptions[ basename( $file ) ] ) && '.' === $relative_pathinfo['dirname'] ) { |
|
| 83 | - return $wp_file_descriptions[ basename( $file ) ]; |
|
| 84 | - } elseif ( file_exists( $file_path ) && is_file( $file_path ) ) { |
|
| 85 | - $template_data = implode( '', file( $file_path ) ); |
|
| 86 | - if ( preg_match( '|Template Name:(.*)$|mi', $template_data, $name ) ) { |
|
| 87 | - return sprintf( __( '%s Page Template' ), _cleanup_header_comment( $name[1] ) ); |
|
| 80 | + $relative_pathinfo = pathinfo($file); |
|
| 81 | + $file_path = $allowed_files[$file]; |
|
| 82 | + if (isset($wp_file_descriptions[basename($file)]) && '.' === $relative_pathinfo['dirname']) { |
|
| 83 | + return $wp_file_descriptions[basename($file)]; |
|
| 84 | + } elseif (file_exists($file_path) && is_file($file_path)) { |
|
| 85 | + $template_data = implode('', file($file_path)); |
|
| 86 | + if (preg_match('|Template Name:(.*)$|mi', $template_data, $name)) { |
|
| 87 | + return sprintf(__('%s Page Template'), _cleanup_header_comment($name[1])); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - return trim( basename( $file ) ); |
|
| 91 | + return trim(basename($file)); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -99,18 +99,18 @@ discard block |
||
| 99 | 99 | * @return string Full filesystem path to the root of the WordPress installation |
| 100 | 100 | */ |
| 101 | 101 | function get_home_path() { |
| 102 | - $home = set_url_scheme( get_option( 'home' ), 'http' ); |
|
| 103 | - $siteurl = set_url_scheme( get_option( 'siteurl' ), 'http' ); |
|
| 104 | - if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) { |
|
| 105 | - $wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /* $siteurl - $home */ |
|
| 106 | - $pos = strripos( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), trailingslashit( $wp_path_rel_to_home ) ); |
|
| 107 | - $home_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos ); |
|
| 108 | - $home_path = trailingslashit( $home_path ); |
|
| 102 | + $home = set_url_scheme(get_option('home'), 'http'); |
|
| 103 | + $siteurl = set_url_scheme(get_option('siteurl'), 'http'); |
|
| 104 | + if ( ! empty($home) && 0 !== strcasecmp($home, $siteurl)) { |
|
| 105 | + $wp_path_rel_to_home = str_ireplace($home, '', $siteurl); /* $siteurl - $home */ |
|
| 106 | + $pos = strripos(str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']), trailingslashit($wp_path_rel_to_home)); |
|
| 107 | + $home_path = substr($_SERVER['SCRIPT_FILENAME'], 0, $pos); |
|
| 108 | + $home_path = trailingslashit($home_path); |
|
| 109 | 109 | } else { |
| 110 | 110 | $home_path = ABSPATH; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - return str_replace( '\\', '/', $home_path ); |
|
| 113 | + return str_replace('\\', '/', $home_path); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -123,30 +123,30 @@ discard block |
||
| 123 | 123 | * @param int $levels Optional. Levels of folders to follow, Default 100 (PHP Loop limit). |
| 124 | 124 | * @return bool|array False on failure, Else array of files |
| 125 | 125 | */ |
| 126 | -function list_files( $folder = '', $levels = 100 ) { |
|
| 127 | - if ( empty($folder) ) |
|
| 126 | +function list_files($folder = '', $levels = 100) { |
|
| 127 | + if (empty($folder)) |
|
| 128 | 128 | return false; |
| 129 | 129 | |
| 130 | - if ( ! $levels ) |
|
| 130 | + if ( ! $levels) |
|
| 131 | 131 | return false; |
| 132 | 132 | |
| 133 | 133 | $files = array(); |
| 134 | - if ( $dir = @opendir( $folder ) ) { |
|
| 135 | - while (($file = readdir( $dir ) ) !== false ) { |
|
| 136 | - if ( in_array($file, array('.', '..') ) ) |
|
| 134 | + if ($dir = @opendir($folder)) { |
|
| 135 | + while (($file = readdir($dir)) !== false) { |
|
| 136 | + if (in_array($file, array('.', '..'))) |
|
| 137 | 137 | continue; |
| 138 | - if ( is_dir( $folder . '/' . $file ) ) { |
|
| 139 | - $files2 = list_files( $folder . '/' . $file, $levels - 1); |
|
| 140 | - if ( $files2 ) |
|
| 141 | - $files = array_merge($files, $files2 ); |
|
| 138 | + if (is_dir($folder.'/'.$file)) { |
|
| 139 | + $files2 = list_files($folder.'/'.$file, $levels - 1); |
|
| 140 | + if ($files2) |
|
| 141 | + $files = array_merge($files, $files2); |
|
| 142 | 142 | else |
| 143 | - $files[] = $folder . '/' . $file . '/'; |
|
| 143 | + $files[] = $folder.'/'.$file.'/'; |
|
| 144 | 144 | } else { |
| 145 | - $files[] = $folder . '/' . $file; |
|
| 145 | + $files[] = $folder.'/'.$file; |
|
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | - @closedir( $dir ); |
|
| 149 | + @closedir($dir); |
|
| 150 | 150 | return $files; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -163,35 +163,35 @@ discard block |
||
| 163 | 163 | * @param string $dir Optional. Directory to store the file in. Default empty. |
| 164 | 164 | * @return string a writable filename |
| 165 | 165 | */ |
| 166 | -function wp_tempnam( $filename = '', $dir = '' ) { |
|
| 167 | - if ( empty( $dir ) ) { |
|
| 166 | +function wp_tempnam($filename = '', $dir = '') { |
|
| 167 | + if (empty($dir)) { |
|
| 168 | 168 | $dir = get_temp_dir(); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if ( empty( $filename ) || '.' == $filename || '/' == $filename || '\\' == $filename ) { |
|
| 171 | + if (empty($filename) || '.' == $filename || '/' == $filename || '\\' == $filename) { |
|
| 172 | 172 | $filename = time(); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | // Use the basename of the given file without the extension as the name for the temporary directory |
| 176 | - $temp_filename = basename( $filename ); |
|
| 177 | - $temp_filename = preg_replace( '|\.[^.]*$|', '', $temp_filename ); |
|
| 176 | + $temp_filename = basename($filename); |
|
| 177 | + $temp_filename = preg_replace('|\.[^.]*$|', '', $temp_filename); |
|
| 178 | 178 | |
| 179 | 179 | // If the folder is falsey, use its parent directory name instead. |
| 180 | - if ( ! $temp_filename ) { |
|
| 181 | - return wp_tempnam( dirname( $filename ), $dir ); |
|
| 180 | + if ( ! $temp_filename) { |
|
| 181 | + return wp_tempnam(dirname($filename), $dir); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | // Suffix some random data to avoid filename conflicts |
| 185 | - $temp_filename .= '-' . wp_generate_password( 6, false ); |
|
| 185 | + $temp_filename .= '-'.wp_generate_password(6, false); |
|
| 186 | 186 | $temp_filename .= '.tmp'; |
| 187 | - $temp_filename = $dir . wp_unique_filename( $dir, $temp_filename ); |
|
| 187 | + $temp_filename = $dir.wp_unique_filename($dir, $temp_filename); |
|
| 188 | 188 | |
| 189 | - $fp = @fopen( $temp_filename, 'x' ); |
|
| 190 | - if ( ! $fp && is_writable( $dir ) && file_exists( $temp_filename ) ) { |
|
| 191 | - return wp_tempnam( $filename, $dir ); |
|
| 189 | + $fp = @fopen($temp_filename, 'x'); |
|
| 190 | + if ( ! $fp && is_writable($dir) && file_exists($temp_filename)) { |
|
| 191 | + return wp_tempnam($filename, $dir); |
|
| 192 | 192 | } |
| 193 | - if ( $fp ) { |
|
| 194 | - fclose( $fp ); |
|
| 193 | + if ($fp) { |
|
| 194 | + fclose($fp); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | return $temp_filename; |
@@ -208,21 +208,21 @@ discard block |
||
| 208 | 208 | * @param array $allowed_files Array of allowed files to edit, $file must match an entry exactly |
| 209 | 209 | * @return string|null |
| 210 | 210 | */ |
| 211 | -function validate_file_to_edit( $file, $allowed_files = '' ) { |
|
| 212 | - $code = validate_file( $file, $allowed_files ); |
|
| 211 | +function validate_file_to_edit($file, $allowed_files = '') { |
|
| 212 | + $code = validate_file($file, $allowed_files); |
|
| 213 | 213 | |
| 214 | - if (!$code ) |
|
| 214 | + if ( ! $code) |
|
| 215 | 215 | return $file; |
| 216 | 216 | |
| 217 | - switch ( $code ) { |
|
| 217 | + switch ($code) { |
|
| 218 | 218 | case 1 : |
| 219 | - wp_die( __( 'Sorry, that file cannot be edited.' ) ); |
|
| 219 | + wp_die(__('Sorry, that file cannot be edited.')); |
|
| 220 | 220 | |
| 221 | 221 | // case 2 : |
| 222 | 222 | // wp_die( __('Sorry, can’t call files with their real path.' )); |
| 223 | 223 | |
| 224 | 224 | case 3 : |
| 225 | - wp_die( __( 'Sorry, that file cannot be edited.' ) ); |
|
| 225 | + wp_die(__('Sorry, that file cannot be edited.')); |
|
| 226 | 226 | } |
| 227 | 227 | } |
| 228 | 228 | |
@@ -242,11 +242,11 @@ discard block |
||
| 242 | 242 | * @return array On success, returns an associative array of file attributes. On failure, returns |
| 243 | 243 | * $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ). |
| 244 | 244 | */ |
| 245 | -function _wp_handle_upload( &$file, $overrides, $time, $action ) { |
|
| 245 | +function _wp_handle_upload(&$file, $overrides, $time, $action) { |
|
| 246 | 246 | // The default error handler. |
| 247 | - if ( ! function_exists( 'wp_handle_upload_error' ) ) { |
|
| 248 | - function wp_handle_upload_error( &$file, $message ) { |
|
| 249 | - return array( 'error' => $message ); |
|
| 247 | + if ( ! function_exists('wp_handle_upload_error')) { |
|
| 248 | + function wp_handle_upload_error(&$file, $message) { |
|
| 249 | + return array('error' => $message); |
|
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | |
@@ -260,24 +260,24 @@ discard block |
||
| 260 | 260 | * |
| 261 | 261 | * @param array $file An array of data for a single file. |
| 262 | 262 | */ |
| 263 | - $file = apply_filters( "{$action}_prefilter", $file ); |
|
| 263 | + $file = apply_filters("{$action}_prefilter", $file); |
|
| 264 | 264 | |
| 265 | 265 | // You may define your own function and pass the name in $overrides['upload_error_handler'] |
| 266 | 266 | $upload_error_handler = 'wp_handle_upload_error'; |
| 267 | - if ( isset( $overrides['upload_error_handler'] ) ) { |
|
| 267 | + if (isset($overrides['upload_error_handler'])) { |
|
| 268 | 268 | $upload_error_handler = $overrides['upload_error_handler']; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | // You may have had one or more 'wp_handle_upload_prefilter' functions error out the file. Handle that gracefully. |
| 272 | - if ( isset( $file['error'] ) && ! is_numeric( $file['error'] ) && $file['error'] ) { |
|
| 273 | - return call_user_func_array( $upload_error_handler, array( &$file, $file['error'] ) ); |
|
| 272 | + if (isset($file['error']) && ! is_numeric($file['error']) && $file['error']) { |
|
| 273 | + return call_user_func_array($upload_error_handler, array(&$file, $file['error'])); |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | // Install user overrides. Did we mention that this voids your warranty? |
| 277 | 277 | |
| 278 | 278 | // You may define your own function and pass the name in $overrides['unique_filename_callback'] |
| 279 | 279 | $unique_filename_callback = null; |
| 280 | - if ( isset( $overrides['unique_filename_callback'] ) ) { |
|
| 280 | + if (isset($overrides['unique_filename_callback'])) { |
|
| 281 | 281 | $unique_filename_callback = $overrides['unique_filename_callback']; |
| 282 | 282 | } |
| 283 | 283 | |
@@ -285,72 +285,72 @@ discard block |
||
| 285 | 285 | * This may not have orignially been intended to be overrideable, |
| 286 | 286 | * but historically has been. |
| 287 | 287 | */ |
| 288 | - if ( isset( $overrides['upload_error_strings'] ) ) { |
|
| 288 | + if (isset($overrides['upload_error_strings'])) { |
|
| 289 | 289 | $upload_error_strings = $overrides['upload_error_strings']; |
| 290 | 290 | } else { |
| 291 | 291 | // Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error']. |
| 292 | 292 | $upload_error_strings = array( |
| 293 | 293 | false, |
| 294 | - __( 'The uploaded file exceeds the upload_max_filesize directive in php.ini.' ), |
|
| 295 | - __( 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.' ), |
|
| 296 | - __( 'The uploaded file was only partially uploaded.' ), |
|
| 297 | - __( 'No file was uploaded.' ), |
|
| 294 | + __('The uploaded file exceeds the upload_max_filesize directive in php.ini.'), |
|
| 295 | + __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'), |
|
| 296 | + __('The uploaded file was only partially uploaded.'), |
|
| 297 | + __('No file was uploaded.'), |
|
| 298 | 298 | '', |
| 299 | - __( 'Missing a temporary folder.' ), |
|
| 300 | - __( 'Failed to write file to disk.' ), |
|
| 301 | - __( 'File upload stopped by extension.' ) |
|
| 299 | + __('Missing a temporary folder.'), |
|
| 300 | + __('Failed to write file to disk.'), |
|
| 301 | + __('File upload stopped by extension.') |
|
| 302 | 302 | ); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | // All tests are on by default. Most can be turned off by $overrides[{test_name}] = false; |
| 306 | - $test_form = isset( $overrides['test_form'] ) ? $overrides['test_form'] : true; |
|
| 307 | - $test_size = isset( $overrides['test_size'] ) ? $overrides['test_size'] : true; |
|
| 306 | + $test_form = isset($overrides['test_form']) ? $overrides['test_form'] : true; |
|
| 307 | + $test_size = isset($overrides['test_size']) ? $overrides['test_size'] : true; |
|
| 308 | 308 | |
| 309 | 309 | // If you override this, you must provide $ext and $type!! |
| 310 | - $test_type = isset( $overrides['test_type'] ) ? $overrides['test_type'] : true; |
|
| 311 | - $mimes = isset( $overrides['mimes'] ) ? $overrides['mimes'] : false; |
|
| 310 | + $test_type = isset($overrides['test_type']) ? $overrides['test_type'] : true; |
|
| 311 | + $mimes = isset($overrides['mimes']) ? $overrides['mimes'] : false; |
|
| 312 | 312 | |
| 313 | 313 | // A correct form post will pass this test. |
| 314 | - if ( $test_form && ( ! isset( $_POST['action'] ) || ( $_POST['action'] != $action ) ) ) { |
|
| 315 | - return call_user_func_array( $upload_error_handler, array( &$file, __( 'Invalid form submission.' ) ) ); |
|
| 314 | + if ($test_form && ( ! isset($_POST['action']) || ($_POST['action'] != $action))) { |
|
| 315 | + return call_user_func_array($upload_error_handler, array(&$file, __('Invalid form submission.'))); |
|
| 316 | 316 | } |
| 317 | 317 | // A successful upload will pass this test. It makes no sense to override this one. |
| 318 | - if ( isset( $file['error'] ) && $file['error'] > 0 ) { |
|
| 319 | - return call_user_func_array( $upload_error_handler, array( &$file, $upload_error_strings[ $file['error'] ] ) ); |
|
| 318 | + if (isset($file['error']) && $file['error'] > 0) { |
|
| 319 | + return call_user_func_array($upload_error_handler, array(&$file, $upload_error_strings[$file['error']])); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - $test_file_size = 'wp_handle_upload' === $action ? $file['size'] : filesize( $file['tmp_name'] ); |
|
| 322 | + $test_file_size = 'wp_handle_upload' === $action ? $file['size'] : filesize($file['tmp_name']); |
|
| 323 | 323 | // A non-empty file will pass this test. |
| 324 | - if ( $test_size && ! ( $test_file_size > 0 ) ) { |
|
| 325 | - if ( is_multisite() ) { |
|
| 326 | - $error_msg = __( 'File is empty. Please upload something more substantial.' ); |
|
| 324 | + if ($test_size && ! ($test_file_size > 0)) { |
|
| 325 | + if (is_multisite()) { |
|
| 326 | + $error_msg = __('File is empty. Please upload something more substantial.'); |
|
| 327 | 327 | } else { |
| 328 | - $error_msg = __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' ); |
|
| 328 | + $error_msg = __('File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.'); |
|
| 329 | 329 | } |
| 330 | - return call_user_func_array( $upload_error_handler, array( &$file, $error_msg ) ); |
|
| 330 | + return call_user_func_array($upload_error_handler, array(&$file, $error_msg)); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | // A properly uploaded file will pass this test. There should be no reason to override this one. |
| 334 | - $test_uploaded_file = 'wp_handle_upload' === $action ? @ is_uploaded_file( $file['tmp_name'] ) : @ is_file( $file['tmp_name'] ); |
|
| 335 | - if ( ! $test_uploaded_file ) { |
|
| 336 | - return call_user_func_array( $upload_error_handler, array( &$file, __( 'Specified file failed upload test.' ) ) ); |
|
| 334 | + $test_uploaded_file = 'wp_handle_upload' === $action ? @ is_uploaded_file($file['tmp_name']) : @ is_file($file['tmp_name']); |
|
| 335 | + if ( ! $test_uploaded_file) { |
|
| 336 | + return call_user_func_array($upload_error_handler, array(&$file, __('Specified file failed upload test.'))); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | // A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter. |
| 340 | - if ( $test_type ) { |
|
| 341 | - $wp_filetype = wp_check_filetype_and_ext( $file['tmp_name'], $file['name'], $mimes ); |
|
| 342 | - $ext = empty( $wp_filetype['ext'] ) ? '' : $wp_filetype['ext']; |
|
| 343 | - $type = empty( $wp_filetype['type'] ) ? '' : $wp_filetype['type']; |
|
| 344 | - $proper_filename = empty( $wp_filetype['proper_filename'] ) ? '' : $wp_filetype['proper_filename']; |
|
| 340 | + if ($test_type) { |
|
| 341 | + $wp_filetype = wp_check_filetype_and_ext($file['tmp_name'], $file['name'], $mimes); |
|
| 342 | + $ext = empty($wp_filetype['ext']) ? '' : $wp_filetype['ext']; |
|
| 343 | + $type = empty($wp_filetype['type']) ? '' : $wp_filetype['type']; |
|
| 344 | + $proper_filename = empty($wp_filetype['proper_filename']) ? '' : $wp_filetype['proper_filename']; |
|
| 345 | 345 | |
| 346 | 346 | // Check to see if wp_check_filetype_and_ext() determined the filename was incorrect |
| 347 | - if ( $proper_filename ) { |
|
| 347 | + if ($proper_filename) { |
|
| 348 | 348 | $file['name'] = $proper_filename; |
| 349 | 349 | } |
| 350 | - if ( ( ! $type || !$ext ) && ! current_user_can( 'unfiltered_upload' ) ) { |
|
| 351 | - return call_user_func_array( $upload_error_handler, array( &$file, __( 'Sorry, this file type is not permitted for security reasons.' ) ) ); |
|
| 350 | + if (( ! $type || ! $ext) && ! current_user_can('unfiltered_upload')) { |
|
| 351 | + return call_user_func_array($upload_error_handler, array(&$file, __('Sorry, this file type is not permitted for security reasons.'))); |
|
| 352 | 352 | } |
| 353 | - if ( ! $type ) { |
|
| 353 | + if ( ! $type) { |
|
| 354 | 354 | $type = $file['type']; |
| 355 | 355 | } |
| 356 | 356 | } else { |
@@ -361,41 +361,41 @@ discard block |
||
| 361 | 361 | * A writable uploads dir will pass this test. Again, there's no point |
| 362 | 362 | * overriding this one. |
| 363 | 363 | */ |
| 364 | - if ( ! ( ( $uploads = wp_upload_dir( $time ) ) && false === $uploads['error'] ) ) { |
|
| 365 | - return call_user_func_array( $upload_error_handler, array( &$file, $uploads['error'] ) ); |
|
| 364 | + if ( ! (($uploads = wp_upload_dir($time)) && false === $uploads['error'])) { |
|
| 365 | + return call_user_func_array($upload_error_handler, array(&$file, $uploads['error'])); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - $filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback ); |
|
| 368 | + $filename = wp_unique_filename($uploads['path'], $file['name'], $unique_filename_callback); |
|
| 369 | 369 | |
| 370 | 370 | // Move the file to the uploads dir. |
| 371 | - $new_file = $uploads['path'] . "/$filename"; |
|
| 372 | - if ( 'wp_handle_upload' === $action ) { |
|
| 373 | - $move_new_file = @ move_uploaded_file( $file['tmp_name'], $new_file ); |
|
| 371 | + $new_file = $uploads['path']."/$filename"; |
|
| 372 | + if ('wp_handle_upload' === $action) { |
|
| 373 | + $move_new_file = @ move_uploaded_file($file['tmp_name'], $new_file); |
|
| 374 | 374 | } else { |
| 375 | 375 | // use copy and unlink because rename breaks streams. |
| 376 | - $move_new_file = @ copy( $file['tmp_name'], $new_file ); |
|
| 377 | - unlink( $file['tmp_name'] ); |
|
| 376 | + $move_new_file = @ copy($file['tmp_name'], $new_file); |
|
| 377 | + unlink($file['tmp_name']); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | - if ( false === $move_new_file ) { |
|
| 381 | - if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) { |
|
| 382 | - $error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir']; |
|
| 380 | + if (false === $move_new_file) { |
|
| 381 | + if (0 === strpos($uploads['basedir'], ABSPATH)) { |
|
| 382 | + $error_path = str_replace(ABSPATH, '', $uploads['basedir']).$uploads['subdir']; |
|
| 383 | 383 | } else { |
| 384 | - $error_path = basename( $uploads['basedir'] ) . $uploads['subdir']; |
|
| 384 | + $error_path = basename($uploads['basedir']).$uploads['subdir']; |
|
| 385 | 385 | } |
| 386 | - return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $error_path ) ); |
|
| 386 | + return $upload_error_handler($file, sprintf(__('The uploaded file could not be moved to %s.'), $error_path)); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | // Set correct file permissions. |
| 390 | - $stat = stat( dirname( $new_file )); |
|
| 390 | + $stat = stat(dirname($new_file)); |
|
| 391 | 391 | $perms = $stat['mode'] & 0000666; |
| 392 | - @ chmod( $new_file, $perms ); |
|
| 392 | + @ chmod($new_file, $perms); |
|
| 393 | 393 | |
| 394 | 394 | // Compute the URL. |
| 395 | - $url = $uploads['url'] . "/$filename"; |
|
| 395 | + $url = $uploads['url']."/$filename"; |
|
| 396 | 396 | |
| 397 | - if ( is_multisite() ) { |
|
| 398 | - delete_transient( 'dirsize_cache' ); |
|
| 397 | + if (is_multisite()) { |
|
| 398 | + delete_transient('dirsize_cache'); |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | /** |
@@ -412,11 +412,11 @@ discard block |
||
| 412 | 412 | * } |
| 413 | 413 | * @param string $context The type of upload action. Values include 'upload' or 'sideload'. |
| 414 | 414 | */ |
| 415 | - return apply_filters( 'wp_handle_upload', array( |
|
| 415 | + return apply_filters('wp_handle_upload', array( |
|
| 416 | 416 | 'file' => $new_file, |
| 417 | 417 | 'url' => $url, |
| 418 | 418 | 'type' => $type |
| 419 | - ), 'wp_handle_sideload' === $action ? 'sideload' : 'upload' ); |
|
| 419 | + ), 'wp_handle_sideload' === $action ? 'sideload' : 'upload'); |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | /** |
@@ -436,17 +436,17 @@ discard block |
||
| 436 | 436 | * @return array On success, returns an associative array of file attributes. On failure, returns |
| 437 | 437 | * $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ). |
| 438 | 438 | */ |
| 439 | -function wp_handle_upload( &$file, $overrides = false, $time = null ) { |
|
| 439 | +function wp_handle_upload(&$file, $overrides = false, $time = null) { |
|
| 440 | 440 | /* |
| 441 | 441 | * $_POST['action'] must be set and its value must equal $overrides['action'] |
| 442 | 442 | * or this: |
| 443 | 443 | */ |
| 444 | 444 | $action = 'wp_handle_upload'; |
| 445 | - if ( isset( $overrides['action'] ) ) { |
|
| 445 | + if (isset($overrides['action'])) { |
|
| 446 | 446 | $action = $overrides['action']; |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | - return _wp_handle_upload( $file, $overrides, $time, $action ); |
|
| 449 | + return _wp_handle_upload($file, $overrides, $time, $action); |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | /** |
@@ -465,16 +465,16 @@ discard block |
||
| 465 | 465 | * @return array On success, returns an associative array of file attributes. On failure, returns |
| 466 | 466 | * $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ). |
| 467 | 467 | */ |
| 468 | -function wp_handle_sideload( &$file, $overrides = false, $time = null ) { |
|
| 468 | +function wp_handle_sideload(&$file, $overrides = false, $time = null) { |
|
| 469 | 469 | /* |
| 470 | 470 | * $_POST['action'] must be set and its value must equal $overrides['action'] |
| 471 | 471 | * or this: |
| 472 | 472 | */ |
| 473 | 473 | $action = 'wp_handle_sideload'; |
| 474 | - if ( isset( $overrides['action'] ) ) { |
|
| 474 | + if (isset($overrides['action'])) { |
|
| 475 | 475 | $action = $overrides['action']; |
| 476 | 476 | } |
| 477 | - return _wp_handle_upload( $file, $overrides, $time, $action ); |
|
| 477 | + return _wp_handle_upload($file, $overrides, $time, $action); |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | |
@@ -488,34 +488,34 @@ discard block |
||
| 488 | 488 | * @param int $timeout The timeout for the request to download the file default 300 seconds |
| 489 | 489 | * @return mixed WP_Error on failure, string Filename on success. |
| 490 | 490 | */ |
| 491 | -function download_url( $url, $timeout = 300 ) { |
|
| 491 | +function download_url($url, $timeout = 300) { |
|
| 492 | 492 | //WARNING: The file is not automatically deleted, The script must unlink() the file. |
| 493 | - if ( ! $url ) |
|
| 493 | + if ( ! $url) |
|
| 494 | 494 | return new WP_Error('http_no_url', __('Invalid URL Provided.')); |
| 495 | 495 | |
| 496 | - $url_filename = basename( parse_url( $url, PHP_URL_PATH ) ); |
|
| 496 | + $url_filename = basename(parse_url($url, PHP_URL_PATH)); |
|
| 497 | 497 | |
| 498 | - $tmpfname = wp_tempnam( $url_filename ); |
|
| 499 | - if ( ! $tmpfname ) |
|
| 498 | + $tmpfname = wp_tempnam($url_filename); |
|
| 499 | + if ( ! $tmpfname) |
|
| 500 | 500 | return new WP_Error('http_no_file', __('Could not create Temporary file.')); |
| 501 | 501 | |
| 502 | - $response = wp_safe_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname ) ); |
|
| 502 | + $response = wp_safe_remote_get($url, array('timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname)); |
|
| 503 | 503 | |
| 504 | - if ( is_wp_error( $response ) ) { |
|
| 505 | - unlink( $tmpfname ); |
|
| 504 | + if (is_wp_error($response)) { |
|
| 505 | + unlink($tmpfname); |
|
| 506 | 506 | return $response; |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | - if ( 200 != wp_remote_retrieve_response_code( $response ) ){ |
|
| 510 | - unlink( $tmpfname ); |
|
| 511 | - return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) ); |
|
| 509 | + if (200 != wp_remote_retrieve_response_code($response)) { |
|
| 510 | + unlink($tmpfname); |
|
| 511 | + return new WP_Error('http_404', trim(wp_remote_retrieve_response_message($response))); |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - $content_md5 = wp_remote_retrieve_header( $response, 'content-md5' ); |
|
| 515 | - if ( $content_md5 ) { |
|
| 516 | - $md5_check = verify_file_md5( $tmpfname, $content_md5 ); |
|
| 517 | - if ( is_wp_error( $md5_check ) ) { |
|
| 518 | - unlink( $tmpfname ); |
|
| 514 | + $content_md5 = wp_remote_retrieve_header($response, 'content-md5'); |
|
| 515 | + if ($content_md5) { |
|
| 516 | + $md5_check = verify_file_md5($tmpfname, $content_md5); |
|
| 517 | + if (is_wp_error($md5_check)) { |
|
| 518 | + unlink($tmpfname); |
|
| 519 | 519 | return $md5_check; |
| 520 | 520 | } |
| 521 | 521 | } |
@@ -532,20 +532,20 @@ discard block |
||
| 532 | 532 | * @param string $expected_md5 The expected MD5 of the file, either a base64 encoded raw md5, or a hex-encoded md5 |
| 533 | 533 | * @return bool|object WP_Error on failure, true on success, false when the MD5 format is unknown/unexpected |
| 534 | 534 | */ |
| 535 | -function verify_file_md5( $filename, $expected_md5 ) { |
|
| 536 | - if ( 32 == strlen( $expected_md5 ) ) |
|
| 537 | - $expected_raw_md5 = pack( 'H*', $expected_md5 ); |
|
| 538 | - elseif ( 24 == strlen( $expected_md5 ) ) |
|
| 539 | - $expected_raw_md5 = base64_decode( $expected_md5 ); |
|
| 535 | +function verify_file_md5($filename, $expected_md5) { |
|
| 536 | + if (32 == strlen($expected_md5)) |
|
| 537 | + $expected_raw_md5 = pack('H*', $expected_md5); |
|
| 538 | + elseif (24 == strlen($expected_md5)) |
|
| 539 | + $expected_raw_md5 = base64_decode($expected_md5); |
|
| 540 | 540 | else |
| 541 | 541 | return false; // unknown format |
| 542 | 542 | |
| 543 | - $file_md5 = md5_file( $filename, true ); |
|
| 543 | + $file_md5 = md5_file($filename, true); |
|
| 544 | 544 | |
| 545 | - if ( $file_md5 === $expected_raw_md5 ) |
|
| 545 | + if ($file_md5 === $expected_raw_md5) |
|
| 546 | 546 | return true; |
| 547 | 547 | |
| 548 | - return new WP_Error( 'md5_mismatch', sprintf( __( 'The checksum of the file (%1$s) does not match the expected checksum value (%2$s).' ), bin2hex( $file_md5 ), bin2hex( $expected_raw_md5 ) ) ); |
|
| 548 | + return new WP_Error('md5_mismatch', sprintf(__('The checksum of the file (%1$s) does not match the expected checksum value (%2$s).'), bin2hex($file_md5), bin2hex($expected_raw_md5))); |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | /** |
@@ -566,27 +566,27 @@ discard block |
||
| 566 | 566 | function unzip_file($file, $to) { |
| 567 | 567 | global $wp_filesystem; |
| 568 | 568 | |
| 569 | - if ( ! $wp_filesystem || !is_object($wp_filesystem) ) |
|
| 569 | + if ( ! $wp_filesystem || ! is_object($wp_filesystem)) |
|
| 570 | 570 | return new WP_Error('fs_unavailable', __('Could not access filesystem.')); |
| 571 | 571 | |
| 572 | 572 | // Unzip can use a lot of memory, but not this much hopefully. |
| 573 | - wp_raise_memory_limit( 'admin' ); |
|
| 573 | + wp_raise_memory_limit('admin'); |
|
| 574 | 574 | |
| 575 | 575 | $needed_dirs = array(); |
| 576 | 576 | $to = trailingslashit($to); |
| 577 | 577 | |
| 578 | 578 | // Determine any parent dir's needed (of the upgrade directory) |
| 579 | - if ( ! $wp_filesystem->is_dir($to) ) { //Only do parents if no children exist |
|
| 579 | + if ( ! $wp_filesystem->is_dir($to)) { //Only do parents if no children exist |
|
| 580 | 580 | $path = preg_split('![/\\\]!', untrailingslashit($to)); |
| 581 | - for ( $i = count($path); $i >= 0; $i-- ) { |
|
| 582 | - if ( empty($path[$i]) ) |
|
| 581 | + for ($i = count($path); $i >= 0; $i--) { |
|
| 582 | + if (empty($path[$i])) |
|
| 583 | 583 | continue; |
| 584 | 584 | |
| 585 | - $dir = implode('/', array_slice($path, 0, $i+1) ); |
|
| 586 | - if ( preg_match('!^[a-z]:$!i', $dir) ) // Skip it if it looks like a Windows Drive letter. |
|
| 585 | + $dir = implode('/', array_slice($path, 0, $i + 1)); |
|
| 586 | + if (preg_match('!^[a-z]:$!i', $dir)) // Skip it if it looks like a Windows Drive letter. |
|
| 587 | 587 | continue; |
| 588 | 588 | |
| 589 | - if ( ! $wp_filesystem->is_dir($dir) ) |
|
| 589 | + if ( ! $wp_filesystem->is_dir($dir)) |
|
| 590 | 590 | $needed_dirs[] = $dir; |
| 591 | 591 | else |
| 592 | 592 | break; // A folder exists, therefor, we dont need the check the levels below this |
@@ -600,12 +600,12 @@ discard block |
||
| 600 | 600 | * |
| 601 | 601 | * @param bool $ziparchive Whether to use ZipArchive. Default true. |
| 602 | 602 | */ |
| 603 | - if ( class_exists( 'ZipArchive', false ) && apply_filters( 'unzip_file_use_ziparchive', true ) ) { |
|
| 603 | + if (class_exists('ZipArchive', false) && apply_filters('unzip_file_use_ziparchive', true)) { |
|
| 604 | 604 | $result = _unzip_file_ziparchive($file, $to, $needed_dirs); |
| 605 | - if ( true === $result ) { |
|
| 605 | + if (true === $result) { |
|
| 606 | 606 | return $result; |
| 607 | - } elseif ( is_wp_error($result) ) { |
|
| 608 | - if ( 'incompatible_archive' != $result->get_error_code() ) |
|
| 607 | + } elseif (is_wp_error($result)) { |
|
| 608 | + if ('incompatible_archive' != $result->get_error_code()) |
|
| 609 | 609 | return $result; |
| 610 | 610 | } |
| 611 | 611 | } |
@@ -628,32 +628,32 @@ discard block |
||
| 628 | 628 | * @param array $needed_dirs A partial list of required folders needed to be created. |
| 629 | 629 | * @return mixed WP_Error on failure, True on success |
| 630 | 630 | */ |
| 631 | -function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) { |
|
| 631 | +function _unzip_file_ziparchive($file, $to, $needed_dirs = array()) { |
|
| 632 | 632 | global $wp_filesystem; |
| 633 | 633 | |
| 634 | 634 | $z = new ZipArchive(); |
| 635 | 635 | |
| 636 | - $zopen = $z->open( $file, ZIPARCHIVE::CHECKCONS ); |
|
| 637 | - if ( true !== $zopen ) |
|
| 638 | - return new WP_Error( 'incompatible_archive', __( 'Incompatible Archive.' ), array( 'ziparchive_error' => $zopen ) ); |
|
| 636 | + $zopen = $z->open($file, ZIPARCHIVE::CHECKCONS); |
|
| 637 | + if (true !== $zopen) |
|
| 638 | + return new WP_Error('incompatible_archive', __('Incompatible Archive.'), array('ziparchive_error' => $zopen)); |
|
| 639 | 639 | |
| 640 | 640 | $uncompressed_size = 0; |
| 641 | 641 | |
| 642 | - for ( $i = 0; $i < $z->numFiles; $i++ ) { |
|
| 643 | - if ( ! $info = $z->statIndex($i) ) |
|
| 644 | - return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) ); |
|
| 642 | + for ($i = 0; $i < $z->numFiles; $i++) { |
|
| 643 | + if ( ! $info = $z->statIndex($i)) |
|
| 644 | + return new WP_Error('stat_failed_ziparchive', __('Could not retrieve file from archive.')); |
|
| 645 | 645 | |
| 646 | - if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Skip the OS X-created __MACOSX directory |
|
| 646 | + if ('__MACOSX/' === substr($info['name'], 0, 9)) // Skip the OS X-created __MACOSX directory |
|
| 647 | 647 | continue; |
| 648 | 648 | |
| 649 | 649 | $uncompressed_size += $info['size']; |
| 650 | 650 | |
| 651 | - if ( '/' === substr( $info['name'], -1 ) ) { |
|
| 651 | + if ('/' === substr($info['name'], -1)) { |
|
| 652 | 652 | // Directory. |
| 653 | - $needed_dirs[] = $to . untrailingslashit( $info['name'] ); |
|
| 654 | - } elseif ( '.' !== $dirname = dirname( $info['name'] ) ) { |
|
| 653 | + $needed_dirs[] = $to.untrailingslashit($info['name']); |
|
| 654 | + } elseif ('.' !== $dirname = dirname($info['name'])) { |
|
| 655 | 655 | // Path to a file. |
| 656 | - $needed_dirs[] = $to . untrailingslashit( $dirname ); |
|
| 656 | + $needed_dirs[] = $to.untrailingslashit($dirname); |
|
| 657 | 657 | } |
| 658 | 658 | } |
| 659 | 659 | |
@@ -662,22 +662,22 @@ discard block |
||
| 662 | 662 | * A disk that has zero free bytes has bigger problems. |
| 663 | 663 | * Require we have enough space to unzip the file and copy its contents, with a 10% buffer. |
| 664 | 664 | */ |
| 665 | - if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
| 666 | - $available_space = @disk_free_space( WP_CONTENT_DIR ); |
|
| 667 | - if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) |
|
| 668 | - return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) ); |
|
| 665 | + if (defined('DOING_CRON') && DOING_CRON) { |
|
| 666 | + $available_space = @disk_free_space(WP_CONTENT_DIR); |
|
| 667 | + if ($available_space && ($uncompressed_size * 2.1) > $available_space) |
|
| 668 | + return new WP_Error('disk_full_unzip_file', __('Could not copy files. You may have run out of disk space.'), compact('uncompressed_size', 'available_space')); |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | $needed_dirs = array_unique($needed_dirs); |
| 672 | - foreach ( $needed_dirs as $dir ) { |
|
| 672 | + foreach ($needed_dirs as $dir) { |
|
| 673 | 673 | // Check the parent folders of the folders all exist within the creation array. |
| 674 | - if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist) |
|
| 674 | + if (untrailingslashit($to) == $dir) // Skip over the working directory, We know this exists (or will exist) |
|
| 675 | 675 | continue; |
| 676 | - if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it |
|
| 676 | + if (strpos($dir, $to) === false) // If the directory is not within the working directory, Skip it |
|
| 677 | 677 | continue; |
| 678 | 678 | |
| 679 | 679 | $parent_folder = dirname($dir); |
| 680 | - while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) { |
|
| 680 | + while ( ! empty($parent_folder) && untrailingslashit($to) != $parent_folder && ! in_array($parent_folder, $needed_dirs)) { |
|
| 681 | 681 | $needed_dirs[] = $parent_folder; |
| 682 | 682 | $parent_folder = dirname($parent_folder); |
| 683 | 683 | } |
@@ -685,30 +685,30 @@ discard block |
||
| 685 | 685 | asort($needed_dirs); |
| 686 | 686 | |
| 687 | 687 | // Create those directories if need be: |
| 688 | - foreach ( $needed_dirs as $_dir ) { |
|
| 688 | + foreach ($needed_dirs as $_dir) { |
|
| 689 | 689 | // Only check to see if the Dir exists upon creation failure. Less I/O this way. |
| 690 | - if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) { |
|
| 691 | - return new WP_Error( 'mkdir_failed_ziparchive', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) ); |
|
| 690 | + if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir)) { |
|
| 691 | + return new WP_Error('mkdir_failed_ziparchive', __('Could not create directory.'), substr($_dir, strlen($to))); |
|
| 692 | 692 | } |
| 693 | 693 | } |
| 694 | 694 | unset($needed_dirs); |
| 695 | 695 | |
| 696 | - for ( $i = 0; $i < $z->numFiles; $i++ ) { |
|
| 697 | - if ( ! $info = $z->statIndex($i) ) |
|
| 698 | - return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) ); |
|
| 696 | + for ($i = 0; $i < $z->numFiles; $i++) { |
|
| 697 | + if ( ! $info = $z->statIndex($i)) |
|
| 698 | + return new WP_Error('stat_failed_ziparchive', __('Could not retrieve file from archive.')); |
|
| 699 | 699 | |
| 700 | - if ( '/' == substr($info['name'], -1) ) // directory |
|
| 700 | + if ('/' == substr($info['name'], -1)) // directory |
|
| 701 | 701 | continue; |
| 702 | 702 | |
| 703 | - if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files |
|
| 703 | + if ('__MACOSX/' === substr($info['name'], 0, 9)) // Don't extract the OS X-created __MACOSX directory files |
|
| 704 | 704 | continue; |
| 705 | 705 | |
| 706 | 706 | $contents = $z->getFromIndex($i); |
| 707 | - if ( false === $contents ) |
|
| 708 | - return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] ); |
|
| 707 | + if (false === $contents) |
|
| 708 | + return new WP_Error('extract_failed_ziparchive', __('Could not extract file from archive.'), $info['name']); |
|
| 709 | 709 | |
| 710 | - if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) ) |
|
| 711 | - return new WP_Error( 'copy_failed_ziparchive', __( 'Could not copy file.' ), $info['name'] ); |
|
| 710 | + if ( ! $wp_filesystem->put_contents($to.$info['name'], $contents, FS_CHMOD_FILE)) |
|
| 711 | + return new WP_Error('copy_failed_ziparchive', __('Could not copy file.'), $info['name']); |
|
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | $z->close(); |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | |
| 737 | 737 | mbstring_binary_safe_encoding(); |
| 738 | 738 | |
| 739 | - require_once(ABSPATH . 'wp-admin/includes/class-pclzip.php'); |
|
| 739 | + require_once(ABSPATH.'wp-admin/includes/class-pclzip.php'); |
|
| 740 | 740 | |
| 741 | 741 | $archive = new PclZip($file); |
| 742 | 742 | |
@@ -745,22 +745,22 @@ discard block |
||
| 745 | 745 | reset_mbstring_encoding(); |
| 746 | 746 | |
| 747 | 747 | // Is the archive valid? |
| 748 | - if ( !is_array($archive_files) ) |
|
| 748 | + if ( ! is_array($archive_files)) |
|
| 749 | 749 | return new WP_Error('incompatible_archive', __('Incompatible Archive.'), $archive->errorInfo(true)); |
| 750 | 750 | |
| 751 | - if ( 0 == count($archive_files) ) |
|
| 752 | - return new WP_Error( 'empty_archive_pclzip', __( 'Empty archive.' ) ); |
|
| 751 | + if (0 == count($archive_files)) |
|
| 752 | + return new WP_Error('empty_archive_pclzip', __('Empty archive.')); |
|
| 753 | 753 | |
| 754 | 754 | $uncompressed_size = 0; |
| 755 | 755 | |
| 756 | 756 | // Determine any children directories needed (From within the archive) |
| 757 | - foreach ( $archive_files as $file ) { |
|
| 758 | - if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Skip the OS X-created __MACOSX directory |
|
| 757 | + foreach ($archive_files as $file) { |
|
| 758 | + if ('__MACOSX/' === substr($file['filename'], 0, 9)) // Skip the OS X-created __MACOSX directory |
|
| 759 | 759 | continue; |
| 760 | 760 | |
| 761 | 761 | $uncompressed_size += $file['size']; |
| 762 | 762 | |
| 763 | - $needed_dirs[] = $to . untrailingslashit( $file['folder'] ? $file['filename'] : dirname($file['filename']) ); |
|
| 763 | + $needed_dirs[] = $to.untrailingslashit($file['folder'] ? $file['filename'] : dirname($file['filename'])); |
|
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | /* |
@@ -768,22 +768,22 @@ discard block |
||
| 768 | 768 | * A disk that has zero free bytes has bigger problems. |
| 769 | 769 | * Require we have enough space to unzip the file and copy its contents, with a 10% buffer. |
| 770 | 770 | */ |
| 771 | - if ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
|
| 772 | - $available_space = @disk_free_space( WP_CONTENT_DIR ); |
|
| 773 | - if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) |
|
| 774 | - return new WP_Error( 'disk_full_unzip_file', __( 'Could not copy files. You may have run out of disk space.' ), compact( 'uncompressed_size', 'available_space' ) ); |
|
| 771 | + if (defined('DOING_CRON') && DOING_CRON) { |
|
| 772 | + $available_space = @disk_free_space(WP_CONTENT_DIR); |
|
| 773 | + if ($available_space && ($uncompressed_size * 2.1) > $available_space) |
|
| 774 | + return new WP_Error('disk_full_unzip_file', __('Could not copy files. You may have run out of disk space.'), compact('uncompressed_size', 'available_space')); |
|
| 775 | 775 | } |
| 776 | 776 | |
| 777 | 777 | $needed_dirs = array_unique($needed_dirs); |
| 778 | - foreach ( $needed_dirs as $dir ) { |
|
| 778 | + foreach ($needed_dirs as $dir) { |
|
| 779 | 779 | // Check the parent folders of the folders all exist within the creation array. |
| 780 | - if ( untrailingslashit($to) == $dir ) // Skip over the working directory, We know this exists (or will exist) |
|
| 780 | + if (untrailingslashit($to) == $dir) // Skip over the working directory, We know this exists (or will exist) |
|
| 781 | 781 | continue; |
| 782 | - if ( strpos($dir, $to) === false ) // If the directory is not within the working directory, Skip it |
|
| 782 | + if (strpos($dir, $to) === false) // If the directory is not within the working directory, Skip it |
|
| 783 | 783 | continue; |
| 784 | 784 | |
| 785 | 785 | $parent_folder = dirname($dir); |
| 786 | - while ( !empty($parent_folder) && untrailingslashit($to) != $parent_folder && !in_array($parent_folder, $needed_dirs) ) { |
|
| 786 | + while ( ! empty($parent_folder) && untrailingslashit($to) != $parent_folder && ! in_array($parent_folder, $needed_dirs)) { |
|
| 787 | 787 | $needed_dirs[] = $parent_folder; |
| 788 | 788 | $parent_folder = dirname($parent_folder); |
| 789 | 789 | } |
@@ -791,23 +791,23 @@ discard block |
||
| 791 | 791 | asort($needed_dirs); |
| 792 | 792 | |
| 793 | 793 | // Create those directories if need be: |
| 794 | - foreach ( $needed_dirs as $_dir ) { |
|
| 794 | + foreach ($needed_dirs as $_dir) { |
|
| 795 | 795 | // Only check to see if the dir exists upon creation failure. Less I/O this way. |
| 796 | - if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) |
|
| 797 | - return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) ); |
|
| 796 | + if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir)) |
|
| 797 | + return new WP_Error('mkdir_failed_pclzip', __('Could not create directory.'), substr($_dir, strlen($to))); |
|
| 798 | 798 | } |
| 799 | 799 | unset($needed_dirs); |
| 800 | 800 | |
| 801 | 801 | // Extract the files from the zip |
| 802 | - foreach ( $archive_files as $file ) { |
|
| 803 | - if ( $file['folder'] ) |
|
| 802 | + foreach ($archive_files as $file) { |
|
| 803 | + if ($file['folder']) |
|
| 804 | 804 | continue; |
| 805 | 805 | |
| 806 | - if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files |
|
| 806 | + if ('__MACOSX/' === substr($file['filename'], 0, 9)) // Don't extract the OS X-created __MACOSX directory files |
|
| 807 | 807 | continue; |
| 808 | 808 | |
| 809 | - if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) ) |
|
| 810 | - return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] ); |
|
| 809 | + if ( ! $wp_filesystem->put_contents($to.$file['filename'], $file['content'], FS_CHMOD_FILE)) |
|
| 810 | + return new WP_Error('copy_failed_pclzip', __('Could not copy file.'), $file['filename']); |
|
| 811 | 811 | } |
| 812 | 812 | return true; |
| 813 | 813 | } |
@@ -825,7 +825,7 @@ discard block |
||
| 825 | 825 | * @param array $skip_list a list of files/folders to skip copying |
| 826 | 826 | * @return mixed WP_Error on failure, True on success. |
| 827 | 827 | */ |
| 828 | -function copy_dir($from, $to, $skip_list = array() ) { |
|
| 828 | +function copy_dir($from, $to, $skip_list = array()) { |
|
| 829 | 829 | global $wp_filesystem; |
| 830 | 830 | |
| 831 | 831 | $dirlist = $wp_filesystem->dirlist($from); |
@@ -833,32 +833,32 @@ discard block |
||
| 833 | 833 | $from = trailingslashit($from); |
| 834 | 834 | $to = trailingslashit($to); |
| 835 | 835 | |
| 836 | - foreach ( (array) $dirlist as $filename => $fileinfo ) { |
|
| 837 | - if ( in_array( $filename, $skip_list ) ) |
|
| 836 | + foreach ((array) $dirlist as $filename => $fileinfo) { |
|
| 837 | + if (in_array($filename, $skip_list)) |
|
| 838 | 838 | continue; |
| 839 | 839 | |
| 840 | - if ( 'f' == $fileinfo['type'] ) { |
|
| 841 | - if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) { |
|
| 840 | + if ('f' == $fileinfo['type']) { |
|
| 841 | + if ( ! $wp_filesystem->copy($from.$filename, $to.$filename, true, FS_CHMOD_FILE)) { |
|
| 842 | 842 | // If copy failed, chmod file to 0644 and try again. |
| 843 | - $wp_filesystem->chmod( $to . $filename, FS_CHMOD_FILE ); |
|
| 844 | - if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) |
|
| 845 | - return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename ); |
|
| 843 | + $wp_filesystem->chmod($to.$filename, FS_CHMOD_FILE); |
|
| 844 | + if ( ! $wp_filesystem->copy($from.$filename, $to.$filename, true, FS_CHMOD_FILE)) |
|
| 845 | + return new WP_Error('copy_failed_copy_dir', __('Could not copy file.'), $to.$filename); |
|
| 846 | 846 | } |
| 847 | - } elseif ( 'd' == $fileinfo['type'] ) { |
|
| 848 | - if ( !$wp_filesystem->is_dir($to . $filename) ) { |
|
| 849 | - if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) ) |
|
| 850 | - return new WP_Error( 'mkdir_failed_copy_dir', __( 'Could not create directory.' ), $to . $filename ); |
|
| 847 | + } elseif ('d' == $fileinfo['type']) { |
|
| 848 | + if ( ! $wp_filesystem->is_dir($to.$filename)) { |
|
| 849 | + if ( ! $wp_filesystem->mkdir($to.$filename, FS_CHMOD_DIR)) |
|
| 850 | + return new WP_Error('mkdir_failed_copy_dir', __('Could not create directory.'), $to.$filename); |
|
| 851 | 851 | } |
| 852 | 852 | |
| 853 | 853 | // generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list |
| 854 | 854 | $sub_skip_list = array(); |
| 855 | - foreach ( $skip_list as $skip_item ) { |
|
| 856 | - if ( 0 === strpos( $skip_item, $filename . '/' ) ) |
|
| 857 | - $sub_skip_list[] = preg_replace( '!^' . preg_quote( $filename, '!' ) . '/!i', '', $skip_item ); |
|
| 855 | + foreach ($skip_list as $skip_item) { |
|
| 856 | + if (0 === strpos($skip_item, $filename.'/')) |
|
| 857 | + $sub_skip_list[] = preg_replace('!^'.preg_quote($filename, '!').'/!i', '', $skip_item); |
|
| 858 | 858 | } |
| 859 | 859 | |
| 860 | - $result = copy_dir($from . $filename, $to . $filename, $sub_skip_list); |
|
| 861 | - if ( is_wp_error($result) ) |
|
| 860 | + $result = copy_dir($from.$filename, $to.$filename, $sub_skip_list); |
|
| 861 | + if (is_wp_error($result)) |
|
| 862 | 862 | return $result; |
| 863 | 863 | } |
| 864 | 864 | } |
@@ -882,17 +882,17 @@ discard block |
||
| 882 | 882 | * @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false. |
| 883 | 883 | * @return null|bool false on failure, true on success. |
| 884 | 884 | */ |
| 885 | -function WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_ownership = false ) { |
|
| 885 | +function WP_Filesystem($args = false, $context = false, $allow_relaxed_file_ownership = false) { |
|
| 886 | 886 | global $wp_filesystem; |
| 887 | 887 | |
| 888 | - require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'); |
|
| 888 | + require_once(ABSPATH.'wp-admin/includes/class-wp-filesystem-base.php'); |
|
| 889 | 889 | |
| 890 | - $method = get_filesystem_method( $args, $context, $allow_relaxed_file_ownership ); |
|
| 890 | + $method = get_filesystem_method($args, $context, $allow_relaxed_file_ownership); |
|
| 891 | 891 | |
| 892 | - if ( ! $method ) |
|
| 892 | + if ( ! $method) |
|
| 893 | 893 | return false; |
| 894 | 894 | |
| 895 | - if ( ! class_exists( "WP_Filesystem_$method" ) ) { |
|
| 895 | + if ( ! class_exists("WP_Filesystem_$method")) { |
|
| 896 | 896 | |
| 897 | 897 | /** |
| 898 | 898 | * Filters the path for a specific filesystem method class file. |
@@ -904,9 +904,9 @@ discard block |
||
| 904 | 904 | * @param string $path Path to the specific filesystem method class file. |
| 905 | 905 | * @param string $method The filesystem method to use. |
| 906 | 906 | */ |
| 907 | - $abstraction_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method ); |
|
| 907 | + $abstraction_file = apply_filters('filesystem_method_file', ABSPATH.'wp-admin/includes/class-wp-filesystem-'.$method.'.php', $method); |
|
| 908 | 908 | |
| 909 | - if ( ! file_exists($abstraction_file) ) |
|
| 909 | + if ( ! file_exists($abstraction_file)) |
|
| 910 | 910 | return; |
| 911 | 911 | |
| 912 | 912 | require_once($abstraction_file); |
@@ -916,22 +916,22 @@ discard block |
||
| 916 | 916 | $wp_filesystem = new $method($args); |
| 917 | 917 | |
| 918 | 918 | //Define the timeouts for the connections. Only available after the construct is called to allow for per-transport overriding of the default. |
| 919 | - if ( ! defined('FS_CONNECT_TIMEOUT') ) |
|
| 919 | + if ( ! defined('FS_CONNECT_TIMEOUT')) |
|
| 920 | 920 | define('FS_CONNECT_TIMEOUT', 30); |
| 921 | - if ( ! defined('FS_TIMEOUT') ) |
|
| 921 | + if ( ! defined('FS_TIMEOUT')) |
|
| 922 | 922 | define('FS_TIMEOUT', 30); |
| 923 | 923 | |
| 924 | - if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) |
|
| 924 | + if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) |
|
| 925 | 925 | return false; |
| 926 | 926 | |
| 927 | - if ( !$wp_filesystem->connect() ) |
|
| 927 | + if ( ! $wp_filesystem->connect()) |
|
| 928 | 928 | return false; //There was an error connecting to the server. |
| 929 | 929 | |
| 930 | 930 | // Set the permission constants if not already set. |
| 931 | - if ( ! defined('FS_CHMOD_DIR') ) |
|
| 932 | - define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) ); |
|
| 933 | - if ( ! defined('FS_CHMOD_FILE') ) |
|
| 934 | - define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) ); |
|
| 931 | + if ( ! defined('FS_CHMOD_DIR')) |
|
| 932 | + define('FS_CHMOD_DIR', (fileperms(ABSPATH) & 0777 | 0755)); |
|
| 933 | + if ( ! defined('FS_CHMOD_FILE')) |
|
| 934 | + define('FS_CHMOD_FILE', (fileperms(ABSPATH.'index.php') & 0777 | 0644)); |
|
| 935 | 935 | |
| 936 | 936 | return true; |
| 937 | 937 | } |
@@ -962,39 +962,39 @@ discard block |
||
| 962 | 962 | * Default false. |
| 963 | 963 | * @return string The transport to use, see description for valid return values. |
| 964 | 964 | */ |
| 965 | -function get_filesystem_method( $args = array(), $context = '', $allow_relaxed_file_ownership = false ) { |
|
| 965 | +function get_filesystem_method($args = array(), $context = '', $allow_relaxed_file_ownership = false) { |
|
| 966 | 966 | $method = defined('FS_METHOD') ? FS_METHOD : false; // Please ensure that this is either 'direct', 'ssh2', 'ftpext' or 'ftpsockets' |
| 967 | 967 | |
| 968 | - if ( ! $context ) { |
|
| 968 | + if ( ! $context) { |
|
| 969 | 969 | $context = WP_CONTENT_DIR; |
| 970 | 970 | } |
| 971 | 971 | |
| 972 | 972 | // If the directory doesn't exist (wp-content/languages) then use the parent directory as we'll create it. |
| 973 | - if ( WP_LANG_DIR == $context && ! is_dir( $context ) ) { |
|
| 974 | - $context = dirname( $context ); |
|
| 973 | + if (WP_LANG_DIR == $context && ! is_dir($context)) { |
|
| 974 | + $context = dirname($context); |
|
| 975 | 975 | } |
| 976 | 976 | |
| 977 | - $context = trailingslashit( $context ); |
|
| 977 | + $context = trailingslashit($context); |
|
| 978 | 978 | |
| 979 | - if ( ! $method ) { |
|
| 979 | + if ( ! $method) { |
|
| 980 | 980 | |
| 981 | - $temp_file_name = $context . 'temp-write-test-' . time(); |
|
| 981 | + $temp_file_name = $context.'temp-write-test-'.time(); |
|
| 982 | 982 | $temp_handle = @fopen($temp_file_name, 'w'); |
| 983 | - if ( $temp_handle ) { |
|
| 983 | + if ($temp_handle) { |
|
| 984 | 984 | |
| 985 | 985 | // Attempt to determine the file owner of the WordPress files, and that of newly created files |
| 986 | 986 | $wp_file_owner = $temp_file_owner = false; |
| 987 | - if ( function_exists('fileowner') ) { |
|
| 988 | - $wp_file_owner = @fileowner( __FILE__ ); |
|
| 989 | - $temp_file_owner = @fileowner( $temp_file_name ); |
|
| 987 | + if (function_exists('fileowner')) { |
|
| 988 | + $wp_file_owner = @fileowner(__FILE__); |
|
| 989 | + $temp_file_owner = @fileowner($temp_file_name); |
|
| 990 | 990 | } |
| 991 | 991 | |
| 992 | - if ( $wp_file_owner !== false && $wp_file_owner === $temp_file_owner ) { |
|
| 992 | + if ($wp_file_owner !== false && $wp_file_owner === $temp_file_owner) { |
|
| 993 | 993 | // WordPress is creating files as the same owner as the WordPress files, |
| 994 | 994 | // this means it's safe to modify & create new files via PHP. |
| 995 | 995 | $method = 'direct'; |
| 996 | 996 | $GLOBALS['_wp_filesystem_direct_method'] = 'file_owner'; |
| 997 | - } elseif ( $allow_relaxed_file_ownership ) { |
|
| 997 | + } elseif ($allow_relaxed_file_ownership) { |
|
| 998 | 998 | // The $context directory is writable, and $allow_relaxed_file_ownership is set, this means we can modify files |
| 999 | 999 | // safely in this directory. This mode doesn't create new files, only alter existing ones. |
| 1000 | 1000 | $method = 'direct'; |
@@ -1006,9 +1006,9 @@ discard block |
||
| 1006 | 1006 | } |
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | - if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents') ) $method = 'ssh2'; |
|
| 1010 | - if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext'; |
|
| 1011 | - if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread |
|
| 1009 | + if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents')) $method = 'ssh2'; |
|
| 1010 | + if ( ! $method && extension_loaded('ftp')) $method = 'ftpext'; |
|
| 1011 | + if ( ! $method && (extension_loaded('sockets') || function_exists('fsockopen'))) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread |
|
| 1012 | 1012 | |
| 1013 | 1013 | /** |
| 1014 | 1014 | * Filters the filesystem method to use. |
@@ -1020,7 +1020,7 @@ discard block |
||
| 1020 | 1020 | * @param string $context Full path to the directory that is tested for being writable. |
| 1021 | 1021 | * @param bool $allow_relaxed_file_ownership Whether to allow Group/World writable. |
| 1022 | 1022 | */ |
| 1023 | - return apply_filters( 'filesystem_method', $method, $args, $context, $allow_relaxed_file_ownership ); |
|
| 1023 | + return apply_filters('filesystem_method', $method, $args, $context, $allow_relaxed_file_ownership); |
|
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | 1026 | /** |
@@ -1051,7 +1051,7 @@ discard block |
||
| 1051 | 1051 | * |
| 1052 | 1052 | * @return bool False on failure, true on success. |
| 1053 | 1053 | */ |
| 1054 | -function request_filesystem_credentials( $form_post, $type = '', $error = false, $context = '', $extra_fields = null, $allow_relaxed_file_ownership = false ) { |
|
| 1054 | +function request_filesystem_credentials($form_post, $type = '', $error = false, $context = '', $extra_fields = null, $allow_relaxed_file_ownership = false) { |
|
| 1055 | 1055 | global $pagenow; |
| 1056 | 1056 | |
| 1057 | 1057 | /** |
@@ -1074,87 +1074,87 @@ discard block |
||
| 1074 | 1074 | * Default false. |
| 1075 | 1075 | * @param array $extra_fields Extra POST fields. |
| 1076 | 1076 | */ |
| 1077 | - $req_cred = apply_filters( 'request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields, $allow_relaxed_file_ownership ); |
|
| 1078 | - if ( '' !== $req_cred ) |
|
| 1077 | + $req_cred = apply_filters('request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields, $allow_relaxed_file_ownership); |
|
| 1078 | + if ('' !== $req_cred) |
|
| 1079 | 1079 | return $req_cred; |
| 1080 | 1080 | |
| 1081 | - if ( empty($type) ) { |
|
| 1082 | - $type = get_filesystem_method( array(), $context, $allow_relaxed_file_ownership ); |
|
| 1081 | + if (empty($type)) { |
|
| 1082 | + $type = get_filesystem_method(array(), $context, $allow_relaxed_file_ownership); |
|
| 1083 | 1083 | } |
| 1084 | 1084 | |
| 1085 | - if ( 'direct' == $type ) |
|
| 1085 | + if ('direct' == $type) |
|
| 1086 | 1086 | return true; |
| 1087 | 1087 | |
| 1088 | - if ( is_null( $extra_fields ) ) |
|
| 1089 | - $extra_fields = array( 'version', 'locale' ); |
|
| 1088 | + if (is_null($extra_fields)) |
|
| 1089 | + $extra_fields = array('version', 'locale'); |
|
| 1090 | 1090 | |
| 1091 | - $credentials = get_option('ftp_credentials', array( 'hostname' => '', 'username' => '')); |
|
| 1091 | + $credentials = get_option('ftp_credentials', array('hostname' => '', 'username' => '')); |
|
| 1092 | 1092 | |
| 1093 | 1093 | // If defined, set it to that, Else, If POST'd, set it to that, If not, Set it to whatever it previously was(saved details in option) |
| 1094 | - $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : (!empty($_POST['hostname']) ? wp_unslash( $_POST['hostname'] ) : $credentials['hostname']); |
|
| 1095 | - $credentials['username'] = defined('FTP_USER') ? FTP_USER : (!empty($_POST['username']) ? wp_unslash( $_POST['username'] ) : $credentials['username']); |
|
| 1096 | - $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : (!empty($_POST['password']) ? wp_unslash( $_POST['password'] ) : ''); |
|
| 1094 | + $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : ( ! empty($_POST['hostname']) ? wp_unslash($_POST['hostname']) : $credentials['hostname']); |
|
| 1095 | + $credentials['username'] = defined('FTP_USER') ? FTP_USER : ( ! empty($_POST['username']) ? wp_unslash($_POST['username']) : $credentials['username']); |
|
| 1096 | + $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : ( ! empty($_POST['password']) ? wp_unslash($_POST['password']) : ''); |
|
| 1097 | 1097 | |
| 1098 | 1098 | // Check to see if we are setting the public/private keys for ssh |
| 1099 | - $credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : (!empty($_POST['public_key']) ? wp_unslash( $_POST['public_key'] ) : ''); |
|
| 1100 | - $credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : (!empty($_POST['private_key']) ? wp_unslash( $_POST['private_key'] ) : ''); |
|
| 1099 | + $credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : ( ! empty($_POST['public_key']) ? wp_unslash($_POST['public_key']) : ''); |
|
| 1100 | + $credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : ( ! empty($_POST['private_key']) ? wp_unslash($_POST['private_key']) : ''); |
|
| 1101 | 1101 | |
| 1102 | 1102 | // Sanitize the hostname, Some people might pass in odd-data: |
| 1103 | 1103 | $credentials['hostname'] = preg_replace('|\w+://|', '', $credentials['hostname']); //Strip any schemes off |
| 1104 | 1104 | |
| 1105 | - if ( strpos($credentials['hostname'], ':') ) { |
|
| 1106 | - list( $credentials['hostname'], $credentials['port'] ) = explode(':', $credentials['hostname'], 2); |
|
| 1107 | - if ( ! is_numeric($credentials['port']) ) |
|
| 1105 | + if (strpos($credentials['hostname'], ':')) { |
|
| 1106 | + list($credentials['hostname'], $credentials['port']) = explode(':', $credentials['hostname'], 2); |
|
| 1107 | + if ( ! is_numeric($credentials['port'])) |
|
| 1108 | 1108 | unset($credentials['port']); |
| 1109 | 1109 | } else { |
| 1110 | 1110 | unset($credentials['port']); |
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | - if ( ( defined( 'FTP_SSH' ) && FTP_SSH ) || ( defined( 'FS_METHOD' ) && 'ssh2' == FS_METHOD ) ) { |
|
| 1113 | + if ((defined('FTP_SSH') && FTP_SSH) || (defined('FS_METHOD') && 'ssh2' == FS_METHOD)) { |
|
| 1114 | 1114 | $credentials['connection_type'] = 'ssh'; |
| 1115 | - } elseif ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' == $type ) { //Only the FTP Extension understands SSL |
|
| 1115 | + } elseif ((defined('FTP_SSL') && FTP_SSL) && 'ftpext' == $type) { //Only the FTP Extension understands SSL |
|
| 1116 | 1116 | $credentials['connection_type'] = 'ftps'; |
| 1117 | - } elseif ( ! empty( $_POST['connection_type'] ) ) { |
|
| 1118 | - $credentials['connection_type'] = wp_unslash( $_POST['connection_type'] ); |
|
| 1119 | - } elseif ( ! isset( $credentials['connection_type'] ) ) { //All else fails (And it's not defaulted to something else saved), Default to FTP |
|
| 1117 | + } elseif ( ! empty($_POST['connection_type'])) { |
|
| 1118 | + $credentials['connection_type'] = wp_unslash($_POST['connection_type']); |
|
| 1119 | + } elseif ( ! isset($credentials['connection_type'])) { //All else fails (And it's not defaulted to something else saved), Default to FTP |
|
| 1120 | 1120 | $credentials['connection_type'] = 'ftp'; |
| 1121 | 1121 | } |
| 1122 | 1122 | if ( ! $error && |
| 1123 | 1123 | ( |
| 1124 | - ( !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) || |
|
| 1125 | - ( 'ssh' == $credentials['connection_type'] && !empty($credentials['public_key']) && !empty($credentials['private_key']) ) |
|
| 1126 | - ) ) { |
|
| 1124 | + ( ! empty($credentials['password']) && ! empty($credentials['username']) && ! empty($credentials['hostname'])) || |
|
| 1125 | + ('ssh' == $credentials['connection_type'] && ! empty($credentials['public_key']) && ! empty($credentials['private_key'])) |
|
| 1126 | + )) { |
|
| 1127 | 1127 | $stored_credentials = $credentials; |
| 1128 | - if ( !empty($stored_credentials['port']) ) //save port as part of hostname to simplify above code. |
|
| 1129 | - $stored_credentials['hostname'] .= ':' . $stored_credentials['port']; |
|
| 1128 | + if ( ! empty($stored_credentials['port'])) //save port as part of hostname to simplify above code. |
|
| 1129 | + $stored_credentials['hostname'] .= ':'.$stored_credentials['port']; |
|
| 1130 | 1130 | |
| 1131 | 1131 | unset($stored_credentials['password'], $stored_credentials['port'], $stored_credentials['private_key'], $stored_credentials['public_key']); |
| 1132 | - if ( ! wp_installing() ) { |
|
| 1133 | - update_option( 'ftp_credentials', $stored_credentials ); |
|
| 1132 | + if ( ! wp_installing()) { |
|
| 1133 | + update_option('ftp_credentials', $stored_credentials); |
|
| 1134 | 1134 | } |
| 1135 | 1135 | return $credentials; |
| 1136 | 1136 | } |
| 1137 | - $hostname = isset( $credentials['hostname'] ) ? $credentials['hostname'] : ''; |
|
| 1138 | - $username = isset( $credentials['username'] ) ? $credentials['username'] : ''; |
|
| 1139 | - $public_key = isset( $credentials['public_key'] ) ? $credentials['public_key'] : ''; |
|
| 1140 | - $private_key = isset( $credentials['private_key'] ) ? $credentials['private_key'] : ''; |
|
| 1141 | - $port = isset( $credentials['port'] ) ? $credentials['port'] : ''; |
|
| 1142 | - $connection_type = isset( $credentials['connection_type'] ) ? $credentials['connection_type'] : ''; |
|
| 1143 | - |
|
| 1144 | - if ( $error ) { |
|
| 1137 | + $hostname = isset($credentials['hostname']) ? $credentials['hostname'] : ''; |
|
| 1138 | + $username = isset($credentials['username']) ? $credentials['username'] : ''; |
|
| 1139 | + $public_key = isset($credentials['public_key']) ? $credentials['public_key'] : ''; |
|
| 1140 | + $private_key = isset($credentials['private_key']) ? $credentials['private_key'] : ''; |
|
| 1141 | + $port = isset($credentials['port']) ? $credentials['port'] : ''; |
|
| 1142 | + $connection_type = isset($credentials['connection_type']) ? $credentials['connection_type'] : ''; |
|
| 1143 | + |
|
| 1144 | + if ($error) { |
|
| 1145 | 1145 | $error_string = __('<strong>ERROR:</strong> There was an error connecting to the server, Please verify the settings are correct.'); |
| 1146 | - if ( is_wp_error($error) ) |
|
| 1147 | - $error_string = esc_html( $error->get_error_message() ); |
|
| 1148 | - echo '<div id="message" class="error"><p>' . $error_string . '</p></div>'; |
|
| 1146 | + if (is_wp_error($error)) |
|
| 1147 | + $error_string = esc_html($error->get_error_message()); |
|
| 1148 | + echo '<div id="message" class="error"><p>'.$error_string.'</p></div>'; |
|
| 1149 | 1149 | } |
| 1150 | 1150 | |
| 1151 | 1151 | $types = array(); |
| 1152 | - if ( extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen') ) |
|
| 1153 | - $types[ 'ftp' ] = __('FTP'); |
|
| 1154 | - if ( extension_loaded('ftp') ) //Only this supports FTPS |
|
| 1155 | - $types[ 'ftps' ] = __('FTPS (SSL)'); |
|
| 1156 | - if ( extension_loaded('ssh2') && function_exists('stream_get_contents') ) |
|
| 1157 | - $types[ 'ssh' ] = __('SSH2'); |
|
| 1152 | + if (extension_loaded('ftp') || extension_loaded('sockets') || function_exists('fsockopen')) |
|
| 1153 | + $types['ftp'] = __('FTP'); |
|
| 1154 | + if (extension_loaded('ftp')) //Only this supports FTPS |
|
| 1155 | + $types['ftps'] = __('FTPS (SSL)'); |
|
| 1156 | + if (extension_loaded('ssh2') && function_exists('stream_get_contents')) |
|
| 1157 | + $types['ssh'] = __('SSH2'); |
|
| 1158 | 1158 | |
| 1159 | 1159 | /** |
| 1160 | 1160 | * Filters the connection types to output to the filesystem credentials form. |
@@ -1169,26 +1169,26 @@ discard block |
||
| 1169 | 1169 | * @param string $context Full path to the directory that is tested |
| 1170 | 1170 | * for being writable. |
| 1171 | 1171 | */ |
| 1172 | - $types = apply_filters( 'fs_ftp_connection_types', $types, $credentials, $type, $error, $context ); |
|
| 1172 | + $types = apply_filters('fs_ftp_connection_types', $types, $credentials, $type, $error, $context); |
|
| 1173 | 1173 | |
| 1174 | 1174 | ?> |
| 1175 | -<form action="<?php echo esc_url( $form_post ) ?>" method="post"> |
|
| 1175 | +<form action="<?php echo esc_url($form_post) ?>" method="post"> |
|
| 1176 | 1176 | <div id="request-filesystem-credentials-form" class="request-filesystem-credentials-form"> |
| 1177 | 1177 | <?php |
| 1178 | 1178 | // Print a H1 heading in the FTP credentials modal dialog, default is a H2. |
| 1179 | 1179 | $heading_tag = 'h2'; |
| 1180 | -if ( 'plugins.php' === $pagenow || 'plugin-install.php' === $pagenow ) { |
|
| 1180 | +if ('plugins.php' === $pagenow || 'plugin-install.php' === $pagenow) { |
|
| 1181 | 1181 | $heading_tag = 'h1'; |
| 1182 | 1182 | } |
| 1183 | -echo "<$heading_tag id='request-filesystem-credentials-title'>" . __( 'Connection Information' ) . "</$heading_tag>"; |
|
| 1183 | +echo "<$heading_tag id='request-filesystem-credentials-title'>".__('Connection Information')."</$heading_tag>"; |
|
| 1184 | 1184 | ?> |
| 1185 | 1185 | <p id="request-filesystem-credentials-desc"><?php |
| 1186 | 1186 | $label_user = __('Username'); |
| 1187 | 1187 | $label_pass = __('Password'); |
| 1188 | 1188 | _e('To perform the requested action, WordPress needs to access your web server.'); |
| 1189 | 1189 | echo ' '; |
| 1190 | - if ( ( isset( $types['ftp'] ) || isset( $types['ftps'] ) ) ) { |
|
| 1191 | - if ( isset( $types['ssh'] ) ) { |
|
| 1190 | + if ((isset($types['ftp']) || isset($types['ftps']))) { |
|
| 1191 | + if (isset($types['ssh'])) { |
|
| 1192 | 1192 | _e('Please enter your FTP or SSH credentials to proceed.'); |
| 1193 | 1193 | $label_user = __('FTP/SSH Username'); |
| 1194 | 1194 | $label_pass = __('FTP/SSH Password'); |
@@ -1202,29 +1202,29 @@ discard block |
||
| 1202 | 1202 | _e('If you do not remember your credentials, you should contact your web host.'); |
| 1203 | 1203 | ?></p> |
| 1204 | 1204 | <label for="hostname"> |
| 1205 | - <span class="field-title"><?php _e( 'Hostname' ) ?></span> |
|
| 1206 | - <input name="hostname" type="text" id="hostname" aria-describedby="request-filesystem-credentials-desc" class="code" placeholder="<?php esc_attr_e( 'example: www.wordpress.org' ) ?>" value="<?php echo esc_attr($hostname); if ( !empty($port) ) echo ":$port"; ?>"<?php disabled( defined('FTP_HOST') ); ?> /> |
|
| 1205 | + <span class="field-title"><?php _e('Hostname') ?></span> |
|
| 1206 | + <input name="hostname" type="text" id="hostname" aria-describedby="request-filesystem-credentials-desc" class="code" placeholder="<?php esc_attr_e('example: www.wordpress.org') ?>" value="<?php echo esc_attr($hostname); if ( ! empty($port)) echo ":$port"; ?>"<?php disabled(defined('FTP_HOST')); ?> /> |
|
| 1207 | 1207 | </label> |
| 1208 | 1208 | <div class="ftp-username"> |
| 1209 | 1209 | <label for="username"> |
| 1210 | 1210 | <span class="field-title"><?php echo $label_user; ?></span> |
| 1211 | - <input name="username" type="text" id="username" value="<?php echo esc_attr($username) ?>"<?php disabled( defined('FTP_USER') ); ?> /> |
|
| 1211 | + <input name="username" type="text" id="username" value="<?php echo esc_attr($username) ?>"<?php disabled(defined('FTP_USER')); ?> /> |
|
| 1212 | 1212 | </label> |
| 1213 | 1213 | </div> |
| 1214 | 1214 | <div class="ftp-password"> |
| 1215 | 1215 | <label for="password"> |
| 1216 | 1216 | <span class="field-title"><?php echo $label_pass; ?></span> |
| 1217 | - <input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) echo '*****'; ?>"<?php disabled( defined('FTP_PASS') ); ?> /> |
|
| 1218 | - <em><?php if ( ! defined('FTP_PASS') ) _e( 'This password will not be stored on the server.' ); ?></em> |
|
| 1217 | + <input name="password" type="password" id="password" value="<?php if (defined('FTP_PASS')) echo '*****'; ?>"<?php disabled(defined('FTP_PASS')); ?> /> |
|
| 1218 | + <em><?php if ( ! defined('FTP_PASS')) _e('This password will not be stored on the server.'); ?></em> |
|
| 1219 | 1219 | </label> |
| 1220 | 1220 | </div> |
| 1221 | 1221 | <fieldset> |
| 1222 | -<legend><?php _e( 'Connection Type' ); ?></legend> |
|
| 1222 | +<legend><?php _e('Connection Type'); ?></legend> |
|
| 1223 | 1223 | <?php |
| 1224 | - $disabled = disabled( ( defined( 'FTP_SSL' ) && FTP_SSL ) || ( defined( 'FTP_SSH' ) && FTP_SSH ), true, false ); |
|
| 1225 | - foreach ( $types as $name => $text ) : ?> |
|
| 1226 | - <label for="<?php echo esc_attr( $name ) ?>"> |
|
| 1227 | - <input type="radio" name="connection_type" id="<?php echo esc_attr( $name ) ?>" value="<?php echo esc_attr( $name ) ?>"<?php checked( $name, $connection_type ); echo $disabled; ?> /> |
|
| 1224 | + $disabled = disabled((defined('FTP_SSL') && FTP_SSL) || (defined('FTP_SSH') && FTP_SSH), true, false); |
|
| 1225 | + foreach ($types as $name => $text) : ?> |
|
| 1226 | + <label for="<?php echo esc_attr($name) ?>"> |
|
| 1227 | + <input type="radio" name="connection_type" id="<?php echo esc_attr($name) ?>" value="<?php echo esc_attr($name) ?>"<?php checked($name, $connection_type); echo $disabled; ?> /> |
|
| 1228 | 1228 | <?php echo $text; ?> |
| 1229 | 1229 | </label> |
| 1230 | 1230 | <?php |
@@ -1232,35 +1232,35 @@ discard block |
||
| 1232 | 1232 | ?> |
| 1233 | 1233 | </fieldset> |
| 1234 | 1234 | <?php |
| 1235 | -if ( isset( $types['ssh'] ) ) { |
|
| 1235 | +if (isset($types['ssh'])) { |
|
| 1236 | 1236 | $hidden_class = ''; |
| 1237 | - if ( 'ssh' != $connection_type || empty( $connection_type ) ) { |
|
| 1237 | + if ('ssh' != $connection_type || empty($connection_type)) { |
|
| 1238 | 1238 | $hidden_class = ' class="hidden"'; |
| 1239 | 1239 | } |
| 1240 | 1240 | ?> |
| 1241 | 1241 | <fieldset id="ssh-keys"<?php echo $hidden_class; ?>"> |
| 1242 | -<legend><?php _e( 'Authentication Keys' ); ?></legend> |
|
| 1242 | +<legend><?php _e('Authentication Keys'); ?></legend> |
|
| 1243 | 1243 | <label for="public_key"> |
| 1244 | 1244 | <span class="field-title"><?php _e('Public Key:') ?></span> |
| 1245 | - <input name="public_key" type="text" id="public_key" aria-describedby="auth-keys-desc" value="<?php echo esc_attr($public_key) ?>"<?php disabled( defined('FTP_PUBKEY') ); ?> /> |
|
| 1245 | + <input name="public_key" type="text" id="public_key" aria-describedby="auth-keys-desc" value="<?php echo esc_attr($public_key) ?>"<?php disabled(defined('FTP_PUBKEY')); ?> /> |
|
| 1246 | 1246 | </label> |
| 1247 | 1247 | <label for="private_key"> |
| 1248 | 1248 | <span class="field-title"><?php _e('Private Key:') ?></span> |
| 1249 | - <input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php disabled( defined('FTP_PRIKEY') ); ?> /> |
|
| 1249 | + <input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php disabled(defined('FTP_PRIKEY')); ?> /> |
|
| 1250 | 1250 | </label> |
| 1251 | -<p id="auth-keys-desc"><?php _e( 'Enter the location on the server where the public and private keys are located. If a passphrase is needed, enter that in the password field above.' ) ?></p> |
|
| 1251 | +<p id="auth-keys-desc"><?php _e('Enter the location on the server where the public and private keys are located. If a passphrase is needed, enter that in the password field above.') ?></p> |
|
| 1252 | 1252 | </fieldset> |
| 1253 | 1253 | <?php |
| 1254 | 1254 | } |
| 1255 | 1255 | |
| 1256 | -foreach ( (array) $extra_fields as $field ) { |
|
| 1257 | - if ( isset( $_POST[ $field ] ) ) |
|
| 1258 | - echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( wp_unslash( $_POST[ $field ] ) ) . '" />'; |
|
| 1256 | +foreach ((array) $extra_fields as $field) { |
|
| 1257 | + if (isset($_POST[$field])) |
|
| 1258 | + echo '<input type="hidden" name="'.esc_attr($field).'" value="'.esc_attr(wp_unslash($_POST[$field])).'" />'; |
|
| 1259 | 1259 | } |
| 1260 | 1260 | ?> |
| 1261 | 1261 | <p class="request-filesystem-credentials-action-buttons"> |
| 1262 | - <button class="button cancel-button" data-js-action="close" type="button"><?php _e( 'Cancel' ); ?></button> |
|
| 1263 | - <?php submit_button( __( 'Proceed' ), 'button', 'upgrade', false ); ?> |
|
| 1262 | + <button class="button cancel-button" data-js-action="close" type="button"><?php _e('Cancel'); ?></button> |
|
| 1263 | + <?php submit_button(__('Proceed'), 'button', 'upgrade', false); ?> |
|
| 1264 | 1264 | </p> |
| 1265 | 1265 | </div> |
| 1266 | 1266 | </form> |
@@ -1276,10 +1276,10 @@ discard block |
||
| 1276 | 1276 | function wp_print_request_filesystem_credentials_modal() { |
| 1277 | 1277 | $filesystem_method = get_filesystem_method(); |
| 1278 | 1278 | ob_start(); |
| 1279 | - $filesystem_credentials_are_stored = request_filesystem_credentials( self_admin_url() ); |
|
| 1279 | + $filesystem_credentials_are_stored = request_filesystem_credentials(self_admin_url()); |
|
| 1280 | 1280 | ob_end_clean(); |
| 1281 | - $request_filesystem_credentials = ( $filesystem_method != 'direct' && ! $filesystem_credentials_are_stored ); |
|
| 1282 | - if ( ! $request_filesystem_credentials ) { |
|
| 1281 | + $request_filesystem_credentials = ($filesystem_method != 'direct' && ! $filesystem_credentials_are_stored); |
|
| 1282 | + if ( ! $request_filesystem_credentials) { |
|
| 1283 | 1283 | return; |
| 1284 | 1284 | } |
| 1285 | 1285 | ?> |
@@ -1287,7 +1287,7 @@ discard block |
||
| 1287 | 1287 | <div class="notification-dialog-background"></div> |
| 1288 | 1288 | <div class="notification-dialog" role="dialog" aria-labelledby="request-filesystem-credentials-title" tabindex="0"> |
| 1289 | 1289 | <div class="request-filesystem-credentials-dialog-content"> |
| 1290 | - <?php request_filesystem_credentials( site_url() ); ?> |
|
| 1290 | + <?php request_filesystem_credentials(site_url()); ?> |
|
| 1291 | 1291 | </div> |
| 1292 | 1292 | </div> |
| 1293 | 1293 | </div> |
@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | function get_preferred_from_update_core() { |
| 15 | 15 | $updates = get_core_updates(); |
| 16 | - if ( ! is_array( $updates ) ) |
|
| 16 | + if ( ! is_array($updates)) |
|
| 17 | 17 | return false; |
| 18 | - if ( empty( $updates ) ) |
|
| 19 | - return (object) array( 'response' => 'latest' ); |
|
| 18 | + if (empty($updates)) |
|
| 19 | + return (object) array('response' => 'latest'); |
|
| 20 | 20 | return $updates[0]; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -27,31 +27,31 @@ discard block |
||
| 27 | 27 | * set $options['available'] to false to skip not-dismissed updates. |
| 28 | 28 | * @return array|false Array of the update objects on success, false on failure. |
| 29 | 29 | */ |
| 30 | -function get_core_updates( $options = array() ) { |
|
| 31 | - $options = array_merge( array( 'available' => true, 'dismissed' => false ), $options ); |
|
| 32 | - $dismissed = get_site_option( 'dismissed_update_core' ); |
|
| 30 | +function get_core_updates($options = array()) { |
|
| 31 | + $options = array_merge(array('available' => true, 'dismissed' => false), $options); |
|
| 32 | + $dismissed = get_site_option('dismissed_update_core'); |
|
| 33 | 33 | |
| 34 | - if ( ! is_array( $dismissed ) ) |
|
| 34 | + if ( ! is_array($dismissed)) |
|
| 35 | 35 | $dismissed = array(); |
| 36 | 36 | |
| 37 | - $from_api = get_site_transient( 'update_core' ); |
|
| 37 | + $from_api = get_site_transient('update_core'); |
|
| 38 | 38 | |
| 39 | - if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) |
|
| 39 | + if ( ! isset($from_api->updates) || ! is_array($from_api->updates)) |
|
| 40 | 40 | return false; |
| 41 | 41 | |
| 42 | 42 | $updates = $from_api->updates; |
| 43 | 43 | $result = array(); |
| 44 | - foreach ( $updates as $update ) { |
|
| 45 | - if ( $update->response == 'autoupdate' ) |
|
| 44 | + foreach ($updates as $update) { |
|
| 45 | + if ($update->response == 'autoupdate') |
|
| 46 | 46 | continue; |
| 47 | 47 | |
| 48 | - if ( array_key_exists( $update->current . '|' . $update->locale, $dismissed ) ) { |
|
| 49 | - if ( $options['dismissed'] ) { |
|
| 48 | + if (array_key_exists($update->current.'|'.$update->locale, $dismissed)) { |
|
| 49 | + if ($options['dismissed']) { |
|
| 50 | 50 | $update->dismissed = true; |
| 51 | 51 | $result[] = $update; |
| 52 | 52 | } |
| 53 | 53 | } else { |
| 54 | - if ( $options['available'] ) { |
|
| 54 | + if ($options['available']) { |
|
| 55 | 55 | $update->dismissed = false; |
| 56 | 56 | $result[] = $update; |
| 57 | 57 | } |
@@ -70,22 +70,22 @@ discard block |
||
| 70 | 70 | * @return array|false False on failure, otherwise the core update offering. |
| 71 | 71 | */ |
| 72 | 72 | function find_core_auto_update() { |
| 73 | - $updates = get_site_transient( 'update_core' ); |
|
| 74 | - if ( ! $updates || empty( $updates->updates ) ) |
|
| 73 | + $updates = get_site_transient('update_core'); |
|
| 74 | + if ( ! $updates || empty($updates->updates)) |
|
| 75 | 75 | return false; |
| 76 | 76 | |
| 77 | - include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
|
| 77 | + include_once(ABSPATH.'wp-admin/includes/class-wp-upgrader.php'); |
|
| 78 | 78 | |
| 79 | 79 | $auto_update = false; |
| 80 | 80 | $upgrader = new WP_Automatic_Updater; |
| 81 | - foreach ( $updates->updates as $update ) { |
|
| 82 | - if ( 'autoupdate' != $update->response ) |
|
| 81 | + foreach ($updates->updates as $update) { |
|
| 82 | + if ('autoupdate' != $update->response) |
|
| 83 | 83 | continue; |
| 84 | 84 | |
| 85 | - if ( ! $upgrader->should_update( 'core', $update, ABSPATH ) ) |
|
| 85 | + if ( ! $upgrader->should_update('core', $update, ABSPATH)) |
|
| 86 | 86 | continue; |
| 87 | 87 | |
| 88 | - if ( ! $auto_update || version_compare( $update->current, $auto_update->current, '>' ) ) |
|
| 88 | + if ( ! $auto_update || version_compare($update->current, $auto_update->current, '>')) |
|
| 89 | 89 | $auto_update = $update; |
| 90 | 90 | } |
| 91 | 91 | return $auto_update; |
@@ -100,29 +100,29 @@ discard block |
||
| 100 | 100 | * @param string $locale Locale to query. |
| 101 | 101 | * @return bool|array False on failure. An array of checksums on success. |
| 102 | 102 | */ |
| 103 | -function get_core_checksums( $version, $locale ) { |
|
| 104 | - $url = $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), null, '&' ); |
|
| 103 | +function get_core_checksums($version, $locale) { |
|
| 104 | + $url = $http_url = 'http://api.wordpress.org/core/checksums/1.0/?'.http_build_query(compact('version', 'locale'), null, '&'); |
|
| 105 | 105 | |
| 106 | - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
|
| 107 | - $url = set_url_scheme( $url, 'https' ); |
|
| 106 | + if ($ssl = wp_http_supports(array('ssl'))) |
|
| 107 | + $url = set_url_scheme($url, 'https'); |
|
| 108 | 108 | |
| 109 | 109 | $options = array( |
| 110 | - 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ), |
|
| 110 | + 'timeout' => ((defined('DOING_CRON') && DOING_CRON) ? 30 : 3), |
|
| 111 | 111 | ); |
| 112 | 112 | |
| 113 | - $response = wp_remote_get( $url, $options ); |
|
| 114 | - if ( $ssl && is_wp_error( $response ) ) { |
|
| 115 | - trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE ); |
|
| 116 | - $response = wp_remote_get( $http_url, $options ); |
|
| 113 | + $response = wp_remote_get($url, $options); |
|
| 114 | + if ($ssl && is_wp_error($response)) { |
|
| 115 | + trigger_error(__('An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.').' '.__('(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)'), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE); |
|
| 116 | + $response = wp_remote_get($http_url, $options); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) |
|
| 119 | + if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) |
|
| 120 | 120 | return false; |
| 121 | 121 | |
| 122 | - $body = trim( wp_remote_retrieve_body( $response ) ); |
|
| 123 | - $body = json_decode( $body, true ); |
|
| 122 | + $body = trim(wp_remote_retrieve_body($response)); |
|
| 123 | + $body = json_decode($body, true); |
|
| 124 | 124 | |
| 125 | - if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) ) |
|
| 125 | + if ( ! is_array($body) || ! isset($body['checksums']) || ! is_array($body['checksums'])) |
|
| 126 | 126 | return false; |
| 127 | 127 | |
| 128 | 128 | return $body['checksums']; |
@@ -133,10 +133,10 @@ discard block |
||
| 133 | 133 | * @param object $update |
| 134 | 134 | * @return bool |
| 135 | 135 | */ |
| 136 | -function dismiss_core_update( $update ) { |
|
| 137 | - $dismissed = get_site_option( 'dismissed_update_core' ); |
|
| 138 | - $dismissed[ $update->current . '|' . $update->locale ] = true; |
|
| 139 | - return update_site_option( 'dismissed_update_core', $dismissed ); |
|
| 136 | +function dismiss_core_update($update) { |
|
| 137 | + $dismissed = get_site_option('dismissed_update_core'); |
|
| 138 | + $dismissed[$update->current.'|'.$update->locale] = true; |
|
| 139 | + return update_site_option('dismissed_update_core', $dismissed); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -145,15 +145,15 @@ discard block |
||
| 145 | 145 | * @param string $locale |
| 146 | 146 | * @return bool |
| 147 | 147 | */ |
| 148 | -function undismiss_core_update( $version, $locale ) { |
|
| 149 | - $dismissed = get_site_option( 'dismissed_update_core' ); |
|
| 150 | - $key = $version . '|' . $locale; |
|
| 148 | +function undismiss_core_update($version, $locale) { |
|
| 149 | + $dismissed = get_site_option('dismissed_update_core'); |
|
| 150 | + $key = $version.'|'.$locale; |
|
| 151 | 151 | |
| 152 | - if ( ! isset( $dismissed[$key] ) ) |
|
| 152 | + if ( ! isset($dismissed[$key])) |
|
| 153 | 153 | return false; |
| 154 | 154 | |
| 155 | - unset( $dismissed[$key] ); |
|
| 156 | - return update_site_option( 'dismissed_update_core', $dismissed ); |
|
| 155 | + unset($dismissed[$key]); |
|
| 156 | + return update_site_option('dismissed_update_core', $dismissed); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -162,15 +162,15 @@ discard block |
||
| 162 | 162 | * @param string $locale |
| 163 | 163 | * @return object|false |
| 164 | 164 | */ |
| 165 | -function find_core_update( $version, $locale ) { |
|
| 166 | - $from_api = get_site_transient( 'update_core' ); |
|
| 165 | +function find_core_update($version, $locale) { |
|
| 166 | + $from_api = get_site_transient('update_core'); |
|
| 167 | 167 | |
| 168 | - if ( ! isset( $from_api->updates ) || ! is_array( $from_api->updates ) ) |
|
| 168 | + if ( ! isset($from_api->updates) || ! is_array($from_api->updates)) |
|
| 169 | 169 | return false; |
| 170 | 170 | |
| 171 | 171 | $updates = $from_api->updates; |
| 172 | - foreach ( $updates as $update ) { |
|
| 173 | - if ( $update->current == $version && $update->locale == $locale ) |
|
| 172 | + foreach ($updates as $update) { |
|
| 173 | + if ($update->current == $version && $update->locale == $locale) |
|
| 174 | 174 | return $update; |
| 175 | 175 | } |
| 176 | 176 | return false; |
@@ -181,33 +181,33 @@ discard block |
||
| 181 | 181 | * @param string $msg |
| 182 | 182 | * @return string |
| 183 | 183 | */ |
| 184 | -function core_update_footer( $msg = '' ) { |
|
| 185 | - if ( !current_user_can('update_core') ) |
|
| 186 | - return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
|
| 184 | +function core_update_footer($msg = '') { |
|
| 185 | + if ( ! current_user_can('update_core')) |
|
| 186 | + return sprintf(__('Version %s'), get_bloginfo('version', 'display')); |
|
| 187 | 187 | |
| 188 | 188 | $cur = get_preferred_from_update_core(); |
| 189 | - if ( ! is_object( $cur ) ) |
|
| 189 | + if ( ! is_object($cur)) |
|
| 190 | 190 | $cur = new stdClass; |
| 191 | 191 | |
| 192 | - if ( ! isset( $cur->current ) ) |
|
| 192 | + if ( ! isset($cur->current)) |
|
| 193 | 193 | $cur->current = ''; |
| 194 | 194 | |
| 195 | - if ( ! isset( $cur->url ) ) |
|
| 195 | + if ( ! isset($cur->url)) |
|
| 196 | 196 | $cur->url = ''; |
| 197 | 197 | |
| 198 | - if ( ! isset( $cur->response ) ) |
|
| 198 | + if ( ! isset($cur->response)) |
|
| 199 | 199 | $cur->response = ''; |
| 200 | 200 | |
| 201 | - switch ( $cur->response ) { |
|
| 201 | + switch ($cur->response) { |
|
| 202 | 202 | case 'development' : |
| 203 | - return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) ); |
|
| 203 | + return sprintf(__('You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.'), get_bloginfo('version', 'display'), network_admin_url('update-core.php')); |
|
| 204 | 204 | |
| 205 | 205 | case 'upgrade' : |
| 206 | - return '<strong><a href="' . network_admin_url( 'update-core.php' ) . '">' . sprintf( __( 'Get Version %s' ), $cur->current ) . '</a></strong>'; |
|
| 206 | + return '<strong><a href="'.network_admin_url('update-core.php').'">'.sprintf(__('Get Version %s'), $cur->current).'</a></strong>'; |
|
| 207 | 207 | |
| 208 | 208 | case 'latest' : |
| 209 | 209 | default : |
| 210 | - return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
|
| 210 | + return sprintf(__('Version %s'), get_bloginfo('version', 'display')); |
|
| 211 | 211 | } |
| 212 | 212 | } |
| 213 | 213 | |
@@ -217,39 +217,39 @@ discard block |
||
| 217 | 217 | * @return false|void |
| 218 | 218 | */ |
| 219 | 219 | function update_nag() { |
| 220 | - if ( is_multisite() && !current_user_can('update_core') ) |
|
| 220 | + if (is_multisite() && ! current_user_can('update_core')) |
|
| 221 | 221 | return false; |
| 222 | 222 | |
| 223 | 223 | global $pagenow; |
| 224 | 224 | |
| 225 | - if ( 'update-core.php' == $pagenow ) |
|
| 225 | + if ('update-core.php' == $pagenow) |
|
| 226 | 226 | return; |
| 227 | 227 | |
| 228 | 228 | $cur = get_preferred_from_update_core(); |
| 229 | 229 | |
| 230 | - if ( ! isset( $cur->response ) || $cur->response != 'upgrade' ) |
|
| 230 | + if ( ! isset($cur->response) || $cur->response != 'upgrade') |
|
| 231 | 231 | return false; |
| 232 | 232 | |
| 233 | - if ( current_user_can( 'update_core' ) ) { |
|
| 233 | + if (current_user_can('update_core')) { |
|
| 234 | 234 | $msg = sprintf( |
| 235 | 235 | /* translators: 1: Codex URL to release notes, 2: new WordPress version, 3: URL to network admin, 4: accessibility text */ |
| 236 | - __( '<a href="%1$s">WordPress %2$s</a> is available! <a href="%3$s" aria-label="%4$s">Please update now</a>.' ), |
|
| 236 | + __('<a href="%1$s">WordPress %2$s</a> is available! <a href="%3$s" aria-label="%4$s">Please update now</a>.'), |
|
| 237 | 237 | sprintf( |
| 238 | 238 | /* translators: %s: WordPress version */ |
| 239 | - esc_url( __( 'https://codex.wordpress.org/Version_%s' ) ), |
|
| 239 | + esc_url(__('https://codex.wordpress.org/Version_%s')), |
|
| 240 | 240 | $cur->current |
| 241 | 241 | ), |
| 242 | 242 | $cur->current, |
| 243 | - network_admin_url( 'update-core.php' ), |
|
| 244 | - esc_attr__( 'Please update WordPress now' ) |
|
| 243 | + network_admin_url('update-core.php'), |
|
| 244 | + esc_attr__('Please update WordPress now') |
|
| 245 | 245 | ); |
| 246 | 246 | } else { |
| 247 | 247 | $msg = sprintf( |
| 248 | 248 | /* translators: 1: Codex URL to release notes, 2: new WordPress version */ |
| 249 | - __( '<a href="%1$s">WordPress %2$s</a> is available! Please notify the site administrator.' ), |
|
| 249 | + __('<a href="%1$s">WordPress %2$s</a> is available! Please notify the site administrator.'), |
|
| 250 | 250 | sprintf( |
| 251 | 251 | /* translators: %s: WordPress version */ |
| 252 | - esc_url( __( 'https://codex.wordpress.org/Version_%s' ) ), |
|
| 252 | + esc_url(__('https://codex.wordpress.org/Version_%s')), |
|
| 253 | 253 | $cur->current |
| 254 | 254 | ), |
| 255 | 255 | $cur->current |
@@ -261,21 +261,21 @@ discard block |
||
| 261 | 261 | // Called directly from dashboard |
| 262 | 262 | function update_right_now_message() { |
| 263 | 263 | $theme_name = wp_get_theme(); |
| 264 | - if ( current_user_can( 'switch_themes' ) ) { |
|
| 265 | - $theme_name = sprintf( '<a href="themes.php">%1$s</a>', $theme_name ); |
|
| 264 | + if (current_user_can('switch_themes')) { |
|
| 265 | + $theme_name = sprintf('<a href="themes.php">%1$s</a>', $theme_name); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | $msg = ''; |
| 269 | 269 | |
| 270 | - if ( current_user_can('update_core') ) { |
|
| 270 | + if (current_user_can('update_core')) { |
|
| 271 | 271 | $cur = get_preferred_from_update_core(); |
| 272 | 272 | |
| 273 | - if ( isset( $cur->response ) && $cur->response == 'upgrade' ) |
|
| 274 | - $msg .= '<a href="' . network_admin_url( 'update-core.php' ) . '" class="button" aria-describedby="wp-version">' . sprintf( __( 'Update to %s' ), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a> '; |
|
| 273 | + if (isset($cur->response) && $cur->response == 'upgrade') |
|
| 274 | + $msg .= '<a href="'.network_admin_url('update-core.php').'" class="button" aria-describedby="wp-version">'.sprintf(__('Update to %s'), $cur->current ? $cur->current : __('Latest')).'</a> '; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /* translators: 1: version number, 2: theme name */ |
| 278 | - $content = __( 'WordPress %1$s running %2$s theme.' ); |
|
| 278 | + $content = __('WordPress %1$s running %2$s theme.'); |
|
| 279 | 279 | |
| 280 | 280 | /** |
| 281 | 281 | * Filters the text displayed in the 'At a Glance' dashboard widget. |
@@ -286,9 +286,9 @@ discard block |
||
| 286 | 286 | * |
| 287 | 287 | * @param string $content Default text. |
| 288 | 288 | */ |
| 289 | - $content = apply_filters( 'update_right_now_text', $content ); |
|
| 289 | + $content = apply_filters('update_right_now_text', $content); |
|
| 290 | 290 | |
| 291 | - $msg .= sprintf( '<span id="wp-version">' . $content . '</span>', get_bloginfo( 'version', 'display' ), $theme_name ); |
|
| 291 | + $msg .= sprintf('<span id="wp-version">'.$content.'</span>', get_bloginfo('version', 'display'), $theme_name); |
|
| 292 | 292 | |
| 293 | 293 | echo "<p id='wp-version-message'>$msg</p>"; |
| 294 | 294 | } |
@@ -301,11 +301,11 @@ discard block |
||
| 301 | 301 | function get_plugin_updates() { |
| 302 | 302 | $all_plugins = get_plugins(); |
| 303 | 303 | $upgrade_plugins = array(); |
| 304 | - $current = get_site_transient( 'update_plugins' ); |
|
| 305 | - foreach ( (array)$all_plugins as $plugin_file => $plugin_data) { |
|
| 306 | - if ( isset( $current->response[ $plugin_file ] ) ) { |
|
| 307 | - $upgrade_plugins[ $plugin_file ] = (object) $plugin_data; |
|
| 308 | - $upgrade_plugins[ $plugin_file ]->update = $current->response[ $plugin_file ]; |
|
| 304 | + $current = get_site_transient('update_plugins'); |
|
| 305 | + foreach ((array) $all_plugins as $plugin_file => $plugin_data) { |
|
| 306 | + if (isset($current->response[$plugin_file])) { |
|
| 307 | + $upgrade_plugins[$plugin_file] = (object) $plugin_data; |
|
| 308 | + $upgrade_plugins[$plugin_file]->update = $current->response[$plugin_file]; |
|
| 309 | 309 | } |
| 310 | 310 | } |
| 311 | 311 | |
@@ -316,14 +316,14 @@ discard block |
||
| 316 | 316 | * @since 2.9.0 |
| 317 | 317 | */ |
| 318 | 318 | function wp_plugin_update_rows() { |
| 319 | - if ( !current_user_can('update_plugins' ) ) |
|
| 319 | + if ( ! current_user_can('update_plugins')) |
|
| 320 | 320 | return; |
| 321 | 321 | |
| 322 | - $plugins = get_site_transient( 'update_plugins' ); |
|
| 323 | - if ( isset($plugins->response) && is_array($plugins->response) ) { |
|
| 324 | - $plugins = array_keys( $plugins->response ); |
|
| 325 | - foreach ( $plugins as $plugin_file ) { |
|
| 326 | - add_action( "after_plugin_row_$plugin_file", 'wp_plugin_update_row', 10, 2 ); |
|
| 322 | + $plugins = get_site_transient('update_plugins'); |
|
| 323 | + if (isset($plugins->response) && is_array($plugins->response)) { |
|
| 324 | + $plugins = array_keys($plugins->response); |
|
| 325 | + foreach ($plugins as $plugin_file) { |
|
| 326 | + add_action("after_plugin_row_$plugin_file", 'wp_plugin_update_row', 10, 2); |
|
| 327 | 327 | } |
| 328 | 328 | } |
| 329 | 329 | } |
@@ -335,74 +335,74 @@ discard block |
||
| 335 | 335 | * @param array $plugin_data Plugin information. |
| 336 | 336 | * @return false|void |
| 337 | 337 | */ |
| 338 | -function wp_plugin_update_row( $file, $plugin_data ) { |
|
| 339 | - $current = get_site_transient( 'update_plugins' ); |
|
| 340 | - if ( ! isset( $current->response[ $file ] ) ) { |
|
| 338 | +function wp_plugin_update_row($file, $plugin_data) { |
|
| 339 | + $current = get_site_transient('update_plugins'); |
|
| 340 | + if ( ! isset($current->response[$file])) { |
|
| 341 | 341 | return false; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - $response = $current->response[ $file ]; |
|
| 344 | + $response = $current->response[$file]; |
|
| 345 | 345 | |
| 346 | 346 | $plugins_allowedtags = array( |
| 347 | - 'a' => array( 'href' => array(), 'title' => array() ), |
|
| 348 | - 'abbr' => array( 'title' => array() ), |
|
| 349 | - 'acronym' => array( 'title' => array() ), |
|
| 347 | + 'a' => array('href' => array(), 'title' => array()), |
|
| 348 | + 'abbr' => array('title' => array()), |
|
| 349 | + 'acronym' => array('title' => array()), |
|
| 350 | 350 | 'code' => array(), |
| 351 | 351 | 'em' => array(), |
| 352 | 352 | 'strong' => array(), |
| 353 | 353 | ); |
| 354 | 354 | |
| 355 | - $plugin_name = wp_kses( $plugin_data['Name'], $plugins_allowedtags ); |
|
| 356 | - $details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $response->slug . '§ion=changelog&TB_iframe=true&width=600&height=800' ); |
|
| 355 | + $plugin_name = wp_kses($plugin_data['Name'], $plugins_allowedtags); |
|
| 356 | + $details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin='.$response->slug.'§ion=changelog&TB_iframe=true&width=600&height=800'); |
|
| 357 | 357 | |
| 358 | 358 | /** @var WP_Plugins_List_Table $wp_list_table */ |
| 359 | - $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
| 359 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 360 | 360 | |
| 361 | - if ( is_network_admin() || ! is_multisite() ) { |
|
| 362 | - if ( is_network_admin() ) { |
|
| 363 | - $active_class = is_plugin_active_for_network( $file ) ? ' active' : ''; |
|
| 361 | + if (is_network_admin() || ! is_multisite()) { |
|
| 362 | + if (is_network_admin()) { |
|
| 363 | + $active_class = is_plugin_active_for_network($file) ? ' active' : ''; |
|
| 364 | 364 | } else { |
| 365 | - $active_class = is_plugin_active( $file ) ? ' active' : ''; |
|
| 365 | + $active_class = is_plugin_active($file) ? ' active' : ''; |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - echo '<tr class="plugin-update-tr' . $active_class . '" id="' . esc_attr( $response->slug . '-update' ) . '" data-slug="' . esc_attr( $response->slug ) . '" data-plugin="' . esc_attr( $file ) . '"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>'; |
|
| 368 | + echo '<tr class="plugin-update-tr'.$active_class.'" id="'.esc_attr($response->slug.'-update').'" data-slug="'.esc_attr($response->slug).'" data-plugin="'.esc_attr($file).'"><td colspan="'.esc_attr($wp_list_table->get_column_count()).'" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>'; |
|
| 369 | 369 | |
| 370 | - if ( ! current_user_can( 'update_plugins' ) ) { |
|
| 370 | + if ( ! current_user_can('update_plugins')) { |
|
| 371 | 371 | /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number */ |
| 372 | - printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.' ), |
|
| 372 | + printf(__('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.'), |
|
| 373 | 373 | $plugin_name, |
| 374 | - esc_url( $details_url ), |
|
| 375 | - sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
| 374 | + esc_url($details_url), |
|
| 375 | + sprintf('class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
| 376 | 376 | /* translators: 1: plugin name, 2: version number */ |
| 377 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) |
|
| 377 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $plugin_name, $response->new_version)) |
|
| 378 | 378 | ), |
| 379 | 379 | $response->new_version |
| 380 | 380 | ); |
| 381 | - } elseif ( empty( $response->package ) ) { |
|
| 381 | + } elseif (empty($response->package)) { |
|
| 382 | 382 | /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number */ |
| 383 | - printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>' ), |
|
| 383 | + printf(__('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this plugin.</em>'), |
|
| 384 | 384 | $plugin_name, |
| 385 | - esc_url( $details_url ), |
|
| 386 | - sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
| 385 | + esc_url($details_url), |
|
| 386 | + sprintf('class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
| 387 | 387 | /* translators: 1: plugin name, 2: version number */ |
| 388 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) |
|
| 388 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $plugin_name, $response->new_version)) |
|
| 389 | 389 | ), |
| 390 | 390 | $response->new_version |
| 391 | 391 | ); |
| 392 | 392 | } else { |
| 393 | 393 | /* translators: 1: plugin name, 2: details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */ |
| 394 | - printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ), |
|
| 394 | + printf(__('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.'), |
|
| 395 | 395 | $plugin_name, |
| 396 | - esc_url( $details_url ), |
|
| 397 | - sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
| 396 | + esc_url($details_url), |
|
| 397 | + sprintf('class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
| 398 | 398 | /* translators: 1: plugin name, 2: version number */ |
| 399 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $plugin_name, $response->new_version ) ) |
|
| 399 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $plugin_name, $response->new_version)) |
|
| 400 | 400 | ), |
| 401 | 401 | $response->new_version, |
| 402 | - wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ), |
|
| 403 | - sprintf( 'class="update-link" aria-label="%s"', |
|
| 402 | + wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$file, 'upgrade-plugin_'.$file), |
|
| 403 | + sprintf('class="update-link" aria-label="%s"', |
|
| 404 | 404 | /* translators: %s: plugin name */ |
| 405 | - esc_attr( sprintf( __( 'Update %s now' ), $plugin_name ) ) |
|
| 405 | + esc_attr(sprintf(__('Update %s now'), $plugin_name)) |
|
| 406 | 406 | ) |
| 407 | 407 | ); |
| 408 | 408 | } |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | * @type string $package Plugin update package URL. |
| 443 | 443 | * } |
| 444 | 444 | */ |
| 445 | - do_action( "in_plugin_update_message-{$file}", $plugin_data, $response ); |
|
| 445 | + do_action("in_plugin_update_message-{$file}", $plugin_data, $response); |
|
| 446 | 446 | |
| 447 | 447 | echo '</p></div></td></tr>'; |
| 448 | 448 | } |
@@ -455,13 +455,13 @@ discard block |
||
| 455 | 455 | function get_theme_updates() { |
| 456 | 456 | $current = get_site_transient('update_themes'); |
| 457 | 457 | |
| 458 | - if ( ! isset( $current->response ) ) |
|
| 458 | + if ( ! isset($current->response)) |
|
| 459 | 459 | return array(); |
| 460 | 460 | |
| 461 | 461 | $update_themes = array(); |
| 462 | - foreach ( $current->response as $stylesheet => $data ) { |
|
| 463 | - $update_themes[ $stylesheet ] = wp_get_theme( $stylesheet ); |
|
| 464 | - $update_themes[ $stylesheet ]->update = $data; |
|
| 462 | + foreach ($current->response as $stylesheet => $data) { |
|
| 463 | + $update_themes[$stylesheet] = wp_get_theme($stylesheet); |
|
| 464 | + $update_themes[$stylesheet]->update = $data; |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | return $update_themes; |
@@ -471,15 +471,15 @@ discard block |
||
| 471 | 471 | * @since 3.1.0 |
| 472 | 472 | */ |
| 473 | 473 | function wp_theme_update_rows() { |
| 474 | - if ( !current_user_can('update_themes' ) ) |
|
| 474 | + if ( ! current_user_can('update_themes')) |
|
| 475 | 475 | return; |
| 476 | 476 | |
| 477 | - $themes = get_site_transient( 'update_themes' ); |
|
| 478 | - if ( isset($themes->response) && is_array($themes->response) ) { |
|
| 479 | - $themes = array_keys( $themes->response ); |
|
| 477 | + $themes = get_site_transient('update_themes'); |
|
| 478 | + if (isset($themes->response) && is_array($themes->response)) { |
|
| 479 | + $themes = array_keys($themes->response); |
|
| 480 | 480 | |
| 481 | - foreach ( $themes as $theme ) { |
|
| 482 | - add_action( "after_theme_row_$theme", 'wp_theme_update_row', 10, 2 ); |
|
| 481 | + foreach ($themes as $theme) { |
|
| 482 | + add_action("after_theme_row_$theme", 'wp_theme_update_row', 10, 2); |
|
| 483 | 483 | } |
| 484 | 484 | } |
| 485 | 485 | } |
@@ -491,63 +491,63 @@ discard block |
||
| 491 | 491 | * @param WP_Theme $theme Theme object. |
| 492 | 492 | * @return false|void |
| 493 | 493 | */ |
| 494 | -function wp_theme_update_row( $theme_key, $theme ) { |
|
| 495 | - $current = get_site_transient( 'update_themes' ); |
|
| 494 | +function wp_theme_update_row($theme_key, $theme) { |
|
| 495 | + $current = get_site_transient('update_themes'); |
|
| 496 | 496 | |
| 497 | - if ( ! isset( $current->response[ $theme_key ] ) ) { |
|
| 497 | + if ( ! isset($current->response[$theme_key])) { |
|
| 498 | 498 | return false; |
| 499 | 499 | } |
| 500 | 500 | |
| 501 | - $response = $current->response[ $theme_key ]; |
|
| 501 | + $response = $current->response[$theme_key]; |
|
| 502 | 502 | |
| 503 | - $details_url = add_query_arg( array( |
|
| 503 | + $details_url = add_query_arg(array( |
|
| 504 | 504 | 'TB_iframe' => 'true', |
| 505 | 505 | 'width' => 1024, |
| 506 | 506 | 'height' => 800, |
| 507 | - ), $current->response[ $theme_key ]['url'] ); |
|
| 507 | + ), $current->response[$theme_key]['url']); |
|
| 508 | 508 | |
| 509 | 509 | /** @var WP_MS_Themes_List_Table $wp_list_table */ |
| 510 | - $wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' ); |
|
| 510 | + $wp_list_table = _get_list_table('WP_MS_Themes_List_Table'); |
|
| 511 | 511 | |
| 512 | - $active = $theme->is_allowed( 'network' ) ? ' active' : ''; |
|
| 512 | + $active = $theme->is_allowed('network') ? ' active' : ''; |
|
| 513 | 513 | |
| 514 | - echo '<tr class="plugin-update-tr' . $active . '" id="' . esc_attr( $theme->get_stylesheet() . '-update' ) . '" data-slug="' . esc_attr( $theme->get_stylesheet() ) . '"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>'; |
|
| 515 | - if ( ! current_user_can( 'update_themes' ) ) { |
|
| 514 | + echo '<tr class="plugin-update-tr'.$active.'" id="'.esc_attr($theme->get_stylesheet().'-update').'" data-slug="'.esc_attr($theme->get_stylesheet()).'"><td colspan="'.$wp_list_table->get_column_count().'" class="plugin-update colspanchange"><div class="update-message notice inline notice-warning notice-alt"><p>'; |
|
| 515 | + if ( ! current_user_can('update_themes')) { |
|
| 516 | 516 | /* translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number */ |
| 517 | - printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.'), |
|
| 517 | + printf(__('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>.'), |
|
| 518 | 518 | $theme['Name'], |
| 519 | - esc_url( $details_url ), |
|
| 520 | - sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
| 519 | + esc_url($details_url), |
|
| 520 | + sprintf('class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
| 521 | 521 | /* translators: 1: theme name, 2: version number */ |
| 522 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) |
|
| 522 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $theme['Name'], $response['new_version'])) |
|
| 523 | 523 | ), |
| 524 | 524 | $response['new_version'] |
| 525 | 525 | ); |
| 526 | - } elseif ( empty( $response['package'] ) ) { |
|
| 526 | + } elseif (empty($response['package'])) { |
|
| 527 | 527 | /* translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number */ |
| 528 | - printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>' ), |
|
| 528 | + printf(__('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a>. <em>Automatic update is unavailable for this theme.</em>'), |
|
| 529 | 529 | $theme['Name'], |
| 530 | - esc_url( $details_url ), |
|
| 531 | - sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
| 530 | + esc_url($details_url), |
|
| 531 | + sprintf('class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
| 532 | 532 | /* translators: 1: theme name, 2: version number */ |
| 533 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) |
|
| 533 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $theme['Name'], $response['new_version'])) |
|
| 534 | 534 | ), |
| 535 | 535 | $response['new_version'] |
| 536 | 536 | ); |
| 537 | 537 | } else { |
| 538 | 538 | /* translators: 1: theme name, 2: details URL, 3: additional link attributes, 4: version number, 5: update URL, 6: additional link attributes */ |
| 539 | - printf( __( 'There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.' ), |
|
| 539 | + printf(__('There is a new version of %1$s available. <a href="%2$s" %3$s>View version %4$s details</a> or <a href="%5$s" %6$s>update now</a>.'), |
|
| 540 | 540 | $theme['Name'], |
| 541 | - esc_url( $details_url ), |
|
| 542 | - sprintf( 'class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
| 541 | + esc_url($details_url), |
|
| 542 | + sprintf('class="thickbox open-plugin-details-modal" aria-label="%s"', |
|
| 543 | 543 | /* translators: 1: theme name, 2: version number */ |
| 544 | - esc_attr( sprintf( __( 'View %1$s version %2$s details' ), $theme['Name'], $response['new_version'] ) ) |
|
| 544 | + esc_attr(sprintf(__('View %1$s version %2$s details'), $theme['Name'], $response['new_version'])) |
|
| 545 | 545 | ), |
| 546 | 546 | $response['new_version'], |
| 547 | - wp_nonce_url( self_admin_url( 'update.php?action=upgrade-theme&theme=' ) . $theme_key, 'upgrade-theme_' . $theme_key ), |
|
| 548 | - sprintf( 'class="update-link" aria-label="%s"', |
|
| 547 | + wp_nonce_url(self_admin_url('update.php?action=upgrade-theme&theme=').$theme_key, 'upgrade-theme_'.$theme_key), |
|
| 548 | + sprintf('class="update-link" aria-label="%s"', |
|
| 549 | 549 | /* translators: %s: theme name */ |
| 550 | - esc_attr( sprintf( __( 'Update %s now' ), $theme['Name'] ) ) |
|
| 550 | + esc_attr(sprintf(__('Update %s now'), $theme['Name'])) |
|
| 551 | 551 | ) |
| 552 | 552 | ); |
| 553 | 553 | } |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | * @type string $package Theme update package URL. |
| 571 | 571 | * } |
| 572 | 572 | */ |
| 573 | - do_action( "in_theme_update_message-{$theme_key}", $theme, $response ); |
|
| 573 | + do_action("in_theme_update_message-{$theme_key}", $theme, $response); |
|
| 574 | 574 | |
| 575 | 575 | echo '</p></div></td></tr>'; |
| 576 | 576 | } |
@@ -581,11 +581,11 @@ discard block |
||
| 581 | 581 | * @return false|void |
| 582 | 582 | */ |
| 583 | 583 | function maintenance_nag() { |
| 584 | - include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version |
|
| 584 | + include(ABSPATH.WPINC.'/version.php'); // include an unmodified $wp_version |
|
| 585 | 585 | global $upgrading; |
| 586 | - $nag = isset( $upgrading ); |
|
| 587 | - if ( ! $nag ) { |
|
| 588 | - $failed = get_site_option( 'auto_core_update_failed' ); |
|
| 586 | + $nag = isset($upgrading); |
|
| 587 | + if ( ! $nag) { |
|
| 588 | + $failed = get_site_option('auto_core_update_failed'); |
|
| 589 | 589 | /* |
| 590 | 590 | * If an update failed critically, we may have copied over version.php but not other files. |
| 591 | 591 | * In that case, if the install claims we're running the version we attempted, nag. |
@@ -596,16 +596,16 @@ discard block |
||
| 596 | 596 | * |
| 597 | 597 | * This flag is cleared whenever a successful update occurs using Core_Upgrader. |
| 598 | 598 | */ |
| 599 | - $comparison = ! empty( $failed['critical'] ) ? '>=' : '>'; |
|
| 600 | - if ( version_compare( $failed['attempted'], $wp_version, $comparison ) ) |
|
| 599 | + $comparison = ! empty($failed['critical']) ? '>=' : '>'; |
|
| 600 | + if (version_compare($failed['attempted'], $wp_version, $comparison)) |
|
| 601 | 601 | $nag = true; |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | - if ( ! $nag ) |
|
| 604 | + if ( ! $nag) |
|
| 605 | 605 | return false; |
| 606 | 606 | |
| 607 | - if ( current_user_can('update_core') ) |
|
| 608 | - $msg = sprintf( __('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php' ); |
|
| 607 | + if (current_user_can('update_core')) |
|
| 608 | + $msg = sprintf(__('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php'); |
|
| 609 | 609 | else |
| 610 | 610 | $msg = __('An automated WordPress update has failed to complete! Please notify the site administrator.'); |
| 611 | 611 | |
@@ -641,24 +641,24 @@ discard block |
||
| 641 | 641 | <# if ( 'plugin' === data.type ) { #> |
| 642 | 642 | <?php |
| 643 | 643 | /* translators: %s: Number of plugins */ |
| 644 | - printf( __( '%s plugin successfully updated.' ), '{{ data.successes }}' ); |
|
| 644 | + printf(__('%s plugin successfully updated.'), '{{ data.successes }}'); |
|
| 645 | 645 | ?> |
| 646 | 646 | <# } else { #> |
| 647 | 647 | <?php |
| 648 | 648 | /* translators: %s: Number of themes */ |
| 649 | - printf( __( '%s theme successfully updated.' ), '{{ data.successes }}' ); |
|
| 649 | + printf(__('%s theme successfully updated.'), '{{ data.successes }}'); |
|
| 650 | 650 | ?> |
| 651 | 651 | <# } #> |
| 652 | 652 | <# } else { #> |
| 653 | 653 | <# if ( 'plugin' === data.type ) { #> |
| 654 | 654 | <?php |
| 655 | 655 | /* translators: %s: Number of plugins */ |
| 656 | - printf( __( '%s plugins successfully updated.' ), '{{ data.successes }}' ); |
|
| 656 | + printf(__('%s plugins successfully updated.'), '{{ data.successes }}'); |
|
| 657 | 657 | ?> |
| 658 | 658 | <# } else { #> |
| 659 | 659 | <?php |
| 660 | 660 | /* translators: %s: Number of themes */ |
| 661 | - printf( __( '%s themes successfully updated.' ), '{{ data.successes }}' ); |
|
| 661 | + printf(__('%s themes successfully updated.'), '{{ data.successes }}'); |
|
| 662 | 662 | ?> |
| 663 | 663 | <# } #> |
| 664 | 664 | <# } #> |
@@ -668,15 +668,15 @@ discard block |
||
| 668 | 668 | <# if ( 1 === data.errors ) { #> |
| 669 | 669 | <?php |
| 670 | 670 | /* translators: %s: Number of failed updates */ |
| 671 | - printf( __( '%s update failed.' ), '{{ data.errors }}' ); |
|
| 671 | + printf(__('%s update failed.'), '{{ data.errors }}'); |
|
| 672 | 672 | ?> |
| 673 | 673 | <# } else { #> |
| 674 | 674 | <?php |
| 675 | 675 | /* translators: %s: Number of failed updates */ |
| 676 | - printf( __( '%s updates failed.' ), '{{ data.errors }}' ); |
|
| 676 | + printf(__('%s updates failed.'), '{{ data.errors }}'); |
|
| 677 | 677 | ?> |
| 678 | 678 | <# } #> |
| 679 | - <span class="screen-reader-text"><?php _e( 'Show more details' ); ?></span> |
|
| 679 | + <span class="screen-reader-text"><?php _e('Show more details'); ?></span> |
|
| 680 | 680 | <span class="toggle-indicator" aria-hidden="true"></span> |
| 681 | 681 | </button> |
| 682 | 682 | <# } #> |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | <?php |
| 737 | 737 | printf( |
| 738 | 738 | /* translators: %s: Plugin name */ |
| 739 | - _x( '%s was successfully deleted.', 'plugin' ), |
|
| 739 | + _x('%s was successfully deleted.', 'plugin'), |
|
| 740 | 740 | '<strong>{{{ data.name }}}</strong>' |
| 741 | 741 | ); |
| 742 | 742 | ?> |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | <?php |
| 745 | 745 | printf( |
| 746 | 746 | /* translators: %s: Theme name */ |
| 747 | - _x( '%s was successfully deleted.', 'theme' ), |
|
| 747 | + _x('%s was successfully deleted.', 'theme'), |
|
| 748 | 748 | '<strong>{{{ data.name }}}</strong>' |
| 749 | 749 | ); |
| 750 | 750 | ?> |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param array $args |
| 35 | 35 | */ |
| 36 | 36 | public function __construct($args = array()) { |
| 37 | - $defaults = array( 'url' => '', 'nonce' => '', 'title' => '', 'context' => false ); |
|
| 37 | + $defaults = array('url' => '', 'nonce' => '', 'title' => '', 'context' => false); |
|
| 38 | 38 | $this->options = wp_parse_args($args, $defaults); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | * @param WP_Upgrader $upgrader |
| 43 | 43 | */ |
| 44 | 44 | public function set_upgrader(&$upgrader) { |
| 45 | - if ( is_object($upgrader) ) |
|
| 46 | - $this->upgrader =& $upgrader; |
|
| 45 | + if (is_object($upgrader)) |
|
| 46 | + $this->upgrader = & $upgrader; |
|
| 47 | 47 | $this->add_strings(); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @param string|bool|WP_Error $result The result of an upgrade. |
| 63 | 63 | */ |
| 64 | - public function set_result( $result ) { |
|
| 64 | + public function set_result($result) { |
|
| 65 | 65 | $this->result = $result; |
| 66 | 66 | } |
| 67 | 67 | |
@@ -81,37 +81,37 @@ discard block |
||
| 81 | 81 | * @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false. |
| 82 | 82 | * @return bool False on failure, true on success. |
| 83 | 83 | */ |
| 84 | - public function request_filesystem_credentials( $error = false, $context = '', $allow_relaxed_file_ownership = false ) { |
|
| 84 | + public function request_filesystem_credentials($error = false, $context = '', $allow_relaxed_file_ownership = false) { |
|
| 85 | 85 | $url = $this->options['url']; |
| 86 | - if ( ! $context ) { |
|
| 86 | + if ( ! $context) { |
|
| 87 | 87 | $context = $this->options['context']; |
| 88 | 88 | } |
| 89 | - if ( !empty($this->options['nonce']) ) { |
|
| 89 | + if ( ! empty($this->options['nonce'])) { |
|
| 90 | 90 | $url = wp_nonce_url($url, $this->options['nonce']); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | $extra_fields = array(); |
| 94 | 94 | |
| 95 | - return request_filesystem_credentials( $url, '', $error, $context, $extra_fields, $allow_relaxed_file_ownership ); |
|
| 95 | + return request_filesystem_credentials($url, '', $error, $context, $extra_fields, $allow_relaxed_file_ownership); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * @access public |
| 100 | 100 | */ |
| 101 | 101 | public function header() { |
| 102 | - if ( $this->done_header ) { |
|
| 102 | + if ($this->done_header) { |
|
| 103 | 103 | return; |
| 104 | 104 | } |
| 105 | 105 | $this->done_header = true; |
| 106 | 106 | echo '<div class="wrap">'; |
| 107 | - echo '<h1>' . $this->options['title'] . '</h1>'; |
|
| 107 | + echo '<h1>'.$this->options['title'].'</h1>'; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | 111 | * @access public |
| 112 | 112 | */ |
| 113 | 113 | public function footer() { |
| 114 | - if ( $this->done_footer ) { |
|
| 114 | + if ($this->done_footer) { |
|
| 115 | 115 | return; |
| 116 | 116 | } |
| 117 | 117 | $this->done_footer = true; |
@@ -123,14 +123,14 @@ discard block |
||
| 123 | 123 | * @param string|WP_Error $errors |
| 124 | 124 | */ |
| 125 | 125 | public function error($errors) { |
| 126 | - if ( ! $this->done_header ) |
|
| 126 | + if ( ! $this->done_header) |
|
| 127 | 127 | $this->header(); |
| 128 | - if ( is_string($errors) ) { |
|
| 128 | + if (is_string($errors)) { |
|
| 129 | 129 | $this->feedback($errors); |
| 130 | - } elseif ( is_wp_error($errors) && $errors->get_error_code() ) { |
|
| 131 | - foreach ( $errors->get_error_messages() as $message ) { |
|
| 132 | - if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) |
|
| 133 | - $this->feedback($message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) ); |
|
| 130 | + } elseif (is_wp_error($errors) && $errors->get_error_code()) { |
|
| 131 | + foreach ($errors->get_error_messages() as $message) { |
|
| 132 | + if ($errors->get_error_data() && is_string($errors->get_error_data())) |
|
| 133 | + $this->feedback($message.' '.esc_html(strip_tags($errors->get_error_data()))); |
|
| 134 | 134 | else |
| 135 | 135 | $this->feedback($message); |
| 136 | 136 | } |
@@ -142,19 +142,19 @@ discard block |
||
| 142 | 142 | * @param string $string |
| 143 | 143 | */ |
| 144 | 144 | public function feedback($string) { |
| 145 | - if ( isset( $this->upgrader->strings[$string] ) ) |
|
| 145 | + if (isset($this->upgrader->strings[$string])) |
|
| 146 | 146 | $string = $this->upgrader->strings[$string]; |
| 147 | 147 | |
| 148 | - if ( strpos($string, '%') !== false ) { |
|
| 148 | + if (strpos($string, '%') !== false) { |
|
| 149 | 149 | $args = func_get_args(); |
| 150 | 150 | $args = array_splice($args, 1); |
| 151 | - if ( $args ) { |
|
| 152 | - $args = array_map( 'strip_tags', $args ); |
|
| 153 | - $args = array_map( 'esc_html', $args ); |
|
| 151 | + if ($args) { |
|
| 152 | + $args = array_map('strip_tags', $args); |
|
| 153 | + $args = array_map('esc_html', $args); |
|
| 154 | 154 | $string = vsprintf($string, $args); |
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | - if ( empty($string) ) |
|
| 157 | + if (empty($string)) |
|
| 158 | 158 | return; |
| 159 | 159 | show_message($string); |
| 160 | 160 | } |
@@ -177,22 +177,22 @@ discard block |
||
| 177 | 177 | * @param string $type Type of update count to decrement. Likely values include 'plugin', |
| 178 | 178 | * 'theme', 'translation', etc. |
| 179 | 179 | */ |
| 180 | - protected function decrement_update_count( $type ) { |
|
| 181 | - if ( ! $this->result || is_wp_error( $this->result ) || 'up_to_date' === $this->result ) { |
|
| 180 | + protected function decrement_update_count($type) { |
|
| 181 | + if ( ! $this->result || is_wp_error($this->result) || 'up_to_date' === $this->result) { |
|
| 182 | 182 | return; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - if ( defined( 'IFRAME_REQUEST' ) ) { |
|
| 185 | + if (defined('IFRAME_REQUEST')) { |
|
| 186 | 186 | echo '<script type="text/javascript"> |
| 187 | 187 | if ( window.postMessage && JSON ) { |
| 188 | - window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type . '" } ), window.location.protocol + "//" + window.location.hostname ); |
|
| 188 | + window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type.'" } ), window.location.protocol + "//" + window.location.hostname ); |
|
| 189 | 189 | } |
| 190 | 190 | </script>'; |
| 191 | 191 | } else { |
| 192 | 192 | echo '<script type="text/javascript"> |
| 193 | 193 | (function( wp ) { |
| 194 | 194 | if ( wp && wp.updates.decrementCount ) { |
| 195 | - wp.updates.decrementCount( "' . $type . '" ); |
|
| 195 | + wp.updates.decrementCount( "' . $type.'" ); |
|
| 196 | 196 | } |
| 197 | 197 | })( window.wp ); |
| 198 | 198 | </script>'; |
@@ -9,16 +9,16 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | /** Include user install customize script. */ |
| 12 | -if ( file_exists(WP_CONTENT_DIR . '/install.php') ) |
|
| 13 | - require (WP_CONTENT_DIR . '/install.php'); |
|
| 12 | +if (file_exists(WP_CONTENT_DIR.'/install.php')) |
|
| 13 | + require (WP_CONTENT_DIR.'/install.php'); |
|
| 14 | 14 | |
| 15 | 15 | /** WordPress Administration API */ |
| 16 | -require_once(ABSPATH . 'wp-admin/includes/admin.php'); |
|
| 16 | +require_once(ABSPATH.'wp-admin/includes/admin.php'); |
|
| 17 | 17 | |
| 18 | 18 | /** WordPress Schema API */ |
| 19 | -require_once(ABSPATH . 'wp-admin/includes/schema.php'); |
|
| 19 | +require_once(ABSPATH.'wp-admin/includes/schema.php'); |
|
| 20 | 20 | |
| 21 | -if ( !function_exists('wp_install') ) : |
|
| 21 | +if ( ! function_exists('wp_install')) : |
|
| 22 | 22 | /** |
| 23 | 23 | * Installs the site. |
| 24 | 24 | * |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | * @param string $language Optional. Language chosen. Default empty. |
| 37 | 37 | * @return array Array keys 'url', 'user_id', 'password', and 'password_message'. |
| 38 | 38 | */ |
| 39 | -function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '' ) { |
|
| 40 | - if ( !empty( $deprecated ) ) |
|
| 41 | - _deprecated_argument( __FUNCTION__, '2.6.0' ); |
|
| 39 | +function wp_install($blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '') { |
|
| 40 | + if ( ! empty($deprecated)) |
|
| 41 | + _deprecated_argument(__FUNCTION__, '2.6.0'); |
|
| 42 | 42 | |
| 43 | 43 | wp_check_mysql_version(); |
| 44 | 44 | wp_cache_flush(); |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | update_option('admin_email', $user_email); |
| 51 | 51 | update_option('blog_public', $public); |
| 52 | 52 | |
| 53 | - if ( $language ) { |
|
| 54 | - update_option( 'WPLANG', $language ); |
|
| 53 | + if ($language) { |
|
| 54 | + update_option('WPLANG', $language); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $guessurl = wp_guess_url(); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | update_option('siteurl', $guessurl); |
| 60 | 60 | |
| 61 | 61 | // If not a public blog, don't ping. |
| 62 | - if ( ! $public ) |
|
| 62 | + if ( ! $public) |
|
| 63 | 63 | update_option('default_pingback_flag', 0); |
| 64 | 64 | |
| 65 | 65 | /* |
@@ -69,13 +69,13 @@ discard block |
||
| 69 | 69 | $user_id = username_exists($user_name); |
| 70 | 70 | $user_password = trim($user_password); |
| 71 | 71 | $email_password = false; |
| 72 | - if ( !$user_id && empty($user_password) ) { |
|
| 73 | - $user_password = wp_generate_password( 12, false ); |
|
| 72 | + if ( ! $user_id && empty($user_password)) { |
|
| 73 | + $user_password = wp_generate_password(12, false); |
|
| 74 | 74 | $message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.'); |
| 75 | 75 | $user_id = wp_create_user($user_name, $user_password, $user_email); |
| 76 | 76 | update_user_option($user_id, 'default_password_nag', true, true); |
| 77 | 77 | $email_password = true; |
| 78 | - } elseif ( ! $user_id ) { |
|
| 78 | + } elseif ( ! $user_id) { |
|
| 79 | 79 | // Password has been provided |
| 80 | 80 | $message = '<em>'.__('Your chosen password.').'</em>'; |
| 81 | 81 | $user_id = wp_create_user($user_name, $user_password, $user_email); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | flush_rewrite_rules(); |
| 94 | 94 | |
| 95 | - wp_new_blog_notification($blog_title, $guessurl, $user_id, ($email_password ? $user_password : __('The password you chose during the install.') ) ); |
|
| 95 | + wp_new_blog_notification($blog_title, $guessurl, $user_id, ($email_password ? $user_password : __('The password you chose during the install.'))); |
|
| 96 | 96 | |
| 97 | 97 | wp_cache_flush(); |
| 98 | 98 | |
@@ -103,13 +103,13 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @param WP_User $user The site owner. |
| 105 | 105 | */ |
| 106 | - do_action( 'wp_install', $user ); |
|
| 106 | + do_action('wp_install', $user); |
|
| 107 | 107 | |
| 108 | 108 | return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $user_password, 'password_message' => $message); |
| 109 | 109 | } |
| 110 | 110 | endif; |
| 111 | 111 | |
| 112 | -if ( !function_exists('wp_install_defaults') ) : |
|
| 112 | +if ( ! function_exists('wp_install_defaults')) : |
|
| 113 | 113 | /** |
| 114 | 114 | * Creates the initial content for a newly-installed site. |
| 115 | 115 | * |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * |
| 125 | 125 | * @param int $user_id User ID. |
| 126 | 126 | */ |
| 127 | -function wp_install_defaults( $user_id ) { |
|
| 127 | +function wp_install_defaults($user_id) { |
|
| 128 | 128 | global $wpdb, $wp_rewrite, $table_prefix; |
| 129 | 129 | |
| 130 | 130 | // Default category |
@@ -132,10 +132,10 @@ discard block |
||
| 132 | 132 | /* translators: Default category slug */ |
| 133 | 133 | $cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug')); |
| 134 | 134 | |
| 135 | - if ( global_terms_enabled() ) { |
|
| 136 | - $cat_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) ); |
|
| 137 | - if ( $cat_id == null ) { |
|
| 138 | - $wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) ); |
|
| 135 | + if (global_terms_enabled()) { |
|
| 136 | + $cat_id = $wpdb->get_var($wpdb->prepare("SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug)); |
|
| 137 | + if ($cat_id == null) { |
|
| 138 | + $wpdb->insert($wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true))); |
|
| 139 | 139 | $cat_id = $wpdb->insert_id; |
| 140 | 140 | } |
| 141 | 141 | update_option('default_category', $cat_id); |
@@ -143,35 +143,35 @@ discard block |
||
| 143 | 143 | $cat_id = 1; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $wpdb->insert( $wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) ); |
|
| 147 | - $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1)); |
|
| 146 | + $wpdb->insert($wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0)); |
|
| 147 | + $wpdb->insert($wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1)); |
|
| 148 | 148 | $cat_tt_id = $wpdb->insert_id; |
| 149 | 149 | |
| 150 | 150 | // First post |
| 151 | - $now = current_time( 'mysql' ); |
|
| 152 | - $now_gmt = current_time( 'mysql', 1 ); |
|
| 153 | - $first_post_guid = get_option( 'home' ) . '/?p=1'; |
|
| 151 | + $now = current_time('mysql'); |
|
| 152 | + $now_gmt = current_time('mysql', 1); |
|
| 153 | + $first_post_guid = get_option('home').'/?p=1'; |
|
| 154 | 154 | |
| 155 | - if ( is_multisite() ) { |
|
| 156 | - $first_post = get_site_option( 'first_post' ); |
|
| 155 | + if (is_multisite()) { |
|
| 156 | + $first_post = get_site_option('first_post'); |
|
| 157 | 157 | |
| 158 | - if ( ! $first_post ) { |
|
| 158 | + if ( ! $first_post) { |
|
| 159 | 159 | /* translators: %s: site link */ |
| 160 | - $first_post = __( 'Welcome to %s. This is your first post. Edit or delete it, then start blogging!' ); |
|
| 160 | + $first_post = __('Welcome to %s. This is your first post. Edit or delete it, then start blogging!'); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - $first_post = sprintf( $first_post, |
|
| 164 | - sprintf( '<a href="%s">%s</a>', esc_url( network_home_url() ), get_current_site()->site_name ) |
|
| 163 | + $first_post = sprintf($first_post, |
|
| 164 | + sprintf('<a href="%s">%s</a>', esc_url(network_home_url()), get_current_site()->site_name) |
|
| 165 | 165 | ); |
| 166 | 166 | |
| 167 | 167 | // Back-compat for pre-4.4 |
| 168 | - $first_post = str_replace( 'SITE_URL', esc_url( network_home_url() ), $first_post ); |
|
| 169 | - $first_post = str_replace( 'SITE_NAME', get_current_site()->site_name, $first_post ); |
|
| 168 | + $first_post = str_replace('SITE_URL', esc_url(network_home_url()), $first_post); |
|
| 169 | + $first_post = str_replace('SITE_NAME', get_current_site()->site_name, $first_post); |
|
| 170 | 170 | } else { |
| 171 | - $first_post = __( 'Welcome to WordPress. This is your first post. Edit or delete it, then start writing!' ); |
|
| 171 | + $first_post = __('Welcome to WordPress. This is your first post. Edit or delete it, then start writing!'); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - $wpdb->insert( $wpdb->posts, array( |
|
| 174 | + $wpdb->insert($wpdb->posts, array( |
|
| 175 | 175 | 'post_author' => $user_id, |
| 176 | 176 | 'post_date' => $now, |
| 177 | 177 | 'post_date_gmt' => $now_gmt, |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | 'post_excerpt' => '', |
| 180 | 180 | 'post_title' => __('Hello world!'), |
| 181 | 181 | /* translators: Default post slug */ |
| 182 | - 'post_name' => sanitize_title( _x('hello-world', 'Default post slug') ), |
|
| 182 | + 'post_name' => sanitize_title(_x('hello-world', 'Default post slug')), |
|
| 183 | 183 | 'post_modified' => $now, |
| 184 | 184 | 'post_modified_gmt' => $now_gmt, |
| 185 | 185 | 'guid' => $first_post_guid, |
@@ -188,22 +188,22 @@ discard block |
||
| 188 | 188 | 'pinged' => '', |
| 189 | 189 | 'post_content_filtered' => '' |
| 190 | 190 | )); |
| 191 | - $wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1) ); |
|
| 191 | + $wpdb->insert($wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1)); |
|
| 192 | 192 | |
| 193 | 193 | // Default comment |
| 194 | - $first_comment_author = __( 'A WordPress Commenter' ); |
|
| 194 | + $first_comment_author = __('A WordPress Commenter'); |
|
| 195 | 195 | $first_comment_email = '[email protected]'; |
| 196 | 196 | $first_comment_url = 'https://wordpress.org/'; |
| 197 | - $first_comment = __( 'Hi, this is a comment. |
|
| 197 | + $first_comment = __('Hi, this is a comment. |
|
| 198 | 198 | To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard. |
| 199 | 199 | Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.' ); |
| 200 | - if ( is_multisite() ) { |
|
| 201 | - $first_comment_author = get_site_option( 'first_comment_author', $first_comment_author ); |
|
| 202 | - $first_comment_email = get_site_option( 'first_comment_email', $first_comment_email ); |
|
| 203 | - $first_comment_url = get_site_option( 'first_comment_url', network_home_url() ); |
|
| 204 | - $first_comment = get_site_option( 'first_comment', $first_comment ); |
|
| 200 | + if (is_multisite()) { |
|
| 201 | + $first_comment_author = get_site_option('first_comment_author', $first_comment_author); |
|
| 202 | + $first_comment_email = get_site_option('first_comment_email', $first_comment_email); |
|
| 203 | + $first_comment_url = get_site_option('first_comment_url', network_home_url()); |
|
| 204 | + $first_comment = get_site_option('first_comment', $first_comment); |
|
| 205 | 205 | } |
| 206 | - $wpdb->insert( $wpdb->comments, array( |
|
| 206 | + $wpdb->insert($wpdb->comments, array( |
|
| 207 | 207 | 'comment_post_ID' => 1, |
| 208 | 208 | 'comment_author' => $first_comment_author, |
| 209 | 209 | 'comment_author_email' => $first_comment_email, |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | )); |
| 215 | 215 | |
| 216 | 216 | // First Page |
| 217 | - $first_page = sprintf( __( "This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this: |
|
| 217 | + $first_page = sprintf(__("This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this: |
|
| 218 | 218 | |
| 219 | 219 | <blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin' caught in the rain.)</blockquote> |
| 220 | 220 | |
@@ -222,20 +222,20 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | <blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote> |
| 224 | 224 | |
| 225 | -As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url() ); |
|
| 226 | - if ( is_multisite() ) |
|
| 227 | - $first_page = get_site_option( 'first_page', $first_page ); |
|
| 228 | - $first_post_guid = get_option('home') . '/?page_id=2'; |
|
| 229 | - $wpdb->insert( $wpdb->posts, array( |
|
| 225 | +As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url()); |
|
| 226 | + if (is_multisite()) |
|
| 227 | + $first_page = get_site_option('first_page', $first_page); |
|
| 228 | + $first_post_guid = get_option('home').'/?page_id=2'; |
|
| 229 | + $wpdb->insert($wpdb->posts, array( |
|
| 230 | 230 | 'post_author' => $user_id, |
| 231 | 231 | 'post_date' => $now, |
| 232 | 232 | 'post_date_gmt' => $now_gmt, |
| 233 | 233 | 'post_content' => $first_page, |
| 234 | 234 | 'post_excerpt' => '', |
| 235 | 235 | 'comment_status' => 'closed', |
| 236 | - 'post_title' => __( 'Sample Page' ), |
|
| 236 | + 'post_title' => __('Sample Page'), |
|
| 237 | 237 | /* translators: Default page slug */ |
| 238 | - 'post_name' => __( 'sample-page' ), |
|
| 238 | + 'post_name' => __('sample-page'), |
|
| 239 | 239 | 'post_modified' => $now, |
| 240 | 240 | 'post_modified_gmt' => $now_gmt, |
| 241 | 241 | 'guid' => $first_post_guid, |
@@ -244,37 +244,37 @@ discard block |
||
| 244 | 244 | 'pinged' => '', |
| 245 | 245 | 'post_content_filtered' => '' |
| 246 | 246 | )); |
| 247 | - $wpdb->insert( $wpdb->postmeta, array( 'post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default' ) ); |
|
| 247 | + $wpdb->insert($wpdb->postmeta, array('post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default')); |
|
| 248 | 248 | |
| 249 | 249 | // Set up default widgets for default theme. |
| 250 | - update_option( 'widget_search', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) ); |
|
| 251 | - update_option( 'widget_recent-posts', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) ); |
|
| 252 | - update_option( 'widget_recent-comments', array ( 2 => array ( 'title' => '', 'number' => 5 ), '_multiwidget' => 1 ) ); |
|
| 253 | - update_option( 'widget_archives', array ( 2 => array ( 'title' => '', 'count' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) ); |
|
| 254 | - update_option( 'widget_categories', array ( 2 => array ( 'title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0 ), '_multiwidget' => 1 ) ); |
|
| 255 | - update_option( 'widget_meta', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) ); |
|
| 256 | - update_option( 'sidebars_widgets', array ( 'wp_inactive_widgets' => array (), 'sidebar-1' => array ( 0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2', ), 'array_version' => 3 ) ); |
|
| 257 | - |
|
| 258 | - if ( ! is_multisite() ) |
|
| 259 | - update_user_meta( $user_id, 'show_welcome_panel', 1 ); |
|
| 260 | - elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) ) |
|
| 261 | - update_user_meta( $user_id, 'show_welcome_panel', 2 ); |
|
| 262 | - |
|
| 263 | - if ( is_multisite() ) { |
|
| 250 | + update_option('widget_search', array(2 => array('title' => ''), '_multiwidget' => 1)); |
|
| 251 | + update_option('widget_recent-posts', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1)); |
|
| 252 | + update_option('widget_recent-comments', array(2 => array('title' => '', 'number' => 5), '_multiwidget' => 1)); |
|
| 253 | + update_option('widget_archives', array(2 => array('title' => '', 'count' => 0, 'dropdown' => 0), '_multiwidget' => 1)); |
|
| 254 | + update_option('widget_categories', array(2 => array('title' => '', 'count' => 0, 'hierarchical' => 0, 'dropdown' => 0), '_multiwidget' => 1)); |
|
| 255 | + update_option('widget_meta', array(2 => array('title' => ''), '_multiwidget' => 1)); |
|
| 256 | + update_option('sidebars_widgets', array('wp_inactive_widgets' => array(), 'sidebar-1' => array(0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2',), 'array_version' => 3)); |
|
| 257 | + |
|
| 258 | + if ( ! is_multisite()) |
|
| 259 | + update_user_meta($user_id, 'show_welcome_panel', 1); |
|
| 260 | + elseif ( ! is_super_admin($user_id) && ! metadata_exists('user', $user_id, 'show_welcome_panel')) |
|
| 261 | + update_user_meta($user_id, 'show_welcome_panel', 2); |
|
| 262 | + |
|
| 263 | + if (is_multisite()) { |
|
| 264 | 264 | // Flush rules to pick up the new page. |
| 265 | 265 | $wp_rewrite->init(); |
| 266 | 266 | $wp_rewrite->flush_rules(); |
| 267 | 267 | |
| 268 | 268 | $user = new WP_User($user_id); |
| 269 | - $wpdb->update( $wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email') ); |
|
| 269 | + $wpdb->update($wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email')); |
|
| 270 | 270 | |
| 271 | 271 | // Remove all perms except for the login user. |
| 272 | - $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'user_level') ); |
|
| 273 | - $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities') ); |
|
| 272 | + $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'user_level')); |
|
| 273 | + $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities')); |
|
| 274 | 274 | |
| 275 | 275 | // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id. |
| 276 | - if ( !is_super_admin( $user_id ) && $user_id != 1 ) |
|
| 277 | - $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) ); |
|
| 276 | + if ( ! is_super_admin($user_id) && $user_id != 1) |
|
| 277 | + $wpdb->delete($wpdb->usermeta, array('user_id' => $user_id, 'meta_key' => $wpdb->base_prefix.'1_capabilities')); |
|
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | endif; |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | global $wp_rewrite; |
| 295 | 295 | |
| 296 | 296 | // Bail if a permalink structure is already enabled. |
| 297 | - if ( get_option( 'permalink_structure' ) ) { |
|
| 297 | + if (get_option('permalink_structure')) { |
|
| 298 | 298 | return true; |
| 299 | 299 | } |
| 300 | 300 | |
@@ -311,21 +311,21 @@ discard block |
||
| 311 | 311 | '/index.php/%year%/%monthnum%/%day%/%postname%/' |
| 312 | 312 | ); |
| 313 | 313 | |
| 314 | - foreach ( (array) $permalink_structures as $permalink_structure ) { |
|
| 315 | - $wp_rewrite->set_permalink_structure( $permalink_structure ); |
|
| 314 | + foreach ((array) $permalink_structures as $permalink_structure) { |
|
| 315 | + $wp_rewrite->set_permalink_structure($permalink_structure); |
|
| 316 | 316 | |
| 317 | 317 | /* |
| 318 | 318 | * Flush rules with the hard option to force refresh of the web-server's |
| 319 | 319 | * rewrite config file (e.g. .htaccess or web.config). |
| 320 | 320 | */ |
| 321 | - $wp_rewrite->flush_rules( true ); |
|
| 321 | + $wp_rewrite->flush_rules(true); |
|
| 322 | 322 | |
| 323 | 323 | $test_url = ''; |
| 324 | 324 | |
| 325 | 325 | // Test against a real WordPress Post |
| 326 | - $first_post = get_page_by_path( sanitize_title( _x( 'hello-world', 'Default post slug' ) ), OBJECT, 'post' ); |
|
| 327 | - if ( $first_post ) { |
|
| 328 | - $test_url = get_permalink( $first_post->ID ); |
|
| 326 | + $first_post = get_page_by_path(sanitize_title(_x('hello-world', 'Default post slug')), OBJECT, 'post'); |
|
| 327 | + if ($first_post) { |
|
| 328 | + $test_url = get_permalink($first_post->ID); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | /* |
@@ -335,11 +335,11 @@ discard block |
||
| 335 | 335 | * Uses wp_remote_get() instead of wp_remote_head() because web servers |
| 336 | 336 | * can block head requests. |
| 337 | 337 | */ |
| 338 | - $response = wp_remote_get( $test_url, array( 'timeout' => 5 ) ); |
|
| 339 | - $x_pingback_header = wp_remote_retrieve_header( $response, 'x-pingback' ); |
|
| 340 | - $pretty_permalinks = $x_pingback_header && $x_pingback_header === get_bloginfo( 'pingback_url' ); |
|
| 338 | + $response = wp_remote_get($test_url, array('timeout' => 5)); |
|
| 339 | + $x_pingback_header = wp_remote_retrieve_header($response, 'x-pingback'); |
|
| 340 | + $pretty_permalinks = $x_pingback_header && $x_pingback_header === get_bloginfo('pingback_url'); |
|
| 341 | 341 | |
| 342 | - if ( $pretty_permalinks ) { |
|
| 342 | + if ($pretty_permalinks) { |
|
| 343 | 343 | return true; |
| 344 | 344 | } |
| 345 | 345 | } |
@@ -348,13 +348,13 @@ discard block |
||
| 348 | 348 | * If it makes it this far, pretty permalinks failed. |
| 349 | 349 | * Fallback to query-string permalinks. |
| 350 | 350 | */ |
| 351 | - $wp_rewrite->set_permalink_structure( '' ); |
|
| 352 | - $wp_rewrite->flush_rules( true ); |
|
| 351 | + $wp_rewrite->set_permalink_structure(''); |
|
| 352 | + $wp_rewrite->flush_rules(true); |
|
| 353 | 353 | |
| 354 | 354 | return false; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | -if ( !function_exists('wp_new_blog_notification') ) : |
|
| 357 | +if ( ! function_exists('wp_new_blog_notification')) : |
|
| 358 | 358 | /** |
| 359 | 359 | * Notifies the site admin that the setup is complete. |
| 360 | 360 | * |
@@ -369,11 +369,11 @@ discard block |
||
| 369 | 369 | * @param string $password User's Password. |
| 370 | 370 | */ |
| 371 | 371 | function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) { |
| 372 | - $user = new WP_User( $user_id ); |
|
| 372 | + $user = new WP_User($user_id); |
|
| 373 | 373 | $email = $user->user_email; |
| 374 | 374 | $name = $user->user_login; |
| 375 | 375 | $login_url = wp_login_url(); |
| 376 | - $message = sprintf( __( "Your new WordPress site has been successfully set up at: |
|
| 376 | + $message = sprintf(__("Your new WordPress site has been successfully set up at: |
|
| 377 | 377 | |
| 378 | 378 | %1\$s |
| 379 | 379 | |
@@ -387,13 +387,13 @@ discard block |
||
| 387 | 387 | |
| 388 | 388 | --The WordPress Team |
| 389 | 389 | https://wordpress.org/ |
| 390 | -"), $blog_url, $name, $password, $login_url ); |
|
| 390 | +"), $blog_url, $name, $password, $login_url); |
|
| 391 | 391 | |
| 392 | 392 | @wp_mail($email, __('New WordPress Site'), $message); |
| 393 | 393 | } |
| 394 | 394 | endif; |
| 395 | 395 | |
| 396 | -if ( !function_exists('wp_upgrade') ) : |
|
| 396 | +if ( ! function_exists('wp_upgrade')) : |
|
| 397 | 397 | /** |
| 398 | 398 | * Runs WordPress Upgrade functions. |
| 399 | 399 | * |
@@ -411,10 +411,10 @@ discard block |
||
| 411 | 411 | $wp_current_db_version = __get_option('db_version'); |
| 412 | 412 | |
| 413 | 413 | // We are up-to-date. Nothing to do. |
| 414 | - if ( $wp_db_version == $wp_current_db_version ) |
|
| 414 | + if ($wp_db_version == $wp_current_db_version) |
|
| 415 | 415 | return; |
| 416 | 416 | |
| 417 | - if ( ! is_blog_installed() ) |
|
| 417 | + if ( ! is_blog_installed()) |
|
| 418 | 418 | return; |
| 419 | 419 | |
| 420 | 420 | wp_check_mysql_version(); |
@@ -422,15 +422,15 @@ discard block |
||
| 422 | 422 | pre_schema_upgrade(); |
| 423 | 423 | make_db_current_silent(); |
| 424 | 424 | upgrade_all(); |
| 425 | - if ( is_multisite() && is_main_site() ) |
|
| 425 | + if (is_multisite() && is_main_site()) |
|
| 426 | 426 | upgrade_network(); |
| 427 | 427 | wp_cache_flush(); |
| 428 | 428 | |
| 429 | - if ( is_multisite() ) { |
|
| 430 | - if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) ) |
|
| 431 | - $wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" ); |
|
| 429 | + if (is_multisite()) { |
|
| 430 | + if ($wpdb->get_row("SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'")) |
|
| 431 | + $wpdb->query("UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'"); |
|
| 432 | 432 | else |
| 433 | - $wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" ); |
|
| 433 | + $wpdb->query("INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());"); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | /** |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | * @param int $wp_db_version The new $wp_db_version. |
| 442 | 442 | * @param int $wp_current_db_version The old (current) $wp_db_version. |
| 443 | 443 | */ |
| 444 | - do_action( 'wp_upgrade', $wp_db_version, $wp_current_db_version ); |
|
| 444 | + do_action('wp_upgrade', $wp_db_version, $wp_current_db_version); |
|
| 445 | 445 | } |
| 446 | 446 | endif; |
| 447 | 447 | |
@@ -462,109 +462,109 @@ discard block |
||
| 462 | 462 | $wp_current_db_version = __get_option('db_version'); |
| 463 | 463 | |
| 464 | 464 | // We are up-to-date. Nothing to do. |
| 465 | - if ( $wp_db_version == $wp_current_db_version ) |
|
| 465 | + if ($wp_db_version == $wp_current_db_version) |
|
| 466 | 466 | return; |
| 467 | 467 | |
| 468 | 468 | // If the version is not set in the DB, try to guess the version. |
| 469 | - if ( empty($wp_current_db_version) ) { |
|
| 469 | + if (empty($wp_current_db_version)) { |
|
| 470 | 470 | $wp_current_db_version = 0; |
| 471 | 471 | |
| 472 | 472 | // If the template option exists, we have 1.5. |
| 473 | 473 | $template = __get_option('template'); |
| 474 | - if ( !empty($template) ) |
|
| 474 | + if ( ! empty($template)) |
|
| 475 | 475 | $wp_current_db_version = 2541; |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | - if ( $wp_current_db_version < 6039 ) |
|
| 478 | + if ($wp_current_db_version < 6039) |
|
| 479 | 479 | upgrade_230_options_table(); |
| 480 | 480 | |
| 481 | 481 | populate_options(); |
| 482 | 482 | |
| 483 | - if ( $wp_current_db_version < 2541 ) { |
|
| 483 | + if ($wp_current_db_version < 2541) { |
|
| 484 | 484 | upgrade_100(); |
| 485 | 485 | upgrade_101(); |
| 486 | 486 | upgrade_110(); |
| 487 | 487 | upgrade_130(); |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - if ( $wp_current_db_version < 3308 ) |
|
| 490 | + if ($wp_current_db_version < 3308) |
|
| 491 | 491 | upgrade_160(); |
| 492 | 492 | |
| 493 | - if ( $wp_current_db_version < 4772 ) |
|
| 493 | + if ($wp_current_db_version < 4772) |
|
| 494 | 494 | upgrade_210(); |
| 495 | 495 | |
| 496 | - if ( $wp_current_db_version < 4351 ) |
|
| 496 | + if ($wp_current_db_version < 4351) |
|
| 497 | 497 | upgrade_old_slugs(); |
| 498 | 498 | |
| 499 | - if ( $wp_current_db_version < 5539 ) |
|
| 499 | + if ($wp_current_db_version < 5539) |
|
| 500 | 500 | upgrade_230(); |
| 501 | 501 | |
| 502 | - if ( $wp_current_db_version < 6124 ) |
|
| 502 | + if ($wp_current_db_version < 6124) |
|
| 503 | 503 | upgrade_230_old_tables(); |
| 504 | 504 | |
| 505 | - if ( $wp_current_db_version < 7499 ) |
|
| 505 | + if ($wp_current_db_version < 7499) |
|
| 506 | 506 | upgrade_250(); |
| 507 | 507 | |
| 508 | - if ( $wp_current_db_version < 7935 ) |
|
| 508 | + if ($wp_current_db_version < 7935) |
|
| 509 | 509 | upgrade_252(); |
| 510 | 510 | |
| 511 | - if ( $wp_current_db_version < 8201 ) |
|
| 511 | + if ($wp_current_db_version < 8201) |
|
| 512 | 512 | upgrade_260(); |
| 513 | 513 | |
| 514 | - if ( $wp_current_db_version < 8989 ) |
|
| 514 | + if ($wp_current_db_version < 8989) |
|
| 515 | 515 | upgrade_270(); |
| 516 | 516 | |
| 517 | - if ( $wp_current_db_version < 10360 ) |
|
| 517 | + if ($wp_current_db_version < 10360) |
|
| 518 | 518 | upgrade_280(); |
| 519 | 519 | |
| 520 | - if ( $wp_current_db_version < 11958 ) |
|
| 520 | + if ($wp_current_db_version < 11958) |
|
| 521 | 521 | upgrade_290(); |
| 522 | 522 | |
| 523 | - if ( $wp_current_db_version < 15260 ) |
|
| 523 | + if ($wp_current_db_version < 15260) |
|
| 524 | 524 | upgrade_300(); |
| 525 | 525 | |
| 526 | - if ( $wp_current_db_version < 19389 ) |
|
| 526 | + if ($wp_current_db_version < 19389) |
|
| 527 | 527 | upgrade_330(); |
| 528 | 528 | |
| 529 | - if ( $wp_current_db_version < 20080 ) |
|
| 529 | + if ($wp_current_db_version < 20080) |
|
| 530 | 530 | upgrade_340(); |
| 531 | 531 | |
| 532 | - if ( $wp_current_db_version < 22422 ) |
|
| 532 | + if ($wp_current_db_version < 22422) |
|
| 533 | 533 | upgrade_350(); |
| 534 | 534 | |
| 535 | - if ( $wp_current_db_version < 25824 ) |
|
| 535 | + if ($wp_current_db_version < 25824) |
|
| 536 | 536 | upgrade_370(); |
| 537 | 537 | |
| 538 | - if ( $wp_current_db_version < 26148 ) |
|
| 538 | + if ($wp_current_db_version < 26148) |
|
| 539 | 539 | upgrade_372(); |
| 540 | 540 | |
| 541 | - if ( $wp_current_db_version < 26691 ) |
|
| 541 | + if ($wp_current_db_version < 26691) |
|
| 542 | 542 | upgrade_380(); |
| 543 | 543 | |
| 544 | - if ( $wp_current_db_version < 29630 ) |
|
| 544 | + if ($wp_current_db_version < 29630) |
|
| 545 | 545 | upgrade_400(); |
| 546 | 546 | |
| 547 | - if ( $wp_current_db_version < 33055 ) |
|
| 547 | + if ($wp_current_db_version < 33055) |
|
| 548 | 548 | upgrade_430(); |
| 549 | 549 | |
| 550 | - if ( $wp_current_db_version < 33056 ) |
|
| 550 | + if ($wp_current_db_version < 33056) |
|
| 551 | 551 | upgrade_431(); |
| 552 | 552 | |
| 553 | - if ( $wp_current_db_version < 35700 ) |
|
| 553 | + if ($wp_current_db_version < 35700) |
|
| 554 | 554 | upgrade_440(); |
| 555 | 555 | |
| 556 | - if ( $wp_current_db_version < 36686 ) |
|
| 556 | + if ($wp_current_db_version < 36686) |
|
| 557 | 557 | upgrade_450(); |
| 558 | 558 | |
| 559 | - if ( $wp_current_db_version < 37965 ) |
|
| 559 | + if ($wp_current_db_version < 37965) |
|
| 560 | 560 | upgrade_460(); |
| 561 | 561 | |
| 562 | 562 | maybe_disable_link_manager(); |
| 563 | 563 | |
| 564 | 564 | maybe_disable_automattic_widgets(); |
| 565 | 565 | |
| 566 | - update_option( 'db_version', $wp_db_version ); |
|
| 567 | - update_option( 'db_upgraded', true ); |
|
| 566 | + update_option('db_version', $wp_db_version); |
|
| 567 | + update_option('db_upgraded', true); |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | /** |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | foreach ($posts as $post) { |
| 585 | 585 | if ('' == $post->post_name) { |
| 586 | 586 | $newtitle = sanitize_title($post->post_title); |
| 587 | - $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID) ); |
|
| 587 | + $wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID)); |
|
| 588 | 588 | } |
| 589 | 589 | } |
| 590 | 590 | } |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | foreach ($categories as $category) { |
| 594 | 594 | if ('' == $category->category_nicename) { |
| 595 | 595 | $newtitle = sanitize_title($category->cat_name); |
| 596 | - $wpdb->update( $wpdb->categories, array('category_nicename' => $newtitle), array('cat_ID' => $category->cat_ID) ); |
|
| 596 | + $wpdb->update($wpdb->categories, array('category_nicename' => $newtitle), array('cat_ID' => $category->cat_ID)); |
|
| 597 | 597 | } |
| 598 | 598 | } |
| 599 | 599 | |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | SET option_value = REPLACE(option_value, 'wp-links/links-images/', 'wp-images/links/') |
| 602 | 602 | WHERE option_name LIKE %s |
| 603 | 603 | AND option_value LIKE %s"; |
| 604 | - $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( 'links_rating_image' ) . '%', $wpdb->esc_like( 'wp-links/links-images/' ) . '%' ) ); |
|
| 604 | + $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('links_rating_image').'%', $wpdb->esc_like('wp-links/links-images/').'%')); |
|
| 605 | 605 | |
| 606 | 606 | $done_ids = $wpdb->get_results("SELECT DISTINCT post_id FROM $wpdb->post2cat"); |
| 607 | 607 | if ($done_ids) : |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | foreach ($done_ids as $done_id) : |
| 610 | 610 | $done_posts[] = $done_id->post_id; |
| 611 | 611 | endforeach; |
| 612 | - $catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')'; |
|
| 612 | + $catwhere = ' AND ID NOT IN ('.implode(',', $done_posts).')'; |
|
| 613 | 613 | else: |
| 614 | 614 | $catwhere = ''; |
| 615 | 615 | endif; |
@@ -618,9 +618,9 @@ discard block |
||
| 618 | 618 | if ($allposts) : |
| 619 | 619 | foreach ($allposts as $post) { |
| 620 | 620 | // Check to see if it's already been imported |
| 621 | - $cat = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category) ); |
|
| 622 | - if (!$cat && 0 != $post->post_category) { // If there's no result |
|
| 623 | - $wpdb->insert( $wpdb->post2cat, array('post_id' => $post->ID, 'category_id' => $post->post_category) ); |
|
| 621 | + $cat = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category)); |
|
| 622 | + if ( ! $cat && 0 != $post->post_category) { // If there's no result |
|
| 623 | + $wpdb->insert($wpdb->post2cat, array('post_id' => $post->ID, 'category_id' => $post->post_category)); |
|
| 624 | 624 | } |
| 625 | 625 | } |
| 626 | 626 | endif; |
@@ -643,8 +643,8 @@ discard block |
||
| 643 | 643 | add_clean_index($wpdb->categories, 'category_nicename'); |
| 644 | 644 | add_clean_index($wpdb->comments, 'comment_approved'); |
| 645 | 645 | add_clean_index($wpdb->comments, 'comment_post_ID'); |
| 646 | - add_clean_index($wpdb->links , 'link_category'); |
|
| 647 | - add_clean_index($wpdb->links , 'link_visible'); |
|
| 646 | + add_clean_index($wpdb->links, 'link_category'); |
|
| 647 | + add_clean_index($wpdb->links, 'link_visible'); |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | /** |
@@ -663,14 +663,14 @@ discard block |
||
| 663 | 663 | foreach ($users as $user) { |
| 664 | 664 | if ('' == $user->user_nicename) { |
| 665 | 665 | $newname = sanitize_title($user->user_nickname); |
| 666 | - $wpdb->update( $wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID) ); |
|
| 666 | + $wpdb->update($wpdb->users, array('user_nicename' => $newname), array('ID' => $user->ID)); |
|
| 667 | 667 | } |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | $users = $wpdb->get_results("SELECT ID, user_pass from $wpdb->users"); |
| 671 | 671 | foreach ($users as $row) { |
| 672 | - if (!preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) { |
|
| 673 | - $wpdb->update( $wpdb->users, array('user_pass' => md5($row->user_pass)), array('ID' => $row->ID) ); |
|
| 672 | + if ( ! preg_match('/^[A-Fa-f0-9]{32}$/', $row->user_pass)) { |
|
| 673 | + $wpdb->update($wpdb->users, array('user_pass' => md5($row->user_pass)), array('ID' => $row->ID)); |
|
| 674 | 674 | } |
| 675 | 675 | } |
| 676 | 676 | |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | |
| 680 | 680 | $time_difference = $all_options->time_difference; |
| 681 | 681 | |
| 682 | - $server_time = time()+date('Z'); |
|
| 682 | + $server_time = time() + date('Z'); |
|
| 683 | 683 | $weblogger_time = $server_time + $time_difference * HOUR_IN_SECONDS; |
| 684 | 684 | $gmt_time = time(); |
| 685 | 685 | |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | // <michel_v> I just slapped myself silly for not thinking about it earlier |
| 697 | 697 | $got_gmt_fields = ! ($wpdb->get_var("SELECT MAX(post_date_gmt) FROM $wpdb->posts") == '0000-00-00 00:00:00'); |
| 698 | 698 | |
| 699 | - if (!$got_gmt_fields) { |
|
| 699 | + if ( ! $got_gmt_fields) { |
|
| 700 | 700 | |
| 701 | 701 | // Add or subtract time to all dates, to get GMT dates |
| 702 | 702 | $add_hours = intval($diff_gmt_weblogger); |
@@ -728,12 +728,12 @@ discard block |
||
| 728 | 728 | $post_content = addslashes(deslash($post->post_content)); |
| 729 | 729 | $post_title = addslashes(deslash($post->post_title)); |
| 730 | 730 | $post_excerpt = addslashes(deslash($post->post_excerpt)); |
| 731 | - if ( empty($post->guid) ) |
|
| 731 | + if (empty($post->guid)) |
|
| 732 | 732 | $guid = get_permalink($post->ID); |
| 733 | 733 | else |
| 734 | 734 | $guid = $post->guid; |
| 735 | 735 | |
| 736 | - $wpdb->update( $wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID) ); |
|
| 736 | + $wpdb->update($wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID)); |
|
| 737 | 737 | |
| 738 | 738 | } |
| 739 | 739 | } |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | $comment_content = deslash($comment->comment_content); |
| 746 | 746 | $comment_author = deslash($comment->comment_author); |
| 747 | 747 | |
| 748 | - $wpdb->update($wpdb->comments, compact('comment_content', 'comment_author'), array('comment_ID' => $comment->comment_ID) ); |
|
| 748 | + $wpdb->update($wpdb->comments, compact('comment_content', 'comment_author'), array('comment_ID' => $comment->comment_ID)); |
|
| 749 | 749 | } |
| 750 | 750 | } |
| 751 | 751 | |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | $link_name = deslash($link->link_name); |
| 757 | 757 | $link_description = deslash($link->link_description); |
| 758 | 758 | |
| 759 | - $wpdb->update( $wpdb->links, compact('link_name', 'link_description'), array('link_id' => $link->link_id) ); |
|
| 759 | + $wpdb->update($wpdb->links, compact('link_name', 'link_description'), array('link_id' => $link->link_id)); |
|
| 760 | 760 | } |
| 761 | 761 | } |
| 762 | 762 | |
@@ -766,16 +766,16 @@ discard block |
||
| 766 | 766 | * If plugins are not stored in an array, they're stored in the old |
| 767 | 767 | * newline separated format. Convert to new format. |
| 768 | 768 | */ |
| 769 | - if ( !is_array( $active_plugins ) ) { |
|
| 769 | + if ( ! is_array($active_plugins)) { |
|
| 770 | 770 | $active_plugins = explode("\n", trim($active_plugins)); |
| 771 | 771 | update_option('active_plugins', $active_plugins); |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | // Obsolete tables |
| 775 | - $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues'); |
|
| 776 | - $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes'); |
|
| 777 | - $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups'); |
|
| 778 | - $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options'); |
|
| 775 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optionvalues'); |
|
| 776 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optiontypes'); |
|
| 777 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optiongroups'); |
|
| 778 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'optiongroup_options'); |
|
| 779 | 779 | |
| 780 | 780 | // Update comments table to use comment_type |
| 781 | 781 | $wpdb->query("UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'"); |
@@ -783,11 +783,11 @@ discard block |
||
| 783 | 783 | |
| 784 | 784 | // Some versions have multiple duplicate option_name rows with the same values |
| 785 | 785 | $options = $wpdb->get_results("SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name"); |
| 786 | - foreach ( $options as $option ) { |
|
| 787 | - if ( 1 != $option->dupes ) { // Could this be done in the query? |
|
| 786 | + foreach ($options as $option) { |
|
| 787 | + if (1 != $option->dupes) { // Could this be done in the query? |
|
| 788 | 788 | $limit = $option->dupes - 1; |
| 789 | - $dupe_ids = $wpdb->get_col( $wpdb->prepare("SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit) ); |
|
| 790 | - if ( $dupe_ids ) { |
|
| 789 | + $dupe_ids = $wpdb->get_col($wpdb->prepare("SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit)); |
|
| 790 | + if ($dupe_ids) { |
|
| 791 | 791 | $dupe_ids = join($dupe_ids, ','); |
| 792 | 792 | $wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)"); |
| 793 | 793 | } |
@@ -812,27 +812,27 @@ discard block |
||
| 812 | 812 | populate_roles_160(); |
| 813 | 813 | |
| 814 | 814 | $users = $wpdb->get_results("SELECT * FROM $wpdb->users"); |
| 815 | - foreach ( $users as $user ) : |
|
| 816 | - if ( !empty( $user->user_firstname ) ) |
|
| 817 | - update_user_meta( $user->ID, 'first_name', wp_slash($user->user_firstname) ); |
|
| 818 | - if ( !empty( $user->user_lastname ) ) |
|
| 819 | - update_user_meta( $user->ID, 'last_name', wp_slash($user->user_lastname) ); |
|
| 820 | - if ( !empty( $user->user_nickname ) ) |
|
| 821 | - update_user_meta( $user->ID, 'nickname', wp_slash($user->user_nickname) ); |
|
| 822 | - if ( !empty( $user->user_level ) ) |
|
| 823 | - update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level ); |
|
| 824 | - if ( !empty( $user->user_icq ) ) |
|
| 825 | - update_user_meta( $user->ID, 'icq', wp_slash($user->user_icq) ); |
|
| 826 | - if ( !empty( $user->user_aim ) ) |
|
| 827 | - update_user_meta( $user->ID, 'aim', wp_slash($user->user_aim) ); |
|
| 828 | - if ( !empty( $user->user_msn ) ) |
|
| 829 | - update_user_meta( $user->ID, 'msn', wp_slash($user->user_msn) ); |
|
| 830 | - if ( !empty( $user->user_yim ) ) |
|
| 831 | - update_user_meta( $user->ID, 'yim', wp_slash($user->user_icq) ); |
|
| 832 | - if ( !empty( $user->user_description ) ) |
|
| 833 | - update_user_meta( $user->ID, 'description', wp_slash($user->user_description) ); |
|
| 834 | - |
|
| 835 | - if ( isset( $user->user_idmode ) ): |
|
| 815 | + foreach ($users as $user) : |
|
| 816 | + if ( ! empty($user->user_firstname)) |
|
| 817 | + update_user_meta($user->ID, 'first_name', wp_slash($user->user_firstname)); |
|
| 818 | + if ( ! empty($user->user_lastname)) |
|
| 819 | + update_user_meta($user->ID, 'last_name', wp_slash($user->user_lastname)); |
|
| 820 | + if ( ! empty($user->user_nickname)) |
|
| 821 | + update_user_meta($user->ID, 'nickname', wp_slash($user->user_nickname)); |
|
| 822 | + if ( ! empty($user->user_level)) |
|
| 823 | + update_user_meta($user->ID, $wpdb->prefix.'user_level', $user->user_level); |
|
| 824 | + if ( ! empty($user->user_icq)) |
|
| 825 | + update_user_meta($user->ID, 'icq', wp_slash($user->user_icq)); |
|
| 826 | + if ( ! empty($user->user_aim)) |
|
| 827 | + update_user_meta($user->ID, 'aim', wp_slash($user->user_aim)); |
|
| 828 | + if ( ! empty($user->user_msn)) |
|
| 829 | + update_user_meta($user->ID, 'msn', wp_slash($user->user_msn)); |
|
| 830 | + if ( ! empty($user->user_yim)) |
|
| 831 | + update_user_meta($user->ID, 'yim', wp_slash($user->user_icq)); |
|
| 832 | + if ( ! empty($user->user_description)) |
|
| 833 | + update_user_meta($user->ID, 'description', wp_slash($user->user_description)); |
|
| 834 | + |
|
| 835 | + if (isset($user->user_idmode)): |
|
| 836 | 836 | $idmode = $user->user_idmode; |
| 837 | 837 | if ($idmode == 'nickname') $id = $user->user_nickname; |
| 838 | 838 | if ($idmode == 'login') $id = $user->user_login; |
@@ -840,46 +840,46 @@ discard block |
||
| 840 | 840 | if ($idmode == 'lastname') $id = $user->user_lastname; |
| 841 | 841 | if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname; |
| 842 | 842 | if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname; |
| 843 | - if (!$idmode) $id = $user->user_nickname; |
|
| 844 | - $wpdb->update( $wpdb->users, array('display_name' => $id), array('ID' => $user->ID) ); |
|
| 843 | + if ( ! $idmode) $id = $user->user_nickname; |
|
| 844 | + $wpdb->update($wpdb->users, array('display_name' => $id), array('ID' => $user->ID)); |
|
| 845 | 845 | endif; |
| 846 | 846 | |
| 847 | 847 | // FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set. |
| 848 | - $caps = get_user_meta( $user->ID, $wpdb->prefix . 'capabilities'); |
|
| 849 | - if ( empty($caps) || defined('RESET_CAPS') ) { |
|
| 850 | - $level = get_user_meta($user->ID, $wpdb->prefix . 'user_level', true); |
|
| 848 | + $caps = get_user_meta($user->ID, $wpdb->prefix.'capabilities'); |
|
| 849 | + if (empty($caps) || defined('RESET_CAPS')) { |
|
| 850 | + $level = get_user_meta($user->ID, $wpdb->prefix.'user_level', true); |
|
| 851 | 851 | $role = translate_level_to_role($level); |
| 852 | - update_user_meta( $user->ID, $wpdb->prefix . 'capabilities', array($role => true) ); |
|
| 852 | + update_user_meta($user->ID, $wpdb->prefix.'capabilities', array($role => true)); |
|
| 853 | 853 | } |
| 854 | 854 | |
| 855 | 855 | endforeach; |
| 856 | - $old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' ); |
|
| 856 | + $old_user_fields = array('user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level'); |
|
| 857 | 857 | $wpdb->hide_errors(); |
| 858 | - foreach ( $old_user_fields as $old ) |
|
| 858 | + foreach ($old_user_fields as $old) |
|
| 859 | 859 | $wpdb->query("ALTER TABLE $wpdb->users DROP $old"); |
| 860 | 860 | $wpdb->show_errors(); |
| 861 | 861 | |
| 862 | 862 | // Populate comment_count field of posts table. |
| 863 | - $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" ); |
|
| 864 | - if ( is_array( $comments ) ) |
|
| 863 | + $comments = $wpdb->get_results("SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID"); |
|
| 864 | + if (is_array($comments)) |
|
| 865 | 865 | foreach ($comments as $comment) |
| 866 | - $wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) ); |
|
| 866 | + $wpdb->update($wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID)); |
|
| 867 | 867 | |
| 868 | 868 | /* |
| 869 | 869 | * Some alpha versions used a post status of object instead of attachment |
| 870 | 870 | * and put the mime type in post_type instead of post_mime_type. |
| 871 | 871 | */ |
| 872 | - if ( $wp_current_db_version > 2541 && $wp_current_db_version <= 3091 ) { |
|
| 872 | + if ($wp_current_db_version > 2541 && $wp_current_db_version <= 3091) { |
|
| 873 | 873 | $objects = $wpdb->get_results("SELECT ID, post_type FROM $wpdb->posts WHERE post_status = 'object'"); |
| 874 | 874 | foreach ($objects as $object) { |
| 875 | - $wpdb->update( $wpdb->posts, array( 'post_status' => 'attachment', |
|
| 875 | + $wpdb->update($wpdb->posts, array('post_status' => 'attachment', |
|
| 876 | 876 | 'post_mime_type' => $object->post_type, |
| 877 | 877 | 'post_type' => ''), |
| 878 | - array( 'ID' => $object->ID ) ); |
|
| 878 | + array('ID' => $object->ID)); |
|
| 879 | 879 | |
| 880 | 880 | $meta = get_post_meta($object->ID, 'imagedata', true); |
| 881 | - if ( ! empty($meta['file']) ) |
|
| 882 | - update_attached_file( $object->ID, $meta['file'] ); |
|
| 881 | + if ( ! empty($meta['file'])) |
|
| 882 | + update_attached_file($object->ID, $meta['file']); |
|
| 883 | 883 | } |
| 884 | 884 | } |
| 885 | 885 | } |
@@ -896,38 +896,38 @@ discard block |
||
| 896 | 896 | function upgrade_210() { |
| 897 | 897 | global $wpdb, $wp_current_db_version; |
| 898 | 898 | |
| 899 | - if ( $wp_current_db_version < 3506 ) { |
|
| 899 | + if ($wp_current_db_version < 3506) { |
|
| 900 | 900 | // Update status and type. |
| 901 | 901 | $posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts"); |
| 902 | 902 | |
| 903 | - if ( ! empty($posts) ) foreach ($posts as $post) { |
|
| 903 | + if ( ! empty($posts)) foreach ($posts as $post) { |
|
| 904 | 904 | $status = $post->post_status; |
| 905 | 905 | $type = 'post'; |
| 906 | 906 | |
| 907 | - if ( 'static' == $status ) { |
|
| 907 | + if ('static' == $status) { |
|
| 908 | 908 | $status = 'publish'; |
| 909 | 909 | $type = 'page'; |
| 910 | - } elseif ( 'attachment' == $status ) { |
|
| 910 | + } elseif ('attachment' == $status) { |
|
| 911 | 911 | $status = 'inherit'; |
| 912 | 912 | $type = 'attachment'; |
| 913 | 913 | } |
| 914 | 914 | |
| 915 | - $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID) ); |
|
| 915 | + $wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID)); |
|
| 916 | 916 | } |
| 917 | 917 | } |
| 918 | 918 | |
| 919 | - if ( $wp_current_db_version < 3845 ) { |
|
| 919 | + if ($wp_current_db_version < 3845) { |
|
| 920 | 920 | populate_roles_210(); |
| 921 | 921 | } |
| 922 | 922 | |
| 923 | - if ( $wp_current_db_version < 3531 ) { |
|
| 923 | + if ($wp_current_db_version < 3531) { |
|
| 924 | 924 | // Give future posts a post_status of future. |
| 925 | 925 | $now = gmdate('Y-m-d H:i:59'); |
| 926 | - $wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'"); |
|
| 926 | + $wpdb->query("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'"); |
|
| 927 | 927 | |
| 928 | 928 | $posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'"); |
| 929 | - if ( !empty($posts) ) |
|
| 930 | - foreach ( $posts as $post ) |
|
| 929 | + if ( ! empty($posts)) |
|
| 930 | + foreach ($posts as $post) |
|
| 931 | 931 | wp_schedule_single_event(mysql2date('U', $post->post_date, false), 'publish_future_post', array($post->ID)); |
| 932 | 932 | } |
| 933 | 933 | } |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | function upgrade_230() { |
| 945 | 945 | global $wp_current_db_version, $wpdb; |
| 946 | 946 | |
| 947 | - if ( $wp_current_db_version < 5200 ) { |
|
| 947 | + if ($wp_current_db_version < 5200) { |
|
| 948 | 948 | populate_roles_230(); |
| 949 | 949 | } |
| 950 | 950 | |
@@ -961,78 +961,78 @@ discard block |
||
| 961 | 961 | $term_group = 0; |
| 962 | 962 | |
| 963 | 963 | // Associate terms with the same slug in a term group and make slugs unique. |
| 964 | - if ( $exists = $wpdb->get_results( $wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug) ) ) { |
|
| 964 | + if ($exists = $wpdb->get_results($wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug))) { |
|
| 965 | 965 | $term_group = $exists[0]->term_group; |
| 966 | 966 | $id = $exists[0]->term_id; |
| 967 | 967 | $num = 2; |
| 968 | 968 | do { |
| 969 | - $alt_slug = $slug . "-$num"; |
|
| 969 | + $alt_slug = $slug."-$num"; |
|
| 970 | 970 | $num++; |
| 971 | - $slug_check = $wpdb->get_var( $wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug) ); |
|
| 972 | - } while ( $slug_check ); |
|
| 971 | + $slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug)); |
|
| 972 | + } while ($slug_check); |
|
| 973 | 973 | |
| 974 | 974 | $slug = $alt_slug; |
| 975 | 975 | |
| 976 | - if ( empty( $term_group ) ) { |
|
| 976 | + if (empty($term_group)) { |
|
| 977 | 977 | $term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms GROUP BY term_group") + 1; |
| 978 | - $wpdb->query( $wpdb->prepare("UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $id) ); |
|
| 978 | + $wpdb->query($wpdb->prepare("UPDATE $wpdb->terms SET term_group = %d WHERE term_id = %d", $term_group, $id)); |
|
| 979 | 979 | } |
| 980 | 980 | } |
| 981 | 981 | |
| 982 | - $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES |
|
| 983 | - (%d, %s, %s, %d)", $term_id, $name, $slug, $term_group) ); |
|
| 982 | + $wpdb->query($wpdb->prepare("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES |
|
| 983 | + (%d, %s, %s, %d)", $term_id, $name, $slug, $term_group)); |
|
| 984 | 984 | |
| 985 | 985 | $count = 0; |
| 986 | - if ( !empty($category->category_count) ) { |
|
| 986 | + if ( ! empty($category->category_count)) { |
|
| 987 | 987 | $count = (int) $category->category_count; |
| 988 | 988 | $taxonomy = 'category'; |
| 989 | - $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) ); |
|
| 989 | + $wpdb->query($wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count)); |
|
| 990 | 990 | $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; |
| 991 | 991 | } |
| 992 | 992 | |
| 993 | - if ( !empty($category->link_count) ) { |
|
| 993 | + if ( ! empty($category->link_count)) { |
|
| 994 | 994 | $count = (int) $category->link_count; |
| 995 | 995 | $taxonomy = 'link_category'; |
| 996 | - $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count) ); |
|
| 996 | + $wpdb->query($wpdb->prepare("INSERT INTO $wpdb->term_taxonomy (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, $count)); |
|
| 997 | 997 | $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; |
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | - if ( !empty($category->tag_count) ) { |
|
| 1000 | + if ( ! empty($category->tag_count)) { |
|
| 1001 | 1001 | $have_tags = true; |
| 1002 | 1002 | $count = (int) $category->tag_count; |
| 1003 | 1003 | $taxonomy = 'post_tag'; |
| 1004 | - $wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') ); |
|
| 1004 | + $wpdb->insert($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count')); |
|
| 1005 | 1005 | $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; |
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | - if ( empty($count) ) { |
|
| 1008 | + if (empty($count)) { |
|
| 1009 | 1009 | $count = 0; |
| 1010 | 1010 | $taxonomy = 'category'; |
| 1011 | - $wpdb->insert( $wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count') ); |
|
| 1011 | + $wpdb->insert($wpdb->term_taxonomy, compact('term_id', 'taxonomy', 'description', 'parent', 'count')); |
|
| 1012 | 1012 | $tt_ids[$term_id][$taxonomy] = (int) $wpdb->insert_id; |
| 1013 | 1013 | } |
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | 1016 | $select = 'post_id, category_id'; |
| 1017 | - if ( $have_tags ) |
|
| 1017 | + if ($have_tags) |
|
| 1018 | 1018 | $select .= ', rel_type'; |
| 1019 | 1019 | |
| 1020 | 1020 | $posts = $wpdb->get_results("SELECT $select FROM $wpdb->post2cat GROUP BY post_id, category_id"); |
| 1021 | - foreach ( $posts as $post ) { |
|
| 1021 | + foreach ($posts as $post) { |
|
| 1022 | 1022 | $post_id = (int) $post->post_id; |
| 1023 | 1023 | $term_id = (int) $post->category_id; |
| 1024 | 1024 | $taxonomy = 'category'; |
| 1025 | - if ( !empty($post->rel_type) && 'tag' == $post->rel_type) |
|
| 1025 | + if ( ! empty($post->rel_type) && 'tag' == $post->rel_type) |
|
| 1026 | 1026 | $taxonomy = 'tag'; |
| 1027 | 1027 | $tt_id = $tt_ids[$term_id][$taxonomy]; |
| 1028 | - if ( empty($tt_id) ) |
|
| 1028 | + if (empty($tt_id)) |
|
| 1029 | 1029 | continue; |
| 1030 | 1030 | |
| 1031 | - $wpdb->insert( $wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id) ); |
|
| 1031 | + $wpdb->insert($wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id)); |
|
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | 1034 | // < 3570 we used linkcategories. >= 3570 we used categories and link2cat. |
| 1035 | - if ( $wp_current_db_version < 3570 ) { |
|
| 1035 | + if ($wp_current_db_version < 3570) { |
|
| 1036 | 1036 | /* |
| 1037 | 1037 | * Create link_category terms for link categories. Create a map of link |
| 1038 | 1038 | * cat IDs to link_category terms. |
@@ -1040,8 +1040,8 @@ discard block |
||
| 1040 | 1040 | $link_cat_id_map = array(); |
| 1041 | 1041 | $default_link_cat = 0; |
| 1042 | 1042 | $tt_ids = array(); |
| 1043 | - $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM " . $wpdb->prefix . 'linkcategories'); |
|
| 1044 | - foreach ( $link_cats as $category) { |
|
| 1043 | + $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM ".$wpdb->prefix.'linkcategories'); |
|
| 1044 | + foreach ($link_cats as $category) { |
|
| 1045 | 1045 | $cat_id = (int) $category->cat_id; |
| 1046 | 1046 | $term_id = 0; |
| 1047 | 1047 | $name = wp_slash($category->cat_name); |
@@ -1049,66 +1049,66 @@ discard block |
||
| 1049 | 1049 | $term_group = 0; |
| 1050 | 1050 | |
| 1051 | 1051 | // Associate terms with the same slug in a term group and make slugs unique. |
| 1052 | - if ( $exists = $wpdb->get_results( $wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug) ) ) { |
|
| 1052 | + if ($exists = $wpdb->get_results($wpdb->prepare("SELECT term_id, term_group FROM $wpdb->terms WHERE slug = %s", $slug))) { |
|
| 1053 | 1053 | $term_group = $exists[0]->term_group; |
| 1054 | 1054 | $term_id = $exists[0]->term_id; |
| 1055 | 1055 | } |
| 1056 | 1056 | |
| 1057 | - if ( empty($term_id) ) { |
|
| 1058 | - $wpdb->insert( $wpdb->terms, compact('name', 'slug', 'term_group') ); |
|
| 1057 | + if (empty($term_id)) { |
|
| 1058 | + $wpdb->insert($wpdb->terms, compact('name', 'slug', 'term_group')); |
|
| 1059 | 1059 | $term_id = (int) $wpdb->insert_id; |
| 1060 | 1060 | } |
| 1061 | 1061 | |
| 1062 | 1062 | $link_cat_id_map[$cat_id] = $term_id; |
| 1063 | 1063 | $default_link_cat = $term_id; |
| 1064 | 1064 | |
| 1065 | - $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $term_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 0) ); |
|
| 1065 | + $wpdb->insert($wpdb->term_taxonomy, array('term_id' => $term_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 0)); |
|
| 1066 | 1066 | $tt_ids[$term_id] = (int) $wpdb->insert_id; |
| 1067 | 1067 | } |
| 1068 | 1068 | |
| 1069 | 1069 | // Associate links to cats. |
| 1070 | 1070 | $links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links"); |
| 1071 | - if ( !empty($links) ) foreach ( $links as $link ) { |
|
| 1072 | - if ( 0 == $link->link_category ) |
|
| 1071 | + if ( ! empty($links)) foreach ($links as $link) { |
|
| 1072 | + if (0 == $link->link_category) |
|
| 1073 | 1073 | continue; |
| 1074 | - if ( ! isset($link_cat_id_map[$link->link_category]) ) |
|
| 1074 | + if ( ! isset($link_cat_id_map[$link->link_category])) |
|
| 1075 | 1075 | continue; |
| 1076 | 1076 | $term_id = $link_cat_id_map[$link->link_category]; |
| 1077 | 1077 | $tt_id = $tt_ids[$term_id]; |
| 1078 | - if ( empty($tt_id) ) |
|
| 1078 | + if (empty($tt_id)) |
|
| 1079 | 1079 | continue; |
| 1080 | 1080 | |
| 1081 | - $wpdb->insert( $wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id) ); |
|
| 1081 | + $wpdb->insert($wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id)); |
|
| 1082 | 1082 | } |
| 1083 | 1083 | |
| 1084 | 1084 | // Set default to the last category we grabbed during the upgrade loop. |
| 1085 | 1085 | update_option('default_link_category', $default_link_cat); |
| 1086 | 1086 | } else { |
| 1087 | 1087 | $links = $wpdb->get_results("SELECT link_id, category_id FROM $wpdb->link2cat GROUP BY link_id, category_id"); |
| 1088 | - foreach ( $links as $link ) { |
|
| 1088 | + foreach ($links as $link) { |
|
| 1089 | 1089 | $link_id = (int) $link->link_id; |
| 1090 | 1090 | $term_id = (int) $link->category_id; |
| 1091 | 1091 | $taxonomy = 'link_category'; |
| 1092 | 1092 | $tt_id = $tt_ids[$term_id][$taxonomy]; |
| 1093 | - if ( empty($tt_id) ) |
|
| 1093 | + if (empty($tt_id)) |
|
| 1094 | 1094 | continue; |
| 1095 | - $wpdb->insert( $wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id) ); |
|
| 1095 | + $wpdb->insert($wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id)); |
|
| 1096 | 1096 | } |
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | - if ( $wp_current_db_version < 4772 ) { |
|
| 1099 | + if ($wp_current_db_version < 4772) { |
|
| 1100 | 1100 | // Obsolete linkcategories table |
| 1101 | - $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'linkcategories'); |
|
| 1101 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'linkcategories'); |
|
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | 1104 | // Recalculate all counts |
| 1105 | 1105 | $terms = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy"); |
| 1106 | - foreach ( (array) $terms as $term ) { |
|
| 1107 | - if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) ) |
|
| 1108 | - $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id) ); |
|
| 1106 | + foreach ((array) $terms as $term) { |
|
| 1107 | + if (('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy)) |
|
| 1108 | + $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id)); |
|
| 1109 | 1109 | else |
| 1110 | - $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) ); |
|
| 1111 | - $wpdb->update( $wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id) ); |
|
| 1110 | + $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id)); |
|
| 1111 | + $wpdb->update($wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id)); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | } |
| 1114 | 1114 | |
@@ -1122,9 +1122,9 @@ discard block |
||
| 1122 | 1122 | */ |
| 1123 | 1123 | function upgrade_230_options_table() { |
| 1124 | 1124 | global $wpdb; |
| 1125 | - $old_options_fields = array( 'option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level' ); |
|
| 1125 | + $old_options_fields = array('option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level'); |
|
| 1126 | 1126 | $wpdb->hide_errors(); |
| 1127 | - foreach ( $old_options_fields as $old ) |
|
| 1127 | + foreach ($old_options_fields as $old) |
|
| 1128 | 1128 | $wpdb->query("ALTER TABLE $wpdb->options DROP $old"); |
| 1129 | 1129 | $wpdb->show_errors(); |
| 1130 | 1130 | } |
@@ -1139,9 +1139,9 @@ discard block |
||
| 1139 | 1139 | */ |
| 1140 | 1140 | function upgrade_230_old_tables() { |
| 1141 | 1141 | global $wpdb; |
| 1142 | - $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'categories'); |
|
| 1143 | - $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'link2cat'); |
|
| 1144 | - $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'post2cat'); |
|
| 1142 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'categories'); |
|
| 1143 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'link2cat'); |
|
| 1144 | + $wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'post2cat'); |
|
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | 1147 | /** |
@@ -1169,7 +1169,7 @@ discard block |
||
| 1169 | 1169 | function upgrade_250() { |
| 1170 | 1170 | global $wp_current_db_version; |
| 1171 | 1171 | |
| 1172 | - if ( $wp_current_db_version < 6689 ) { |
|
| 1172 | + if ($wp_current_db_version < 6689) { |
|
| 1173 | 1173 | populate_roles_250(); |
| 1174 | 1174 | } |
| 1175 | 1175 | |
@@ -1200,7 +1200,7 @@ discard block |
||
| 1200 | 1200 | function upgrade_260() { |
| 1201 | 1201 | global $wp_current_db_version; |
| 1202 | 1202 | |
| 1203 | - if ( $wp_current_db_version < 8000 ) |
|
| 1203 | + if ($wp_current_db_version < 8000) |
|
| 1204 | 1204 | populate_roles_260(); |
| 1205 | 1205 | } |
| 1206 | 1206 | |
@@ -1216,12 +1216,12 @@ discard block |
||
| 1216 | 1216 | function upgrade_270() { |
| 1217 | 1217 | global $wpdb, $wp_current_db_version; |
| 1218 | 1218 | |
| 1219 | - if ( $wp_current_db_version < 8980 ) |
|
| 1219 | + if ($wp_current_db_version < 8980) |
|
| 1220 | 1220 | populate_roles_270(); |
| 1221 | 1221 | |
| 1222 | 1222 | // Update post_date for unpublished posts with empty timestamp |
| 1223 | - if ( $wp_current_db_version < 8921 ) |
|
| 1224 | - $wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" ); |
|
| 1223 | + if ($wp_current_db_version < 8921) |
|
| 1224 | + $wpdb->query("UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'"); |
|
| 1225 | 1225 | } |
| 1226 | 1226 | |
| 1227 | 1227 | /** |
@@ -1236,22 +1236,22 @@ discard block |
||
| 1236 | 1236 | function upgrade_280() { |
| 1237 | 1237 | global $wp_current_db_version, $wpdb; |
| 1238 | 1238 | |
| 1239 | - if ( $wp_current_db_version < 10360 ) |
|
| 1239 | + if ($wp_current_db_version < 10360) |
|
| 1240 | 1240 | populate_roles_280(); |
| 1241 | - if ( is_multisite() ) { |
|
| 1241 | + if (is_multisite()) { |
|
| 1242 | 1242 | $start = 0; |
| 1243 | - while( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) { |
|
| 1244 | - foreach ( $rows as $row ) { |
|
| 1243 | + while ($rows = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20")) { |
|
| 1244 | + foreach ($rows as $row) { |
|
| 1245 | 1245 | $value = $row->option_value; |
| 1246 | - if ( !@unserialize( $value ) ) |
|
| 1247 | - $value = stripslashes( $value ); |
|
| 1248 | - if ( $value !== $row->option_value ) { |
|
| 1249 | - update_option( $row->option_name, $value ); |
|
| 1246 | + if ( ! @unserialize($value)) |
|
| 1247 | + $value = stripslashes($value); |
|
| 1248 | + if ($value !== $row->option_value) { |
|
| 1249 | + update_option($row->option_name, $value); |
|
| 1250 | 1250 | } |
| 1251 | 1251 | } |
| 1252 | 1252 | $start += 20; |
| 1253 | 1253 | } |
| 1254 | - refresh_blog_details( $wpdb->blogid ); |
|
| 1254 | + refresh_blog_details($wpdb->blogid); |
|
| 1255 | 1255 | } |
| 1256 | 1256 | } |
| 1257 | 1257 | |
@@ -1266,11 +1266,11 @@ discard block |
||
| 1266 | 1266 | function upgrade_290() { |
| 1267 | 1267 | global $wp_current_db_version; |
| 1268 | 1268 | |
| 1269 | - if ( $wp_current_db_version < 11958 ) { |
|
| 1269 | + if ($wp_current_db_version < 11958) { |
|
| 1270 | 1270 | // Previously, setting depth to 1 would redundantly disable threading, but now 2 is the minimum depth to avoid confusion |
| 1271 | - if ( get_option( 'thread_comments_depth' ) == '1' ) { |
|
| 1272 | - update_option( 'thread_comments_depth', 2 ); |
|
| 1273 | - update_option( 'thread_comments', 0 ); |
|
| 1271 | + if (get_option('thread_comments_depth') == '1') { |
|
| 1272 | + update_option('thread_comments_depth', 2); |
|
| 1273 | + update_option('thread_comments', 0); |
|
| 1274 | 1274 | } |
| 1275 | 1275 | } |
| 1276 | 1276 | } |
@@ -1287,14 +1287,14 @@ discard block |
||
| 1287 | 1287 | function upgrade_300() { |
| 1288 | 1288 | global $wp_current_db_version, $wpdb; |
| 1289 | 1289 | |
| 1290 | - if ( $wp_current_db_version < 15093 ) |
|
| 1290 | + if ($wp_current_db_version < 15093) |
|
| 1291 | 1291 | populate_roles_300(); |
| 1292 | 1292 | |
| 1293 | - if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false ) |
|
| 1294 | - add_site_option( 'siteurl', '' ); |
|
| 1293 | + if ($wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined('MULTISITE') && get_site_option('siteurl') === false) |
|
| 1294 | + add_site_option('siteurl', ''); |
|
| 1295 | 1295 | |
| 1296 | 1296 | // 3.0 screen options key name changes. |
| 1297 | - if ( wp_should_upgrade_global_tables() ) { |
|
| 1297 | + if (wp_should_upgrade_global_tables()) { |
|
| 1298 | 1298 | $sql = "DELETE FROM $wpdb->usermeta |
| 1299 | 1299 | WHERE meta_key LIKE %s |
| 1300 | 1300 | OR meta_key LIKE %s |
@@ -1308,15 +1308,15 @@ discard block |
||
| 1308 | 1308 | OR meta_key = 'manageeditcolumnshidden' |
| 1309 | 1309 | OR meta_key = 'categories_per_page' |
| 1310 | 1310 | OR meta_key = 'edit_tags_per_page'"; |
| 1311 | - $prefix = $wpdb->esc_like( $wpdb->base_prefix ); |
|
| 1312 | - $wpdb->query( $wpdb->prepare( $sql, |
|
| 1313 | - $prefix . '%' . $wpdb->esc_like( 'meta-box-hidden' ) . '%', |
|
| 1314 | - $prefix . '%' . $wpdb->esc_like( 'closedpostboxes' ) . '%', |
|
| 1315 | - $prefix . '%' . $wpdb->esc_like( 'manage-' ) . '%' . $wpdb->esc_like( '-columns-hidden' ) . '%', |
|
| 1316 | - $prefix . '%' . $wpdb->esc_like( 'meta-box-order' ) . '%', |
|
| 1317 | - $prefix . '%' . $wpdb->esc_like( 'metaboxorder' ) . '%', |
|
| 1318 | - $prefix . '%' . $wpdb->esc_like( 'screen_layout' ) . '%' |
|
| 1319 | - ) ); |
|
| 1311 | + $prefix = $wpdb->esc_like($wpdb->base_prefix); |
|
| 1312 | + $wpdb->query($wpdb->prepare($sql, |
|
| 1313 | + $prefix.'%'.$wpdb->esc_like('meta-box-hidden').'%', |
|
| 1314 | + $prefix.'%'.$wpdb->esc_like('closedpostboxes').'%', |
|
| 1315 | + $prefix.'%'.$wpdb->esc_like('manage-').'%'.$wpdb->esc_like('-columns-hidden').'%', |
|
| 1316 | + $prefix.'%'.$wpdb->esc_like('meta-box-order').'%', |
|
| 1317 | + $prefix.'%'.$wpdb->esc_like('metaboxorder').'%', |
|
| 1318 | + $prefix.'%'.$wpdb->esc_like('screen_layout').'%' |
|
| 1319 | + )); |
|
| 1320 | 1320 | } |
| 1321 | 1321 | |
| 1322 | 1322 | } |
@@ -1335,52 +1335,52 @@ discard block |
||
| 1335 | 1335 | function upgrade_330() { |
| 1336 | 1336 | global $wp_current_db_version, $wpdb, $wp_registered_widgets, $sidebars_widgets; |
| 1337 | 1337 | |
| 1338 | - if ( $wp_current_db_version < 19061 && wp_should_upgrade_global_tables() ) { |
|
| 1339 | - $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')" ); |
|
| 1338 | + if ($wp_current_db_version < 19061 && wp_should_upgrade_global_tables()) { |
|
| 1339 | + $wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')"); |
|
| 1340 | 1340 | } |
| 1341 | 1341 | |
| 1342 | - if ( $wp_current_db_version >= 11548 ) |
|
| 1342 | + if ($wp_current_db_version >= 11548) |
|
| 1343 | 1343 | return; |
| 1344 | 1344 | |
| 1345 | - $sidebars_widgets = get_option( 'sidebars_widgets', array() ); |
|
| 1345 | + $sidebars_widgets = get_option('sidebars_widgets', array()); |
|
| 1346 | 1346 | $_sidebars_widgets = array(); |
| 1347 | 1347 | |
| 1348 | - if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) ) |
|
| 1348 | + if (isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets)) |
|
| 1349 | 1349 | $sidebars_widgets['array_version'] = 3; |
| 1350 | - elseif ( !isset($sidebars_widgets['array_version']) ) |
|
| 1350 | + elseif ( ! isset($sidebars_widgets['array_version'])) |
|
| 1351 | 1351 | $sidebars_widgets['array_version'] = 1; |
| 1352 | 1352 | |
| 1353 | - switch ( $sidebars_widgets['array_version'] ) { |
|
| 1353 | + switch ($sidebars_widgets['array_version']) { |
|
| 1354 | 1354 | case 1 : |
| 1355 | - foreach ( (array) $sidebars_widgets as $index => $sidebar ) |
|
| 1356 | - if ( is_array($sidebar) ) |
|
| 1357 | - foreach ( (array) $sidebar as $i => $name ) { |
|
| 1355 | + foreach ((array) $sidebars_widgets as $index => $sidebar) |
|
| 1356 | + if (is_array($sidebar)) |
|
| 1357 | + foreach ((array) $sidebar as $i => $name) { |
|
| 1358 | 1358 | $id = strtolower($name); |
| 1359 | - if ( isset($wp_registered_widgets[$id]) ) { |
|
| 1359 | + if (isset($wp_registered_widgets[$id])) { |
|
| 1360 | 1360 | $_sidebars_widgets[$index][$i] = $id; |
| 1361 | 1361 | continue; |
| 1362 | 1362 | } |
| 1363 | 1363 | $id = sanitize_title($name); |
| 1364 | - if ( isset($wp_registered_widgets[$id]) ) { |
|
| 1364 | + if (isset($wp_registered_widgets[$id])) { |
|
| 1365 | 1365 | $_sidebars_widgets[$index][$i] = $id; |
| 1366 | 1366 | continue; |
| 1367 | 1367 | } |
| 1368 | 1368 | |
| 1369 | 1369 | $found = false; |
| 1370 | 1370 | |
| 1371 | - foreach ( $wp_registered_widgets as $widget_id => $widget ) { |
|
| 1372 | - if ( strtolower($widget['name']) == strtolower($name) ) { |
|
| 1371 | + foreach ($wp_registered_widgets as $widget_id => $widget) { |
|
| 1372 | + if (strtolower($widget['name']) == strtolower($name)) { |
|
| 1373 | 1373 | $_sidebars_widgets[$index][$i] = $widget['id']; |
| 1374 | 1374 | $found = true; |
| 1375 | 1375 | break; |
| 1376 | - } elseif ( sanitize_title($widget['name']) == sanitize_title($name) ) { |
|
| 1376 | + } elseif (sanitize_title($widget['name']) == sanitize_title($name)) { |
|
| 1377 | 1377 | $_sidebars_widgets[$index][$i] = $widget['id']; |
| 1378 | 1378 | $found = true; |
| 1379 | 1379 | break; |
| 1380 | 1380 | } |
| 1381 | 1381 | } |
| 1382 | 1382 | |
| 1383 | - if ( $found ) |
|
| 1383 | + if ($found) |
|
| 1384 | 1384 | continue; |
| 1385 | 1385 | |
| 1386 | 1386 | unset($_sidebars_widgets[$index][$i]); |
@@ -1392,7 +1392,7 @@ discard block |
||
| 1392 | 1392 | case 2 : |
| 1393 | 1393 | $sidebars_widgets = retrieve_widgets(); |
| 1394 | 1394 | $sidebars_widgets['array_version'] = 3; |
| 1395 | - update_option( 'sidebars_widgets', $sidebars_widgets ); |
|
| 1395 | + update_option('sidebars_widgets', $sidebars_widgets); |
|
| 1396 | 1396 | } |
| 1397 | 1397 | } |
| 1398 | 1398 | |
@@ -1408,27 +1408,27 @@ discard block |
||
| 1408 | 1408 | function upgrade_340() { |
| 1409 | 1409 | global $wp_current_db_version, $wpdb; |
| 1410 | 1410 | |
| 1411 | - if ( $wp_current_db_version < 19798 ) { |
|
| 1411 | + if ($wp_current_db_version < 19798) { |
|
| 1412 | 1412 | $wpdb->hide_errors(); |
| 1413 | - $wpdb->query( "ALTER TABLE $wpdb->options DROP COLUMN blog_id" ); |
|
| 1413 | + $wpdb->query("ALTER TABLE $wpdb->options DROP COLUMN blog_id"); |
|
| 1414 | 1414 | $wpdb->show_errors(); |
| 1415 | 1415 | } |
| 1416 | 1416 | |
| 1417 | - if ( $wp_current_db_version < 19799 ) { |
|
| 1417 | + if ($wp_current_db_version < 19799) { |
|
| 1418 | 1418 | $wpdb->hide_errors(); |
| 1419 | 1419 | $wpdb->query("ALTER TABLE $wpdb->comments DROP INDEX comment_approved"); |
| 1420 | 1420 | $wpdb->show_errors(); |
| 1421 | 1421 | } |
| 1422 | 1422 | |
| 1423 | - if ( $wp_current_db_version < 20022 && wp_should_upgrade_global_tables() ) { |
|
| 1424 | - $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key = 'themes_last_view'" ); |
|
| 1423 | + if ($wp_current_db_version < 20022 && wp_should_upgrade_global_tables()) { |
|
| 1424 | + $wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key = 'themes_last_view'"); |
|
| 1425 | 1425 | } |
| 1426 | 1426 | |
| 1427 | - if ( $wp_current_db_version < 20080 ) { |
|
| 1428 | - if ( 'yes' == $wpdb->get_var( "SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'" ) ) { |
|
| 1429 | - $uninstall_plugins = get_option( 'uninstall_plugins' ); |
|
| 1430 | - delete_option( 'uninstall_plugins' ); |
|
| 1431 | - add_option( 'uninstall_plugins', $uninstall_plugins, null, 'no' ); |
|
| 1427 | + if ($wp_current_db_version < 20080) { |
|
| 1428 | + if ('yes' == $wpdb->get_var("SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'")) { |
|
| 1429 | + $uninstall_plugins = get_option('uninstall_plugins'); |
|
| 1430 | + delete_option('uninstall_plugins'); |
|
| 1431 | + add_option('uninstall_plugins', $uninstall_plugins, null, 'no'); |
|
| 1432 | 1432 | } |
| 1433 | 1433 | } |
| 1434 | 1434 | } |
@@ -1445,23 +1445,23 @@ discard block |
||
| 1445 | 1445 | function upgrade_350() { |
| 1446 | 1446 | global $wp_current_db_version, $wpdb; |
| 1447 | 1447 | |
| 1448 | - if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) |
|
| 1449 | - update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options() |
|
| 1448 | + if ($wp_current_db_version < 22006 && $wpdb->get_var("SELECT link_id FROM $wpdb->links LIMIT 1")) |
|
| 1449 | + update_option('link_manager_enabled', 1); // Previously set to 0 by populate_options() |
|
| 1450 | 1450 | |
| 1451 | - if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) { |
|
| 1451 | + if ($wp_current_db_version < 21811 && wp_should_upgrade_global_tables()) { |
|
| 1452 | 1452 | $meta_keys = array(); |
| 1453 | - foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) { |
|
| 1454 | - if ( false !== strpos( $name, '-' ) ) |
|
| 1455 | - $meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page'; |
|
| 1453 | + foreach (array_merge(get_post_types(), get_taxonomies()) as $name) { |
|
| 1454 | + if (false !== strpos($name, '-')) |
|
| 1455 | + $meta_keys[] = 'edit_'.str_replace('-', '_', $name).'_per_page'; |
|
| 1456 | 1456 | } |
| 1457 | - if ( $meta_keys ) { |
|
| 1458 | - $meta_keys = implode( "', '", $meta_keys ); |
|
| 1459 | - $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('$meta_keys')" ); |
|
| 1457 | + if ($meta_keys) { |
|
| 1458 | + $meta_keys = implode("', '", $meta_keys); |
|
| 1459 | + $wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key IN ('$meta_keys')"); |
|
| 1460 | 1460 | } |
| 1461 | 1461 | } |
| 1462 | 1462 | |
| 1463 | - if ( $wp_current_db_version < 22422 && $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ) ) |
|
| 1464 | - wp_delete_term( $term->term_id, 'post_format' ); |
|
| 1463 | + if ($wp_current_db_version < 22422 && $term = get_term_by('slug', 'post-format-standard', 'post_format')) |
|
| 1464 | + wp_delete_term($term->term_id, 'post_format'); |
|
| 1465 | 1465 | } |
| 1466 | 1466 | |
| 1467 | 1467 | /** |
@@ -1474,8 +1474,8 @@ discard block |
||
| 1474 | 1474 | */ |
| 1475 | 1475 | function upgrade_370() { |
| 1476 | 1476 | global $wp_current_db_version; |
| 1477 | - if ( $wp_current_db_version < 25824 ) |
|
| 1478 | - wp_clear_scheduled_hook( 'wp_auto_updates_maybe_update' ); |
|
| 1477 | + if ($wp_current_db_version < 25824) |
|
| 1478 | + wp_clear_scheduled_hook('wp_auto_updates_maybe_update'); |
|
| 1479 | 1479 | } |
| 1480 | 1480 | |
| 1481 | 1481 | /** |
@@ -1489,8 +1489,8 @@ discard block |
||
| 1489 | 1489 | */ |
| 1490 | 1490 | function upgrade_372() { |
| 1491 | 1491 | global $wp_current_db_version; |
| 1492 | - if ( $wp_current_db_version < 26148 ) |
|
| 1493 | - wp_clear_scheduled_hook( 'wp_maybe_auto_update' ); |
|
| 1492 | + if ($wp_current_db_version < 26148) |
|
| 1493 | + wp_clear_scheduled_hook('wp_maybe_auto_update'); |
|
| 1494 | 1494 | } |
| 1495 | 1495 | |
| 1496 | 1496 | /** |
@@ -1503,8 +1503,8 @@ discard block |
||
| 1503 | 1503 | */ |
| 1504 | 1504 | function upgrade_380() { |
| 1505 | 1505 | global $wp_current_db_version; |
| 1506 | - if ( $wp_current_db_version < 26691 ) { |
|
| 1507 | - deactivate_plugins( array( 'mp6/mp6.php' ), true ); |
|
| 1506 | + if ($wp_current_db_version < 26691) { |
|
| 1507 | + deactivate_plugins(array('mp6/mp6.php'), true); |
|
| 1508 | 1508 | } |
| 1509 | 1509 | } |
| 1510 | 1510 | |
@@ -1518,12 +1518,12 @@ discard block |
||
| 1518 | 1518 | */ |
| 1519 | 1519 | function upgrade_400() { |
| 1520 | 1520 | global $wp_current_db_version; |
| 1521 | - if ( $wp_current_db_version < 29630 ) { |
|
| 1522 | - if ( ! is_multisite() && false === get_option( 'WPLANG' ) ) { |
|
| 1523 | - if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && in_array( WPLANG, get_available_languages() ) ) { |
|
| 1524 | - update_option( 'WPLANG', WPLANG ); |
|
| 1521 | + if ($wp_current_db_version < 29630) { |
|
| 1522 | + if ( ! is_multisite() && false === get_option('WPLANG')) { |
|
| 1523 | + if (defined('WPLANG') && ('' !== WPLANG) && in_array(WPLANG, get_available_languages())) { |
|
| 1524 | + update_option('WPLANG', WPLANG); |
|
| 1525 | 1525 | } else { |
| 1526 | - update_option( 'WPLANG', '' ); |
|
| 1526 | + update_option('WPLANG', ''); |
|
| 1527 | 1527 | } |
| 1528 | 1528 | } |
| 1529 | 1529 | } |
@@ -1552,29 +1552,29 @@ discard block |
||
| 1552 | 1552 | function upgrade_430() { |
| 1553 | 1553 | global $wp_current_db_version, $wpdb; |
| 1554 | 1554 | |
| 1555 | - if ( $wp_current_db_version < 32364 ) { |
|
| 1555 | + if ($wp_current_db_version < 32364) { |
|
| 1556 | 1556 | upgrade_430_fix_comments(); |
| 1557 | 1557 | } |
| 1558 | 1558 | |
| 1559 | 1559 | // Shared terms are split in a separate process. |
| 1560 | - if ( $wp_current_db_version < 32814 ) { |
|
| 1561 | - update_option( 'finished_splitting_shared_terms', 0 ); |
|
| 1562 | - wp_schedule_single_event( time() + ( 1 * MINUTE_IN_SECONDS ), 'wp_split_shared_term_batch' ); |
|
| 1560 | + if ($wp_current_db_version < 32814) { |
|
| 1561 | + update_option('finished_splitting_shared_terms', 0); |
|
| 1562 | + wp_schedule_single_event(time() + (1 * MINUTE_IN_SECONDS), 'wp_split_shared_term_batch'); |
|
| 1563 | 1563 | } |
| 1564 | 1564 | |
| 1565 | - if ( $wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset ) { |
|
| 1566 | - if ( is_multisite() ) { |
|
| 1567 | - $tables = $wpdb->tables( 'blog' ); |
|
| 1565 | + if ($wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset) { |
|
| 1566 | + if (is_multisite()) { |
|
| 1567 | + $tables = $wpdb->tables('blog'); |
|
| 1568 | 1568 | } else { |
| 1569 | - $tables = $wpdb->tables( 'all' ); |
|
| 1570 | - if ( ! wp_should_upgrade_global_tables() ) { |
|
| 1571 | - $global_tables = $wpdb->tables( 'global' ); |
|
| 1572 | - $tables = array_diff_assoc( $tables, $global_tables ); |
|
| 1569 | + $tables = $wpdb->tables('all'); |
|
| 1570 | + if ( ! wp_should_upgrade_global_tables()) { |
|
| 1571 | + $global_tables = $wpdb->tables('global'); |
|
| 1572 | + $tables = array_diff_assoc($tables, $global_tables); |
|
| 1573 | 1573 | } |
| 1574 | 1574 | } |
| 1575 | 1575 | |
| 1576 | - foreach ( $tables as $table ) { |
|
| 1577 | - maybe_convert_table_to_utf8mb4( $table ); |
|
| 1576 | + foreach ($tables as $table) { |
|
| 1577 | + maybe_convert_table_to_utf8mb4($table); |
|
| 1578 | 1578 | } |
| 1579 | 1579 | } |
| 1580 | 1580 | } |
@@ -1591,18 +1591,18 @@ discard block |
||
| 1591 | 1591 | function upgrade_430_fix_comments() { |
| 1592 | 1592 | global $wp_current_db_version, $wpdb; |
| 1593 | 1593 | |
| 1594 | - $content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' ); |
|
| 1594 | + $content_length = $wpdb->get_col_length($wpdb->comments, 'comment_content'); |
|
| 1595 | 1595 | |
| 1596 | - if ( is_wp_error( $content_length ) ) { |
|
| 1596 | + if (is_wp_error($content_length)) { |
|
| 1597 | 1597 | return; |
| 1598 | 1598 | } |
| 1599 | 1599 | |
| 1600 | - if ( false === $content_length ) { |
|
| 1600 | + if (false === $content_length) { |
|
| 1601 | 1601 | $content_length = array( |
| 1602 | 1602 | 'type' => 'byte', |
| 1603 | 1603 | 'length' => 65535, |
| 1604 | 1604 | ); |
| 1605 | - } elseif ( ! is_array( $content_length ) ) { |
|
| 1605 | + } elseif ( ! is_array($content_length)) { |
|
| 1606 | 1606 | $length = (int) $content_length > 0 ? (int) $content_length : 65535; |
| 1607 | 1607 | $content_length = array( |
| 1608 | 1608 | 'type' => 'byte', |
@@ -1610,12 +1610,12 @@ discard block |
||
| 1610 | 1610 | ); |
| 1611 | 1611 | } |
| 1612 | 1612 | |
| 1613 | - if ( 'byte' !== $content_length['type'] || 0 === $content_length['length'] ) { |
|
| 1613 | + if ('byte' !== $content_length['type'] || 0 === $content_length['length']) { |
|
| 1614 | 1614 | // Sites with malformed DB schemas are on their own. |
| 1615 | 1615 | return; |
| 1616 | 1616 | } |
| 1617 | 1617 | |
| 1618 | - $allowed_length = intval( $content_length['length'] ) - 10; |
|
| 1618 | + $allowed_length = intval($content_length['length']) - 10; |
|
| 1619 | 1619 | |
| 1620 | 1620 | $comments = $wpdb->get_results( |
| 1621 | 1621 | "SELECT `comment_ID` FROM `{$wpdb->comments}` |
@@ -1624,8 +1624,8 @@ discard block |
||
| 1624 | 1624 | AND ( `comment_content` LIKE '%<%' OR `comment_content` LIKE '%>%' )" |
| 1625 | 1625 | ); |
| 1626 | 1626 | |
| 1627 | - foreach ( $comments as $comment ) { |
|
| 1628 | - wp_delete_comment( $comment->comment_ID, true ); |
|
| 1627 | + foreach ($comments as $comment) { |
|
| 1628 | + wp_delete_comment($comment->comment_ID, true); |
|
| 1629 | 1629 | } |
| 1630 | 1630 | } |
| 1631 | 1631 | |
@@ -1638,9 +1638,9 @@ discard block |
||
| 1638 | 1638 | function upgrade_431() { |
| 1639 | 1639 | // Fix incorrect cron entries for term splitting |
| 1640 | 1640 | $cron_array = _get_cron_array(); |
| 1641 | - if ( isset( $cron_array['wp_batch_split_terms'] ) ) { |
|
| 1642 | - unset( $cron_array['wp_batch_split_terms'] ); |
|
| 1643 | - _set_cron_array( $cron_array ); |
|
| 1641 | + if (isset($cron_array['wp_batch_split_terms'])) { |
|
| 1642 | + unset($cron_array['wp_batch_split_terms']); |
|
| 1643 | + _set_cron_array($cron_array); |
|
| 1644 | 1644 | } |
| 1645 | 1645 | } |
| 1646 | 1646 | |
@@ -1656,15 +1656,15 @@ discard block |
||
| 1656 | 1656 | function upgrade_440() { |
| 1657 | 1657 | global $wp_current_db_version, $wpdb; |
| 1658 | 1658 | |
| 1659 | - if ( $wp_current_db_version < 34030 ) { |
|
| 1660 | - $wpdb->query( "ALTER TABLE {$wpdb->options} MODIFY option_name VARCHAR(191)" ); |
|
| 1659 | + if ($wp_current_db_version < 34030) { |
|
| 1660 | + $wpdb->query("ALTER TABLE {$wpdb->options} MODIFY option_name VARCHAR(191)"); |
|
| 1661 | 1661 | } |
| 1662 | 1662 | |
| 1663 | 1663 | // Remove the unused 'add_users' role. |
| 1664 | 1664 | $roles = wp_roles(); |
| 1665 | - foreach ( $roles->role_objects as $role ) { |
|
| 1666 | - if ( $role->has_cap( 'add_users' ) ) { |
|
| 1667 | - $role->remove_cap( 'add_users' ); |
|
| 1665 | + foreach ($roles->role_objects as $role) { |
|
| 1666 | + if ($role->has_cap('add_users')) { |
|
| 1667 | + $role->remove_cap('add_users'); |
|
| 1668 | 1668 | } |
| 1669 | 1669 | } |
| 1670 | 1670 | } |
@@ -1681,17 +1681,17 @@ discard block |
||
| 1681 | 1681 | function upgrade_450() { |
| 1682 | 1682 | global $wp_current_db_version, $wpdb; |
| 1683 | 1683 | |
| 1684 | - if ( $wp_current_db_version < 36180 ) { |
|
| 1685 | - wp_clear_scheduled_hook( 'wp_maybe_auto_update' ); |
|
| 1684 | + if ($wp_current_db_version < 36180) { |
|
| 1685 | + wp_clear_scheduled_hook('wp_maybe_auto_update'); |
|
| 1686 | 1686 | } |
| 1687 | 1687 | |
| 1688 | 1688 | // Remove unused email confirmation options, moved to usermeta. |
| 1689 | - if ( $wp_current_db_version < 36679 && is_multisite() ) { |
|
| 1690 | - $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name REGEXP '^[0-9]+_new_email$'" ); |
|
| 1689 | + if ($wp_current_db_version < 36679 && is_multisite()) { |
|
| 1690 | + $wpdb->query("DELETE FROM $wpdb->options WHERE option_name REGEXP '^[0-9]+_new_email$'"); |
|
| 1691 | 1691 | } |
| 1692 | 1692 | |
| 1693 | 1693 | // Remove unused user setting for wpLink. |
| 1694 | - delete_user_setting( 'wplink' ); |
|
| 1694 | + delete_user_setting('wplink'); |
|
| 1695 | 1695 | } |
| 1696 | 1696 | |
| 1697 | 1697 | /** |
@@ -1706,22 +1706,22 @@ discard block |
||
| 1706 | 1706 | global $wp_current_db_version; |
| 1707 | 1707 | |
| 1708 | 1708 | // Remove unused post meta. |
| 1709 | - if ( $wp_current_db_version < 37854 ) { |
|
| 1710 | - delete_post_meta_by_key( '_post_restored_from' ); |
|
| 1709 | + if ($wp_current_db_version < 37854) { |
|
| 1710 | + delete_post_meta_by_key('_post_restored_from'); |
|
| 1711 | 1711 | } |
| 1712 | 1712 | |
| 1713 | 1713 | // Remove plugins with callback as an array object/method as the uninstall hook, see #13786. |
| 1714 | - if ( $wp_current_db_version < 37965 ) { |
|
| 1715 | - $uninstall_plugins = get_option( 'uninstall_plugins', array() ); |
|
| 1714 | + if ($wp_current_db_version < 37965) { |
|
| 1715 | + $uninstall_plugins = get_option('uninstall_plugins', array()); |
|
| 1716 | 1716 | |
| 1717 | - if ( ! empty( $uninstall_plugins ) ) { |
|
| 1718 | - foreach ( $uninstall_plugins as $basename => $callback ) { |
|
| 1719 | - if ( is_array( $callback ) && is_object( $callback[0] ) ) { |
|
| 1720 | - unset( $uninstall_plugins[ $basename ] ); |
|
| 1717 | + if ( ! empty($uninstall_plugins)) { |
|
| 1718 | + foreach ($uninstall_plugins as $basename => $callback) { |
|
| 1719 | + if (is_array($callback) && is_object($callback[0])) { |
|
| 1720 | + unset($uninstall_plugins[$basename]); |
|
| 1721 | 1721 | } |
| 1722 | 1722 | } |
| 1723 | 1723 | |
| 1724 | - update_option( 'uninstall_plugins', $uninstall_plugins ); |
|
| 1724 | + update_option('uninstall_plugins', $uninstall_plugins); |
|
| 1725 | 1725 | } |
| 1726 | 1726 | } |
| 1727 | 1727 | } |
@@ -1738,7 +1738,7 @@ discard block |
||
| 1738 | 1738 | global $wp_current_db_version, $wpdb; |
| 1739 | 1739 | |
| 1740 | 1740 | // Always. |
| 1741 | - if ( is_main_network() ) { |
|
| 1741 | + if (is_main_network()) { |
|
| 1742 | 1742 | /* |
| 1743 | 1743 | * Deletes all expired transients. The multi-table delete syntax is used |
| 1744 | 1744 | * to delete the transient record from table a, and the corresponding |
@@ -1750,32 +1750,32 @@ discard block |
||
| 1750 | 1750 | AND a.meta_key NOT LIKE %s |
| 1751 | 1751 | AND b.meta_key = CONCAT( '_site_transient_timeout_', SUBSTRING( a.meta_key, 17 ) ) |
| 1752 | 1752 | AND b.meta_value < %d"; |
| 1753 | - $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_site_transient_' ) . '%', $wpdb->esc_like ( '_site_transient_timeout_' ) . '%', $time ) ); |
|
| 1753 | + $wpdb->query($wpdb->prepare($sql, $wpdb->esc_like('_site_transient_').'%', $wpdb->esc_like('_site_transient_timeout_').'%', $time)); |
|
| 1754 | 1754 | } |
| 1755 | 1755 | |
| 1756 | 1756 | // 2.8. |
| 1757 | - if ( $wp_current_db_version < 11549 ) { |
|
| 1758 | - $wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' ); |
|
| 1759 | - $active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' ); |
|
| 1760 | - if ( $wpmu_sitewide_plugins ) { |
|
| 1761 | - if ( !$active_sitewide_plugins ) |
|
| 1757 | + if ($wp_current_db_version < 11549) { |
|
| 1758 | + $wpmu_sitewide_plugins = get_site_option('wpmu_sitewide_plugins'); |
|
| 1759 | + $active_sitewide_plugins = get_site_option('active_sitewide_plugins'); |
|
| 1760 | + if ($wpmu_sitewide_plugins) { |
|
| 1761 | + if ( ! $active_sitewide_plugins) |
|
| 1762 | 1762 | $sitewide_plugins = (array) $wpmu_sitewide_plugins; |
| 1763 | 1763 | else |
| 1764 | - $sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins ); |
|
| 1764 | + $sitewide_plugins = array_merge((array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins); |
|
| 1765 | 1765 | |
| 1766 | - update_site_option( 'active_sitewide_plugins', $sitewide_plugins ); |
|
| 1766 | + update_site_option('active_sitewide_plugins', $sitewide_plugins); |
|
| 1767 | 1767 | } |
| 1768 | - delete_site_option( 'wpmu_sitewide_plugins' ); |
|
| 1769 | - delete_site_option( 'deactivated_sitewide_plugins' ); |
|
| 1768 | + delete_site_option('wpmu_sitewide_plugins'); |
|
| 1769 | + delete_site_option('deactivated_sitewide_plugins'); |
|
| 1770 | 1770 | |
| 1771 | 1771 | $start = 0; |
| 1772 | - while( $rows = $wpdb->get_results( "SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20" ) ) { |
|
| 1773 | - foreach ( $rows as $row ) { |
|
| 1772 | + while ($rows = $wpdb->get_results("SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20")) { |
|
| 1773 | + foreach ($rows as $row) { |
|
| 1774 | 1774 | $value = $row->meta_value; |
| 1775 | - if ( !@unserialize( $value ) ) |
|
| 1776 | - $value = stripslashes( $value ); |
|
| 1777 | - if ( $value !== $row->meta_value ) { |
|
| 1778 | - update_site_option( $row->meta_key, $value ); |
|
| 1775 | + if ( ! @unserialize($value)) |
|
| 1776 | + $value = stripslashes($value); |
|
| 1777 | + if ($value !== $row->meta_value) { |
|
| 1778 | + update_site_option($row->meta_key, $value); |
|
| 1779 | 1779 | } |
| 1780 | 1780 | } |
| 1781 | 1781 | $start += 20; |
@@ -1783,95 +1783,95 @@ discard block |
||
| 1783 | 1783 | } |
| 1784 | 1784 | |
| 1785 | 1785 | // 3.0 |
| 1786 | - if ( $wp_current_db_version < 13576 ) |
|
| 1787 | - update_site_option( 'global_terms_enabled', '1' ); |
|
| 1786 | + if ($wp_current_db_version < 13576) |
|
| 1787 | + update_site_option('global_terms_enabled', '1'); |
|
| 1788 | 1788 | |
| 1789 | 1789 | // 3.3 |
| 1790 | - if ( $wp_current_db_version < 19390 ) |
|
| 1791 | - update_site_option( 'initial_db_version', $wp_current_db_version ); |
|
| 1790 | + if ($wp_current_db_version < 19390) |
|
| 1791 | + update_site_option('initial_db_version', $wp_current_db_version); |
|
| 1792 | 1792 | |
| 1793 | - if ( $wp_current_db_version < 19470 ) { |
|
| 1794 | - if ( false === get_site_option( 'active_sitewide_plugins' ) ) |
|
| 1795 | - update_site_option( 'active_sitewide_plugins', array() ); |
|
| 1793 | + if ($wp_current_db_version < 19470) { |
|
| 1794 | + if (false === get_site_option('active_sitewide_plugins')) |
|
| 1795 | + update_site_option('active_sitewide_plugins', array()); |
|
| 1796 | 1796 | } |
| 1797 | 1797 | |
| 1798 | 1798 | // 3.4 |
| 1799 | - if ( $wp_current_db_version < 20148 ) { |
|
| 1799 | + if ($wp_current_db_version < 20148) { |
|
| 1800 | 1800 | // 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name. |
| 1801 | - $allowedthemes = get_site_option( 'allowedthemes' ); |
|
| 1802 | - $allowed_themes = get_site_option( 'allowed_themes' ); |
|
| 1803 | - if ( false === $allowedthemes && is_array( $allowed_themes ) && $allowed_themes ) { |
|
| 1801 | + $allowedthemes = get_site_option('allowedthemes'); |
|
| 1802 | + $allowed_themes = get_site_option('allowed_themes'); |
|
| 1803 | + if (false === $allowedthemes && is_array($allowed_themes) && $allowed_themes) { |
|
| 1804 | 1804 | $converted = array(); |
| 1805 | 1805 | $themes = wp_get_themes(); |
| 1806 | - foreach ( $themes as $stylesheet => $theme_data ) { |
|
| 1807 | - if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) ) |
|
| 1808 | - $converted[ $stylesheet ] = true; |
|
| 1806 | + foreach ($themes as $stylesheet => $theme_data) { |
|
| 1807 | + if (isset($allowed_themes[$theme_data->get('Name')])) |
|
| 1808 | + $converted[$stylesheet] = true; |
|
| 1809 | 1809 | } |
| 1810 | - update_site_option( 'allowedthemes', $converted ); |
|
| 1811 | - delete_site_option( 'allowed_themes' ); |
|
| 1810 | + update_site_option('allowedthemes', $converted); |
|
| 1811 | + delete_site_option('allowed_themes'); |
|
| 1812 | 1812 | } |
| 1813 | 1813 | } |
| 1814 | 1814 | |
| 1815 | 1815 | // 3.5 |
| 1816 | - if ( $wp_current_db_version < 21823 ) |
|
| 1817 | - update_site_option( 'ms_files_rewriting', '1' ); |
|
| 1816 | + if ($wp_current_db_version < 21823) |
|
| 1817 | + update_site_option('ms_files_rewriting', '1'); |
|
| 1818 | 1818 | |
| 1819 | 1819 | // 3.5.2 |
| 1820 | - if ( $wp_current_db_version < 24448 ) { |
|
| 1821 | - $illegal_names = get_site_option( 'illegal_names' ); |
|
| 1822 | - if ( is_array( $illegal_names ) && count( $illegal_names ) === 1 ) { |
|
| 1823 | - $illegal_name = reset( $illegal_names ); |
|
| 1824 | - $illegal_names = explode( ' ', $illegal_name ); |
|
| 1825 | - update_site_option( 'illegal_names', $illegal_names ); |
|
| 1820 | + if ($wp_current_db_version < 24448) { |
|
| 1821 | + $illegal_names = get_site_option('illegal_names'); |
|
| 1822 | + if (is_array($illegal_names) && count($illegal_names) === 1) { |
|
| 1823 | + $illegal_name = reset($illegal_names); |
|
| 1824 | + $illegal_names = explode(' ', $illegal_name); |
|
| 1825 | + update_site_option('illegal_names', $illegal_names); |
|
| 1826 | 1826 | } |
| 1827 | 1827 | } |
| 1828 | 1828 | |
| 1829 | 1829 | // 4.2 |
| 1830 | - if ( $wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4' ) { |
|
| 1831 | - if ( wp_should_upgrade_global_tables() ) { |
|
| 1832 | - $wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" ); |
|
| 1833 | - $wpdb->query( "ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))" ); |
|
| 1834 | - $wpdb->query( "ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" ); |
|
| 1835 | - $wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))" ); |
|
| 1830 | + if ($wp_current_db_version < 31351 && $wpdb->charset === 'utf8mb4') { |
|
| 1831 | + if (wp_should_upgrade_global_tables()) { |
|
| 1832 | + $wpdb->query("ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))"); |
|
| 1833 | + $wpdb->query("ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))"); |
|
| 1834 | + $wpdb->query("ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))"); |
|
| 1835 | + $wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))"); |
|
| 1836 | 1836 | |
| 1837 | - $tables = $wpdb->tables( 'global' ); |
|
| 1837 | + $tables = $wpdb->tables('global'); |
|
| 1838 | 1838 | |
| 1839 | 1839 | // sitecategories may not exist. |
| 1840 | - if ( ! $wpdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) { |
|
| 1841 | - unset( $tables['sitecategories'] ); |
|
| 1840 | + if ( ! $wpdb->get_var("SHOW TABLES LIKE '{$tables['sitecategories']}'")) { |
|
| 1841 | + unset($tables['sitecategories']); |
|
| 1842 | 1842 | } |
| 1843 | 1843 | |
| 1844 | - foreach ( $tables as $table ) { |
|
| 1845 | - maybe_convert_table_to_utf8mb4( $table ); |
|
| 1844 | + foreach ($tables as $table) { |
|
| 1845 | + maybe_convert_table_to_utf8mb4($table); |
|
| 1846 | 1846 | } |
| 1847 | 1847 | } |
| 1848 | 1848 | } |
| 1849 | 1849 | |
| 1850 | 1850 | // 4.3 |
| 1851 | - if ( $wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset ) { |
|
| 1852 | - if ( wp_should_upgrade_global_tables() ) { |
|
| 1851 | + if ($wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset) { |
|
| 1852 | + if (wp_should_upgrade_global_tables()) { |
|
| 1853 | 1853 | $upgrade = false; |
| 1854 | - $indexes = $wpdb->get_results( "SHOW INDEXES FROM $wpdb->signups" ); |
|
| 1855 | - foreach ( $indexes as $index ) { |
|
| 1856 | - if ( 'domain_path' == $index->Key_name && 'domain' == $index->Column_name && 140 != $index->Sub_part ) { |
|
| 1854 | + $indexes = $wpdb->get_results("SHOW INDEXES FROM $wpdb->signups"); |
|
| 1855 | + foreach ($indexes as $index) { |
|
| 1856 | + if ('domain_path' == $index->Key_name && 'domain' == $index->Column_name && 140 != $index->Sub_part) { |
|
| 1857 | 1857 | $upgrade = true; |
| 1858 | 1858 | break; |
| 1859 | 1859 | } |
| 1860 | 1860 | } |
| 1861 | 1861 | |
| 1862 | - if ( $upgrade ) { |
|
| 1863 | - $wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))" ); |
|
| 1862 | + if ($upgrade) { |
|
| 1863 | + $wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))"); |
|
| 1864 | 1864 | } |
| 1865 | 1865 | |
| 1866 | - $tables = $wpdb->tables( 'global' ); |
|
| 1866 | + $tables = $wpdb->tables('global'); |
|
| 1867 | 1867 | |
| 1868 | 1868 | // sitecategories may not exist. |
| 1869 | - if ( ! $wpdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) { |
|
| 1870 | - unset( $tables['sitecategories'] ); |
|
| 1869 | + if ( ! $wpdb->get_var("SHOW TABLES LIKE '{$tables['sitecategories']}'")) { |
|
| 1870 | + unset($tables['sitecategories']); |
|
| 1871 | 1871 | } |
| 1872 | 1872 | |
| 1873 | - foreach ( $tables as $table ) { |
|
| 1874 | - maybe_convert_table_to_utf8mb4( $table ); |
|
| 1873 | + foreach ($tables as $table) { |
|
| 1874 | + maybe_convert_table_to_utf8mb4($table); |
|
| 1875 | 1875 | } |
| 1876 | 1876 | } |
| 1877 | 1877 | } |
@@ -1899,9 +1899,9 @@ discard block |
||
| 1899 | 1899 | function maybe_create_table($table_name, $create_ddl) { |
| 1900 | 1900 | global $wpdb; |
| 1901 | 1901 | |
| 1902 | - $query = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $table_name ) ); |
|
| 1902 | + $query = $wpdb->prepare("SHOW TABLES LIKE %s", $wpdb->esc_like($table_name)); |
|
| 1903 | 1903 | |
| 1904 | - if ( $wpdb->get_var( $query ) == $table_name ) { |
|
| 1904 | + if ($wpdb->get_var($query) == $table_name) { |
|
| 1905 | 1905 | return true; |
| 1906 | 1906 | } |
| 1907 | 1907 | |
@@ -1909,7 +1909,7 @@ discard block |
||
| 1909 | 1909 | $wpdb->query($create_ddl); |
| 1910 | 1910 | |
| 1911 | 1911 | // We cannot directly tell that whether this succeeded! |
| 1912 | - if ( $wpdb->get_var( $query ) == $table_name ) { |
|
| 1912 | + if ($wpdb->get_var($query) == $table_name) { |
|
| 1913 | 1913 | return true; |
| 1914 | 1914 | } |
| 1915 | 1915 | return false; |
@@ -1970,7 +1970,7 @@ discard block |
||
| 1970 | 1970 | */ |
| 1971 | 1971 | function maybe_add_column($table_name, $column_name, $create_ddl) { |
| 1972 | 1972 | global $wpdb; |
| 1973 | - foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) { |
|
| 1973 | + foreach ($wpdb->get_col("DESC $table_name", 0) as $column) { |
|
| 1974 | 1974 | if ($column == $column_name) { |
| 1975 | 1975 | return true; |
| 1976 | 1976 | } |
@@ -1980,7 +1980,7 @@ discard block |
||
| 1980 | 1980 | $wpdb->query($create_ddl); |
| 1981 | 1981 | |
| 1982 | 1982 | // We cannot directly tell that whether this succeeded! |
| 1983 | - foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) { |
|
| 1983 | + foreach ($wpdb->get_col("DESC $table_name", 0) as $column) { |
|
| 1984 | 1984 | if ($column == $column_name) { |
| 1985 | 1985 | return true; |
| 1986 | 1986 | } |
@@ -1998,37 +1998,37 @@ discard block |
||
| 1998 | 1998 | * @param string $table The table to convert. |
| 1999 | 1999 | * @return bool true if the table was converted, false if it wasn't. |
| 2000 | 2000 | */ |
| 2001 | -function maybe_convert_table_to_utf8mb4( $table ) { |
|
| 2001 | +function maybe_convert_table_to_utf8mb4($table) { |
|
| 2002 | 2002 | global $wpdb; |
| 2003 | 2003 | |
| 2004 | - $results = $wpdb->get_results( "SHOW FULL COLUMNS FROM `$table`" ); |
|
| 2005 | - if ( ! $results ) { |
|
| 2004 | + $results = $wpdb->get_results("SHOW FULL COLUMNS FROM `$table`"); |
|
| 2005 | + if ( ! $results) { |
|
| 2006 | 2006 | return false; |
| 2007 | 2007 | } |
| 2008 | 2008 | |
| 2009 | - foreach ( $results as $column ) { |
|
| 2010 | - if ( $column->Collation ) { |
|
| 2011 | - list( $charset ) = explode( '_', $column->Collation ); |
|
| 2012 | - $charset = strtolower( $charset ); |
|
| 2013 | - if ( 'utf8' !== $charset && 'utf8mb4' !== $charset ) { |
|
| 2009 | + foreach ($results as $column) { |
|
| 2010 | + if ($column->Collation) { |
|
| 2011 | + list($charset) = explode('_', $column->Collation); |
|
| 2012 | + $charset = strtolower($charset); |
|
| 2013 | + if ('utf8' !== $charset && 'utf8mb4' !== $charset) { |
|
| 2014 | 2014 | // Don't upgrade tables that have non-utf8 columns. |
| 2015 | 2015 | return false; |
| 2016 | 2016 | } |
| 2017 | 2017 | } |
| 2018 | 2018 | } |
| 2019 | 2019 | |
| 2020 | - $table_details = $wpdb->get_row( "SHOW TABLE STATUS LIKE '$table'" ); |
|
| 2021 | - if ( ! $table_details ) { |
|
| 2020 | + $table_details = $wpdb->get_row("SHOW TABLE STATUS LIKE '$table'"); |
|
| 2021 | + if ( ! $table_details) { |
|
| 2022 | 2022 | return false; |
| 2023 | 2023 | } |
| 2024 | 2024 | |
| 2025 | - list( $table_charset ) = explode( '_', $table_details->Collation ); |
|
| 2026 | - $table_charset = strtolower( $table_charset ); |
|
| 2027 | - if ( 'utf8mb4' === $table_charset ) { |
|
| 2025 | + list($table_charset) = explode('_', $table_details->Collation); |
|
| 2026 | + $table_charset = strtolower($table_charset); |
|
| 2027 | + if ('utf8mb4' === $table_charset) { |
|
| 2028 | 2028 | return true; |
| 2029 | 2029 | } |
| 2030 | 2030 | |
| 2031 | - return $wpdb->query( "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" ); |
|
| 2031 | + return $wpdb->query("ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); |
|
| 2032 | 2032 | } |
| 2033 | 2033 | |
| 2034 | 2034 | /** |
@@ -2043,11 +2043,11 @@ discard block |
||
| 2043 | 2043 | function get_alloptions_110() { |
| 2044 | 2044 | global $wpdb; |
| 2045 | 2045 | $all_options = new stdClass; |
| 2046 | - if ( $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ) ) { |
|
| 2047 | - foreach ( $options as $option ) { |
|
| 2048 | - if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name ) |
|
| 2049 | - $option->option_value = untrailingslashit( $option->option_value ); |
|
| 2050 | - $all_options->{$option->option_name} = stripslashes( $option->option_value ); |
|
| 2046 | + if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options")) { |
|
| 2047 | + foreach ($options as $option) { |
|
| 2048 | + if ('siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name) |
|
| 2049 | + $option->option_value = untrailingslashit($option->option_value); |
|
| 2050 | + $all_options->{$option->option_name} = stripslashes($option->option_value); |
|
| 2051 | 2051 | } |
| 2052 | 2052 | } |
| 2053 | 2053 | return $all_options; |
@@ -2068,21 +2068,21 @@ discard block |
||
| 2068 | 2068 | function __get_option($setting) { |
| 2069 | 2069 | global $wpdb; |
| 2070 | 2070 | |
| 2071 | - if ( $setting == 'home' && defined( 'WP_HOME' ) ) |
|
| 2072 | - return untrailingslashit( WP_HOME ); |
|
| 2071 | + if ($setting == 'home' && defined('WP_HOME')) |
|
| 2072 | + return untrailingslashit(WP_HOME); |
|
| 2073 | 2073 | |
| 2074 | - if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) |
|
| 2075 | - return untrailingslashit( WP_SITEURL ); |
|
| 2074 | + if ($setting == 'siteurl' && defined('WP_SITEURL')) |
|
| 2075 | + return untrailingslashit(WP_SITEURL); |
|
| 2076 | 2076 | |
| 2077 | - $option = $wpdb->get_var( $wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting ) ); |
|
| 2077 | + $option = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting)); |
|
| 2078 | 2078 | |
| 2079 | - if ( 'home' == $setting && '' == $option ) |
|
| 2080 | - return __get_option( 'siteurl' ); |
|
| 2079 | + if ('home' == $setting && '' == $option) |
|
| 2080 | + return __get_option('siteurl'); |
|
| 2081 | 2081 | |
| 2082 | - if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting ) |
|
| 2083 | - $option = untrailingslashit( $option ); |
|
| 2082 | + if ('siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting) |
|
| 2083 | + $option = untrailingslashit($option); |
|
| 2084 | 2084 | |
| 2085 | - return maybe_unserialize( $option ); |
|
| 2085 | + return maybe_unserialize($option); |
|
| 2086 | 2086 | } |
| 2087 | 2087 | |
| 2088 | 2088 | /** |
@@ -2130,16 +2130,16 @@ discard block |
||
| 2130 | 2130 | * Default true. |
| 2131 | 2131 | * @return array Strings containing the results of the various update queries. |
| 2132 | 2132 | */ |
| 2133 | -function dbDelta( $queries = '', $execute = true ) { |
|
| 2133 | +function dbDelta($queries = '', $execute = true) { |
|
| 2134 | 2134 | global $wpdb; |
| 2135 | 2135 | |
| 2136 | - if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) ) |
|
| 2137 | - $queries = wp_get_db_schema( $queries ); |
|
| 2136 | + if (in_array($queries, array('', 'all', 'blog', 'global', 'ms_global'), true)) |
|
| 2137 | + $queries = wp_get_db_schema($queries); |
|
| 2138 | 2138 | |
| 2139 | 2139 | // Separate individual queries into an array |
| 2140 | - if ( !is_array($queries) ) { |
|
| 2141 | - $queries = explode( ';', $queries ); |
|
| 2142 | - $queries = array_filter( $queries ); |
|
| 2140 | + if ( ! is_array($queries)) { |
|
| 2141 | + $queries = explode(';', $queries); |
|
| 2142 | + $queries = array_filter($queries); |
|
| 2143 | 2143 | } |
| 2144 | 2144 | |
| 2145 | 2145 | /** |
@@ -2149,7 +2149,7 @@ discard block |
||
| 2149 | 2149 | * |
| 2150 | 2150 | * @param array $queries An array of dbDelta SQL queries. |
| 2151 | 2151 | */ |
| 2152 | - $queries = apply_filters( 'dbdelta_queries', $queries ); |
|
| 2152 | + $queries = apply_filters('dbdelta_queries', $queries); |
|
| 2153 | 2153 | |
| 2154 | 2154 | $cqueries = array(); // Creation Queries |
| 2155 | 2155 | $iqueries = array(); // Insertion Queries |
@@ -2157,14 +2157,14 @@ discard block |
||
| 2157 | 2157 | |
| 2158 | 2158 | // Create a tablename index for an array ($cqueries) of queries |
| 2159 | 2159 | foreach ($queries as $qry) { |
| 2160 | - if ( preg_match( "|CREATE TABLE ([^ ]*)|", $qry, $matches ) ) { |
|
| 2161 | - $cqueries[ trim( $matches[1], '`' ) ] = $qry; |
|
| 2160 | + if (preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) { |
|
| 2161 | + $cqueries[trim($matches[1], '`')] = $qry; |
|
| 2162 | 2162 | $for_update[$matches[1]] = 'Created table '.$matches[1]; |
| 2163 | - } elseif ( preg_match( "|CREATE DATABASE ([^ ]*)|", $qry, $matches ) ) { |
|
| 2164 | - array_unshift( $cqueries, $qry ); |
|
| 2165 | - } elseif ( preg_match( "|INSERT INTO ([^ ]*)|", $qry, $matches ) ) { |
|
| 2163 | + } elseif (preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) { |
|
| 2164 | + array_unshift($cqueries, $qry); |
|
| 2165 | + } elseif (preg_match("|INSERT INTO ([^ ]*)|", $qry, $matches)) { |
|
| 2166 | 2166 | $iqueries[] = $qry; |
| 2167 | - } elseif ( preg_match( "|UPDATE ([^ ]*)|", $qry, $matches ) ) { |
|
| 2167 | + } elseif (preg_match("|UPDATE ([^ ]*)|", $qry, $matches)) { |
|
| 2168 | 2168 | $iqueries[] = $qry; |
| 2169 | 2169 | } else { |
| 2170 | 2170 | // Unrecognized query type |
@@ -2180,7 +2180,7 @@ discard block |
||
| 2180 | 2180 | * |
| 2181 | 2181 | * @param array $cqueries An array of dbDelta create SQL queries. |
| 2182 | 2182 | */ |
| 2183 | - $cqueries = apply_filters( 'dbdelta_create_queries', $cqueries ); |
|
| 2183 | + $cqueries = apply_filters('dbdelta_create_queries', $cqueries); |
|
| 2184 | 2184 | |
| 2185 | 2185 | /** |
| 2186 | 2186 | * Filters the dbDelta SQL queries for inserting or updating. |
@@ -2191,25 +2191,25 @@ discard block |
||
| 2191 | 2191 | * |
| 2192 | 2192 | * @param array $iqueries An array of dbDelta insert or update SQL queries. |
| 2193 | 2193 | */ |
| 2194 | - $iqueries = apply_filters( 'dbdelta_insert_queries', $iqueries ); |
|
| 2194 | + $iqueries = apply_filters('dbdelta_insert_queries', $iqueries); |
|
| 2195 | 2195 | |
| 2196 | - $text_fields = array( 'tinytext', 'text', 'mediumtext', 'longtext' ); |
|
| 2197 | - $blob_fields = array( 'tinyblob', 'blob', 'mediumblob', 'longblob' ); |
|
| 2196 | + $text_fields = array('tinytext', 'text', 'mediumtext', 'longtext'); |
|
| 2197 | + $blob_fields = array('tinyblob', 'blob', 'mediumblob', 'longblob'); |
|
| 2198 | 2198 | |
| 2199 | - $global_tables = $wpdb->tables( 'global' ); |
|
| 2200 | - foreach ( $cqueries as $table => $qry ) { |
|
| 2199 | + $global_tables = $wpdb->tables('global'); |
|
| 2200 | + foreach ($cqueries as $table => $qry) { |
|
| 2201 | 2201 | // Upgrade global tables only for the main site. Don't upgrade at all if conditions are not optimal. |
| 2202 | - if ( in_array( $table, $global_tables ) && ! wp_should_upgrade_global_tables() ) { |
|
| 2203 | - unset( $cqueries[ $table ], $for_update[ $table ] ); |
|
| 2202 | + if (in_array($table, $global_tables) && ! wp_should_upgrade_global_tables()) { |
|
| 2203 | + unset($cqueries[$table], $for_update[$table]); |
|
| 2204 | 2204 | continue; |
| 2205 | 2205 | } |
| 2206 | 2206 | |
| 2207 | 2207 | // Fetch the table column structure from the database |
| 2208 | 2208 | $suppress = $wpdb->suppress_errors(); |
| 2209 | 2209 | $tablefields = $wpdb->get_results("DESCRIBE {$table};"); |
| 2210 | - $wpdb->suppress_errors( $suppress ); |
|
| 2210 | + $wpdb->suppress_errors($suppress); |
|
| 2211 | 2211 | |
| 2212 | - if ( ! $tablefields ) |
|
| 2212 | + if ( ! $tablefields) |
|
| 2213 | 2213 | continue; |
| 2214 | 2214 | |
| 2215 | 2215 | // Clear the field and index arrays. |
@@ -2223,17 +2223,17 @@ discard block |
||
| 2223 | 2223 | $flds = explode("\n", $qryline); |
| 2224 | 2224 | |
| 2225 | 2225 | // For every field line specified in the query. |
| 2226 | - foreach ( $flds as $fld ) { |
|
| 2227 | - $fld = trim( $fld, " \t\n\r\0\x0B," ); // Default trim characters, plus ','. |
|
| 2226 | + foreach ($flds as $fld) { |
|
| 2227 | + $fld = trim($fld, " \t\n\r\0\x0B,"); // Default trim characters, plus ','. |
|
| 2228 | 2228 | |
| 2229 | 2229 | // Extract the field name. |
| 2230 | - preg_match( '|^([^ ]*)|', $fld, $fvals ); |
|
| 2231 | - $fieldname = trim( $fvals[1], '`' ); |
|
| 2232 | - $fieldname_lowercased = strtolower( $fieldname ); |
|
| 2230 | + preg_match('|^([^ ]*)|', $fld, $fvals); |
|
| 2231 | + $fieldname = trim($fvals[1], '`'); |
|
| 2232 | + $fieldname_lowercased = strtolower($fieldname); |
|
| 2233 | 2233 | |
| 2234 | 2234 | // Verify the found field name. |
| 2235 | 2235 | $validfield = true; |
| 2236 | - switch ( $fieldname_lowercased ) { |
|
| 2236 | + switch ($fieldname_lowercased) { |
|
| 2237 | 2237 | case '': |
| 2238 | 2238 | case 'primary': |
| 2239 | 2239 | case 'index': |
@@ -2277,19 +2277,19 @@ discard block |
||
| 2277 | 2277 | ); |
| 2278 | 2278 | |
| 2279 | 2279 | // Uppercase the index type and normalize space characters. |
| 2280 | - $index_type = strtoupper( preg_replace( '/\s+/', ' ', trim( $index_matches['index_type'] ) ) ); |
|
| 2280 | + $index_type = strtoupper(preg_replace('/\s+/', ' ', trim($index_matches['index_type']))); |
|
| 2281 | 2281 | |
| 2282 | 2282 | // 'INDEX' is a synonym for 'KEY', standardize on 'KEY'. |
| 2283 | - $index_type = str_replace( 'INDEX', 'KEY', $index_type ); |
|
| 2283 | + $index_type = str_replace('INDEX', 'KEY', $index_type); |
|
| 2284 | 2284 | |
| 2285 | 2285 | // Escape the index name with backticks. An index for a primary key has no name. |
| 2286 | - $index_name = ( 'PRIMARY KEY' === $index_type ) ? '' : '`' . $index_matches['index_name'] . '`'; |
|
| 2286 | + $index_name = ('PRIMARY KEY' === $index_type) ? '' : '`'.$index_matches['index_name'].'`'; |
|
| 2287 | 2287 | |
| 2288 | 2288 | // Parse the columns. Multiple columns are separated by a comma. |
| 2289 | - $index_columns = array_map( 'trim', explode( ',', $index_matches['index_columns'] ) ); |
|
| 2289 | + $index_columns = array_map('trim', explode(',', $index_matches['index_columns'])); |
|
| 2290 | 2290 | |
| 2291 | 2291 | // Normalize columns. |
| 2292 | - foreach ( $index_columns as &$index_column ) { |
|
| 2292 | + foreach ($index_columns as &$index_column) { |
|
| 2293 | 2293 | // Extract column name and number of indexed characters (sub_part). |
| 2294 | 2294 | preg_match( |
| 2295 | 2295 | '/' |
@@ -2314,66 +2314,66 @@ discard block |
||
| 2314 | 2314 | ); |
| 2315 | 2315 | |
| 2316 | 2316 | // Escape the column name with backticks. |
| 2317 | - $index_column = '`' . $index_column_matches['column_name'] . '`'; |
|
| 2317 | + $index_column = '`'.$index_column_matches['column_name'].'`'; |
|
| 2318 | 2318 | |
| 2319 | 2319 | // Append the optional sup part with the number of indexed characters. |
| 2320 | - if ( isset( $index_column_matches['sub_part'] ) ) { |
|
| 2321 | - $index_column .= '(' . $index_column_matches['sub_part'] . ')'; |
|
| 2320 | + if (isset($index_column_matches['sub_part'])) { |
|
| 2321 | + $index_column .= '('.$index_column_matches['sub_part'].')'; |
|
| 2322 | 2322 | } |
| 2323 | 2323 | } |
| 2324 | 2324 | |
| 2325 | 2325 | // Build the normalized index definition and add it to the list of indices. |
| 2326 | - $indices[] = "{$index_type} {$index_name} (" . implode( ',', $index_columns ) . ")"; |
|
| 2326 | + $indices[] = "{$index_type} {$index_name} (".implode(',', $index_columns).")"; |
|
| 2327 | 2327 | |
| 2328 | 2328 | // Destroy no longer needed variables. |
| 2329 | - unset( $index_column, $index_column_matches, $index_matches, $index_type, $index_name, $index_columns ); |
|
| 2329 | + unset($index_column, $index_column_matches, $index_matches, $index_type, $index_name, $index_columns); |
|
| 2330 | 2330 | |
| 2331 | 2331 | break; |
| 2332 | 2332 | } |
| 2333 | 2333 | |
| 2334 | 2334 | // If it's a valid field, add it to the field array. |
| 2335 | - if ( $validfield ) { |
|
| 2336 | - $cfields[ $fieldname_lowercased ] = $fld; |
|
| 2335 | + if ($validfield) { |
|
| 2336 | + $cfields[$fieldname_lowercased] = $fld; |
|
| 2337 | 2337 | } |
| 2338 | 2338 | } |
| 2339 | 2339 | |
| 2340 | 2340 | // For every field in the table. |
| 2341 | - foreach ( $tablefields as $tablefield ) { |
|
| 2342 | - $tablefield_field_lowercased = strtolower( $tablefield->Field ); |
|
| 2343 | - $tablefield_type_lowercased = strtolower( $tablefield->Type ); |
|
| 2341 | + foreach ($tablefields as $tablefield) { |
|
| 2342 | + $tablefield_field_lowercased = strtolower($tablefield->Field); |
|
| 2343 | + $tablefield_type_lowercased = strtolower($tablefield->Type); |
|
| 2344 | 2344 | |
| 2345 | 2345 | // If the table field exists in the field array ... |
| 2346 | - if ( array_key_exists( $tablefield_field_lowercased, $cfields ) ) { |
|
| 2346 | + if (array_key_exists($tablefield_field_lowercased, $cfields)) { |
|
| 2347 | 2347 | |
| 2348 | 2348 | // Get the field type from the query. |
| 2349 | - preg_match( '|`?' . $tablefield->Field . '`? ([^ ]*( unsigned)?)|i', $cfields[ $tablefield_field_lowercased ], $matches ); |
|
| 2349 | + preg_match('|`?'.$tablefield->Field.'`? ([^ ]*( unsigned)?)|i', $cfields[$tablefield_field_lowercased], $matches); |
|
| 2350 | 2350 | $fieldtype = $matches[1]; |
| 2351 | - $fieldtype_lowercased = strtolower( $fieldtype ); |
|
| 2351 | + $fieldtype_lowercased = strtolower($fieldtype); |
|
| 2352 | 2352 | |
| 2353 | 2353 | // Is actual field type different from the field type in query? |
| 2354 | 2354 | if ($tablefield->Type != $fieldtype) { |
| 2355 | 2355 | $do_change = true; |
| 2356 | - if ( in_array( $fieldtype_lowercased, $text_fields ) && in_array( $tablefield_type_lowercased, $text_fields ) ) { |
|
| 2357 | - if ( array_search( $fieldtype_lowercased, $text_fields ) < array_search( $tablefield_type_lowercased, $text_fields ) ) { |
|
| 2356 | + if (in_array($fieldtype_lowercased, $text_fields) && in_array($tablefield_type_lowercased, $text_fields)) { |
|
| 2357 | + if (array_search($fieldtype_lowercased, $text_fields) < array_search($tablefield_type_lowercased, $text_fields)) { |
|
| 2358 | 2358 | $do_change = false; |
| 2359 | 2359 | } |
| 2360 | 2360 | } |
| 2361 | 2361 | |
| 2362 | - if ( in_array( $fieldtype_lowercased, $blob_fields ) && in_array( $tablefield_type_lowercased, $blob_fields ) ) { |
|
| 2363 | - if ( array_search( $fieldtype_lowercased, $blob_fields ) < array_search( $tablefield_type_lowercased, $blob_fields ) ) { |
|
| 2362 | + if (in_array($fieldtype_lowercased, $blob_fields) && in_array($tablefield_type_lowercased, $blob_fields)) { |
|
| 2363 | + if (array_search($fieldtype_lowercased, $blob_fields) < array_search($tablefield_type_lowercased, $blob_fields)) { |
|
| 2364 | 2364 | $do_change = false; |
| 2365 | 2365 | } |
| 2366 | 2366 | } |
| 2367 | 2367 | |
| 2368 | - if ( $do_change ) { |
|
| 2368 | + if ($do_change) { |
|
| 2369 | 2369 | // Add a query to change the column type. |
| 2370 | - $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN `{$tablefield->Field}` " . $cfields[ $tablefield_field_lowercased ]; |
|
| 2370 | + $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN `{$tablefield->Field}` ".$cfields[$tablefield_field_lowercased]; |
|
| 2371 | 2371 | $for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}"; |
| 2372 | 2372 | } |
| 2373 | 2373 | } |
| 2374 | 2374 | |
| 2375 | 2375 | // Get the default value from the array. |
| 2376 | - if ( preg_match( "| DEFAULT '(.*?)'|i", $cfields[ $tablefield_field_lowercased ], $matches ) ) { |
|
| 2376 | + if (preg_match("| DEFAULT '(.*?)'|i", $cfields[$tablefield_field_lowercased], $matches)) { |
|
| 2377 | 2377 | $default_value = $matches[1]; |
| 2378 | 2378 | if ($tablefield->Default != $default_value) { |
| 2379 | 2379 | // Add a query to change the column's default value |
@@ -2383,7 +2383,7 @@ discard block |
||
| 2383 | 2383 | } |
| 2384 | 2384 | |
| 2385 | 2385 | // Remove the field from the array (so it's not added). |
| 2386 | - unset( $cfields[ $tablefield_field_lowercased ] ); |
|
| 2386 | + unset($cfields[$tablefield_field_lowercased]); |
|
| 2387 | 2387 | } else { |
| 2388 | 2388 | // This field exists in the table, but not in the creation queries? |
| 2389 | 2389 | } |
@@ -2409,7 +2409,7 @@ discard block |
||
| 2409 | 2409 | // Add the index to the index data array. |
| 2410 | 2410 | $keyname = $tableindex->Key_name; |
| 2411 | 2411 | $index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part); |
| 2412 | - $index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0)?true:false; |
|
| 2412 | + $index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0) ? true : false; |
|
| 2413 | 2413 | $index_ary[$keyname]['index_type'] = $tableindex->Index_type; |
| 2414 | 2414 | } |
| 2415 | 2415 | |
@@ -2420,36 +2420,36 @@ discard block |
||
| 2420 | 2420 | $index_string = ''; |
| 2421 | 2421 | if ($index_name == 'PRIMARY') { |
| 2422 | 2422 | $index_string .= 'PRIMARY '; |
| 2423 | - } elseif ( $index_data['unique'] ) { |
|
| 2423 | + } elseif ($index_data['unique']) { |
|
| 2424 | 2424 | $index_string .= 'UNIQUE '; |
| 2425 | 2425 | } |
| 2426 | - if ( 'FULLTEXT' === strtoupper( $index_data['index_type'] ) ) { |
|
| 2426 | + if ('FULLTEXT' === strtoupper($index_data['index_type'])) { |
|
| 2427 | 2427 | $index_string .= 'FULLTEXT '; |
| 2428 | 2428 | } |
| 2429 | - if ( 'SPATIAL' === strtoupper( $index_data['index_type'] ) ) { |
|
| 2429 | + if ('SPATIAL' === strtoupper($index_data['index_type'])) { |
|
| 2430 | 2430 | $index_string .= 'SPATIAL '; |
| 2431 | 2431 | } |
| 2432 | 2432 | $index_string .= 'KEY '; |
| 2433 | - if ( 'PRIMARY' !== $index_name ) { |
|
| 2434 | - $index_string .= '`' . $index_name . '`'; |
|
| 2433 | + if ('PRIMARY' !== $index_name) { |
|
| 2434 | + $index_string .= '`'.$index_name.'`'; |
|
| 2435 | 2435 | } |
| 2436 | 2436 | $index_columns = ''; |
| 2437 | 2437 | |
| 2438 | 2438 | // For each column in the index. |
| 2439 | 2439 | foreach ($index_data['columns'] as $column_data) { |
| 2440 | - if ( $index_columns != '' ) { |
|
| 2440 | + if ($index_columns != '') { |
|
| 2441 | 2441 | $index_columns .= ','; |
| 2442 | 2442 | } |
| 2443 | 2443 | |
| 2444 | 2444 | // Add the field to the column list string. |
| 2445 | - $index_columns .= '`' . $column_data['fieldname'] . '`'; |
|
| 2445 | + $index_columns .= '`'.$column_data['fieldname'].'`'; |
|
| 2446 | 2446 | if ($column_data['subpart'] != '') { |
| 2447 | 2447 | $index_columns .= '('.$column_data['subpart'].')'; |
| 2448 | 2448 | } |
| 2449 | 2449 | } |
| 2450 | 2450 | |
| 2451 | 2451 | // The alternative index string doesn't care about subparts |
| 2452 | - $alt_index_columns = preg_replace( '/\([^)]*\)/', '', $index_columns ); |
|
| 2452 | + $alt_index_columns = preg_replace('/\([^)]*\)/', '', $index_columns); |
|
| 2453 | 2453 | |
| 2454 | 2454 | // Add the column list to the index create string. |
| 2455 | 2455 | $index_strings = array( |
@@ -2457,9 +2457,9 @@ discard block |
||
| 2457 | 2457 | "$index_string ($alt_index_columns)", |
| 2458 | 2458 | ); |
| 2459 | 2459 | |
| 2460 | - foreach ( $index_strings as $index_string ) { |
|
| 2461 | - if ( ! ( ( $aindex = array_search( $index_string, $indices ) ) === false ) ) { |
|
| 2462 | - unset( $indices[ $aindex ] ); |
|
| 2460 | + foreach ($index_strings as $index_string) { |
|
| 2461 | + if ( ! (($aindex = array_search($index_string, $indices)) === false)) { |
|
| 2462 | + unset($indices[$aindex]); |
|
| 2463 | 2463 | break; |
| 2464 | 2464 | } |
| 2465 | 2465 | } |
@@ -2467,14 +2467,14 @@ discard block |
||
| 2467 | 2467 | } |
| 2468 | 2468 | |
| 2469 | 2469 | // For every remaining index specified for the table. |
| 2470 | - foreach ( (array) $indices as $index ) { |
|
| 2470 | + foreach ((array) $indices as $index) { |
|
| 2471 | 2471 | // Push a query line into $cqueries that adds the index to that table. |
| 2472 | 2472 | $cqueries[] = "ALTER TABLE {$table} ADD $index"; |
| 2473 | - $for_update[] = 'Added index ' . $table . ' ' . $index; |
|
| 2473 | + $for_update[] = 'Added index '.$table.' '.$index; |
|
| 2474 | 2474 | } |
| 2475 | 2475 | |
| 2476 | 2476 | // Remove the original table creation query from processing. |
| 2477 | - unset( $cqueries[ $table ], $for_update[ $table ] ); |
|
| 2477 | + unset($cqueries[$table], $for_update[$table]); |
|
| 2478 | 2478 | } |
| 2479 | 2479 | |
| 2480 | 2480 | $allqueries = array_merge($cqueries, $iqueries); |
@@ -2499,8 +2499,8 @@ discard block |
||
| 2499 | 2499 | * |
| 2500 | 2500 | * @param string $tables Optional. Which set of tables to update. Default is 'all'. |
| 2501 | 2501 | */ |
| 2502 | -function make_db_current( $tables = 'all' ) { |
|
| 2503 | - $alterations = dbDelta( $tables ); |
|
| 2502 | +function make_db_current($tables = 'all') { |
|
| 2503 | + $alterations = dbDelta($tables); |
|
| 2504 | 2504 | echo "<ol>\n"; |
| 2505 | 2505 | foreach ($alterations as $alteration) echo "<li>$alteration</li>\n"; |
| 2506 | 2506 | echo "</ol>\n"; |
@@ -2518,8 +2518,8 @@ discard block |
||
| 2518 | 2518 | * |
| 2519 | 2519 | * @param string $tables Optional. Which set of tables to update. Default is 'all'. |
| 2520 | 2520 | */ |
| 2521 | -function make_db_current_silent( $tables = 'all' ) { |
|
| 2522 | - dbDelta( $tables ); |
|
| 2521 | +function make_db_current_silent($tables = 'all') { |
|
| 2522 | + dbDelta($tables); |
|
| 2523 | 2523 | } |
| 2524 | 2524 | |
| 2525 | 2525 | /** |
@@ -2535,9 +2535,9 @@ discard block |
||
| 2535 | 2535 | */ |
| 2536 | 2536 | function make_site_theme_from_oldschool($theme_name, $template) { |
| 2537 | 2537 | $home_path = get_home_path(); |
| 2538 | - $site_dir = WP_CONTENT_DIR . "/themes/$template"; |
|
| 2538 | + $site_dir = WP_CONTENT_DIR."/themes/$template"; |
|
| 2539 | 2539 | |
| 2540 | - if (! file_exists("$home_path/index.php")) |
|
| 2540 | + if ( ! file_exists("$home_path/index.php")) |
|
| 2541 | 2541 | return false; |
| 2542 | 2542 | |
| 2543 | 2543 | /* |
@@ -2556,7 +2556,7 @@ discard block |
||
| 2556 | 2556 | if ($oldfile == 'index.php') { |
| 2557 | 2557 | $index = implode('', file("$oldpath/$oldfile")); |
| 2558 | 2558 | if (strpos($index, 'WP_USE_THEMES') !== false) { |
| 2559 | - if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile")) |
|
| 2559 | + if ( ! @copy(WP_CONTENT_DIR.'/themes/'.WP_DEFAULT_THEME.'/index.php', "$site_dir/$newfile")) |
|
| 2560 | 2560 | return false; |
| 2561 | 2561 | |
| 2562 | 2562 | // Don't copy anything. |
@@ -2564,7 +2564,7 @@ discard block |
||
| 2564 | 2564 | } |
| 2565 | 2565 | } |
| 2566 | 2566 | |
| 2567 | - if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile")) |
|
| 2567 | + if ( ! @copy("$oldpath/$oldfile", "$site_dir/$newfile")) |
|
| 2568 | 2568 | return false; |
| 2569 | 2569 | |
| 2570 | 2570 | chmod("$site_dir/$newfile", 0777); |
@@ -2576,7 +2576,7 @@ discard block |
||
| 2576 | 2576 | |
| 2577 | 2577 | foreach ($lines as $line) { |
| 2578 | 2578 | if (preg_match('/require.*wp-blog-header/', $line)) |
| 2579 | - $line = '//' . $line; |
|
| 2579 | + $line = '//'.$line; |
|
| 2580 | 2580 | |
| 2581 | 2581 | // Update stylesheet references. |
| 2582 | 2582 | $line = str_replace("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line); |
@@ -2591,7 +2591,7 @@ discard block |
||
| 2591 | 2591 | } |
| 2592 | 2592 | |
| 2593 | 2593 | // Add a theme header. |
| 2594 | - $header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option('siteurl') . "\nDescription: A theme automatically created by the update.\nVersion: 1.0\nAuthor: Moi\n*/\n"; |
|
| 2594 | + $header = "/*\nTheme Name: $theme_name\nTheme URI: ".__get_option('siteurl')."\nDescription: A theme automatically created by the update.\nVersion: 1.0\nAuthor: Moi\n*/\n"; |
|
| 2595 | 2595 | |
| 2596 | 2596 | $stylelines = file_get_contents("$site_dir/style.css"); |
| 2597 | 2597 | if ($stylelines) { |
@@ -2617,18 +2617,18 @@ discard block |
||
| 2617 | 2617 | * @return false|void |
| 2618 | 2618 | */ |
| 2619 | 2619 | function make_site_theme_from_default($theme_name, $template) { |
| 2620 | - $site_dir = WP_CONTENT_DIR . "/themes/$template"; |
|
| 2621 | - $default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME; |
|
| 2620 | + $site_dir = WP_CONTENT_DIR."/themes/$template"; |
|
| 2621 | + $default_dir = WP_CONTENT_DIR.'/themes/'.WP_DEFAULT_THEME; |
|
| 2622 | 2622 | |
| 2623 | 2623 | // Copy files from the default theme to the site theme. |
| 2624 | 2624 | //$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css'); |
| 2625 | 2625 | |
| 2626 | 2626 | $theme_dir = @ opendir($default_dir); |
| 2627 | 2627 | if ($theme_dir) { |
| 2628 | - while(($theme_file = readdir( $theme_dir )) !== false) { |
|
| 2628 | + while (($theme_file = readdir($theme_dir)) !== false) { |
|
| 2629 | 2629 | if (is_dir("$default_dir/$theme_file")) |
| 2630 | 2630 | continue; |
| 2631 | - if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file")) |
|
| 2631 | + if ( ! @copy("$default_dir/$theme_file", "$site_dir/$theme_file")) |
|
| 2632 | 2632 | return; |
| 2633 | 2633 | chmod("$site_dir/$theme_file", 0777); |
| 2634 | 2634 | } |
@@ -2641,28 +2641,28 @@ discard block |
||
| 2641 | 2641 | $f = fopen("$site_dir/style.css", 'w'); |
| 2642 | 2642 | |
| 2643 | 2643 | foreach ($stylelines as $line) { |
| 2644 | - if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name; |
|
| 2645 | - elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url'); |
|
| 2644 | + if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: '.$theme_name; |
|
| 2645 | + elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: '.__get_option('url'); |
|
| 2646 | 2646 | elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.'; |
| 2647 | 2647 | elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1'; |
| 2648 | 2648 | elseif (strpos($line, 'Author:') !== false) $line = 'Author: You'; |
| 2649 | - fwrite($f, $line . "\n"); |
|
| 2649 | + fwrite($f, $line."\n"); |
|
| 2650 | 2650 | } |
| 2651 | 2651 | fclose($f); |
| 2652 | 2652 | } |
| 2653 | 2653 | |
| 2654 | 2654 | // Copy the images. |
| 2655 | 2655 | umask(0); |
| 2656 | - if (! mkdir("$site_dir/images", 0777)) { |
|
| 2656 | + if ( ! mkdir("$site_dir/images", 0777)) { |
|
| 2657 | 2657 | return false; |
| 2658 | 2658 | } |
| 2659 | 2659 | |
| 2660 | 2660 | $images_dir = @ opendir("$default_dir/images"); |
| 2661 | 2661 | if ($images_dir) { |
| 2662 | - while(($image = readdir($images_dir)) !== false) { |
|
| 2662 | + while (($image = readdir($images_dir)) !== false) { |
|
| 2663 | 2663 | if (is_dir("$default_dir/images/$image")) |
| 2664 | 2664 | continue; |
| 2665 | - if (! @copy("$default_dir/images/$image", "$site_dir/images/$image")) |
|
| 2665 | + if ( ! @copy("$default_dir/images/$image", "$site_dir/images/$image")) |
|
| 2666 | 2666 | return; |
| 2667 | 2667 | chmod("$site_dir/images/$image", 0777); |
| 2668 | 2668 | } |
@@ -2683,30 +2683,30 @@ discard block |
||
| 2683 | 2683 | // Name the theme after the blog. |
| 2684 | 2684 | $theme_name = __get_option('blogname'); |
| 2685 | 2685 | $template = sanitize_title($theme_name); |
| 2686 | - $site_dir = WP_CONTENT_DIR . "/themes/$template"; |
|
| 2686 | + $site_dir = WP_CONTENT_DIR."/themes/$template"; |
|
| 2687 | 2687 | |
| 2688 | 2688 | // If the theme already exists, nothing to do. |
| 2689 | - if ( is_dir($site_dir)) { |
|
| 2689 | + if (is_dir($site_dir)) { |
|
| 2690 | 2690 | return false; |
| 2691 | 2691 | } |
| 2692 | 2692 | |
| 2693 | 2693 | // We must be able to write to the themes dir. |
| 2694 | - if (! is_writable(WP_CONTENT_DIR . "/themes")) { |
|
| 2694 | + if ( ! is_writable(WP_CONTENT_DIR."/themes")) { |
|
| 2695 | 2695 | return false; |
| 2696 | 2696 | } |
| 2697 | 2697 | |
| 2698 | 2698 | umask(0); |
| 2699 | - if (! mkdir($site_dir, 0777)) { |
|
| 2699 | + if ( ! mkdir($site_dir, 0777)) { |
|
| 2700 | 2700 | return false; |
| 2701 | 2701 | } |
| 2702 | 2702 | |
| 2703 | - if (file_exists(ABSPATH . 'wp-layout.css')) { |
|
| 2704 | - if (! make_site_theme_from_oldschool($theme_name, $template)) { |
|
| 2703 | + if (file_exists(ABSPATH.'wp-layout.css')) { |
|
| 2704 | + if ( ! make_site_theme_from_oldschool($theme_name, $template)) { |
|
| 2705 | 2705 | // TODO: rm -rf the site theme directory. |
| 2706 | 2706 | return false; |
| 2707 | 2707 | } |
| 2708 | 2708 | } else { |
| 2709 | - if (! make_site_theme_from_default($theme_name, $template)) |
|
| 2709 | + if ( ! make_site_theme_from_default($theme_name, $template)) |
|
| 2710 | 2710 | // TODO: rm -rf the site theme directory. |
| 2711 | 2711 | return false; |
| 2712 | 2712 | } |
@@ -2759,8 +2759,8 @@ discard block |
||
| 2759 | 2759 | function wp_check_mysql_version() { |
| 2760 | 2760 | global $wpdb; |
| 2761 | 2761 | $result = $wpdb->check_database_version(); |
| 2762 | - if ( is_wp_error( $result ) ) |
|
| 2763 | - die( $result->get_error_message() ); |
|
| 2762 | + if (is_wp_error($result)) |
|
| 2763 | + die($result->get_error_message()); |
|
| 2764 | 2764 | } |
| 2765 | 2765 | |
| 2766 | 2766 | /** |
@@ -2769,12 +2769,12 @@ discard block |
||
| 2769 | 2769 | * @since 2.2.0 |
| 2770 | 2770 | */ |
| 2771 | 2771 | function maybe_disable_automattic_widgets() { |
| 2772 | - $plugins = __get_option( 'active_plugins' ); |
|
| 2772 | + $plugins = __get_option('active_plugins'); |
|
| 2773 | 2773 | |
| 2774 | - foreach ( (array) $plugins as $plugin ) { |
|
| 2775 | - if ( basename( $plugin ) == 'widgets.php' ) { |
|
| 2776 | - array_splice( $plugins, array_search( $plugin, $plugins ), 1 ); |
|
| 2777 | - update_option( 'active_plugins', $plugins ); |
|
| 2774 | + foreach ((array) $plugins as $plugin) { |
|
| 2775 | + if (basename($plugin) == 'widgets.php') { |
|
| 2776 | + array_splice($plugins, array_search($plugin, $plugins), 1); |
|
| 2777 | + update_option('active_plugins', $plugins); |
|
| 2778 | 2778 | break; |
| 2779 | 2779 | } |
| 2780 | 2780 | } |
@@ -2791,8 +2791,8 @@ discard block |
||
| 2791 | 2791 | function maybe_disable_link_manager() { |
| 2792 | 2792 | global $wp_current_db_version, $wpdb; |
| 2793 | 2793 | |
| 2794 | - if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) |
|
| 2795 | - update_option( 'link_manager_enabled', 0 ); |
|
| 2794 | + if ($wp_current_db_version >= 22006 && get_option('link_manager_enabled') && ! $wpdb->get_var("SELECT link_id FROM $wpdb->links LIMIT 1")) |
|
| 2795 | + update_option('link_manager_enabled', 0); |
|
| 2796 | 2796 | } |
| 2797 | 2797 | |
| 2798 | 2798 | /** |
@@ -2807,7 +2807,7 @@ discard block |
||
| 2807 | 2807 | global $wp_current_db_version, $wpdb; |
| 2808 | 2808 | |
| 2809 | 2809 | // Upgrade versions prior to 2.9 |
| 2810 | - if ( $wp_current_db_version < 11557 ) { |
|
| 2810 | + if ($wp_current_db_version < 11557) { |
|
| 2811 | 2811 | // Delete duplicate options. Keep the option with the highest option_id. |
| 2812 | 2812 | $wpdb->query("DELETE o1 FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2 USING (`option_name`) WHERE o2.option_id > o1.option_id"); |
| 2813 | 2813 | |
@@ -2819,40 +2819,40 @@ discard block |
||
| 2819 | 2819 | } |
| 2820 | 2820 | |
| 2821 | 2821 | // Multisite schema upgrades. |
| 2822 | - if ( $wp_current_db_version < 25448 && is_multisite() && wp_should_upgrade_global_tables() ) { |
|
| 2822 | + if ($wp_current_db_version < 25448 && is_multisite() && wp_should_upgrade_global_tables()) { |
|
| 2823 | 2823 | |
| 2824 | 2824 | // Upgrade verions prior to 3.7 |
| 2825 | - if ( $wp_current_db_version < 25179 ) { |
|
| 2825 | + if ($wp_current_db_version < 25179) { |
|
| 2826 | 2826 | // New primary key for signups. |
| 2827 | - $wpdb->query( "ALTER TABLE $wpdb->signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST" ); |
|
| 2828 | - $wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain" ); |
|
| 2827 | + $wpdb->query("ALTER TABLE $wpdb->signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST"); |
|
| 2828 | + $wpdb->query("ALTER TABLE $wpdb->signups DROP INDEX domain"); |
|
| 2829 | 2829 | } |
| 2830 | 2830 | |
| 2831 | - if ( $wp_current_db_version < 25448 ) { |
|
| 2831 | + if ($wp_current_db_version < 25448) { |
|
| 2832 | 2832 | // Convert archived from enum to tinyint. |
| 2833 | - $wpdb->query( "ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived varchar(1) NOT NULL default '0'" ); |
|
| 2834 | - $wpdb->query( "ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived tinyint(2) NOT NULL default 0" ); |
|
| 2833 | + $wpdb->query("ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived varchar(1) NOT NULL default '0'"); |
|
| 2834 | + $wpdb->query("ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived tinyint(2) NOT NULL default 0"); |
|
| 2835 | 2835 | } |
| 2836 | 2836 | } |
| 2837 | 2837 | |
| 2838 | 2838 | // Upgrade versions prior to 4.2. |
| 2839 | - if ( $wp_current_db_version < 31351 ) { |
|
| 2840 | - if ( ! is_multisite() && wp_should_upgrade_global_tables() ) { |
|
| 2841 | - $wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" ); |
|
| 2839 | + if ($wp_current_db_version < 31351) { |
|
| 2840 | + if ( ! is_multisite() && wp_should_upgrade_global_tables()) { |
|
| 2841 | + $wpdb->query("ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))"); |
|
| 2842 | 2842 | } |
| 2843 | - $wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX slug, ADD INDEX slug(slug(191))" ); |
|
| 2844 | - $wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX name, ADD INDEX name(name(191))" ); |
|
| 2845 | - $wpdb->query( "ALTER TABLE $wpdb->commentmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" ); |
|
| 2846 | - $wpdb->query( "ALTER TABLE $wpdb->postmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" ); |
|
| 2847 | - $wpdb->query( "ALTER TABLE $wpdb->posts DROP INDEX post_name, ADD INDEX post_name(post_name(191))" ); |
|
| 2843 | + $wpdb->query("ALTER TABLE $wpdb->terms DROP INDEX slug, ADD INDEX slug(slug(191))"); |
|
| 2844 | + $wpdb->query("ALTER TABLE $wpdb->terms DROP INDEX name, ADD INDEX name(name(191))"); |
|
| 2845 | + $wpdb->query("ALTER TABLE $wpdb->commentmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))"); |
|
| 2846 | + $wpdb->query("ALTER TABLE $wpdb->postmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))"); |
|
| 2847 | + $wpdb->query("ALTER TABLE $wpdb->posts DROP INDEX post_name, ADD INDEX post_name(post_name(191))"); |
|
| 2848 | 2848 | } |
| 2849 | 2849 | |
| 2850 | 2850 | // Upgrade versions prior to 4.4. |
| 2851 | - if ( $wp_current_db_version < 34978 ) { |
|
| 2851 | + if ($wp_current_db_version < 34978) { |
|
| 2852 | 2852 | // If compatible termmeta table is found, use it, but enforce a proper index and update collation. |
| 2853 | - if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->termmeta}'" ) && $wpdb->get_results( "SHOW INDEX FROM {$wpdb->termmeta} WHERE Column_name = 'meta_key'" ) ) { |
|
| 2854 | - $wpdb->query( "ALTER TABLE $wpdb->termmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" ); |
|
| 2855 | - maybe_convert_table_to_utf8mb4( $wpdb->termmeta ); |
|
| 2853 | + if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->termmeta}'") && $wpdb->get_results("SHOW INDEX FROM {$wpdb->termmeta} WHERE Column_name = 'meta_key'")) { |
|
| 2854 | + $wpdb->query("ALTER TABLE $wpdb->termmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))"); |
|
| 2855 | + maybe_convert_table_to_utf8mb4($wpdb->termmeta); |
|
| 2856 | 2856 | } |
| 2857 | 2857 | } |
| 2858 | 2858 | } |
@@ -2865,7 +2865,7 @@ discard block |
||
| 2865 | 2865 | * @global wpdb $wpdb |
| 2866 | 2866 | * @global string $charset_collate |
| 2867 | 2867 | */ |
| 2868 | -if ( !function_exists( 'install_global_terms' ) ) : |
|
| 2868 | +if ( ! function_exists('install_global_terms')) : |
|
| 2869 | 2869 | function install_global_terms() { |
| 2870 | 2870 | global $wpdb, $charset_collate; |
| 2871 | 2871 | $ms_queries = " |
@@ -2880,7 +2880,7 @@ discard block |
||
| 2880 | 2880 | ) $charset_collate; |
| 2881 | 2881 | "; |
| 2882 | 2882 | // now create tables |
| 2883 | - dbDelta( $ms_queries ); |
|
| 2883 | + dbDelta($ms_queries); |
|
| 2884 | 2884 | } |
| 2885 | 2885 | endif; |
| 2886 | 2886 | |
@@ -2905,7 +2905,7 @@ discard block |
||
| 2905 | 2905 | function wp_should_upgrade_global_tables() { |
| 2906 | 2906 | |
| 2907 | 2907 | // Return false early if explicitly not upgrading |
| 2908 | - if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) { |
|
| 2908 | + if (defined('DO_NOT_UPGRADE_GLOBAL_TABLES')) { |
|
| 2909 | 2909 | return false; |
| 2910 | 2910 | } |
| 2911 | 2911 | |
@@ -2913,12 +2913,12 @@ discard block |
||
| 2913 | 2913 | $should_upgrade = true; |
| 2914 | 2914 | |
| 2915 | 2915 | // Set to false if not on main network (does not matter if not multi-network) |
| 2916 | - if ( ! is_main_network() ) { |
|
| 2916 | + if ( ! is_main_network()) { |
|
| 2917 | 2917 | $should_upgrade = false; |
| 2918 | 2918 | } |
| 2919 | 2919 | |
| 2920 | 2920 | // Set to false if not on main site of current network (does not matter if not multi-site) |
| 2921 | - if ( ! is_main_site() ) { |
|
| 2921 | + if ( ! is_main_site()) { |
|
| 2922 | 2922 | $should_upgrade = false; |
| 2923 | 2923 | } |
| 2924 | 2924 | |
@@ -2927,5 +2927,5 @@ discard block |
||
| 2927 | 2927 | * |
| 2928 | 2928 | * @param bool $should_upgrade Whether to run the upgrade routines on global tables. |
| 2929 | 2929 | */ |
| 2930 | - return apply_filters( 'wp_should_upgrade_global_tables', $should_upgrade ); |
|
| 2930 | + return apply_filters('wp_should_upgrade_global_tables', $should_upgrade); |
|
| 2931 | 2931 | } |
@@ -9,8 +9,9 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | /** Include user install customize script. */ |
| 12 | -if ( file_exists(WP_CONTENT_DIR . '/install.php') ) |
|
| 12 | +if ( file_exists(WP_CONTENT_DIR . '/install.php') ) { |
|
| 13 | 13 | require (WP_CONTENT_DIR . '/install.php'); |
| 14 | +} |
|
| 14 | 15 | |
| 15 | 16 | /** WordPress Administration API */ |
| 16 | 17 | require_once(ABSPATH . 'wp-admin/includes/admin.php'); |
@@ -37,8 +38,9 @@ discard block |
||
| 37 | 38 | * @return array Array keys 'url', 'user_id', 'password', and 'password_message'. |
| 38 | 39 | */ |
| 39 | 40 | function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '' ) { |
| 40 | - if ( !empty( $deprecated ) ) |
|
| 41 | - _deprecated_argument( __FUNCTION__, '2.6.0' ); |
|
| 41 | + if ( !empty( $deprecated ) ) { |
|
| 42 | + _deprecated_argument( __FUNCTION__, '2.6.0' ); |
|
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | wp_check_mysql_version(); |
| 44 | 46 | wp_cache_flush(); |
@@ -59,8 +61,9 @@ discard block |
||
| 59 | 61 | update_option('siteurl', $guessurl); |
| 60 | 62 | |
| 61 | 63 | // If not a public blog, don't ping. |
| 62 | - if ( ! $public ) |
|
| 63 | - update_option('default_pingback_flag', 0); |
|
| 64 | + if ( ! $public ) { |
|
| 65 | + update_option('default_pingback_flag', 0); |
|
| 66 | + } |
|
| 64 | 67 | |
| 65 | 68 | /* |
| 66 | 69 | * Create default user. If the user already exists, the user tables are |
@@ -223,8 +226,9 @@ discard block |
||
| 223 | 226 | <blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote> |
| 224 | 227 | |
| 225 | 228 | As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url() ); |
| 226 | - if ( is_multisite() ) |
|
| 227 | - $first_page = get_site_option( 'first_page', $first_page ); |
|
| 229 | + if ( is_multisite() ) { |
|
| 230 | + $first_page = get_site_option( 'first_page', $first_page ); |
|
| 231 | + } |
|
| 228 | 232 | $first_post_guid = get_option('home') . '/?page_id=2'; |
| 229 | 233 | $wpdb->insert( $wpdb->posts, array( |
| 230 | 234 | 'post_author' => $user_id, |
@@ -255,10 +259,11 @@ discard block |
||
| 255 | 259 | update_option( 'widget_meta', array ( 2 => array ( 'title' => '' ), '_multiwidget' => 1 ) ); |
| 256 | 260 | update_option( 'sidebars_widgets', array ( 'wp_inactive_widgets' => array (), 'sidebar-1' => array ( 0 => 'search-2', 1 => 'recent-posts-2', 2 => 'recent-comments-2', 3 => 'archives-2', 4 => 'categories-2', 5 => 'meta-2', ), 'array_version' => 3 ) ); |
| 257 | 261 | |
| 258 | - if ( ! is_multisite() ) |
|
| 259 | - update_user_meta( $user_id, 'show_welcome_panel', 1 ); |
|
| 260 | - elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) ) |
|
| 261 | - update_user_meta( $user_id, 'show_welcome_panel', 2 ); |
|
| 262 | + if ( ! is_multisite() ) { |
|
| 263 | + update_user_meta( $user_id, 'show_welcome_panel', 1 ); |
|
| 264 | + } elseif ( ! is_super_admin( $user_id ) && ! metadata_exists( 'user', $user_id, 'show_welcome_panel' ) ) { |
|
| 265 | + update_user_meta( $user_id, 'show_welcome_panel', 2 ); |
|
| 266 | + } |
|
| 262 | 267 | |
| 263 | 268 | if ( is_multisite() ) { |
| 264 | 269 | // Flush rules to pick up the new page. |
@@ -273,8 +278,9 @@ discard block |
||
| 273 | 278 | $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities') ); |
| 274 | 279 | |
| 275 | 280 | // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id. |
| 276 | - if ( !is_super_admin( $user_id ) && $user_id != 1 ) |
|
| 277 | - $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) ); |
|
| 281 | + if ( !is_super_admin( $user_id ) && $user_id != 1 ) { |
|
| 282 | + $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $user_id , 'meta_key' => $wpdb->base_prefix.'1_capabilities' ) ); |
|
| 283 | + } |
|
| 278 | 284 | } |
| 279 | 285 | } |
| 280 | 286 | endif; |
@@ -411,26 +417,30 @@ discard block |
||
| 411 | 417 | $wp_current_db_version = __get_option('db_version'); |
| 412 | 418 | |
| 413 | 419 | // We are up-to-date. Nothing to do. |
| 414 | - if ( $wp_db_version == $wp_current_db_version ) |
|
| 415 | - return; |
|
| 420 | + if ( $wp_db_version == $wp_current_db_version ) { |
|
| 421 | + return; |
|
| 422 | + } |
|
| 416 | 423 | |
| 417 | - if ( ! is_blog_installed() ) |
|
| 418 | - return; |
|
| 424 | + if ( ! is_blog_installed() ) { |
|
| 425 | + return; |
|
| 426 | + } |
|
| 419 | 427 | |
| 420 | 428 | wp_check_mysql_version(); |
| 421 | 429 | wp_cache_flush(); |
| 422 | 430 | pre_schema_upgrade(); |
| 423 | 431 | make_db_current_silent(); |
| 424 | 432 | upgrade_all(); |
| 425 | - if ( is_multisite() && is_main_site() ) |
|
| 426 | - upgrade_network(); |
|
| 433 | + if ( is_multisite() && is_main_site() ) { |
|
| 434 | + upgrade_network(); |
|
| 435 | + } |
|
| 427 | 436 | wp_cache_flush(); |
| 428 | 437 | |
| 429 | 438 | if ( is_multisite() ) { |
| 430 | - if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) ) |
|
| 431 | - $wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" ); |
|
| 432 | - else |
|
| 433 | - $wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" ); |
|
| 439 | + if ( $wpdb->get_row( "SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'" ) ) { |
|
| 440 | + $wpdb->query( "UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" ); |
|
| 441 | + } else { |
|
| 442 | + $wpdb->query( "INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" ); |
|
| 443 | + } |
|
| 434 | 444 | } |
| 435 | 445 | |
| 436 | 446 | /** |
@@ -462,8 +472,9 @@ discard block |
||
| 462 | 472 | $wp_current_db_version = __get_option('db_version'); |
| 463 | 473 | |
| 464 | 474 | // We are up-to-date. Nothing to do. |
| 465 | - if ( $wp_db_version == $wp_current_db_version ) |
|
| 466 | - return; |
|
| 475 | + if ( $wp_db_version == $wp_current_db_version ) { |
|
| 476 | + return; |
|
| 477 | + } |
|
| 467 | 478 | |
| 468 | 479 | // If the version is not set in the DB, try to guess the version. |
| 469 | 480 | if ( empty($wp_current_db_version) ) { |
@@ -471,12 +482,14 @@ discard block |
||
| 471 | 482 | |
| 472 | 483 | // If the template option exists, we have 1.5. |
| 473 | 484 | $template = __get_option('template'); |
| 474 | - if ( !empty($template) ) |
|
| 475 | - $wp_current_db_version = 2541; |
|
| 485 | + if ( !empty($template) ) { |
|
| 486 | + $wp_current_db_version = 2541; |
|
| 487 | + } |
|
| 476 | 488 | } |
| 477 | 489 | |
| 478 | - if ( $wp_current_db_version < 6039 ) |
|
| 479 | - upgrade_230_options_table(); |
|
| 490 | + if ( $wp_current_db_version < 6039 ) { |
|
| 491 | + upgrade_230_options_table(); |
|
| 492 | + } |
|
| 480 | 493 | |
| 481 | 494 | populate_options(); |
| 482 | 495 | |
@@ -487,77 +500,101 @@ discard block |
||
| 487 | 500 | upgrade_130(); |
| 488 | 501 | } |
| 489 | 502 | |
| 490 | - if ( $wp_current_db_version < 3308 ) |
|
| 491 | - upgrade_160(); |
|
| 503 | + if ( $wp_current_db_version < 3308 ) { |
|
| 504 | + upgrade_160(); |
|
| 505 | + } |
|
| 492 | 506 | |
| 493 | - if ( $wp_current_db_version < 4772 ) |
|
| 494 | - upgrade_210(); |
|
| 507 | + if ( $wp_current_db_version < 4772 ) { |
|
| 508 | + upgrade_210(); |
|
| 509 | + } |
|
| 495 | 510 | |
| 496 | - if ( $wp_current_db_version < 4351 ) |
|
| 497 | - upgrade_old_slugs(); |
|
| 511 | + if ( $wp_current_db_version < 4351 ) { |
|
| 512 | + upgrade_old_slugs(); |
|
| 513 | + } |
|
| 498 | 514 | |
| 499 | - if ( $wp_current_db_version < 5539 ) |
|
| 500 | - upgrade_230(); |
|
| 515 | + if ( $wp_current_db_version < 5539 ) { |
|
| 516 | + upgrade_230(); |
|
| 517 | + } |
|
| 501 | 518 | |
| 502 | - if ( $wp_current_db_version < 6124 ) |
|
| 503 | - upgrade_230_old_tables(); |
|
| 519 | + if ( $wp_current_db_version < 6124 ) { |
|
| 520 | + upgrade_230_old_tables(); |
|
| 521 | + } |
|
| 504 | 522 | |
| 505 | - if ( $wp_current_db_version < 7499 ) |
|
| 506 | - upgrade_250(); |
|
| 523 | + if ( $wp_current_db_version < 7499 ) { |
|
| 524 | + upgrade_250(); |
|
| 525 | + } |
|
| 507 | 526 | |
| 508 | - if ( $wp_current_db_version < 7935 ) |
|
| 509 | - upgrade_252(); |
|
| 527 | + if ( $wp_current_db_version < 7935 ) { |
|
| 528 | + upgrade_252(); |
|
| 529 | + } |
|
| 510 | 530 | |
| 511 | - if ( $wp_current_db_version < 8201 ) |
|
| 512 | - upgrade_260(); |
|
| 531 | + if ( $wp_current_db_version < 8201 ) { |
|
| 532 | + upgrade_260(); |
|
| 533 | + } |
|
| 513 | 534 | |
| 514 | - if ( $wp_current_db_version < 8989 ) |
|
| 515 | - upgrade_270(); |
|
| 535 | + if ( $wp_current_db_version < 8989 ) { |
|
| 536 | + upgrade_270(); |
|
| 537 | + } |
|
| 516 | 538 | |
| 517 | - if ( $wp_current_db_version < 10360 ) |
|
| 518 | - upgrade_280(); |
|
| 539 | + if ( $wp_current_db_version < 10360 ) { |
|
| 540 | + upgrade_280(); |
|
| 541 | + } |
|
| 519 | 542 | |
| 520 | - if ( $wp_current_db_version < 11958 ) |
|
| 521 | - upgrade_290(); |
|
| 543 | + if ( $wp_current_db_version < 11958 ) { |
|
| 544 | + upgrade_290(); |
|
| 545 | + } |
|
| 522 | 546 | |
| 523 | - if ( $wp_current_db_version < 15260 ) |
|
| 524 | - upgrade_300(); |
|
| 547 | + if ( $wp_current_db_version < 15260 ) { |
|
| 548 | + upgrade_300(); |
|
| 549 | + } |
|
| 525 | 550 | |
| 526 | - if ( $wp_current_db_version < 19389 ) |
|
| 527 | - upgrade_330(); |
|
| 551 | + if ( $wp_current_db_version < 19389 ) { |
|
| 552 | + upgrade_330(); |
|
| 553 | + } |
|
| 528 | 554 | |
| 529 | - if ( $wp_current_db_version < 20080 ) |
|
| 530 | - upgrade_340(); |
|
| 555 | + if ( $wp_current_db_version < 20080 ) { |
|
| 556 | + upgrade_340(); |
|
| 557 | + } |
|
| 531 | 558 | |
| 532 | - if ( $wp_current_db_version < 22422 ) |
|
| 533 | - upgrade_350(); |
|
| 559 | + if ( $wp_current_db_version < 22422 ) { |
|
| 560 | + upgrade_350(); |
|
| 561 | + } |
|
| 534 | 562 | |
| 535 | - if ( $wp_current_db_version < 25824 ) |
|
| 536 | - upgrade_370(); |
|
| 563 | + if ( $wp_current_db_version < 25824 ) { |
|
| 564 | + upgrade_370(); |
|
| 565 | + } |
|
| 537 | 566 | |
| 538 | - if ( $wp_current_db_version < 26148 ) |
|
| 539 | - upgrade_372(); |
|
| 567 | + if ( $wp_current_db_version < 26148 ) { |
|
| 568 | + upgrade_372(); |
|
| 569 | + } |
|
| 540 | 570 | |
| 541 | - if ( $wp_current_db_version < 26691 ) |
|
| 542 | - upgrade_380(); |
|
| 571 | + if ( $wp_current_db_version < 26691 ) { |
|
| 572 | + upgrade_380(); |
|
| 573 | + } |
|
| 543 | 574 | |
| 544 | - if ( $wp_current_db_version < 29630 ) |
|
| 545 | - upgrade_400(); |
|
| 575 | + if ( $wp_current_db_version < 29630 ) { |
|
| 576 | + upgrade_400(); |
|
| 577 | + } |
|
| 546 | 578 | |
| 547 | - if ( $wp_current_db_version < 33055 ) |
|
| 548 | - upgrade_430(); |
|
| 579 | + if ( $wp_current_db_version < 33055 ) { |
|
| 580 | + upgrade_430(); |
|
| 581 | + } |
|
| 549 | 582 | |
| 550 | - if ( $wp_current_db_version < 33056 ) |
|
| 551 | - upgrade_431(); |
|
| 583 | + if ( $wp_current_db_version < 33056 ) { |
|
| 584 | + upgrade_431(); |
|
| 585 | + } |
|
| 552 | 586 | |
| 553 | - if ( $wp_current_db_version < 35700 ) |
|
| 554 | - upgrade_440(); |
|
| 587 | + if ( $wp_current_db_version < 35700 ) { |
|
| 588 | + upgrade_440(); |
|
| 589 | + } |
|
| 555 | 590 | |
| 556 | - if ( $wp_current_db_version < 36686 ) |
|
| 557 | - upgrade_450(); |
|
| 591 | + if ( $wp_current_db_version < 36686 ) { |
|
| 592 | + upgrade_450(); |
|
| 593 | + } |
|
| 558 | 594 | |
| 559 | - if ( $wp_current_db_version < 37965 ) |
|
| 560 | - upgrade_460(); |
|
| 595 | + if ( $wp_current_db_version < 37965 ) { |
|
| 596 | + upgrade_460(); |
|
| 597 | + } |
|
| 561 | 598 | |
| 562 | 599 | maybe_disable_link_manager(); |
| 563 | 600 | |
@@ -610,8 +647,10 @@ discard block |
||
| 610 | 647 | $done_posts[] = $done_id->post_id; |
| 611 | 648 | endforeach; |
| 612 | 649 | $catwhere = ' AND ID NOT IN (' . implode(',', $done_posts) . ')'; |
| 613 | - else: |
|
| 650 | + else { |
|
| 651 | + : |
|
| 614 | 652 | $catwhere = ''; |
| 653 | + } |
|
| 615 | 654 | endif; |
| 616 | 655 | |
| 617 | 656 | $allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere"); |
@@ -728,10 +767,11 @@ discard block |
||
| 728 | 767 | $post_content = addslashes(deslash($post->post_content)); |
| 729 | 768 | $post_title = addslashes(deslash($post->post_title)); |
| 730 | 769 | $post_excerpt = addslashes(deslash($post->post_excerpt)); |
| 731 | - if ( empty($post->guid) ) |
|
| 732 | - $guid = get_permalink($post->ID); |
|
| 733 | - else |
|
| 734 | - $guid = $post->guid; |
|
| 770 | + if ( empty($post->guid) ) { |
|
| 771 | + $guid = get_permalink($post->ID); |
|
| 772 | + } else { |
|
| 773 | + $guid = $post->guid; |
|
| 774 | + } |
|
| 735 | 775 | |
| 736 | 776 | $wpdb->update( $wpdb->posts, compact('post_title', 'post_content', 'post_excerpt', 'guid'), array('ID' => $post->ID) ); |
| 737 | 777 | |
@@ -813,34 +853,57 @@ discard block |
||
| 813 | 853 | |
| 814 | 854 | $users = $wpdb->get_results("SELECT * FROM $wpdb->users"); |
| 815 | 855 | foreach ( $users as $user ) : |
| 816 | - if ( !empty( $user->user_firstname ) ) |
|
| 817 | - update_user_meta( $user->ID, 'first_name', wp_slash($user->user_firstname) ); |
|
| 818 | - if ( !empty( $user->user_lastname ) ) |
|
| 819 | - update_user_meta( $user->ID, 'last_name', wp_slash($user->user_lastname) ); |
|
| 820 | - if ( !empty( $user->user_nickname ) ) |
|
| 821 | - update_user_meta( $user->ID, 'nickname', wp_slash($user->user_nickname) ); |
|
| 822 | - if ( !empty( $user->user_level ) ) |
|
| 823 | - update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level ); |
|
| 824 | - if ( !empty( $user->user_icq ) ) |
|
| 825 | - update_user_meta( $user->ID, 'icq', wp_slash($user->user_icq) ); |
|
| 826 | - if ( !empty( $user->user_aim ) ) |
|
| 827 | - update_user_meta( $user->ID, 'aim', wp_slash($user->user_aim) ); |
|
| 828 | - if ( !empty( $user->user_msn ) ) |
|
| 829 | - update_user_meta( $user->ID, 'msn', wp_slash($user->user_msn) ); |
|
| 830 | - if ( !empty( $user->user_yim ) ) |
|
| 831 | - update_user_meta( $user->ID, 'yim', wp_slash($user->user_icq) ); |
|
| 832 | - if ( !empty( $user->user_description ) ) |
|
| 833 | - update_user_meta( $user->ID, 'description', wp_slash($user->user_description) ); |
|
| 856 | + if ( !empty( $user->user_firstname ) ) { |
|
| 857 | + update_user_meta( $user->ID, 'first_name', wp_slash($user->user_firstname) ); |
|
| 858 | + } |
|
| 859 | + if ( !empty( $user->user_lastname ) ) { |
|
| 860 | + update_user_meta( $user->ID, 'last_name', wp_slash($user->user_lastname) ); |
|
| 861 | + } |
|
| 862 | + if ( !empty( $user->user_nickname ) ) { |
|
| 863 | + update_user_meta( $user->ID, 'nickname', wp_slash($user->user_nickname) ); |
|
| 864 | + } |
|
| 865 | + if ( !empty( $user->user_level ) ) { |
|
| 866 | + update_user_meta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level ); |
|
| 867 | + } |
|
| 868 | + if ( !empty( $user->user_icq ) ) { |
|
| 869 | + update_user_meta( $user->ID, 'icq', wp_slash($user->user_icq) ); |
|
| 870 | + } |
|
| 871 | + if ( !empty( $user->user_aim ) ) { |
|
| 872 | + update_user_meta( $user->ID, 'aim', wp_slash($user->user_aim) ); |
|
| 873 | + } |
|
| 874 | + if ( !empty( $user->user_msn ) ) { |
|
| 875 | + update_user_meta( $user->ID, 'msn', wp_slash($user->user_msn) ); |
|
| 876 | + } |
|
| 877 | + if ( !empty( $user->user_yim ) ) { |
|
| 878 | + update_user_meta( $user->ID, 'yim', wp_slash($user->user_icq) ); |
|
| 879 | + } |
|
| 880 | + if ( !empty( $user->user_description ) ) { |
|
| 881 | + update_user_meta( $user->ID, 'description', wp_slash($user->user_description) ); |
|
| 882 | + } |
|
| 834 | 883 | |
| 835 | 884 | if ( isset( $user->user_idmode ) ): |
| 836 | 885 | $idmode = $user->user_idmode; |
| 837 | - if ($idmode == 'nickname') $id = $user->user_nickname; |
|
| 838 | - if ($idmode == 'login') $id = $user->user_login; |
|
| 839 | - if ($idmode == 'firstname') $id = $user->user_firstname; |
|
| 840 | - if ($idmode == 'lastname') $id = $user->user_lastname; |
|
| 841 | - if ($idmode == 'namefl') $id = $user->user_firstname.' '.$user->user_lastname; |
|
| 842 | - if ($idmode == 'namelf') $id = $user->user_lastname.' '.$user->user_firstname; |
|
| 843 | - if (!$idmode) $id = $user->user_nickname; |
|
| 886 | + if ($idmode == 'nickname') { |
|
| 887 | + $id = $user->user_nickname; |
|
| 888 | + } |
|
| 889 | + if ($idmode == 'login') { |
|
| 890 | + $id = $user->user_login; |
|
| 891 | + } |
|
| 892 | + if ($idmode == 'firstname') { |
|
| 893 | + $id = $user->user_firstname; |
|
| 894 | + } |
|
| 895 | + if ($idmode == 'lastname') { |
|
| 896 | + $id = $user->user_lastname; |
|
| 897 | + } |
|
| 898 | + if ($idmode == 'namefl') { |
|
| 899 | + $id = $user->user_firstname.' '.$user->user_lastname; |
|
| 900 | + } |
|
| 901 | + if ($idmode == 'namelf') { |
|
| 902 | + $id = $user->user_lastname.' '.$user->user_firstname; |
|
| 903 | + } |
|
| 904 | + if (!$idmode) { |
|
| 905 | + $id = $user->user_nickname; |
|
| 906 | + } |
|
| 844 | 907 | $wpdb->update( $wpdb->users, array('display_name' => $id), array('ID' => $user->ID) ); |
| 845 | 908 | endif; |
| 846 | 909 | |
@@ -855,15 +918,17 @@ discard block |
||
| 855 | 918 | endforeach; |
| 856 | 919 | $old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' ); |
| 857 | 920 | $wpdb->hide_errors(); |
| 858 | - foreach ( $old_user_fields as $old ) |
|
| 859 | - $wpdb->query("ALTER TABLE $wpdb->users DROP $old"); |
|
| 921 | + foreach ( $old_user_fields as $old ) { |
|
| 922 | + $wpdb->query("ALTER TABLE $wpdb->users DROP $old"); |
|
| 923 | + } |
|
| 860 | 924 | $wpdb->show_errors(); |
| 861 | 925 | |
| 862 | 926 | // Populate comment_count field of posts table. |
| 863 | 927 | $comments = $wpdb->get_results( "SELECT comment_post_ID, COUNT(*) as c FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID" ); |
| 864 | - if ( is_array( $comments ) ) |
|
| 865 | - foreach ($comments as $comment) |
|
| 928 | + if ( is_array( $comments ) ) { |
|
| 929 | + foreach ($comments as $comment) |
|
| 866 | 930 | $wpdb->update( $wpdb->posts, array('comment_count' => $comment->c), array('ID' => $comment->comment_post_ID) ); |
| 931 | + } |
|
| 867 | 932 | |
| 868 | 933 | /* |
| 869 | 934 | * Some alpha versions used a post status of object instead of attachment |
@@ -878,8 +943,9 @@ discard block |
||
| 878 | 943 | array( 'ID' => $object->ID ) ); |
| 879 | 944 | |
| 880 | 945 | $meta = get_post_meta($object->ID, 'imagedata', true); |
| 881 | - if ( ! empty($meta['file']) ) |
|
| 882 | - update_attached_file( $object->ID, $meta['file'] ); |
|
| 946 | + if ( ! empty($meta['file']) ) { |
|
| 947 | + update_attached_file( $object->ID, $meta['file'] ); |
|
| 948 | + } |
|
| 883 | 949 | } |
| 884 | 950 | } |
| 885 | 951 | } |
@@ -900,8 +966,10 @@ discard block |
||
| 900 | 966 | // Update status and type. |
| 901 | 967 | $posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts"); |
| 902 | 968 | |
| 903 | - if ( ! empty($posts) ) foreach ($posts as $post) { |
|
| 969 | + if ( ! empty($posts) ) { |
|
| 970 | + foreach ($posts as $post) { |
|
| 904 | 971 | $status = $post->post_status; |
| 972 | + } |
|
| 905 | 973 | $type = 'post'; |
| 906 | 974 | |
| 907 | 975 | if ( 'static' == $status ) { |
@@ -926,9 +994,10 @@ discard block |
||
| 926 | 994 | $wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'"); |
| 927 | 995 | |
| 928 | 996 | $posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'"); |
| 929 | - if ( !empty($posts) ) |
|
| 930 | - foreach ( $posts as $post ) |
|
| 997 | + if ( !empty($posts) ) { |
|
| 998 | + foreach ( $posts as $post ) |
|
| 931 | 999 | wp_schedule_single_event(mysql2date('U', $post->post_date, false), 'publish_future_post', array($post->ID)); |
| 1000 | + } |
|
| 932 | 1001 | } |
| 933 | 1002 | } |
| 934 | 1003 | |
@@ -1014,19 +1083,22 @@ discard block |
||
| 1014 | 1083 | } |
| 1015 | 1084 | |
| 1016 | 1085 | $select = 'post_id, category_id'; |
| 1017 | - if ( $have_tags ) |
|
| 1018 | - $select .= ', rel_type'; |
|
| 1086 | + if ( $have_tags ) { |
|
| 1087 | + $select .= ', rel_type'; |
|
| 1088 | + } |
|
| 1019 | 1089 | |
| 1020 | 1090 | $posts = $wpdb->get_results("SELECT $select FROM $wpdb->post2cat GROUP BY post_id, category_id"); |
| 1021 | 1091 | foreach ( $posts as $post ) { |
| 1022 | 1092 | $post_id = (int) $post->post_id; |
| 1023 | 1093 | $term_id = (int) $post->category_id; |
| 1024 | 1094 | $taxonomy = 'category'; |
| 1025 | - if ( !empty($post->rel_type) && 'tag' == $post->rel_type) |
|
| 1026 | - $taxonomy = 'tag'; |
|
| 1095 | + if ( !empty($post->rel_type) && 'tag' == $post->rel_type) { |
|
| 1096 | + $taxonomy = 'tag'; |
|
| 1097 | + } |
|
| 1027 | 1098 | $tt_id = $tt_ids[$term_id][$taxonomy]; |
| 1028 | - if ( empty($tt_id) ) |
|
| 1029 | - continue; |
|
| 1099 | + if ( empty($tt_id) ) { |
|
| 1100 | + continue; |
|
| 1101 | + } |
|
| 1030 | 1102 | |
| 1031 | 1103 | $wpdb->insert( $wpdb->term_relationships, array('object_id' => $post_id, 'term_taxonomy_id' => $tt_id) ); |
| 1032 | 1104 | } |
@@ -1068,15 +1140,19 @@ discard block |
||
| 1068 | 1140 | |
| 1069 | 1141 | // Associate links to cats. |
| 1070 | 1142 | $links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links"); |
| 1071 | - if ( !empty($links) ) foreach ( $links as $link ) { |
|
| 1143 | + if ( !empty($links) ) { |
|
| 1144 | + foreach ( $links as $link ) { |
|
| 1072 | 1145 | if ( 0 == $link->link_category ) |
| 1073 | 1146 | continue; |
| 1074 | - if ( ! isset($link_cat_id_map[$link->link_category]) ) |
|
| 1075 | - continue; |
|
| 1147 | + } |
|
| 1148 | + if ( ! isset($link_cat_id_map[$link->link_category]) ) { |
|
| 1149 | + continue; |
|
| 1150 | + } |
|
| 1076 | 1151 | $term_id = $link_cat_id_map[$link->link_category]; |
| 1077 | 1152 | $tt_id = $tt_ids[$term_id]; |
| 1078 | - if ( empty($tt_id) ) |
|
| 1079 | - continue; |
|
| 1153 | + if ( empty($tt_id) ) { |
|
| 1154 | + continue; |
|
| 1155 | + } |
|
| 1080 | 1156 | |
| 1081 | 1157 | $wpdb->insert( $wpdb->term_relationships, array('object_id' => $link->link_id, 'term_taxonomy_id' => $tt_id) ); |
| 1082 | 1158 | } |
@@ -1090,8 +1166,9 @@ discard block |
||
| 1090 | 1166 | $term_id = (int) $link->category_id; |
| 1091 | 1167 | $taxonomy = 'link_category'; |
| 1092 | 1168 | $tt_id = $tt_ids[$term_id][$taxonomy]; |
| 1093 | - if ( empty($tt_id) ) |
|
| 1094 | - continue; |
|
| 1169 | + if ( empty($tt_id) ) { |
|
| 1170 | + continue; |
|
| 1171 | + } |
|
| 1095 | 1172 | $wpdb->insert( $wpdb->term_relationships, array('object_id' => $link_id, 'term_taxonomy_id' => $tt_id) ); |
| 1096 | 1173 | } |
| 1097 | 1174 | } |
@@ -1104,10 +1181,11 @@ discard block |
||
| 1104 | 1181 | // Recalculate all counts |
| 1105 | 1182 | $terms = $wpdb->get_results("SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy"); |
| 1106 | 1183 | foreach ( (array) $terms as $term ) { |
| 1107 | - if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) ) |
|
| 1108 | - $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id) ); |
|
| 1109 | - else |
|
| 1110 | - $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) ); |
|
| 1184 | + if ( ('post_tag' == $term->taxonomy) || ('category' == $term->taxonomy) ) { |
|
| 1185 | + $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id) ); |
|
| 1186 | + } else { |
|
| 1187 | + $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term->term_taxonomy_id) ); |
|
| 1188 | + } |
|
| 1111 | 1189 | $wpdb->update( $wpdb->term_taxonomy, array('count' => $count), array('term_taxonomy_id' => $term->term_taxonomy_id) ); |
| 1112 | 1190 | } |
| 1113 | 1191 | } |
@@ -1124,8 +1202,9 @@ discard block |
||
| 1124 | 1202 | global $wpdb; |
| 1125 | 1203 | $old_options_fields = array( 'option_can_override', 'option_type', 'option_width', 'option_height', 'option_description', 'option_admin_level' ); |
| 1126 | 1204 | $wpdb->hide_errors(); |
| 1127 | - foreach ( $old_options_fields as $old ) |
|
| 1128 | - $wpdb->query("ALTER TABLE $wpdb->options DROP $old"); |
|
| 1205 | + foreach ( $old_options_fields as $old ) { |
|
| 1206 | + $wpdb->query("ALTER TABLE $wpdb->options DROP $old"); |
|
| 1207 | + } |
|
| 1129 | 1208 | $wpdb->show_errors(); |
| 1130 | 1209 | } |
| 1131 | 1210 | |
@@ -1200,9 +1279,10 @@ discard block |
||
| 1200 | 1279 | function upgrade_260() { |
| 1201 | 1280 | global $wp_current_db_version; |
| 1202 | 1281 | |
| 1203 | - if ( $wp_current_db_version < 8000 ) |
|
| 1204 | - populate_roles_260(); |
|
| 1205 | -} |
|
| 1282 | + if ( $wp_current_db_version < 8000 ) { |
|
| 1283 | + populate_roles_260(); |
|
| 1284 | + } |
|
| 1285 | + } |
|
| 1206 | 1286 | |
| 1207 | 1287 | /** |
| 1208 | 1288 | * Execute changes made in WordPress 2.7. |
@@ -1216,13 +1296,15 @@ discard block |
||
| 1216 | 1296 | function upgrade_270() { |
| 1217 | 1297 | global $wpdb, $wp_current_db_version; |
| 1218 | 1298 | |
| 1219 | - if ( $wp_current_db_version < 8980 ) |
|
| 1220 | - populate_roles_270(); |
|
| 1299 | + if ( $wp_current_db_version < 8980 ) { |
|
| 1300 | + populate_roles_270(); |
|
| 1301 | + } |
|
| 1221 | 1302 | |
| 1222 | 1303 | // Update post_date for unpublished posts with empty timestamp |
| 1223 | - if ( $wp_current_db_version < 8921 ) |
|
| 1224 | - $wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" ); |
|
| 1225 | -} |
|
| 1304 | + if ( $wp_current_db_version < 8921 ) { |
|
| 1305 | + $wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" ); |
|
| 1306 | + } |
|
| 1307 | + } |
|
| 1226 | 1308 | |
| 1227 | 1309 | /** |
| 1228 | 1310 | * Execute changes made in WordPress 2.8. |
@@ -1236,15 +1318,17 @@ discard block |
||
| 1236 | 1318 | function upgrade_280() { |
| 1237 | 1319 | global $wp_current_db_version, $wpdb; |
| 1238 | 1320 | |
| 1239 | - if ( $wp_current_db_version < 10360 ) |
|
| 1240 | - populate_roles_280(); |
|
| 1321 | + if ( $wp_current_db_version < 10360 ) { |
|
| 1322 | + populate_roles_280(); |
|
| 1323 | + } |
|
| 1241 | 1324 | if ( is_multisite() ) { |
| 1242 | 1325 | $start = 0; |
| 1243 | 1326 | while( $rows = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options ORDER BY option_id LIMIT $start, 20" ) ) { |
| 1244 | 1327 | foreach ( $rows as $row ) { |
| 1245 | 1328 | $value = $row->option_value; |
| 1246 | - if ( !@unserialize( $value ) ) |
|
| 1247 | - $value = stripslashes( $value ); |
|
| 1329 | + if ( !@unserialize( $value ) ) { |
|
| 1330 | + $value = stripslashes( $value ); |
|
| 1331 | + } |
|
| 1248 | 1332 | if ( $value !== $row->option_value ) { |
| 1249 | 1333 | update_option( $row->option_name, $value ); |
| 1250 | 1334 | } |
@@ -1287,11 +1371,13 @@ discard block |
||
| 1287 | 1371 | function upgrade_300() { |
| 1288 | 1372 | global $wp_current_db_version, $wpdb; |
| 1289 | 1373 | |
| 1290 | - if ( $wp_current_db_version < 15093 ) |
|
| 1291 | - populate_roles_300(); |
|
| 1374 | + if ( $wp_current_db_version < 15093 ) { |
|
| 1375 | + populate_roles_300(); |
|
| 1376 | + } |
|
| 1292 | 1377 | |
| 1293 | - if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false ) |
|
| 1294 | - add_site_option( 'siteurl', '' ); |
|
| 1378 | + if ( $wp_current_db_version < 14139 && is_multisite() && is_main_site() && ! defined( 'MULTISITE' ) && get_site_option( 'siteurl' ) === false ) { |
|
| 1379 | + add_site_option( 'siteurl', '' ); |
|
| 1380 | + } |
|
| 1295 | 1381 | |
| 1296 | 1382 | // 3.0 screen options key name changes. |
| 1297 | 1383 | if ( wp_should_upgrade_global_tables() ) { |
@@ -1339,23 +1425,26 @@ discard block |
||
| 1339 | 1425 | $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')" ); |
| 1340 | 1426 | } |
| 1341 | 1427 | |
| 1342 | - if ( $wp_current_db_version >= 11548 ) |
|
| 1343 | - return; |
|
| 1428 | + if ( $wp_current_db_version >= 11548 ) { |
|
| 1429 | + return; |
|
| 1430 | + } |
|
| 1344 | 1431 | |
| 1345 | 1432 | $sidebars_widgets = get_option( 'sidebars_widgets', array() ); |
| 1346 | 1433 | $_sidebars_widgets = array(); |
| 1347 | 1434 | |
| 1348 | - if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) ) |
|
| 1349 | - $sidebars_widgets['array_version'] = 3; |
|
| 1350 | - elseif ( !isset($sidebars_widgets['array_version']) ) |
|
| 1351 | - $sidebars_widgets['array_version'] = 1; |
|
| 1435 | + if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) ) { |
|
| 1436 | + $sidebars_widgets['array_version'] = 3; |
|
| 1437 | + } elseif ( !isset($sidebars_widgets['array_version']) ) { |
|
| 1438 | + $sidebars_widgets['array_version'] = 1; |
|
| 1439 | + } |
|
| 1352 | 1440 | |
| 1353 | 1441 | switch ( $sidebars_widgets['array_version'] ) { |
| 1354 | 1442 | case 1 : |
| 1355 | - foreach ( (array) $sidebars_widgets as $index => $sidebar ) |
|
| 1356 | - if ( is_array($sidebar) ) |
|
| 1443 | + foreach ( (array) $sidebars_widgets as $index => $sidebar ) { |
|
| 1444 | + if ( is_array($sidebar) ) |
|
| 1357 | 1445 | foreach ( (array) $sidebar as $i => $name ) { |
| 1358 | 1446 | $id = strtolower($name); |
| 1447 | + } |
|
| 1359 | 1448 | if ( isset($wp_registered_widgets[$id]) ) { |
| 1360 | 1449 | $_sidebars_widgets[$index][$i] = $id; |
| 1361 | 1450 | continue; |
@@ -1380,8 +1469,9 @@ discard block |
||
| 1380 | 1469 | } |
| 1381 | 1470 | } |
| 1382 | 1471 | |
| 1383 | - if ( $found ) |
|
| 1384 | - continue; |
|
| 1472 | + if ( $found ) { |
|
| 1473 | + continue; |
|
| 1474 | + } |
|
| 1385 | 1475 | |
| 1386 | 1476 | unset($_sidebars_widgets[$index][$i]); |
| 1387 | 1477 | } |
@@ -1445,14 +1535,17 @@ discard block |
||
| 1445 | 1535 | function upgrade_350() { |
| 1446 | 1536 | global $wp_current_db_version, $wpdb; |
| 1447 | 1537 | |
| 1448 | - if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) |
|
| 1449 | - update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options() |
|
| 1538 | + if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) { |
|
| 1539 | + update_option( 'link_manager_enabled', 1 ); |
|
| 1540 | + } |
|
| 1541 | + // Previously set to 0 by populate_options() |
|
| 1450 | 1542 | |
| 1451 | 1543 | if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) { |
| 1452 | 1544 | $meta_keys = array(); |
| 1453 | 1545 | foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) { |
| 1454 | - if ( false !== strpos( $name, '-' ) ) |
|
| 1455 | - $meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page'; |
|
| 1546 | + if ( false !== strpos( $name, '-' ) ) { |
|
| 1547 | + $meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page'; |
|
| 1548 | + } |
|
| 1456 | 1549 | } |
| 1457 | 1550 | if ( $meta_keys ) { |
| 1458 | 1551 | $meta_keys = implode( "', '", $meta_keys ); |
@@ -1460,9 +1553,10 @@ discard block |
||
| 1460 | 1553 | } |
| 1461 | 1554 | } |
| 1462 | 1555 | |
| 1463 | - if ( $wp_current_db_version < 22422 && $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ) ) |
|
| 1464 | - wp_delete_term( $term->term_id, 'post_format' ); |
|
| 1465 | -} |
|
| 1556 | + if ( $wp_current_db_version < 22422 && $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ) ) { |
|
| 1557 | + wp_delete_term( $term->term_id, 'post_format' ); |
|
| 1558 | + } |
|
| 1559 | + } |
|
| 1466 | 1560 | |
| 1467 | 1561 | /** |
| 1468 | 1562 | * Execute changes made in WordPress 3.7. |
@@ -1474,9 +1568,10 @@ discard block |
||
| 1474 | 1568 | */ |
| 1475 | 1569 | function upgrade_370() { |
| 1476 | 1570 | global $wp_current_db_version; |
| 1477 | - if ( $wp_current_db_version < 25824 ) |
|
| 1478 | - wp_clear_scheduled_hook( 'wp_auto_updates_maybe_update' ); |
|
| 1479 | -} |
|
| 1571 | + if ( $wp_current_db_version < 25824 ) { |
|
| 1572 | + wp_clear_scheduled_hook( 'wp_auto_updates_maybe_update' ); |
|
| 1573 | + } |
|
| 1574 | + } |
|
| 1480 | 1575 | |
| 1481 | 1576 | /** |
| 1482 | 1577 | * Execute changes made in WordPress 3.7.2. |
@@ -1489,9 +1584,10 @@ discard block |
||
| 1489 | 1584 | */ |
| 1490 | 1585 | function upgrade_372() { |
| 1491 | 1586 | global $wp_current_db_version; |
| 1492 | - if ( $wp_current_db_version < 26148 ) |
|
| 1493 | - wp_clear_scheduled_hook( 'wp_maybe_auto_update' ); |
|
| 1494 | -} |
|
| 1587 | + if ( $wp_current_db_version < 26148 ) { |
|
| 1588 | + wp_clear_scheduled_hook( 'wp_maybe_auto_update' ); |
|
| 1589 | + } |
|
| 1590 | + } |
|
| 1495 | 1591 | |
| 1496 | 1592 | /** |
| 1497 | 1593 | * Execute changes made in WordPress 3.8.0. |
@@ -1758,10 +1854,11 @@ discard block |
||
| 1758 | 1854 | $wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' ); |
| 1759 | 1855 | $active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' ); |
| 1760 | 1856 | if ( $wpmu_sitewide_plugins ) { |
| 1761 | - if ( !$active_sitewide_plugins ) |
|
| 1762 | - $sitewide_plugins = (array) $wpmu_sitewide_plugins; |
|
| 1763 | - else |
|
| 1764 | - $sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins ); |
|
| 1857 | + if ( !$active_sitewide_plugins ) { |
|
| 1858 | + $sitewide_plugins = (array) $wpmu_sitewide_plugins; |
|
| 1859 | + } else { |
|
| 1860 | + $sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins ); |
|
| 1861 | + } |
|
| 1765 | 1862 | |
| 1766 | 1863 | update_site_option( 'active_sitewide_plugins', $sitewide_plugins ); |
| 1767 | 1864 | } |
@@ -1772,8 +1869,9 @@ discard block |
||
| 1772 | 1869 | while( $rows = $wpdb->get_results( "SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20" ) ) { |
| 1773 | 1870 | foreach ( $rows as $row ) { |
| 1774 | 1871 | $value = $row->meta_value; |
| 1775 | - if ( !@unserialize( $value ) ) |
|
| 1776 | - $value = stripslashes( $value ); |
|
| 1872 | + if ( !@unserialize( $value ) ) { |
|
| 1873 | + $value = stripslashes( $value ); |
|
| 1874 | + } |
|
| 1777 | 1875 | if ( $value !== $row->meta_value ) { |
| 1778 | 1876 | update_site_option( $row->meta_key, $value ); |
| 1779 | 1877 | } |
@@ -1783,16 +1881,19 @@ discard block |
||
| 1783 | 1881 | } |
| 1784 | 1882 | |
| 1785 | 1883 | // 3.0 |
| 1786 | - if ( $wp_current_db_version < 13576 ) |
|
| 1787 | - update_site_option( 'global_terms_enabled', '1' ); |
|
| 1884 | + if ( $wp_current_db_version < 13576 ) { |
|
| 1885 | + update_site_option( 'global_terms_enabled', '1' ); |
|
| 1886 | + } |
|
| 1788 | 1887 | |
| 1789 | 1888 | // 3.3 |
| 1790 | - if ( $wp_current_db_version < 19390 ) |
|
| 1791 | - update_site_option( 'initial_db_version', $wp_current_db_version ); |
|
| 1889 | + if ( $wp_current_db_version < 19390 ) { |
|
| 1890 | + update_site_option( 'initial_db_version', $wp_current_db_version ); |
|
| 1891 | + } |
|
| 1792 | 1892 | |
| 1793 | 1893 | if ( $wp_current_db_version < 19470 ) { |
| 1794 | - if ( false === get_site_option( 'active_sitewide_plugins' ) ) |
|
| 1795 | - update_site_option( 'active_sitewide_plugins', array() ); |
|
| 1894 | + if ( false === get_site_option( 'active_sitewide_plugins' ) ) { |
|
| 1895 | + update_site_option( 'active_sitewide_plugins', array() ); |
|
| 1896 | + } |
|
| 1796 | 1897 | } |
| 1797 | 1898 | |
| 1798 | 1899 | // 3.4 |
@@ -1804,8 +1905,9 @@ discard block |
||
| 1804 | 1905 | $converted = array(); |
| 1805 | 1906 | $themes = wp_get_themes(); |
| 1806 | 1907 | foreach ( $themes as $stylesheet => $theme_data ) { |
| 1807 | - if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) ) |
|
| 1808 | - $converted[ $stylesheet ] = true; |
|
| 1908 | + if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) ) { |
|
| 1909 | + $converted[ $stylesheet ] = true; |
|
| 1910 | + } |
|
| 1809 | 1911 | } |
| 1810 | 1912 | update_site_option( 'allowedthemes', $converted ); |
| 1811 | 1913 | delete_site_option( 'allowed_themes' ); |
@@ -1813,8 +1915,9 @@ discard block |
||
| 1813 | 1915 | } |
| 1814 | 1916 | |
| 1815 | 1917 | // 3.5 |
| 1816 | - if ( $wp_current_db_version < 21823 ) |
|
| 1817 | - update_site_option( 'ms_files_rewriting', '1' ); |
|
| 1918 | + if ( $wp_current_db_version < 21823 ) { |
|
| 1919 | + update_site_option( 'ms_files_rewriting', '1' ); |
|
| 1920 | + } |
|
| 1818 | 1921 | |
| 1819 | 1922 | // 3.5.2 |
| 1820 | 1923 | if ( $wp_current_db_version < 24448 ) { |
@@ -2045,8 +2148,9 @@ discard block |
||
| 2045 | 2148 | $all_options = new stdClass; |
| 2046 | 2149 | if ( $options = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" ) ) { |
| 2047 | 2150 | foreach ( $options as $option ) { |
| 2048 | - if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name ) |
|
| 2049 | - $option->option_value = untrailingslashit( $option->option_value ); |
|
| 2151 | + if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name ) { |
|
| 2152 | + $option->option_value = untrailingslashit( $option->option_value ); |
|
| 2153 | + } |
|
| 2050 | 2154 | $all_options->{$option->option_name} = stripslashes( $option->option_value ); |
| 2051 | 2155 | } |
| 2052 | 2156 | } |
@@ -2068,19 +2172,23 @@ discard block |
||
| 2068 | 2172 | function __get_option($setting) { |
| 2069 | 2173 | global $wpdb; |
| 2070 | 2174 | |
| 2071 | - if ( $setting == 'home' && defined( 'WP_HOME' ) ) |
|
| 2072 | - return untrailingslashit( WP_HOME ); |
|
| 2175 | + if ( $setting == 'home' && defined( 'WP_HOME' ) ) { |
|
| 2176 | + return untrailingslashit( WP_HOME ); |
|
| 2177 | + } |
|
| 2073 | 2178 | |
| 2074 | - if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) |
|
| 2075 | - return untrailingslashit( WP_SITEURL ); |
|
| 2179 | + if ( $setting == 'siteurl' && defined( 'WP_SITEURL' ) ) { |
|
| 2180 | + return untrailingslashit( WP_SITEURL ); |
|
| 2181 | + } |
|
| 2076 | 2182 | |
| 2077 | 2183 | $option = $wpdb->get_var( $wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting ) ); |
| 2078 | 2184 | |
| 2079 | - if ( 'home' == $setting && '' == $option ) |
|
| 2080 | - return __get_option( 'siteurl' ); |
|
| 2185 | + if ( 'home' == $setting && '' == $option ) { |
|
| 2186 | + return __get_option( 'siteurl' ); |
|
| 2187 | + } |
|
| 2081 | 2188 | |
| 2082 | - if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting ) |
|
| 2083 | - $option = untrailingslashit( $option ); |
|
| 2189 | + if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting || 'tag_base' == $setting ) { |
|
| 2190 | + $option = untrailingslashit( $option ); |
|
| 2191 | + } |
|
| 2084 | 2192 | |
| 2085 | 2193 | return maybe_unserialize( $option ); |
| 2086 | 2194 | } |
@@ -2133,8 +2241,9 @@ discard block |
||
| 2133 | 2241 | function dbDelta( $queries = '', $execute = true ) { |
| 2134 | 2242 | global $wpdb; |
| 2135 | 2243 | |
| 2136 | - if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) ) |
|
| 2137 | - $queries = wp_get_db_schema( $queries ); |
|
| 2244 | + if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) ) { |
|
| 2245 | + $queries = wp_get_db_schema( $queries ); |
|
| 2246 | + } |
|
| 2138 | 2247 | |
| 2139 | 2248 | // Separate individual queries into an array |
| 2140 | 2249 | if ( !is_array($queries) ) { |
@@ -2209,8 +2318,9 @@ discard block |
||
| 2209 | 2318 | $tablefields = $wpdb->get_results("DESCRIBE {$table};"); |
| 2210 | 2319 | $wpdb->suppress_errors( $suppress ); |
| 2211 | 2320 | |
| 2212 | - if ( ! $tablefields ) |
|
| 2213 | - continue; |
|
| 2321 | + if ( ! $tablefields ) { |
|
| 2322 | + continue; |
|
| 2323 | + } |
|
| 2214 | 2324 | |
| 2215 | 2325 | // Clear the field and index arrays. |
| 2216 | 2326 | $cfields = $indices = array(); |
@@ -2502,7 +2612,9 @@ discard block |
||
| 2502 | 2612 | function make_db_current( $tables = 'all' ) { |
| 2503 | 2613 | $alterations = dbDelta( $tables ); |
| 2504 | 2614 | echo "<ol>\n"; |
| 2505 | - foreach ($alterations as $alteration) echo "<li>$alteration</li>\n"; |
|
| 2615 | + foreach ($alterations as $alteration) { |
|
| 2616 | + echo "<li>$alteration</li>\n"; |
|
| 2617 | + } |
|
| 2506 | 2618 | echo "</ol>\n"; |
| 2507 | 2619 | } |
| 2508 | 2620 | |
@@ -2537,8 +2649,9 @@ discard block |
||
| 2537 | 2649 | $home_path = get_home_path(); |
| 2538 | 2650 | $site_dir = WP_CONTENT_DIR . "/themes/$template"; |
| 2539 | 2651 | |
| 2540 | - if (! file_exists("$home_path/index.php")) |
|
| 2541 | - return false; |
|
| 2652 | + if (! file_exists("$home_path/index.php")) { |
|
| 2653 | + return false; |
|
| 2654 | + } |
|
| 2542 | 2655 | |
| 2543 | 2656 | /* |
| 2544 | 2657 | * Copy files from the old locations to the site theme. |
@@ -2547,25 +2660,28 @@ discard block |
||
| 2547 | 2660 | $files = array('index.php' => 'index.php', 'wp-layout.css' => 'style.css', 'wp-comments.php' => 'comments.php', 'wp-comments-popup.php' => 'comments-popup.php'); |
| 2548 | 2661 | |
| 2549 | 2662 | foreach ($files as $oldfile => $newfile) { |
| 2550 | - if ($oldfile == 'index.php') |
|
| 2551 | - $oldpath = $home_path; |
|
| 2552 | - else |
|
| 2553 | - $oldpath = ABSPATH; |
|
| 2663 | + if ($oldfile == 'index.php') { |
|
| 2664 | + $oldpath = $home_path; |
|
| 2665 | + } else { |
|
| 2666 | + $oldpath = ABSPATH; |
|
| 2667 | + } |
|
| 2554 | 2668 | |
| 2555 | 2669 | // Check to make sure it's not a new index. |
| 2556 | 2670 | if ($oldfile == 'index.php') { |
| 2557 | 2671 | $index = implode('', file("$oldpath/$oldfile")); |
| 2558 | 2672 | if (strpos($index, 'WP_USE_THEMES') !== false) { |
| 2559 | - if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile")) |
|
| 2560 | - return false; |
|
| 2673 | + if (! @copy(WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile")) { |
|
| 2674 | + return false; |
|
| 2675 | + } |
|
| 2561 | 2676 | |
| 2562 | 2677 | // Don't copy anything. |
| 2563 | 2678 | continue; |
| 2564 | 2679 | } |
| 2565 | 2680 | } |
| 2566 | 2681 | |
| 2567 | - if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile")) |
|
| 2568 | - return false; |
|
| 2682 | + if (! @copy("$oldpath/$oldfile", "$site_dir/$newfile")) { |
|
| 2683 | + return false; |
|
| 2684 | + } |
|
| 2569 | 2685 | |
| 2570 | 2686 | chmod("$site_dir/$newfile", 0777); |
| 2571 | 2687 | |
@@ -2575,8 +2691,9 @@ discard block |
||
| 2575 | 2691 | $f = fopen("$site_dir/$newfile", 'w'); |
| 2576 | 2692 | |
| 2577 | 2693 | foreach ($lines as $line) { |
| 2578 | - if (preg_match('/require.*wp-blog-header/', $line)) |
|
| 2579 | - $line = '//' . $line; |
|
| 2694 | + if (preg_match('/require.*wp-blog-header/', $line)) { |
|
| 2695 | + $line = '//' . $line; |
|
| 2696 | + } |
|
| 2580 | 2697 | |
| 2581 | 2698 | // Update stylesheet references. |
| 2582 | 2699 | $line = str_replace("<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line); |
@@ -2626,10 +2743,12 @@ discard block |
||
| 2626 | 2743 | $theme_dir = @ opendir($default_dir); |
| 2627 | 2744 | if ($theme_dir) { |
| 2628 | 2745 | while(($theme_file = readdir( $theme_dir )) !== false) { |
| 2629 | - if (is_dir("$default_dir/$theme_file")) |
|
| 2630 | - continue; |
|
| 2631 | - if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file")) |
|
| 2632 | - return; |
|
| 2746 | + if (is_dir("$default_dir/$theme_file")) { |
|
| 2747 | + continue; |
|
| 2748 | + } |
|
| 2749 | + if (! @copy("$default_dir/$theme_file", "$site_dir/$theme_file")) { |
|
| 2750 | + return; |
|
| 2751 | + } |
|
| 2633 | 2752 | chmod("$site_dir/$theme_file", 0777); |
| 2634 | 2753 | } |
| 2635 | 2754 | } |
@@ -2641,11 +2760,17 @@ discard block |
||
| 2641 | 2760 | $f = fopen("$site_dir/style.css", 'w'); |
| 2642 | 2761 | |
| 2643 | 2762 | foreach ($stylelines as $line) { |
| 2644 | - if (strpos($line, 'Theme Name:') !== false) $line = 'Theme Name: ' . $theme_name; |
|
| 2645 | - elseif (strpos($line, 'Theme URI:') !== false) $line = 'Theme URI: ' . __get_option('url'); |
|
| 2646 | - elseif (strpos($line, 'Description:') !== false) $line = 'Description: Your theme.'; |
|
| 2647 | - elseif (strpos($line, 'Version:') !== false) $line = 'Version: 1'; |
|
| 2648 | - elseif (strpos($line, 'Author:') !== false) $line = 'Author: You'; |
|
| 2763 | + if (strpos($line, 'Theme Name:') !== false) { |
|
| 2764 | + $line = 'Theme Name: ' . $theme_name; |
|
| 2765 | + } elseif (strpos($line, 'Theme URI:') !== false) { |
|
| 2766 | + $line = 'Theme URI: ' . __get_option('url'); |
|
| 2767 | + } elseif (strpos($line, 'Description:') !== false) { |
|
| 2768 | + $line = 'Description: Your theme.'; |
|
| 2769 | + } elseif (strpos($line, 'Version:') !== false) { |
|
| 2770 | + $line = 'Version: 1'; |
|
| 2771 | + } elseif (strpos($line, 'Author:') !== false) { |
|
| 2772 | + $line = 'Author: You'; |
|
| 2773 | + } |
|
| 2649 | 2774 | fwrite($f, $line . "\n"); |
| 2650 | 2775 | } |
| 2651 | 2776 | fclose($f); |
@@ -2660,10 +2785,12 @@ discard block |
||
| 2660 | 2785 | $images_dir = @ opendir("$default_dir/images"); |
| 2661 | 2786 | if ($images_dir) { |
| 2662 | 2787 | while(($image = readdir($images_dir)) !== false) { |
| 2663 | - if (is_dir("$default_dir/images/$image")) |
|
| 2664 | - continue; |
|
| 2665 | - if (! @copy("$default_dir/images/$image", "$site_dir/images/$image")) |
|
| 2666 | - return; |
|
| 2788 | + if (is_dir("$default_dir/images/$image")) { |
|
| 2789 | + continue; |
|
| 2790 | + } |
|
| 2791 | + if (! @copy("$default_dir/images/$image", "$site_dir/images/$image")) { |
|
| 2792 | + return; |
|
| 2793 | + } |
|
| 2667 | 2794 | chmod("$site_dir/images/$image", 0777); |
| 2668 | 2795 | } |
| 2669 | 2796 | } |
@@ -2706,9 +2833,10 @@ discard block |
||
| 2706 | 2833 | return false; |
| 2707 | 2834 | } |
| 2708 | 2835 | } else { |
| 2709 | - if (! make_site_theme_from_default($theme_name, $template)) |
|
| 2710 | - // TODO: rm -rf the site theme directory. |
|
| 2836 | + if (! make_site_theme_from_default($theme_name, $template)) { |
|
| 2837 | + // TODO: rm -rf the site theme directory. |
|
| 2711 | 2838 | return false; |
| 2839 | + } |
|
| 2712 | 2840 | } |
| 2713 | 2841 | |
| 2714 | 2842 | // Make the new site theme active. |
@@ -2759,9 +2887,10 @@ discard block |
||
| 2759 | 2887 | function wp_check_mysql_version() { |
| 2760 | 2888 | global $wpdb; |
| 2761 | 2889 | $result = $wpdb->check_database_version(); |
| 2762 | - if ( is_wp_error( $result ) ) |
|
| 2763 | - die( $result->get_error_message() ); |
|
| 2764 | -} |
|
| 2890 | + if ( is_wp_error( $result ) ) { |
|
| 2891 | + die( $result->get_error_message() ); |
|
| 2892 | + } |
|
| 2893 | + } |
|
| 2765 | 2894 | |
| 2766 | 2895 | /** |
| 2767 | 2896 | * Disables the Automattic widgets plugin, which was merged into core. |
@@ -2791,9 +2920,10 @@ discard block |
||
| 2791 | 2920 | function maybe_disable_link_manager() { |
| 2792 | 2921 | global $wp_current_db_version, $wpdb; |
| 2793 | 2922 | |
| 2794 | - if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) |
|
| 2795 | - update_option( 'link_manager_enabled', 0 ); |
|
| 2796 | -} |
|
| 2923 | + if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) { |
|
| 2924 | + update_option( 'link_manager_enabled', 0 ); |
|
| 2925 | + } |
|
| 2926 | + } |
|
| 2797 | 2927 | |
| 2798 | 2928 | /** |
| 2799 | 2929 | * Runs before the schema is upgraded. |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | function get_importers() { |
| 18 | 18 | global $wp_importers; |
| 19 | - if ( is_array( $wp_importers ) ) { |
|
| 20 | - uasort( $wp_importers, '_usort_by_first_member' ); |
|
| 19 | + if (is_array($wp_importers)) { |
|
| 20 | + uasort($wp_importers, '_usort_by_first_member'); |
|
| 21 | 21 | } |
| 22 | 22 | return $wp_importers; |
| 23 | 23 | } |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | * @param array $b |
| 35 | 35 | * @return int |
| 36 | 36 | */ |
| 37 | -function _usort_by_first_member( $a, $b ) { |
|
| 38 | - return strnatcasecmp( $a[0], $b[0] ); |
|
| 37 | +function _usort_by_first_member($a, $b) { |
|
| 38 | + return strnatcasecmp($a[0], $b[0]); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | * @param callable $callback Callback to run. |
| 52 | 52 | * @return WP_Error Returns WP_Error when $callback is WP_Error. |
| 53 | 53 | */ |
| 54 | -function register_importer( $id, $name, $description, $callback ) { |
|
| 54 | +function register_importer($id, $name, $description, $callback) { |
|
| 55 | 55 | global $wp_importers; |
| 56 | - if ( is_wp_error( $callback ) ) |
|
| 56 | + if (is_wp_error($callback)) |
|
| 57 | 57 | return $callback; |
| 58 | - $wp_importers[$id] = array ( $name, $description, $callback ); |
|
| 58 | + $wp_importers[$id] = array($name, $description, $callback); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @param string $id Importer ID. |
| 69 | 69 | */ |
| 70 | -function wp_import_cleanup( $id ) { |
|
| 71 | - wp_delete_attachment( $id ); |
|
| 70 | +function wp_import_cleanup($id) { |
|
| 71 | + wp_delete_attachment($id); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -79,23 +79,23 @@ discard block |
||
| 79 | 79 | * @return array Uploaded file's details on success, error message on failure |
| 80 | 80 | */ |
| 81 | 81 | function wp_import_handle_upload() { |
| 82 | - if ( ! isset( $_FILES['import'] ) ) { |
|
| 82 | + if ( ! isset($_FILES['import'])) { |
|
| 83 | 83 | return array( |
| 84 | - 'error' => __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' ) |
|
| 84 | + 'error' => __('File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.') |
|
| 85 | 85 | ); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - $overrides = array( 'test_form' => false, 'test_type' => false ); |
|
| 88 | + $overrides = array('test_form' => false, 'test_type' => false); |
|
| 89 | 89 | $_FILES['import']['name'] .= '.txt'; |
| 90 | - $upload = wp_handle_upload( $_FILES['import'], $overrides ); |
|
| 90 | + $upload = wp_handle_upload($_FILES['import'], $overrides); |
|
| 91 | 91 | |
| 92 | - if ( isset( $upload['error'] ) ) { |
|
| 92 | + if (isset($upload['error'])) { |
|
| 93 | 93 | return $upload; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | // Construct the object array |
| 97 | 97 | $object = array( |
| 98 | - 'post_title' => basename( $upload['file'] ), |
|
| 98 | + 'post_title' => basename($upload['file']), |
|
| 99 | 99 | 'post_content' => $upload['url'], |
| 100 | 100 | 'post_mime_type' => $upload['type'], |
| 101 | 101 | 'guid' => $upload['url'], |
@@ -104,15 +104,15 @@ discard block |
||
| 104 | 104 | ); |
| 105 | 105 | |
| 106 | 106 | // Save the data |
| 107 | - $id = wp_insert_attachment( $object, $upload['file'] ); |
|
| 107 | + $id = wp_insert_attachment($object, $upload['file']); |
|
| 108 | 108 | |
| 109 | 109 | /* |
| 110 | 110 | * Schedule a cleanup for one day from now in case of failed |
| 111 | 111 | * import or missing wp_import_cleanup() call. |
| 112 | 112 | */ |
| 113 | - wp_schedule_single_event( time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array( $id ) ); |
|
| 113 | + wp_schedule_single_event(time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array($id)); |
|
| 114 | 114 | |
| 115 | - return array( 'file' => $upload['file'], 'id' => $id ); |
|
| 115 | + return array('file' => $upload['file'], 'id' => $id); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -123,37 +123,37 @@ discard block |
||
| 123 | 123 | * @return array Importers with metadata for each. |
| 124 | 124 | */ |
| 125 | 125 | function wp_get_popular_importers() { |
| 126 | - include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version |
|
| 126 | + include(ABSPATH.WPINC.'/version.php'); // include an unmodified $wp_version |
|
| 127 | 127 | |
| 128 | 128 | $locale = get_locale(); |
| 129 | - $cache_key = 'popular_importers_' . md5( $locale . $wp_version ); |
|
| 130 | - $popular_importers = get_site_transient( $cache_key ); |
|
| 129 | + $cache_key = 'popular_importers_'.md5($locale.$wp_version); |
|
| 130 | + $popular_importers = get_site_transient($cache_key); |
|
| 131 | 131 | |
| 132 | - if ( ! $popular_importers ) { |
|
| 133 | - $url = add_query_arg( array( |
|
| 132 | + if ( ! $popular_importers) { |
|
| 133 | + $url = add_query_arg(array( |
|
| 134 | 134 | 'locale' => get_locale(), |
| 135 | 135 | 'version' => $wp_version, |
| 136 | - ), 'http://api.wordpress.org/core/importers/1.1/' ); |
|
| 137 | - $options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url() ); |
|
| 138 | - $response = wp_remote_get( $url, $options ); |
|
| 139 | - $popular_importers = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
| 136 | + ), 'http://api.wordpress.org/core/importers/1.1/'); |
|
| 137 | + $options = array('user-agent' => 'WordPress/'.$wp_version.'; '.home_url()); |
|
| 138 | + $response = wp_remote_get($url, $options); |
|
| 139 | + $popular_importers = json_decode(wp_remote_retrieve_body($response), true); |
|
| 140 | 140 | |
| 141 | - if ( is_array( $popular_importers ) ) { |
|
| 142 | - set_site_transient( $cache_key, $popular_importers, 2 * DAY_IN_SECONDS ); |
|
| 141 | + if (is_array($popular_importers)) { |
|
| 142 | + set_site_transient($cache_key, $popular_importers, 2 * DAY_IN_SECONDS); |
|
| 143 | 143 | } else { |
| 144 | 144 | $popular_importers = false; |
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - if ( is_array( $popular_importers ) ) { |
|
| 148 | + if (is_array($popular_importers)) { |
|
| 149 | 149 | // If the data was received as translated, return it as-is. |
| 150 | - if ( $popular_importers['translated'] ) |
|
| 150 | + if ($popular_importers['translated']) |
|
| 151 | 151 | return $popular_importers['importers']; |
| 152 | 152 | |
| 153 | - foreach ( $popular_importers['importers'] as &$importer ) { |
|
| 154 | - $importer['description'] = translate( $importer['description'] ); |
|
| 155 | - if ( $importer['name'] != 'WordPress' ) |
|
| 156 | - $importer['name'] = translate( $importer['name'] ); |
|
| 153 | + foreach ($popular_importers['importers'] as &$importer) { |
|
| 154 | + $importer['description'] = translate($importer['description']); |
|
| 155 | + if ($importer['name'] != 'WordPress') |
|
| 156 | + $importer['name'] = translate($importer['name']); |
|
| 157 | 157 | } |
| 158 | 158 | return $popular_importers['importers']; |
| 159 | 159 | } |
@@ -161,50 +161,50 @@ discard block |
||
| 161 | 161 | return array( |
| 162 | 162 | // slug => name, description, plugin slug, and register_importer() slug |
| 163 | 163 | 'blogger' => array( |
| 164 | - 'name' => __( 'Blogger' ), |
|
| 165 | - 'description' => __( 'Import posts, comments, and users from a Blogger blog.' ), |
|
| 164 | + 'name' => __('Blogger'), |
|
| 165 | + 'description' => __('Import posts, comments, and users from a Blogger blog.'), |
|
| 166 | 166 | 'plugin-slug' => 'blogger-importer', |
| 167 | 167 | 'importer-id' => 'blogger', |
| 168 | 168 | ), |
| 169 | 169 | 'wpcat2tag' => array( |
| 170 | - 'name' => __( 'Categories and Tags Converter' ), |
|
| 171 | - 'description' => __( 'Convert existing categories to tags or tags to categories, selectively.' ), |
|
| 170 | + 'name' => __('Categories and Tags Converter'), |
|
| 171 | + 'description' => __('Convert existing categories to tags or tags to categories, selectively.'), |
|
| 172 | 172 | 'plugin-slug' => 'wpcat2tag-importer', |
| 173 | 173 | 'importer-id' => 'wp-cat2tag', |
| 174 | 174 | ), |
| 175 | 175 | 'livejournal' => array( |
| 176 | - 'name' => __( 'LiveJournal' ), |
|
| 177 | - 'description' => __( 'Import posts from LiveJournal using their API.' ), |
|
| 176 | + 'name' => __('LiveJournal'), |
|
| 177 | + 'description' => __('Import posts from LiveJournal using their API.'), |
|
| 178 | 178 | 'plugin-slug' => 'livejournal-importer', |
| 179 | 179 | 'importer-id' => 'livejournal', |
| 180 | 180 | ), |
| 181 | 181 | 'movabletype' => array( |
| 182 | - 'name' => __( 'Movable Type and TypePad' ), |
|
| 183 | - 'description' => __( 'Import posts and comments from a Movable Type or TypePad blog.' ), |
|
| 182 | + 'name' => __('Movable Type and TypePad'), |
|
| 183 | + 'description' => __('Import posts and comments from a Movable Type or TypePad blog.'), |
|
| 184 | 184 | 'plugin-slug' => 'movabletype-importer', |
| 185 | 185 | 'importer-id' => 'mt', |
| 186 | 186 | ), |
| 187 | 187 | 'opml' => array( |
| 188 | - 'name' => __( 'Blogroll' ), |
|
| 189 | - 'description' => __( 'Import links in OPML format.' ), |
|
| 188 | + 'name' => __('Blogroll'), |
|
| 189 | + 'description' => __('Import links in OPML format.'), |
|
| 190 | 190 | 'plugin-slug' => 'opml-importer', |
| 191 | 191 | 'importer-id' => 'opml', |
| 192 | 192 | ), |
| 193 | 193 | 'rss' => array( |
| 194 | - 'name' => __( 'RSS' ), |
|
| 195 | - 'description' => __( 'Import posts from an RSS feed.' ), |
|
| 194 | + 'name' => __('RSS'), |
|
| 195 | + 'description' => __('Import posts from an RSS feed.'), |
|
| 196 | 196 | 'plugin-slug' => 'rss-importer', |
| 197 | 197 | 'importer-id' => 'rss', |
| 198 | 198 | ), |
| 199 | 199 | 'tumblr' => array( |
| 200 | - 'name' => __( 'Tumblr' ), |
|
| 201 | - 'description' => __( 'Import posts & media from Tumblr using their API.' ), |
|
| 200 | + 'name' => __('Tumblr'), |
|
| 201 | + 'description' => __('Import posts & media from Tumblr using their API.'), |
|
| 202 | 202 | 'plugin-slug' => 'tumblr-importer', |
| 203 | 203 | 'importer-id' => 'tumblr', |
| 204 | 204 | ), |
| 205 | 205 | 'wordpress' => array( |
| 206 | 206 | 'name' => 'WordPress', |
| 207 | - 'description' => __( 'Import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.' ), |
|
| 207 | + 'description' => __('Import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.'), |
|
| 208 | 208 | 'plugin-slug' => 'wordpress-importer', |
| 209 | 209 | 'importer-id' => 'wordpress', |
| 210 | 210 | ), |
@@ -53,8 +53,9 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | function register_importer( $id, $name, $description, $callback ) { |
| 55 | 55 | global $wp_importers; |
| 56 | - if ( is_wp_error( $callback ) ) |
|
| 57 | - return $callback; |
|
| 56 | + if ( is_wp_error( $callback ) ) { |
|
| 57 | + return $callback; |
|
| 58 | + } |
|
| 58 | 59 | $wp_importers[$id] = array ( $name, $description, $callback ); |
| 59 | 60 | } |
| 60 | 61 | |
@@ -147,13 +148,15 @@ discard block |
||
| 147 | 148 | |
| 148 | 149 | if ( is_array( $popular_importers ) ) { |
| 149 | 150 | // If the data was received as translated, return it as-is. |
| 150 | - if ( $popular_importers['translated'] ) |
|
| 151 | - return $popular_importers['importers']; |
|
| 151 | + if ( $popular_importers['translated'] ) { |
|
| 152 | + return $popular_importers['importers']; |
|
| 153 | + } |
|
| 152 | 154 | |
| 153 | 155 | foreach ( $popular_importers['importers'] as &$importer ) { |
| 154 | 156 | $importer['description'] = translate( $importer['description'] ); |
| 155 | - if ( $importer['name'] != 'WordPress' ) |
|
| 156 | - $importer['name'] = translate( $importer['name'] ); |
|
| 157 | + if ( $importer['name'] != 'WordPress' ) { |
|
| 158 | + $importer['name'] = translate( $importer['name'] ); |
|
| 159 | + } |
|
| 157 | 160 | } |
| 158 | 161 | return $popular_importers['importers']; |
| 159 | 162 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | // ----- Constants |
| 29 | 29 | if (!defined('PCLZIP_READ_BLOCK_SIZE')) { |
| 30 | - define( 'PCLZIP_READ_BLOCK_SIZE', 2048 ); |
|
| 30 | + define( 'PCLZIP_READ_BLOCK_SIZE', 2048 ); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | // ----- File list separator |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | //define( 'PCLZIP_SEPARATOR', ' ' ); |
| 42 | 42 | // Recommanded values for smart separation of filenames. |
| 43 | 43 | if (!defined('PCLZIP_SEPARATOR')) { |
| 44 | - define( 'PCLZIP_SEPARATOR', ',' ); |
|
| 44 | + define( 'PCLZIP_SEPARATOR', ',' ); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // ----- Error configuration |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | // you must ensure that you have included PclError library. |
| 51 | 51 | // [2,...] : reserved for futur use |
| 52 | 52 | if (!defined('PCLZIP_ERROR_EXTERNAL')) { |
| 53 | - define( 'PCLZIP_ERROR_EXTERNAL', 0 ); |
|
| 53 | + define( 'PCLZIP_ERROR_EXTERNAL', 0 ); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // ----- Optional static temporary directory |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' ); |
| 64 | 64 | // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' ); |
| 65 | 65 | if (!defined('PCLZIP_TEMPORARY_DIR')) { |
| 66 | - define( 'PCLZIP_TEMPORARY_DIR', '' ); |
|
| 66 | + define( 'PCLZIP_TEMPORARY_DIR', '' ); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // ----- Optional threshold ratio for use of temporary files |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | // Samples : |
| 76 | 76 | // define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 ); |
| 77 | 77 | if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) { |
| 78 | - define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 ); |
|
| 78 | + define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 ); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | // -------------------------------------------------------------------------------- |
@@ -189,20 +189,20 @@ discard block |
||
| 189 | 189 | // -------------------------------------------------------------------------------- |
| 190 | 190 | class PclZip |
| 191 | 191 | { |
| 192 | - // ----- Filename of the zip file |
|
| 193 | - var $zipname = ''; |
|
| 192 | + // ----- Filename of the zip file |
|
| 193 | + var $zipname = ''; |
|
| 194 | 194 | |
| 195 | - // ----- File descriptor of the zip file |
|
| 196 | - var $zip_fd = 0; |
|
| 195 | + // ----- File descriptor of the zip file |
|
| 196 | + var $zip_fd = 0; |
|
| 197 | 197 | |
| 198 | - // ----- Internal error handling |
|
| 199 | - var $error_code = 1; |
|
| 200 | - var $error_string = ''; |
|
| 198 | + // ----- Internal error handling |
|
| 199 | + var $error_code = 1; |
|
| 200 | + var $error_string = ''; |
|
| 201 | 201 | |
| 202 | - // ----- Current status of the magic_quotes_runtime |
|
| 203 | - // This value store the php configuration for magic_quotes |
|
| 204 | - // The class can then disable the magic_quotes and reset it after |
|
| 205 | - var $magic_quotes_status; |
|
| 202 | + // ----- Current status of the magic_quotes_runtime |
|
| 203 | + // This value store the php configuration for magic_quotes |
|
| 204 | + // The class can then disable the magic_quotes and reset it after |
|
| 205 | + var $magic_quotes_status; |
|
| 206 | 206 | |
| 207 | 207 | // -------------------------------------------------------------------------------- |
| 208 | 208 | // Function : PclZip() |
@@ -215,23 +215,23 @@ discard block |
||
| 215 | 215 | function __construct($p_zipname) |
| 216 | 216 | { |
| 217 | 217 | |
| 218 | - // ----- Tests the zlib |
|
| 219 | - if (!function_exists('gzopen')) |
|
| 220 | - { |
|
| 221 | - die('Abort '.basename(__FILE__).' : Missing zlib extensions'); |
|
| 222 | - } |
|
| 218 | + // ----- Tests the zlib |
|
| 219 | + if (!function_exists('gzopen')) |
|
| 220 | + { |
|
| 221 | + die('Abort '.basename(__FILE__).' : Missing zlib extensions'); |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - // ----- Set the attributes |
|
| 225 | - $this->zipname = $p_zipname; |
|
| 226 | - $this->zip_fd = 0; |
|
| 227 | - $this->magic_quotes_status = -1; |
|
| 224 | + // ----- Set the attributes |
|
| 225 | + $this->zipname = $p_zipname; |
|
| 226 | + $this->zip_fd = 0; |
|
| 227 | + $this->magic_quotes_status = -1; |
|
| 228 | 228 | |
| 229 | - // ----- Return |
|
| 230 | - return; |
|
| 229 | + // ----- Return |
|
| 230 | + return; |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | public function PclZip($p_zipname) { |
| 234 | - self::__construct($p_zipname); |
|
| 234 | + self::__construct($p_zipname); |
|
| 235 | 235 | } |
| 236 | 236 | // -------------------------------------------------------------------------------- |
| 237 | 237 | |
@@ -274,149 +274,149 @@ discard block |
||
| 274 | 274 | // -------------------------------------------------------------------------------- |
| 275 | 275 | function create($p_filelist) |
| 276 | 276 | { |
| 277 | - $v_result=1; |
|
| 278 | - |
|
| 279 | - // ----- Reset the error handler |
|
| 280 | - $this->privErrorReset(); |
|
| 281 | - |
|
| 282 | - // ----- Set default values |
|
| 283 | - $v_options = array(); |
|
| 284 | - $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; |
|
| 285 | - |
|
| 286 | - // ----- Look for variable options arguments |
|
| 287 | - $v_size = func_num_args(); |
|
| 288 | - |
|
| 289 | - // ----- Look for arguments |
|
| 290 | - if ($v_size > 1) { |
|
| 291 | - // ----- Get the arguments |
|
| 292 | - $v_arg_list = func_get_args(); |
|
| 293 | - |
|
| 294 | - // ----- Remove from the options list the first argument |
|
| 295 | - array_shift($v_arg_list); |
|
| 296 | - $v_size--; |
|
| 297 | - |
|
| 298 | - // ----- Look for first arg |
|
| 299 | - if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { |
|
| 300 | - |
|
| 301 | - // ----- Parse the options |
|
| 302 | - $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 303 | - array (PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 304 | - PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 305 | - PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 306 | - PCLZIP_CB_PRE_ADD => 'optional', |
|
| 307 | - PCLZIP_CB_POST_ADD => 'optional', |
|
| 308 | - PCLZIP_OPT_NO_COMPRESSION => 'optional', |
|
| 309 | - PCLZIP_OPT_COMMENT => 'optional', |
|
| 310 | - PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 311 | - PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 312 | - PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 313 | - //, PCLZIP_OPT_CRYPT => 'optional' |
|
| 314 | - )); |
|
| 315 | - if ($v_result != 1) { |
|
| 316 | - return 0; |
|
| 317 | - } |
|
| 318 | - } |
|
| 277 | + $v_result=1; |
|
| 278 | + |
|
| 279 | + // ----- Reset the error handler |
|
| 280 | + $this->privErrorReset(); |
|
| 281 | + |
|
| 282 | + // ----- Set default values |
|
| 283 | + $v_options = array(); |
|
| 284 | + $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; |
|
| 285 | + |
|
| 286 | + // ----- Look for variable options arguments |
|
| 287 | + $v_size = func_num_args(); |
|
| 288 | + |
|
| 289 | + // ----- Look for arguments |
|
| 290 | + if ($v_size > 1) { |
|
| 291 | + // ----- Get the arguments |
|
| 292 | + $v_arg_list = func_get_args(); |
|
| 293 | + |
|
| 294 | + // ----- Remove from the options list the first argument |
|
| 295 | + array_shift($v_arg_list); |
|
| 296 | + $v_size--; |
|
| 297 | + |
|
| 298 | + // ----- Look for first arg |
|
| 299 | + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { |
|
| 300 | + |
|
| 301 | + // ----- Parse the options |
|
| 302 | + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 303 | + array (PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 304 | + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 305 | + PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 306 | + PCLZIP_CB_PRE_ADD => 'optional', |
|
| 307 | + PCLZIP_CB_POST_ADD => 'optional', |
|
| 308 | + PCLZIP_OPT_NO_COMPRESSION => 'optional', |
|
| 309 | + PCLZIP_OPT_COMMENT => 'optional', |
|
| 310 | + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 311 | + PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 312 | + PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 313 | + //, PCLZIP_OPT_CRYPT => 'optional' |
|
| 314 | + )); |
|
| 315 | + if ($v_result != 1) { |
|
| 316 | + return 0; |
|
| 317 | + } |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - // ----- Look for 2 args |
|
| 321 | - // Here we need to support the first historic synopsis of the |
|
| 322 | - // method. |
|
| 323 | - else { |
|
| 324 | - |
|
| 325 | - // ----- Get the first argument |
|
| 326 | - $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0]; |
|
| 327 | - |
|
| 328 | - // ----- Look for the optional second argument |
|
| 329 | - if ($v_size == 2) { |
|
| 330 | - $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; |
|
| 331 | - } |
|
| 332 | - else if ($v_size > 2) { |
|
| 333 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
|
| 334 | - "Invalid number / type of arguments"); |
|
| 335 | - return 0; |
|
| 336 | - } |
|
| 337 | - } |
|
| 338 | - } |
|
| 320 | + // ----- Look for 2 args |
|
| 321 | + // Here we need to support the first historic synopsis of the |
|
| 322 | + // method. |
|
| 323 | + else { |
|
| 324 | + |
|
| 325 | + // ----- Get the first argument |
|
| 326 | + $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0]; |
|
| 327 | + |
|
| 328 | + // ----- Look for the optional second argument |
|
| 329 | + if ($v_size == 2) { |
|
| 330 | + $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; |
|
| 331 | + } |
|
| 332 | + else if ($v_size > 2) { |
|
| 333 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
|
| 334 | + "Invalid number / type of arguments"); |
|
| 335 | + return 0; |
|
| 336 | + } |
|
| 337 | + } |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | - // ----- Look for default option values |
|
| 341 | - $this->privOptionDefaultThreshold($v_options); |
|
| 340 | + // ----- Look for default option values |
|
| 341 | + $this->privOptionDefaultThreshold($v_options); |
|
| 342 | 342 | |
| 343 | - // ----- Init |
|
| 344 | - $v_string_list = array(); |
|
| 345 | - $v_att_list = array(); |
|
| 346 | - $v_filedescr_list = array(); |
|
| 347 | - $p_result_list = array(); |
|
| 343 | + // ----- Init |
|
| 344 | + $v_string_list = array(); |
|
| 345 | + $v_att_list = array(); |
|
| 346 | + $v_filedescr_list = array(); |
|
| 347 | + $p_result_list = array(); |
|
| 348 | 348 | |
| 349 | - // ----- Look if the $p_filelist is really an array |
|
| 350 | - if (is_array($p_filelist)) { |
|
| 349 | + // ----- Look if the $p_filelist is really an array |
|
| 350 | + if (is_array($p_filelist)) { |
|
| 351 | 351 | |
| 352 | - // ----- Look if the first element is also an array |
|
| 353 | - // This will mean that this is a file description entry |
|
| 354 | - if (isset($p_filelist[0]) && is_array($p_filelist[0])) { |
|
| 355 | - $v_att_list = $p_filelist; |
|
| 356 | - } |
|
| 352 | + // ----- Look if the first element is also an array |
|
| 353 | + // This will mean that this is a file description entry |
|
| 354 | + if (isset($p_filelist[0]) && is_array($p_filelist[0])) { |
|
| 355 | + $v_att_list = $p_filelist; |
|
| 356 | + } |
|
| 357 | 357 | |
| 358 | - // ----- The list is a list of string names |
|
| 359 | - else { |
|
| 360 | - $v_string_list = $p_filelist; |
|
| 361 | - } |
|
| 362 | - } |
|
| 358 | + // ----- The list is a list of string names |
|
| 359 | + else { |
|
| 360 | + $v_string_list = $p_filelist; |
|
| 361 | + } |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | - // ----- Look if the $p_filelist is a string |
|
| 365 | - else if (is_string($p_filelist)) { |
|
| 366 | - // ----- Create a list from the string |
|
| 367 | - $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); |
|
| 368 | - } |
|
| 364 | + // ----- Look if the $p_filelist is a string |
|
| 365 | + else if (is_string($p_filelist)) { |
|
| 366 | + // ----- Create a list from the string |
|
| 367 | + $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); |
|
| 368 | + } |
|
| 369 | 369 | |
| 370 | - // ----- Invalid variable type for $p_filelist |
|
| 371 | - else { |
|
| 372 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist"); |
|
| 373 | - return 0; |
|
| 374 | - } |
|
| 370 | + // ----- Invalid variable type for $p_filelist |
|
| 371 | + else { |
|
| 372 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist"); |
|
| 373 | + return 0; |
|
| 374 | + } |
|
| 375 | 375 | |
| 376 | - // ----- Reformat the string list |
|
| 377 | - if (sizeof($v_string_list) != 0) { |
|
| 378 | - foreach ($v_string_list as $v_string) { |
|
| 379 | - if ($v_string != '') { |
|
| 380 | - $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; |
|
| 381 | - } |
|
| 382 | - else { |
|
| 383 | - } |
|
| 384 | - } |
|
| 385 | - } |
|
| 376 | + // ----- Reformat the string list |
|
| 377 | + if (sizeof($v_string_list) != 0) { |
|
| 378 | + foreach ($v_string_list as $v_string) { |
|
| 379 | + if ($v_string != '') { |
|
| 380 | + $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; |
|
| 381 | + } |
|
| 382 | + else { |
|
| 383 | + } |
|
| 384 | + } |
|
| 385 | + } |
|
| 386 | 386 | |
| 387 | - // ----- For each file in the list check the attributes |
|
| 388 | - $v_supported_attributes |
|
| 389 | - = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 390 | - ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
|
| 391 | - ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
|
| 392 | - ,PCLZIP_ATT_FILE_MTIME => 'optional' |
|
| 393 | - ,PCLZIP_ATT_FILE_CONTENT => 'optional' |
|
| 394 | - ,PCLZIP_ATT_FILE_COMMENT => 'optional' |
|
| 387 | + // ----- For each file in the list check the attributes |
|
| 388 | + $v_supported_attributes |
|
| 389 | + = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 390 | + ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
|
| 391 | + ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
|
| 392 | + ,PCLZIP_ATT_FILE_MTIME => 'optional' |
|
| 393 | + ,PCLZIP_ATT_FILE_CONTENT => 'optional' |
|
| 394 | + ,PCLZIP_ATT_FILE_COMMENT => 'optional' |
|
| 395 | 395 | ); |
| 396 | - foreach ($v_att_list as $v_entry) { |
|
| 397 | - $v_result = $this->privFileDescrParseAtt($v_entry, |
|
| 398 | - $v_filedescr_list[], |
|
| 399 | - $v_options, |
|
| 400 | - $v_supported_attributes); |
|
| 401 | - if ($v_result != 1) { |
|
| 402 | - return 0; |
|
| 403 | - } |
|
| 404 | - } |
|
| 396 | + foreach ($v_att_list as $v_entry) { |
|
| 397 | + $v_result = $this->privFileDescrParseAtt($v_entry, |
|
| 398 | + $v_filedescr_list[], |
|
| 399 | + $v_options, |
|
| 400 | + $v_supported_attributes); |
|
| 401 | + if ($v_result != 1) { |
|
| 402 | + return 0; |
|
| 403 | + } |
|
| 404 | + } |
|
| 405 | 405 | |
| 406 | - // ----- Expand the filelist (expand directories) |
|
| 407 | - $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); |
|
| 408 | - if ($v_result != 1) { |
|
| 409 | - return 0; |
|
| 410 | - } |
|
| 406 | + // ----- Expand the filelist (expand directories) |
|
| 407 | + $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); |
|
| 408 | + if ($v_result != 1) { |
|
| 409 | + return 0; |
|
| 410 | + } |
|
| 411 | 411 | |
| 412 | - // ----- Call the create fct |
|
| 413 | - $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options); |
|
| 414 | - if ($v_result != 1) { |
|
| 415 | - return 0; |
|
| 416 | - } |
|
| 412 | + // ----- Call the create fct |
|
| 413 | + $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options); |
|
| 414 | + if ($v_result != 1) { |
|
| 415 | + return 0; |
|
| 416 | + } |
|
| 417 | 417 | |
| 418 | - // ----- Return |
|
| 419 | - return $p_result_list; |
|
| 418 | + // ----- Return |
|
| 419 | + return $p_result_list; |
|
| 420 | 420 | } |
| 421 | 421 | // -------------------------------------------------------------------------------- |
| 422 | 422 | |
@@ -457,149 +457,149 @@ discard block |
||
| 457 | 457 | // -------------------------------------------------------------------------------- |
| 458 | 458 | function add($p_filelist) |
| 459 | 459 | { |
| 460 | - $v_result=1; |
|
| 461 | - |
|
| 462 | - // ----- Reset the error handler |
|
| 463 | - $this->privErrorReset(); |
|
| 464 | - |
|
| 465 | - // ----- Set default values |
|
| 466 | - $v_options = array(); |
|
| 467 | - $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; |
|
| 468 | - |
|
| 469 | - // ----- Look for variable options arguments |
|
| 470 | - $v_size = func_num_args(); |
|
| 471 | - |
|
| 472 | - // ----- Look for arguments |
|
| 473 | - if ($v_size > 1) { |
|
| 474 | - // ----- Get the arguments |
|
| 475 | - $v_arg_list = func_get_args(); |
|
| 476 | - |
|
| 477 | - // ----- Remove form the options list the first argument |
|
| 478 | - array_shift($v_arg_list); |
|
| 479 | - $v_size--; |
|
| 480 | - |
|
| 481 | - // ----- Look for first arg |
|
| 482 | - if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { |
|
| 483 | - |
|
| 484 | - // ----- Parse the options |
|
| 485 | - $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 486 | - array (PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 487 | - PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 488 | - PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 489 | - PCLZIP_CB_PRE_ADD => 'optional', |
|
| 490 | - PCLZIP_CB_POST_ADD => 'optional', |
|
| 491 | - PCLZIP_OPT_NO_COMPRESSION => 'optional', |
|
| 492 | - PCLZIP_OPT_COMMENT => 'optional', |
|
| 493 | - PCLZIP_OPT_ADD_COMMENT => 'optional', |
|
| 494 | - PCLZIP_OPT_PREPEND_COMMENT => 'optional', |
|
| 495 | - PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 496 | - PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 497 | - PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 498 | - //, PCLZIP_OPT_CRYPT => 'optional' |
|
| 460 | + $v_result=1; |
|
| 461 | + |
|
| 462 | + // ----- Reset the error handler |
|
| 463 | + $this->privErrorReset(); |
|
| 464 | + |
|
| 465 | + // ----- Set default values |
|
| 466 | + $v_options = array(); |
|
| 467 | + $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; |
|
| 468 | + |
|
| 469 | + // ----- Look for variable options arguments |
|
| 470 | + $v_size = func_num_args(); |
|
| 471 | + |
|
| 472 | + // ----- Look for arguments |
|
| 473 | + if ($v_size > 1) { |
|
| 474 | + // ----- Get the arguments |
|
| 475 | + $v_arg_list = func_get_args(); |
|
| 476 | + |
|
| 477 | + // ----- Remove form the options list the first argument |
|
| 478 | + array_shift($v_arg_list); |
|
| 479 | + $v_size--; |
|
| 480 | + |
|
| 481 | + // ----- Look for first arg |
|
| 482 | + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { |
|
| 483 | + |
|
| 484 | + // ----- Parse the options |
|
| 485 | + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 486 | + array (PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 487 | + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 488 | + PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 489 | + PCLZIP_CB_PRE_ADD => 'optional', |
|
| 490 | + PCLZIP_CB_POST_ADD => 'optional', |
|
| 491 | + PCLZIP_OPT_NO_COMPRESSION => 'optional', |
|
| 492 | + PCLZIP_OPT_COMMENT => 'optional', |
|
| 493 | + PCLZIP_OPT_ADD_COMMENT => 'optional', |
|
| 494 | + PCLZIP_OPT_PREPEND_COMMENT => 'optional', |
|
| 495 | + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 496 | + PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 497 | + PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 498 | + //, PCLZIP_OPT_CRYPT => 'optional' |
|
| 499 | 499 | )); |
| 500 | - if ($v_result != 1) { |
|
| 501 | - return 0; |
|
| 502 | - } |
|
| 503 | - } |
|
| 500 | + if ($v_result != 1) { |
|
| 501 | + return 0; |
|
| 502 | + } |
|
| 503 | + } |
|
| 504 | 504 | |
| 505 | - // ----- Look for 2 args |
|
| 506 | - // Here we need to support the first historic synopsis of the |
|
| 507 | - // method. |
|
| 508 | - else { |
|
| 509 | - |
|
| 510 | - // ----- Get the first argument |
|
| 511 | - $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0]; |
|
| 512 | - |
|
| 513 | - // ----- Look for the optional second argument |
|
| 514 | - if ($v_size == 2) { |
|
| 515 | - $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; |
|
| 516 | - } |
|
| 517 | - else if ($v_size > 2) { |
|
| 518 | - // ----- Error log |
|
| 519 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
|
| 520 | - |
|
| 521 | - // ----- Return |
|
| 522 | - return 0; |
|
| 523 | - } |
|
| 524 | - } |
|
| 525 | - } |
|
| 505 | + // ----- Look for 2 args |
|
| 506 | + // Here we need to support the first historic synopsis of the |
|
| 507 | + // method. |
|
| 508 | + else { |
|
| 509 | + |
|
| 510 | + // ----- Get the first argument |
|
| 511 | + $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0]; |
|
| 512 | + |
|
| 513 | + // ----- Look for the optional second argument |
|
| 514 | + if ($v_size == 2) { |
|
| 515 | + $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; |
|
| 516 | + } |
|
| 517 | + else if ($v_size > 2) { |
|
| 518 | + // ----- Error log |
|
| 519 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
|
| 520 | + |
|
| 521 | + // ----- Return |
|
| 522 | + return 0; |
|
| 523 | + } |
|
| 524 | + } |
|
| 525 | + } |
|
| 526 | 526 | |
| 527 | - // ----- Look for default option values |
|
| 528 | - $this->privOptionDefaultThreshold($v_options); |
|
| 527 | + // ----- Look for default option values |
|
| 528 | + $this->privOptionDefaultThreshold($v_options); |
|
| 529 | 529 | |
| 530 | - // ----- Init |
|
| 531 | - $v_string_list = array(); |
|
| 532 | - $v_att_list = array(); |
|
| 533 | - $v_filedescr_list = array(); |
|
| 534 | - $p_result_list = array(); |
|
| 530 | + // ----- Init |
|
| 531 | + $v_string_list = array(); |
|
| 532 | + $v_att_list = array(); |
|
| 533 | + $v_filedescr_list = array(); |
|
| 534 | + $p_result_list = array(); |
|
| 535 | 535 | |
| 536 | - // ----- Look if the $p_filelist is really an array |
|
| 537 | - if (is_array($p_filelist)) { |
|
| 536 | + // ----- Look if the $p_filelist is really an array |
|
| 537 | + if (is_array($p_filelist)) { |
|
| 538 | 538 | |
| 539 | - // ----- Look if the first element is also an array |
|
| 540 | - // This will mean that this is a file description entry |
|
| 541 | - if (isset($p_filelist[0]) && is_array($p_filelist[0])) { |
|
| 542 | - $v_att_list = $p_filelist; |
|
| 543 | - } |
|
| 539 | + // ----- Look if the first element is also an array |
|
| 540 | + // This will mean that this is a file description entry |
|
| 541 | + if (isset($p_filelist[0]) && is_array($p_filelist[0])) { |
|
| 542 | + $v_att_list = $p_filelist; |
|
| 543 | + } |
|
| 544 | 544 | |
| 545 | - // ----- The list is a list of string names |
|
| 546 | - else { |
|
| 547 | - $v_string_list = $p_filelist; |
|
| 548 | - } |
|
| 549 | - } |
|
| 545 | + // ----- The list is a list of string names |
|
| 546 | + else { |
|
| 547 | + $v_string_list = $p_filelist; |
|
| 548 | + } |
|
| 549 | + } |
|
| 550 | 550 | |
| 551 | - // ----- Look if the $p_filelist is a string |
|
| 552 | - else if (is_string($p_filelist)) { |
|
| 553 | - // ----- Create a list from the string |
|
| 554 | - $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); |
|
| 555 | - } |
|
| 551 | + // ----- Look if the $p_filelist is a string |
|
| 552 | + else if (is_string($p_filelist)) { |
|
| 553 | + // ----- Create a list from the string |
|
| 554 | + $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); |
|
| 555 | + } |
|
| 556 | 556 | |
| 557 | - // ----- Invalid variable type for $p_filelist |
|
| 558 | - else { |
|
| 559 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist"); |
|
| 560 | - return 0; |
|
| 561 | - } |
|
| 557 | + // ----- Invalid variable type for $p_filelist |
|
| 558 | + else { |
|
| 559 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist"); |
|
| 560 | + return 0; |
|
| 561 | + } |
|
| 562 | 562 | |
| 563 | - // ----- Reformat the string list |
|
| 564 | - if (sizeof($v_string_list) != 0) { |
|
| 565 | - foreach ($v_string_list as $v_string) { |
|
| 566 | - $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; |
|
| 567 | - } |
|
| 568 | - } |
|
| 563 | + // ----- Reformat the string list |
|
| 564 | + if (sizeof($v_string_list) != 0) { |
|
| 565 | + foreach ($v_string_list as $v_string) { |
|
| 566 | + $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; |
|
| 567 | + } |
|
| 568 | + } |
|
| 569 | 569 | |
| 570 | - // ----- For each file in the list check the attributes |
|
| 571 | - $v_supported_attributes |
|
| 572 | - = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 573 | - ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
|
| 574 | - ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
|
| 575 | - ,PCLZIP_ATT_FILE_MTIME => 'optional' |
|
| 576 | - ,PCLZIP_ATT_FILE_CONTENT => 'optional' |
|
| 577 | - ,PCLZIP_ATT_FILE_COMMENT => 'optional' |
|
| 570 | + // ----- For each file in the list check the attributes |
|
| 571 | + $v_supported_attributes |
|
| 572 | + = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 573 | + ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
|
| 574 | + ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
|
| 575 | + ,PCLZIP_ATT_FILE_MTIME => 'optional' |
|
| 576 | + ,PCLZIP_ATT_FILE_CONTENT => 'optional' |
|
| 577 | + ,PCLZIP_ATT_FILE_COMMENT => 'optional' |
|
| 578 | 578 | ); |
| 579 | - foreach ($v_att_list as $v_entry) { |
|
| 580 | - $v_result = $this->privFileDescrParseAtt($v_entry, |
|
| 581 | - $v_filedescr_list[], |
|
| 582 | - $v_options, |
|
| 583 | - $v_supported_attributes); |
|
| 584 | - if ($v_result != 1) { |
|
| 585 | - return 0; |
|
| 586 | - } |
|
| 587 | - } |
|
| 579 | + foreach ($v_att_list as $v_entry) { |
|
| 580 | + $v_result = $this->privFileDescrParseAtt($v_entry, |
|
| 581 | + $v_filedescr_list[], |
|
| 582 | + $v_options, |
|
| 583 | + $v_supported_attributes); |
|
| 584 | + if ($v_result != 1) { |
|
| 585 | + return 0; |
|
| 586 | + } |
|
| 587 | + } |
|
| 588 | 588 | |
| 589 | - // ----- Expand the filelist (expand directories) |
|
| 590 | - $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); |
|
| 591 | - if ($v_result != 1) { |
|
| 592 | - return 0; |
|
| 593 | - } |
|
| 589 | + // ----- Expand the filelist (expand directories) |
|
| 590 | + $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); |
|
| 591 | + if ($v_result != 1) { |
|
| 592 | + return 0; |
|
| 593 | + } |
|
| 594 | 594 | |
| 595 | - // ----- Call the create fct |
|
| 596 | - $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options); |
|
| 597 | - if ($v_result != 1) { |
|
| 598 | - return 0; |
|
| 599 | - } |
|
| 595 | + // ----- Call the create fct |
|
| 596 | + $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options); |
|
| 597 | + if ($v_result != 1) { |
|
| 598 | + return 0; |
|
| 599 | + } |
|
| 600 | 600 | |
| 601 | - // ----- Return |
|
| 602 | - return $p_result_list; |
|
| 601 | + // ----- Return |
|
| 602 | + return $p_result_list; |
|
| 603 | 603 | } |
| 604 | 604 | // -------------------------------------------------------------------------------- |
| 605 | 605 | |
@@ -646,26 +646,26 @@ discard block |
||
| 646 | 646 | // -------------------------------------------------------------------------------- |
| 647 | 647 | function listContent() |
| 648 | 648 | { |
| 649 | - $v_result=1; |
|
| 649 | + $v_result=1; |
|
| 650 | 650 | |
| 651 | - // ----- Reset the error handler |
|
| 652 | - $this->privErrorReset(); |
|
| 651 | + // ----- Reset the error handler |
|
| 652 | + $this->privErrorReset(); |
|
| 653 | 653 | |
| 654 | - // ----- Check archive |
|
| 655 | - if (!$this->privCheckFormat()) { |
|
| 656 | - return(0); |
|
| 657 | - } |
|
| 654 | + // ----- Check archive |
|
| 655 | + if (!$this->privCheckFormat()) { |
|
| 656 | + return(0); |
|
| 657 | + } |
|
| 658 | 658 | |
| 659 | - // ----- Call the extracting fct |
|
| 660 | - $p_list = array(); |
|
| 661 | - if (($v_result = $this->privList($p_list)) != 1) |
|
| 662 | - { |
|
| 663 | - unset($p_list); |
|
| 664 | - return(0); |
|
| 665 | - } |
|
| 659 | + // ----- Call the extracting fct |
|
| 660 | + $p_list = array(); |
|
| 661 | + if (($v_result = $this->privList($p_list)) != 1) |
|
| 662 | + { |
|
| 663 | + unset($p_list); |
|
| 664 | + return(0); |
|
| 665 | + } |
|
| 666 | 666 | |
| 667 | - // ----- Return |
|
| 668 | - return $p_list; |
|
| 667 | + // ----- Return |
|
| 668 | + return $p_list; |
|
| 669 | 669 | } |
| 670 | 670 | // -------------------------------------------------------------------------------- |
| 671 | 671 | |
@@ -703,120 +703,120 @@ discard block |
||
| 703 | 703 | // -------------------------------------------------------------------------------- |
| 704 | 704 | function extract() |
| 705 | 705 | { |
| 706 | - $v_result=1; |
|
| 706 | + $v_result=1; |
|
| 707 | 707 | |
| 708 | - // ----- Reset the error handler |
|
| 709 | - $this->privErrorReset(); |
|
| 708 | + // ----- Reset the error handler |
|
| 709 | + $this->privErrorReset(); |
|
| 710 | 710 | |
| 711 | - // ----- Check archive |
|
| 712 | - if (!$this->privCheckFormat()) { |
|
| 713 | - return(0); |
|
| 714 | - } |
|
| 711 | + // ----- Check archive |
|
| 712 | + if (!$this->privCheckFormat()) { |
|
| 713 | + return(0); |
|
| 714 | + } |
|
| 715 | 715 | |
| 716 | - // ----- Set default values |
|
| 717 | - $v_options = array(); |
|
| 716 | + // ----- Set default values |
|
| 717 | + $v_options = array(); |
|
| 718 | 718 | // $v_path = "./"; |
| 719 | - $v_path = ''; |
|
| 720 | - $v_remove_path = ""; |
|
| 721 | - $v_remove_all_path = false; |
|
| 722 | - |
|
| 723 | - // ----- Look for variable options arguments |
|
| 724 | - $v_size = func_num_args(); |
|
| 725 | - |
|
| 726 | - // ----- Default values for option |
|
| 727 | - $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; |
|
| 728 | - |
|
| 729 | - // ----- Look for arguments |
|
| 730 | - if ($v_size > 0) { |
|
| 731 | - // ----- Get the arguments |
|
| 732 | - $v_arg_list = func_get_args(); |
|
| 733 | - |
|
| 734 | - // ----- Look for first arg |
|
| 735 | - if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { |
|
| 736 | - |
|
| 737 | - // ----- Parse the options |
|
| 738 | - $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 739 | - array (PCLZIP_OPT_PATH => 'optional', |
|
| 740 | - PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 741 | - PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 742 | - PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 743 | - PCLZIP_CB_PRE_EXTRACT => 'optional', |
|
| 744 | - PCLZIP_CB_POST_EXTRACT => 'optional', |
|
| 745 | - PCLZIP_OPT_SET_CHMOD => 'optional', |
|
| 746 | - PCLZIP_OPT_BY_NAME => 'optional', |
|
| 747 | - PCLZIP_OPT_BY_EREG => 'optional', |
|
| 748 | - PCLZIP_OPT_BY_PREG => 'optional', |
|
| 749 | - PCLZIP_OPT_BY_INDEX => 'optional', |
|
| 750 | - PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', |
|
| 751 | - PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional', |
|
| 752 | - PCLZIP_OPT_REPLACE_NEWER => 'optional' |
|
| 753 | - ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' |
|
| 754 | - ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional', |
|
| 755 | - PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 756 | - PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 757 | - PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 758 | - )); |
|
| 759 | - if ($v_result != 1) { |
|
| 760 | - return 0; |
|
| 761 | - } |
|
| 762 | - |
|
| 763 | - // ----- Set the arguments |
|
| 764 | - if (isset($v_options[PCLZIP_OPT_PATH])) { |
|
| 765 | - $v_path = $v_options[PCLZIP_OPT_PATH]; |
|
| 766 | - } |
|
| 767 | - if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { |
|
| 768 | - $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; |
|
| 769 | - } |
|
| 770 | - if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { |
|
| 771 | - $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
|
| 772 | - } |
|
| 773 | - if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { |
|
| 774 | - // ----- Check for '/' in last path char |
|
| 775 | - if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { |
|
| 776 | - $v_path .= '/'; |
|
| 777 | - } |
|
| 778 | - $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; |
|
| 779 | - } |
|
| 780 | - } |
|
| 719 | + $v_path = ''; |
|
| 720 | + $v_remove_path = ""; |
|
| 721 | + $v_remove_all_path = false; |
|
| 722 | + |
|
| 723 | + // ----- Look for variable options arguments |
|
| 724 | + $v_size = func_num_args(); |
|
| 725 | + |
|
| 726 | + // ----- Default values for option |
|
| 727 | + $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; |
|
| 728 | + |
|
| 729 | + // ----- Look for arguments |
|
| 730 | + if ($v_size > 0) { |
|
| 731 | + // ----- Get the arguments |
|
| 732 | + $v_arg_list = func_get_args(); |
|
| 733 | + |
|
| 734 | + // ----- Look for first arg |
|
| 735 | + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { |
|
| 736 | + |
|
| 737 | + // ----- Parse the options |
|
| 738 | + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 739 | + array (PCLZIP_OPT_PATH => 'optional', |
|
| 740 | + PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 741 | + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 742 | + PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 743 | + PCLZIP_CB_PRE_EXTRACT => 'optional', |
|
| 744 | + PCLZIP_CB_POST_EXTRACT => 'optional', |
|
| 745 | + PCLZIP_OPT_SET_CHMOD => 'optional', |
|
| 746 | + PCLZIP_OPT_BY_NAME => 'optional', |
|
| 747 | + PCLZIP_OPT_BY_EREG => 'optional', |
|
| 748 | + PCLZIP_OPT_BY_PREG => 'optional', |
|
| 749 | + PCLZIP_OPT_BY_INDEX => 'optional', |
|
| 750 | + PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', |
|
| 751 | + PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional', |
|
| 752 | + PCLZIP_OPT_REPLACE_NEWER => 'optional' |
|
| 753 | + ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' |
|
| 754 | + ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional', |
|
| 755 | + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 756 | + PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 757 | + PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 758 | + )); |
|
| 759 | + if ($v_result != 1) { |
|
| 760 | + return 0; |
|
| 761 | + } |
|
| 762 | + |
|
| 763 | + // ----- Set the arguments |
|
| 764 | + if (isset($v_options[PCLZIP_OPT_PATH])) { |
|
| 765 | + $v_path = $v_options[PCLZIP_OPT_PATH]; |
|
| 766 | + } |
|
| 767 | + if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { |
|
| 768 | + $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; |
|
| 769 | + } |
|
| 770 | + if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { |
|
| 771 | + $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
|
| 772 | + } |
|
| 773 | + if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { |
|
| 774 | + // ----- Check for '/' in last path char |
|
| 775 | + if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { |
|
| 776 | + $v_path .= '/'; |
|
| 777 | + } |
|
| 778 | + $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; |
|
| 779 | + } |
|
| 780 | + } |
|
| 781 | 781 | |
| 782 | - // ----- Look for 2 args |
|
| 783 | - // Here we need to support the first historic synopsis of the |
|
| 784 | - // method. |
|
| 785 | - else { |
|
| 786 | - |
|
| 787 | - // ----- Get the first argument |
|
| 788 | - $v_path = $v_arg_list[0]; |
|
| 789 | - |
|
| 790 | - // ----- Look for the optional second argument |
|
| 791 | - if ($v_size == 2) { |
|
| 792 | - $v_remove_path = $v_arg_list[1]; |
|
| 793 | - } |
|
| 794 | - else if ($v_size > 2) { |
|
| 795 | - // ----- Error log |
|
| 796 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
|
| 797 | - |
|
| 798 | - // ----- Return |
|
| 799 | - return 0; |
|
| 800 | - } |
|
| 801 | - } |
|
| 802 | - } |
|
| 782 | + // ----- Look for 2 args |
|
| 783 | + // Here we need to support the first historic synopsis of the |
|
| 784 | + // method. |
|
| 785 | + else { |
|
| 786 | + |
|
| 787 | + // ----- Get the first argument |
|
| 788 | + $v_path = $v_arg_list[0]; |
|
| 789 | + |
|
| 790 | + // ----- Look for the optional second argument |
|
| 791 | + if ($v_size == 2) { |
|
| 792 | + $v_remove_path = $v_arg_list[1]; |
|
| 793 | + } |
|
| 794 | + else if ($v_size > 2) { |
|
| 795 | + // ----- Error log |
|
| 796 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
|
| 797 | + |
|
| 798 | + // ----- Return |
|
| 799 | + return 0; |
|
| 800 | + } |
|
| 801 | + } |
|
| 802 | + } |
|
| 803 | 803 | |
| 804 | - // ----- Look for default option values |
|
| 805 | - $this->privOptionDefaultThreshold($v_options); |
|
| 804 | + // ----- Look for default option values |
|
| 805 | + $this->privOptionDefaultThreshold($v_options); |
|
| 806 | 806 | |
| 807 | - // ----- Trace |
|
| 807 | + // ----- Trace |
|
| 808 | 808 | |
| 809 | - // ----- Call the extracting fct |
|
| 810 | - $p_list = array(); |
|
| 811 | - $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, |
|
| 812 | - $v_remove_all_path, $v_options); |
|
| 813 | - if ($v_result < 1) { |
|
| 814 | - unset($p_list); |
|
| 815 | - return(0); |
|
| 816 | - } |
|
| 809 | + // ----- Call the extracting fct |
|
| 810 | + $p_list = array(); |
|
| 811 | + $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, |
|
| 812 | + $v_remove_all_path, $v_options); |
|
| 813 | + if ($v_result < 1) { |
|
| 814 | + unset($p_list); |
|
| 815 | + return(0); |
|
| 816 | + } |
|
| 817 | 817 | |
| 818 | - // ----- Return |
|
| 819 | - return $p_list; |
|
| 818 | + // ----- Return |
|
| 819 | + return $p_list; |
|
| 820 | 820 | } |
| 821 | 821 | // -------------------------------------------------------------------------------- |
| 822 | 822 | |
@@ -860,132 +860,132 @@ discard block |
||
| 860 | 860 | //function extractByIndex($p_index, options...) |
| 861 | 861 | function extractByIndex($p_index) |
| 862 | 862 | { |
| 863 | - $v_result=1; |
|
| 863 | + $v_result=1; |
|
| 864 | 864 | |
| 865 | - // ----- Reset the error handler |
|
| 866 | - $this->privErrorReset(); |
|
| 865 | + // ----- Reset the error handler |
|
| 866 | + $this->privErrorReset(); |
|
| 867 | 867 | |
| 868 | - // ----- Check archive |
|
| 869 | - if (!$this->privCheckFormat()) { |
|
| 870 | - return(0); |
|
| 871 | - } |
|
| 868 | + // ----- Check archive |
|
| 869 | + if (!$this->privCheckFormat()) { |
|
| 870 | + return(0); |
|
| 871 | + } |
|
| 872 | 872 | |
| 873 | - // ----- Set default values |
|
| 874 | - $v_options = array(); |
|
| 873 | + // ----- Set default values |
|
| 874 | + $v_options = array(); |
|
| 875 | 875 | // $v_path = "./"; |
| 876 | - $v_path = ''; |
|
| 877 | - $v_remove_path = ""; |
|
| 878 | - $v_remove_all_path = false; |
|
| 879 | - |
|
| 880 | - // ----- Look for variable options arguments |
|
| 881 | - $v_size = func_num_args(); |
|
| 882 | - |
|
| 883 | - // ----- Default values for option |
|
| 884 | - $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; |
|
| 885 | - |
|
| 886 | - // ----- Look for arguments |
|
| 887 | - if ($v_size > 1) { |
|
| 888 | - // ----- Get the arguments |
|
| 889 | - $v_arg_list = func_get_args(); |
|
| 890 | - |
|
| 891 | - // ----- Remove form the options list the first argument |
|
| 892 | - array_shift($v_arg_list); |
|
| 893 | - $v_size--; |
|
| 894 | - |
|
| 895 | - // ----- Look for first arg |
|
| 896 | - if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { |
|
| 897 | - |
|
| 898 | - // ----- Parse the options |
|
| 899 | - $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 900 | - array (PCLZIP_OPT_PATH => 'optional', |
|
| 901 | - PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 902 | - PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 903 | - PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', |
|
| 904 | - PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 905 | - PCLZIP_CB_PRE_EXTRACT => 'optional', |
|
| 906 | - PCLZIP_CB_POST_EXTRACT => 'optional', |
|
| 907 | - PCLZIP_OPT_SET_CHMOD => 'optional', |
|
| 908 | - PCLZIP_OPT_REPLACE_NEWER => 'optional' |
|
| 909 | - ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' |
|
| 910 | - ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional', |
|
| 911 | - PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 912 | - PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 913 | - PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 876 | + $v_path = ''; |
|
| 877 | + $v_remove_path = ""; |
|
| 878 | + $v_remove_all_path = false; |
|
| 879 | + |
|
| 880 | + // ----- Look for variable options arguments |
|
| 881 | + $v_size = func_num_args(); |
|
| 882 | + |
|
| 883 | + // ----- Default values for option |
|
| 884 | + $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; |
|
| 885 | + |
|
| 886 | + // ----- Look for arguments |
|
| 887 | + if ($v_size > 1) { |
|
| 888 | + // ----- Get the arguments |
|
| 889 | + $v_arg_list = func_get_args(); |
|
| 890 | + |
|
| 891 | + // ----- Remove form the options list the first argument |
|
| 892 | + array_shift($v_arg_list); |
|
| 893 | + $v_size--; |
|
| 894 | + |
|
| 895 | + // ----- Look for first arg |
|
| 896 | + if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { |
|
| 897 | + |
|
| 898 | + // ----- Parse the options |
|
| 899 | + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 900 | + array (PCLZIP_OPT_PATH => 'optional', |
|
| 901 | + PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 902 | + PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
|
| 903 | + PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', |
|
| 904 | + PCLZIP_OPT_ADD_PATH => 'optional', |
|
| 905 | + PCLZIP_CB_PRE_EXTRACT => 'optional', |
|
| 906 | + PCLZIP_CB_POST_EXTRACT => 'optional', |
|
| 907 | + PCLZIP_OPT_SET_CHMOD => 'optional', |
|
| 908 | + PCLZIP_OPT_REPLACE_NEWER => 'optional' |
|
| 909 | + ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' |
|
| 910 | + ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional', |
|
| 911 | + PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', |
|
| 912 | + PCLZIP_OPT_TEMP_FILE_ON => 'optional', |
|
| 913 | + PCLZIP_OPT_TEMP_FILE_OFF => 'optional' |
|
| 914 | 914 | )); |
| 915 | - if ($v_result != 1) { |
|
| 916 | - return 0; |
|
| 917 | - } |
|
| 918 | - |
|
| 919 | - // ----- Set the arguments |
|
| 920 | - if (isset($v_options[PCLZIP_OPT_PATH])) { |
|
| 921 | - $v_path = $v_options[PCLZIP_OPT_PATH]; |
|
| 922 | - } |
|
| 923 | - if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { |
|
| 924 | - $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; |
|
| 925 | - } |
|
| 926 | - if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { |
|
| 927 | - $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
|
| 928 | - } |
|
| 929 | - if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { |
|
| 930 | - // ----- Check for '/' in last path char |
|
| 931 | - if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { |
|
| 932 | - $v_path .= '/'; |
|
| 933 | - } |
|
| 934 | - $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; |
|
| 935 | - } |
|
| 936 | - if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) { |
|
| 937 | - $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; |
|
| 938 | - } |
|
| 939 | - else { |
|
| 940 | - } |
|
| 941 | - } |
|
| 915 | + if ($v_result != 1) { |
|
| 916 | + return 0; |
|
| 917 | + } |
|
| 918 | + |
|
| 919 | + // ----- Set the arguments |
|
| 920 | + if (isset($v_options[PCLZIP_OPT_PATH])) { |
|
| 921 | + $v_path = $v_options[PCLZIP_OPT_PATH]; |
|
| 922 | + } |
|
| 923 | + if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { |
|
| 924 | + $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; |
|
| 925 | + } |
|
| 926 | + if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { |
|
| 927 | + $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
|
| 928 | + } |
|
| 929 | + if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { |
|
| 930 | + // ----- Check for '/' in last path char |
|
| 931 | + if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { |
|
| 932 | + $v_path .= '/'; |
|
| 933 | + } |
|
| 934 | + $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; |
|
| 935 | + } |
|
| 936 | + if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) { |
|
| 937 | + $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; |
|
| 938 | + } |
|
| 939 | + else { |
|
| 940 | + } |
|
| 941 | + } |
|
| 942 | 942 | |
| 943 | - // ----- Look for 2 args |
|
| 944 | - // Here we need to support the first historic synopsis of the |
|
| 945 | - // method. |
|
| 946 | - else { |
|
| 947 | - |
|
| 948 | - // ----- Get the first argument |
|
| 949 | - $v_path = $v_arg_list[0]; |
|
| 950 | - |
|
| 951 | - // ----- Look for the optional second argument |
|
| 952 | - if ($v_size == 2) { |
|
| 953 | - $v_remove_path = $v_arg_list[1]; |
|
| 954 | - } |
|
| 955 | - else if ($v_size > 2) { |
|
| 956 | - // ----- Error log |
|
| 957 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
|
| 958 | - |
|
| 959 | - // ----- Return |
|
| 960 | - return 0; |
|
| 961 | - } |
|
| 962 | - } |
|
| 963 | - } |
|
| 943 | + // ----- Look for 2 args |
|
| 944 | + // Here we need to support the first historic synopsis of the |
|
| 945 | + // method. |
|
| 946 | + else { |
|
| 947 | + |
|
| 948 | + // ----- Get the first argument |
|
| 949 | + $v_path = $v_arg_list[0]; |
|
| 950 | + |
|
| 951 | + // ----- Look for the optional second argument |
|
| 952 | + if ($v_size == 2) { |
|
| 953 | + $v_remove_path = $v_arg_list[1]; |
|
| 954 | + } |
|
| 955 | + else if ($v_size > 2) { |
|
| 956 | + // ----- Error log |
|
| 957 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
|
| 958 | + |
|
| 959 | + // ----- Return |
|
| 960 | + return 0; |
|
| 961 | + } |
|
| 962 | + } |
|
| 963 | + } |
|
| 964 | 964 | |
| 965 | - // ----- Trace |
|
| 966 | - |
|
| 967 | - // ----- Trick |
|
| 968 | - // Here I want to reuse extractByRule(), so I need to parse the $p_index |
|
| 969 | - // with privParseOptions() |
|
| 970 | - $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index); |
|
| 971 | - $v_options_trick = array(); |
|
| 972 | - $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick, |
|
| 973 | - array (PCLZIP_OPT_BY_INDEX => 'optional' )); |
|
| 974 | - if ($v_result != 1) { |
|
| 975 | - return 0; |
|
| 976 | - } |
|
| 977 | - $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX]; |
|
| 965 | + // ----- Trace |
|
| 966 | + |
|
| 967 | + // ----- Trick |
|
| 968 | + // Here I want to reuse extractByRule(), so I need to parse the $p_index |
|
| 969 | + // with privParseOptions() |
|
| 970 | + $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index); |
|
| 971 | + $v_options_trick = array(); |
|
| 972 | + $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick, |
|
| 973 | + array (PCLZIP_OPT_BY_INDEX => 'optional' )); |
|
| 974 | + if ($v_result != 1) { |
|
| 975 | + return 0; |
|
| 976 | + } |
|
| 977 | + $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX]; |
|
| 978 | 978 | |
| 979 | - // ----- Look for default option values |
|
| 980 | - $this->privOptionDefaultThreshold($v_options); |
|
| 979 | + // ----- Look for default option values |
|
| 980 | + $this->privOptionDefaultThreshold($v_options); |
|
| 981 | 981 | |
| 982 | - // ----- Call the extracting fct |
|
| 983 | - if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) { |
|
| 984 | - return(0); |
|
| 985 | - } |
|
| 982 | + // ----- Call the extracting fct |
|
| 983 | + if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) { |
|
| 984 | + return(0); |
|
| 985 | + } |
|
| 986 | 986 | |
| 987 | - // ----- Return |
|
| 988 | - return $p_list; |
|
| 987 | + // ----- Return |
|
| 988 | + return $p_list; |
|
| 989 | 989 | } |
| 990 | 990 | // -------------------------------------------------------------------------------- |
| 991 | 991 | |
@@ -1009,54 +1009,54 @@ discard block |
||
| 1009 | 1009 | // -------------------------------------------------------------------------------- |
| 1010 | 1010 | function delete() |
| 1011 | 1011 | { |
| 1012 | - $v_result=1; |
|
| 1012 | + $v_result=1; |
|
| 1013 | 1013 | |
| 1014 | - // ----- Reset the error handler |
|
| 1015 | - $this->privErrorReset(); |
|
| 1014 | + // ----- Reset the error handler |
|
| 1015 | + $this->privErrorReset(); |
|
| 1016 | 1016 | |
| 1017 | - // ----- Check archive |
|
| 1018 | - if (!$this->privCheckFormat()) { |
|
| 1019 | - return(0); |
|
| 1020 | - } |
|
| 1017 | + // ----- Check archive |
|
| 1018 | + if (!$this->privCheckFormat()) { |
|
| 1019 | + return(0); |
|
| 1020 | + } |
|
| 1021 | 1021 | |
| 1022 | - // ----- Set default values |
|
| 1023 | - $v_options = array(); |
|
| 1024 | - |
|
| 1025 | - // ----- Look for variable options arguments |
|
| 1026 | - $v_size = func_num_args(); |
|
| 1027 | - |
|
| 1028 | - // ----- Look for arguments |
|
| 1029 | - if ($v_size > 0) { |
|
| 1030 | - // ----- Get the arguments |
|
| 1031 | - $v_arg_list = func_get_args(); |
|
| 1032 | - |
|
| 1033 | - // ----- Parse the options |
|
| 1034 | - $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 1035 | - array (PCLZIP_OPT_BY_NAME => 'optional', |
|
| 1036 | - PCLZIP_OPT_BY_EREG => 'optional', |
|
| 1037 | - PCLZIP_OPT_BY_PREG => 'optional', |
|
| 1038 | - PCLZIP_OPT_BY_INDEX => 'optional' )); |
|
| 1039 | - if ($v_result != 1) { |
|
| 1040 | - return 0; |
|
| 1041 | - } |
|
| 1042 | - } |
|
| 1022 | + // ----- Set default values |
|
| 1023 | + $v_options = array(); |
|
| 1024 | + |
|
| 1025 | + // ----- Look for variable options arguments |
|
| 1026 | + $v_size = func_num_args(); |
|
| 1027 | + |
|
| 1028 | + // ----- Look for arguments |
|
| 1029 | + if ($v_size > 0) { |
|
| 1030 | + // ----- Get the arguments |
|
| 1031 | + $v_arg_list = func_get_args(); |
|
| 1032 | + |
|
| 1033 | + // ----- Parse the options |
|
| 1034 | + $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
|
| 1035 | + array (PCLZIP_OPT_BY_NAME => 'optional', |
|
| 1036 | + PCLZIP_OPT_BY_EREG => 'optional', |
|
| 1037 | + PCLZIP_OPT_BY_PREG => 'optional', |
|
| 1038 | + PCLZIP_OPT_BY_INDEX => 'optional' )); |
|
| 1039 | + if ($v_result != 1) { |
|
| 1040 | + return 0; |
|
| 1041 | + } |
|
| 1042 | + } |
|
| 1043 | 1043 | |
| 1044 | - // ----- Magic quotes trick |
|
| 1045 | - $this->privDisableMagicQuotes(); |
|
| 1044 | + // ----- Magic quotes trick |
|
| 1045 | + $this->privDisableMagicQuotes(); |
|
| 1046 | 1046 | |
| 1047 | - // ----- Call the delete fct |
|
| 1048 | - $v_list = array(); |
|
| 1049 | - if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) { |
|
| 1050 | - $this->privSwapBackMagicQuotes(); |
|
| 1051 | - unset($v_list); |
|
| 1052 | - return(0); |
|
| 1053 | - } |
|
| 1047 | + // ----- Call the delete fct |
|
| 1048 | + $v_list = array(); |
|
| 1049 | + if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) { |
|
| 1050 | + $this->privSwapBackMagicQuotes(); |
|
| 1051 | + unset($v_list); |
|
| 1052 | + return(0); |
|
| 1053 | + } |
|
| 1054 | 1054 | |
| 1055 | - // ----- Magic quotes trick |
|
| 1056 | - $this->privSwapBackMagicQuotes(); |
|
| 1055 | + // ----- Magic quotes trick |
|
| 1056 | + $this->privSwapBackMagicQuotes(); |
|
| 1057 | 1057 | |
| 1058 | - // ----- Return |
|
| 1059 | - return $v_list; |
|
| 1058 | + // ----- Return |
|
| 1059 | + return $v_list; |
|
| 1060 | 1060 | } |
| 1061 | 1061 | // -------------------------------------------------------------------------------- |
| 1062 | 1062 | |
@@ -1069,10 +1069,10 @@ discard block |
||
| 1069 | 1069 | function deleteByIndex($p_index) |
| 1070 | 1070 | { |
| 1071 | 1071 | |
| 1072 | - $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index); |
|
| 1072 | + $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index); |
|
| 1073 | 1073 | |
| 1074 | - // ----- Return |
|
| 1075 | - return $p_list; |
|
| 1074 | + // ----- Return |
|
| 1075 | + return $p_list; |
|
| 1076 | 1076 | } |
| 1077 | 1077 | // -------------------------------------------------------------------------------- |
| 1078 | 1078 | |
@@ -1093,61 +1093,61 @@ discard block |
||
| 1093 | 1093 | function properties() |
| 1094 | 1094 | { |
| 1095 | 1095 | |
| 1096 | - // ----- Reset the error handler |
|
| 1097 | - $this->privErrorReset(); |
|
| 1096 | + // ----- Reset the error handler |
|
| 1097 | + $this->privErrorReset(); |
|
| 1098 | 1098 | |
| 1099 | - // ----- Magic quotes trick |
|
| 1100 | - $this->privDisableMagicQuotes(); |
|
| 1099 | + // ----- Magic quotes trick |
|
| 1100 | + $this->privDisableMagicQuotes(); |
|
| 1101 | 1101 | |
| 1102 | - // ----- Check archive |
|
| 1103 | - if (!$this->privCheckFormat()) { |
|
| 1104 | - $this->privSwapBackMagicQuotes(); |
|
| 1105 | - return(0); |
|
| 1106 | - } |
|
| 1102 | + // ----- Check archive |
|
| 1103 | + if (!$this->privCheckFormat()) { |
|
| 1104 | + $this->privSwapBackMagicQuotes(); |
|
| 1105 | + return(0); |
|
| 1106 | + } |
|
| 1107 | 1107 | |
| 1108 | - // ----- Default properties |
|
| 1109 | - $v_prop = array(); |
|
| 1110 | - $v_prop['comment'] = ''; |
|
| 1111 | - $v_prop['nb'] = 0; |
|
| 1112 | - $v_prop['status'] = 'not_exist'; |
|
| 1113 | - |
|
| 1114 | - // ----- Look if file exists |
|
| 1115 | - if (@is_file($this->zipname)) |
|
| 1116 | - { |
|
| 1117 | - // ----- Open the zip file |
|
| 1118 | - if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) |
|
| 1119 | - { |
|
| 1120 | - $this->privSwapBackMagicQuotes(); |
|
| 1121 | - |
|
| 1122 | - // ----- Error log |
|
| 1123 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); |
|
| 1124 | - |
|
| 1125 | - // ----- Return |
|
| 1126 | - return 0; |
|
| 1127 | - } |
|
| 1108 | + // ----- Default properties |
|
| 1109 | + $v_prop = array(); |
|
| 1110 | + $v_prop['comment'] = ''; |
|
| 1111 | + $v_prop['nb'] = 0; |
|
| 1112 | + $v_prop['status'] = 'not_exist'; |
|
| 1113 | + |
|
| 1114 | + // ----- Look if file exists |
|
| 1115 | + if (@is_file($this->zipname)) |
|
| 1116 | + { |
|
| 1117 | + // ----- Open the zip file |
|
| 1118 | + if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) |
|
| 1119 | + { |
|
| 1120 | + $this->privSwapBackMagicQuotes(); |
|
| 1121 | + |
|
| 1122 | + // ----- Error log |
|
| 1123 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); |
|
| 1124 | + |
|
| 1125 | + // ----- Return |
|
| 1126 | + return 0; |
|
| 1127 | + } |
|
| 1128 | 1128 | |
| 1129 | - // ----- Read the central directory informations |
|
| 1130 | - $v_central_dir = array(); |
|
| 1131 | - if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 1132 | - { |
|
| 1133 | - $this->privSwapBackMagicQuotes(); |
|
| 1134 | - return 0; |
|
| 1135 | - } |
|
| 1129 | + // ----- Read the central directory informations |
|
| 1130 | + $v_central_dir = array(); |
|
| 1131 | + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 1132 | + { |
|
| 1133 | + $this->privSwapBackMagicQuotes(); |
|
| 1134 | + return 0; |
|
| 1135 | + } |
|
| 1136 | 1136 | |
| 1137 | - // ----- Close the zip file |
|
| 1138 | - $this->privCloseFd(); |
|
| 1137 | + // ----- Close the zip file |
|
| 1138 | + $this->privCloseFd(); |
|
| 1139 | 1139 | |
| 1140 | - // ----- Set the user attributes |
|
| 1141 | - $v_prop['comment'] = $v_central_dir['comment']; |
|
| 1142 | - $v_prop['nb'] = $v_central_dir['entries']; |
|
| 1143 | - $v_prop['status'] = 'ok'; |
|
| 1144 | - } |
|
| 1140 | + // ----- Set the user attributes |
|
| 1141 | + $v_prop['comment'] = $v_central_dir['comment']; |
|
| 1142 | + $v_prop['nb'] = $v_central_dir['entries']; |
|
| 1143 | + $v_prop['status'] = 'ok'; |
|
| 1144 | + } |
|
| 1145 | 1145 | |
| 1146 | - // ----- Magic quotes trick |
|
| 1147 | - $this->privSwapBackMagicQuotes(); |
|
| 1146 | + // ----- Magic quotes trick |
|
| 1147 | + $this->privSwapBackMagicQuotes(); |
|
| 1148 | 1148 | |
| 1149 | - // ----- Return |
|
| 1150 | - return $v_prop; |
|
| 1149 | + // ----- Return |
|
| 1150 | + return $v_prop; |
|
| 1151 | 1151 | } |
| 1152 | 1152 | // -------------------------------------------------------------------------------- |
| 1153 | 1153 | |
@@ -1165,46 +1165,46 @@ discard block |
||
| 1165 | 1165 | // -------------------------------------------------------------------------------- |
| 1166 | 1166 | function duplicate($p_archive) |
| 1167 | 1167 | { |
| 1168 | - $v_result = 1; |
|
| 1168 | + $v_result = 1; |
|
| 1169 | 1169 | |
| 1170 | - // ----- Reset the error handler |
|
| 1171 | - $this->privErrorReset(); |
|
| 1170 | + // ----- Reset the error handler |
|
| 1171 | + $this->privErrorReset(); |
|
| 1172 | 1172 | |
| 1173 | - // ----- Look if the $p_archive is a PclZip object |
|
| 1174 | - if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip')) |
|
| 1175 | - { |
|
| 1173 | + // ----- Look if the $p_archive is a PclZip object |
|
| 1174 | + if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip')) |
|
| 1175 | + { |
|
| 1176 | 1176 | |
| 1177 | - // ----- Duplicate the archive |
|
| 1178 | - $v_result = $this->privDuplicate($p_archive->zipname); |
|
| 1179 | - } |
|
| 1177 | + // ----- Duplicate the archive |
|
| 1178 | + $v_result = $this->privDuplicate($p_archive->zipname); |
|
| 1179 | + } |
|
| 1180 | 1180 | |
| 1181 | - // ----- Look if the $p_archive is a string (so a filename) |
|
| 1182 | - else if (is_string($p_archive)) |
|
| 1183 | - { |
|
| 1181 | + // ----- Look if the $p_archive is a string (so a filename) |
|
| 1182 | + else if (is_string($p_archive)) |
|
| 1183 | + { |
|
| 1184 | 1184 | |
| 1185 | - // ----- Check that $p_archive is a valid zip file |
|
| 1186 | - // TBC : Should also check the archive format |
|
| 1187 | - if (!is_file($p_archive)) { |
|
| 1188 | - // ----- Error log |
|
| 1189 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'"); |
|
| 1190 | - $v_result = PCLZIP_ERR_MISSING_FILE; |
|
| 1191 | - } |
|
| 1192 | - else { |
|
| 1193 | - // ----- Duplicate the archive |
|
| 1194 | - $v_result = $this->privDuplicate($p_archive); |
|
| 1195 | - } |
|
| 1196 | - } |
|
| 1185 | + // ----- Check that $p_archive is a valid zip file |
|
| 1186 | + // TBC : Should also check the archive format |
|
| 1187 | + if (!is_file($p_archive)) { |
|
| 1188 | + // ----- Error log |
|
| 1189 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'"); |
|
| 1190 | + $v_result = PCLZIP_ERR_MISSING_FILE; |
|
| 1191 | + } |
|
| 1192 | + else { |
|
| 1193 | + // ----- Duplicate the archive |
|
| 1194 | + $v_result = $this->privDuplicate($p_archive); |
|
| 1195 | + } |
|
| 1196 | + } |
|
| 1197 | 1197 | |
| 1198 | - // ----- Invalid variable |
|
| 1199 | - else |
|
| 1200 | - { |
|
| 1201 | - // ----- Error log |
|
| 1202 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); |
|
| 1203 | - $v_result = PCLZIP_ERR_INVALID_PARAMETER; |
|
| 1204 | - } |
|
| 1198 | + // ----- Invalid variable |
|
| 1199 | + else |
|
| 1200 | + { |
|
| 1201 | + // ----- Error log |
|
| 1202 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); |
|
| 1203 | + $v_result = PCLZIP_ERR_INVALID_PARAMETER; |
|
| 1204 | + } |
|
| 1205 | 1205 | |
| 1206 | - // ----- Return |
|
| 1207 | - return $v_result; |
|
| 1206 | + // ----- Return |
|
| 1207 | + return $v_result; |
|
| 1208 | 1208 | } |
| 1209 | 1209 | // -------------------------------------------------------------------------------- |
| 1210 | 1210 | |
@@ -1224,45 +1224,45 @@ discard block |
||
| 1224 | 1224 | // -------------------------------------------------------------------------------- |
| 1225 | 1225 | function merge($p_archive_to_add) |
| 1226 | 1226 | { |
| 1227 | - $v_result = 1; |
|
| 1227 | + $v_result = 1; |
|
| 1228 | 1228 | |
| 1229 | - // ----- Reset the error handler |
|
| 1230 | - $this->privErrorReset(); |
|
| 1229 | + // ----- Reset the error handler |
|
| 1230 | + $this->privErrorReset(); |
|
| 1231 | 1231 | |
| 1232 | - // ----- Check archive |
|
| 1233 | - if (!$this->privCheckFormat()) { |
|
| 1234 | - return(0); |
|
| 1235 | - } |
|
| 1232 | + // ----- Check archive |
|
| 1233 | + if (!$this->privCheckFormat()) { |
|
| 1234 | + return(0); |
|
| 1235 | + } |
|
| 1236 | 1236 | |
| 1237 | - // ----- Look if the $p_archive_to_add is a PclZip object |
|
| 1238 | - if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip')) |
|
| 1239 | - { |
|
| 1237 | + // ----- Look if the $p_archive_to_add is a PclZip object |
|
| 1238 | + if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip')) |
|
| 1239 | + { |
|
| 1240 | 1240 | |
| 1241 | - // ----- Merge the archive |
|
| 1242 | - $v_result = $this->privMerge($p_archive_to_add); |
|
| 1243 | - } |
|
| 1241 | + // ----- Merge the archive |
|
| 1242 | + $v_result = $this->privMerge($p_archive_to_add); |
|
| 1243 | + } |
|
| 1244 | 1244 | |
| 1245 | - // ----- Look if the $p_archive_to_add is a string (so a filename) |
|
| 1246 | - else if (is_string($p_archive_to_add)) |
|
| 1247 | - { |
|
| 1245 | + // ----- Look if the $p_archive_to_add is a string (so a filename) |
|
| 1246 | + else if (is_string($p_archive_to_add)) |
|
| 1247 | + { |
|
| 1248 | 1248 | |
| 1249 | - // ----- Create a temporary archive |
|
| 1250 | - $v_object_archive = new PclZip($p_archive_to_add); |
|
| 1249 | + // ----- Create a temporary archive |
|
| 1250 | + $v_object_archive = new PclZip($p_archive_to_add); |
|
| 1251 | 1251 | |
| 1252 | - // ----- Merge the archive |
|
| 1253 | - $v_result = $this->privMerge($v_object_archive); |
|
| 1254 | - } |
|
| 1252 | + // ----- Merge the archive |
|
| 1253 | + $v_result = $this->privMerge($v_object_archive); |
|
| 1254 | + } |
|
| 1255 | 1255 | |
| 1256 | - // ----- Invalid variable |
|
| 1257 | - else |
|
| 1258 | - { |
|
| 1259 | - // ----- Error log |
|
| 1260 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); |
|
| 1261 | - $v_result = PCLZIP_ERR_INVALID_PARAMETER; |
|
| 1262 | - } |
|
| 1256 | + // ----- Invalid variable |
|
| 1257 | + else |
|
| 1258 | + { |
|
| 1259 | + // ----- Error log |
|
| 1260 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); |
|
| 1261 | + $v_result = PCLZIP_ERR_INVALID_PARAMETER; |
|
| 1262 | + } |
|
| 1263 | 1263 | |
| 1264 | - // ----- Return |
|
| 1265 | - return $v_result; |
|
| 1264 | + // ----- Return |
|
| 1265 | + return $v_result; |
|
| 1266 | 1266 | } |
| 1267 | 1267 | // -------------------------------------------------------------------------------- |
| 1268 | 1268 | |
@@ -1275,12 +1275,12 @@ discard block |
||
| 1275 | 1275 | // -------------------------------------------------------------------------------- |
| 1276 | 1276 | function errorCode() |
| 1277 | 1277 | { |
| 1278 | - if (PCLZIP_ERROR_EXTERNAL == 1) { |
|
| 1279 | - return(PclErrorCode()); |
|
| 1280 | - } |
|
| 1281 | - else { |
|
| 1282 | - return($this->error_code); |
|
| 1283 | - } |
|
| 1278 | + if (PCLZIP_ERROR_EXTERNAL == 1) { |
|
| 1279 | + return(PclErrorCode()); |
|
| 1280 | + } |
|
| 1281 | + else { |
|
| 1282 | + return($this->error_code); |
|
| 1283 | + } |
|
| 1284 | 1284 | } |
| 1285 | 1285 | // -------------------------------------------------------------------------------- |
| 1286 | 1286 | |
@@ -1291,42 +1291,42 @@ discard block |
||
| 1291 | 1291 | // -------------------------------------------------------------------------------- |
| 1292 | 1292 | function errorName($p_with_code=false) |
| 1293 | 1293 | { |
| 1294 | - $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR', |
|
| 1295 | - PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL', |
|
| 1296 | - PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL', |
|
| 1297 | - PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER', |
|
| 1298 | - PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE', |
|
| 1299 | - PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG', |
|
| 1300 | - PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP', |
|
| 1301 | - PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE', |
|
| 1302 | - PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL', |
|
| 1303 | - PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION', |
|
| 1304 | - PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT', |
|
| 1305 | - PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL', |
|
| 1306 | - PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL', |
|
| 1307 | - PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM', |
|
| 1308 | - PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', |
|
| 1309 | - PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE', |
|
| 1310 | - PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE', |
|
| 1311 | - PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', |
|
| 1312 | - PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION' |
|
| 1313 | - ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE' |
|
| 1314 | - ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION' |
|
| 1315 | - ); |
|
| 1316 | - |
|
| 1317 | - if (isset($v_name[$this->error_code])) { |
|
| 1318 | - $v_value = $v_name[$this->error_code]; |
|
| 1319 | - } |
|
| 1320 | - else { |
|
| 1321 | - $v_value = 'NoName'; |
|
| 1322 | - } |
|
| 1294 | + $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR', |
|
| 1295 | + PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL', |
|
| 1296 | + PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL', |
|
| 1297 | + PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER', |
|
| 1298 | + PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE', |
|
| 1299 | + PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG', |
|
| 1300 | + PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP', |
|
| 1301 | + PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE', |
|
| 1302 | + PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL', |
|
| 1303 | + PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION', |
|
| 1304 | + PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT', |
|
| 1305 | + PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL', |
|
| 1306 | + PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL', |
|
| 1307 | + PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM', |
|
| 1308 | + PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', |
|
| 1309 | + PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE', |
|
| 1310 | + PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE', |
|
| 1311 | + PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', |
|
| 1312 | + PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION' |
|
| 1313 | + ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE' |
|
| 1314 | + ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION' |
|
| 1315 | + ); |
|
| 1316 | + |
|
| 1317 | + if (isset($v_name[$this->error_code])) { |
|
| 1318 | + $v_value = $v_name[$this->error_code]; |
|
| 1319 | + } |
|
| 1320 | + else { |
|
| 1321 | + $v_value = 'NoName'; |
|
| 1322 | + } |
|
| 1323 | 1323 | |
| 1324 | - if ($p_with_code) { |
|
| 1325 | - return($v_value.' ('.$this->error_code.')'); |
|
| 1326 | - } |
|
| 1327 | - else { |
|
| 1328 | - return($v_value); |
|
| 1329 | - } |
|
| 1324 | + if ($p_with_code) { |
|
| 1325 | + return($v_value.' ('.$this->error_code.')'); |
|
| 1326 | + } |
|
| 1327 | + else { |
|
| 1328 | + return($v_value); |
|
| 1329 | + } |
|
| 1330 | 1330 | } |
| 1331 | 1331 | // -------------------------------------------------------------------------------- |
| 1332 | 1332 | |
@@ -1337,17 +1337,17 @@ discard block |
||
| 1337 | 1337 | // -------------------------------------------------------------------------------- |
| 1338 | 1338 | function errorInfo($p_full=false) |
| 1339 | 1339 | { |
| 1340 | - if (PCLZIP_ERROR_EXTERNAL == 1) { |
|
| 1341 | - return(PclErrorString()); |
|
| 1342 | - } |
|
| 1343 | - else { |
|
| 1344 | - if ($p_full) { |
|
| 1345 | - return($this->errorName(true)." : ".$this->error_string); |
|
| 1346 | - } |
|
| 1347 | - else { |
|
| 1348 | - return($this->error_string." [code ".$this->error_code."]"); |
|
| 1349 | - } |
|
| 1350 | - } |
|
| 1340 | + if (PCLZIP_ERROR_EXTERNAL == 1) { |
|
| 1341 | + return(PclErrorString()); |
|
| 1342 | + } |
|
| 1343 | + else { |
|
| 1344 | + if ($p_full) { |
|
| 1345 | + return($this->errorName(true)." : ".$this->error_string); |
|
| 1346 | + } |
|
| 1347 | + else { |
|
| 1348 | + return($this->error_string." [code ".$this->error_code."]"); |
|
| 1349 | + } |
|
| 1350 | + } |
|
| 1351 | 1351 | } |
| 1352 | 1352 | // -------------------------------------------------------------------------------- |
| 1353 | 1353 | |
@@ -1376,39 +1376,39 @@ discard block |
||
| 1376 | 1376 | // -------------------------------------------------------------------------------- |
| 1377 | 1377 | function privCheckFormat($p_level=0) |
| 1378 | 1378 | { |
| 1379 | - $v_result = true; |
|
| 1379 | + $v_result = true; |
|
| 1380 | 1380 | |
| 1381 | 1381 | // ----- Reset the file system cache |
| 1382 | - clearstatcache(); |
|
| 1382 | + clearstatcache(); |
|
| 1383 | 1383 | |
| 1384 | - // ----- Reset the error handler |
|
| 1385 | - $this->privErrorReset(); |
|
| 1384 | + // ----- Reset the error handler |
|
| 1385 | + $this->privErrorReset(); |
|
| 1386 | 1386 | |
| 1387 | - // ----- Look if the file exits |
|
| 1388 | - if (!is_file($this->zipname)) { |
|
| 1389 | - // ----- Error log |
|
| 1390 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'"); |
|
| 1391 | - return(false); |
|
| 1392 | - } |
|
| 1387 | + // ----- Look if the file exits |
|
| 1388 | + if (!is_file($this->zipname)) { |
|
| 1389 | + // ----- Error log |
|
| 1390 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'"); |
|
| 1391 | + return(false); |
|
| 1392 | + } |
|
| 1393 | 1393 | |
| 1394 | - // ----- Check that the file is readeable |
|
| 1395 | - if (!is_readable($this->zipname)) { |
|
| 1396 | - // ----- Error log |
|
| 1397 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'"); |
|
| 1398 | - return(false); |
|
| 1399 | - } |
|
| 1394 | + // ----- Check that the file is readeable |
|
| 1395 | + if (!is_readable($this->zipname)) { |
|
| 1396 | + // ----- Error log |
|
| 1397 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'"); |
|
| 1398 | + return(false); |
|
| 1399 | + } |
|
| 1400 | 1400 | |
| 1401 | - // ----- Check the magic code |
|
| 1402 | - // TBC |
|
| 1401 | + // ----- Check the magic code |
|
| 1402 | + // TBC |
|
| 1403 | 1403 | |
| 1404 | - // ----- Check the central header |
|
| 1405 | - // TBC |
|
| 1404 | + // ----- Check the central header |
|
| 1405 | + // TBC |
|
| 1406 | 1406 | |
| 1407 | - // ----- Check each file header |
|
| 1408 | - // TBC |
|
| 1407 | + // ----- Check each file header |
|
| 1408 | + // TBC |
|
| 1409 | 1409 | |
| 1410 | - // ----- Return |
|
| 1411 | - return $v_result; |
|
| 1410 | + // ----- Return |
|
| 1411 | + return $v_result; |
|
| 1412 | 1412 | } |
| 1413 | 1413 | // -------------------------------------------------------------------------------- |
| 1414 | 1414 | |
@@ -1429,395 +1429,395 @@ discard block |
||
| 1429 | 1429 | // -------------------------------------------------------------------------------- |
| 1430 | 1430 | function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false) |
| 1431 | 1431 | { |
| 1432 | - $v_result=1; |
|
| 1432 | + $v_result=1; |
|
| 1433 | 1433 | |
| 1434 | - // ----- Read the options |
|
| 1435 | - $i=0; |
|
| 1436 | - while ($i<$p_size) { |
|
| 1434 | + // ----- Read the options |
|
| 1435 | + $i=0; |
|
| 1436 | + while ($i<$p_size) { |
|
| 1437 | 1437 | |
| 1438 | - // ----- Check if the option is supported |
|
| 1439 | - if (!isset($v_requested_options[$p_options_list[$i]])) { |
|
| 1440 | - // ----- Error log |
|
| 1441 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method"); |
|
| 1438 | + // ----- Check if the option is supported |
|
| 1439 | + if (!isset($v_requested_options[$p_options_list[$i]])) { |
|
| 1440 | + // ----- Error log |
|
| 1441 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method"); |
|
| 1442 | 1442 | |
| 1443 | - // ----- Return |
|
| 1444 | - return PclZip::errorCode(); |
|
| 1445 | - } |
|
| 1443 | + // ----- Return |
|
| 1444 | + return PclZip::errorCode(); |
|
| 1445 | + } |
|
| 1446 | 1446 | |
| 1447 | - // ----- Look for next option |
|
| 1448 | - switch ($p_options_list[$i]) { |
|
| 1449 | - // ----- Look for options that request a path value |
|
| 1450 | - case PCLZIP_OPT_PATH : |
|
| 1451 | - case PCLZIP_OPT_REMOVE_PATH : |
|
| 1452 | - case PCLZIP_OPT_ADD_PATH : |
|
| 1453 | - // ----- Check the number of parameters |
|
| 1454 | - if (($i+1) >= $p_size) { |
|
| 1455 | - // ----- Error log |
|
| 1456 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1457 | - |
|
| 1458 | - // ----- Return |
|
| 1459 | - return PclZip::errorCode(); |
|
| 1460 | - } |
|
| 1447 | + // ----- Look for next option |
|
| 1448 | + switch ($p_options_list[$i]) { |
|
| 1449 | + // ----- Look for options that request a path value |
|
| 1450 | + case PCLZIP_OPT_PATH : |
|
| 1451 | + case PCLZIP_OPT_REMOVE_PATH : |
|
| 1452 | + case PCLZIP_OPT_ADD_PATH : |
|
| 1453 | + // ----- Check the number of parameters |
|
| 1454 | + if (($i+1) >= $p_size) { |
|
| 1455 | + // ----- Error log |
|
| 1456 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1457 | + |
|
| 1458 | + // ----- Return |
|
| 1459 | + return PclZip::errorCode(); |
|
| 1460 | + } |
|
| 1461 | 1461 | |
| 1462 | - // ----- Get the value |
|
| 1463 | - $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
|
| 1464 | - $i++; |
|
| 1465 | - break; |
|
| 1462 | + // ----- Get the value |
|
| 1463 | + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
|
| 1464 | + $i++; |
|
| 1465 | + break; |
|
| 1466 | 1466 | |
| 1467 | - case PCLZIP_OPT_TEMP_FILE_THRESHOLD : |
|
| 1468 | - // ----- Check the number of parameters |
|
| 1469 | - if (($i+1) >= $p_size) { |
|
| 1470 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1471 | - return PclZip::errorCode(); |
|
| 1472 | - } |
|
| 1467 | + case PCLZIP_OPT_TEMP_FILE_THRESHOLD : |
|
| 1468 | + // ----- Check the number of parameters |
|
| 1469 | + if (($i+1) >= $p_size) { |
|
| 1470 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1471 | + return PclZip::errorCode(); |
|
| 1472 | + } |
|
| 1473 | 1473 | |
| 1474 | - // ----- Check for incompatible options |
|
| 1475 | - if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) { |
|
| 1476 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); |
|
| 1477 | - return PclZip::errorCode(); |
|
| 1478 | - } |
|
| 1474 | + // ----- Check for incompatible options |
|
| 1475 | + if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) { |
|
| 1476 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); |
|
| 1477 | + return PclZip::errorCode(); |
|
| 1478 | + } |
|
| 1479 | 1479 | |
| 1480 | - // ----- Check the value |
|
| 1481 | - $v_value = $p_options_list[$i+1]; |
|
| 1482 | - if ((!is_integer($v_value)) || ($v_value<0)) { |
|
| 1483 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1484 | - return PclZip::errorCode(); |
|
| 1485 | - } |
|
| 1480 | + // ----- Check the value |
|
| 1481 | + $v_value = $p_options_list[$i+1]; |
|
| 1482 | + if ((!is_integer($v_value)) || ($v_value<0)) { |
|
| 1483 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1484 | + return PclZip::errorCode(); |
|
| 1485 | + } |
|
| 1486 | 1486 | |
| 1487 | - // ----- Get the value (and convert it in bytes) |
|
| 1488 | - $v_result_list[$p_options_list[$i]] = $v_value*1048576; |
|
| 1489 | - $i++; |
|
| 1490 | - break; |
|
| 1487 | + // ----- Get the value (and convert it in bytes) |
|
| 1488 | + $v_result_list[$p_options_list[$i]] = $v_value*1048576; |
|
| 1489 | + $i++; |
|
| 1490 | + break; |
|
| 1491 | 1491 | |
| 1492 | - case PCLZIP_OPT_TEMP_FILE_ON : |
|
| 1493 | - // ----- Check for incompatible options |
|
| 1494 | - if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) { |
|
| 1495 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); |
|
| 1496 | - return PclZip::errorCode(); |
|
| 1497 | - } |
|
| 1492 | + case PCLZIP_OPT_TEMP_FILE_ON : |
|
| 1493 | + // ----- Check for incompatible options |
|
| 1494 | + if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) { |
|
| 1495 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); |
|
| 1496 | + return PclZip::errorCode(); |
|
| 1497 | + } |
|
| 1498 | 1498 | |
| 1499 | - $v_result_list[$p_options_list[$i]] = true; |
|
| 1500 | - break; |
|
| 1499 | + $v_result_list[$p_options_list[$i]] = true; |
|
| 1500 | + break; |
|
| 1501 | 1501 | |
| 1502 | - case PCLZIP_OPT_TEMP_FILE_OFF : |
|
| 1503 | - // ----- Check for incompatible options |
|
| 1504 | - if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) { |
|
| 1505 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'"); |
|
| 1506 | - return PclZip::errorCode(); |
|
| 1507 | - } |
|
| 1508 | - // ----- Check for incompatible options |
|
| 1509 | - if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { |
|
| 1510 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'"); |
|
| 1511 | - return PclZip::errorCode(); |
|
| 1512 | - } |
|
| 1502 | + case PCLZIP_OPT_TEMP_FILE_OFF : |
|
| 1503 | + // ----- Check for incompatible options |
|
| 1504 | + if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) { |
|
| 1505 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'"); |
|
| 1506 | + return PclZip::errorCode(); |
|
| 1507 | + } |
|
| 1508 | + // ----- Check for incompatible options |
|
| 1509 | + if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { |
|
| 1510 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'"); |
|
| 1511 | + return PclZip::errorCode(); |
|
| 1512 | + } |
|
| 1513 | 1513 | |
| 1514 | - $v_result_list[$p_options_list[$i]] = true; |
|
| 1515 | - break; |
|
| 1514 | + $v_result_list[$p_options_list[$i]] = true; |
|
| 1515 | + break; |
|
| 1516 | 1516 | |
| 1517 | - case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION : |
|
| 1518 | - // ----- Check the number of parameters |
|
| 1519 | - if (($i+1) >= $p_size) { |
|
| 1520 | - // ----- Error log |
|
| 1521 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1517 | + case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION : |
|
| 1518 | + // ----- Check the number of parameters |
|
| 1519 | + if (($i+1) >= $p_size) { |
|
| 1520 | + // ----- Error log |
|
| 1521 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1522 | 1522 | |
| 1523 | - // ----- Return |
|
| 1524 | - return PclZip::errorCode(); |
|
| 1525 | - } |
|
| 1523 | + // ----- Return |
|
| 1524 | + return PclZip::errorCode(); |
|
| 1525 | + } |
|
| 1526 | 1526 | |
| 1527 | - // ----- Get the value |
|
| 1528 | - if ( is_string($p_options_list[$i+1]) |
|
| 1529 | - && ($p_options_list[$i+1] != '')) { |
|
| 1530 | - $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
|
| 1531 | - $i++; |
|
| 1532 | - } |
|
| 1533 | - else { |
|
| 1534 | - } |
|
| 1535 | - break; |
|
| 1527 | + // ----- Get the value |
|
| 1528 | + if ( is_string($p_options_list[$i+1]) |
|
| 1529 | + && ($p_options_list[$i+1] != '')) { |
|
| 1530 | + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
|
| 1531 | + $i++; |
|
| 1532 | + } |
|
| 1533 | + else { |
|
| 1534 | + } |
|
| 1535 | + break; |
|
| 1536 | 1536 | |
| 1537 | - // ----- Look for options that request an array of string for value |
|
| 1538 | - case PCLZIP_OPT_BY_NAME : |
|
| 1539 | - // ----- Check the number of parameters |
|
| 1540 | - if (($i+1) >= $p_size) { |
|
| 1541 | - // ----- Error log |
|
| 1542 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1537 | + // ----- Look for options that request an array of string for value |
|
| 1538 | + case PCLZIP_OPT_BY_NAME : |
|
| 1539 | + // ----- Check the number of parameters |
|
| 1540 | + if (($i+1) >= $p_size) { |
|
| 1541 | + // ----- Error log |
|
| 1542 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1543 | 1543 | |
| 1544 | - // ----- Return |
|
| 1545 | - return PclZip::errorCode(); |
|
| 1546 | - } |
|
| 1544 | + // ----- Return |
|
| 1545 | + return PclZip::errorCode(); |
|
| 1546 | + } |
|
| 1547 | 1547 | |
| 1548 | - // ----- Get the value |
|
| 1549 | - if (is_string($p_options_list[$i+1])) { |
|
| 1550 | - $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1]; |
|
| 1551 | - } |
|
| 1552 | - else if (is_array($p_options_list[$i+1])) { |
|
| 1553 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1554 | - } |
|
| 1555 | - else { |
|
| 1556 | - // ----- Error log |
|
| 1557 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1548 | + // ----- Get the value |
|
| 1549 | + if (is_string($p_options_list[$i+1])) { |
|
| 1550 | + $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1]; |
|
| 1551 | + } |
|
| 1552 | + else if (is_array($p_options_list[$i+1])) { |
|
| 1553 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1554 | + } |
|
| 1555 | + else { |
|
| 1556 | + // ----- Error log |
|
| 1557 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1558 | 1558 | |
| 1559 | - // ----- Return |
|
| 1560 | - return PclZip::errorCode(); |
|
| 1561 | - } |
|
| 1562 | - $i++; |
|
| 1563 | - break; |
|
| 1564 | - |
|
| 1565 | - // ----- Look for options that request an EREG or PREG expression |
|
| 1566 | - case PCLZIP_OPT_BY_EREG : |
|
| 1567 | - // ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG |
|
| 1568 | - // to PCLZIP_OPT_BY_PREG |
|
| 1569 | - $p_options_list[$i] = PCLZIP_OPT_BY_PREG; |
|
| 1570 | - case PCLZIP_OPT_BY_PREG : |
|
| 1571 | - //case PCLZIP_OPT_CRYPT : |
|
| 1572 | - // ----- Check the number of parameters |
|
| 1573 | - if (($i+1) >= $p_size) { |
|
| 1574 | - // ----- Error log |
|
| 1575 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1576 | - |
|
| 1577 | - // ----- Return |
|
| 1578 | - return PclZip::errorCode(); |
|
| 1579 | - } |
|
| 1559 | + // ----- Return |
|
| 1560 | + return PclZip::errorCode(); |
|
| 1561 | + } |
|
| 1562 | + $i++; |
|
| 1563 | + break; |
|
| 1564 | + |
|
| 1565 | + // ----- Look for options that request an EREG or PREG expression |
|
| 1566 | + case PCLZIP_OPT_BY_EREG : |
|
| 1567 | + // ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG |
|
| 1568 | + // to PCLZIP_OPT_BY_PREG |
|
| 1569 | + $p_options_list[$i] = PCLZIP_OPT_BY_PREG; |
|
| 1570 | + case PCLZIP_OPT_BY_PREG : |
|
| 1571 | + //case PCLZIP_OPT_CRYPT : |
|
| 1572 | + // ----- Check the number of parameters |
|
| 1573 | + if (($i+1) >= $p_size) { |
|
| 1574 | + // ----- Error log |
|
| 1575 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1576 | + |
|
| 1577 | + // ----- Return |
|
| 1578 | + return PclZip::errorCode(); |
|
| 1579 | + } |
|
| 1580 | 1580 | |
| 1581 | - // ----- Get the value |
|
| 1582 | - if (is_string($p_options_list[$i+1])) { |
|
| 1583 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1584 | - } |
|
| 1585 | - else { |
|
| 1586 | - // ----- Error log |
|
| 1587 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1581 | + // ----- Get the value |
|
| 1582 | + if (is_string($p_options_list[$i+1])) { |
|
| 1583 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1584 | + } |
|
| 1585 | + else { |
|
| 1586 | + // ----- Error log |
|
| 1587 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1588 | 1588 | |
| 1589 | - // ----- Return |
|
| 1590 | - return PclZip::errorCode(); |
|
| 1591 | - } |
|
| 1592 | - $i++; |
|
| 1593 | - break; |
|
| 1594 | - |
|
| 1595 | - // ----- Look for options that takes a string |
|
| 1596 | - case PCLZIP_OPT_COMMENT : |
|
| 1597 | - case PCLZIP_OPT_ADD_COMMENT : |
|
| 1598 | - case PCLZIP_OPT_PREPEND_COMMENT : |
|
| 1599 | - // ----- Check the number of parameters |
|
| 1600 | - if (($i+1) >= $p_size) { |
|
| 1601 | - // ----- Error log |
|
| 1602 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, |
|
| 1603 | - "Missing parameter value for option '" |
|
| 1589 | + // ----- Return |
|
| 1590 | + return PclZip::errorCode(); |
|
| 1591 | + } |
|
| 1592 | + $i++; |
|
| 1593 | + break; |
|
| 1594 | + |
|
| 1595 | + // ----- Look for options that takes a string |
|
| 1596 | + case PCLZIP_OPT_COMMENT : |
|
| 1597 | + case PCLZIP_OPT_ADD_COMMENT : |
|
| 1598 | + case PCLZIP_OPT_PREPEND_COMMENT : |
|
| 1599 | + // ----- Check the number of parameters |
|
| 1600 | + if (($i+1) >= $p_size) { |
|
| 1601 | + // ----- Error log |
|
| 1602 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, |
|
| 1603 | + "Missing parameter value for option '" |
|
| 1604 | 1604 | .PclZipUtilOptionText($p_options_list[$i]) |
| 1605 | 1605 | ."'"); |
| 1606 | 1606 | |
| 1607 | - // ----- Return |
|
| 1608 | - return PclZip::errorCode(); |
|
| 1609 | - } |
|
| 1607 | + // ----- Return |
|
| 1608 | + return PclZip::errorCode(); |
|
| 1609 | + } |
|
| 1610 | 1610 | |
| 1611 | - // ----- Get the value |
|
| 1612 | - if (is_string($p_options_list[$i+1])) { |
|
| 1613 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1614 | - } |
|
| 1615 | - else { |
|
| 1616 | - // ----- Error log |
|
| 1617 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, |
|
| 1618 | - "Wrong parameter value for option '" |
|
| 1611 | + // ----- Get the value |
|
| 1612 | + if (is_string($p_options_list[$i+1])) { |
|
| 1613 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1614 | + } |
|
| 1615 | + else { |
|
| 1616 | + // ----- Error log |
|
| 1617 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, |
|
| 1618 | + "Wrong parameter value for option '" |
|
| 1619 | 1619 | .PclZipUtilOptionText($p_options_list[$i]) |
| 1620 | 1620 | ."'"); |
| 1621 | 1621 | |
| 1622 | - // ----- Return |
|
| 1623 | - return PclZip::errorCode(); |
|
| 1624 | - } |
|
| 1625 | - $i++; |
|
| 1626 | - break; |
|
| 1627 | - |
|
| 1628 | - // ----- Look for options that request an array of index |
|
| 1629 | - case PCLZIP_OPT_BY_INDEX : |
|
| 1630 | - // ----- Check the number of parameters |
|
| 1631 | - if (($i+1) >= $p_size) { |
|
| 1632 | - // ----- Error log |
|
| 1633 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1634 | - |
|
| 1635 | - // ----- Return |
|
| 1636 | - return PclZip::errorCode(); |
|
| 1637 | - } |
|
| 1622 | + // ----- Return |
|
| 1623 | + return PclZip::errorCode(); |
|
| 1624 | + } |
|
| 1625 | + $i++; |
|
| 1626 | + break; |
|
| 1627 | + |
|
| 1628 | + // ----- Look for options that request an array of index |
|
| 1629 | + case PCLZIP_OPT_BY_INDEX : |
|
| 1630 | + // ----- Check the number of parameters |
|
| 1631 | + if (($i+1) >= $p_size) { |
|
| 1632 | + // ----- Error log |
|
| 1633 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1634 | + |
|
| 1635 | + // ----- Return |
|
| 1636 | + return PclZip::errorCode(); |
|
| 1637 | + } |
|
| 1638 | 1638 | |
| 1639 | - // ----- Get the value |
|
| 1640 | - $v_work_list = array(); |
|
| 1641 | - if (is_string($p_options_list[$i+1])) { |
|
| 1639 | + // ----- Get the value |
|
| 1640 | + $v_work_list = array(); |
|
| 1641 | + if (is_string($p_options_list[$i+1])) { |
|
| 1642 | 1642 | |
| 1643 | - // ----- Remove spaces |
|
| 1644 | - $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', ''); |
|
| 1643 | + // ----- Remove spaces |
|
| 1644 | + $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', ''); |
|
| 1645 | 1645 | |
| 1646 | - // ----- Parse items |
|
| 1647 | - $v_work_list = explode(",", $p_options_list[$i+1]); |
|
| 1648 | - } |
|
| 1649 | - else if (is_integer($p_options_list[$i+1])) { |
|
| 1650 | - $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; |
|
| 1651 | - } |
|
| 1652 | - else if (is_array($p_options_list[$i+1])) { |
|
| 1653 | - $v_work_list = $p_options_list[$i+1]; |
|
| 1654 | - } |
|
| 1655 | - else { |
|
| 1656 | - // ----- Error log |
|
| 1657 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1646 | + // ----- Parse items |
|
| 1647 | + $v_work_list = explode(",", $p_options_list[$i+1]); |
|
| 1648 | + } |
|
| 1649 | + else if (is_integer($p_options_list[$i+1])) { |
|
| 1650 | + $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; |
|
| 1651 | + } |
|
| 1652 | + else if (is_array($p_options_list[$i+1])) { |
|
| 1653 | + $v_work_list = $p_options_list[$i+1]; |
|
| 1654 | + } |
|
| 1655 | + else { |
|
| 1656 | + // ----- Error log |
|
| 1657 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1658 | 1658 | |
| 1659 | - // ----- Return |
|
| 1660 | - return PclZip::errorCode(); |
|
| 1661 | - } |
|
| 1659 | + // ----- Return |
|
| 1660 | + return PclZip::errorCode(); |
|
| 1661 | + } |
|
| 1662 | 1662 | |
| 1663 | - // ----- Reduce the index list |
|
| 1664 | - // each index item in the list must be a couple with a start and |
|
| 1665 | - // an end value : [0,3], [5-5], [8-10], ... |
|
| 1666 | - // ----- Check the format of each item |
|
| 1667 | - $v_sort_flag=false; |
|
| 1668 | - $v_sort_value=0; |
|
| 1669 | - for ($j=0; $j<sizeof($v_work_list); $j++) { |
|
| 1670 | - // ----- Explode the item |
|
| 1671 | - $v_item_list = explode("-", $v_work_list[$j]); |
|
| 1672 | - $v_size_item_list = sizeof($v_item_list); |
|
| 1673 | - |
|
| 1674 | - // ----- TBC : Here we might check that each item is a |
|
| 1675 | - // real integer ... |
|
| 1676 | - |
|
| 1677 | - // ----- Look for single value |
|
| 1678 | - if ($v_size_item_list == 1) { |
|
| 1679 | - // ----- Set the option value |
|
| 1680 | - $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; |
|
| 1681 | - $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0]; |
|
| 1682 | - } |
|
| 1683 | - elseif ($v_size_item_list == 2) { |
|
| 1684 | - // ----- Set the option value |
|
| 1685 | - $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; |
|
| 1686 | - $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1]; |
|
| 1687 | - } |
|
| 1688 | - else { |
|
| 1689 | - // ----- Error log |
|
| 1690 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1691 | - |
|
| 1692 | - // ----- Return |
|
| 1693 | - return PclZip::errorCode(); |
|
| 1694 | - } |
|
| 1695 | - |
|
| 1696 | - |
|
| 1697 | - // ----- Look for list sort |
|
| 1698 | - if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) { |
|
| 1699 | - $v_sort_flag=true; |
|
| 1700 | - |
|
| 1701 | - // ----- TBC : An automatic sort should be writen ... |
|
| 1702 | - // ----- Error log |
|
| 1703 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1704 | - |
|
| 1705 | - // ----- Return |
|
| 1706 | - return PclZip::errorCode(); |
|
| 1707 | - } |
|
| 1708 | - $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start']; |
|
| 1709 | - } |
|
| 1663 | + // ----- Reduce the index list |
|
| 1664 | + // each index item in the list must be a couple with a start and |
|
| 1665 | + // an end value : [0,3], [5-5], [8-10], ... |
|
| 1666 | + // ----- Check the format of each item |
|
| 1667 | + $v_sort_flag=false; |
|
| 1668 | + $v_sort_value=0; |
|
| 1669 | + for ($j=0; $j<sizeof($v_work_list); $j++) { |
|
| 1670 | + // ----- Explode the item |
|
| 1671 | + $v_item_list = explode("-", $v_work_list[$j]); |
|
| 1672 | + $v_size_item_list = sizeof($v_item_list); |
|
| 1673 | + |
|
| 1674 | + // ----- TBC : Here we might check that each item is a |
|
| 1675 | + // real integer ... |
|
| 1676 | + |
|
| 1677 | + // ----- Look for single value |
|
| 1678 | + if ($v_size_item_list == 1) { |
|
| 1679 | + // ----- Set the option value |
|
| 1680 | + $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; |
|
| 1681 | + $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0]; |
|
| 1682 | + } |
|
| 1683 | + elseif ($v_size_item_list == 2) { |
|
| 1684 | + // ----- Set the option value |
|
| 1685 | + $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; |
|
| 1686 | + $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1]; |
|
| 1687 | + } |
|
| 1688 | + else { |
|
| 1689 | + // ----- Error log |
|
| 1690 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1691 | + |
|
| 1692 | + // ----- Return |
|
| 1693 | + return PclZip::errorCode(); |
|
| 1694 | + } |
|
| 1695 | + |
|
| 1696 | + |
|
| 1697 | + // ----- Look for list sort |
|
| 1698 | + if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) { |
|
| 1699 | + $v_sort_flag=true; |
|
| 1700 | + |
|
| 1701 | + // ----- TBC : An automatic sort should be writen ... |
|
| 1702 | + // ----- Error log |
|
| 1703 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1704 | + |
|
| 1705 | + // ----- Return |
|
| 1706 | + return PclZip::errorCode(); |
|
| 1707 | + } |
|
| 1708 | + $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start']; |
|
| 1709 | + } |
|
| 1710 | 1710 | |
| 1711 | - // ----- Sort the items |
|
| 1712 | - if ($v_sort_flag) { |
|
| 1713 | - // TBC : To Be Completed |
|
| 1714 | - } |
|
| 1711 | + // ----- Sort the items |
|
| 1712 | + if ($v_sort_flag) { |
|
| 1713 | + // TBC : To Be Completed |
|
| 1714 | + } |
|
| 1715 | 1715 | |
| 1716 | - // ----- Next option |
|
| 1717 | - $i++; |
|
| 1718 | - break; |
|
| 1719 | - |
|
| 1720 | - // ----- Look for options that request no value |
|
| 1721 | - case PCLZIP_OPT_REMOVE_ALL_PATH : |
|
| 1722 | - case PCLZIP_OPT_EXTRACT_AS_STRING : |
|
| 1723 | - case PCLZIP_OPT_NO_COMPRESSION : |
|
| 1724 | - case PCLZIP_OPT_EXTRACT_IN_OUTPUT : |
|
| 1725 | - case PCLZIP_OPT_REPLACE_NEWER : |
|
| 1726 | - case PCLZIP_OPT_STOP_ON_ERROR : |
|
| 1727 | - $v_result_list[$p_options_list[$i]] = true; |
|
| 1728 | - break; |
|
| 1729 | - |
|
| 1730 | - // ----- Look for options that request an octal value |
|
| 1731 | - case PCLZIP_OPT_SET_CHMOD : |
|
| 1732 | - // ----- Check the number of parameters |
|
| 1733 | - if (($i+1) >= $p_size) { |
|
| 1734 | - // ----- Error log |
|
| 1735 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1736 | - |
|
| 1737 | - // ----- Return |
|
| 1738 | - return PclZip::errorCode(); |
|
| 1739 | - } |
|
| 1716 | + // ----- Next option |
|
| 1717 | + $i++; |
|
| 1718 | + break; |
|
| 1719 | + |
|
| 1720 | + // ----- Look for options that request no value |
|
| 1721 | + case PCLZIP_OPT_REMOVE_ALL_PATH : |
|
| 1722 | + case PCLZIP_OPT_EXTRACT_AS_STRING : |
|
| 1723 | + case PCLZIP_OPT_NO_COMPRESSION : |
|
| 1724 | + case PCLZIP_OPT_EXTRACT_IN_OUTPUT : |
|
| 1725 | + case PCLZIP_OPT_REPLACE_NEWER : |
|
| 1726 | + case PCLZIP_OPT_STOP_ON_ERROR : |
|
| 1727 | + $v_result_list[$p_options_list[$i]] = true; |
|
| 1728 | + break; |
|
| 1729 | + |
|
| 1730 | + // ----- Look for options that request an octal value |
|
| 1731 | + case PCLZIP_OPT_SET_CHMOD : |
|
| 1732 | + // ----- Check the number of parameters |
|
| 1733 | + if (($i+1) >= $p_size) { |
|
| 1734 | + // ----- Error log |
|
| 1735 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1736 | + |
|
| 1737 | + // ----- Return |
|
| 1738 | + return PclZip::errorCode(); |
|
| 1739 | + } |
|
| 1740 | 1740 | |
| 1741 | - // ----- Get the value |
|
| 1742 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1743 | - $i++; |
|
| 1744 | - break; |
|
| 1745 | - |
|
| 1746 | - // ----- Look for options that request a call-back |
|
| 1747 | - case PCLZIP_CB_PRE_EXTRACT : |
|
| 1748 | - case PCLZIP_CB_POST_EXTRACT : |
|
| 1749 | - case PCLZIP_CB_PRE_ADD : |
|
| 1750 | - case PCLZIP_CB_POST_ADD : |
|
| 1751 | - /* for futur use |
|
| 1741 | + // ----- Get the value |
|
| 1742 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1743 | + $i++; |
|
| 1744 | + break; |
|
| 1745 | + |
|
| 1746 | + // ----- Look for options that request a call-back |
|
| 1747 | + case PCLZIP_CB_PRE_EXTRACT : |
|
| 1748 | + case PCLZIP_CB_POST_EXTRACT : |
|
| 1749 | + case PCLZIP_CB_PRE_ADD : |
|
| 1750 | + case PCLZIP_CB_POST_ADD : |
|
| 1751 | + /* for futur use |
|
| 1752 | 1752 | case PCLZIP_CB_PRE_DELETE : |
| 1753 | 1753 | case PCLZIP_CB_POST_DELETE : |
| 1754 | 1754 | case PCLZIP_CB_PRE_LIST : |
| 1755 | 1755 | case PCLZIP_CB_POST_LIST : |
| 1756 | 1756 | */ |
| 1757 | - // ----- Check the number of parameters |
|
| 1758 | - if (($i+1) >= $p_size) { |
|
| 1759 | - // ----- Error log |
|
| 1760 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1757 | + // ----- Check the number of parameters |
|
| 1758 | + if (($i+1) >= $p_size) { |
|
| 1759 | + // ----- Error log |
|
| 1760 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1761 | 1761 | |
| 1762 | - // ----- Return |
|
| 1763 | - return PclZip::errorCode(); |
|
| 1764 | - } |
|
| 1762 | + // ----- Return |
|
| 1763 | + return PclZip::errorCode(); |
|
| 1764 | + } |
|
| 1765 | 1765 | |
| 1766 | - // ----- Get the value |
|
| 1767 | - $v_function_name = $p_options_list[$i+1]; |
|
| 1766 | + // ----- Get the value |
|
| 1767 | + $v_function_name = $p_options_list[$i+1]; |
|
| 1768 | 1768 | |
| 1769 | - // ----- Check that the value is a valid existing function |
|
| 1770 | - if (!function_exists($v_function_name)) { |
|
| 1771 | - // ----- Error log |
|
| 1772 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1769 | + // ----- Check that the value is a valid existing function |
|
| 1770 | + if (!function_exists($v_function_name)) { |
|
| 1771 | + // ----- Error log |
|
| 1772 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
|
| 1773 | 1773 | |
| 1774 | - // ----- Return |
|
| 1775 | - return PclZip::errorCode(); |
|
| 1776 | - } |
|
| 1774 | + // ----- Return |
|
| 1775 | + return PclZip::errorCode(); |
|
| 1776 | + } |
|
| 1777 | 1777 | |
| 1778 | - // ----- Set the attribute |
|
| 1779 | - $v_result_list[$p_options_list[$i]] = $v_function_name; |
|
| 1780 | - $i++; |
|
| 1781 | - break; |
|
| 1778 | + // ----- Set the attribute |
|
| 1779 | + $v_result_list[$p_options_list[$i]] = $v_function_name; |
|
| 1780 | + $i++; |
|
| 1781 | + break; |
|
| 1782 | 1782 | |
| 1783 | - default : |
|
| 1784 | - // ----- Error log |
|
| 1785 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
|
| 1786 | - "Unknown parameter '" |
|
| 1783 | + default : |
|
| 1784 | + // ----- Error log |
|
| 1785 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
|
| 1786 | + "Unknown parameter '" |
|
| 1787 | 1787 | .$p_options_list[$i]."'"); |
| 1788 | 1788 | |
| 1789 | - // ----- Return |
|
| 1790 | - return PclZip::errorCode(); |
|
| 1791 | - } |
|
| 1789 | + // ----- Return |
|
| 1790 | + return PclZip::errorCode(); |
|
| 1791 | + } |
|
| 1792 | 1792 | |
| 1793 | - // ----- Next options |
|
| 1794 | - $i++; |
|
| 1795 | - } |
|
| 1793 | + // ----- Next options |
|
| 1794 | + $i++; |
|
| 1795 | + } |
|
| 1796 | 1796 | |
| 1797 | - // ----- Look for mandatory options |
|
| 1798 | - if ($v_requested_options !== false) { |
|
| 1799 | - for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { |
|
| 1800 | - // ----- Look for mandatory option |
|
| 1801 | - if ($v_requested_options[$key] == 'mandatory') { |
|
| 1802 | - // ----- Look if present |
|
| 1803 | - if (!isset($v_result_list[$key])) { |
|
| 1804 | - // ----- Error log |
|
| 1805 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); |
|
| 1806 | - |
|
| 1807 | - // ----- Return |
|
| 1808 | - return PclZip::errorCode(); |
|
| 1809 | - } |
|
| 1810 | - } |
|
| 1811 | - } |
|
| 1812 | - } |
|
| 1797 | + // ----- Look for mandatory options |
|
| 1798 | + if ($v_requested_options !== false) { |
|
| 1799 | + for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { |
|
| 1800 | + // ----- Look for mandatory option |
|
| 1801 | + if ($v_requested_options[$key] == 'mandatory') { |
|
| 1802 | + // ----- Look if present |
|
| 1803 | + if (!isset($v_result_list[$key])) { |
|
| 1804 | + // ----- Error log |
|
| 1805 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); |
|
| 1806 | + |
|
| 1807 | + // ----- Return |
|
| 1808 | + return PclZip::errorCode(); |
|
| 1809 | + } |
|
| 1810 | + } |
|
| 1811 | + } |
|
| 1812 | + } |
|
| 1813 | 1813 | |
| 1814 | - // ----- Look for default values |
|
| 1815 | - if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { |
|
| 1814 | + // ----- Look for default values |
|
| 1815 | + if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { |
|
| 1816 | 1816 | |
| 1817 | - } |
|
| 1817 | + } |
|
| 1818 | 1818 | |
| 1819 | - // ----- Return |
|
| 1820 | - return $v_result; |
|
| 1819 | + // ----- Return |
|
| 1820 | + return $v_result; |
|
| 1821 | 1821 | } |
| 1822 | 1822 | // -------------------------------------------------------------------------------- |
| 1823 | 1823 | |
@@ -1829,38 +1829,38 @@ discard block |
||
| 1829 | 1829 | // -------------------------------------------------------------------------------- |
| 1830 | 1830 | function privOptionDefaultThreshold(&$p_options) |
| 1831 | 1831 | { |
| 1832 | - $v_result=1; |
|
| 1832 | + $v_result=1; |
|
| 1833 | 1833 | |
| 1834 | - if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
|
| 1835 | - || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) { |
|
| 1836 | - return $v_result; |
|
| 1837 | - } |
|
| 1834 | + if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
|
| 1835 | + || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) { |
|
| 1836 | + return $v_result; |
|
| 1837 | + } |
|
| 1838 | 1838 | |
| 1839 | - // ----- Get 'memory_limit' configuration value |
|
| 1840 | - $v_memory_limit = ini_get('memory_limit'); |
|
| 1841 | - $v_memory_limit = trim($v_memory_limit); |
|
| 1842 | - $v_memory_limit_int = (int) $v_memory_limit; |
|
| 1843 | - $last = strtolower(substr($v_memory_limit, -1)); |
|
| 1839 | + // ----- Get 'memory_limit' configuration value |
|
| 1840 | + $v_memory_limit = ini_get('memory_limit'); |
|
| 1841 | + $v_memory_limit = trim($v_memory_limit); |
|
| 1842 | + $v_memory_limit_int = (int) $v_memory_limit; |
|
| 1843 | + $last = strtolower(substr($v_memory_limit, -1)); |
|
| 1844 | 1844 | |
| 1845 | - if($last == 'g') |
|
| 1846 | - //$v_memory_limit_int = $v_memory_limit_int*1024*1024*1024; |
|
| 1847 | - $v_memory_limit_int = $v_memory_limit_int*1073741824; |
|
| 1848 | - if($last == 'm') |
|
| 1849 | - //$v_memory_limit_int = $v_memory_limit_int*1024*1024; |
|
| 1850 | - $v_memory_limit_int = $v_memory_limit_int*1048576; |
|
| 1851 | - if($last == 'k') |
|
| 1852 | - $v_memory_limit_int = $v_memory_limit_int*1024; |
|
| 1845 | + if($last == 'g') |
|
| 1846 | + //$v_memory_limit_int = $v_memory_limit_int*1024*1024*1024; |
|
| 1847 | + $v_memory_limit_int = $v_memory_limit_int*1073741824; |
|
| 1848 | + if($last == 'm') |
|
| 1849 | + //$v_memory_limit_int = $v_memory_limit_int*1024*1024; |
|
| 1850 | + $v_memory_limit_int = $v_memory_limit_int*1048576; |
|
| 1851 | + if($last == 'k') |
|
| 1852 | + $v_memory_limit_int = $v_memory_limit_int*1024; |
|
| 1853 | 1853 | |
| 1854 | - $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit_int*PCLZIP_TEMPORARY_FILE_RATIO); |
|
| 1854 | + $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit_int*PCLZIP_TEMPORARY_FILE_RATIO); |
|
| 1855 | 1855 | |
| 1856 | 1856 | |
| 1857 | - // ----- Sanity check : No threshold if value lower than 1M |
|
| 1858 | - if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) { |
|
| 1859 | - unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]); |
|
| 1860 | - } |
|
| 1857 | + // ----- Sanity check : No threshold if value lower than 1M |
|
| 1858 | + if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) { |
|
| 1859 | + unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]); |
|
| 1860 | + } |
|
| 1861 | 1861 | |
| 1862 | - // ----- Return |
|
| 1863 | - return $v_result; |
|
| 1862 | + // ----- Return |
|
| 1863 | + return $v_result; |
|
| 1864 | 1864 | } |
| 1865 | 1865 | // -------------------------------------------------------------------------------- |
| 1866 | 1866 | |
@@ -1874,116 +1874,116 @@ discard block |
||
| 1874 | 1874 | // -------------------------------------------------------------------------------- |
| 1875 | 1875 | function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false) |
| 1876 | 1876 | { |
| 1877 | - $v_result=1; |
|
| 1877 | + $v_result=1; |
|
| 1878 | 1878 | |
| 1879 | - // ----- For each file in the list check the attributes |
|
| 1880 | - foreach ($p_file_list as $v_key => $v_value) { |
|
| 1879 | + // ----- For each file in the list check the attributes |
|
| 1880 | + foreach ($p_file_list as $v_key => $v_value) { |
|
| 1881 | 1881 | |
| 1882 | - // ----- Check if the option is supported |
|
| 1883 | - if (!isset($v_requested_options[$v_key])) { |
|
| 1884 | - // ----- Error log |
|
| 1885 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file"); |
|
| 1882 | + // ----- Check if the option is supported |
|
| 1883 | + if (!isset($v_requested_options[$v_key])) { |
|
| 1884 | + // ----- Error log |
|
| 1885 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file"); |
|
| 1886 | 1886 | |
| 1887 | - // ----- Return |
|
| 1888 | - return PclZip::errorCode(); |
|
| 1889 | - } |
|
| 1887 | + // ----- Return |
|
| 1888 | + return PclZip::errorCode(); |
|
| 1889 | + } |
|
| 1890 | 1890 | |
| 1891 | - // ----- Look for attribute |
|
| 1892 | - switch ($v_key) { |
|
| 1893 | - case PCLZIP_ATT_FILE_NAME : |
|
| 1894 | - if (!is_string($v_value)) { |
|
| 1895 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1896 | - return PclZip::errorCode(); |
|
| 1897 | - } |
|
| 1891 | + // ----- Look for attribute |
|
| 1892 | + switch ($v_key) { |
|
| 1893 | + case PCLZIP_ATT_FILE_NAME : |
|
| 1894 | + if (!is_string($v_value)) { |
|
| 1895 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1896 | + return PclZip::errorCode(); |
|
| 1897 | + } |
|
| 1898 | 1898 | |
| 1899 | - $p_filedescr['filename'] = PclZipUtilPathReduction($v_value); |
|
| 1899 | + $p_filedescr['filename'] = PclZipUtilPathReduction($v_value); |
|
| 1900 | 1900 | |
| 1901 | - if ($p_filedescr['filename'] == '') { |
|
| 1902 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1903 | - return PclZip::errorCode(); |
|
| 1904 | - } |
|
| 1901 | + if ($p_filedescr['filename'] == '') { |
|
| 1902 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1903 | + return PclZip::errorCode(); |
|
| 1904 | + } |
|
| 1905 | 1905 | |
| 1906 | - break; |
|
| 1906 | + break; |
|
| 1907 | 1907 | |
| 1908 | - case PCLZIP_ATT_FILE_NEW_SHORT_NAME : |
|
| 1909 | - if (!is_string($v_value)) { |
|
| 1910 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1911 | - return PclZip::errorCode(); |
|
| 1912 | - } |
|
| 1908 | + case PCLZIP_ATT_FILE_NEW_SHORT_NAME : |
|
| 1909 | + if (!is_string($v_value)) { |
|
| 1910 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1911 | + return PclZip::errorCode(); |
|
| 1912 | + } |
|
| 1913 | 1913 | |
| 1914 | - $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value); |
|
| 1914 | + $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value); |
|
| 1915 | 1915 | |
| 1916 | - if ($p_filedescr['new_short_name'] == '') { |
|
| 1917 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1918 | - return PclZip::errorCode(); |
|
| 1919 | - } |
|
| 1920 | - break; |
|
| 1916 | + if ($p_filedescr['new_short_name'] == '') { |
|
| 1917 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1918 | + return PclZip::errorCode(); |
|
| 1919 | + } |
|
| 1920 | + break; |
|
| 1921 | 1921 | |
| 1922 | - case PCLZIP_ATT_FILE_NEW_FULL_NAME : |
|
| 1923 | - if (!is_string($v_value)) { |
|
| 1924 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1925 | - return PclZip::errorCode(); |
|
| 1926 | - } |
|
| 1922 | + case PCLZIP_ATT_FILE_NEW_FULL_NAME : |
|
| 1923 | + if (!is_string($v_value)) { |
|
| 1924 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1925 | + return PclZip::errorCode(); |
|
| 1926 | + } |
|
| 1927 | 1927 | |
| 1928 | - $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value); |
|
| 1928 | + $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value); |
|
| 1929 | 1929 | |
| 1930 | - if ($p_filedescr['new_full_name'] == '') { |
|
| 1931 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1932 | - return PclZip::errorCode(); |
|
| 1933 | - } |
|
| 1934 | - break; |
|
| 1930 | + if ($p_filedescr['new_full_name'] == '') { |
|
| 1931 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1932 | + return PclZip::errorCode(); |
|
| 1933 | + } |
|
| 1934 | + break; |
|
| 1935 | 1935 | |
| 1936 | - // ----- Look for options that takes a string |
|
| 1937 | - case PCLZIP_ATT_FILE_COMMENT : |
|
| 1938 | - if (!is_string($v_value)) { |
|
| 1939 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1940 | - return PclZip::errorCode(); |
|
| 1941 | - } |
|
| 1936 | + // ----- Look for options that takes a string |
|
| 1937 | + case PCLZIP_ATT_FILE_COMMENT : |
|
| 1938 | + if (!is_string($v_value)) { |
|
| 1939 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1940 | + return PclZip::errorCode(); |
|
| 1941 | + } |
|
| 1942 | 1942 | |
| 1943 | - $p_filedescr['comment'] = $v_value; |
|
| 1944 | - break; |
|
| 1943 | + $p_filedescr['comment'] = $v_value; |
|
| 1944 | + break; |
|
| 1945 | 1945 | |
| 1946 | - case PCLZIP_ATT_FILE_MTIME : |
|
| 1947 | - if (!is_integer($v_value)) { |
|
| 1948 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1949 | - return PclZip::errorCode(); |
|
| 1950 | - } |
|
| 1946 | + case PCLZIP_ATT_FILE_MTIME : |
|
| 1947 | + if (!is_integer($v_value)) { |
|
| 1948 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
|
| 1949 | + return PclZip::errorCode(); |
|
| 1950 | + } |
|
| 1951 | 1951 | |
| 1952 | - $p_filedescr['mtime'] = $v_value; |
|
| 1953 | - break; |
|
| 1952 | + $p_filedescr['mtime'] = $v_value; |
|
| 1953 | + break; |
|
| 1954 | 1954 | |
| 1955 | - case PCLZIP_ATT_FILE_CONTENT : |
|
| 1956 | - $p_filedescr['content'] = $v_value; |
|
| 1957 | - break; |
|
| 1955 | + case PCLZIP_ATT_FILE_CONTENT : |
|
| 1956 | + $p_filedescr['content'] = $v_value; |
|
| 1957 | + break; |
|
| 1958 | 1958 | |
| 1959 | - default : |
|
| 1960 | - // ----- Error log |
|
| 1961 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
|
| 1962 | - "Unknown parameter '".$v_key."'"); |
|
| 1959 | + default : |
|
| 1960 | + // ----- Error log |
|
| 1961 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
|
| 1962 | + "Unknown parameter '".$v_key."'"); |
|
| 1963 | 1963 | |
| 1964 | - // ----- Return |
|
| 1965 | - return PclZip::errorCode(); |
|
| 1966 | - } |
|
| 1964 | + // ----- Return |
|
| 1965 | + return PclZip::errorCode(); |
|
| 1966 | + } |
|
| 1967 | 1967 | |
| 1968 | - // ----- Look for mandatory options |
|
| 1969 | - if ($v_requested_options !== false) { |
|
| 1970 | - for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { |
|
| 1971 | - // ----- Look for mandatory option |
|
| 1972 | - if ($v_requested_options[$key] == 'mandatory') { |
|
| 1973 | - // ----- Look if present |
|
| 1974 | - if (!isset($p_file_list[$key])) { |
|
| 1975 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); |
|
| 1976 | - return PclZip::errorCode(); |
|
| 1977 | - } |
|
| 1978 | - } |
|
| 1979 | - } |
|
| 1980 | - } |
|
| 1968 | + // ----- Look for mandatory options |
|
| 1969 | + if ($v_requested_options !== false) { |
|
| 1970 | + for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { |
|
| 1971 | + // ----- Look for mandatory option |
|
| 1972 | + if ($v_requested_options[$key] == 'mandatory') { |
|
| 1973 | + // ----- Look if present |
|
| 1974 | + if (!isset($p_file_list[$key])) { |
|
| 1975 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); |
|
| 1976 | + return PclZip::errorCode(); |
|
| 1977 | + } |
|
| 1978 | + } |
|
| 1979 | + } |
|
| 1980 | + } |
|
| 1981 | 1981 | |
| 1982 | - // end foreach |
|
| 1983 | - } |
|
| 1982 | + // end foreach |
|
| 1983 | + } |
|
| 1984 | 1984 | |
| 1985 | - // ----- Return |
|
| 1986 | - return $v_result; |
|
| 1985 | + // ----- Return |
|
| 1986 | + return $v_result; |
|
| 1987 | 1987 | } |
| 1988 | 1988 | // -------------------------------------------------------------------------------- |
| 1989 | 1989 | |
@@ -2003,120 +2003,120 @@ discard block |
||
| 2003 | 2003 | // -------------------------------------------------------------------------------- |
| 2004 | 2004 | function privFileDescrExpand(&$p_filedescr_list, &$p_options) |
| 2005 | 2005 | { |
| 2006 | - $v_result=1; |
|
| 2007 | - |
|
| 2008 | - // ----- Create a result list |
|
| 2009 | - $v_result_list = array(); |
|
| 2010 | - |
|
| 2011 | - // ----- Look each entry |
|
| 2012 | - for ($i=0; $i<sizeof($p_filedescr_list); $i++) { |
|
| 2013 | - |
|
| 2014 | - // ----- Get filedescr |
|
| 2015 | - $v_descr = $p_filedescr_list[$i]; |
|
| 2016 | - |
|
| 2017 | - // ----- Reduce the filename |
|
| 2018 | - $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false); |
|
| 2019 | - $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']); |
|
| 2020 | - |
|
| 2021 | - // ----- Look for real file or folder |
|
| 2022 | - if (file_exists($v_descr['filename'])) { |
|
| 2023 | - if (@is_file($v_descr['filename'])) { |
|
| 2024 | - $v_descr['type'] = 'file'; |
|
| 2025 | - } |
|
| 2026 | - else if (@is_dir($v_descr['filename'])) { |
|
| 2027 | - $v_descr['type'] = 'folder'; |
|
| 2028 | - } |
|
| 2029 | - else if (@is_link($v_descr['filename'])) { |
|
| 2030 | - // skip |
|
| 2031 | - continue; |
|
| 2032 | - } |
|
| 2033 | - else { |
|
| 2034 | - // skip |
|
| 2035 | - continue; |
|
| 2036 | - } |
|
| 2037 | - } |
|
| 2006 | + $v_result=1; |
|
| 2007 | + |
|
| 2008 | + // ----- Create a result list |
|
| 2009 | + $v_result_list = array(); |
|
| 2010 | + |
|
| 2011 | + // ----- Look each entry |
|
| 2012 | + for ($i=0; $i<sizeof($p_filedescr_list); $i++) { |
|
| 2013 | + |
|
| 2014 | + // ----- Get filedescr |
|
| 2015 | + $v_descr = $p_filedescr_list[$i]; |
|
| 2016 | + |
|
| 2017 | + // ----- Reduce the filename |
|
| 2018 | + $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false); |
|
| 2019 | + $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']); |
|
| 2020 | + |
|
| 2021 | + // ----- Look for real file or folder |
|
| 2022 | + if (file_exists($v_descr['filename'])) { |
|
| 2023 | + if (@is_file($v_descr['filename'])) { |
|
| 2024 | + $v_descr['type'] = 'file'; |
|
| 2025 | + } |
|
| 2026 | + else if (@is_dir($v_descr['filename'])) { |
|
| 2027 | + $v_descr['type'] = 'folder'; |
|
| 2028 | + } |
|
| 2029 | + else if (@is_link($v_descr['filename'])) { |
|
| 2030 | + // skip |
|
| 2031 | + continue; |
|
| 2032 | + } |
|
| 2033 | + else { |
|
| 2034 | + // skip |
|
| 2035 | + continue; |
|
| 2036 | + } |
|
| 2037 | + } |
|
| 2038 | 2038 | |
| 2039 | - // ----- Look for string added as file |
|
| 2040 | - else if (isset($v_descr['content'])) { |
|
| 2041 | - $v_descr['type'] = 'virtual_file'; |
|
| 2042 | - } |
|
| 2039 | + // ----- Look for string added as file |
|
| 2040 | + else if (isset($v_descr['content'])) { |
|
| 2041 | + $v_descr['type'] = 'virtual_file'; |
|
| 2042 | + } |
|
| 2043 | 2043 | |
| 2044 | - // ----- Missing file |
|
| 2045 | - else { |
|
| 2046 | - // ----- Error log |
|
| 2047 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist"); |
|
| 2044 | + // ----- Missing file |
|
| 2045 | + else { |
|
| 2046 | + // ----- Error log |
|
| 2047 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist"); |
|
| 2048 | 2048 | |
| 2049 | - // ----- Return |
|
| 2050 | - return PclZip::errorCode(); |
|
| 2051 | - } |
|
| 2049 | + // ----- Return |
|
| 2050 | + return PclZip::errorCode(); |
|
| 2051 | + } |
|
| 2052 | 2052 | |
| 2053 | - // ----- Calculate the stored filename |
|
| 2054 | - $this->privCalculateStoredFilename($v_descr, $p_options); |
|
| 2055 | - |
|
| 2056 | - // ----- Add the descriptor in result list |
|
| 2057 | - $v_result_list[sizeof($v_result_list)] = $v_descr; |
|
| 2058 | - |
|
| 2059 | - // ----- Look for folder |
|
| 2060 | - if ($v_descr['type'] == 'folder') { |
|
| 2061 | - // ----- List of items in folder |
|
| 2062 | - $v_dirlist_descr = array(); |
|
| 2063 | - $v_dirlist_nb = 0; |
|
| 2064 | - if ($v_folder_handler = @opendir($v_descr['filename'])) { |
|
| 2065 | - while (($v_item_handler = @readdir($v_folder_handler)) !== false) { |
|
| 2066 | - |
|
| 2067 | - // ----- Skip '.' and '..' |
|
| 2068 | - if (($v_item_handler == '.') || ($v_item_handler == '..')) { |
|
| 2069 | - continue; |
|
| 2070 | - } |
|
| 2071 | - |
|
| 2072 | - // ----- Compose the full filename |
|
| 2073 | - $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler; |
|
| 2074 | - |
|
| 2075 | - // ----- Look for different stored filename |
|
| 2076 | - // Because the name of the folder was changed, the name of the |
|
| 2077 | - // files/sub-folders also change |
|
| 2078 | - if (($v_descr['stored_filename'] != $v_descr['filename']) |
|
| 2079 | - && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) { |
|
| 2080 | - if ($v_descr['stored_filename'] != '') { |
|
| 2081 | - $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; |
|
| 2082 | - } |
|
| 2083 | - else { |
|
| 2084 | - $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler; |
|
| 2085 | - } |
|
| 2086 | - } |
|
| 2087 | - |
|
| 2088 | - $v_dirlist_nb++; |
|
| 2089 | - } |
|
| 2053 | + // ----- Calculate the stored filename |
|
| 2054 | + $this->privCalculateStoredFilename($v_descr, $p_options); |
|
| 2055 | + |
|
| 2056 | + // ----- Add the descriptor in result list |
|
| 2057 | + $v_result_list[sizeof($v_result_list)] = $v_descr; |
|
| 2058 | + |
|
| 2059 | + // ----- Look for folder |
|
| 2060 | + if ($v_descr['type'] == 'folder') { |
|
| 2061 | + // ----- List of items in folder |
|
| 2062 | + $v_dirlist_descr = array(); |
|
| 2063 | + $v_dirlist_nb = 0; |
|
| 2064 | + if ($v_folder_handler = @opendir($v_descr['filename'])) { |
|
| 2065 | + while (($v_item_handler = @readdir($v_folder_handler)) !== false) { |
|
| 2066 | + |
|
| 2067 | + // ----- Skip '.' and '..' |
|
| 2068 | + if (($v_item_handler == '.') || ($v_item_handler == '..')) { |
|
| 2069 | + continue; |
|
| 2070 | + } |
|
| 2071 | + |
|
| 2072 | + // ----- Compose the full filename |
|
| 2073 | + $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler; |
|
| 2074 | + |
|
| 2075 | + // ----- Look for different stored filename |
|
| 2076 | + // Because the name of the folder was changed, the name of the |
|
| 2077 | + // files/sub-folders also change |
|
| 2078 | + if (($v_descr['stored_filename'] != $v_descr['filename']) |
|
| 2079 | + && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) { |
|
| 2080 | + if ($v_descr['stored_filename'] != '') { |
|
| 2081 | + $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; |
|
| 2082 | + } |
|
| 2083 | + else { |
|
| 2084 | + $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler; |
|
| 2085 | + } |
|
| 2086 | + } |
|
| 2087 | + |
|
| 2088 | + $v_dirlist_nb++; |
|
| 2089 | + } |
|
| 2090 | 2090 | |
| 2091 | - @closedir($v_folder_handler); |
|
| 2092 | - } |
|
| 2093 | - else { |
|
| 2094 | - // TBC : unable to open folder in read mode |
|
| 2095 | - } |
|
| 2096 | - |
|
| 2097 | - // ----- Expand each element of the list |
|
| 2098 | - if ($v_dirlist_nb != 0) { |
|
| 2099 | - // ----- Expand |
|
| 2100 | - if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) { |
|
| 2101 | - return $v_result; |
|
| 2102 | - } |
|
| 2091 | + @closedir($v_folder_handler); |
|
| 2092 | + } |
|
| 2093 | + else { |
|
| 2094 | + // TBC : unable to open folder in read mode |
|
| 2095 | + } |
|
| 2096 | + |
|
| 2097 | + // ----- Expand each element of the list |
|
| 2098 | + if ($v_dirlist_nb != 0) { |
|
| 2099 | + // ----- Expand |
|
| 2100 | + if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) { |
|
| 2101 | + return $v_result; |
|
| 2102 | + } |
|
| 2103 | 2103 | |
| 2104 | - // ----- Concat the resulting list |
|
| 2105 | - $v_result_list = array_merge($v_result_list, $v_dirlist_descr); |
|
| 2106 | - } |
|
| 2107 | - else { |
|
| 2108 | - } |
|
| 2104 | + // ----- Concat the resulting list |
|
| 2105 | + $v_result_list = array_merge($v_result_list, $v_dirlist_descr); |
|
| 2106 | + } |
|
| 2107 | + else { |
|
| 2108 | + } |
|
| 2109 | 2109 | |
| 2110 | - // ----- Free local array |
|
| 2111 | - unset($v_dirlist_descr); |
|
| 2112 | - } |
|
| 2113 | - } |
|
| 2110 | + // ----- Free local array |
|
| 2111 | + unset($v_dirlist_descr); |
|
| 2112 | + } |
|
| 2113 | + } |
|
| 2114 | 2114 | |
| 2115 | - // ----- Get the result list |
|
| 2116 | - $p_filedescr_list = $v_result_list; |
|
| 2115 | + // ----- Get the result list |
|
| 2116 | + $p_filedescr_list = $v_result_list; |
|
| 2117 | 2117 | |
| 2118 | - // ----- Return |
|
| 2119 | - return $v_result; |
|
| 2118 | + // ----- Return |
|
| 2119 | + return $v_result; |
|
| 2120 | 2120 | } |
| 2121 | 2121 | // -------------------------------------------------------------------------------- |
| 2122 | 2122 | |
@@ -2128,30 +2128,30 @@ discard block |
||
| 2128 | 2128 | // -------------------------------------------------------------------------------- |
| 2129 | 2129 | function privCreate($p_filedescr_list, &$p_result_list, &$p_options) |
| 2130 | 2130 | { |
| 2131 | - $v_result=1; |
|
| 2132 | - $v_list_detail = array(); |
|
| 2131 | + $v_result=1; |
|
| 2132 | + $v_list_detail = array(); |
|
| 2133 | 2133 | |
| 2134 | - // ----- Magic quotes trick |
|
| 2135 | - $this->privDisableMagicQuotes(); |
|
| 2134 | + // ----- Magic quotes trick |
|
| 2135 | + $this->privDisableMagicQuotes(); |
|
| 2136 | 2136 | |
| 2137 | - // ----- Open the file in write mode |
|
| 2138 | - if (($v_result = $this->privOpenFd('wb')) != 1) |
|
| 2139 | - { |
|
| 2140 | - // ----- Return |
|
| 2141 | - return $v_result; |
|
| 2142 | - } |
|
| 2137 | + // ----- Open the file in write mode |
|
| 2138 | + if (($v_result = $this->privOpenFd('wb')) != 1) |
|
| 2139 | + { |
|
| 2140 | + // ----- Return |
|
| 2141 | + return $v_result; |
|
| 2142 | + } |
|
| 2143 | 2143 | |
| 2144 | - // ----- Add the list of files |
|
| 2145 | - $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options); |
|
| 2144 | + // ----- Add the list of files |
|
| 2145 | + $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options); |
|
| 2146 | 2146 | |
| 2147 | - // ----- Close |
|
| 2148 | - $this->privCloseFd(); |
|
| 2147 | + // ----- Close |
|
| 2148 | + $this->privCloseFd(); |
|
| 2149 | 2149 | |
| 2150 | - // ----- Magic quotes trick |
|
| 2151 | - $this->privSwapBackMagicQuotes(); |
|
| 2150 | + // ----- Magic quotes trick |
|
| 2151 | + $this->privSwapBackMagicQuotes(); |
|
| 2152 | 2152 | |
| 2153 | - // ----- Return |
|
| 2154 | - return $v_result; |
|
| 2153 | + // ----- Return |
|
| 2154 | + return $v_result; |
|
| 2155 | 2155 | } |
| 2156 | 2156 | // -------------------------------------------------------------------------------- |
| 2157 | 2157 | |
@@ -2163,175 +2163,175 @@ discard block |
||
| 2163 | 2163 | // -------------------------------------------------------------------------------- |
| 2164 | 2164 | function privAdd($p_filedescr_list, &$p_result_list, &$p_options) |
| 2165 | 2165 | { |
| 2166 | - $v_result=1; |
|
| 2167 | - $v_list_detail = array(); |
|
| 2166 | + $v_result=1; |
|
| 2167 | + $v_list_detail = array(); |
|
| 2168 | 2168 | |
| 2169 | - // ----- Look if the archive exists or is empty |
|
| 2170 | - if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0)) |
|
| 2171 | - { |
|
| 2169 | + // ----- Look if the archive exists or is empty |
|
| 2170 | + if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0)) |
|
| 2171 | + { |
|
| 2172 | 2172 | |
| 2173 | - // ----- Do a create |
|
| 2174 | - $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options); |
|
| 2173 | + // ----- Do a create |
|
| 2174 | + $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options); |
|
| 2175 | 2175 | |
| 2176 | - // ----- Return |
|
| 2177 | - return $v_result; |
|
| 2178 | - } |
|
| 2179 | - // ----- Magic quotes trick |
|
| 2180 | - $this->privDisableMagicQuotes(); |
|
| 2176 | + // ----- Return |
|
| 2177 | + return $v_result; |
|
| 2178 | + } |
|
| 2179 | + // ----- Magic quotes trick |
|
| 2180 | + $this->privDisableMagicQuotes(); |
|
| 2181 | 2181 | |
| 2182 | - // ----- Open the zip file |
|
| 2183 | - if (($v_result=$this->privOpenFd('rb')) != 1) |
|
| 2184 | - { |
|
| 2185 | - // ----- Magic quotes trick |
|
| 2186 | - $this->privSwapBackMagicQuotes(); |
|
| 2182 | + // ----- Open the zip file |
|
| 2183 | + if (($v_result=$this->privOpenFd('rb')) != 1) |
|
| 2184 | + { |
|
| 2185 | + // ----- Magic quotes trick |
|
| 2186 | + $this->privSwapBackMagicQuotes(); |
|
| 2187 | 2187 | |
| 2188 | - // ----- Return |
|
| 2189 | - return $v_result; |
|
| 2190 | - } |
|
| 2188 | + // ----- Return |
|
| 2189 | + return $v_result; |
|
| 2190 | + } |
|
| 2191 | 2191 | |
| 2192 | - // ----- Read the central directory informations |
|
| 2193 | - $v_central_dir = array(); |
|
| 2194 | - if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 2195 | - { |
|
| 2196 | - $this->privCloseFd(); |
|
| 2197 | - $this->privSwapBackMagicQuotes(); |
|
| 2198 | - return $v_result; |
|
| 2199 | - } |
|
| 2192 | + // ----- Read the central directory informations |
|
| 2193 | + $v_central_dir = array(); |
|
| 2194 | + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 2195 | + { |
|
| 2196 | + $this->privCloseFd(); |
|
| 2197 | + $this->privSwapBackMagicQuotes(); |
|
| 2198 | + return $v_result; |
|
| 2199 | + } |
|
| 2200 | 2200 | |
| 2201 | - // ----- Go to beginning of File |
|
| 2202 | - @rewind($this->zip_fd); |
|
| 2201 | + // ----- Go to beginning of File |
|
| 2202 | + @rewind($this->zip_fd); |
|
| 2203 | 2203 | |
| 2204 | - // ----- Creates a temporay file |
|
| 2205 | - $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; |
|
| 2204 | + // ----- Creates a temporay file |
|
| 2205 | + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; |
|
| 2206 | 2206 | |
| 2207 | - // ----- Open the temporary file in write mode |
|
| 2208 | - if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) |
|
| 2209 | - { |
|
| 2210 | - $this->privCloseFd(); |
|
| 2211 | - $this->privSwapBackMagicQuotes(); |
|
| 2207 | + // ----- Open the temporary file in write mode |
|
| 2208 | + if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) |
|
| 2209 | + { |
|
| 2210 | + $this->privCloseFd(); |
|
| 2211 | + $this->privSwapBackMagicQuotes(); |
|
| 2212 | 2212 | |
| 2213 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); |
|
| 2213 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); |
|
| 2214 | 2214 | |
| 2215 | - // ----- Return |
|
| 2216 | - return PclZip::errorCode(); |
|
| 2217 | - } |
|
| 2215 | + // ----- Return |
|
| 2216 | + return PclZip::errorCode(); |
|
| 2217 | + } |
|
| 2218 | 2218 | |
| 2219 | - // ----- Copy the files from the archive to the temporary file |
|
| 2220 | - // TBC : Here I should better append the file and go back to erase the central dir |
|
| 2221 | - $v_size = $v_central_dir['offset']; |
|
| 2222 | - while ($v_size != 0) |
|
| 2223 | - { |
|
| 2224 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2225 | - $v_buffer = fread($this->zip_fd, $v_read_size); |
|
| 2226 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 2227 | - $v_size -= $v_read_size; |
|
| 2228 | - } |
|
| 2219 | + // ----- Copy the files from the archive to the temporary file |
|
| 2220 | + // TBC : Here I should better append the file and go back to erase the central dir |
|
| 2221 | + $v_size = $v_central_dir['offset']; |
|
| 2222 | + while ($v_size != 0) |
|
| 2223 | + { |
|
| 2224 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2225 | + $v_buffer = fread($this->zip_fd, $v_read_size); |
|
| 2226 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 2227 | + $v_size -= $v_read_size; |
|
| 2228 | + } |
|
| 2229 | 2229 | |
| 2230 | - // ----- Swap the file descriptor |
|
| 2231 | - // Here is a trick : I swap the temporary fd with the zip fd, in order to use |
|
| 2232 | - // the following methods on the temporary fil and not the real archive |
|
| 2233 | - $v_swap = $this->zip_fd; |
|
| 2234 | - $this->zip_fd = $v_zip_temp_fd; |
|
| 2235 | - $v_zip_temp_fd = $v_swap; |
|
| 2236 | - |
|
| 2237 | - // ----- Add the files |
|
| 2238 | - $v_header_list = array(); |
|
| 2239 | - if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) |
|
| 2240 | - { |
|
| 2241 | - fclose($v_zip_temp_fd); |
|
| 2242 | - $this->privCloseFd(); |
|
| 2243 | - @unlink($v_zip_temp_name); |
|
| 2244 | - $this->privSwapBackMagicQuotes(); |
|
| 2245 | - |
|
| 2246 | - // ----- Return |
|
| 2247 | - return $v_result; |
|
| 2248 | - } |
|
| 2230 | + // ----- Swap the file descriptor |
|
| 2231 | + // Here is a trick : I swap the temporary fd with the zip fd, in order to use |
|
| 2232 | + // the following methods on the temporary fil and not the real archive |
|
| 2233 | + $v_swap = $this->zip_fd; |
|
| 2234 | + $this->zip_fd = $v_zip_temp_fd; |
|
| 2235 | + $v_zip_temp_fd = $v_swap; |
|
| 2236 | + |
|
| 2237 | + // ----- Add the files |
|
| 2238 | + $v_header_list = array(); |
|
| 2239 | + if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) |
|
| 2240 | + { |
|
| 2241 | + fclose($v_zip_temp_fd); |
|
| 2242 | + $this->privCloseFd(); |
|
| 2243 | + @unlink($v_zip_temp_name); |
|
| 2244 | + $this->privSwapBackMagicQuotes(); |
|
| 2245 | + |
|
| 2246 | + // ----- Return |
|
| 2247 | + return $v_result; |
|
| 2248 | + } |
|
| 2249 | 2249 | |
| 2250 | - // ----- Store the offset of the central dir |
|
| 2251 | - $v_offset = @ftell($this->zip_fd); |
|
| 2252 | - |
|
| 2253 | - // ----- Copy the block of file headers from the old archive |
|
| 2254 | - $v_size = $v_central_dir['size']; |
|
| 2255 | - while ($v_size != 0) |
|
| 2256 | - { |
|
| 2257 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2258 | - $v_buffer = @fread($v_zip_temp_fd, $v_read_size); |
|
| 2259 | - @fwrite($this->zip_fd, $v_buffer, $v_read_size); |
|
| 2260 | - $v_size -= $v_read_size; |
|
| 2261 | - } |
|
| 2250 | + // ----- Store the offset of the central dir |
|
| 2251 | + $v_offset = @ftell($this->zip_fd); |
|
| 2252 | + |
|
| 2253 | + // ----- Copy the block of file headers from the old archive |
|
| 2254 | + $v_size = $v_central_dir['size']; |
|
| 2255 | + while ($v_size != 0) |
|
| 2256 | + { |
|
| 2257 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2258 | + $v_buffer = @fread($v_zip_temp_fd, $v_read_size); |
|
| 2259 | + @fwrite($this->zip_fd, $v_buffer, $v_read_size); |
|
| 2260 | + $v_size -= $v_read_size; |
|
| 2261 | + } |
|
| 2262 | 2262 | |
| 2263 | - // ----- Create the Central Dir files header |
|
| 2264 | - for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++) |
|
| 2265 | - { |
|
| 2266 | - // ----- Create the file header |
|
| 2267 | - if ($v_header_list[$i]['status'] == 'ok') { |
|
| 2268 | - if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) { |
|
| 2269 | - fclose($v_zip_temp_fd); |
|
| 2270 | - $this->privCloseFd(); |
|
| 2271 | - @unlink($v_zip_temp_name); |
|
| 2272 | - $this->privSwapBackMagicQuotes(); |
|
| 2273 | - |
|
| 2274 | - // ----- Return |
|
| 2275 | - return $v_result; |
|
| 2276 | - } |
|
| 2277 | - $v_count++; |
|
| 2278 | - } |
|
| 2263 | + // ----- Create the Central Dir files header |
|
| 2264 | + for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++) |
|
| 2265 | + { |
|
| 2266 | + // ----- Create the file header |
|
| 2267 | + if ($v_header_list[$i]['status'] == 'ok') { |
|
| 2268 | + if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) { |
|
| 2269 | + fclose($v_zip_temp_fd); |
|
| 2270 | + $this->privCloseFd(); |
|
| 2271 | + @unlink($v_zip_temp_name); |
|
| 2272 | + $this->privSwapBackMagicQuotes(); |
|
| 2273 | + |
|
| 2274 | + // ----- Return |
|
| 2275 | + return $v_result; |
|
| 2276 | + } |
|
| 2277 | + $v_count++; |
|
| 2278 | + } |
|
| 2279 | 2279 | |
| 2280 | - // ----- Transform the header to a 'usable' info |
|
| 2281 | - $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 2282 | - } |
|
| 2280 | + // ----- Transform the header to a 'usable' info |
|
| 2281 | + $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 2282 | + } |
|
| 2283 | 2283 | |
| 2284 | - // ----- Zip file comment |
|
| 2285 | - $v_comment = $v_central_dir['comment']; |
|
| 2286 | - if (isset($p_options[PCLZIP_OPT_COMMENT])) { |
|
| 2287 | - $v_comment = $p_options[PCLZIP_OPT_COMMENT]; |
|
| 2288 | - } |
|
| 2289 | - if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) { |
|
| 2290 | - $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT]; |
|
| 2291 | - } |
|
| 2292 | - if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) { |
|
| 2293 | - $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment; |
|
| 2294 | - } |
|
| 2284 | + // ----- Zip file comment |
|
| 2285 | + $v_comment = $v_central_dir['comment']; |
|
| 2286 | + if (isset($p_options[PCLZIP_OPT_COMMENT])) { |
|
| 2287 | + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; |
|
| 2288 | + } |
|
| 2289 | + if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) { |
|
| 2290 | + $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT]; |
|
| 2291 | + } |
|
| 2292 | + if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) { |
|
| 2293 | + $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment; |
|
| 2294 | + } |
|
| 2295 | 2295 | |
| 2296 | - // ----- Calculate the size of the central header |
|
| 2297 | - $v_size = @ftell($this->zip_fd)-$v_offset; |
|
| 2296 | + // ----- Calculate the size of the central header |
|
| 2297 | + $v_size = @ftell($this->zip_fd)-$v_offset; |
|
| 2298 | 2298 | |
| 2299 | - // ----- Create the central dir footer |
|
| 2300 | - if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 2301 | - { |
|
| 2302 | - // ----- Reset the file list |
|
| 2303 | - unset($v_header_list); |
|
| 2304 | - $this->privSwapBackMagicQuotes(); |
|
| 2299 | + // ----- Create the central dir footer |
|
| 2300 | + if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 2301 | + { |
|
| 2302 | + // ----- Reset the file list |
|
| 2303 | + unset($v_header_list); |
|
| 2304 | + $this->privSwapBackMagicQuotes(); |
|
| 2305 | 2305 | |
| 2306 | - // ----- Return |
|
| 2307 | - return $v_result; |
|
| 2308 | - } |
|
| 2306 | + // ----- Return |
|
| 2307 | + return $v_result; |
|
| 2308 | + } |
|
| 2309 | 2309 | |
| 2310 | - // ----- Swap back the file descriptor |
|
| 2311 | - $v_swap = $this->zip_fd; |
|
| 2312 | - $this->zip_fd = $v_zip_temp_fd; |
|
| 2313 | - $v_zip_temp_fd = $v_swap; |
|
| 2310 | + // ----- Swap back the file descriptor |
|
| 2311 | + $v_swap = $this->zip_fd; |
|
| 2312 | + $this->zip_fd = $v_zip_temp_fd; |
|
| 2313 | + $v_zip_temp_fd = $v_swap; |
|
| 2314 | 2314 | |
| 2315 | - // ----- Close |
|
| 2316 | - $this->privCloseFd(); |
|
| 2315 | + // ----- Close |
|
| 2316 | + $this->privCloseFd(); |
|
| 2317 | 2317 | |
| 2318 | - // ----- Close the temporary file |
|
| 2319 | - @fclose($v_zip_temp_fd); |
|
| 2318 | + // ----- Close the temporary file |
|
| 2319 | + @fclose($v_zip_temp_fd); |
|
| 2320 | 2320 | |
| 2321 | - // ----- Magic quotes trick |
|
| 2322 | - $this->privSwapBackMagicQuotes(); |
|
| 2321 | + // ----- Magic quotes trick |
|
| 2322 | + $this->privSwapBackMagicQuotes(); |
|
| 2323 | 2323 | |
| 2324 | - // ----- Delete the zip file |
|
| 2325 | - // TBC : I should test the result ... |
|
| 2326 | - @unlink($this->zipname); |
|
| 2324 | + // ----- Delete the zip file |
|
| 2325 | + // TBC : I should test the result ... |
|
| 2326 | + @unlink($this->zipname); |
|
| 2327 | 2327 | |
| 2328 | - // ----- Rename the temporary file |
|
| 2329 | - // TBC : I should test the result ... |
|
| 2330 | - //@rename($v_zip_temp_name, $this->zipname); |
|
| 2331 | - PclZipUtilRename($v_zip_temp_name, $this->zipname); |
|
| 2328 | + // ----- Rename the temporary file |
|
| 2329 | + // TBC : I should test the result ... |
|
| 2330 | + //@rename($v_zip_temp_name, $this->zipname); |
|
| 2331 | + PclZipUtilRename($v_zip_temp_name, $this->zipname); |
|
| 2332 | 2332 | |
| 2333 | - // ----- Return |
|
| 2334 | - return $v_result; |
|
| 2333 | + // ----- Return |
|
| 2334 | + return $v_result; |
|
| 2335 | 2335 | } |
| 2336 | 2336 | // -------------------------------------------------------------------------------- |
| 2337 | 2337 | |
@@ -2342,30 +2342,30 @@ discard block |
||
| 2342 | 2342 | // -------------------------------------------------------------------------------- |
| 2343 | 2343 | function privOpenFd($p_mode) |
| 2344 | 2344 | { |
| 2345 | - $v_result=1; |
|
| 2345 | + $v_result=1; |
|
| 2346 | 2346 | |
| 2347 | - // ----- Look if already open |
|
| 2348 | - if ($this->zip_fd != 0) |
|
| 2349 | - { |
|
| 2350 | - // ----- Error log |
|
| 2351 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open'); |
|
| 2347 | + // ----- Look if already open |
|
| 2348 | + if ($this->zip_fd != 0) |
|
| 2349 | + { |
|
| 2350 | + // ----- Error log |
|
| 2351 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open'); |
|
| 2352 | 2352 | |
| 2353 | - // ----- Return |
|
| 2354 | - return PclZip::errorCode(); |
|
| 2355 | - } |
|
| 2353 | + // ----- Return |
|
| 2354 | + return PclZip::errorCode(); |
|
| 2355 | + } |
|
| 2356 | 2356 | |
| 2357 | - // ----- Open the zip file |
|
| 2358 | - if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0) |
|
| 2359 | - { |
|
| 2360 | - // ----- Error log |
|
| 2361 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode'); |
|
| 2357 | + // ----- Open the zip file |
|
| 2358 | + if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0) |
|
| 2359 | + { |
|
| 2360 | + // ----- Error log |
|
| 2361 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode'); |
|
| 2362 | 2362 | |
| 2363 | - // ----- Return |
|
| 2364 | - return PclZip::errorCode(); |
|
| 2365 | - } |
|
| 2363 | + // ----- Return |
|
| 2364 | + return PclZip::errorCode(); |
|
| 2365 | + } |
|
| 2366 | 2366 | |
| 2367 | - // ----- Return |
|
| 2368 | - return $v_result; |
|
| 2367 | + // ----- Return |
|
| 2368 | + return $v_result; |
|
| 2369 | 2369 | } |
| 2370 | 2370 | // -------------------------------------------------------------------------------- |
| 2371 | 2371 | |
@@ -2376,14 +2376,14 @@ discard block |
||
| 2376 | 2376 | // -------------------------------------------------------------------------------- |
| 2377 | 2377 | function privCloseFd() |
| 2378 | 2378 | { |
| 2379 | - $v_result=1; |
|
| 2379 | + $v_result=1; |
|
| 2380 | 2380 | |
| 2381 | - if ($this->zip_fd != 0) |
|
| 2382 | - @fclose($this->zip_fd); |
|
| 2383 | - $this->zip_fd = 0; |
|
| 2381 | + if ($this->zip_fd != 0) |
|
| 2382 | + @fclose($this->zip_fd); |
|
| 2383 | + $this->zip_fd = 0; |
|
| 2384 | 2384 | |
| 2385 | - // ----- Return |
|
| 2386 | - return $v_result; |
|
| 2385 | + // ----- Return |
|
| 2386 | + return $v_result; |
|
| 2387 | 2387 | } |
| 2388 | 2388 | // -------------------------------------------------------------------------------- |
| 2389 | 2389 | |
@@ -2403,56 +2403,56 @@ discard block |
||
| 2403 | 2403 | // function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options) |
| 2404 | 2404 | function privAddList($p_filedescr_list, &$p_result_list, &$p_options) |
| 2405 | 2405 | { |
| 2406 | - $v_result=1; |
|
| 2407 | - |
|
| 2408 | - // ----- Add the files |
|
| 2409 | - $v_header_list = array(); |
|
| 2410 | - if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) |
|
| 2411 | - { |
|
| 2412 | - // ----- Return |
|
| 2413 | - return $v_result; |
|
| 2414 | - } |
|
| 2406 | + $v_result=1; |
|
| 2407 | + |
|
| 2408 | + // ----- Add the files |
|
| 2409 | + $v_header_list = array(); |
|
| 2410 | + if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) |
|
| 2411 | + { |
|
| 2412 | + // ----- Return |
|
| 2413 | + return $v_result; |
|
| 2414 | + } |
|
| 2415 | 2415 | |
| 2416 | - // ----- Store the offset of the central dir |
|
| 2417 | - $v_offset = @ftell($this->zip_fd); |
|
| 2418 | - |
|
| 2419 | - // ----- Create the Central Dir files header |
|
| 2420 | - for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++) |
|
| 2421 | - { |
|
| 2422 | - // ----- Create the file header |
|
| 2423 | - if ($v_header_list[$i]['status'] == 'ok') { |
|
| 2424 | - if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) { |
|
| 2425 | - // ----- Return |
|
| 2426 | - return $v_result; |
|
| 2427 | - } |
|
| 2428 | - $v_count++; |
|
| 2429 | - } |
|
| 2416 | + // ----- Store the offset of the central dir |
|
| 2417 | + $v_offset = @ftell($this->zip_fd); |
|
| 2418 | + |
|
| 2419 | + // ----- Create the Central Dir files header |
|
| 2420 | + for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++) |
|
| 2421 | + { |
|
| 2422 | + // ----- Create the file header |
|
| 2423 | + if ($v_header_list[$i]['status'] == 'ok') { |
|
| 2424 | + if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) { |
|
| 2425 | + // ----- Return |
|
| 2426 | + return $v_result; |
|
| 2427 | + } |
|
| 2428 | + $v_count++; |
|
| 2429 | + } |
|
| 2430 | 2430 | |
| 2431 | - // ----- Transform the header to a 'usable' info |
|
| 2432 | - $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 2433 | - } |
|
| 2431 | + // ----- Transform the header to a 'usable' info |
|
| 2432 | + $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 2433 | + } |
|
| 2434 | 2434 | |
| 2435 | - // ----- Zip file comment |
|
| 2436 | - $v_comment = ''; |
|
| 2437 | - if (isset($p_options[PCLZIP_OPT_COMMENT])) { |
|
| 2438 | - $v_comment = $p_options[PCLZIP_OPT_COMMENT]; |
|
| 2439 | - } |
|
| 2435 | + // ----- Zip file comment |
|
| 2436 | + $v_comment = ''; |
|
| 2437 | + if (isset($p_options[PCLZIP_OPT_COMMENT])) { |
|
| 2438 | + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; |
|
| 2439 | + } |
|
| 2440 | 2440 | |
| 2441 | - // ----- Calculate the size of the central header |
|
| 2442 | - $v_size = @ftell($this->zip_fd)-$v_offset; |
|
| 2441 | + // ----- Calculate the size of the central header |
|
| 2442 | + $v_size = @ftell($this->zip_fd)-$v_offset; |
|
| 2443 | 2443 | |
| 2444 | - // ----- Create the central dir footer |
|
| 2445 | - if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1) |
|
| 2446 | - { |
|
| 2447 | - // ----- Reset the file list |
|
| 2448 | - unset($v_header_list); |
|
| 2444 | + // ----- Create the central dir footer |
|
| 2445 | + if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1) |
|
| 2446 | + { |
|
| 2447 | + // ----- Reset the file list |
|
| 2448 | + unset($v_header_list); |
|
| 2449 | 2449 | |
| 2450 | - // ----- Return |
|
| 2451 | - return $v_result; |
|
| 2452 | - } |
|
| 2450 | + // ----- Return |
|
| 2451 | + return $v_result; |
|
| 2452 | + } |
|
| 2453 | 2453 | |
| 2454 | - // ----- Return |
|
| 2455 | - return $v_result; |
|
| 2454 | + // ----- Return |
|
| 2455 | + return $v_result; |
|
| 2456 | 2456 | } |
| 2457 | 2457 | // -------------------------------------------------------------------------------- |
| 2458 | 2458 | |
@@ -2467,57 +2467,57 @@ discard block |
||
| 2467 | 2467 | // -------------------------------------------------------------------------------- |
| 2468 | 2468 | function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options) |
| 2469 | 2469 | { |
| 2470 | - $v_result=1; |
|
| 2471 | - $v_header = array(); |
|
| 2470 | + $v_result=1; |
|
| 2471 | + $v_header = array(); |
|
| 2472 | 2472 | |
| 2473 | - // ----- Recuperate the current number of elt in list |
|
| 2474 | - $v_nb = sizeof($p_result_list); |
|
| 2473 | + // ----- Recuperate the current number of elt in list |
|
| 2474 | + $v_nb = sizeof($p_result_list); |
|
| 2475 | 2475 | |
| 2476 | - // ----- Loop on the files |
|
| 2477 | - for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) { |
|
| 2478 | - // ----- Format the filename |
|
| 2479 | - $p_filedescr_list[$j]['filename'] |
|
| 2480 | - = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false); |
|
| 2476 | + // ----- Loop on the files |
|
| 2477 | + for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) { |
|
| 2478 | + // ----- Format the filename |
|
| 2479 | + $p_filedescr_list[$j]['filename'] |
|
| 2480 | + = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false); |
|
| 2481 | 2481 | |
| 2482 | 2482 | |
| 2483 | - // ----- Skip empty file names |
|
| 2484 | - // TBC : Can this be possible ? not checked in DescrParseAtt ? |
|
| 2485 | - if ($p_filedescr_list[$j]['filename'] == "") { |
|
| 2486 | - continue; |
|
| 2487 | - } |
|
| 2483 | + // ----- Skip empty file names |
|
| 2484 | + // TBC : Can this be possible ? not checked in DescrParseAtt ? |
|
| 2485 | + if ($p_filedescr_list[$j]['filename'] == "") { |
|
| 2486 | + continue; |
|
| 2487 | + } |
|
| 2488 | 2488 | |
| 2489 | - // ----- Check the filename |
|
| 2490 | - if ( ($p_filedescr_list[$j]['type'] != 'virtual_file') |
|
| 2491 | - && (!file_exists($p_filedescr_list[$j]['filename']))) { |
|
| 2492 | - PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist"); |
|
| 2493 | - return PclZip::errorCode(); |
|
| 2494 | - } |
|
| 2489 | + // ----- Check the filename |
|
| 2490 | + if ( ($p_filedescr_list[$j]['type'] != 'virtual_file') |
|
| 2491 | + && (!file_exists($p_filedescr_list[$j]['filename']))) { |
|
| 2492 | + PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist"); |
|
| 2493 | + return PclZip::errorCode(); |
|
| 2494 | + } |
|
| 2495 | 2495 | |
| 2496 | - // ----- Look if it is a file or a dir with no all path remove option |
|
| 2497 | - // or a dir with all its path removed |
|
| 2496 | + // ----- Look if it is a file or a dir with no all path remove option |
|
| 2497 | + // or a dir with all its path removed |
|
| 2498 | 2498 | // if ( (is_file($p_filedescr_list[$j]['filename'])) |
| 2499 | 2499 | // || ( is_dir($p_filedescr_list[$j]['filename']) |
| 2500 | - if ( ($p_filedescr_list[$j]['type'] == 'file') |
|
| 2501 | - || ($p_filedescr_list[$j]['type'] == 'virtual_file') |
|
| 2502 | - || ( ($p_filedescr_list[$j]['type'] == 'folder') |
|
| 2503 | - && ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]) |
|
| 2504 | - || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) |
|
| 2505 | - ) { |
|
| 2506 | - |
|
| 2507 | - // ----- Add the file |
|
| 2508 | - $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header, |
|
| 2509 | - $p_options); |
|
| 2510 | - if ($v_result != 1) { |
|
| 2511 | - return $v_result; |
|
| 2512 | - } |
|
| 2513 | - |
|
| 2514 | - // ----- Store the file infos |
|
| 2515 | - $p_result_list[$v_nb++] = $v_header; |
|
| 2516 | - } |
|
| 2517 | - } |
|
| 2500 | + if ( ($p_filedescr_list[$j]['type'] == 'file') |
|
| 2501 | + || ($p_filedescr_list[$j]['type'] == 'virtual_file') |
|
| 2502 | + || ( ($p_filedescr_list[$j]['type'] == 'folder') |
|
| 2503 | + && ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]) |
|
| 2504 | + || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) |
|
| 2505 | + ) { |
|
| 2506 | + |
|
| 2507 | + // ----- Add the file |
|
| 2508 | + $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header, |
|
| 2509 | + $p_options); |
|
| 2510 | + if ($v_result != 1) { |
|
| 2511 | + return $v_result; |
|
| 2512 | + } |
|
| 2513 | + |
|
| 2514 | + // ----- Store the file infos |
|
| 2515 | + $p_result_list[$v_nb++] = $v_header; |
|
| 2516 | + } |
|
| 2517 | + } |
|
| 2518 | 2518 | |
| 2519 | - // ----- Return |
|
| 2520 | - return $v_result; |
|
| 2519 | + // ----- Return |
|
| 2520 | + return $v_result; |
|
| 2521 | 2521 | } |
| 2522 | 2522 | // -------------------------------------------------------------------------------- |
| 2523 | 2523 | |
@@ -2529,22 +2529,22 @@ discard block |
||
| 2529 | 2529 | // -------------------------------------------------------------------------------- |
| 2530 | 2530 | function privAddFile($p_filedescr, &$p_header, &$p_options) |
| 2531 | 2531 | { |
| 2532 | - $v_result=1; |
|
| 2532 | + $v_result=1; |
|
| 2533 | 2533 | |
| 2534 | - // ----- Working variable |
|
| 2535 | - $p_filename = $p_filedescr['filename']; |
|
| 2534 | + // ----- Working variable |
|
| 2535 | + $p_filename = $p_filedescr['filename']; |
|
| 2536 | 2536 | |
| 2537 | - // TBC : Already done in the fileAtt check ... ? |
|
| 2538 | - if ($p_filename == "") { |
|
| 2539 | - // ----- Error log |
|
| 2540 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)"); |
|
| 2537 | + // TBC : Already done in the fileAtt check ... ? |
|
| 2538 | + if ($p_filename == "") { |
|
| 2539 | + // ----- Error log |
|
| 2540 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)"); |
|
| 2541 | 2541 | |
| 2542 | - // ----- Return |
|
| 2543 | - return PclZip::errorCode(); |
|
| 2544 | - } |
|
| 2542 | + // ----- Return |
|
| 2543 | + return PclZip::errorCode(); |
|
| 2544 | + } |
|
| 2545 | 2545 | |
| 2546 | - // ----- Look for a stored different filename |
|
| 2547 | - /* TBC : Removed |
|
| 2546 | + // ----- Look for a stored different filename |
|
| 2547 | + /* TBC : Removed |
|
| 2548 | 2548 | if (isset($p_filedescr['stored_filename'])) { |
| 2549 | 2549 | $v_stored_filename = $p_filedescr['stored_filename']; |
| 2550 | 2550 | } |
@@ -2553,242 +2553,242 @@ discard block |
||
| 2553 | 2553 | } |
| 2554 | 2554 | */ |
| 2555 | 2555 | |
| 2556 | - // ----- Set the file properties |
|
| 2557 | - clearstatcache(); |
|
| 2558 | - $p_header['version'] = 20; |
|
| 2559 | - $p_header['version_extracted'] = 10; |
|
| 2560 | - $p_header['flag'] = 0; |
|
| 2561 | - $p_header['compression'] = 0; |
|
| 2562 | - $p_header['crc'] = 0; |
|
| 2563 | - $p_header['compressed_size'] = 0; |
|
| 2564 | - $p_header['filename_len'] = strlen($p_filename); |
|
| 2565 | - $p_header['extra_len'] = 0; |
|
| 2566 | - $p_header['disk'] = 0; |
|
| 2567 | - $p_header['internal'] = 0; |
|
| 2568 | - $p_header['offset'] = 0; |
|
| 2569 | - $p_header['filename'] = $p_filename; |
|
| 2556 | + // ----- Set the file properties |
|
| 2557 | + clearstatcache(); |
|
| 2558 | + $p_header['version'] = 20; |
|
| 2559 | + $p_header['version_extracted'] = 10; |
|
| 2560 | + $p_header['flag'] = 0; |
|
| 2561 | + $p_header['compression'] = 0; |
|
| 2562 | + $p_header['crc'] = 0; |
|
| 2563 | + $p_header['compressed_size'] = 0; |
|
| 2564 | + $p_header['filename_len'] = strlen($p_filename); |
|
| 2565 | + $p_header['extra_len'] = 0; |
|
| 2566 | + $p_header['disk'] = 0; |
|
| 2567 | + $p_header['internal'] = 0; |
|
| 2568 | + $p_header['offset'] = 0; |
|
| 2569 | + $p_header['filename'] = $p_filename; |
|
| 2570 | 2570 | // TBC : Removed $p_header['stored_filename'] = $v_stored_filename; |
| 2571 | - $p_header['stored_filename'] = $p_filedescr['stored_filename']; |
|
| 2572 | - $p_header['extra'] = ''; |
|
| 2573 | - $p_header['status'] = 'ok'; |
|
| 2574 | - $p_header['index'] = -1; |
|
| 2575 | - |
|
| 2576 | - // ----- Look for regular file |
|
| 2577 | - if ($p_filedescr['type']=='file') { |
|
| 2578 | - $p_header['external'] = 0x00000000; |
|
| 2579 | - $p_header['size'] = filesize($p_filename); |
|
| 2580 | - } |
|
| 2571 | + $p_header['stored_filename'] = $p_filedescr['stored_filename']; |
|
| 2572 | + $p_header['extra'] = ''; |
|
| 2573 | + $p_header['status'] = 'ok'; |
|
| 2574 | + $p_header['index'] = -1; |
|
| 2575 | + |
|
| 2576 | + // ----- Look for regular file |
|
| 2577 | + if ($p_filedescr['type']=='file') { |
|
| 2578 | + $p_header['external'] = 0x00000000; |
|
| 2579 | + $p_header['size'] = filesize($p_filename); |
|
| 2580 | + } |
|
| 2581 | 2581 | |
| 2582 | - // ----- Look for regular folder |
|
| 2583 | - else if ($p_filedescr['type']=='folder') { |
|
| 2584 | - $p_header['external'] = 0x00000010; |
|
| 2585 | - $p_header['mtime'] = filemtime($p_filename); |
|
| 2586 | - $p_header['size'] = filesize($p_filename); |
|
| 2587 | - } |
|
| 2582 | + // ----- Look for regular folder |
|
| 2583 | + else if ($p_filedescr['type']=='folder') { |
|
| 2584 | + $p_header['external'] = 0x00000010; |
|
| 2585 | + $p_header['mtime'] = filemtime($p_filename); |
|
| 2586 | + $p_header['size'] = filesize($p_filename); |
|
| 2587 | + } |
|
| 2588 | 2588 | |
| 2589 | - // ----- Look for virtual file |
|
| 2590 | - else if ($p_filedescr['type'] == 'virtual_file') { |
|
| 2591 | - $p_header['external'] = 0x00000000; |
|
| 2592 | - $p_header['size'] = strlen($p_filedescr['content']); |
|
| 2593 | - } |
|
| 2589 | + // ----- Look for virtual file |
|
| 2590 | + else if ($p_filedescr['type'] == 'virtual_file') { |
|
| 2591 | + $p_header['external'] = 0x00000000; |
|
| 2592 | + $p_header['size'] = strlen($p_filedescr['content']); |
|
| 2593 | + } |
|
| 2594 | 2594 | |
| 2595 | 2595 | |
| 2596 | - // ----- Look for filetime |
|
| 2597 | - if (isset($p_filedescr['mtime'])) { |
|
| 2598 | - $p_header['mtime'] = $p_filedescr['mtime']; |
|
| 2599 | - } |
|
| 2600 | - else if ($p_filedescr['type'] == 'virtual_file') { |
|
| 2601 | - $p_header['mtime'] = time(); |
|
| 2602 | - } |
|
| 2603 | - else { |
|
| 2604 | - $p_header['mtime'] = filemtime($p_filename); |
|
| 2605 | - } |
|
| 2596 | + // ----- Look for filetime |
|
| 2597 | + if (isset($p_filedescr['mtime'])) { |
|
| 2598 | + $p_header['mtime'] = $p_filedescr['mtime']; |
|
| 2599 | + } |
|
| 2600 | + else if ($p_filedescr['type'] == 'virtual_file') { |
|
| 2601 | + $p_header['mtime'] = time(); |
|
| 2602 | + } |
|
| 2603 | + else { |
|
| 2604 | + $p_header['mtime'] = filemtime($p_filename); |
|
| 2605 | + } |
|
| 2606 | 2606 | |
| 2607 | - // ------ Look for file comment |
|
| 2608 | - if (isset($p_filedescr['comment'])) { |
|
| 2609 | - $p_header['comment_len'] = strlen($p_filedescr['comment']); |
|
| 2610 | - $p_header['comment'] = $p_filedescr['comment']; |
|
| 2611 | - } |
|
| 2612 | - else { |
|
| 2613 | - $p_header['comment_len'] = 0; |
|
| 2614 | - $p_header['comment'] = ''; |
|
| 2615 | - } |
|
| 2607 | + // ------ Look for file comment |
|
| 2608 | + if (isset($p_filedescr['comment'])) { |
|
| 2609 | + $p_header['comment_len'] = strlen($p_filedescr['comment']); |
|
| 2610 | + $p_header['comment'] = $p_filedescr['comment']; |
|
| 2611 | + } |
|
| 2612 | + else { |
|
| 2613 | + $p_header['comment_len'] = 0; |
|
| 2614 | + $p_header['comment'] = ''; |
|
| 2615 | + } |
|
| 2616 | 2616 | |
| 2617 | - // ----- Look for pre-add callback |
|
| 2618 | - if (isset($p_options[PCLZIP_CB_PRE_ADD])) { |
|
| 2619 | - |
|
| 2620 | - // ----- Generate a local information |
|
| 2621 | - $v_local_header = array(); |
|
| 2622 | - $this->privConvertHeader2FileInfo($p_header, $v_local_header); |
|
| 2623 | - |
|
| 2624 | - // ----- Call the callback |
|
| 2625 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 2626 | - // header. |
|
| 2627 | - $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header); |
|
| 2628 | - if ($v_result == 0) { |
|
| 2629 | - // ----- Change the file status |
|
| 2630 | - $p_header['status'] = "skipped"; |
|
| 2631 | - $v_result = 1; |
|
| 2632 | - } |
|
| 2617 | + // ----- Look for pre-add callback |
|
| 2618 | + if (isset($p_options[PCLZIP_CB_PRE_ADD])) { |
|
| 2619 | + |
|
| 2620 | + // ----- Generate a local information |
|
| 2621 | + $v_local_header = array(); |
|
| 2622 | + $this->privConvertHeader2FileInfo($p_header, $v_local_header); |
|
| 2623 | + |
|
| 2624 | + // ----- Call the callback |
|
| 2625 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 2626 | + // header. |
|
| 2627 | + $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header); |
|
| 2628 | + if ($v_result == 0) { |
|
| 2629 | + // ----- Change the file status |
|
| 2630 | + $p_header['status'] = "skipped"; |
|
| 2631 | + $v_result = 1; |
|
| 2632 | + } |
|
| 2633 | 2633 | |
| 2634 | - // ----- Update the informations |
|
| 2635 | - // Only some fields can be modified |
|
| 2636 | - if ($p_header['stored_filename'] != $v_local_header['stored_filename']) { |
|
| 2637 | - $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']); |
|
| 2638 | - } |
|
| 2639 | - } |
|
| 2634 | + // ----- Update the informations |
|
| 2635 | + // Only some fields can be modified |
|
| 2636 | + if ($p_header['stored_filename'] != $v_local_header['stored_filename']) { |
|
| 2637 | + $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']); |
|
| 2638 | + } |
|
| 2639 | + } |
|
| 2640 | 2640 | |
| 2641 | - // ----- Look for empty stored filename |
|
| 2642 | - if ($p_header['stored_filename'] == "") { |
|
| 2643 | - $p_header['status'] = "filtered"; |
|
| 2644 | - } |
|
| 2641 | + // ----- Look for empty stored filename |
|
| 2642 | + if ($p_header['stored_filename'] == "") { |
|
| 2643 | + $p_header['status'] = "filtered"; |
|
| 2644 | + } |
|
| 2645 | 2645 | |
| 2646 | - // ----- Check the path length |
|
| 2647 | - if (strlen($p_header['stored_filename']) > 0xFF) { |
|
| 2648 | - $p_header['status'] = 'filename_too_long'; |
|
| 2649 | - } |
|
| 2646 | + // ----- Check the path length |
|
| 2647 | + if (strlen($p_header['stored_filename']) > 0xFF) { |
|
| 2648 | + $p_header['status'] = 'filename_too_long'; |
|
| 2649 | + } |
|
| 2650 | 2650 | |
| 2651 | - // ----- Look if no error, or file not skipped |
|
| 2652 | - if ($p_header['status'] == 'ok') { |
|
| 2653 | - |
|
| 2654 | - // ----- Look for a file |
|
| 2655 | - if ($p_filedescr['type'] == 'file') { |
|
| 2656 | - // ----- Look for using temporary file to zip |
|
| 2657 | - if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 2658 | - && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) |
|
| 2659 | - || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
|
| 2660 | - && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) { |
|
| 2661 | - $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options); |
|
| 2662 | - if ($v_result < PCLZIP_ERR_NO_ERROR) { |
|
| 2663 | - return $v_result; |
|
| 2664 | - } |
|
| 2665 | - } |
|
| 2651 | + // ----- Look if no error, or file not skipped |
|
| 2652 | + if ($p_header['status'] == 'ok') { |
|
| 2653 | + |
|
| 2654 | + // ----- Look for a file |
|
| 2655 | + if ($p_filedescr['type'] == 'file') { |
|
| 2656 | + // ----- Look for using temporary file to zip |
|
| 2657 | + if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 2658 | + && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) |
|
| 2659 | + || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
|
| 2660 | + && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) { |
|
| 2661 | + $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options); |
|
| 2662 | + if ($v_result < PCLZIP_ERR_NO_ERROR) { |
|
| 2663 | + return $v_result; |
|
| 2664 | + } |
|
| 2665 | + } |
|
| 2666 | 2666 | |
| 2667 | - // ----- Use "in memory" zip algo |
|
| 2668 | - else { |
|
| 2667 | + // ----- Use "in memory" zip algo |
|
| 2668 | + else { |
|
| 2669 | 2669 | |
| 2670 | - // ----- Open the source file |
|
| 2671 | - if (($v_file = @fopen($p_filename, "rb")) == 0) { |
|
| 2672 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); |
|
| 2673 | - return PclZip::errorCode(); |
|
| 2674 | - } |
|
| 2670 | + // ----- Open the source file |
|
| 2671 | + if (($v_file = @fopen($p_filename, "rb")) == 0) { |
|
| 2672 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); |
|
| 2673 | + return PclZip::errorCode(); |
|
| 2674 | + } |
|
| 2675 | 2675 | |
| 2676 | - // ----- Read the file content |
|
| 2677 | - $v_content = @fread($v_file, $p_header['size']); |
|
| 2676 | + // ----- Read the file content |
|
| 2677 | + $v_content = @fread($v_file, $p_header['size']); |
|
| 2678 | 2678 | |
| 2679 | - // ----- Close the file |
|
| 2680 | - @fclose($v_file); |
|
| 2679 | + // ----- Close the file |
|
| 2680 | + @fclose($v_file); |
|
| 2681 | 2681 | |
| 2682 | - // ----- Calculate the CRC |
|
| 2683 | - $p_header['crc'] = @crc32($v_content); |
|
| 2682 | + // ----- Calculate the CRC |
|
| 2683 | + $p_header['crc'] = @crc32($v_content); |
|
| 2684 | 2684 | |
| 2685 | - // ----- Look for no compression |
|
| 2686 | - if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { |
|
| 2687 | - // ----- Set header parameters |
|
| 2688 | - $p_header['compressed_size'] = $p_header['size']; |
|
| 2689 | - $p_header['compression'] = 0; |
|
| 2690 | - } |
|
| 2685 | + // ----- Look for no compression |
|
| 2686 | + if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { |
|
| 2687 | + // ----- Set header parameters |
|
| 2688 | + $p_header['compressed_size'] = $p_header['size']; |
|
| 2689 | + $p_header['compression'] = 0; |
|
| 2690 | + } |
|
| 2691 | 2691 | |
| 2692 | - // ----- Look for normal compression |
|
| 2693 | - else { |
|
| 2694 | - // ----- Compress the content |
|
| 2695 | - $v_content = @gzdeflate($v_content); |
|
| 2692 | + // ----- Look for normal compression |
|
| 2693 | + else { |
|
| 2694 | + // ----- Compress the content |
|
| 2695 | + $v_content = @gzdeflate($v_content); |
|
| 2696 | 2696 | |
| 2697 | - // ----- Set header parameters |
|
| 2698 | - $p_header['compressed_size'] = strlen($v_content); |
|
| 2699 | - $p_header['compression'] = 8; |
|
| 2700 | - } |
|
| 2697 | + // ----- Set header parameters |
|
| 2698 | + $p_header['compressed_size'] = strlen($v_content); |
|
| 2699 | + $p_header['compression'] = 8; |
|
| 2700 | + } |
|
| 2701 | 2701 | |
| 2702 | - // ----- Call the header generation |
|
| 2703 | - if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { |
|
| 2704 | - @fclose($v_file); |
|
| 2705 | - return $v_result; |
|
| 2706 | - } |
|
| 2702 | + // ----- Call the header generation |
|
| 2703 | + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { |
|
| 2704 | + @fclose($v_file); |
|
| 2705 | + return $v_result; |
|
| 2706 | + } |
|
| 2707 | 2707 | |
| 2708 | - // ----- Write the compressed (or not) content |
|
| 2709 | - @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']); |
|
| 2708 | + // ----- Write the compressed (or not) content |
|
| 2709 | + @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']); |
|
| 2710 | 2710 | |
| 2711 | - } |
|
| 2711 | + } |
|
| 2712 | 2712 | |
| 2713 | - } |
|
| 2713 | + } |
|
| 2714 | 2714 | |
| 2715 | - // ----- Look for a virtual file (a file from string) |
|
| 2716 | - else if ($p_filedescr['type'] == 'virtual_file') { |
|
| 2715 | + // ----- Look for a virtual file (a file from string) |
|
| 2716 | + else if ($p_filedescr['type'] == 'virtual_file') { |
|
| 2717 | 2717 | |
| 2718 | - $v_content = $p_filedescr['content']; |
|
| 2718 | + $v_content = $p_filedescr['content']; |
|
| 2719 | 2719 | |
| 2720 | - // ----- Calculate the CRC |
|
| 2721 | - $p_header['crc'] = @crc32($v_content); |
|
| 2720 | + // ----- Calculate the CRC |
|
| 2721 | + $p_header['crc'] = @crc32($v_content); |
|
| 2722 | 2722 | |
| 2723 | - // ----- Look for no compression |
|
| 2724 | - if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { |
|
| 2725 | - // ----- Set header parameters |
|
| 2726 | - $p_header['compressed_size'] = $p_header['size']; |
|
| 2727 | - $p_header['compression'] = 0; |
|
| 2728 | - } |
|
| 2723 | + // ----- Look for no compression |
|
| 2724 | + if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { |
|
| 2725 | + // ----- Set header parameters |
|
| 2726 | + $p_header['compressed_size'] = $p_header['size']; |
|
| 2727 | + $p_header['compression'] = 0; |
|
| 2728 | + } |
|
| 2729 | 2729 | |
| 2730 | - // ----- Look for normal compression |
|
| 2731 | - else { |
|
| 2732 | - // ----- Compress the content |
|
| 2733 | - $v_content = @gzdeflate($v_content); |
|
| 2730 | + // ----- Look for normal compression |
|
| 2731 | + else { |
|
| 2732 | + // ----- Compress the content |
|
| 2733 | + $v_content = @gzdeflate($v_content); |
|
| 2734 | 2734 | |
| 2735 | - // ----- Set header parameters |
|
| 2736 | - $p_header['compressed_size'] = strlen($v_content); |
|
| 2737 | - $p_header['compression'] = 8; |
|
| 2738 | - } |
|
| 2735 | + // ----- Set header parameters |
|
| 2736 | + $p_header['compressed_size'] = strlen($v_content); |
|
| 2737 | + $p_header['compression'] = 8; |
|
| 2738 | + } |
|
| 2739 | 2739 | |
| 2740 | - // ----- Call the header generation |
|
| 2741 | - if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { |
|
| 2742 | - @fclose($v_file); |
|
| 2743 | - return $v_result; |
|
| 2744 | - } |
|
| 2740 | + // ----- Call the header generation |
|
| 2741 | + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { |
|
| 2742 | + @fclose($v_file); |
|
| 2743 | + return $v_result; |
|
| 2744 | + } |
|
| 2745 | 2745 | |
| 2746 | - // ----- Write the compressed (or not) content |
|
| 2747 | - @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']); |
|
| 2748 | - } |
|
| 2746 | + // ----- Write the compressed (or not) content |
|
| 2747 | + @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']); |
|
| 2748 | + } |
|
| 2749 | 2749 | |
| 2750 | - // ----- Look for a directory |
|
| 2751 | - else if ($p_filedescr['type'] == 'folder') { |
|
| 2752 | - // ----- Look for directory last '/' |
|
| 2753 | - if (@substr($p_header['stored_filename'], -1) != '/') { |
|
| 2754 | - $p_header['stored_filename'] .= '/'; |
|
| 2755 | - } |
|
| 2756 | - |
|
| 2757 | - // ----- Set the file properties |
|
| 2758 | - $p_header['size'] = 0; |
|
| 2759 | - //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked |
|
| 2760 | - $p_header['external'] = 0x00000010; // Value for a folder : to be checked |
|
| 2761 | - |
|
| 2762 | - // ----- Call the header generation |
|
| 2763 | - if (($v_result = $this->privWriteFileHeader($p_header)) != 1) |
|
| 2764 | - { |
|
| 2765 | - return $v_result; |
|
| 2766 | - } |
|
| 2767 | - } |
|
| 2768 | - } |
|
| 2750 | + // ----- Look for a directory |
|
| 2751 | + else if ($p_filedescr['type'] == 'folder') { |
|
| 2752 | + // ----- Look for directory last '/' |
|
| 2753 | + if (@substr($p_header['stored_filename'], -1) != '/') { |
|
| 2754 | + $p_header['stored_filename'] .= '/'; |
|
| 2755 | + } |
|
| 2756 | + |
|
| 2757 | + // ----- Set the file properties |
|
| 2758 | + $p_header['size'] = 0; |
|
| 2759 | + //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked |
|
| 2760 | + $p_header['external'] = 0x00000010; // Value for a folder : to be checked |
|
| 2761 | + |
|
| 2762 | + // ----- Call the header generation |
|
| 2763 | + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) |
|
| 2764 | + { |
|
| 2765 | + return $v_result; |
|
| 2766 | + } |
|
| 2767 | + } |
|
| 2768 | + } |
|
| 2769 | 2769 | |
| 2770 | - // ----- Look for post-add callback |
|
| 2771 | - if (isset($p_options[PCLZIP_CB_POST_ADD])) { |
|
| 2770 | + // ----- Look for post-add callback |
|
| 2771 | + if (isset($p_options[PCLZIP_CB_POST_ADD])) { |
|
| 2772 | 2772 | |
| 2773 | - // ----- Generate a local information |
|
| 2774 | - $v_local_header = array(); |
|
| 2775 | - $this->privConvertHeader2FileInfo($p_header, $v_local_header); |
|
| 2773 | + // ----- Generate a local information |
|
| 2774 | + $v_local_header = array(); |
|
| 2775 | + $this->privConvertHeader2FileInfo($p_header, $v_local_header); |
|
| 2776 | 2776 | |
| 2777 | - // ----- Call the callback |
|
| 2778 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 2779 | - // header. |
|
| 2780 | - $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header); |
|
| 2781 | - if ($v_result == 0) { |
|
| 2782 | - // ----- Ignored |
|
| 2783 | - $v_result = 1; |
|
| 2784 | - } |
|
| 2777 | + // ----- Call the callback |
|
| 2778 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 2779 | + // header. |
|
| 2780 | + $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header); |
|
| 2781 | + if ($v_result == 0) { |
|
| 2782 | + // ----- Ignored |
|
| 2783 | + $v_result = 1; |
|
| 2784 | + } |
|
| 2785 | 2785 | |
| 2786 | - // ----- Update the informations |
|
| 2787 | - // Nothing can be modified |
|
| 2788 | - } |
|
| 2786 | + // ----- Update the informations |
|
| 2787 | + // Nothing can be modified |
|
| 2788 | + } |
|
| 2789 | 2789 | |
| 2790 | - // ----- Return |
|
| 2791 | - return $v_result; |
|
| 2790 | + // ----- Return |
|
| 2791 | + return $v_result; |
|
| 2792 | 2792 | } |
| 2793 | 2793 | // -------------------------------------------------------------------------------- |
| 2794 | 2794 | |
@@ -2800,105 +2800,105 @@ discard block |
||
| 2800 | 2800 | // -------------------------------------------------------------------------------- |
| 2801 | 2801 | function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options) |
| 2802 | 2802 | { |
| 2803 | - $v_result=PCLZIP_ERR_NO_ERROR; |
|
| 2803 | + $v_result=PCLZIP_ERR_NO_ERROR; |
|
| 2804 | 2804 | |
| 2805 | - // ----- Working variable |
|
| 2806 | - $p_filename = $p_filedescr['filename']; |
|
| 2805 | + // ----- Working variable |
|
| 2806 | + $p_filename = $p_filedescr['filename']; |
|
| 2807 | 2807 | |
| 2808 | 2808 | |
| 2809 | - // ----- Open the source file |
|
| 2810 | - if (($v_file = @fopen($p_filename, "rb")) == 0) { |
|
| 2811 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); |
|
| 2812 | - return PclZip::errorCode(); |
|
| 2813 | - } |
|
| 2809 | + // ----- Open the source file |
|
| 2810 | + if (($v_file = @fopen($p_filename, "rb")) == 0) { |
|
| 2811 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); |
|
| 2812 | + return PclZip::errorCode(); |
|
| 2813 | + } |
|
| 2814 | 2814 | |
| 2815 | - // ----- Creates a compressed temporary file |
|
| 2816 | - $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz'; |
|
| 2817 | - if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) { |
|
| 2818 | - fclose($v_file); |
|
| 2819 | - PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode'); |
|
| 2820 | - return PclZip::errorCode(); |
|
| 2821 | - } |
|
| 2815 | + // ----- Creates a compressed temporary file |
|
| 2816 | + $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz'; |
|
| 2817 | + if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) { |
|
| 2818 | + fclose($v_file); |
|
| 2819 | + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode'); |
|
| 2820 | + return PclZip::errorCode(); |
|
| 2821 | + } |
|
| 2822 | 2822 | |
| 2823 | - // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 2824 | - $v_size = filesize($p_filename); |
|
| 2825 | - while ($v_size != 0) { |
|
| 2826 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2827 | - $v_buffer = @fread($v_file, $v_read_size); |
|
| 2828 | - //$v_binary_data = pack('a'.$v_read_size, $v_buffer); |
|
| 2829 | - @gzputs($v_file_compressed, $v_buffer, $v_read_size); |
|
| 2830 | - $v_size -= $v_read_size; |
|
| 2831 | - } |
|
| 2823 | + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 2824 | + $v_size = filesize($p_filename); |
|
| 2825 | + while ($v_size != 0) { |
|
| 2826 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2827 | + $v_buffer = @fread($v_file, $v_read_size); |
|
| 2828 | + //$v_binary_data = pack('a'.$v_read_size, $v_buffer); |
|
| 2829 | + @gzputs($v_file_compressed, $v_buffer, $v_read_size); |
|
| 2830 | + $v_size -= $v_read_size; |
|
| 2831 | + } |
|
| 2832 | 2832 | |
| 2833 | - // ----- Close the file |
|
| 2834 | - @fclose($v_file); |
|
| 2835 | - @gzclose($v_file_compressed); |
|
| 2833 | + // ----- Close the file |
|
| 2834 | + @fclose($v_file); |
|
| 2835 | + @gzclose($v_file_compressed); |
|
| 2836 | 2836 | |
| 2837 | - // ----- Check the minimum file size |
|
| 2838 | - if (filesize($v_gzip_temp_name) < 18) { |
|
| 2839 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes'); |
|
| 2840 | - return PclZip::errorCode(); |
|
| 2841 | - } |
|
| 2837 | + // ----- Check the minimum file size |
|
| 2838 | + if (filesize($v_gzip_temp_name) < 18) { |
|
| 2839 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes'); |
|
| 2840 | + return PclZip::errorCode(); |
|
| 2841 | + } |
|
| 2842 | 2842 | |
| 2843 | - // ----- Extract the compressed attributes |
|
| 2844 | - if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) { |
|
| 2845 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 2846 | - return PclZip::errorCode(); |
|
| 2847 | - } |
|
| 2843 | + // ----- Extract the compressed attributes |
|
| 2844 | + if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) { |
|
| 2845 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 2846 | + return PclZip::errorCode(); |
|
| 2847 | + } |
|
| 2848 | 2848 | |
| 2849 | - // ----- Read the gzip file header |
|
| 2850 | - $v_binary_data = @fread($v_file_compressed, 10); |
|
| 2851 | - $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data); |
|
| 2849 | + // ----- Read the gzip file header |
|
| 2850 | + $v_binary_data = @fread($v_file_compressed, 10); |
|
| 2851 | + $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data); |
|
| 2852 | 2852 | |
| 2853 | - // ----- Check some parameters |
|
| 2854 | - $v_data_header['os'] = bin2hex($v_data_header['os']); |
|
| 2853 | + // ----- Check some parameters |
|
| 2854 | + $v_data_header['os'] = bin2hex($v_data_header['os']); |
|
| 2855 | 2855 | |
| 2856 | - // ----- Read the gzip file footer |
|
| 2857 | - @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8); |
|
| 2858 | - $v_binary_data = @fread($v_file_compressed, 8); |
|
| 2859 | - $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data); |
|
| 2856 | + // ----- Read the gzip file footer |
|
| 2857 | + @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8); |
|
| 2858 | + $v_binary_data = @fread($v_file_compressed, 8); |
|
| 2859 | + $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data); |
|
| 2860 | 2860 | |
| 2861 | - // ----- Set the attributes |
|
| 2862 | - $p_header['compression'] = ord($v_data_header['cm']); |
|
| 2863 | - //$p_header['mtime'] = $v_data_header['mtime']; |
|
| 2864 | - $p_header['crc'] = $v_data_footer['crc']; |
|
| 2865 | - $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18; |
|
| 2861 | + // ----- Set the attributes |
|
| 2862 | + $p_header['compression'] = ord($v_data_header['cm']); |
|
| 2863 | + //$p_header['mtime'] = $v_data_header['mtime']; |
|
| 2864 | + $p_header['crc'] = $v_data_footer['crc']; |
|
| 2865 | + $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18; |
|
| 2866 | 2866 | |
| 2867 | - // ----- Close the file |
|
| 2868 | - @fclose($v_file_compressed); |
|
| 2867 | + // ----- Close the file |
|
| 2868 | + @fclose($v_file_compressed); |
|
| 2869 | 2869 | |
| 2870 | - // ----- Call the header generation |
|
| 2871 | - if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { |
|
| 2872 | - return $v_result; |
|
| 2873 | - } |
|
| 2870 | + // ----- Call the header generation |
|
| 2871 | + if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { |
|
| 2872 | + return $v_result; |
|
| 2873 | + } |
|
| 2874 | 2874 | |
| 2875 | - // ----- Add the compressed data |
|
| 2876 | - if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) |
|
| 2877 | - { |
|
| 2878 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 2879 | - return PclZip::errorCode(); |
|
| 2880 | - } |
|
| 2875 | + // ----- Add the compressed data |
|
| 2876 | + if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) |
|
| 2877 | + { |
|
| 2878 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 2879 | + return PclZip::errorCode(); |
|
| 2880 | + } |
|
| 2881 | 2881 | |
| 2882 | - // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 2883 | - fseek($v_file_compressed, 10); |
|
| 2884 | - $v_size = $p_header['compressed_size']; |
|
| 2885 | - while ($v_size != 0) |
|
| 2886 | - { |
|
| 2887 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2888 | - $v_buffer = @fread($v_file_compressed, $v_read_size); |
|
| 2889 | - //$v_binary_data = pack('a'.$v_read_size, $v_buffer); |
|
| 2890 | - @fwrite($this->zip_fd, $v_buffer, $v_read_size); |
|
| 2891 | - $v_size -= $v_read_size; |
|
| 2892 | - } |
|
| 2882 | + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 2883 | + fseek($v_file_compressed, 10); |
|
| 2884 | + $v_size = $p_header['compressed_size']; |
|
| 2885 | + while ($v_size != 0) |
|
| 2886 | + { |
|
| 2887 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 2888 | + $v_buffer = @fread($v_file_compressed, $v_read_size); |
|
| 2889 | + //$v_binary_data = pack('a'.$v_read_size, $v_buffer); |
|
| 2890 | + @fwrite($this->zip_fd, $v_buffer, $v_read_size); |
|
| 2891 | + $v_size -= $v_read_size; |
|
| 2892 | + } |
|
| 2893 | 2893 | |
| 2894 | - // ----- Close the file |
|
| 2895 | - @fclose($v_file_compressed); |
|
| 2894 | + // ----- Close the file |
|
| 2895 | + @fclose($v_file_compressed); |
|
| 2896 | 2896 | |
| 2897 | - // ----- Unlink the temporary file |
|
| 2898 | - @unlink($v_gzip_temp_name); |
|
| 2897 | + // ----- Unlink the temporary file |
|
| 2898 | + @unlink($v_gzip_temp_name); |
|
| 2899 | 2899 | |
| 2900 | - // ----- Return |
|
| 2901 | - return $v_result; |
|
| 2900 | + // ----- Return |
|
| 2901 | + return $v_result; |
|
| 2902 | 2902 | } |
| 2903 | 2903 | // -------------------------------------------------------------------------------- |
| 2904 | 2904 | |
@@ -2912,107 +2912,107 @@ discard block |
||
| 2912 | 2912 | // -------------------------------------------------------------------------------- |
| 2913 | 2913 | function privCalculateStoredFilename(&$p_filedescr, &$p_options) |
| 2914 | 2914 | { |
| 2915 | - $v_result=1; |
|
| 2916 | - |
|
| 2917 | - // ----- Working variables |
|
| 2918 | - $p_filename = $p_filedescr['filename']; |
|
| 2919 | - if (isset($p_options[PCLZIP_OPT_ADD_PATH])) { |
|
| 2920 | - $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH]; |
|
| 2921 | - } |
|
| 2922 | - else { |
|
| 2923 | - $p_add_dir = ''; |
|
| 2924 | - } |
|
| 2925 | - if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) { |
|
| 2926 | - $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH]; |
|
| 2927 | - } |
|
| 2928 | - else { |
|
| 2929 | - $p_remove_dir = ''; |
|
| 2930 | - } |
|
| 2931 | - if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { |
|
| 2932 | - $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
|
| 2933 | - } |
|
| 2934 | - else { |
|
| 2935 | - $p_remove_all_dir = 0; |
|
| 2936 | - } |
|
| 2915 | + $v_result=1; |
|
| 2937 | 2916 | |
| 2917 | + // ----- Working variables |
|
| 2918 | + $p_filename = $p_filedescr['filename']; |
|
| 2919 | + if (isset($p_options[PCLZIP_OPT_ADD_PATH])) { |
|
| 2920 | + $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH]; |
|
| 2921 | + } |
|
| 2922 | + else { |
|
| 2923 | + $p_add_dir = ''; |
|
| 2924 | + } |
|
| 2925 | + if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) { |
|
| 2926 | + $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH]; |
|
| 2927 | + } |
|
| 2928 | + else { |
|
| 2929 | + $p_remove_dir = ''; |
|
| 2930 | + } |
|
| 2931 | + if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { |
|
| 2932 | + $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
|
| 2933 | + } |
|
| 2934 | + else { |
|
| 2935 | + $p_remove_all_dir = 0; |
|
| 2936 | + } |
|
| 2938 | 2937 | |
| 2939 | - // ----- Look for full name change |
|
| 2940 | - if (isset($p_filedescr['new_full_name'])) { |
|
| 2941 | - // ----- Remove drive letter if any |
|
| 2942 | - $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']); |
|
| 2943 | - } |
|
| 2944 | 2938 | |
| 2945 | - // ----- Look for path and/or short name change |
|
| 2946 | - else { |
|
| 2939 | + // ----- Look for full name change |
|
| 2940 | + if (isset($p_filedescr['new_full_name'])) { |
|
| 2941 | + // ----- Remove drive letter if any |
|
| 2942 | + $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']); |
|
| 2943 | + } |
|
| 2947 | 2944 | |
| 2948 | - // ----- Look for short name change |
|
| 2949 | - // Its when we cahnge just the filename but not the path |
|
| 2950 | - if (isset($p_filedescr['new_short_name'])) { |
|
| 2951 | - $v_path_info = pathinfo($p_filename); |
|
| 2952 | - $v_dir = ''; |
|
| 2953 | - if ($v_path_info['dirname'] != '') { |
|
| 2954 | - $v_dir = $v_path_info['dirname'].'/'; |
|
| 2955 | - } |
|
| 2956 | - $v_stored_filename = $v_dir.$p_filedescr['new_short_name']; |
|
| 2957 | - } |
|
| 2958 | - else { |
|
| 2959 | - // ----- Calculate the stored filename |
|
| 2960 | - $v_stored_filename = $p_filename; |
|
| 2961 | - } |
|
| 2945 | + // ----- Look for path and/or short name change |
|
| 2946 | + else { |
|
| 2947 | + |
|
| 2948 | + // ----- Look for short name change |
|
| 2949 | + // Its when we cahnge just the filename but not the path |
|
| 2950 | + if (isset($p_filedescr['new_short_name'])) { |
|
| 2951 | + $v_path_info = pathinfo($p_filename); |
|
| 2952 | + $v_dir = ''; |
|
| 2953 | + if ($v_path_info['dirname'] != '') { |
|
| 2954 | + $v_dir = $v_path_info['dirname'].'/'; |
|
| 2955 | + } |
|
| 2956 | + $v_stored_filename = $v_dir.$p_filedescr['new_short_name']; |
|
| 2957 | + } |
|
| 2958 | + else { |
|
| 2959 | + // ----- Calculate the stored filename |
|
| 2960 | + $v_stored_filename = $p_filename; |
|
| 2961 | + } |
|
| 2962 | 2962 | |
| 2963 | - // ----- Look for all path to remove |
|
| 2964 | - if ($p_remove_all_dir) { |
|
| 2965 | - $v_stored_filename = basename($p_filename); |
|
| 2966 | - } |
|
| 2967 | - // ----- Look for partial path remove |
|
| 2968 | - else if ($p_remove_dir != "") { |
|
| 2969 | - if (substr($p_remove_dir, -1) != '/') |
|
| 2970 | - $p_remove_dir .= "/"; |
|
| 2963 | + // ----- Look for all path to remove |
|
| 2964 | + if ($p_remove_all_dir) { |
|
| 2965 | + $v_stored_filename = basename($p_filename); |
|
| 2966 | + } |
|
| 2967 | + // ----- Look for partial path remove |
|
| 2968 | + else if ($p_remove_dir != "") { |
|
| 2969 | + if (substr($p_remove_dir, -1) != '/') |
|
| 2970 | + $p_remove_dir .= "/"; |
|
| 2971 | 2971 | |
| 2972 | - if ( (substr($p_filename, 0, 2) == "./") |
|
| 2973 | - || (substr($p_remove_dir, 0, 2) == "./")) { |
|
| 2972 | + if ( (substr($p_filename, 0, 2) == "./") |
|
| 2973 | + || (substr($p_remove_dir, 0, 2) == "./")) { |
|
| 2974 | 2974 | |
| 2975 | - if ( (substr($p_filename, 0, 2) == "./") |
|
| 2976 | - && (substr($p_remove_dir, 0, 2) != "./")) { |
|
| 2977 | - $p_remove_dir = "./".$p_remove_dir; |
|
| 2978 | - } |
|
| 2979 | - if ( (substr($p_filename, 0, 2) != "./") |
|
| 2980 | - && (substr($p_remove_dir, 0, 2) == "./")) { |
|
| 2981 | - $p_remove_dir = substr($p_remove_dir, 2); |
|
| 2982 | - } |
|
| 2983 | - } |
|
| 2975 | + if ( (substr($p_filename, 0, 2) == "./") |
|
| 2976 | + && (substr($p_remove_dir, 0, 2) != "./")) { |
|
| 2977 | + $p_remove_dir = "./".$p_remove_dir; |
|
| 2978 | + } |
|
| 2979 | + if ( (substr($p_filename, 0, 2) != "./") |
|
| 2980 | + && (substr($p_remove_dir, 0, 2) == "./")) { |
|
| 2981 | + $p_remove_dir = substr($p_remove_dir, 2); |
|
| 2982 | + } |
|
| 2983 | + } |
|
| 2984 | 2984 | |
| 2985 | - $v_compare = PclZipUtilPathInclusion($p_remove_dir, |
|
| 2986 | - $v_stored_filename); |
|
| 2987 | - if ($v_compare > 0) { |
|
| 2988 | - if ($v_compare == 2) { |
|
| 2989 | - $v_stored_filename = ""; |
|
| 2990 | - } |
|
| 2991 | - else { |
|
| 2992 | - $v_stored_filename = substr($v_stored_filename, |
|
| 2993 | - strlen($p_remove_dir)); |
|
| 2994 | - } |
|
| 2995 | - } |
|
| 2996 | - } |
|
| 2985 | + $v_compare = PclZipUtilPathInclusion($p_remove_dir, |
|
| 2986 | + $v_stored_filename); |
|
| 2987 | + if ($v_compare > 0) { |
|
| 2988 | + if ($v_compare == 2) { |
|
| 2989 | + $v_stored_filename = ""; |
|
| 2990 | + } |
|
| 2991 | + else { |
|
| 2992 | + $v_stored_filename = substr($v_stored_filename, |
|
| 2993 | + strlen($p_remove_dir)); |
|
| 2994 | + } |
|
| 2995 | + } |
|
| 2996 | + } |
|
| 2997 | 2997 | |
| 2998 | - // ----- Remove drive letter if any |
|
| 2999 | - $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename); |
|
| 2998 | + // ----- Remove drive letter if any |
|
| 2999 | + $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename); |
|
| 3000 | 3000 | |
| 3001 | - // ----- Look for path to add |
|
| 3002 | - if ($p_add_dir != "") { |
|
| 3003 | - if (substr($p_add_dir, -1) == "/") |
|
| 3004 | - $v_stored_filename = $p_add_dir.$v_stored_filename; |
|
| 3005 | - else |
|
| 3006 | - $v_stored_filename = $p_add_dir."/".$v_stored_filename; |
|
| 3007 | - } |
|
| 3008 | - } |
|
| 3001 | + // ----- Look for path to add |
|
| 3002 | + if ($p_add_dir != "") { |
|
| 3003 | + if (substr($p_add_dir, -1) == "/") |
|
| 3004 | + $v_stored_filename = $p_add_dir.$v_stored_filename; |
|
| 3005 | + else |
|
| 3006 | + $v_stored_filename = $p_add_dir."/".$v_stored_filename; |
|
| 3007 | + } |
|
| 3008 | + } |
|
| 3009 | 3009 | |
| 3010 | - // ----- Filename (reduce the path of stored name) |
|
| 3011 | - $v_stored_filename = PclZipUtilPathReduction($v_stored_filename); |
|
| 3012 | - $p_filedescr['stored_filename'] = $v_stored_filename; |
|
| 3010 | + // ----- Filename (reduce the path of stored name) |
|
| 3011 | + $v_stored_filename = PclZipUtilPathReduction($v_stored_filename); |
|
| 3012 | + $p_filedescr['stored_filename'] = $v_stored_filename; |
|
| 3013 | 3013 | |
| 3014 | - // ----- Return |
|
| 3015 | - return $v_result; |
|
| 3014 | + // ----- Return |
|
| 3015 | + return $v_result; |
|
| 3016 | 3016 | } |
| 3017 | 3017 | // -------------------------------------------------------------------------------- |
| 3018 | 3018 | |
@@ -3024,40 +3024,40 @@ discard block |
||
| 3024 | 3024 | // -------------------------------------------------------------------------------- |
| 3025 | 3025 | function privWriteFileHeader(&$p_header) |
| 3026 | 3026 | { |
| 3027 | - $v_result=1; |
|
| 3027 | + $v_result=1; |
|
| 3028 | 3028 | |
| 3029 | - // ----- Store the offset position of the file |
|
| 3030 | - $p_header['offset'] = ftell($this->zip_fd); |
|
| 3029 | + // ----- Store the offset position of the file |
|
| 3030 | + $p_header['offset'] = ftell($this->zip_fd); |
|
| 3031 | 3031 | |
| 3032 | - // ----- Transform UNIX mtime to DOS format mdate/mtime |
|
| 3033 | - $v_date = getdate($p_header['mtime']); |
|
| 3034 | - $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 3035 | - $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 3032 | + // ----- Transform UNIX mtime to DOS format mdate/mtime |
|
| 3033 | + $v_date = getdate($p_header['mtime']); |
|
| 3034 | + $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 3035 | + $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 3036 | 3036 | |
| 3037 | - // ----- Packed data |
|
| 3038 | - $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, |
|
| 3039 | - $p_header['version_extracted'], $p_header['flag'], |
|
| 3040 | - $p_header['compression'], $v_mtime, $v_mdate, |
|
| 3041 | - $p_header['crc'], $p_header['compressed_size'], |
|
| 3037 | + // ----- Packed data |
|
| 3038 | + $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, |
|
| 3039 | + $p_header['version_extracted'], $p_header['flag'], |
|
| 3040 | + $p_header['compression'], $v_mtime, $v_mdate, |
|
| 3041 | + $p_header['crc'], $p_header['compressed_size'], |
|
| 3042 | 3042 | $p_header['size'], |
| 3043 | - strlen($p_header['stored_filename']), |
|
| 3043 | + strlen($p_header['stored_filename']), |
|
| 3044 | 3044 | $p_header['extra_len']); |
| 3045 | 3045 | |
| 3046 | - // ----- Write the first 148 bytes of the header in the archive |
|
| 3047 | - fputs($this->zip_fd, $v_binary_data, 30); |
|
| 3046 | + // ----- Write the first 148 bytes of the header in the archive |
|
| 3047 | + fputs($this->zip_fd, $v_binary_data, 30); |
|
| 3048 | 3048 | |
| 3049 | - // ----- Write the variable fields |
|
| 3050 | - if (strlen($p_header['stored_filename']) != 0) |
|
| 3051 | - { |
|
| 3052 | - fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); |
|
| 3053 | - } |
|
| 3054 | - if ($p_header['extra_len'] != 0) |
|
| 3055 | - { |
|
| 3056 | - fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
| 3057 | - } |
|
| 3049 | + // ----- Write the variable fields |
|
| 3050 | + if (strlen($p_header['stored_filename']) != 0) |
|
| 3051 | + { |
|
| 3052 | + fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); |
|
| 3053 | + } |
|
| 3054 | + if ($p_header['extra_len'] != 0) |
|
| 3055 | + { |
|
| 3056 | + fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
| 3057 | + } |
|
| 3058 | 3058 | |
| 3059 | - // ----- Return |
|
| 3060 | - return $v_result; |
|
| 3059 | + // ----- Return |
|
| 3060 | + return $v_result; |
|
| 3061 | 3061 | } |
| 3062 | 3062 | // -------------------------------------------------------------------------------- |
| 3063 | 3063 | |
@@ -3069,48 +3069,48 @@ discard block |
||
| 3069 | 3069 | // -------------------------------------------------------------------------------- |
| 3070 | 3070 | function privWriteCentralFileHeader(&$p_header) |
| 3071 | 3071 | { |
| 3072 | - $v_result=1; |
|
| 3072 | + $v_result=1; |
|
| 3073 | 3073 | |
| 3074 | - // TBC |
|
| 3075 | - //for(reset($p_header); $key = key($p_header); next($p_header)) { |
|
| 3076 | - //} |
|
| 3074 | + // TBC |
|
| 3075 | + //for(reset($p_header); $key = key($p_header); next($p_header)) { |
|
| 3076 | + //} |
|
| 3077 | 3077 | |
| 3078 | - // ----- Transform UNIX mtime to DOS format mdate/mtime |
|
| 3079 | - $v_date = getdate($p_header['mtime']); |
|
| 3080 | - $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 3081 | - $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 3078 | + // ----- Transform UNIX mtime to DOS format mdate/mtime |
|
| 3079 | + $v_date = getdate($p_header['mtime']); |
|
| 3080 | + $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 3081 | + $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 3082 | 3082 | |
| 3083 | 3083 | |
| 3084 | - // ----- Packed data |
|
| 3085 | - $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50, |
|
| 3086 | - $p_header['version'], $p_header['version_extracted'], |
|
| 3087 | - $p_header['flag'], $p_header['compression'], |
|
| 3084 | + // ----- Packed data |
|
| 3085 | + $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50, |
|
| 3086 | + $p_header['version'], $p_header['version_extracted'], |
|
| 3087 | + $p_header['flag'], $p_header['compression'], |
|
| 3088 | 3088 | $v_mtime, $v_mdate, $p_header['crc'], |
| 3089 | - $p_header['compressed_size'], $p_header['size'], |
|
| 3090 | - strlen($p_header['stored_filename']), |
|
| 3089 | + $p_header['compressed_size'], $p_header['size'], |
|
| 3090 | + strlen($p_header['stored_filename']), |
|
| 3091 | 3091 | $p_header['extra_len'], $p_header['comment_len'], |
| 3092 | - $p_header['disk'], $p_header['internal'], |
|
| 3092 | + $p_header['disk'], $p_header['internal'], |
|
| 3093 | 3093 | $p_header['external'], $p_header['offset']); |
| 3094 | 3094 | |
| 3095 | - // ----- Write the 42 bytes of the header in the zip file |
|
| 3096 | - fputs($this->zip_fd, $v_binary_data, 46); |
|
| 3095 | + // ----- Write the 42 bytes of the header in the zip file |
|
| 3096 | + fputs($this->zip_fd, $v_binary_data, 46); |
|
| 3097 | 3097 | |
| 3098 | - // ----- Write the variable fields |
|
| 3099 | - if (strlen($p_header['stored_filename']) != 0) |
|
| 3100 | - { |
|
| 3101 | - fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); |
|
| 3102 | - } |
|
| 3103 | - if ($p_header['extra_len'] != 0) |
|
| 3104 | - { |
|
| 3105 | - fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
| 3106 | - } |
|
| 3107 | - if ($p_header['comment_len'] != 0) |
|
| 3108 | - { |
|
| 3109 | - fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']); |
|
| 3110 | - } |
|
| 3098 | + // ----- Write the variable fields |
|
| 3099 | + if (strlen($p_header['stored_filename']) != 0) |
|
| 3100 | + { |
|
| 3101 | + fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); |
|
| 3102 | + } |
|
| 3103 | + if ($p_header['extra_len'] != 0) |
|
| 3104 | + { |
|
| 3105 | + fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
| 3106 | + } |
|
| 3107 | + if ($p_header['comment_len'] != 0) |
|
| 3108 | + { |
|
| 3109 | + fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']); |
|
| 3110 | + } |
|
| 3111 | 3111 | |
| 3112 | - // ----- Return |
|
| 3113 | - return $v_result; |
|
| 3112 | + // ----- Return |
|
| 3113 | + return $v_result; |
|
| 3114 | 3114 | } |
| 3115 | 3115 | // -------------------------------------------------------------------------------- |
| 3116 | 3116 | |
@@ -3122,24 +3122,24 @@ discard block |
||
| 3122 | 3122 | // -------------------------------------------------------------------------------- |
| 3123 | 3123 | function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) |
| 3124 | 3124 | { |
| 3125 | - $v_result=1; |
|
| 3125 | + $v_result=1; |
|
| 3126 | 3126 | |
| 3127 | - // ----- Packed data |
|
| 3128 | - $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, |
|
| 3129 | - $p_nb_entries, $p_size, |
|
| 3127 | + // ----- Packed data |
|
| 3128 | + $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, |
|
| 3129 | + $p_nb_entries, $p_size, |
|
| 3130 | 3130 | $p_offset, strlen($p_comment)); |
| 3131 | 3131 | |
| 3132 | - // ----- Write the 22 bytes of the header in the zip file |
|
| 3133 | - fputs($this->zip_fd, $v_binary_data, 22); |
|
| 3132 | + // ----- Write the 22 bytes of the header in the zip file |
|
| 3133 | + fputs($this->zip_fd, $v_binary_data, 22); |
|
| 3134 | 3134 | |
| 3135 | - // ----- Write the variable fields |
|
| 3136 | - if (strlen($p_comment) != 0) |
|
| 3137 | - { |
|
| 3138 | - fputs($this->zip_fd, $p_comment, strlen($p_comment)); |
|
| 3139 | - } |
|
| 3135 | + // ----- Write the variable fields |
|
| 3136 | + if (strlen($p_comment) != 0) |
|
| 3137 | + { |
|
| 3138 | + fputs($this->zip_fd, $p_comment, strlen($p_comment)); |
|
| 3139 | + } |
|
| 3140 | 3140 | |
| 3141 | - // ----- Return |
|
| 3142 | - return $v_result; |
|
| 3141 | + // ----- Return |
|
| 3142 | + return $v_result; |
|
| 3143 | 3143 | } |
| 3144 | 3144 | // -------------------------------------------------------------------------------- |
| 3145 | 3145 | |
@@ -3151,69 +3151,69 @@ discard block |
||
| 3151 | 3151 | // -------------------------------------------------------------------------------- |
| 3152 | 3152 | function privList(&$p_list) |
| 3153 | 3153 | { |
| 3154 | - $v_result=1; |
|
| 3154 | + $v_result=1; |
|
| 3155 | 3155 | |
| 3156 | - // ----- Magic quotes trick |
|
| 3157 | - $this->privDisableMagicQuotes(); |
|
| 3156 | + // ----- Magic quotes trick |
|
| 3157 | + $this->privDisableMagicQuotes(); |
|
| 3158 | 3158 | |
| 3159 | - // ----- Open the zip file |
|
| 3160 | - if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) |
|
| 3161 | - { |
|
| 3162 | - // ----- Magic quotes trick |
|
| 3163 | - $this->privSwapBackMagicQuotes(); |
|
| 3159 | + // ----- Open the zip file |
|
| 3160 | + if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) |
|
| 3161 | + { |
|
| 3162 | + // ----- Magic quotes trick |
|
| 3163 | + $this->privSwapBackMagicQuotes(); |
|
| 3164 | 3164 | |
| 3165 | - // ----- Error log |
|
| 3166 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); |
|
| 3165 | + // ----- Error log |
|
| 3166 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); |
|
| 3167 | 3167 | |
| 3168 | - // ----- Return |
|
| 3169 | - return PclZip::errorCode(); |
|
| 3170 | - } |
|
| 3168 | + // ----- Return |
|
| 3169 | + return PclZip::errorCode(); |
|
| 3170 | + } |
|
| 3171 | 3171 | |
| 3172 | - // ----- Read the central directory informations |
|
| 3173 | - $v_central_dir = array(); |
|
| 3174 | - if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 3175 | - { |
|
| 3176 | - $this->privSwapBackMagicQuotes(); |
|
| 3177 | - return $v_result; |
|
| 3178 | - } |
|
| 3172 | + // ----- Read the central directory informations |
|
| 3173 | + $v_central_dir = array(); |
|
| 3174 | + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 3175 | + { |
|
| 3176 | + $this->privSwapBackMagicQuotes(); |
|
| 3177 | + return $v_result; |
|
| 3178 | + } |
|
| 3179 | 3179 | |
| 3180 | - // ----- Go to beginning of Central Dir |
|
| 3181 | - @rewind($this->zip_fd); |
|
| 3182 | - if (@fseek($this->zip_fd, $v_central_dir['offset'])) |
|
| 3183 | - { |
|
| 3184 | - $this->privSwapBackMagicQuotes(); |
|
| 3180 | + // ----- Go to beginning of Central Dir |
|
| 3181 | + @rewind($this->zip_fd); |
|
| 3182 | + if (@fseek($this->zip_fd, $v_central_dir['offset'])) |
|
| 3183 | + { |
|
| 3184 | + $this->privSwapBackMagicQuotes(); |
|
| 3185 | 3185 | |
| 3186 | - // ----- Error log |
|
| 3187 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 3186 | + // ----- Error log |
|
| 3187 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 3188 | 3188 | |
| 3189 | - // ----- Return |
|
| 3190 | - return PclZip::errorCode(); |
|
| 3191 | - } |
|
| 3189 | + // ----- Return |
|
| 3190 | + return PclZip::errorCode(); |
|
| 3191 | + } |
|
| 3192 | 3192 | |
| 3193 | - // ----- Read each entry |
|
| 3194 | - for ($i=0; $i<$v_central_dir['entries']; $i++) |
|
| 3195 | - { |
|
| 3196 | - // ----- Read the file header |
|
| 3197 | - if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) |
|
| 3198 | - { |
|
| 3199 | - $this->privSwapBackMagicQuotes(); |
|
| 3200 | - return $v_result; |
|
| 3201 | - } |
|
| 3202 | - $v_header['index'] = $i; |
|
| 3193 | + // ----- Read each entry |
|
| 3194 | + for ($i=0; $i<$v_central_dir['entries']; $i++) |
|
| 3195 | + { |
|
| 3196 | + // ----- Read the file header |
|
| 3197 | + if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) |
|
| 3198 | + { |
|
| 3199 | + $this->privSwapBackMagicQuotes(); |
|
| 3200 | + return $v_result; |
|
| 3201 | + } |
|
| 3202 | + $v_header['index'] = $i; |
|
| 3203 | 3203 | |
| 3204 | - // ----- Get the only interesting attributes |
|
| 3205 | - $this->privConvertHeader2FileInfo($v_header, $p_list[$i]); |
|
| 3206 | - unset($v_header); |
|
| 3207 | - } |
|
| 3204 | + // ----- Get the only interesting attributes |
|
| 3205 | + $this->privConvertHeader2FileInfo($v_header, $p_list[$i]); |
|
| 3206 | + unset($v_header); |
|
| 3207 | + } |
|
| 3208 | 3208 | |
| 3209 | - // ----- Close the zip file |
|
| 3210 | - $this->privCloseFd(); |
|
| 3209 | + // ----- Close the zip file |
|
| 3210 | + $this->privCloseFd(); |
|
| 3211 | 3211 | |
| 3212 | - // ----- Magic quotes trick |
|
| 3213 | - $this->privSwapBackMagicQuotes(); |
|
| 3212 | + // ----- Magic quotes trick |
|
| 3213 | + $this->privSwapBackMagicQuotes(); |
|
| 3214 | 3214 | |
| 3215 | - // ----- Return |
|
| 3216 | - return $v_result; |
|
| 3215 | + // ----- Return |
|
| 3216 | + return $v_result; |
|
| 3217 | 3217 | } |
| 3218 | 3218 | // -------------------------------------------------------------------------------- |
| 3219 | 3219 | |
@@ -3238,24 +3238,24 @@ discard block |
||
| 3238 | 3238 | // -------------------------------------------------------------------------------- |
| 3239 | 3239 | function privConvertHeader2FileInfo($p_header, &$p_info) |
| 3240 | 3240 | { |
| 3241 | - $v_result=1; |
|
| 3242 | - |
|
| 3243 | - // ----- Get the interesting attributes |
|
| 3244 | - $v_temp_path = PclZipUtilPathReduction($p_header['filename']); |
|
| 3245 | - $p_info['filename'] = $v_temp_path; |
|
| 3246 | - $v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']); |
|
| 3247 | - $p_info['stored_filename'] = $v_temp_path; |
|
| 3248 | - $p_info['size'] = $p_header['size']; |
|
| 3249 | - $p_info['compressed_size'] = $p_header['compressed_size']; |
|
| 3250 | - $p_info['mtime'] = $p_header['mtime']; |
|
| 3251 | - $p_info['comment'] = $p_header['comment']; |
|
| 3252 | - $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); |
|
| 3253 | - $p_info['index'] = $p_header['index']; |
|
| 3254 | - $p_info['status'] = $p_header['status']; |
|
| 3255 | - $p_info['crc'] = $p_header['crc']; |
|
| 3256 | - |
|
| 3257 | - // ----- Return |
|
| 3258 | - return $v_result; |
|
| 3241 | + $v_result=1; |
|
| 3242 | + |
|
| 3243 | + // ----- Get the interesting attributes |
|
| 3244 | + $v_temp_path = PclZipUtilPathReduction($p_header['filename']); |
|
| 3245 | + $p_info['filename'] = $v_temp_path; |
|
| 3246 | + $v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']); |
|
| 3247 | + $p_info['stored_filename'] = $v_temp_path; |
|
| 3248 | + $p_info['size'] = $p_header['size']; |
|
| 3249 | + $p_info['compressed_size'] = $p_header['compressed_size']; |
|
| 3250 | + $p_info['mtime'] = $p_header['mtime']; |
|
| 3251 | + $p_info['comment'] = $p_header['comment']; |
|
| 3252 | + $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); |
|
| 3253 | + $p_info['index'] = $p_header['index']; |
|
| 3254 | + $p_info['status'] = $p_header['status']; |
|
| 3255 | + $p_info['crc'] = $p_header['crc']; |
|
| 3256 | + |
|
| 3257 | + // ----- Return |
|
| 3258 | + return $v_result; |
|
| 3259 | 3259 | } |
| 3260 | 3260 | // -------------------------------------------------------------------------------- |
| 3261 | 3261 | |
@@ -3277,122 +3277,122 @@ discard block |
||
| 3277 | 3277 | // -------------------------------------------------------------------------------- |
| 3278 | 3278 | function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) |
| 3279 | 3279 | { |
| 3280 | - $v_result=1; |
|
| 3280 | + $v_result=1; |
|
| 3281 | 3281 | |
| 3282 | - // ----- Magic quotes trick |
|
| 3283 | - $this->privDisableMagicQuotes(); |
|
| 3282 | + // ----- Magic quotes trick |
|
| 3283 | + $this->privDisableMagicQuotes(); |
|
| 3284 | 3284 | |
| 3285 | - // ----- Check the path |
|
| 3286 | - if ( ($p_path == "") |
|
| 3287 | - || ( (substr($p_path, 0, 1) != "/") |
|
| 3288 | - && (substr($p_path, 0, 3) != "../") |
|
| 3285 | + // ----- Check the path |
|
| 3286 | + if ( ($p_path == "") |
|
| 3287 | + || ( (substr($p_path, 0, 1) != "/") |
|
| 3288 | + && (substr($p_path, 0, 3) != "../") |
|
| 3289 | 3289 | && (substr($p_path,1,2)!=":/"))) |
| 3290 | - $p_path = "./".$p_path; |
|
| 3291 | - |
|
| 3292 | - // ----- Reduce the path last (and duplicated) '/' |
|
| 3293 | - if (($p_path != "./") && ($p_path != "/")) |
|
| 3294 | - { |
|
| 3295 | - // ----- Look for the path end '/' |
|
| 3296 | - while (substr($p_path, -1) == "/") |
|
| 3297 | - { |
|
| 3298 | - $p_path = substr($p_path, 0, strlen($p_path)-1); |
|
| 3299 | - } |
|
| 3300 | - } |
|
| 3290 | + $p_path = "./".$p_path; |
|
| 3291 | + |
|
| 3292 | + // ----- Reduce the path last (and duplicated) '/' |
|
| 3293 | + if (($p_path != "./") && ($p_path != "/")) |
|
| 3294 | + { |
|
| 3295 | + // ----- Look for the path end '/' |
|
| 3296 | + while (substr($p_path, -1) == "/") |
|
| 3297 | + { |
|
| 3298 | + $p_path = substr($p_path, 0, strlen($p_path)-1); |
|
| 3299 | + } |
|
| 3300 | + } |
|
| 3301 | 3301 | |
| 3302 | - // ----- Look for path to remove format (should end by /) |
|
| 3303 | - if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/')) |
|
| 3304 | - { |
|
| 3305 | - $p_remove_path .= '/'; |
|
| 3306 | - } |
|
| 3307 | - $p_remove_path_size = strlen($p_remove_path); |
|
| 3302 | + // ----- Look for path to remove format (should end by /) |
|
| 3303 | + if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/')) |
|
| 3304 | + { |
|
| 3305 | + $p_remove_path .= '/'; |
|
| 3306 | + } |
|
| 3307 | + $p_remove_path_size = strlen($p_remove_path); |
|
| 3308 | 3308 | |
| 3309 | - // ----- Open the zip file |
|
| 3310 | - if (($v_result = $this->privOpenFd('rb')) != 1) |
|
| 3311 | - { |
|
| 3312 | - $this->privSwapBackMagicQuotes(); |
|
| 3313 | - return $v_result; |
|
| 3314 | - } |
|
| 3309 | + // ----- Open the zip file |
|
| 3310 | + if (($v_result = $this->privOpenFd('rb')) != 1) |
|
| 3311 | + { |
|
| 3312 | + $this->privSwapBackMagicQuotes(); |
|
| 3313 | + return $v_result; |
|
| 3314 | + } |
|
| 3315 | 3315 | |
| 3316 | - // ----- Read the central directory informations |
|
| 3317 | - $v_central_dir = array(); |
|
| 3318 | - if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 3319 | - { |
|
| 3320 | - // ----- Close the zip file |
|
| 3321 | - $this->privCloseFd(); |
|
| 3322 | - $this->privSwapBackMagicQuotes(); |
|
| 3316 | + // ----- Read the central directory informations |
|
| 3317 | + $v_central_dir = array(); |
|
| 3318 | + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 3319 | + { |
|
| 3320 | + // ----- Close the zip file |
|
| 3321 | + $this->privCloseFd(); |
|
| 3322 | + $this->privSwapBackMagicQuotes(); |
|
| 3323 | 3323 | |
| 3324 | - return $v_result; |
|
| 3325 | - } |
|
| 3324 | + return $v_result; |
|
| 3325 | + } |
|
| 3326 | 3326 | |
| 3327 | - // ----- Start at beginning of Central Dir |
|
| 3328 | - $v_pos_entry = $v_central_dir['offset']; |
|
| 3327 | + // ----- Start at beginning of Central Dir |
|
| 3328 | + $v_pos_entry = $v_central_dir['offset']; |
|
| 3329 | 3329 | |
| 3330 | - // ----- Read each entry |
|
| 3331 | - $j_start = 0; |
|
| 3332 | - for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) |
|
| 3333 | - { |
|
| 3330 | + // ----- Read each entry |
|
| 3331 | + $j_start = 0; |
|
| 3332 | + for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) |
|
| 3333 | + { |
|
| 3334 | 3334 | |
| 3335 | - // ----- Read next Central dir entry |
|
| 3336 | - @rewind($this->zip_fd); |
|
| 3337 | - if (@fseek($this->zip_fd, $v_pos_entry)) |
|
| 3338 | - { |
|
| 3339 | - // ----- Close the zip file |
|
| 3340 | - $this->privCloseFd(); |
|
| 3341 | - $this->privSwapBackMagicQuotes(); |
|
| 3335 | + // ----- Read next Central dir entry |
|
| 3336 | + @rewind($this->zip_fd); |
|
| 3337 | + if (@fseek($this->zip_fd, $v_pos_entry)) |
|
| 3338 | + { |
|
| 3339 | + // ----- Close the zip file |
|
| 3340 | + $this->privCloseFd(); |
|
| 3341 | + $this->privSwapBackMagicQuotes(); |
|
| 3342 | 3342 | |
| 3343 | - // ----- Error log |
|
| 3344 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 3343 | + // ----- Error log |
|
| 3344 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 3345 | 3345 | |
| 3346 | - // ----- Return |
|
| 3347 | - return PclZip::errorCode(); |
|
| 3348 | - } |
|
| 3346 | + // ----- Return |
|
| 3347 | + return PclZip::errorCode(); |
|
| 3348 | + } |
|
| 3349 | 3349 | |
| 3350 | - // ----- Read the file header |
|
| 3351 | - $v_header = array(); |
|
| 3352 | - if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) |
|
| 3353 | - { |
|
| 3354 | - // ----- Close the zip file |
|
| 3355 | - $this->privCloseFd(); |
|
| 3356 | - $this->privSwapBackMagicQuotes(); |
|
| 3350 | + // ----- Read the file header |
|
| 3351 | + $v_header = array(); |
|
| 3352 | + if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) |
|
| 3353 | + { |
|
| 3354 | + // ----- Close the zip file |
|
| 3355 | + $this->privCloseFd(); |
|
| 3356 | + $this->privSwapBackMagicQuotes(); |
|
| 3357 | 3357 | |
| 3358 | - return $v_result; |
|
| 3359 | - } |
|
| 3358 | + return $v_result; |
|
| 3359 | + } |
|
| 3360 | 3360 | |
| 3361 | - // ----- Store the index |
|
| 3362 | - $v_header['index'] = $i; |
|
| 3361 | + // ----- Store the index |
|
| 3362 | + $v_header['index'] = $i; |
|
| 3363 | 3363 | |
| 3364 | - // ----- Store the file position |
|
| 3365 | - $v_pos_entry = ftell($this->zip_fd); |
|
| 3364 | + // ----- Store the file position |
|
| 3365 | + $v_pos_entry = ftell($this->zip_fd); |
|
| 3366 | 3366 | |
| 3367 | - // ----- Look for the specific extract rules |
|
| 3368 | - $v_extract = false; |
|
| 3367 | + // ----- Look for the specific extract rules |
|
| 3368 | + $v_extract = false; |
|
| 3369 | 3369 | |
| 3370 | - // ----- Look for extract by name rule |
|
| 3371 | - if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 3372 | - && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { |
|
| 3370 | + // ----- Look for extract by name rule |
|
| 3371 | + if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 3372 | + && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { |
|
| 3373 | 3373 | |
| 3374 | - // ----- Look if the filename is in the list |
|
| 3375 | - for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) { |
|
| 3374 | + // ----- Look if the filename is in the list |
|
| 3375 | + for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) { |
|
| 3376 | 3376 | |
| 3377 | - // ----- Look for a directory |
|
| 3378 | - if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") { |
|
| 3377 | + // ----- Look for a directory |
|
| 3378 | + if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") { |
|
| 3379 | 3379 | |
| 3380 | - // ----- Look if the directory is in the filename path |
|
| 3381 | - if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 3382 | - && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { |
|
| 3383 | - $v_extract = true; |
|
| 3384 | - } |
|
| 3385 | - } |
|
| 3386 | - // ----- Look for a filename |
|
| 3387 | - elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { |
|
| 3388 | - $v_extract = true; |
|
| 3389 | - } |
|
| 3390 | - } |
|
| 3391 | - } |
|
| 3380 | + // ----- Look if the directory is in the filename path |
|
| 3381 | + if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 3382 | + && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { |
|
| 3383 | + $v_extract = true; |
|
| 3384 | + } |
|
| 3385 | + } |
|
| 3386 | + // ----- Look for a filename |
|
| 3387 | + elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { |
|
| 3388 | + $v_extract = true; |
|
| 3389 | + } |
|
| 3390 | + } |
|
| 3391 | + } |
|
| 3392 | 3392 | |
| 3393 | - // ----- Look for extract by ereg rule |
|
| 3394 | - // ereg() is deprecated with PHP 5.3 |
|
| 3395 | - /* |
|
| 3393 | + // ----- Look for extract by ereg rule |
|
| 3394 | + // ereg() is deprecated with PHP 5.3 |
|
| 3395 | + /* |
|
| 3396 | 3396 | else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) |
| 3397 | 3397 | && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { |
| 3398 | 3398 | |
@@ -3402,207 +3402,207 @@ discard block |
||
| 3402 | 3402 | } |
| 3403 | 3403 | */ |
| 3404 | 3404 | |
| 3405 | - // ----- Look for extract by preg rule |
|
| 3406 | - else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 3407 | - && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { |
|
| 3405 | + // ----- Look for extract by preg rule |
|
| 3406 | + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 3407 | + && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { |
|
| 3408 | 3408 | |
| 3409 | - if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) { |
|
| 3410 | - $v_extract = true; |
|
| 3411 | - } |
|
| 3412 | - } |
|
| 3409 | + if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) { |
|
| 3410 | + $v_extract = true; |
|
| 3411 | + } |
|
| 3412 | + } |
|
| 3413 | 3413 | |
| 3414 | - // ----- Look for extract by index rule |
|
| 3415 | - else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 3416 | - && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { |
|
| 3414 | + // ----- Look for extract by index rule |
|
| 3415 | + else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 3416 | + && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { |
|
| 3417 | 3417 | |
| 3418 | - // ----- Look if the index is in the list |
|
| 3419 | - for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) { |
|
| 3418 | + // ----- Look if the index is in the list |
|
| 3419 | + for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) { |
|
| 3420 | 3420 | |
| 3421 | - if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { |
|
| 3422 | - $v_extract = true; |
|
| 3423 | - } |
|
| 3424 | - if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { |
|
| 3425 | - $j_start = $j+1; |
|
| 3426 | - } |
|
| 3421 | + if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { |
|
| 3422 | + $v_extract = true; |
|
| 3423 | + } |
|
| 3424 | + if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { |
|
| 3425 | + $j_start = $j+1; |
|
| 3426 | + } |
|
| 3427 | 3427 | |
| 3428 | - if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { |
|
| 3429 | - break; |
|
| 3430 | - } |
|
| 3431 | - } |
|
| 3432 | - } |
|
| 3428 | + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { |
|
| 3429 | + break; |
|
| 3430 | + } |
|
| 3431 | + } |
|
| 3432 | + } |
|
| 3433 | 3433 | |
| 3434 | - // ----- Look for no rule, which means extract all the archive |
|
| 3435 | - else { |
|
| 3436 | - $v_extract = true; |
|
| 3437 | - } |
|
| 3434 | + // ----- Look for no rule, which means extract all the archive |
|
| 3435 | + else { |
|
| 3436 | + $v_extract = true; |
|
| 3437 | + } |
|
| 3438 | 3438 | |
| 3439 | 3439 | // ----- Check compression method |
| 3440 | 3440 | if ( ($v_extract) |
| 3441 | - && ( ($v_header['compression'] != 8) |
|
| 3442 | - && ($v_header['compression'] != 0))) { |
|
| 3443 | - $v_header['status'] = 'unsupported_compression'; |
|
| 3441 | + && ( ($v_header['compression'] != 8) |
|
| 3442 | + && ($v_header['compression'] != 0))) { |
|
| 3443 | + $v_header['status'] = 'unsupported_compression'; |
|
| 3444 | 3444 | |
| 3445 | - // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3446 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3447 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3445 | + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3446 | + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3447 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3448 | 3448 | |
| 3449 | - $this->privSwapBackMagicQuotes(); |
|
| 3449 | + $this->privSwapBackMagicQuotes(); |
|
| 3450 | 3450 | |
| 3451 | - PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, |
|
| 3452 | - "Filename '".$v_header['stored_filename']."' is " |
|
| 3453 | - ."compressed by an unsupported compression " |
|
| 3454 | - ."method (".$v_header['compression'].") "); |
|
| 3451 | + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, |
|
| 3452 | + "Filename '".$v_header['stored_filename']."' is " |
|
| 3453 | + ."compressed by an unsupported compression " |
|
| 3454 | + ."method (".$v_header['compression'].") "); |
|
| 3455 | 3455 | |
| 3456 | - return PclZip::errorCode(); |
|
| 3456 | + return PclZip::errorCode(); |
|
| 3457 | 3457 | } |
| 3458 | 3458 | } |
| 3459 | 3459 | |
| 3460 | 3460 | // ----- Check encrypted files |
| 3461 | 3461 | if (($v_extract) && (($v_header['flag'] & 1) == 1)) { |
| 3462 | - $v_header['status'] = 'unsupported_encryption'; |
|
| 3462 | + $v_header['status'] = 'unsupported_encryption'; |
|
| 3463 | 3463 | |
| 3464 | - // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3465 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3466 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3464 | + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3465 | + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3466 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3467 | 3467 | |
| 3468 | - $this->privSwapBackMagicQuotes(); |
|
| 3468 | + $this->privSwapBackMagicQuotes(); |
|
| 3469 | 3469 | |
| 3470 | - PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, |
|
| 3471 | - "Unsupported encryption for " |
|
| 3472 | - ." filename '".$v_header['stored_filename'] |
|
| 3470 | + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, |
|
| 3471 | + "Unsupported encryption for " |
|
| 3472 | + ." filename '".$v_header['stored_filename'] |
|
| 3473 | 3473 | ."'"); |
| 3474 | 3474 | |
| 3475 | - return PclZip::errorCode(); |
|
| 3475 | + return PclZip::errorCode(); |
|
| 3476 | 3476 | } |
| 3477 | - } |
|
| 3477 | + } |
|
| 3478 | 3478 | |
| 3479 | - // ----- Look for real extraction |
|
| 3480 | - if (($v_extract) && ($v_header['status'] != 'ok')) { |
|
| 3481 | - $v_result = $this->privConvertHeader2FileInfo($v_header, |
|
| 3482 | - $p_file_list[$v_nb_extracted++]); |
|
| 3483 | - if ($v_result != 1) { |
|
| 3484 | - $this->privCloseFd(); |
|
| 3485 | - $this->privSwapBackMagicQuotes(); |
|
| 3486 | - return $v_result; |
|
| 3487 | - } |
|
| 3479 | + // ----- Look for real extraction |
|
| 3480 | + if (($v_extract) && ($v_header['status'] != 'ok')) { |
|
| 3481 | + $v_result = $this->privConvertHeader2FileInfo($v_header, |
|
| 3482 | + $p_file_list[$v_nb_extracted++]); |
|
| 3483 | + if ($v_result != 1) { |
|
| 3484 | + $this->privCloseFd(); |
|
| 3485 | + $this->privSwapBackMagicQuotes(); |
|
| 3486 | + return $v_result; |
|
| 3487 | + } |
|
| 3488 | 3488 | |
| 3489 | - $v_extract = false; |
|
| 3490 | - } |
|
| 3489 | + $v_extract = false; |
|
| 3490 | + } |
|
| 3491 | 3491 | |
| 3492 | - // ----- Look for real extraction |
|
| 3493 | - if ($v_extract) |
|
| 3494 | - { |
|
| 3492 | + // ----- Look for real extraction |
|
| 3493 | + if ($v_extract) |
|
| 3494 | + { |
|
| 3495 | 3495 | |
| 3496 | - // ----- Go to the file position |
|
| 3497 | - @rewind($this->zip_fd); |
|
| 3498 | - if (@fseek($this->zip_fd, $v_header['offset'])) |
|
| 3499 | - { |
|
| 3500 | - // ----- Close the zip file |
|
| 3501 | - $this->privCloseFd(); |
|
| 3496 | + // ----- Go to the file position |
|
| 3497 | + @rewind($this->zip_fd); |
|
| 3498 | + if (@fseek($this->zip_fd, $v_header['offset'])) |
|
| 3499 | + { |
|
| 3500 | + // ----- Close the zip file |
|
| 3501 | + $this->privCloseFd(); |
|
| 3502 | 3502 | |
| 3503 | - $this->privSwapBackMagicQuotes(); |
|
| 3503 | + $this->privSwapBackMagicQuotes(); |
|
| 3504 | 3504 | |
| 3505 | - // ----- Error log |
|
| 3506 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 3505 | + // ----- Error log |
|
| 3506 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 3507 | 3507 | |
| 3508 | - // ----- Return |
|
| 3509 | - return PclZip::errorCode(); |
|
| 3510 | - } |
|
| 3508 | + // ----- Return |
|
| 3509 | + return PclZip::errorCode(); |
|
| 3510 | + } |
|
| 3511 | 3511 | |
| 3512 | - // ----- Look for extraction as string |
|
| 3513 | - if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) { |
|
| 3512 | + // ----- Look for extraction as string |
|
| 3513 | + if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) { |
|
| 3514 | 3514 | |
| 3515 | - $v_string = ''; |
|
| 3515 | + $v_string = ''; |
|
| 3516 | 3516 | |
| 3517 | - // ----- Extracting the file |
|
| 3518 | - $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options); |
|
| 3519 | - if ($v_result1 < 1) { |
|
| 3520 | - $this->privCloseFd(); |
|
| 3521 | - $this->privSwapBackMagicQuotes(); |
|
| 3522 | - return $v_result1; |
|
| 3523 | - } |
|
| 3517 | + // ----- Extracting the file |
|
| 3518 | + $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options); |
|
| 3519 | + if ($v_result1 < 1) { |
|
| 3520 | + $this->privCloseFd(); |
|
| 3521 | + $this->privSwapBackMagicQuotes(); |
|
| 3522 | + return $v_result1; |
|
| 3523 | + } |
|
| 3524 | 3524 | |
| 3525 | - // ----- Get the only interesting attributes |
|
| 3526 | - if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) |
|
| 3527 | - { |
|
| 3528 | - // ----- Close the zip file |
|
| 3529 | - $this->privCloseFd(); |
|
| 3530 | - $this->privSwapBackMagicQuotes(); |
|
| 3525 | + // ----- Get the only interesting attributes |
|
| 3526 | + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) |
|
| 3527 | + { |
|
| 3528 | + // ----- Close the zip file |
|
| 3529 | + $this->privCloseFd(); |
|
| 3530 | + $this->privSwapBackMagicQuotes(); |
|
| 3531 | 3531 | |
| 3532 | - return $v_result; |
|
| 3533 | - } |
|
| 3532 | + return $v_result; |
|
| 3533 | + } |
|
| 3534 | 3534 | |
| 3535 | - // ----- Set the file content |
|
| 3536 | - $p_file_list[$v_nb_extracted]['content'] = $v_string; |
|
| 3535 | + // ----- Set the file content |
|
| 3536 | + $p_file_list[$v_nb_extracted]['content'] = $v_string; |
|
| 3537 | 3537 | |
| 3538 | - // ----- Next extracted file |
|
| 3539 | - $v_nb_extracted++; |
|
| 3538 | + // ----- Next extracted file |
|
| 3539 | + $v_nb_extracted++; |
|
| 3540 | 3540 | |
| 3541 | - // ----- Look for user callback abort |
|
| 3542 | - if ($v_result1 == 2) { |
|
| 3543 | - break; |
|
| 3544 | - } |
|
| 3545 | - } |
|
| 3546 | - // ----- Look for extraction in standard output |
|
| 3547 | - elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) |
|
| 3548 | - && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) { |
|
| 3549 | - // ----- Extracting the file in standard output |
|
| 3550 | - $v_result1 = $this->privExtractFileInOutput($v_header, $p_options); |
|
| 3551 | - if ($v_result1 < 1) { |
|
| 3552 | - $this->privCloseFd(); |
|
| 3553 | - $this->privSwapBackMagicQuotes(); |
|
| 3554 | - return $v_result1; |
|
| 3555 | - } |
|
| 3541 | + // ----- Look for user callback abort |
|
| 3542 | + if ($v_result1 == 2) { |
|
| 3543 | + break; |
|
| 3544 | + } |
|
| 3545 | + } |
|
| 3546 | + // ----- Look for extraction in standard output |
|
| 3547 | + elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) |
|
| 3548 | + && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) { |
|
| 3549 | + // ----- Extracting the file in standard output |
|
| 3550 | + $v_result1 = $this->privExtractFileInOutput($v_header, $p_options); |
|
| 3551 | + if ($v_result1 < 1) { |
|
| 3552 | + $this->privCloseFd(); |
|
| 3553 | + $this->privSwapBackMagicQuotes(); |
|
| 3554 | + return $v_result1; |
|
| 3555 | + } |
|
| 3556 | 3556 | |
| 3557 | - // ----- Get the only interesting attributes |
|
| 3558 | - if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) { |
|
| 3559 | - $this->privCloseFd(); |
|
| 3560 | - $this->privSwapBackMagicQuotes(); |
|
| 3561 | - return $v_result; |
|
| 3562 | - } |
|
| 3557 | + // ----- Get the only interesting attributes |
|
| 3558 | + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) { |
|
| 3559 | + $this->privCloseFd(); |
|
| 3560 | + $this->privSwapBackMagicQuotes(); |
|
| 3561 | + return $v_result; |
|
| 3562 | + } |
|
| 3563 | 3563 | |
| 3564 | - // ----- Look for user callback abort |
|
| 3565 | - if ($v_result1 == 2) { |
|
| 3566 | - break; |
|
| 3567 | - } |
|
| 3568 | - } |
|
| 3569 | - // ----- Look for normal extraction |
|
| 3570 | - else { |
|
| 3571 | - // ----- Extracting the file |
|
| 3572 | - $v_result1 = $this->privExtractFile($v_header, |
|
| 3573 | - $p_path, $p_remove_path, |
|
| 3564 | + // ----- Look for user callback abort |
|
| 3565 | + if ($v_result1 == 2) { |
|
| 3566 | + break; |
|
| 3567 | + } |
|
| 3568 | + } |
|
| 3569 | + // ----- Look for normal extraction |
|
| 3570 | + else { |
|
| 3571 | + // ----- Extracting the file |
|
| 3572 | + $v_result1 = $this->privExtractFile($v_header, |
|
| 3573 | + $p_path, $p_remove_path, |
|
| 3574 | 3574 | $p_remove_all_path, |
| 3575 | 3575 | $p_options); |
| 3576 | - if ($v_result1 < 1) { |
|
| 3577 | - $this->privCloseFd(); |
|
| 3578 | - $this->privSwapBackMagicQuotes(); |
|
| 3579 | - return $v_result1; |
|
| 3580 | - } |
|
| 3576 | + if ($v_result1 < 1) { |
|
| 3577 | + $this->privCloseFd(); |
|
| 3578 | + $this->privSwapBackMagicQuotes(); |
|
| 3579 | + return $v_result1; |
|
| 3580 | + } |
|
| 3581 | 3581 | |
| 3582 | - // ----- Get the only interesting attributes |
|
| 3583 | - if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) |
|
| 3584 | - { |
|
| 3585 | - // ----- Close the zip file |
|
| 3586 | - $this->privCloseFd(); |
|
| 3587 | - $this->privSwapBackMagicQuotes(); |
|
| 3582 | + // ----- Get the only interesting attributes |
|
| 3583 | + if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) |
|
| 3584 | + { |
|
| 3585 | + // ----- Close the zip file |
|
| 3586 | + $this->privCloseFd(); |
|
| 3587 | + $this->privSwapBackMagicQuotes(); |
|
| 3588 | 3588 | |
| 3589 | - return $v_result; |
|
| 3590 | - } |
|
| 3589 | + return $v_result; |
|
| 3590 | + } |
|
| 3591 | 3591 | |
| 3592 | - // ----- Look for user callback abort |
|
| 3593 | - if ($v_result1 == 2) { |
|
| 3594 | - break; |
|
| 3595 | - } |
|
| 3596 | - } |
|
| 3597 | - } |
|
| 3598 | - } |
|
| 3592 | + // ----- Look for user callback abort |
|
| 3593 | + if ($v_result1 == 2) { |
|
| 3594 | + break; |
|
| 3595 | + } |
|
| 3596 | + } |
|
| 3597 | + } |
|
| 3598 | + } |
|
| 3599 | 3599 | |
| 3600 | - // ----- Close the zip file |
|
| 3601 | - $this->privCloseFd(); |
|
| 3602 | - $this->privSwapBackMagicQuotes(); |
|
| 3600 | + // ----- Close the zip file |
|
| 3601 | + $this->privCloseFd(); |
|
| 3602 | + $this->privSwapBackMagicQuotes(); |
|
| 3603 | 3603 | |
| 3604 | - // ----- Return |
|
| 3605 | - return $v_result; |
|
| 3604 | + // ----- Return |
|
| 3605 | + return $v_result; |
|
| 3606 | 3606 | } |
| 3607 | 3607 | // -------------------------------------------------------------------------------- |
| 3608 | 3608 | |
@@ -3617,344 +3617,344 @@ discard block |
||
| 3617 | 3617 | // -------------------------------------------------------------------------------- |
| 3618 | 3618 | function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) |
| 3619 | 3619 | { |
| 3620 | - $v_result=1; |
|
| 3620 | + $v_result=1; |
|
| 3621 | 3621 | |
| 3622 | - // ----- Read the file header |
|
| 3623 | - if (($v_result = $this->privReadFileHeader($v_header)) != 1) |
|
| 3624 | - { |
|
| 3625 | - // ----- Return |
|
| 3626 | - return $v_result; |
|
| 3627 | - } |
|
| 3622 | + // ----- Read the file header |
|
| 3623 | + if (($v_result = $this->privReadFileHeader($v_header)) != 1) |
|
| 3624 | + { |
|
| 3625 | + // ----- Return |
|
| 3626 | + return $v_result; |
|
| 3627 | + } |
|
| 3628 | 3628 | |
| 3629 | 3629 | |
| 3630 | - // ----- Check that the file header is coherent with $p_entry info |
|
| 3631 | - if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { |
|
| 3632 | - // TBC |
|
| 3633 | - } |
|
| 3630 | + // ----- Check that the file header is coherent with $p_entry info |
|
| 3631 | + if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { |
|
| 3632 | + // TBC |
|
| 3633 | + } |
|
| 3634 | 3634 | |
| 3635 | - // ----- Look for all path to remove |
|
| 3636 | - if ($p_remove_all_path == true) { |
|
| 3637 | - // ----- Look for folder entry that not need to be extracted |
|
| 3638 | - if (($p_entry['external']&0x00000010)==0x00000010) { |
|
| 3635 | + // ----- Look for all path to remove |
|
| 3636 | + if ($p_remove_all_path == true) { |
|
| 3637 | + // ----- Look for folder entry that not need to be extracted |
|
| 3638 | + if (($p_entry['external']&0x00000010)==0x00000010) { |
|
| 3639 | 3639 | |
| 3640 | - $p_entry['status'] = "filtered"; |
|
| 3640 | + $p_entry['status'] = "filtered"; |
|
| 3641 | 3641 | |
| 3642 | - return $v_result; |
|
| 3643 | - } |
|
| 3642 | + return $v_result; |
|
| 3643 | + } |
|
| 3644 | 3644 | |
| 3645 | - // ----- Get the basename of the path |
|
| 3646 | - $p_entry['filename'] = basename($p_entry['filename']); |
|
| 3647 | - } |
|
| 3645 | + // ----- Get the basename of the path |
|
| 3646 | + $p_entry['filename'] = basename($p_entry['filename']); |
|
| 3647 | + } |
|
| 3648 | 3648 | |
| 3649 | - // ----- Look for path to remove |
|
| 3650 | - else if ($p_remove_path != "") |
|
| 3651 | - { |
|
| 3652 | - if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2) |
|
| 3653 | - { |
|
| 3649 | + // ----- Look for path to remove |
|
| 3650 | + else if ($p_remove_path != "") |
|
| 3651 | + { |
|
| 3652 | + if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2) |
|
| 3653 | + { |
|
| 3654 | 3654 | |
| 3655 | - // ----- Change the file status |
|
| 3656 | - $p_entry['status'] = "filtered"; |
|
| 3655 | + // ----- Change the file status |
|
| 3656 | + $p_entry['status'] = "filtered"; |
|
| 3657 | 3657 | |
| 3658 | - // ----- Return |
|
| 3659 | - return $v_result; |
|
| 3660 | - } |
|
| 3658 | + // ----- Return |
|
| 3659 | + return $v_result; |
|
| 3660 | + } |
|
| 3661 | 3661 | |
| 3662 | - $p_remove_path_size = strlen($p_remove_path); |
|
| 3663 | - if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) |
|
| 3664 | - { |
|
| 3662 | + $p_remove_path_size = strlen($p_remove_path); |
|
| 3663 | + if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) |
|
| 3664 | + { |
|
| 3665 | 3665 | |
| 3666 | - // ----- Remove the path |
|
| 3667 | - $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size); |
|
| 3666 | + // ----- Remove the path |
|
| 3667 | + $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size); |
|
| 3668 | 3668 | |
| 3669 | - } |
|
| 3670 | - } |
|
| 3669 | + } |
|
| 3670 | + } |
|
| 3671 | 3671 | |
| 3672 | - // ----- Add the path |
|
| 3673 | - if ($p_path != '') { |
|
| 3674 | - $p_entry['filename'] = $p_path."/".$p_entry['filename']; |
|
| 3675 | - } |
|
| 3672 | + // ----- Add the path |
|
| 3673 | + if ($p_path != '') { |
|
| 3674 | + $p_entry['filename'] = $p_path."/".$p_entry['filename']; |
|
| 3675 | + } |
|
| 3676 | 3676 | |
| 3677 | - // ----- Check a base_dir_restriction |
|
| 3678 | - if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) { |
|
| 3679 | - $v_inclusion |
|
| 3680 | - = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], |
|
| 3681 | - $p_entry['filename']); |
|
| 3682 | - if ($v_inclusion == 0) { |
|
| 3677 | + // ----- Check a base_dir_restriction |
|
| 3678 | + if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) { |
|
| 3679 | + $v_inclusion |
|
| 3680 | + = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], |
|
| 3681 | + $p_entry['filename']); |
|
| 3682 | + if ($v_inclusion == 0) { |
|
| 3683 | 3683 | |
| 3684 | - PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION, |
|
| 3685 | - "Filename '".$p_entry['filename']."' is " |
|
| 3684 | + PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION, |
|
| 3685 | + "Filename '".$p_entry['filename']."' is " |
|
| 3686 | 3686 | ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION"); |
| 3687 | 3687 | |
| 3688 | - return PclZip::errorCode(); |
|
| 3689 | - } |
|
| 3690 | - } |
|
| 3688 | + return PclZip::errorCode(); |
|
| 3689 | + } |
|
| 3690 | + } |
|
| 3691 | 3691 | |
| 3692 | - // ----- Look for pre-extract callback |
|
| 3693 | - if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { |
|
| 3694 | - |
|
| 3695 | - // ----- Generate a local information |
|
| 3696 | - $v_local_header = array(); |
|
| 3697 | - $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 3698 | - |
|
| 3699 | - // ----- Call the callback |
|
| 3700 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 3701 | - // header. |
|
| 3702 | - $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); |
|
| 3703 | - if ($v_result == 0) { |
|
| 3704 | - // ----- Change the file status |
|
| 3705 | - $p_entry['status'] = "skipped"; |
|
| 3706 | - $v_result = 1; |
|
| 3707 | - } |
|
| 3692 | + // ----- Look for pre-extract callback |
|
| 3693 | + if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { |
|
| 3694 | + |
|
| 3695 | + // ----- Generate a local information |
|
| 3696 | + $v_local_header = array(); |
|
| 3697 | + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 3698 | + |
|
| 3699 | + // ----- Call the callback |
|
| 3700 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 3701 | + // header. |
|
| 3702 | + $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); |
|
| 3703 | + if ($v_result == 0) { |
|
| 3704 | + // ----- Change the file status |
|
| 3705 | + $p_entry['status'] = "skipped"; |
|
| 3706 | + $v_result = 1; |
|
| 3707 | + } |
|
| 3708 | 3708 | |
| 3709 | - // ----- Look for abort result |
|
| 3710 | - if ($v_result == 2) { |
|
| 3711 | - // ----- This status is internal and will be changed in 'skipped' |
|
| 3712 | - $p_entry['status'] = "aborted"; |
|
| 3713 | - $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 3714 | - } |
|
| 3709 | + // ----- Look for abort result |
|
| 3710 | + if ($v_result == 2) { |
|
| 3711 | + // ----- This status is internal and will be changed in 'skipped' |
|
| 3712 | + $p_entry['status'] = "aborted"; |
|
| 3713 | + $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 3714 | + } |
|
| 3715 | 3715 | |
| 3716 | - // ----- Update the informations |
|
| 3717 | - // Only some fields can be modified |
|
| 3718 | - $p_entry['filename'] = $v_local_header['filename']; |
|
| 3719 | - } |
|
| 3716 | + // ----- Update the informations |
|
| 3717 | + // Only some fields can be modified |
|
| 3718 | + $p_entry['filename'] = $v_local_header['filename']; |
|
| 3719 | + } |
|
| 3720 | 3720 | |
| 3721 | 3721 | |
| 3722 | - // ----- Look if extraction should be done |
|
| 3723 | - if ($p_entry['status'] == 'ok') { |
|
| 3722 | + // ----- Look if extraction should be done |
|
| 3723 | + if ($p_entry['status'] == 'ok') { |
|
| 3724 | 3724 | |
| 3725 | - // ----- Look for specific actions while the file exist |
|
| 3726 | - if (file_exists($p_entry['filename'])) |
|
| 3727 | - { |
|
| 3725 | + // ----- Look for specific actions while the file exist |
|
| 3726 | + if (file_exists($p_entry['filename'])) |
|
| 3727 | + { |
|
| 3728 | 3728 | |
| 3729 | - // ----- Look if file is a directory |
|
| 3730 | - if (is_dir($p_entry['filename'])) |
|
| 3731 | - { |
|
| 3729 | + // ----- Look if file is a directory |
|
| 3730 | + if (is_dir($p_entry['filename'])) |
|
| 3731 | + { |
|
| 3732 | 3732 | |
| 3733 | - // ----- Change the file status |
|
| 3734 | - $p_entry['status'] = "already_a_directory"; |
|
| 3733 | + // ----- Change the file status |
|
| 3734 | + $p_entry['status'] = "already_a_directory"; |
|
| 3735 | 3735 | |
| 3736 | - // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3737 | - // For historical reason first PclZip implementation does not stop |
|
| 3738 | - // when this kind of error occurs. |
|
| 3739 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3740 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3736 | + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3737 | + // For historical reason first PclZip implementation does not stop |
|
| 3738 | + // when this kind of error occurs. |
|
| 3739 | + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3740 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3741 | 3741 | |
| 3742 | - PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY, |
|
| 3743 | - "Filename '".$p_entry['filename']."' is " |
|
| 3742 | + PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY, |
|
| 3743 | + "Filename '".$p_entry['filename']."' is " |
|
| 3744 | 3744 | ."already used by an existing directory"); |
| 3745 | 3745 | |
| 3746 | - return PclZip::errorCode(); |
|
| 3747 | - } |
|
| 3748 | - } |
|
| 3749 | - // ----- Look if file is write protected |
|
| 3750 | - else if (!is_writeable($p_entry['filename'])) |
|
| 3751 | - { |
|
| 3746 | + return PclZip::errorCode(); |
|
| 3747 | + } |
|
| 3748 | + } |
|
| 3749 | + // ----- Look if file is write protected |
|
| 3750 | + else if (!is_writeable($p_entry['filename'])) |
|
| 3751 | + { |
|
| 3752 | 3752 | |
| 3753 | - // ----- Change the file status |
|
| 3754 | - $p_entry['status'] = "write_protected"; |
|
| 3753 | + // ----- Change the file status |
|
| 3754 | + $p_entry['status'] = "write_protected"; |
|
| 3755 | 3755 | |
| 3756 | - // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3757 | - // For historical reason first PclZip implementation does not stop |
|
| 3758 | - // when this kind of error occurs. |
|
| 3759 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3760 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3756 | + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3757 | + // For historical reason first PclZip implementation does not stop |
|
| 3758 | + // when this kind of error occurs. |
|
| 3759 | + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3760 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3761 | 3761 | |
| 3762 | - PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, |
|
| 3763 | - "Filename '".$p_entry['filename']."' exists " |
|
| 3762 | + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, |
|
| 3763 | + "Filename '".$p_entry['filename']."' exists " |
|
| 3764 | 3764 | ."and is write protected"); |
| 3765 | 3765 | |
| 3766 | - return PclZip::errorCode(); |
|
| 3767 | - } |
|
| 3768 | - } |
|
| 3766 | + return PclZip::errorCode(); |
|
| 3767 | + } |
|
| 3768 | + } |
|
| 3769 | 3769 | |
| 3770 | - // ----- Look if the extracted file is older |
|
| 3771 | - else if (filemtime($p_entry['filename']) > $p_entry['mtime']) |
|
| 3772 | - { |
|
| 3773 | - // ----- Change the file status |
|
| 3774 | - if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) |
|
| 3775 | - && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) { |
|
| 3770 | + // ----- Look if the extracted file is older |
|
| 3771 | + else if (filemtime($p_entry['filename']) > $p_entry['mtime']) |
|
| 3772 | + { |
|
| 3773 | + // ----- Change the file status |
|
| 3774 | + if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) |
|
| 3775 | + && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) { |
|
| 3776 | 3776 | } |
| 3777 | - else { |
|
| 3778 | - $p_entry['status'] = "newer_exist"; |
|
| 3779 | - |
|
| 3780 | - // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3781 | - // For historical reason first PclZip implementation does not stop |
|
| 3782 | - // when this kind of error occurs. |
|
| 3783 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3784 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3785 | - |
|
| 3786 | - PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, |
|
| 3787 | - "Newer version of '".$p_entry['filename']."' exists " |
|
| 3788 | - ."and option PCLZIP_OPT_REPLACE_NEWER is not selected"); |
|
| 3789 | - |
|
| 3790 | - return PclZip::errorCode(); |
|
| 3791 | - } |
|
| 3792 | - } |
|
| 3793 | - } |
|
| 3794 | - else { |
|
| 3795 | - } |
|
| 3796 | - } |
|
| 3777 | + else { |
|
| 3778 | + $p_entry['status'] = "newer_exist"; |
|
| 3779 | + |
|
| 3780 | + // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
|
| 3781 | + // For historical reason first PclZip implementation does not stop |
|
| 3782 | + // when this kind of error occurs. |
|
| 3783 | + if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3784 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3785 | + |
|
| 3786 | + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, |
|
| 3787 | + "Newer version of '".$p_entry['filename']."' exists " |
|
| 3788 | + ."and option PCLZIP_OPT_REPLACE_NEWER is not selected"); |
|
| 3789 | + |
|
| 3790 | + return PclZip::errorCode(); |
|
| 3791 | + } |
|
| 3792 | + } |
|
| 3793 | + } |
|
| 3794 | + else { |
|
| 3795 | + } |
|
| 3796 | + } |
|
| 3797 | 3797 | |
| 3798 | - // ----- Check the directory availability and create it if necessary |
|
| 3799 | - else { |
|
| 3800 | - if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) |
|
| 3801 | - $v_dir_to_check = $p_entry['filename']; |
|
| 3802 | - else if (!strstr($p_entry['filename'], "/")) |
|
| 3803 | - $v_dir_to_check = ""; |
|
| 3804 | - else |
|
| 3805 | - $v_dir_to_check = dirname($p_entry['filename']); |
|
| 3806 | - |
|
| 3807 | - if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) { |
|
| 3808 | - |
|
| 3809 | - // ----- Change the file status |
|
| 3810 | - $p_entry['status'] = "path_creation_fail"; |
|
| 3811 | - |
|
| 3812 | - // ----- Return |
|
| 3813 | - //return $v_result; |
|
| 3814 | - $v_result = 1; |
|
| 3815 | - } |
|
| 3816 | - } |
|
| 3817 | - } |
|
| 3798 | + // ----- Check the directory availability and create it if necessary |
|
| 3799 | + else { |
|
| 3800 | + if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) |
|
| 3801 | + $v_dir_to_check = $p_entry['filename']; |
|
| 3802 | + else if (!strstr($p_entry['filename'], "/")) |
|
| 3803 | + $v_dir_to_check = ""; |
|
| 3804 | + else |
|
| 3805 | + $v_dir_to_check = dirname($p_entry['filename']); |
|
| 3806 | + |
|
| 3807 | + if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) { |
|
| 3808 | + |
|
| 3809 | + // ----- Change the file status |
|
| 3810 | + $p_entry['status'] = "path_creation_fail"; |
|
| 3818 | 3811 | |
| 3819 | - // ----- Look if extraction should be done |
|
| 3820 | - if ($p_entry['status'] == 'ok') { |
|
| 3812 | + // ----- Return |
|
| 3813 | + //return $v_result; |
|
| 3814 | + $v_result = 1; |
|
| 3815 | + } |
|
| 3816 | + } |
|
| 3817 | + } |
|
| 3821 | 3818 | |
| 3822 | - // ----- Do the extraction (if not a folder) |
|
| 3823 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) |
|
| 3824 | - { |
|
| 3825 | - // ----- Look for not compressed file |
|
| 3826 | - if ($p_entry['compression'] == 0) { |
|
| 3819 | + // ----- Look if extraction should be done |
|
| 3820 | + if ($p_entry['status'] == 'ok') { |
|
| 3827 | 3821 | |
| 3828 | - // ----- Opening destination file |
|
| 3829 | - if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) |
|
| 3830 | - { |
|
| 3822 | + // ----- Do the extraction (if not a folder) |
|
| 3823 | + if (!(($p_entry['external']&0x00000010)==0x00000010)) |
|
| 3824 | + { |
|
| 3825 | + // ----- Look for not compressed file |
|
| 3826 | + if ($p_entry['compression'] == 0) { |
|
| 3831 | 3827 | |
| 3832 | - // ----- Change the file status |
|
| 3833 | - $p_entry['status'] = "write_error"; |
|
| 3828 | + // ----- Opening destination file |
|
| 3829 | + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) |
|
| 3830 | + { |
|
| 3834 | 3831 | |
| 3835 | - // ----- Return |
|
| 3836 | - return $v_result; |
|
| 3837 | - } |
|
| 3832 | + // ----- Change the file status |
|
| 3833 | + $p_entry['status'] = "write_error"; |
|
| 3834 | + |
|
| 3835 | + // ----- Return |
|
| 3836 | + return $v_result; |
|
| 3837 | + } |
|
| 3838 | 3838 | |
| 3839 | 3839 | |
| 3840 | - // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 3841 | - $v_size = $p_entry['compressed_size']; |
|
| 3842 | - while ($v_size != 0) |
|
| 3843 | - { |
|
| 3844 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 3845 | - $v_buffer = @fread($this->zip_fd, $v_read_size); |
|
| 3846 | - /* Try to speed up the code |
|
| 3840 | + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 3841 | + $v_size = $p_entry['compressed_size']; |
|
| 3842 | + while ($v_size != 0) |
|
| 3843 | + { |
|
| 3844 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 3845 | + $v_buffer = @fread($this->zip_fd, $v_read_size); |
|
| 3846 | + /* Try to speed up the code |
|
| 3847 | 3847 | $v_binary_data = pack('a'.$v_read_size, $v_buffer); |
| 3848 | 3848 | @fwrite($v_dest_file, $v_binary_data, $v_read_size); |
| 3849 | 3849 | */ |
| 3850 | - @fwrite($v_dest_file, $v_buffer, $v_read_size); |
|
| 3851 | - $v_size -= $v_read_size; |
|
| 3852 | - } |
|
| 3850 | + @fwrite($v_dest_file, $v_buffer, $v_read_size); |
|
| 3851 | + $v_size -= $v_read_size; |
|
| 3852 | + } |
|
| 3853 | 3853 | |
| 3854 | - // ----- Closing the destination file |
|
| 3855 | - fclose($v_dest_file); |
|
| 3854 | + // ----- Closing the destination file |
|
| 3855 | + fclose($v_dest_file); |
|
| 3856 | 3856 | |
| 3857 | - // ----- Change the file mtime |
|
| 3858 | - touch($p_entry['filename'], $p_entry['mtime']); |
|
| 3857 | + // ----- Change the file mtime |
|
| 3858 | + touch($p_entry['filename'], $p_entry['mtime']); |
|
| 3859 | 3859 | |
| 3860 | 3860 | |
| 3861 | - } |
|
| 3862 | - else { |
|
| 3863 | - // ----- TBC |
|
| 3864 | - // Need to be finished |
|
| 3865 | - if (($p_entry['flag'] & 1) == 1) { |
|
| 3866 | - PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.'); |
|
| 3867 | - return PclZip::errorCode(); |
|
| 3868 | - } |
|
| 3861 | + } |
|
| 3862 | + else { |
|
| 3863 | + // ----- TBC |
|
| 3864 | + // Need to be finished |
|
| 3865 | + if (($p_entry['flag'] & 1) == 1) { |
|
| 3866 | + PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.'); |
|
| 3867 | + return PclZip::errorCode(); |
|
| 3868 | + } |
|
| 3869 | 3869 | |
| 3870 | 3870 | |
| 3871 | - // ----- Look for using temporary file to unzip |
|
| 3872 | - if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 3873 | - && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) |
|
| 3874 | - || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
|
| 3875 | - && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) { |
|
| 3876 | - $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options); |
|
| 3877 | - if ($v_result < PCLZIP_ERR_NO_ERROR) { |
|
| 3878 | - return $v_result; |
|
| 3879 | - } |
|
| 3880 | - } |
|
| 3871 | + // ----- Look for using temporary file to unzip |
|
| 3872 | + if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 3873 | + && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) |
|
| 3874 | + || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
|
| 3875 | + && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) { |
|
| 3876 | + $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options); |
|
| 3877 | + if ($v_result < PCLZIP_ERR_NO_ERROR) { |
|
| 3878 | + return $v_result; |
|
| 3879 | + } |
|
| 3880 | + } |
|
| 3881 | 3881 | |
| 3882 | - // ----- Look for extract in memory |
|
| 3883 | - else { |
|
| 3882 | + // ----- Look for extract in memory |
|
| 3883 | + else { |
|
| 3884 | 3884 | |
| 3885 | 3885 | |
| 3886 | - // ----- Read the compressed file in a buffer (one shot) |
|
| 3887 | - $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 3886 | + // ----- Read the compressed file in a buffer (one shot) |
|
| 3887 | + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 3888 | 3888 | |
| 3889 | - // ----- Decompress the file |
|
| 3890 | - $v_file_content = @gzinflate($v_buffer); |
|
| 3891 | - unset($v_buffer); |
|
| 3892 | - if ($v_file_content === FALSE) { |
|
| 3889 | + // ----- Decompress the file |
|
| 3890 | + $v_file_content = @gzinflate($v_buffer); |
|
| 3891 | + unset($v_buffer); |
|
| 3892 | + if ($v_file_content === FALSE) { |
|
| 3893 | 3893 | |
| 3894 | - // ----- Change the file status |
|
| 3895 | - // TBC |
|
| 3896 | - $p_entry['status'] = "error"; |
|
| 3894 | + // ----- Change the file status |
|
| 3895 | + // TBC |
|
| 3896 | + $p_entry['status'] = "error"; |
|
| 3897 | 3897 | |
| 3898 | - return $v_result; |
|
| 3899 | - } |
|
| 3898 | + return $v_result; |
|
| 3899 | + } |
|
| 3900 | 3900 | |
| 3901 | - // ----- Opening destination file |
|
| 3902 | - if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { |
|
| 3901 | + // ----- Opening destination file |
|
| 3902 | + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { |
|
| 3903 | 3903 | |
| 3904 | - // ----- Change the file status |
|
| 3905 | - $p_entry['status'] = "write_error"; |
|
| 3904 | + // ----- Change the file status |
|
| 3905 | + $p_entry['status'] = "write_error"; |
|
| 3906 | 3906 | |
| 3907 | - return $v_result; |
|
| 3908 | - } |
|
| 3907 | + return $v_result; |
|
| 3908 | + } |
|
| 3909 | 3909 | |
| 3910 | - // ----- Write the uncompressed data |
|
| 3911 | - @fwrite($v_dest_file, $v_file_content, $p_entry['size']); |
|
| 3912 | - unset($v_file_content); |
|
| 3910 | + // ----- Write the uncompressed data |
|
| 3911 | + @fwrite($v_dest_file, $v_file_content, $p_entry['size']); |
|
| 3912 | + unset($v_file_content); |
|
| 3913 | 3913 | |
| 3914 | - // ----- Closing the destination file |
|
| 3915 | - @fclose($v_dest_file); |
|
| 3914 | + // ----- Closing the destination file |
|
| 3915 | + @fclose($v_dest_file); |
|
| 3916 | 3916 | |
| 3917 | - } |
|
| 3917 | + } |
|
| 3918 | 3918 | |
| 3919 | - // ----- Change the file mtime |
|
| 3920 | - @touch($p_entry['filename'], $p_entry['mtime']); |
|
| 3921 | - } |
|
| 3919 | + // ----- Change the file mtime |
|
| 3920 | + @touch($p_entry['filename'], $p_entry['mtime']); |
|
| 3921 | + } |
|
| 3922 | 3922 | |
| 3923 | - // ----- Look for chmod option |
|
| 3924 | - if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) { |
|
| 3923 | + // ----- Look for chmod option |
|
| 3924 | + if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) { |
|
| 3925 | 3925 | |
| 3926 | - // ----- Change the mode of the file |
|
| 3927 | - @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]); |
|
| 3928 | - } |
|
| 3926 | + // ----- Change the mode of the file |
|
| 3927 | + @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]); |
|
| 3928 | + } |
|
| 3929 | 3929 | |
| 3930 | - } |
|
| 3931 | - } |
|
| 3930 | + } |
|
| 3931 | + } |
|
| 3932 | 3932 | |
| 3933 | 3933 | // ----- Change abort status |
| 3934 | 3934 | if ($p_entry['status'] == "aborted") { |
| 3935 | - $p_entry['status'] = "skipped"; |
|
| 3935 | + $p_entry['status'] = "skipped"; |
|
| 3936 | 3936 | } |
| 3937 | 3937 | |
| 3938 | - // ----- Look for post-extract callback |
|
| 3939 | - elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { |
|
| 3938 | + // ----- Look for post-extract callback |
|
| 3939 | + elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { |
|
| 3940 | 3940 | |
| 3941 | - // ----- Generate a local information |
|
| 3942 | - $v_local_header = array(); |
|
| 3943 | - $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 3941 | + // ----- Generate a local information |
|
| 3942 | + $v_local_header = array(); |
|
| 3943 | + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 3944 | 3944 | |
| 3945 | - // ----- Call the callback |
|
| 3946 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 3947 | - // header. |
|
| 3948 | - $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); |
|
| 3945 | + // ----- Call the callback |
|
| 3946 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 3947 | + // header. |
|
| 3948 | + $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); |
|
| 3949 | 3949 | |
| 3950 | - // ----- Look for abort result |
|
| 3951 | - if ($v_result == 2) { |
|
| 3952 | - $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 3953 | - } |
|
| 3954 | - } |
|
| 3950 | + // ----- Look for abort result |
|
| 3951 | + if ($v_result == 2) { |
|
| 3952 | + $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 3953 | + } |
|
| 3954 | + } |
|
| 3955 | 3955 | |
| 3956 | - // ----- Return |
|
| 3957 | - return $v_result; |
|
| 3956 | + // ----- Return |
|
| 3957 | + return $v_result; |
|
| 3958 | 3958 | } |
| 3959 | 3959 | // -------------------------------------------------------------------------------- |
| 3960 | 3960 | |
@@ -3966,71 +3966,71 @@ discard block |
||
| 3966 | 3966 | // -------------------------------------------------------------------------------- |
| 3967 | 3967 | function privExtractFileUsingTempFile(&$p_entry, &$p_options) |
| 3968 | 3968 | { |
| 3969 | - $v_result=1; |
|
| 3970 | - |
|
| 3971 | - // ----- Creates a temporary file |
|
| 3972 | - $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz'; |
|
| 3973 | - if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) { |
|
| 3974 | - fclose($v_file); |
|
| 3975 | - PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode'); |
|
| 3976 | - return PclZip::errorCode(); |
|
| 3977 | - } |
|
| 3969 | + $v_result=1; |
|
| 3970 | + |
|
| 3971 | + // ----- Creates a temporary file |
|
| 3972 | + $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz'; |
|
| 3973 | + if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) { |
|
| 3974 | + fclose($v_file); |
|
| 3975 | + PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode'); |
|
| 3976 | + return PclZip::errorCode(); |
|
| 3977 | + } |
|
| 3978 | 3978 | |
| 3979 | 3979 | |
| 3980 | - // ----- Write gz file format header |
|
| 3981 | - $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3)); |
|
| 3982 | - @fwrite($v_dest_file, $v_binary_data, 10); |
|
| 3980 | + // ----- Write gz file format header |
|
| 3981 | + $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3)); |
|
| 3982 | + @fwrite($v_dest_file, $v_binary_data, 10); |
|
| 3983 | 3983 | |
| 3984 | - // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 3985 | - $v_size = $p_entry['compressed_size']; |
|
| 3986 | - while ($v_size != 0) |
|
| 3987 | - { |
|
| 3988 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 3989 | - $v_buffer = @fread($this->zip_fd, $v_read_size); |
|
| 3990 | - //$v_binary_data = pack('a'.$v_read_size, $v_buffer); |
|
| 3991 | - @fwrite($v_dest_file, $v_buffer, $v_read_size); |
|
| 3992 | - $v_size -= $v_read_size; |
|
| 3993 | - } |
|
| 3984 | + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 3985 | + $v_size = $p_entry['compressed_size']; |
|
| 3986 | + while ($v_size != 0) |
|
| 3987 | + { |
|
| 3988 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 3989 | + $v_buffer = @fread($this->zip_fd, $v_read_size); |
|
| 3990 | + //$v_binary_data = pack('a'.$v_read_size, $v_buffer); |
|
| 3991 | + @fwrite($v_dest_file, $v_buffer, $v_read_size); |
|
| 3992 | + $v_size -= $v_read_size; |
|
| 3993 | + } |
|
| 3994 | 3994 | |
| 3995 | - // ----- Write gz file format footer |
|
| 3996 | - $v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']); |
|
| 3997 | - @fwrite($v_dest_file, $v_binary_data, 8); |
|
| 3995 | + // ----- Write gz file format footer |
|
| 3996 | + $v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']); |
|
| 3997 | + @fwrite($v_dest_file, $v_binary_data, 8); |
|
| 3998 | 3998 | |
| 3999 | - // ----- Close the temporary file |
|
| 4000 | - @fclose($v_dest_file); |
|
| 3999 | + // ----- Close the temporary file |
|
| 4000 | + @fclose($v_dest_file); |
|
| 4001 | 4001 | |
| 4002 | - // ----- Opening destination file |
|
| 4003 | - if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { |
|
| 4004 | - $p_entry['status'] = "write_error"; |
|
| 4005 | - return $v_result; |
|
| 4006 | - } |
|
| 4002 | + // ----- Opening destination file |
|
| 4003 | + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { |
|
| 4004 | + $p_entry['status'] = "write_error"; |
|
| 4005 | + return $v_result; |
|
| 4006 | + } |
|
| 4007 | 4007 | |
| 4008 | - // ----- Open the temporary gz file |
|
| 4009 | - if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) { |
|
| 4010 | - @fclose($v_dest_file); |
|
| 4011 | - $p_entry['status'] = "read_error"; |
|
| 4012 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 4013 | - return PclZip::errorCode(); |
|
| 4014 | - } |
|
| 4008 | + // ----- Open the temporary gz file |
|
| 4009 | + if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) { |
|
| 4010 | + @fclose($v_dest_file); |
|
| 4011 | + $p_entry['status'] = "read_error"; |
|
| 4012 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); |
|
| 4013 | + return PclZip::errorCode(); |
|
| 4014 | + } |
|
| 4015 | 4015 | |
| 4016 | 4016 | |
| 4017 | - // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 4018 | - $v_size = $p_entry['size']; |
|
| 4019 | - while ($v_size != 0) { |
|
| 4020 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 4021 | - $v_buffer = @gzread($v_src_file, $v_read_size); |
|
| 4022 | - //$v_binary_data = pack('a'.$v_read_size, $v_buffer); |
|
| 4023 | - @fwrite($v_dest_file, $v_buffer, $v_read_size); |
|
| 4024 | - $v_size -= $v_read_size; |
|
| 4025 | - } |
|
| 4026 | - @fclose($v_dest_file); |
|
| 4027 | - @gzclose($v_src_file); |
|
| 4017 | + // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks |
|
| 4018 | + $v_size = $p_entry['size']; |
|
| 4019 | + while ($v_size != 0) { |
|
| 4020 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 4021 | + $v_buffer = @gzread($v_src_file, $v_read_size); |
|
| 4022 | + //$v_binary_data = pack('a'.$v_read_size, $v_buffer); |
|
| 4023 | + @fwrite($v_dest_file, $v_buffer, $v_read_size); |
|
| 4024 | + $v_size -= $v_read_size; |
|
| 4025 | + } |
|
| 4026 | + @fclose($v_dest_file); |
|
| 4027 | + @gzclose($v_src_file); |
|
| 4028 | 4028 | |
| 4029 | - // ----- Delete the temporary file |
|
| 4030 | - @unlink($v_gzip_temp_name); |
|
| 4029 | + // ----- Delete the temporary file |
|
| 4030 | + @unlink($v_gzip_temp_name); |
|
| 4031 | 4031 | |
| 4032 | - // ----- Return |
|
| 4033 | - return $v_result; |
|
| 4032 | + // ----- Return |
|
| 4033 | + return $v_result; |
|
| 4034 | 4034 | } |
| 4035 | 4035 | // -------------------------------------------------------------------------------- |
| 4036 | 4036 | |
@@ -4042,106 +4042,106 @@ discard block |
||
| 4042 | 4042 | // -------------------------------------------------------------------------------- |
| 4043 | 4043 | function privExtractFileInOutput(&$p_entry, &$p_options) |
| 4044 | 4044 | { |
| 4045 | - $v_result=1; |
|
| 4045 | + $v_result=1; |
|
| 4046 | 4046 | |
| 4047 | - // ----- Read the file header |
|
| 4048 | - if (($v_result = $this->privReadFileHeader($v_header)) != 1) { |
|
| 4049 | - return $v_result; |
|
| 4050 | - } |
|
| 4047 | + // ----- Read the file header |
|
| 4048 | + if (($v_result = $this->privReadFileHeader($v_header)) != 1) { |
|
| 4049 | + return $v_result; |
|
| 4050 | + } |
|
| 4051 | 4051 | |
| 4052 | 4052 | |
| 4053 | - // ----- Check that the file header is coherent with $p_entry info |
|
| 4054 | - if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { |
|
| 4055 | - // TBC |
|
| 4056 | - } |
|
| 4053 | + // ----- Check that the file header is coherent with $p_entry info |
|
| 4054 | + if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { |
|
| 4055 | + // TBC |
|
| 4056 | + } |
|
| 4057 | 4057 | |
| 4058 | - // ----- Look for pre-extract callback |
|
| 4059 | - if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { |
|
| 4058 | + // ----- Look for pre-extract callback |
|
| 4059 | + if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { |
|
| 4060 | 4060 | |
| 4061 | - // ----- Generate a local information |
|
| 4062 | - $v_local_header = array(); |
|
| 4063 | - $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4061 | + // ----- Generate a local information |
|
| 4062 | + $v_local_header = array(); |
|
| 4063 | + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4064 | 4064 | |
| 4065 | - // ----- Call the callback |
|
| 4066 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4067 | - // header. |
|
| 4065 | + // ----- Call the callback |
|
| 4066 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4067 | + // header. |
|
| 4068 | 4068 | // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'); |
| 4069 | - $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); |
|
| 4070 | - if ($v_result == 0) { |
|
| 4071 | - // ----- Change the file status |
|
| 4072 | - $p_entry['status'] = "skipped"; |
|
| 4073 | - $v_result = 1; |
|
| 4074 | - } |
|
| 4069 | + $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); |
|
| 4070 | + if ($v_result == 0) { |
|
| 4071 | + // ----- Change the file status |
|
| 4072 | + $p_entry['status'] = "skipped"; |
|
| 4073 | + $v_result = 1; |
|
| 4074 | + } |
|
| 4075 | 4075 | |
| 4076 | - // ----- Look for abort result |
|
| 4077 | - if ($v_result == 2) { |
|
| 4078 | - // ----- This status is internal and will be changed in 'skipped' |
|
| 4079 | - $p_entry['status'] = "aborted"; |
|
| 4080 | - $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4081 | - } |
|
| 4076 | + // ----- Look for abort result |
|
| 4077 | + if ($v_result == 2) { |
|
| 4078 | + // ----- This status is internal and will be changed in 'skipped' |
|
| 4079 | + $p_entry['status'] = "aborted"; |
|
| 4080 | + $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4081 | + } |
|
| 4082 | 4082 | |
| 4083 | - // ----- Update the informations |
|
| 4084 | - // Only some fields can be modified |
|
| 4085 | - $p_entry['filename'] = $v_local_header['filename']; |
|
| 4086 | - } |
|
| 4083 | + // ----- Update the informations |
|
| 4084 | + // Only some fields can be modified |
|
| 4085 | + $p_entry['filename'] = $v_local_header['filename']; |
|
| 4086 | + } |
|
| 4087 | 4087 | |
| 4088 | - // ----- Trace |
|
| 4088 | + // ----- Trace |
|
| 4089 | 4089 | |
| 4090 | - // ----- Look if extraction should be done |
|
| 4091 | - if ($p_entry['status'] == 'ok') { |
|
| 4090 | + // ----- Look if extraction should be done |
|
| 4091 | + if ($p_entry['status'] == 'ok') { |
|
| 4092 | 4092 | |
| 4093 | - // ----- Do the extraction (if not a folder) |
|
| 4094 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
|
| 4095 | - // ----- Look for not compressed file |
|
| 4096 | - if ($p_entry['compressed_size'] == $p_entry['size']) { |
|
| 4093 | + // ----- Do the extraction (if not a folder) |
|
| 4094 | + if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
|
| 4095 | + // ----- Look for not compressed file |
|
| 4096 | + if ($p_entry['compressed_size'] == $p_entry['size']) { |
|
| 4097 | 4097 | |
| 4098 | - // ----- Read the file in a buffer (one shot) |
|
| 4099 | - $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4098 | + // ----- Read the file in a buffer (one shot) |
|
| 4099 | + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4100 | 4100 | |
| 4101 | - // ----- Send the file to the output |
|
| 4102 | - echo $v_buffer; |
|
| 4103 | - unset($v_buffer); |
|
| 4104 | - } |
|
| 4105 | - else { |
|
| 4101 | + // ----- Send the file to the output |
|
| 4102 | + echo $v_buffer; |
|
| 4103 | + unset($v_buffer); |
|
| 4104 | + } |
|
| 4105 | + else { |
|
| 4106 | 4106 | |
| 4107 | - // ----- Read the compressed file in a buffer (one shot) |
|
| 4108 | - $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4107 | + // ----- Read the compressed file in a buffer (one shot) |
|
| 4108 | + $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4109 | 4109 | |
| 4110 | - // ----- Decompress the file |
|
| 4111 | - $v_file_content = gzinflate($v_buffer); |
|
| 4112 | - unset($v_buffer); |
|
| 4110 | + // ----- Decompress the file |
|
| 4111 | + $v_file_content = gzinflate($v_buffer); |
|
| 4112 | + unset($v_buffer); |
|
| 4113 | 4113 | |
| 4114 | - // ----- Send the file to the output |
|
| 4115 | - echo $v_file_content; |
|
| 4116 | - unset($v_file_content); |
|
| 4117 | - } |
|
| 4118 | - } |
|
| 4119 | - } |
|
| 4114 | + // ----- Send the file to the output |
|
| 4115 | + echo $v_file_content; |
|
| 4116 | + unset($v_file_content); |
|
| 4117 | + } |
|
| 4118 | + } |
|
| 4119 | + } |
|
| 4120 | 4120 | |
| 4121 | 4121 | // ----- Change abort status |
| 4122 | 4122 | if ($p_entry['status'] == "aborted") { |
| 4123 | - $p_entry['status'] = "skipped"; |
|
| 4123 | + $p_entry['status'] = "skipped"; |
|
| 4124 | 4124 | } |
| 4125 | 4125 | |
| 4126 | - // ----- Look for post-extract callback |
|
| 4127 | - elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { |
|
| 4126 | + // ----- Look for post-extract callback |
|
| 4127 | + elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { |
|
| 4128 | 4128 | |
| 4129 | - // ----- Generate a local information |
|
| 4130 | - $v_local_header = array(); |
|
| 4131 | - $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4129 | + // ----- Generate a local information |
|
| 4130 | + $v_local_header = array(); |
|
| 4131 | + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4132 | 4132 | |
| 4133 | - // ----- Call the callback |
|
| 4134 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4135 | - // header. |
|
| 4136 | - $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); |
|
| 4133 | + // ----- Call the callback |
|
| 4134 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4135 | + // header. |
|
| 4136 | + $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); |
|
| 4137 | 4137 | |
| 4138 | - // ----- Look for abort result |
|
| 4139 | - if ($v_result == 2) { |
|
| 4140 | - $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4141 | - } |
|
| 4142 | - } |
|
| 4138 | + // ----- Look for abort result |
|
| 4139 | + if ($v_result == 2) { |
|
| 4140 | + $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4141 | + } |
|
| 4142 | + } |
|
| 4143 | 4143 | |
| 4144 | - return $v_result; |
|
| 4144 | + return $v_result; |
|
| 4145 | 4145 | } |
| 4146 | 4146 | // -------------------------------------------------------------------------------- |
| 4147 | 4147 | |
@@ -4153,116 +4153,116 @@ discard block |
||
| 4153 | 4153 | // -------------------------------------------------------------------------------- |
| 4154 | 4154 | function privExtractFileAsString(&$p_entry, &$p_string, &$p_options) |
| 4155 | 4155 | { |
| 4156 | - $v_result=1; |
|
| 4157 | - |
|
| 4158 | - // ----- Read the file header |
|
| 4159 | - $v_header = array(); |
|
| 4160 | - if (($v_result = $this->privReadFileHeader($v_header)) != 1) |
|
| 4161 | - { |
|
| 4162 | - // ----- Return |
|
| 4163 | - return $v_result; |
|
| 4164 | - } |
|
| 4156 | + $v_result=1; |
|
| 4157 | + |
|
| 4158 | + // ----- Read the file header |
|
| 4159 | + $v_header = array(); |
|
| 4160 | + if (($v_result = $this->privReadFileHeader($v_header)) != 1) |
|
| 4161 | + { |
|
| 4162 | + // ----- Return |
|
| 4163 | + return $v_result; |
|
| 4164 | + } |
|
| 4165 | 4165 | |
| 4166 | 4166 | |
| 4167 | - // ----- Check that the file header is coherent with $p_entry info |
|
| 4168 | - if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { |
|
| 4169 | - // TBC |
|
| 4170 | - } |
|
| 4167 | + // ----- Check that the file header is coherent with $p_entry info |
|
| 4168 | + if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { |
|
| 4169 | + // TBC |
|
| 4170 | + } |
|
| 4171 | 4171 | |
| 4172 | - // ----- Look for pre-extract callback |
|
| 4173 | - if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { |
|
| 4174 | - |
|
| 4175 | - // ----- Generate a local information |
|
| 4176 | - $v_local_header = array(); |
|
| 4177 | - $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4178 | - |
|
| 4179 | - // ----- Call the callback |
|
| 4180 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4181 | - // header. |
|
| 4182 | - $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); |
|
| 4183 | - if ($v_result == 0) { |
|
| 4184 | - // ----- Change the file status |
|
| 4185 | - $p_entry['status'] = "skipped"; |
|
| 4186 | - $v_result = 1; |
|
| 4187 | - } |
|
| 4172 | + // ----- Look for pre-extract callback |
|
| 4173 | + if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { |
|
| 4174 | + |
|
| 4175 | + // ----- Generate a local information |
|
| 4176 | + $v_local_header = array(); |
|
| 4177 | + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4178 | + |
|
| 4179 | + // ----- Call the callback |
|
| 4180 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4181 | + // header. |
|
| 4182 | + $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); |
|
| 4183 | + if ($v_result == 0) { |
|
| 4184 | + // ----- Change the file status |
|
| 4185 | + $p_entry['status'] = "skipped"; |
|
| 4186 | + $v_result = 1; |
|
| 4187 | + } |
|
| 4188 | 4188 | |
| 4189 | - // ----- Look for abort result |
|
| 4190 | - if ($v_result == 2) { |
|
| 4191 | - // ----- This status is internal and will be changed in 'skipped' |
|
| 4192 | - $p_entry['status'] = "aborted"; |
|
| 4193 | - $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4194 | - } |
|
| 4189 | + // ----- Look for abort result |
|
| 4190 | + if ($v_result == 2) { |
|
| 4191 | + // ----- This status is internal and will be changed in 'skipped' |
|
| 4192 | + $p_entry['status'] = "aborted"; |
|
| 4193 | + $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4194 | + } |
|
| 4195 | 4195 | |
| 4196 | - // ----- Update the informations |
|
| 4197 | - // Only some fields can be modified |
|
| 4198 | - $p_entry['filename'] = $v_local_header['filename']; |
|
| 4199 | - } |
|
| 4196 | + // ----- Update the informations |
|
| 4197 | + // Only some fields can be modified |
|
| 4198 | + $p_entry['filename'] = $v_local_header['filename']; |
|
| 4199 | + } |
|
| 4200 | 4200 | |
| 4201 | 4201 | |
| 4202 | - // ----- Look if extraction should be done |
|
| 4203 | - if ($p_entry['status'] == 'ok') { |
|
| 4202 | + // ----- Look if extraction should be done |
|
| 4203 | + if ($p_entry['status'] == 'ok') { |
|
| 4204 | 4204 | |
| 4205 | - // ----- Do the extraction (if not a folder) |
|
| 4206 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
|
| 4207 | - // ----- Look for not compressed file |
|
| 4205 | + // ----- Do the extraction (if not a folder) |
|
| 4206 | + if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
|
| 4207 | + // ----- Look for not compressed file |
|
| 4208 | 4208 | // if ($p_entry['compressed_size'] == $p_entry['size']) |
| 4209 | - if ($p_entry['compression'] == 0) { |
|
| 4209 | + if ($p_entry['compression'] == 0) { |
|
| 4210 | 4210 | |
| 4211 | - // ----- Reading the file |
|
| 4212 | - $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4213 | - } |
|
| 4214 | - else { |
|
| 4211 | + // ----- Reading the file |
|
| 4212 | + $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4213 | + } |
|
| 4214 | + else { |
|
| 4215 | 4215 | |
| 4216 | - // ----- Reading the file |
|
| 4217 | - $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4216 | + // ----- Reading the file |
|
| 4217 | + $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); |
|
| 4218 | 4218 | |
| 4219 | - // ----- Decompress the file |
|
| 4220 | - if (($p_string = @gzinflate($v_data)) === FALSE) { |
|
| 4221 | - // TBC |
|
| 4222 | - } |
|
| 4223 | - } |
|
| 4219 | + // ----- Decompress the file |
|
| 4220 | + if (($p_string = @gzinflate($v_data)) === FALSE) { |
|
| 4221 | + // TBC |
|
| 4222 | + } |
|
| 4223 | + } |
|
| 4224 | 4224 | |
| 4225 | - // ----- Trace |
|
| 4226 | - } |
|
| 4227 | - else { |
|
| 4228 | - // TBC : error : can not extract a folder in a string |
|
| 4229 | - } |
|
| 4225 | + // ----- Trace |
|
| 4226 | + } |
|
| 4227 | + else { |
|
| 4228 | + // TBC : error : can not extract a folder in a string |
|
| 4229 | + } |
|
| 4230 | 4230 | |
| 4231 | - } |
|
| 4231 | + } |
|
| 4232 | 4232 | |
| 4233 | 4233 | // ----- Change abort status |
| 4234 | 4234 | if ($p_entry['status'] == "aborted") { |
| 4235 | - $p_entry['status'] = "skipped"; |
|
| 4235 | + $p_entry['status'] = "skipped"; |
|
| 4236 | 4236 | } |
| 4237 | 4237 | |
| 4238 | - // ----- Look for post-extract callback |
|
| 4239 | - elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { |
|
| 4238 | + // ----- Look for post-extract callback |
|
| 4239 | + elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { |
|
| 4240 | 4240 | |
| 4241 | - // ----- Generate a local information |
|
| 4242 | - $v_local_header = array(); |
|
| 4243 | - $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4241 | + // ----- Generate a local information |
|
| 4242 | + $v_local_header = array(); |
|
| 4243 | + $this->privConvertHeader2FileInfo($p_entry, $v_local_header); |
|
| 4244 | 4244 | |
| 4245 | - // ----- Swap the content to header |
|
| 4246 | - $v_local_header['content'] = $p_string; |
|
| 4247 | - $p_string = ''; |
|
| 4245 | + // ----- Swap the content to header |
|
| 4246 | + $v_local_header['content'] = $p_string; |
|
| 4247 | + $p_string = ''; |
|
| 4248 | 4248 | |
| 4249 | - // ----- Call the callback |
|
| 4250 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4251 | - // header. |
|
| 4252 | - $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); |
|
| 4249 | + // ----- Call the callback |
|
| 4250 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 4251 | + // header. |
|
| 4252 | + $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); |
|
| 4253 | 4253 | |
| 4254 | - // ----- Swap back the content to header |
|
| 4255 | - $p_string = $v_local_header['content']; |
|
| 4256 | - unset($v_local_header['content']); |
|
| 4254 | + // ----- Swap back the content to header |
|
| 4255 | + $p_string = $v_local_header['content']; |
|
| 4256 | + unset($v_local_header['content']); |
|
| 4257 | 4257 | |
| 4258 | - // ----- Look for abort result |
|
| 4259 | - if ($v_result == 2) { |
|
| 4260 | - $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4261 | - } |
|
| 4262 | - } |
|
| 4258 | + // ----- Look for abort result |
|
| 4259 | + if ($v_result == 2) { |
|
| 4260 | + $v_result = PCLZIP_ERR_USER_ABORTED; |
|
| 4261 | + } |
|
| 4262 | + } |
|
| 4263 | 4263 | |
| 4264 | - // ----- Return |
|
| 4265 | - return $v_result; |
|
| 4264 | + // ----- Return |
|
| 4265 | + return $v_result; |
|
| 4266 | 4266 | } |
| 4267 | 4267 | // -------------------------------------------------------------------------------- |
| 4268 | 4268 | |
@@ -4274,98 +4274,98 @@ discard block |
||
| 4274 | 4274 | // -------------------------------------------------------------------------------- |
| 4275 | 4275 | function privReadFileHeader(&$p_header) |
| 4276 | 4276 | { |
| 4277 | - $v_result=1; |
|
| 4277 | + $v_result=1; |
|
| 4278 | 4278 | |
| 4279 | - // ----- Read the 4 bytes signature |
|
| 4280 | - $v_binary_data = @fread($this->zip_fd, 4); |
|
| 4281 | - $v_data = unpack('Vid', $v_binary_data); |
|
| 4279 | + // ----- Read the 4 bytes signature |
|
| 4280 | + $v_binary_data = @fread($this->zip_fd, 4); |
|
| 4281 | + $v_data = unpack('Vid', $v_binary_data); |
|
| 4282 | 4282 | |
| 4283 | - // ----- Check signature |
|
| 4284 | - if ($v_data['id'] != 0x04034b50) |
|
| 4285 | - { |
|
| 4283 | + // ----- Check signature |
|
| 4284 | + if ($v_data['id'] != 0x04034b50) |
|
| 4285 | + { |
|
| 4286 | 4286 | |
| 4287 | - // ----- Error log |
|
| 4288 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
| 4287 | + // ----- Error log |
|
| 4288 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
| 4289 | 4289 | |
| 4290 | - // ----- Return |
|
| 4291 | - return PclZip::errorCode(); |
|
| 4292 | - } |
|
| 4290 | + // ----- Return |
|
| 4291 | + return PclZip::errorCode(); |
|
| 4292 | + } |
|
| 4293 | 4293 | |
| 4294 | - // ----- Read the first 42 bytes of the header |
|
| 4295 | - $v_binary_data = fread($this->zip_fd, 26); |
|
| 4294 | + // ----- Read the first 42 bytes of the header |
|
| 4295 | + $v_binary_data = fread($this->zip_fd, 26); |
|
| 4296 | 4296 | |
| 4297 | - // ----- Look for invalid block size |
|
| 4298 | - if (strlen($v_binary_data) != 26) |
|
| 4299 | - { |
|
| 4300 | - $p_header['filename'] = ""; |
|
| 4301 | - $p_header['status'] = "invalid_header"; |
|
| 4297 | + // ----- Look for invalid block size |
|
| 4298 | + if (strlen($v_binary_data) != 26) |
|
| 4299 | + { |
|
| 4300 | + $p_header['filename'] = ""; |
|
| 4301 | + $p_header['status'] = "invalid_header"; |
|
| 4302 | 4302 | |
| 4303 | - // ----- Error log |
|
| 4304 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); |
|
| 4303 | + // ----- Error log |
|
| 4304 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); |
|
| 4305 | 4305 | |
| 4306 | - // ----- Return |
|
| 4307 | - return PclZip::errorCode(); |
|
| 4308 | - } |
|
| 4306 | + // ----- Return |
|
| 4307 | + return PclZip::errorCode(); |
|
| 4308 | + } |
|
| 4309 | 4309 | |
| 4310 | - // ----- Extract the values |
|
| 4311 | - $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data); |
|
| 4310 | + // ----- Extract the values |
|
| 4311 | + $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data); |
|
| 4312 | 4312 | |
| 4313 | - // ----- Get filename |
|
| 4314 | - $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']); |
|
| 4313 | + // ----- Get filename |
|
| 4314 | + $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']); |
|
| 4315 | 4315 | |
| 4316 | - // ----- Get extra_fields |
|
| 4317 | - if ($v_data['extra_len'] != 0) { |
|
| 4318 | - $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']); |
|
| 4319 | - } |
|
| 4320 | - else { |
|
| 4321 | - $p_header['extra'] = ''; |
|
| 4322 | - } |
|
| 4316 | + // ----- Get extra_fields |
|
| 4317 | + if ($v_data['extra_len'] != 0) { |
|
| 4318 | + $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']); |
|
| 4319 | + } |
|
| 4320 | + else { |
|
| 4321 | + $p_header['extra'] = ''; |
|
| 4322 | + } |
|
| 4323 | 4323 | |
| 4324 | - // ----- Extract properties |
|
| 4325 | - $p_header['version_extracted'] = $v_data['version']; |
|
| 4326 | - $p_header['compression'] = $v_data['compression']; |
|
| 4327 | - $p_header['size'] = $v_data['size']; |
|
| 4328 | - $p_header['compressed_size'] = $v_data['compressed_size']; |
|
| 4329 | - $p_header['crc'] = $v_data['crc']; |
|
| 4330 | - $p_header['flag'] = $v_data['flag']; |
|
| 4331 | - $p_header['filename_len'] = $v_data['filename_len']; |
|
| 4332 | - |
|
| 4333 | - // ----- Recuperate date in UNIX format |
|
| 4334 | - $p_header['mdate'] = $v_data['mdate']; |
|
| 4335 | - $p_header['mtime'] = $v_data['mtime']; |
|
| 4336 | - if ($p_header['mdate'] && $p_header['mtime']) |
|
| 4337 | - { |
|
| 4338 | - // ----- Extract time |
|
| 4339 | - $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
| 4340 | - $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
|
| 4341 | - $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 4342 | - |
|
| 4343 | - // ----- Extract date |
|
| 4344 | - $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
| 4345 | - $v_month = ($p_header['mdate'] & 0x01E0) >> 5; |
|
| 4346 | - $v_day = $p_header['mdate'] & 0x001F; |
|
| 4347 | - |
|
| 4348 | - // ----- Get UNIX date format |
|
| 4349 | - $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
| 4324 | + // ----- Extract properties |
|
| 4325 | + $p_header['version_extracted'] = $v_data['version']; |
|
| 4326 | + $p_header['compression'] = $v_data['compression']; |
|
| 4327 | + $p_header['size'] = $v_data['size']; |
|
| 4328 | + $p_header['compressed_size'] = $v_data['compressed_size']; |
|
| 4329 | + $p_header['crc'] = $v_data['crc']; |
|
| 4330 | + $p_header['flag'] = $v_data['flag']; |
|
| 4331 | + $p_header['filename_len'] = $v_data['filename_len']; |
|
| 4332 | + |
|
| 4333 | + // ----- Recuperate date in UNIX format |
|
| 4334 | + $p_header['mdate'] = $v_data['mdate']; |
|
| 4335 | + $p_header['mtime'] = $v_data['mtime']; |
|
| 4336 | + if ($p_header['mdate'] && $p_header['mtime']) |
|
| 4337 | + { |
|
| 4338 | + // ----- Extract time |
|
| 4339 | + $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
| 4340 | + $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
|
| 4341 | + $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 4342 | + |
|
| 4343 | + // ----- Extract date |
|
| 4344 | + $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
| 4345 | + $v_month = ($p_header['mdate'] & 0x01E0) >> 5; |
|
| 4346 | + $v_day = $p_header['mdate'] & 0x001F; |
|
| 4347 | + |
|
| 4348 | + // ----- Get UNIX date format |
|
| 4349 | + $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
| 4350 | 4350 | |
| 4351 | - } |
|
| 4352 | - else |
|
| 4353 | - { |
|
| 4354 | - $p_header['mtime'] = time(); |
|
| 4355 | - } |
|
| 4351 | + } |
|
| 4352 | + else |
|
| 4353 | + { |
|
| 4354 | + $p_header['mtime'] = time(); |
|
| 4355 | + } |
|
| 4356 | 4356 | |
| 4357 | - // TBC |
|
| 4358 | - //for(reset($v_data); $key = key($v_data); next($v_data)) { |
|
| 4359 | - //} |
|
| 4357 | + // TBC |
|
| 4358 | + //for(reset($v_data); $key = key($v_data); next($v_data)) { |
|
| 4359 | + //} |
|
| 4360 | 4360 | |
| 4361 | - // ----- Set the stored filename |
|
| 4362 | - $p_header['stored_filename'] = $p_header['filename']; |
|
| 4361 | + // ----- Set the stored filename |
|
| 4362 | + $p_header['stored_filename'] = $p_header['filename']; |
|
| 4363 | 4363 | |
| 4364 | - // ----- Set the status field |
|
| 4365 | - $p_header['status'] = "ok"; |
|
| 4364 | + // ----- Set the status field |
|
| 4365 | + $p_header['status'] = "ok"; |
|
| 4366 | 4366 | |
| 4367 | - // ----- Return |
|
| 4368 | - return $v_result; |
|
| 4367 | + // ----- Return |
|
| 4368 | + return $v_result; |
|
| 4369 | 4369 | } |
| 4370 | 4370 | // -------------------------------------------------------------------------------- |
| 4371 | 4371 | |
@@ -4377,101 +4377,101 @@ discard block |
||
| 4377 | 4377 | // -------------------------------------------------------------------------------- |
| 4378 | 4378 | function privReadCentralFileHeader(&$p_header) |
| 4379 | 4379 | { |
| 4380 | - $v_result=1; |
|
| 4380 | + $v_result=1; |
|
| 4381 | 4381 | |
| 4382 | - // ----- Read the 4 bytes signature |
|
| 4383 | - $v_binary_data = @fread($this->zip_fd, 4); |
|
| 4384 | - $v_data = unpack('Vid', $v_binary_data); |
|
| 4382 | + // ----- Read the 4 bytes signature |
|
| 4383 | + $v_binary_data = @fread($this->zip_fd, 4); |
|
| 4384 | + $v_data = unpack('Vid', $v_binary_data); |
|
| 4385 | 4385 | |
| 4386 | - // ----- Check signature |
|
| 4387 | - if ($v_data['id'] != 0x02014b50) |
|
| 4388 | - { |
|
| 4386 | + // ----- Check signature |
|
| 4387 | + if ($v_data['id'] != 0x02014b50) |
|
| 4388 | + { |
|
| 4389 | 4389 | |
| 4390 | - // ----- Error log |
|
| 4391 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
| 4390 | + // ----- Error log |
|
| 4391 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
| 4392 | 4392 | |
| 4393 | - // ----- Return |
|
| 4394 | - return PclZip::errorCode(); |
|
| 4395 | - } |
|
| 4393 | + // ----- Return |
|
| 4394 | + return PclZip::errorCode(); |
|
| 4395 | + } |
|
| 4396 | 4396 | |
| 4397 | - // ----- Read the first 42 bytes of the header |
|
| 4398 | - $v_binary_data = fread($this->zip_fd, 42); |
|
| 4397 | + // ----- Read the first 42 bytes of the header |
|
| 4398 | + $v_binary_data = fread($this->zip_fd, 42); |
|
| 4399 | 4399 | |
| 4400 | - // ----- Look for invalid block size |
|
| 4401 | - if (strlen($v_binary_data) != 42) |
|
| 4402 | - { |
|
| 4403 | - $p_header['filename'] = ""; |
|
| 4404 | - $p_header['status'] = "invalid_header"; |
|
| 4400 | + // ----- Look for invalid block size |
|
| 4401 | + if (strlen($v_binary_data) != 42) |
|
| 4402 | + { |
|
| 4403 | + $p_header['filename'] = ""; |
|
| 4404 | + $p_header['status'] = "invalid_header"; |
|
| 4405 | 4405 | |
| 4406 | - // ----- Error log |
|
| 4407 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); |
|
| 4406 | + // ----- Error log |
|
| 4407 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); |
|
| 4408 | 4408 | |
| 4409 | - // ----- Return |
|
| 4410 | - return PclZip::errorCode(); |
|
| 4411 | - } |
|
| 4409 | + // ----- Return |
|
| 4410 | + return PclZip::errorCode(); |
|
| 4411 | + } |
|
| 4412 | 4412 | |
| 4413 | - // ----- Extract the values |
|
| 4414 | - $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data); |
|
| 4415 | - |
|
| 4416 | - // ----- Get filename |
|
| 4417 | - if ($p_header['filename_len'] != 0) |
|
| 4418 | - $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']); |
|
| 4419 | - else |
|
| 4420 | - $p_header['filename'] = ''; |
|
| 4421 | - |
|
| 4422 | - // ----- Get extra |
|
| 4423 | - if ($p_header['extra_len'] != 0) |
|
| 4424 | - $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); |
|
| 4425 | - else |
|
| 4426 | - $p_header['extra'] = ''; |
|
| 4427 | - |
|
| 4428 | - // ----- Get comment |
|
| 4429 | - if ($p_header['comment_len'] != 0) |
|
| 4430 | - $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); |
|
| 4431 | - else |
|
| 4432 | - $p_header['comment'] = ''; |
|
| 4433 | - |
|
| 4434 | - // ----- Extract properties |
|
| 4435 | - |
|
| 4436 | - // ----- Recuperate date in UNIX format |
|
| 4437 | - //if ($p_header['mdate'] && $p_header['mtime']) |
|
| 4438 | - // TBC : bug : this was ignoring time with 0/0/0 |
|
| 4439 | - if (1) |
|
| 4440 | - { |
|
| 4441 | - // ----- Extract time |
|
| 4442 | - $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
| 4443 | - $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
|
| 4444 | - $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 4445 | - |
|
| 4446 | - // ----- Extract date |
|
| 4447 | - $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
| 4448 | - $v_month = ($p_header['mdate'] & 0x01E0) >> 5; |
|
| 4449 | - $v_day = $p_header['mdate'] & 0x001F; |
|
| 4450 | - |
|
| 4451 | - // ----- Get UNIX date format |
|
| 4452 | - $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
| 4413 | + // ----- Extract the values |
|
| 4414 | + $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data); |
|
| 4415 | + |
|
| 4416 | + // ----- Get filename |
|
| 4417 | + if ($p_header['filename_len'] != 0) |
|
| 4418 | + $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']); |
|
| 4419 | + else |
|
| 4420 | + $p_header['filename'] = ''; |
|
| 4421 | + |
|
| 4422 | + // ----- Get extra |
|
| 4423 | + if ($p_header['extra_len'] != 0) |
|
| 4424 | + $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); |
|
| 4425 | + else |
|
| 4426 | + $p_header['extra'] = ''; |
|
| 4427 | + |
|
| 4428 | + // ----- Get comment |
|
| 4429 | + if ($p_header['comment_len'] != 0) |
|
| 4430 | + $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); |
|
| 4431 | + else |
|
| 4432 | + $p_header['comment'] = ''; |
|
| 4433 | + |
|
| 4434 | + // ----- Extract properties |
|
| 4435 | + |
|
| 4436 | + // ----- Recuperate date in UNIX format |
|
| 4437 | + //if ($p_header['mdate'] && $p_header['mtime']) |
|
| 4438 | + // TBC : bug : this was ignoring time with 0/0/0 |
|
| 4439 | + if (1) |
|
| 4440 | + { |
|
| 4441 | + // ----- Extract time |
|
| 4442 | + $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
| 4443 | + $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
|
| 4444 | + $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 4445 | + |
|
| 4446 | + // ----- Extract date |
|
| 4447 | + $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
| 4448 | + $v_month = ($p_header['mdate'] & 0x01E0) >> 5; |
|
| 4449 | + $v_day = $p_header['mdate'] & 0x001F; |
|
| 4450 | + |
|
| 4451 | + // ----- Get UNIX date format |
|
| 4452 | + $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
| 4453 | 4453 | |
| 4454 | - } |
|
| 4455 | - else |
|
| 4456 | - { |
|
| 4457 | - $p_header['mtime'] = time(); |
|
| 4458 | - } |
|
| 4454 | + } |
|
| 4455 | + else |
|
| 4456 | + { |
|
| 4457 | + $p_header['mtime'] = time(); |
|
| 4458 | + } |
|
| 4459 | 4459 | |
| 4460 | - // ----- Set the stored filename |
|
| 4461 | - $p_header['stored_filename'] = $p_header['filename']; |
|
| 4460 | + // ----- Set the stored filename |
|
| 4461 | + $p_header['stored_filename'] = $p_header['filename']; |
|
| 4462 | 4462 | |
| 4463 | - // ----- Set default status to ok |
|
| 4464 | - $p_header['status'] = 'ok'; |
|
| 4463 | + // ----- Set default status to ok |
|
| 4464 | + $p_header['status'] = 'ok'; |
|
| 4465 | 4465 | |
| 4466 | - // ----- Look if it is a directory |
|
| 4467 | - if (substr($p_header['filename'], -1) == '/') { |
|
| 4468 | - //$p_header['external'] = 0x41FF0010; |
|
| 4469 | - $p_header['external'] = 0x00000010; |
|
| 4470 | - } |
|
| 4466 | + // ----- Look if it is a directory |
|
| 4467 | + if (substr($p_header['filename'], -1) == '/') { |
|
| 4468 | + //$p_header['external'] = 0x41FF0010; |
|
| 4469 | + $p_header['external'] = 0x00000010; |
|
| 4470 | + } |
|
| 4471 | 4471 | |
| 4472 | 4472 | |
| 4473 | - // ----- Return |
|
| 4474 | - return $v_result; |
|
| 4473 | + // ----- Return |
|
| 4474 | + return $v_result; |
|
| 4475 | 4475 | } |
| 4476 | 4476 | // -------------------------------------------------------------------------------- |
| 4477 | 4477 | |
@@ -4485,7 +4485,7 @@ discard block |
||
| 4485 | 4485 | // -------------------------------------------------------------------------------- |
| 4486 | 4486 | function privCheckFileHeaders(&$p_local_header, &$p_central_header) |
| 4487 | 4487 | { |
| 4488 | - $v_result=1; |
|
| 4488 | + $v_result=1; |
|
| 4489 | 4489 | |
| 4490 | 4490 | // ----- Check the static values |
| 4491 | 4491 | // TBC |
@@ -4504,13 +4504,13 @@ discard block |
||
| 4504 | 4504 | |
| 4505 | 4505 | // ----- Look for flag bit 3 |
| 4506 | 4506 | if (($p_local_header['flag'] & 8) == 8) { |
| 4507 | - $p_local_header['size'] = $p_central_header['size']; |
|
| 4508 | - $p_local_header['compressed_size'] = $p_central_header['compressed_size']; |
|
| 4509 | - $p_local_header['crc'] = $p_central_header['crc']; |
|
| 4507 | + $p_local_header['size'] = $p_central_header['size']; |
|
| 4508 | + $p_local_header['compressed_size'] = $p_central_header['compressed_size']; |
|
| 4509 | + $p_local_header['crc'] = $p_central_header['crc']; |
|
| 4510 | 4510 | } |
| 4511 | 4511 | |
| 4512 | - // ----- Return |
|
| 4513 | - return $v_result; |
|
| 4512 | + // ----- Return |
|
| 4513 | + return $v_result; |
|
| 4514 | 4514 | } |
| 4515 | 4515 | // -------------------------------------------------------------------------------- |
| 4516 | 4516 | |
@@ -4522,152 +4522,152 @@ discard block |
||
| 4522 | 4522 | // -------------------------------------------------------------------------------- |
| 4523 | 4523 | function privReadEndCentralDir(&$p_central_dir) |
| 4524 | 4524 | { |
| 4525 | - $v_result=1; |
|
| 4526 | - |
|
| 4527 | - // ----- Go to the end of the zip file |
|
| 4528 | - $v_size = filesize($this->zipname); |
|
| 4529 | - @fseek($this->zip_fd, $v_size); |
|
| 4530 | - if (@ftell($this->zip_fd) != $v_size) |
|
| 4531 | - { |
|
| 4532 | - // ----- Error log |
|
| 4533 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\''); |
|
| 4534 | - |
|
| 4535 | - // ----- Return |
|
| 4536 | - return PclZip::errorCode(); |
|
| 4537 | - } |
|
| 4525 | + $v_result=1; |
|
| 4526 | + |
|
| 4527 | + // ----- Go to the end of the zip file |
|
| 4528 | + $v_size = filesize($this->zipname); |
|
| 4529 | + @fseek($this->zip_fd, $v_size); |
|
| 4530 | + if (@ftell($this->zip_fd) != $v_size) |
|
| 4531 | + { |
|
| 4532 | + // ----- Error log |
|
| 4533 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\''); |
|
| 4534 | + |
|
| 4535 | + // ----- Return |
|
| 4536 | + return PclZip::errorCode(); |
|
| 4537 | + } |
|
| 4538 | 4538 | |
| 4539 | - // ----- First try : look if this is an archive with no commentaries (most of the time) |
|
| 4540 | - // in this case the end of central dir is at 22 bytes of the file end |
|
| 4541 | - $v_found = 0; |
|
| 4542 | - if ($v_size > 26) { |
|
| 4543 | - @fseek($this->zip_fd, $v_size-22); |
|
| 4544 | - if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22)) |
|
| 4545 | - { |
|
| 4546 | - // ----- Error log |
|
| 4547 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); |
|
| 4548 | - |
|
| 4549 | - // ----- Return |
|
| 4550 | - return PclZip::errorCode(); |
|
| 4551 | - } |
|
| 4539 | + // ----- First try : look if this is an archive with no commentaries (most of the time) |
|
| 4540 | + // in this case the end of central dir is at 22 bytes of the file end |
|
| 4541 | + $v_found = 0; |
|
| 4542 | + if ($v_size > 26) { |
|
| 4543 | + @fseek($this->zip_fd, $v_size-22); |
|
| 4544 | + if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22)) |
|
| 4545 | + { |
|
| 4546 | + // ----- Error log |
|
| 4547 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); |
|
| 4548 | + |
|
| 4549 | + // ----- Return |
|
| 4550 | + return PclZip::errorCode(); |
|
| 4551 | + } |
|
| 4552 | 4552 | |
| 4553 | - // ----- Read for bytes |
|
| 4554 | - $v_binary_data = @fread($this->zip_fd, 4); |
|
| 4555 | - $v_data = @unpack('Vid', $v_binary_data); |
|
| 4553 | + // ----- Read for bytes |
|
| 4554 | + $v_binary_data = @fread($this->zip_fd, 4); |
|
| 4555 | + $v_data = @unpack('Vid', $v_binary_data); |
|
| 4556 | 4556 | |
| 4557 | - // ----- Check signature |
|
| 4558 | - if ($v_data['id'] == 0x06054b50) { |
|
| 4559 | - $v_found = 1; |
|
| 4560 | - } |
|
| 4557 | + // ----- Check signature |
|
| 4558 | + if ($v_data['id'] == 0x06054b50) { |
|
| 4559 | + $v_found = 1; |
|
| 4560 | + } |
|
| 4561 | 4561 | |
| 4562 | - $v_pos = ftell($this->zip_fd); |
|
| 4563 | - } |
|
| 4562 | + $v_pos = ftell($this->zip_fd); |
|
| 4563 | + } |
|
| 4564 | 4564 | |
| 4565 | - // ----- Go back to the maximum possible size of the Central Dir End Record |
|
| 4566 | - if (!$v_found) { |
|
| 4567 | - $v_maximum_size = 65557; // 0xFFFF + 22; |
|
| 4568 | - if ($v_maximum_size > $v_size) |
|
| 4569 | - $v_maximum_size = $v_size; |
|
| 4570 | - @fseek($this->zip_fd, $v_size-$v_maximum_size); |
|
| 4571 | - if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) |
|
| 4572 | - { |
|
| 4573 | - // ----- Error log |
|
| 4574 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); |
|
| 4575 | - |
|
| 4576 | - // ----- Return |
|
| 4577 | - return PclZip::errorCode(); |
|
| 4578 | - } |
|
| 4565 | + // ----- Go back to the maximum possible size of the Central Dir End Record |
|
| 4566 | + if (!$v_found) { |
|
| 4567 | + $v_maximum_size = 65557; // 0xFFFF + 22; |
|
| 4568 | + if ($v_maximum_size > $v_size) |
|
| 4569 | + $v_maximum_size = $v_size; |
|
| 4570 | + @fseek($this->zip_fd, $v_size-$v_maximum_size); |
|
| 4571 | + if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) |
|
| 4572 | + { |
|
| 4573 | + // ----- Error log |
|
| 4574 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); |
|
| 4575 | + |
|
| 4576 | + // ----- Return |
|
| 4577 | + return PclZip::errorCode(); |
|
| 4578 | + } |
|
| 4579 | 4579 | |
| 4580 | - // ----- Read byte per byte in order to find the signature |
|
| 4581 | - $v_pos = ftell($this->zip_fd); |
|
| 4582 | - $v_bytes = 0x00000000; |
|
| 4583 | - while ($v_pos < $v_size) |
|
| 4584 | - { |
|
| 4585 | - // ----- Read a byte |
|
| 4586 | - $v_byte = @fread($this->zip_fd, 1); |
|
| 4587 | - |
|
| 4588 | - // ----- Add the byte |
|
| 4589 | - //$v_bytes = ($v_bytes << 8) | Ord($v_byte); |
|
| 4590 | - // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number |
|
| 4591 | - // Otherwise on systems where we have 64bit integers the check below for the magic number will fail. |
|
| 4592 | - $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); |
|
| 4593 | - |
|
| 4594 | - // ----- Compare the bytes |
|
| 4595 | - if ($v_bytes == 0x504b0506) |
|
| 4596 | - { |
|
| 4597 | - $v_pos++; |
|
| 4598 | - break; |
|
| 4599 | - } |
|
| 4600 | - |
|
| 4601 | - $v_pos++; |
|
| 4602 | - } |
|
| 4580 | + // ----- Read byte per byte in order to find the signature |
|
| 4581 | + $v_pos = ftell($this->zip_fd); |
|
| 4582 | + $v_bytes = 0x00000000; |
|
| 4583 | + while ($v_pos < $v_size) |
|
| 4584 | + { |
|
| 4585 | + // ----- Read a byte |
|
| 4586 | + $v_byte = @fread($this->zip_fd, 1); |
|
| 4587 | + |
|
| 4588 | + // ----- Add the byte |
|
| 4589 | + //$v_bytes = ($v_bytes << 8) | Ord($v_byte); |
|
| 4590 | + // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number |
|
| 4591 | + // Otherwise on systems where we have 64bit integers the check below for the magic number will fail. |
|
| 4592 | + $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); |
|
| 4593 | + |
|
| 4594 | + // ----- Compare the bytes |
|
| 4595 | + if ($v_bytes == 0x504b0506) |
|
| 4596 | + { |
|
| 4597 | + $v_pos++; |
|
| 4598 | + break; |
|
| 4599 | + } |
|
| 4600 | + |
|
| 4601 | + $v_pos++; |
|
| 4602 | + } |
|
| 4603 | 4603 | |
| 4604 | - // ----- Look if not found end of central dir |
|
| 4605 | - if ($v_pos == $v_size) |
|
| 4606 | - { |
|
| 4604 | + // ----- Look if not found end of central dir |
|
| 4605 | + if ($v_pos == $v_size) |
|
| 4606 | + { |
|
| 4607 | 4607 | |
| 4608 | - // ----- Error log |
|
| 4609 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature"); |
|
| 4608 | + // ----- Error log |
|
| 4609 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature"); |
|
| 4610 | 4610 | |
| 4611 | - // ----- Return |
|
| 4612 | - return PclZip::errorCode(); |
|
| 4613 | - } |
|
| 4614 | - } |
|
| 4611 | + // ----- Return |
|
| 4612 | + return PclZip::errorCode(); |
|
| 4613 | + } |
|
| 4614 | + } |
|
| 4615 | 4615 | |
| 4616 | - // ----- Read the first 18 bytes of the header |
|
| 4617 | - $v_binary_data = fread($this->zip_fd, 18); |
|
| 4616 | + // ----- Read the first 18 bytes of the header |
|
| 4617 | + $v_binary_data = fread($this->zip_fd, 18); |
|
| 4618 | 4618 | |
| 4619 | - // ----- Look for invalid block size |
|
| 4620 | - if (strlen($v_binary_data) != 18) |
|
| 4621 | - { |
|
| 4619 | + // ----- Look for invalid block size |
|
| 4620 | + if (strlen($v_binary_data) != 18) |
|
| 4621 | + { |
|
| 4622 | 4622 | |
| 4623 | - // ----- Error log |
|
| 4624 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); |
|
| 4623 | + // ----- Error log |
|
| 4624 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); |
|
| 4625 | 4625 | |
| 4626 | - // ----- Return |
|
| 4627 | - return PclZip::errorCode(); |
|
| 4628 | - } |
|
| 4626 | + // ----- Return |
|
| 4627 | + return PclZip::errorCode(); |
|
| 4628 | + } |
|
| 4629 | 4629 | |
| 4630 | - // ----- Extract the values |
|
| 4631 | - $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data); |
|
| 4630 | + // ----- Extract the values |
|
| 4631 | + $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data); |
|
| 4632 | 4632 | |
| 4633 | - // ----- Check the global size |
|
| 4634 | - if (($v_pos + $v_data['comment_size'] + 18) != $v_size) { |
|
| 4633 | + // ----- Check the global size |
|
| 4634 | + if (($v_pos + $v_data['comment_size'] + 18) != $v_size) { |
|
| 4635 | 4635 | |
| 4636 | 4636 | // ----- Removed in release 2.2 see readme file |
| 4637 | 4637 | // The check of the file size is a little too strict. |
| 4638 | 4638 | // Some bugs where found when a zip is encrypted/decrypted with 'crypt'. |
| 4639 | 4639 | // While decrypted, zip has training 0 bytes |
| 4640 | 4640 | if (0) { |
| 4641 | - // ----- Error log |
|
| 4642 | - PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, |
|
| 4643 | - 'The central dir is not at the end of the archive.' |
|
| 4641 | + // ----- Error log |
|
| 4642 | + PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, |
|
| 4643 | + 'The central dir is not at the end of the archive.' |
|
| 4644 | 4644 | .' Some trailing bytes exists after the archive.'); |
| 4645 | 4645 | |
| 4646 | - // ----- Return |
|
| 4647 | - return PclZip::errorCode(); |
|
| 4646 | + // ----- Return |
|
| 4647 | + return PclZip::errorCode(); |
|
| 4648 | 4648 | } |
| 4649 | - } |
|
| 4649 | + } |
|
| 4650 | 4650 | |
| 4651 | - // ----- Get comment |
|
| 4652 | - if ($v_data['comment_size'] != 0) { |
|
| 4653 | - $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']); |
|
| 4654 | - } |
|
| 4655 | - else |
|
| 4656 | - $p_central_dir['comment'] = ''; |
|
| 4657 | - |
|
| 4658 | - $p_central_dir['entries'] = $v_data['entries']; |
|
| 4659 | - $p_central_dir['disk_entries'] = $v_data['disk_entries']; |
|
| 4660 | - $p_central_dir['offset'] = $v_data['offset']; |
|
| 4661 | - $p_central_dir['size'] = $v_data['size']; |
|
| 4662 | - $p_central_dir['disk'] = $v_data['disk']; |
|
| 4663 | - $p_central_dir['disk_start'] = $v_data['disk_start']; |
|
| 4664 | - |
|
| 4665 | - // TBC |
|
| 4666 | - //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) { |
|
| 4667 | - //} |
|
| 4668 | - |
|
| 4669 | - // ----- Return |
|
| 4670 | - return $v_result; |
|
| 4651 | + // ----- Get comment |
|
| 4652 | + if ($v_data['comment_size'] != 0) { |
|
| 4653 | + $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']); |
|
| 4654 | + } |
|
| 4655 | + else |
|
| 4656 | + $p_central_dir['comment'] = ''; |
|
| 4657 | + |
|
| 4658 | + $p_central_dir['entries'] = $v_data['entries']; |
|
| 4659 | + $p_central_dir['disk_entries'] = $v_data['disk_entries']; |
|
| 4660 | + $p_central_dir['offset'] = $v_data['offset']; |
|
| 4661 | + $p_central_dir['size'] = $v_data['size']; |
|
| 4662 | + $p_central_dir['disk'] = $v_data['disk']; |
|
| 4663 | + $p_central_dir['disk_start'] = $v_data['disk_start']; |
|
| 4664 | + |
|
| 4665 | + // TBC |
|
| 4666 | + //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) { |
|
| 4667 | + //} |
|
| 4668 | + |
|
| 4669 | + // ----- Return |
|
| 4670 | + return $v_result; |
|
| 4671 | 4671 | } |
| 4672 | 4672 | // -------------------------------------------------------------------------------- |
| 4673 | 4673 | |
@@ -4679,96 +4679,96 @@ discard block |
||
| 4679 | 4679 | // -------------------------------------------------------------------------------- |
| 4680 | 4680 | function privDeleteByRule(&$p_result_list, &$p_options) |
| 4681 | 4681 | { |
| 4682 | - $v_result=1; |
|
| 4683 | - $v_list_detail = array(); |
|
| 4684 | - |
|
| 4685 | - // ----- Open the zip file |
|
| 4686 | - if (($v_result=$this->privOpenFd('rb')) != 1) |
|
| 4687 | - { |
|
| 4688 | - // ----- Return |
|
| 4689 | - return $v_result; |
|
| 4690 | - } |
|
| 4682 | + $v_result=1; |
|
| 4683 | + $v_list_detail = array(); |
|
| 4684 | + |
|
| 4685 | + // ----- Open the zip file |
|
| 4686 | + if (($v_result=$this->privOpenFd('rb')) != 1) |
|
| 4687 | + { |
|
| 4688 | + // ----- Return |
|
| 4689 | + return $v_result; |
|
| 4690 | + } |
|
| 4691 | 4691 | |
| 4692 | - // ----- Read the central directory informations |
|
| 4693 | - $v_central_dir = array(); |
|
| 4694 | - if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 4695 | - { |
|
| 4696 | - $this->privCloseFd(); |
|
| 4697 | - return $v_result; |
|
| 4698 | - } |
|
| 4692 | + // ----- Read the central directory informations |
|
| 4693 | + $v_central_dir = array(); |
|
| 4694 | + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 4695 | + { |
|
| 4696 | + $this->privCloseFd(); |
|
| 4697 | + return $v_result; |
|
| 4698 | + } |
|
| 4699 | 4699 | |
| 4700 | - // ----- Go to beginning of File |
|
| 4701 | - @rewind($this->zip_fd); |
|
| 4700 | + // ----- Go to beginning of File |
|
| 4701 | + @rewind($this->zip_fd); |
|
| 4702 | 4702 | |
| 4703 | - // ----- Scan all the files |
|
| 4704 | - // ----- Start at beginning of Central Dir |
|
| 4705 | - $v_pos_entry = $v_central_dir['offset']; |
|
| 4706 | - @rewind($this->zip_fd); |
|
| 4707 | - if (@fseek($this->zip_fd, $v_pos_entry)) |
|
| 4708 | - { |
|
| 4709 | - // ----- Close the zip file |
|
| 4710 | - $this->privCloseFd(); |
|
| 4703 | + // ----- Scan all the files |
|
| 4704 | + // ----- Start at beginning of Central Dir |
|
| 4705 | + $v_pos_entry = $v_central_dir['offset']; |
|
| 4706 | + @rewind($this->zip_fd); |
|
| 4707 | + if (@fseek($this->zip_fd, $v_pos_entry)) |
|
| 4708 | + { |
|
| 4709 | + // ----- Close the zip file |
|
| 4710 | + $this->privCloseFd(); |
|
| 4711 | 4711 | |
| 4712 | - // ----- Error log |
|
| 4713 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 4712 | + // ----- Error log |
|
| 4713 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 4714 | 4714 | |
| 4715 | - // ----- Return |
|
| 4716 | - return PclZip::errorCode(); |
|
| 4717 | - } |
|
| 4715 | + // ----- Return |
|
| 4716 | + return PclZip::errorCode(); |
|
| 4717 | + } |
|
| 4718 | 4718 | |
| 4719 | - // ----- Read each entry |
|
| 4720 | - $v_header_list = array(); |
|
| 4721 | - $j_start = 0; |
|
| 4722 | - for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) |
|
| 4723 | - { |
|
| 4719 | + // ----- Read each entry |
|
| 4720 | + $v_header_list = array(); |
|
| 4721 | + $j_start = 0; |
|
| 4722 | + for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) |
|
| 4723 | + { |
|
| 4724 | 4724 | |
| 4725 | - // ----- Read the file header |
|
| 4726 | - $v_header_list[$v_nb_extracted] = array(); |
|
| 4727 | - if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1) |
|
| 4728 | - { |
|
| 4729 | - // ----- Close the zip file |
|
| 4730 | - $this->privCloseFd(); |
|
| 4725 | + // ----- Read the file header |
|
| 4726 | + $v_header_list[$v_nb_extracted] = array(); |
|
| 4727 | + if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1) |
|
| 4728 | + { |
|
| 4729 | + // ----- Close the zip file |
|
| 4730 | + $this->privCloseFd(); |
|
| 4731 | 4731 | |
| 4732 | - return $v_result; |
|
| 4733 | - } |
|
| 4732 | + return $v_result; |
|
| 4733 | + } |
|
| 4734 | 4734 | |
| 4735 | 4735 | |
| 4736 | - // ----- Store the index |
|
| 4737 | - $v_header_list[$v_nb_extracted]['index'] = $i; |
|
| 4738 | - |
|
| 4739 | - // ----- Look for the specific extract rules |
|
| 4740 | - $v_found = false; |
|
| 4741 | - |
|
| 4742 | - // ----- Look for extract by name rule |
|
| 4743 | - if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 4744 | - && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { |
|
| 4745 | - |
|
| 4746 | - // ----- Look if the filename is in the list |
|
| 4747 | - for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) { |
|
| 4748 | - |
|
| 4749 | - // ----- Look for a directory |
|
| 4750 | - if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") { |
|
| 4751 | - |
|
| 4752 | - // ----- Look if the directory is in the filename path |
|
| 4753 | - if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 4754 | - && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { |
|
| 4755 | - $v_found = true; |
|
| 4756 | - } |
|
| 4757 | - elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
| 4758 | - && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) { |
|
| 4759 | - $v_found = true; |
|
| 4760 | - } |
|
| 4761 | - } |
|
| 4762 | - // ----- Look for a filename |
|
| 4763 | - elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { |
|
| 4764 | - $v_found = true; |
|
| 4765 | - } |
|
| 4766 | - } |
|
| 4767 | - } |
|
| 4736 | + // ----- Store the index |
|
| 4737 | + $v_header_list[$v_nb_extracted]['index'] = $i; |
|
| 4738 | + |
|
| 4739 | + // ----- Look for the specific extract rules |
|
| 4740 | + $v_found = false; |
|
| 4741 | + |
|
| 4742 | + // ----- Look for extract by name rule |
|
| 4743 | + if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 4744 | + && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { |
|
| 4745 | + |
|
| 4746 | + // ----- Look if the filename is in the list |
|
| 4747 | + for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) { |
|
| 4748 | + |
|
| 4749 | + // ----- Look for a directory |
|
| 4750 | + if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") { |
|
| 4751 | + |
|
| 4752 | + // ----- Look if the directory is in the filename path |
|
| 4753 | + if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 4754 | + && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { |
|
| 4755 | + $v_found = true; |
|
| 4756 | + } |
|
| 4757 | + elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
| 4758 | + && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) { |
|
| 4759 | + $v_found = true; |
|
| 4760 | + } |
|
| 4761 | + } |
|
| 4762 | + // ----- Look for a filename |
|
| 4763 | + elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { |
|
| 4764 | + $v_found = true; |
|
| 4765 | + } |
|
| 4766 | + } |
|
| 4767 | + } |
|
| 4768 | 4768 | |
| 4769 | - // ----- Look for extract by ereg rule |
|
| 4770 | - // ereg() is deprecated with PHP 5.3 |
|
| 4771 | - /* |
|
| 4769 | + // ----- Look for extract by ereg rule |
|
| 4770 | + // ereg() is deprecated with PHP 5.3 |
|
| 4771 | + /* |
|
| 4772 | 4772 | else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) |
| 4773 | 4773 | && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { |
| 4774 | 4774 | |
@@ -4778,201 +4778,201 @@ discard block |
||
| 4778 | 4778 | } |
| 4779 | 4779 | */ |
| 4780 | 4780 | |
| 4781 | - // ----- Look for extract by preg rule |
|
| 4782 | - else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 4783 | - && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { |
|
| 4781 | + // ----- Look for extract by preg rule |
|
| 4782 | + else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 4783 | + && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { |
|
| 4784 | 4784 | |
| 4785 | - if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { |
|
| 4786 | - $v_found = true; |
|
| 4787 | - } |
|
| 4788 | - } |
|
| 4785 | + if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { |
|
| 4786 | + $v_found = true; |
|
| 4787 | + } |
|
| 4788 | + } |
|
| 4789 | 4789 | |
| 4790 | - // ----- Look for extract by index rule |
|
| 4791 | - else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 4792 | - && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { |
|
| 4790 | + // ----- Look for extract by index rule |
|
| 4791 | + else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 4792 | + && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { |
|
| 4793 | 4793 | |
| 4794 | - // ----- Look if the index is in the list |
|
| 4795 | - for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) { |
|
| 4794 | + // ----- Look if the index is in the list |
|
| 4795 | + for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) { |
|
| 4796 | 4796 | |
| 4797 | - if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { |
|
| 4798 | - $v_found = true; |
|
| 4799 | - } |
|
| 4800 | - if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { |
|
| 4801 | - $j_start = $j+1; |
|
| 4802 | - } |
|
| 4797 | + if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { |
|
| 4798 | + $v_found = true; |
|
| 4799 | + } |
|
| 4800 | + if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { |
|
| 4801 | + $j_start = $j+1; |
|
| 4802 | + } |
|
| 4803 | 4803 | |
| 4804 | - if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { |
|
| 4805 | - break; |
|
| 4806 | - } |
|
| 4807 | - } |
|
| 4808 | - } |
|
| 4809 | - else { |
|
| 4810 | - $v_found = true; |
|
| 4811 | - } |
|
| 4804 | + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { |
|
| 4805 | + break; |
|
| 4806 | + } |
|
| 4807 | + } |
|
| 4808 | + } |
|
| 4809 | + else { |
|
| 4810 | + $v_found = true; |
|
| 4811 | + } |
|
| 4812 | 4812 | |
| 4813 | - // ----- Look for deletion |
|
| 4814 | - if ($v_found) |
|
| 4815 | - { |
|
| 4816 | - unset($v_header_list[$v_nb_extracted]); |
|
| 4817 | - } |
|
| 4818 | - else |
|
| 4819 | - { |
|
| 4820 | - $v_nb_extracted++; |
|
| 4821 | - } |
|
| 4822 | - } |
|
| 4813 | + // ----- Look for deletion |
|
| 4814 | + if ($v_found) |
|
| 4815 | + { |
|
| 4816 | + unset($v_header_list[$v_nb_extracted]); |
|
| 4817 | + } |
|
| 4818 | + else |
|
| 4819 | + { |
|
| 4820 | + $v_nb_extracted++; |
|
| 4821 | + } |
|
| 4822 | + } |
|
| 4823 | 4823 | |
| 4824 | - // ----- Look if something need to be deleted |
|
| 4825 | - if ($v_nb_extracted > 0) { |
|
| 4826 | - |
|
| 4827 | - // ----- Creates a temporay file |
|
| 4828 | - $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; |
|
| 4829 | - |
|
| 4830 | - // ----- Creates a temporary zip archive |
|
| 4831 | - $v_temp_zip = new PclZip($v_zip_temp_name); |
|
| 4832 | - |
|
| 4833 | - // ----- Open the temporary zip file in write mode |
|
| 4834 | - if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) { |
|
| 4835 | - $this->privCloseFd(); |
|
| 4836 | - |
|
| 4837 | - // ----- Return |
|
| 4838 | - return $v_result; |
|
| 4839 | - } |
|
| 4840 | - |
|
| 4841 | - // ----- Look which file need to be kept |
|
| 4842 | - for ($i=0; $i<sizeof($v_header_list); $i++) { |
|
| 4843 | - |
|
| 4844 | - // ----- Calculate the position of the header |
|
| 4845 | - @rewind($this->zip_fd); |
|
| 4846 | - if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) { |
|
| 4847 | - // ----- Close the zip file |
|
| 4848 | - $this->privCloseFd(); |
|
| 4849 | - $v_temp_zip->privCloseFd(); |
|
| 4850 | - @unlink($v_zip_temp_name); |
|
| 4851 | - |
|
| 4852 | - // ----- Error log |
|
| 4853 | - PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 4854 | - |
|
| 4855 | - // ----- Return |
|
| 4856 | - return PclZip::errorCode(); |
|
| 4857 | - } |
|
| 4858 | - |
|
| 4859 | - // ----- Read the file header |
|
| 4860 | - $v_local_header = array(); |
|
| 4861 | - if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) { |
|
| 4862 | - // ----- Close the zip file |
|
| 4863 | - $this->privCloseFd(); |
|
| 4864 | - $v_temp_zip->privCloseFd(); |
|
| 4865 | - @unlink($v_zip_temp_name); |
|
| 4866 | - |
|
| 4867 | - // ----- Return |
|
| 4868 | - return $v_result; |
|
| 4869 | - } |
|
| 4870 | - |
|
| 4871 | - // ----- Check that local file header is same as central file header |
|
| 4872 | - if ($this->privCheckFileHeaders($v_local_header, |
|
| 4873 | - $v_header_list[$i]) != 1) { |
|
| 4874 | - // TBC |
|
| 4875 | - } |
|
| 4876 | - unset($v_local_header); |
|
| 4877 | - |
|
| 4878 | - // ----- Write the file header |
|
| 4879 | - if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) { |
|
| 4880 | - // ----- Close the zip file |
|
| 4881 | - $this->privCloseFd(); |
|
| 4882 | - $v_temp_zip->privCloseFd(); |
|
| 4883 | - @unlink($v_zip_temp_name); |
|
| 4884 | - |
|
| 4885 | - // ----- Return |
|
| 4886 | - return $v_result; |
|
| 4887 | - } |
|
| 4888 | - |
|
| 4889 | - // ----- Read/write the data block |
|
| 4890 | - if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) { |
|
| 4891 | - // ----- Close the zip file |
|
| 4892 | - $this->privCloseFd(); |
|
| 4893 | - $v_temp_zip->privCloseFd(); |
|
| 4894 | - @unlink($v_zip_temp_name); |
|
| 4895 | - |
|
| 4896 | - // ----- Return |
|
| 4897 | - return $v_result; |
|
| 4898 | - } |
|
| 4899 | - } |
|
| 4900 | - |
|
| 4901 | - // ----- Store the offset of the central dir |
|
| 4902 | - $v_offset = @ftell($v_temp_zip->zip_fd); |
|
| 4903 | - |
|
| 4904 | - // ----- Re-Create the Central Dir files header |
|
| 4905 | - for ($i=0; $i<sizeof($v_header_list); $i++) { |
|
| 4906 | - // ----- Create the file header |
|
| 4907 | - if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) { |
|
| 4908 | - $v_temp_zip->privCloseFd(); |
|
| 4909 | - $this->privCloseFd(); |
|
| 4910 | - @unlink($v_zip_temp_name); |
|
| 4911 | - |
|
| 4912 | - // ----- Return |
|
| 4913 | - return $v_result; |
|
| 4914 | - } |
|
| 4915 | - |
|
| 4916 | - // ----- Transform the header to a 'usable' info |
|
| 4917 | - $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 4918 | - } |
|
| 4919 | - |
|
| 4920 | - |
|
| 4921 | - // ----- Zip file comment |
|
| 4922 | - $v_comment = ''; |
|
| 4923 | - if (isset($p_options[PCLZIP_OPT_COMMENT])) { |
|
| 4924 | - $v_comment = $p_options[PCLZIP_OPT_COMMENT]; |
|
| 4925 | - } |
|
| 4926 | - |
|
| 4927 | - // ----- Calculate the size of the central header |
|
| 4928 | - $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset; |
|
| 4929 | - |
|
| 4930 | - // ----- Create the central dir footer |
|
| 4931 | - if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) { |
|
| 4932 | - // ----- Reset the file list |
|
| 4933 | - unset($v_header_list); |
|
| 4934 | - $v_temp_zip->privCloseFd(); |
|
| 4935 | - $this->privCloseFd(); |
|
| 4936 | - @unlink($v_zip_temp_name); |
|
| 4937 | - |
|
| 4938 | - // ----- Return |
|
| 4939 | - return $v_result; |
|
| 4940 | - } |
|
| 4941 | - |
|
| 4942 | - // ----- Close |
|
| 4943 | - $v_temp_zip->privCloseFd(); |
|
| 4944 | - $this->privCloseFd(); |
|
| 4945 | - |
|
| 4946 | - // ----- Delete the zip file |
|
| 4947 | - // TBC : I should test the result ... |
|
| 4948 | - @unlink($this->zipname); |
|
| 4949 | - |
|
| 4950 | - // ----- Rename the temporary file |
|
| 4951 | - // TBC : I should test the result ... |
|
| 4952 | - //@rename($v_zip_temp_name, $this->zipname); |
|
| 4953 | - PclZipUtilRename($v_zip_temp_name, $this->zipname); |
|
| 4954 | - |
|
| 4955 | - // ----- Destroy the temporary archive |
|
| 4956 | - unset($v_temp_zip); |
|
| 4957 | - } |
|
| 4824 | + // ----- Look if something need to be deleted |
|
| 4825 | + if ($v_nb_extracted > 0) { |
|
| 4826 | + |
|
| 4827 | + // ----- Creates a temporay file |
|
| 4828 | + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; |
|
| 4829 | + |
|
| 4830 | + // ----- Creates a temporary zip archive |
|
| 4831 | + $v_temp_zip = new PclZip($v_zip_temp_name); |
|
| 4832 | + |
|
| 4833 | + // ----- Open the temporary zip file in write mode |
|
| 4834 | + if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) { |
|
| 4835 | + $this->privCloseFd(); |
|
| 4836 | + |
|
| 4837 | + // ----- Return |
|
| 4838 | + return $v_result; |
|
| 4839 | + } |
|
| 4840 | + |
|
| 4841 | + // ----- Look which file need to be kept |
|
| 4842 | + for ($i=0; $i<sizeof($v_header_list); $i++) { |
|
| 4843 | + |
|
| 4844 | + // ----- Calculate the position of the header |
|
| 4845 | + @rewind($this->zip_fd); |
|
| 4846 | + if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) { |
|
| 4847 | + // ----- Close the zip file |
|
| 4848 | + $this->privCloseFd(); |
|
| 4849 | + $v_temp_zip->privCloseFd(); |
|
| 4850 | + @unlink($v_zip_temp_name); |
|
| 4851 | + |
|
| 4852 | + // ----- Error log |
|
| 4853 | + PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 4854 | + |
|
| 4855 | + // ----- Return |
|
| 4856 | + return PclZip::errorCode(); |
|
| 4857 | + } |
|
| 4858 | + |
|
| 4859 | + // ----- Read the file header |
|
| 4860 | + $v_local_header = array(); |
|
| 4861 | + if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) { |
|
| 4862 | + // ----- Close the zip file |
|
| 4863 | + $this->privCloseFd(); |
|
| 4864 | + $v_temp_zip->privCloseFd(); |
|
| 4865 | + @unlink($v_zip_temp_name); |
|
| 4866 | + |
|
| 4867 | + // ----- Return |
|
| 4868 | + return $v_result; |
|
| 4869 | + } |
|
| 4870 | + |
|
| 4871 | + // ----- Check that local file header is same as central file header |
|
| 4872 | + if ($this->privCheckFileHeaders($v_local_header, |
|
| 4873 | + $v_header_list[$i]) != 1) { |
|
| 4874 | + // TBC |
|
| 4875 | + } |
|
| 4876 | + unset($v_local_header); |
|
| 4877 | + |
|
| 4878 | + // ----- Write the file header |
|
| 4879 | + if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) { |
|
| 4880 | + // ----- Close the zip file |
|
| 4881 | + $this->privCloseFd(); |
|
| 4882 | + $v_temp_zip->privCloseFd(); |
|
| 4883 | + @unlink($v_zip_temp_name); |
|
| 4884 | + |
|
| 4885 | + // ----- Return |
|
| 4886 | + return $v_result; |
|
| 4887 | + } |
|
| 4888 | + |
|
| 4889 | + // ----- Read/write the data block |
|
| 4890 | + if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) { |
|
| 4891 | + // ----- Close the zip file |
|
| 4892 | + $this->privCloseFd(); |
|
| 4893 | + $v_temp_zip->privCloseFd(); |
|
| 4894 | + @unlink($v_zip_temp_name); |
|
| 4895 | + |
|
| 4896 | + // ----- Return |
|
| 4897 | + return $v_result; |
|
| 4898 | + } |
|
| 4899 | + } |
|
| 4900 | + |
|
| 4901 | + // ----- Store the offset of the central dir |
|
| 4902 | + $v_offset = @ftell($v_temp_zip->zip_fd); |
|
| 4903 | + |
|
| 4904 | + // ----- Re-Create the Central Dir files header |
|
| 4905 | + for ($i=0; $i<sizeof($v_header_list); $i++) { |
|
| 4906 | + // ----- Create the file header |
|
| 4907 | + if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) { |
|
| 4908 | + $v_temp_zip->privCloseFd(); |
|
| 4909 | + $this->privCloseFd(); |
|
| 4910 | + @unlink($v_zip_temp_name); |
|
| 4911 | + |
|
| 4912 | + // ----- Return |
|
| 4913 | + return $v_result; |
|
| 4914 | + } |
|
| 4915 | + |
|
| 4916 | + // ----- Transform the header to a 'usable' info |
|
| 4917 | + $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 4918 | + } |
|
| 4919 | + |
|
| 4920 | + |
|
| 4921 | + // ----- Zip file comment |
|
| 4922 | + $v_comment = ''; |
|
| 4923 | + if (isset($p_options[PCLZIP_OPT_COMMENT])) { |
|
| 4924 | + $v_comment = $p_options[PCLZIP_OPT_COMMENT]; |
|
| 4925 | + } |
|
| 4926 | + |
|
| 4927 | + // ----- Calculate the size of the central header |
|
| 4928 | + $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset; |
|
| 4929 | + |
|
| 4930 | + // ----- Create the central dir footer |
|
| 4931 | + if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) { |
|
| 4932 | + // ----- Reset the file list |
|
| 4933 | + unset($v_header_list); |
|
| 4934 | + $v_temp_zip->privCloseFd(); |
|
| 4935 | + $this->privCloseFd(); |
|
| 4936 | + @unlink($v_zip_temp_name); |
|
| 4937 | + |
|
| 4938 | + // ----- Return |
|
| 4939 | + return $v_result; |
|
| 4940 | + } |
|
| 4941 | + |
|
| 4942 | + // ----- Close |
|
| 4943 | + $v_temp_zip->privCloseFd(); |
|
| 4944 | + $this->privCloseFd(); |
|
| 4945 | + |
|
| 4946 | + // ----- Delete the zip file |
|
| 4947 | + // TBC : I should test the result ... |
|
| 4948 | + @unlink($this->zipname); |
|
| 4949 | + |
|
| 4950 | + // ----- Rename the temporary file |
|
| 4951 | + // TBC : I should test the result ... |
|
| 4952 | + //@rename($v_zip_temp_name, $this->zipname); |
|
| 4953 | + PclZipUtilRename($v_zip_temp_name, $this->zipname); |
|
| 4954 | + |
|
| 4955 | + // ----- Destroy the temporary archive |
|
| 4956 | + unset($v_temp_zip); |
|
| 4957 | + } |
|
| 4958 | 4958 | |
| 4959 | - // ----- Remove every files : reset the file |
|
| 4960 | - else if ($v_central_dir['entries'] != 0) { |
|
| 4961 | - $this->privCloseFd(); |
|
| 4959 | + // ----- Remove every files : reset the file |
|
| 4960 | + else if ($v_central_dir['entries'] != 0) { |
|
| 4961 | + $this->privCloseFd(); |
|
| 4962 | 4962 | |
| 4963 | - if (($v_result = $this->privOpenFd('wb')) != 1) { |
|
| 4964 | - return $v_result; |
|
| 4965 | - } |
|
| 4963 | + if (($v_result = $this->privOpenFd('wb')) != 1) { |
|
| 4964 | + return $v_result; |
|
| 4965 | + } |
|
| 4966 | 4966 | |
| 4967 | - if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) { |
|
| 4968 | - return $v_result; |
|
| 4969 | - } |
|
| 4967 | + if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) { |
|
| 4968 | + return $v_result; |
|
| 4969 | + } |
|
| 4970 | 4970 | |
| 4971 | - $this->privCloseFd(); |
|
| 4972 | - } |
|
| 4971 | + $this->privCloseFd(); |
|
| 4972 | + } |
|
| 4973 | 4973 | |
| 4974 | - // ----- Return |
|
| 4975 | - return $v_result; |
|
| 4974 | + // ----- Return |
|
| 4975 | + return $v_result; |
|
| 4976 | 4976 | } |
| 4977 | 4977 | // -------------------------------------------------------------------------------- |
| 4978 | 4978 | |
@@ -4989,49 +4989,49 @@ discard block |
||
| 4989 | 4989 | // -------------------------------------------------------------------------------- |
| 4990 | 4990 | function privDirCheck($p_dir, $p_is_dir=false) |
| 4991 | 4991 | { |
| 4992 | - $v_result = 1; |
|
| 4992 | + $v_result = 1; |
|
| 4993 | 4993 | |
| 4994 | 4994 | |
| 4995 | - // ----- Remove the final '/' |
|
| 4996 | - if (($p_is_dir) && (substr($p_dir, -1)=='/')) |
|
| 4997 | - { |
|
| 4998 | - $p_dir = substr($p_dir, 0, strlen($p_dir)-1); |
|
| 4999 | - } |
|
| 4995 | + // ----- Remove the final '/' |
|
| 4996 | + if (($p_is_dir) && (substr($p_dir, -1)=='/')) |
|
| 4997 | + { |
|
| 4998 | + $p_dir = substr($p_dir, 0, strlen($p_dir)-1); |
|
| 4999 | + } |
|
| 5000 | 5000 | |
| 5001 | - // ----- Check the directory availability |
|
| 5002 | - if ((is_dir($p_dir)) || ($p_dir == "")) |
|
| 5003 | - { |
|
| 5004 | - return 1; |
|
| 5005 | - } |
|
| 5001 | + // ----- Check the directory availability |
|
| 5002 | + if ((is_dir($p_dir)) || ($p_dir == "")) |
|
| 5003 | + { |
|
| 5004 | + return 1; |
|
| 5005 | + } |
|
| 5006 | 5006 | |
| 5007 | - // ----- Extract parent directory |
|
| 5008 | - $p_parent_dir = dirname($p_dir); |
|
| 5009 | - |
|
| 5010 | - // ----- Just a check |
|
| 5011 | - if ($p_parent_dir != $p_dir) |
|
| 5012 | - { |
|
| 5013 | - // ----- Look for parent directory |
|
| 5014 | - if ($p_parent_dir != "") |
|
| 5015 | - { |
|
| 5016 | - if (($v_result = $this->privDirCheck($p_parent_dir)) != 1) |
|
| 5017 | - { |
|
| 5018 | - return $v_result; |
|
| 5019 | - } |
|
| 5020 | - } |
|
| 5021 | - } |
|
| 5007 | + // ----- Extract parent directory |
|
| 5008 | + $p_parent_dir = dirname($p_dir); |
|
| 5009 | + |
|
| 5010 | + // ----- Just a check |
|
| 5011 | + if ($p_parent_dir != $p_dir) |
|
| 5012 | + { |
|
| 5013 | + // ----- Look for parent directory |
|
| 5014 | + if ($p_parent_dir != "") |
|
| 5015 | + { |
|
| 5016 | + if (($v_result = $this->privDirCheck($p_parent_dir)) != 1) |
|
| 5017 | + { |
|
| 5018 | + return $v_result; |
|
| 5019 | + } |
|
| 5020 | + } |
|
| 5021 | + } |
|
| 5022 | 5022 | |
| 5023 | - // ----- Create the directory |
|
| 5024 | - if (!@mkdir($p_dir, 0777)) |
|
| 5025 | - { |
|
| 5026 | - // ----- Error log |
|
| 5027 | - PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'"); |
|
| 5023 | + // ----- Create the directory |
|
| 5024 | + if (!@mkdir($p_dir, 0777)) |
|
| 5025 | + { |
|
| 5026 | + // ----- Error log |
|
| 5027 | + PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'"); |
|
| 5028 | 5028 | |
| 5029 | - // ----- Return |
|
| 5030 | - return PclZip::errorCode(); |
|
| 5031 | - } |
|
| 5029 | + // ----- Return |
|
| 5030 | + return PclZip::errorCode(); |
|
| 5031 | + } |
|
| 5032 | 5032 | |
| 5033 | - // ----- Return |
|
| 5034 | - return $v_result; |
|
| 5033 | + // ----- Return |
|
| 5034 | + return $v_result; |
|
| 5035 | 5035 | } |
| 5036 | 5036 | // -------------------------------------------------------------------------------- |
| 5037 | 5037 | |
@@ -5044,180 +5044,180 @@ discard block |
||
| 5044 | 5044 | // -------------------------------------------------------------------------------- |
| 5045 | 5045 | function privMerge(&$p_archive_to_add) |
| 5046 | 5046 | { |
| 5047 | - $v_result=1; |
|
| 5047 | + $v_result=1; |
|
| 5048 | 5048 | |
| 5049 | - // ----- Look if the archive_to_add exists |
|
| 5050 | - if (!is_file($p_archive_to_add->zipname)) |
|
| 5051 | - { |
|
| 5049 | + // ----- Look if the archive_to_add exists |
|
| 5050 | + if (!is_file($p_archive_to_add->zipname)) |
|
| 5051 | + { |
|
| 5052 | 5052 | |
| 5053 | - // ----- Nothing to merge, so merge is a success |
|
| 5054 | - $v_result = 1; |
|
| 5053 | + // ----- Nothing to merge, so merge is a success |
|
| 5054 | + $v_result = 1; |
|
| 5055 | 5055 | |
| 5056 | - // ----- Return |
|
| 5057 | - return $v_result; |
|
| 5058 | - } |
|
| 5056 | + // ----- Return |
|
| 5057 | + return $v_result; |
|
| 5058 | + } |
|
| 5059 | 5059 | |
| 5060 | - // ----- Look if the archive exists |
|
| 5061 | - if (!is_file($this->zipname)) |
|
| 5062 | - { |
|
| 5060 | + // ----- Look if the archive exists |
|
| 5061 | + if (!is_file($this->zipname)) |
|
| 5062 | + { |
|
| 5063 | 5063 | |
| 5064 | - // ----- Do a duplicate |
|
| 5065 | - $v_result = $this->privDuplicate($p_archive_to_add->zipname); |
|
| 5064 | + // ----- Do a duplicate |
|
| 5065 | + $v_result = $this->privDuplicate($p_archive_to_add->zipname); |
|
| 5066 | 5066 | |
| 5067 | - // ----- Return |
|
| 5068 | - return $v_result; |
|
| 5069 | - } |
|
| 5067 | + // ----- Return |
|
| 5068 | + return $v_result; |
|
| 5069 | + } |
|
| 5070 | 5070 | |
| 5071 | - // ----- Open the zip file |
|
| 5072 | - if (($v_result=$this->privOpenFd('rb')) != 1) |
|
| 5073 | - { |
|
| 5074 | - // ----- Return |
|
| 5075 | - return $v_result; |
|
| 5076 | - } |
|
| 5071 | + // ----- Open the zip file |
|
| 5072 | + if (($v_result=$this->privOpenFd('rb')) != 1) |
|
| 5073 | + { |
|
| 5074 | + // ----- Return |
|
| 5075 | + return $v_result; |
|
| 5076 | + } |
|
| 5077 | 5077 | |
| 5078 | - // ----- Read the central directory informations |
|
| 5079 | - $v_central_dir = array(); |
|
| 5080 | - if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 5081 | - { |
|
| 5082 | - $this->privCloseFd(); |
|
| 5083 | - return $v_result; |
|
| 5084 | - } |
|
| 5078 | + // ----- Read the central directory informations |
|
| 5079 | + $v_central_dir = array(); |
|
| 5080 | + if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) |
|
| 5081 | + { |
|
| 5082 | + $this->privCloseFd(); |
|
| 5083 | + return $v_result; |
|
| 5084 | + } |
|
| 5085 | 5085 | |
| 5086 | - // ----- Go to beginning of File |
|
| 5087 | - @rewind($this->zip_fd); |
|
| 5086 | + // ----- Go to beginning of File |
|
| 5087 | + @rewind($this->zip_fd); |
|
| 5088 | 5088 | |
| 5089 | - // ----- Open the archive_to_add file |
|
| 5090 | - if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1) |
|
| 5091 | - { |
|
| 5092 | - $this->privCloseFd(); |
|
| 5089 | + // ----- Open the archive_to_add file |
|
| 5090 | + if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1) |
|
| 5091 | + { |
|
| 5092 | + $this->privCloseFd(); |
|
| 5093 | 5093 | |
| 5094 | - // ----- Return |
|
| 5095 | - return $v_result; |
|
| 5096 | - } |
|
| 5094 | + // ----- Return |
|
| 5095 | + return $v_result; |
|
| 5096 | + } |
|
| 5097 | 5097 | |
| 5098 | - // ----- Read the central directory informations |
|
| 5099 | - $v_central_dir_to_add = array(); |
|
| 5100 | - if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1) |
|
| 5101 | - { |
|
| 5102 | - $this->privCloseFd(); |
|
| 5103 | - $p_archive_to_add->privCloseFd(); |
|
| 5098 | + // ----- Read the central directory informations |
|
| 5099 | + $v_central_dir_to_add = array(); |
|
| 5100 | + if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1) |
|
| 5101 | + { |
|
| 5102 | + $this->privCloseFd(); |
|
| 5103 | + $p_archive_to_add->privCloseFd(); |
|
| 5104 | 5104 | |
| 5105 | - return $v_result; |
|
| 5106 | - } |
|
| 5105 | + return $v_result; |
|
| 5106 | + } |
|
| 5107 | 5107 | |
| 5108 | - // ----- Go to beginning of File |
|
| 5109 | - @rewind($p_archive_to_add->zip_fd); |
|
| 5108 | + // ----- Go to beginning of File |
|
| 5109 | + @rewind($p_archive_to_add->zip_fd); |
|
| 5110 | 5110 | |
| 5111 | - // ----- Creates a temporay file |
|
| 5112 | - $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; |
|
| 5111 | + // ----- Creates a temporay file |
|
| 5112 | + $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; |
|
| 5113 | 5113 | |
| 5114 | - // ----- Open the temporary file in write mode |
|
| 5115 | - if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) |
|
| 5116 | - { |
|
| 5117 | - $this->privCloseFd(); |
|
| 5118 | - $p_archive_to_add->privCloseFd(); |
|
| 5114 | + // ----- Open the temporary file in write mode |
|
| 5115 | + if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) |
|
| 5116 | + { |
|
| 5117 | + $this->privCloseFd(); |
|
| 5118 | + $p_archive_to_add->privCloseFd(); |
|
| 5119 | 5119 | |
| 5120 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); |
|
| 5120 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); |
|
| 5121 | 5121 | |
| 5122 | - // ----- Return |
|
| 5123 | - return PclZip::errorCode(); |
|
| 5124 | - } |
|
| 5122 | + // ----- Return |
|
| 5123 | + return PclZip::errorCode(); |
|
| 5124 | + } |
|
| 5125 | 5125 | |
| 5126 | - // ----- Copy the files from the archive to the temporary file |
|
| 5127 | - // TBC : Here I should better append the file and go back to erase the central dir |
|
| 5128 | - $v_size = $v_central_dir['offset']; |
|
| 5129 | - while ($v_size != 0) |
|
| 5130 | - { |
|
| 5131 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5132 | - $v_buffer = fread($this->zip_fd, $v_read_size); |
|
| 5133 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5134 | - $v_size -= $v_read_size; |
|
| 5135 | - } |
|
| 5126 | + // ----- Copy the files from the archive to the temporary file |
|
| 5127 | + // TBC : Here I should better append the file and go back to erase the central dir |
|
| 5128 | + $v_size = $v_central_dir['offset']; |
|
| 5129 | + while ($v_size != 0) |
|
| 5130 | + { |
|
| 5131 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5132 | + $v_buffer = fread($this->zip_fd, $v_read_size); |
|
| 5133 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5134 | + $v_size -= $v_read_size; |
|
| 5135 | + } |
|
| 5136 | 5136 | |
| 5137 | - // ----- Copy the files from the archive_to_add into the temporary file |
|
| 5138 | - $v_size = $v_central_dir_to_add['offset']; |
|
| 5139 | - while ($v_size != 0) |
|
| 5140 | - { |
|
| 5141 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5142 | - $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size); |
|
| 5143 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5144 | - $v_size -= $v_read_size; |
|
| 5145 | - } |
|
| 5137 | + // ----- Copy the files from the archive_to_add into the temporary file |
|
| 5138 | + $v_size = $v_central_dir_to_add['offset']; |
|
| 5139 | + while ($v_size != 0) |
|
| 5140 | + { |
|
| 5141 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5142 | + $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size); |
|
| 5143 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5144 | + $v_size -= $v_read_size; |
|
| 5145 | + } |
|
| 5146 | 5146 | |
| 5147 | - // ----- Store the offset of the central dir |
|
| 5148 | - $v_offset = @ftell($v_zip_temp_fd); |
|
| 5149 | - |
|
| 5150 | - // ----- Copy the block of file headers from the old archive |
|
| 5151 | - $v_size = $v_central_dir['size']; |
|
| 5152 | - while ($v_size != 0) |
|
| 5153 | - { |
|
| 5154 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5155 | - $v_buffer = @fread($this->zip_fd, $v_read_size); |
|
| 5156 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5157 | - $v_size -= $v_read_size; |
|
| 5158 | - } |
|
| 5147 | + // ----- Store the offset of the central dir |
|
| 5148 | + $v_offset = @ftell($v_zip_temp_fd); |
|
| 5149 | + |
|
| 5150 | + // ----- Copy the block of file headers from the old archive |
|
| 5151 | + $v_size = $v_central_dir['size']; |
|
| 5152 | + while ($v_size != 0) |
|
| 5153 | + { |
|
| 5154 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5155 | + $v_buffer = @fread($this->zip_fd, $v_read_size); |
|
| 5156 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5157 | + $v_size -= $v_read_size; |
|
| 5158 | + } |
|
| 5159 | 5159 | |
| 5160 | - // ----- Copy the block of file headers from the archive_to_add |
|
| 5161 | - $v_size = $v_central_dir_to_add['size']; |
|
| 5162 | - while ($v_size != 0) |
|
| 5163 | - { |
|
| 5164 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5165 | - $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size); |
|
| 5166 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5167 | - $v_size -= $v_read_size; |
|
| 5168 | - } |
|
| 5160 | + // ----- Copy the block of file headers from the archive_to_add |
|
| 5161 | + $v_size = $v_central_dir_to_add['size']; |
|
| 5162 | + while ($v_size != 0) |
|
| 5163 | + { |
|
| 5164 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5165 | + $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size); |
|
| 5166 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 5167 | + $v_size -= $v_read_size; |
|
| 5168 | + } |
|
| 5169 | 5169 | |
| 5170 | - // ----- Merge the file comments |
|
| 5171 | - $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment']; |
|
| 5170 | + // ----- Merge the file comments |
|
| 5171 | + $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment']; |
|
| 5172 | 5172 | |
| 5173 | - // ----- Calculate the size of the (new) central header |
|
| 5174 | - $v_size = @ftell($v_zip_temp_fd)-$v_offset; |
|
| 5173 | + // ----- Calculate the size of the (new) central header |
|
| 5174 | + $v_size = @ftell($v_zip_temp_fd)-$v_offset; |
|
| 5175 | 5175 | |
| 5176 | - // ----- Swap the file descriptor |
|
| 5177 | - // Here is a trick : I swap the temporary fd with the zip fd, in order to use |
|
| 5178 | - // the following methods on the temporary fil and not the real archive fd |
|
| 5179 | - $v_swap = $this->zip_fd; |
|
| 5180 | - $this->zip_fd = $v_zip_temp_fd; |
|
| 5181 | - $v_zip_temp_fd = $v_swap; |
|
| 5176 | + // ----- Swap the file descriptor |
|
| 5177 | + // Here is a trick : I swap the temporary fd with the zip fd, in order to use |
|
| 5178 | + // the following methods on the temporary fil and not the real archive fd |
|
| 5179 | + $v_swap = $this->zip_fd; |
|
| 5180 | + $this->zip_fd = $v_zip_temp_fd; |
|
| 5181 | + $v_zip_temp_fd = $v_swap; |
|
| 5182 | 5182 | |
| 5183 | - // ----- Create the central dir footer |
|
| 5184 | - if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 5185 | - { |
|
| 5186 | - $this->privCloseFd(); |
|
| 5187 | - $p_archive_to_add->privCloseFd(); |
|
| 5188 | - @fclose($v_zip_temp_fd); |
|
| 5189 | - $this->zip_fd = null; |
|
| 5183 | + // ----- Create the central dir footer |
|
| 5184 | + if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 5185 | + { |
|
| 5186 | + $this->privCloseFd(); |
|
| 5187 | + $p_archive_to_add->privCloseFd(); |
|
| 5188 | + @fclose($v_zip_temp_fd); |
|
| 5189 | + $this->zip_fd = null; |
|
| 5190 | 5190 | |
| 5191 | - // ----- Reset the file list |
|
| 5192 | - unset($v_header_list); |
|
| 5191 | + // ----- Reset the file list |
|
| 5192 | + unset($v_header_list); |
|
| 5193 | 5193 | |
| 5194 | - // ----- Return |
|
| 5195 | - return $v_result; |
|
| 5196 | - } |
|
| 5194 | + // ----- Return |
|
| 5195 | + return $v_result; |
|
| 5196 | + } |
|
| 5197 | 5197 | |
| 5198 | - // ----- Swap back the file descriptor |
|
| 5199 | - $v_swap = $this->zip_fd; |
|
| 5200 | - $this->zip_fd = $v_zip_temp_fd; |
|
| 5201 | - $v_zip_temp_fd = $v_swap; |
|
| 5198 | + // ----- Swap back the file descriptor |
|
| 5199 | + $v_swap = $this->zip_fd; |
|
| 5200 | + $this->zip_fd = $v_zip_temp_fd; |
|
| 5201 | + $v_zip_temp_fd = $v_swap; |
|
| 5202 | 5202 | |
| 5203 | - // ----- Close |
|
| 5204 | - $this->privCloseFd(); |
|
| 5205 | - $p_archive_to_add->privCloseFd(); |
|
| 5203 | + // ----- Close |
|
| 5204 | + $this->privCloseFd(); |
|
| 5205 | + $p_archive_to_add->privCloseFd(); |
|
| 5206 | 5206 | |
| 5207 | - // ----- Close the temporary file |
|
| 5208 | - @fclose($v_zip_temp_fd); |
|
| 5207 | + // ----- Close the temporary file |
|
| 5208 | + @fclose($v_zip_temp_fd); |
|
| 5209 | 5209 | |
| 5210 | - // ----- Delete the zip file |
|
| 5211 | - // TBC : I should test the result ... |
|
| 5212 | - @unlink($this->zipname); |
|
| 5210 | + // ----- Delete the zip file |
|
| 5211 | + // TBC : I should test the result ... |
|
| 5212 | + @unlink($this->zipname); |
|
| 5213 | 5213 | |
| 5214 | - // ----- Rename the temporary file |
|
| 5215 | - // TBC : I should test the result ... |
|
| 5216 | - //@rename($v_zip_temp_name, $this->zipname); |
|
| 5217 | - PclZipUtilRename($v_zip_temp_name, $this->zipname); |
|
| 5214 | + // ----- Rename the temporary file |
|
| 5215 | + // TBC : I should test the result ... |
|
| 5216 | + //@rename($v_zip_temp_name, $this->zipname); |
|
| 5217 | + PclZipUtilRename($v_zip_temp_name, $this->zipname); |
|
| 5218 | 5218 | |
| 5219 | - // ----- Return |
|
| 5220 | - return $v_result; |
|
| 5219 | + // ----- Return |
|
| 5220 | + return $v_result; |
|
| 5221 | 5221 | } |
| 5222 | 5222 | // -------------------------------------------------------------------------------- |
| 5223 | 5223 | |
@@ -5229,56 +5229,56 @@ discard block |
||
| 5229 | 5229 | // -------------------------------------------------------------------------------- |
| 5230 | 5230 | function privDuplicate($p_archive_filename) |
| 5231 | 5231 | { |
| 5232 | - $v_result=1; |
|
| 5232 | + $v_result=1; |
|
| 5233 | 5233 | |
| 5234 | - // ----- Look if the $p_archive_filename exists |
|
| 5235 | - if (!is_file($p_archive_filename)) |
|
| 5236 | - { |
|
| 5234 | + // ----- Look if the $p_archive_filename exists |
|
| 5235 | + if (!is_file($p_archive_filename)) |
|
| 5236 | + { |
|
| 5237 | 5237 | |
| 5238 | - // ----- Nothing to duplicate, so duplicate is a success. |
|
| 5239 | - $v_result = 1; |
|
| 5238 | + // ----- Nothing to duplicate, so duplicate is a success. |
|
| 5239 | + $v_result = 1; |
|
| 5240 | 5240 | |
| 5241 | - // ----- Return |
|
| 5242 | - return $v_result; |
|
| 5243 | - } |
|
| 5241 | + // ----- Return |
|
| 5242 | + return $v_result; |
|
| 5243 | + } |
|
| 5244 | 5244 | |
| 5245 | - // ----- Open the zip file |
|
| 5246 | - if (($v_result=$this->privOpenFd('wb')) != 1) |
|
| 5247 | - { |
|
| 5248 | - // ----- Return |
|
| 5249 | - return $v_result; |
|
| 5250 | - } |
|
| 5245 | + // ----- Open the zip file |
|
| 5246 | + if (($v_result=$this->privOpenFd('wb')) != 1) |
|
| 5247 | + { |
|
| 5248 | + // ----- Return |
|
| 5249 | + return $v_result; |
|
| 5250 | + } |
|
| 5251 | 5251 | |
| 5252 | - // ----- Open the temporary file in write mode |
|
| 5253 | - if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) |
|
| 5254 | - { |
|
| 5255 | - $this->privCloseFd(); |
|
| 5252 | + // ----- Open the temporary file in write mode |
|
| 5253 | + if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) |
|
| 5254 | + { |
|
| 5255 | + $this->privCloseFd(); |
|
| 5256 | 5256 | |
| 5257 | - PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode'); |
|
| 5257 | + PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode'); |
|
| 5258 | 5258 | |
| 5259 | - // ----- Return |
|
| 5260 | - return PclZip::errorCode(); |
|
| 5261 | - } |
|
| 5259 | + // ----- Return |
|
| 5260 | + return PclZip::errorCode(); |
|
| 5261 | + } |
|
| 5262 | 5262 | |
| 5263 | - // ----- Copy the files from the archive to the temporary file |
|
| 5264 | - // TBC : Here I should better append the file and go back to erase the central dir |
|
| 5265 | - $v_size = filesize($p_archive_filename); |
|
| 5266 | - while ($v_size != 0) |
|
| 5267 | - { |
|
| 5268 | - $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5269 | - $v_buffer = fread($v_zip_temp_fd, $v_read_size); |
|
| 5270 | - @fwrite($this->zip_fd, $v_buffer, $v_read_size); |
|
| 5271 | - $v_size -= $v_read_size; |
|
| 5272 | - } |
|
| 5263 | + // ----- Copy the files from the archive to the temporary file |
|
| 5264 | + // TBC : Here I should better append the file and go back to erase the central dir |
|
| 5265 | + $v_size = filesize($p_archive_filename); |
|
| 5266 | + while ($v_size != 0) |
|
| 5267 | + { |
|
| 5268 | + $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5269 | + $v_buffer = fread($v_zip_temp_fd, $v_read_size); |
|
| 5270 | + @fwrite($this->zip_fd, $v_buffer, $v_read_size); |
|
| 5271 | + $v_size -= $v_read_size; |
|
| 5272 | + } |
|
| 5273 | 5273 | |
| 5274 | - // ----- Close |
|
| 5275 | - $this->privCloseFd(); |
|
| 5274 | + // ----- Close |
|
| 5275 | + $this->privCloseFd(); |
|
| 5276 | 5276 | |
| 5277 | - // ----- Close the temporary file |
|
| 5278 | - @fclose($v_zip_temp_fd); |
|
| 5277 | + // ----- Close the temporary file |
|
| 5278 | + @fclose($v_zip_temp_fd); |
|
| 5279 | 5279 | |
| 5280 | - // ----- Return |
|
| 5281 | - return $v_result; |
|
| 5280 | + // ----- Return |
|
| 5281 | + return $v_result; |
|
| 5282 | 5282 | } |
| 5283 | 5283 | // -------------------------------------------------------------------------------- |
| 5284 | 5284 | |
@@ -5289,13 +5289,13 @@ discard block |
||
| 5289 | 5289 | // -------------------------------------------------------------------------------- |
| 5290 | 5290 | function privErrorLog($p_error_code=0, $p_error_string='') |
| 5291 | 5291 | { |
| 5292 | - if (PCLZIP_ERROR_EXTERNAL == 1) { |
|
| 5293 | - PclError($p_error_code, $p_error_string); |
|
| 5294 | - } |
|
| 5295 | - else { |
|
| 5296 | - $this->error_code = $p_error_code; |
|
| 5297 | - $this->error_string = $p_error_string; |
|
| 5298 | - } |
|
| 5292 | + if (PCLZIP_ERROR_EXTERNAL == 1) { |
|
| 5293 | + PclError($p_error_code, $p_error_string); |
|
| 5294 | + } |
|
| 5295 | + else { |
|
| 5296 | + $this->error_code = $p_error_code; |
|
| 5297 | + $this->error_string = $p_error_string; |
|
| 5298 | + } |
|
| 5299 | 5299 | } |
| 5300 | 5300 | // -------------------------------------------------------------------------------- |
| 5301 | 5301 | |
@@ -5306,13 +5306,13 @@ discard block |
||
| 5306 | 5306 | // -------------------------------------------------------------------------------- |
| 5307 | 5307 | function privErrorReset() |
| 5308 | 5308 | { |
| 5309 | - if (PCLZIP_ERROR_EXTERNAL == 1) { |
|
| 5310 | - PclErrorReset(); |
|
| 5311 | - } |
|
| 5312 | - else { |
|
| 5313 | - $this->error_code = 0; |
|
| 5314 | - $this->error_string = ''; |
|
| 5315 | - } |
|
| 5309 | + if (PCLZIP_ERROR_EXTERNAL == 1) { |
|
| 5310 | + PclErrorReset(); |
|
| 5311 | + } |
|
| 5312 | + else { |
|
| 5313 | + $this->error_code = 0; |
|
| 5314 | + $this->error_string = ''; |
|
| 5315 | + } |
|
| 5316 | 5316 | } |
| 5317 | 5317 | // -------------------------------------------------------------------------------- |
| 5318 | 5318 | |
@@ -5324,17 +5324,17 @@ discard block |
||
| 5324 | 5324 | // -------------------------------------------------------------------------------- |
| 5325 | 5325 | function privDisableMagicQuotes() |
| 5326 | 5326 | { |
| 5327 | - $v_result=1; |
|
| 5327 | + $v_result=1; |
|
| 5328 | 5328 | |
| 5329 | - // ----- Look if function exists |
|
| 5330 | - if ( (!function_exists("get_magic_quotes_runtime")) |
|
| 5331 | - || (!function_exists("set_magic_quotes_runtime"))) { |
|
| 5332 | - return $v_result; |
|
| 5329 | + // ----- Look if function exists |
|
| 5330 | + if ( (!function_exists("get_magic_quotes_runtime")) |
|
| 5331 | + || (!function_exists("set_magic_quotes_runtime"))) { |
|
| 5332 | + return $v_result; |
|
| 5333 | 5333 | } |
| 5334 | 5334 | |
| 5335 | - // ----- Look if already done |
|
| 5336 | - if ($this->magic_quotes_status != -1) { |
|
| 5337 | - return $v_result; |
|
| 5335 | + // ----- Look if already done |
|
| 5336 | + if ($this->magic_quotes_status != -1) { |
|
| 5337 | + return $v_result; |
|
| 5338 | 5338 | } |
| 5339 | 5339 | |
| 5340 | 5340 | // ----- Get and memorize the magic_quote value |
@@ -5345,8 +5345,8 @@ discard block |
||
| 5345 | 5345 | @set_magic_quotes_runtime(0); |
| 5346 | 5346 | } |
| 5347 | 5347 | |
| 5348 | - // ----- Return |
|
| 5349 | - return $v_result; |
|
| 5348 | + // ----- Return |
|
| 5349 | + return $v_result; |
|
| 5350 | 5350 | } |
| 5351 | 5351 | // -------------------------------------------------------------------------------- |
| 5352 | 5352 | |
@@ -5358,17 +5358,17 @@ discard block |
||
| 5358 | 5358 | // -------------------------------------------------------------------------------- |
| 5359 | 5359 | function privSwapBackMagicQuotes() |
| 5360 | 5360 | { |
| 5361 | - $v_result=1; |
|
| 5361 | + $v_result=1; |
|
| 5362 | 5362 | |
| 5363 | - // ----- Look if function exists |
|
| 5364 | - if ( (!function_exists("get_magic_quotes_runtime")) |
|
| 5365 | - || (!function_exists("set_magic_quotes_runtime"))) { |
|
| 5366 | - return $v_result; |
|
| 5363 | + // ----- Look if function exists |
|
| 5364 | + if ( (!function_exists("get_magic_quotes_runtime")) |
|
| 5365 | + || (!function_exists("set_magic_quotes_runtime"))) { |
|
| 5366 | + return $v_result; |
|
| 5367 | 5367 | } |
| 5368 | 5368 | |
| 5369 | - // ----- Look if something to do |
|
| 5370 | - if ($this->magic_quotes_status != -1) { |
|
| 5371 | - return $v_result; |
|
| 5369 | + // ----- Look if something to do |
|
| 5370 | + if ($this->magic_quotes_status != -1) { |
|
| 5371 | + return $v_result; |
|
| 5372 | 5372 | } |
| 5373 | 5373 | |
| 5374 | 5374 | // ----- Swap back magic_quotes |
@@ -5376,8 +5376,8 @@ discard block |
||
| 5376 | 5376 | @set_magic_quotes_runtime($this->magic_quotes_status); |
| 5377 | 5377 | } |
| 5378 | 5378 | |
| 5379 | - // ----- Return |
|
| 5380 | - return $v_result; |
|
| 5379 | + // ----- Return |
|
| 5380 | + return $v_result; |
|
| 5381 | 5381 | } |
| 5382 | 5382 | // -------------------------------------------------------------------------------- |
| 5383 | 5383 | |
@@ -5393,67 +5393,67 @@ discard block |
||
| 5393 | 5393 | // -------------------------------------------------------------------------------- |
| 5394 | 5394 | function PclZipUtilPathReduction($p_dir) |
| 5395 | 5395 | { |
| 5396 | - $v_result = ""; |
|
| 5397 | - |
|
| 5398 | - // ----- Look for not empty path |
|
| 5399 | - if ($p_dir != "") { |
|
| 5400 | - // ----- Explode path by directory names |
|
| 5401 | - $v_list = explode("/", $p_dir); |
|
| 5402 | - |
|
| 5403 | - // ----- Study directories from last to first |
|
| 5404 | - $v_skip = 0; |
|
| 5405 | - for ($i=sizeof($v_list)-1; $i>=0; $i--) { |
|
| 5406 | - // ----- Look for current path |
|
| 5407 | - if ($v_list[$i] == ".") { |
|
| 5408 | - // ----- Ignore this directory |
|
| 5409 | - // Should be the first $i=0, but no check is done |
|
| 5410 | - } |
|
| 5411 | - else if ($v_list[$i] == "..") { |
|
| 5396 | + $v_result = ""; |
|
| 5397 | + |
|
| 5398 | + // ----- Look for not empty path |
|
| 5399 | + if ($p_dir != "") { |
|
| 5400 | + // ----- Explode path by directory names |
|
| 5401 | + $v_list = explode("/", $p_dir); |
|
| 5402 | + |
|
| 5403 | + // ----- Study directories from last to first |
|
| 5404 | + $v_skip = 0; |
|
| 5405 | + for ($i=sizeof($v_list)-1; $i>=0; $i--) { |
|
| 5406 | + // ----- Look for current path |
|
| 5407 | + if ($v_list[$i] == ".") { |
|
| 5408 | + // ----- Ignore this directory |
|
| 5409 | + // Should be the first $i=0, but no check is done |
|
| 5410 | + } |
|
| 5411 | + else if ($v_list[$i] == "..") { |
|
| 5412 | 5412 | $v_skip++; |
| 5413 | - } |
|
| 5414 | - else if ($v_list[$i] == "") { |
|
| 5413 | + } |
|
| 5414 | + else if ($v_list[$i] == "") { |
|
| 5415 | 5415 | // ----- First '/' i.e. root slash |
| 5416 | 5416 | if ($i == 0) { |
| 5417 | - $v_result = "/".$v_result; |
|
| 5418 | - if ($v_skip > 0) { |
|
| 5419 | - // ----- It is an invalid path, so the path is not modified |
|
| 5420 | - // TBC |
|
| 5421 | - $v_result = $p_dir; |
|
| 5422 | - $v_skip = 0; |
|
| 5423 | - } |
|
| 5417 | + $v_result = "/".$v_result; |
|
| 5418 | + if ($v_skip > 0) { |
|
| 5419 | + // ----- It is an invalid path, so the path is not modified |
|
| 5420 | + // TBC |
|
| 5421 | + $v_result = $p_dir; |
|
| 5422 | + $v_skip = 0; |
|
| 5423 | + } |
|
| 5424 | 5424 | } |
| 5425 | 5425 | // ----- Last '/' i.e. indicates a directory |
| 5426 | 5426 | else if ($i == (sizeof($v_list)-1)) { |
| 5427 | - $v_result = $v_list[$i]; |
|
| 5427 | + $v_result = $v_list[$i]; |
|
| 5428 | 5428 | } |
| 5429 | 5429 | // ----- Double '/' inside the path |
| 5430 | 5430 | else { |
| 5431 | - // ----- Ignore only the double '//' in path, |
|
| 5432 | - // but not the first and last '/' |
|
| 5431 | + // ----- Ignore only the double '//' in path, |
|
| 5432 | + // but not the first and last '/' |
|
| 5433 | 5433 | } |
| 5434 | - } |
|
| 5435 | - else { |
|
| 5434 | + } |
|
| 5435 | + else { |
|
| 5436 | 5436 | // ----- Look for item to skip |
| 5437 | 5437 | if ($v_skip > 0) { |
| 5438 | - $v_skip--; |
|
| 5438 | + $v_skip--; |
|
| 5439 | 5439 | } |
| 5440 | 5440 | else { |
| 5441 | - $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); |
|
| 5441 | + $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); |
|
| 5442 | 5442 | } |
| 5443 | - } |
|
| 5444 | - } |
|
| 5443 | + } |
|
| 5444 | + } |
|
| 5445 | 5445 | |
| 5446 | - // ----- Look for skip |
|
| 5447 | - if ($v_skip > 0) { |
|
| 5448 | - while ($v_skip > 0) { |
|
| 5449 | - $v_result = '../'.$v_result; |
|
| 5450 | - $v_skip--; |
|
| 5451 | - } |
|
| 5452 | - } |
|
| 5453 | - } |
|
| 5446 | + // ----- Look for skip |
|
| 5447 | + if ($v_skip > 0) { |
|
| 5448 | + while ($v_skip > 0) { |
|
| 5449 | + $v_result = '../'.$v_result; |
|
| 5450 | + $v_skip--; |
|
| 5451 | + } |
|
| 5452 | + } |
|
| 5453 | + } |
|
| 5454 | 5454 | |
| 5455 | - // ----- Return |
|
| 5456 | - return $v_result; |
|
| 5455 | + // ----- Return |
|
| 5456 | + return $v_result; |
|
| 5457 | 5457 | } |
| 5458 | 5458 | // -------------------------------------------------------------------------------- |
| 5459 | 5459 | |
@@ -5474,67 +5474,67 @@ discard block |
||
| 5474 | 5474 | // -------------------------------------------------------------------------------- |
| 5475 | 5475 | function PclZipUtilPathInclusion($p_dir, $p_path) |
| 5476 | 5476 | { |
| 5477 | - $v_result = 1; |
|
| 5477 | + $v_result = 1; |
|
| 5478 | 5478 | |
| 5479 | - // ----- Look for path beginning by ./ |
|
| 5480 | - if ( ($p_dir == '.') |
|
| 5481 | - || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { |
|
| 5482 | - $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); |
|
| 5483 | - } |
|
| 5484 | - if ( ($p_path == '.') |
|
| 5485 | - || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) { |
|
| 5486 | - $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); |
|
| 5487 | - } |
|
| 5479 | + // ----- Look for path beginning by ./ |
|
| 5480 | + if ( ($p_dir == '.') |
|
| 5481 | + || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { |
|
| 5482 | + $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); |
|
| 5483 | + } |
|
| 5484 | + if ( ($p_path == '.') |
|
| 5485 | + || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) { |
|
| 5486 | + $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); |
|
| 5487 | + } |
|
| 5488 | 5488 | |
| 5489 | - // ----- Explode dir and path by directory separator |
|
| 5490 | - $v_list_dir = explode("/", $p_dir); |
|
| 5491 | - $v_list_dir_size = sizeof($v_list_dir); |
|
| 5492 | - $v_list_path = explode("/", $p_path); |
|
| 5493 | - $v_list_path_size = sizeof($v_list_path); |
|
| 5494 | - |
|
| 5495 | - // ----- Study directories paths |
|
| 5496 | - $i = 0; |
|
| 5497 | - $j = 0; |
|
| 5498 | - while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) { |
|
| 5499 | - |
|
| 5500 | - // ----- Look for empty dir (path reduction) |
|
| 5501 | - if ($v_list_dir[$i] == '') { |
|
| 5502 | - $i++; |
|
| 5503 | - continue; |
|
| 5504 | - } |
|
| 5505 | - if ($v_list_path[$j] == '') { |
|
| 5506 | - $j++; |
|
| 5507 | - continue; |
|
| 5508 | - } |
|
| 5489 | + // ----- Explode dir and path by directory separator |
|
| 5490 | + $v_list_dir = explode("/", $p_dir); |
|
| 5491 | + $v_list_dir_size = sizeof($v_list_dir); |
|
| 5492 | + $v_list_path = explode("/", $p_path); |
|
| 5493 | + $v_list_path_size = sizeof($v_list_path); |
|
| 5494 | + |
|
| 5495 | + // ----- Study directories paths |
|
| 5496 | + $i = 0; |
|
| 5497 | + $j = 0; |
|
| 5498 | + while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) { |
|
| 5499 | + |
|
| 5500 | + // ----- Look for empty dir (path reduction) |
|
| 5501 | + if ($v_list_dir[$i] == '') { |
|
| 5502 | + $i++; |
|
| 5503 | + continue; |
|
| 5504 | + } |
|
| 5505 | + if ($v_list_path[$j] == '') { |
|
| 5506 | + $j++; |
|
| 5507 | + continue; |
|
| 5508 | + } |
|
| 5509 | 5509 | |
| 5510 | - // ----- Compare the items |
|
| 5511 | - if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) { |
|
| 5512 | - $v_result = 0; |
|
| 5513 | - } |
|
| 5510 | + // ----- Compare the items |
|
| 5511 | + if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) { |
|
| 5512 | + $v_result = 0; |
|
| 5513 | + } |
|
| 5514 | 5514 | |
| 5515 | - // ----- Next items |
|
| 5516 | - $i++; |
|
| 5517 | - $j++; |
|
| 5518 | - } |
|
| 5515 | + // ----- Next items |
|
| 5516 | + $i++; |
|
| 5517 | + $j++; |
|
| 5518 | + } |
|
| 5519 | 5519 | |
| 5520 | - // ----- Look if everything seems to be the same |
|
| 5521 | - if ($v_result) { |
|
| 5522 | - // ----- Skip all the empty items |
|
| 5523 | - while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; |
|
| 5524 | - while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; |
|
| 5520 | + // ----- Look if everything seems to be the same |
|
| 5521 | + if ($v_result) { |
|
| 5522 | + // ----- Skip all the empty items |
|
| 5523 | + while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; |
|
| 5524 | + while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; |
|
| 5525 | 5525 | |
| 5526 | - if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { |
|
| 5527 | - // ----- There are exactly the same |
|
| 5528 | - $v_result = 2; |
|
| 5529 | - } |
|
| 5530 | - else if ($i < $v_list_dir_size) { |
|
| 5531 | - // ----- The path is shorter than the dir |
|
| 5532 | - $v_result = 0; |
|
| 5533 | - } |
|
| 5534 | - } |
|
| 5526 | + if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { |
|
| 5527 | + // ----- There are exactly the same |
|
| 5528 | + $v_result = 2; |
|
| 5529 | + } |
|
| 5530 | + else if ($i < $v_list_dir_size) { |
|
| 5531 | + // ----- The path is shorter than the dir |
|
| 5532 | + $v_result = 0; |
|
| 5533 | + } |
|
| 5534 | + } |
|
| 5535 | 5535 | |
| 5536 | - // ----- Return |
|
| 5537 | - return $v_result; |
|
| 5536 | + // ----- Return |
|
| 5537 | + return $v_result; |
|
| 5538 | 5538 | } |
| 5539 | 5539 | // -------------------------------------------------------------------------------- |
| 5540 | 5540 | |
@@ -5551,51 +5551,51 @@ discard block |
||
| 5551 | 5551 | // -------------------------------------------------------------------------------- |
| 5552 | 5552 | function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0) |
| 5553 | 5553 | { |
| 5554 | - $v_result = 1; |
|
| 5555 | - |
|
| 5556 | - if ($p_mode==0) |
|
| 5557 | - { |
|
| 5558 | - while ($p_size != 0) |
|
| 5559 | - { |
|
| 5560 | - $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5561 | - $v_buffer = @fread($p_src, $v_read_size); |
|
| 5562 | - @fwrite($p_dest, $v_buffer, $v_read_size); |
|
| 5563 | - $p_size -= $v_read_size; |
|
| 5564 | - } |
|
| 5565 | - } |
|
| 5566 | - else if ($p_mode==1) |
|
| 5567 | - { |
|
| 5568 | - while ($p_size != 0) |
|
| 5569 | - { |
|
| 5570 | - $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5571 | - $v_buffer = @gzread($p_src, $v_read_size); |
|
| 5572 | - @fwrite($p_dest, $v_buffer, $v_read_size); |
|
| 5573 | - $p_size -= $v_read_size; |
|
| 5574 | - } |
|
| 5575 | - } |
|
| 5576 | - else if ($p_mode==2) |
|
| 5577 | - { |
|
| 5578 | - while ($p_size != 0) |
|
| 5579 | - { |
|
| 5580 | - $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5581 | - $v_buffer = @fread($p_src, $v_read_size); |
|
| 5582 | - @gzwrite($p_dest, $v_buffer, $v_read_size); |
|
| 5583 | - $p_size -= $v_read_size; |
|
| 5584 | - } |
|
| 5585 | - } |
|
| 5586 | - else if ($p_mode==3) |
|
| 5587 | - { |
|
| 5588 | - while ($p_size != 0) |
|
| 5589 | - { |
|
| 5590 | - $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5591 | - $v_buffer = @gzread($p_src, $v_read_size); |
|
| 5592 | - @gzwrite($p_dest, $v_buffer, $v_read_size); |
|
| 5593 | - $p_size -= $v_read_size; |
|
| 5594 | - } |
|
| 5595 | - } |
|
| 5554 | + $v_result = 1; |
|
| 5555 | + |
|
| 5556 | + if ($p_mode==0) |
|
| 5557 | + { |
|
| 5558 | + while ($p_size != 0) |
|
| 5559 | + { |
|
| 5560 | + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5561 | + $v_buffer = @fread($p_src, $v_read_size); |
|
| 5562 | + @fwrite($p_dest, $v_buffer, $v_read_size); |
|
| 5563 | + $p_size -= $v_read_size; |
|
| 5564 | + } |
|
| 5565 | + } |
|
| 5566 | + else if ($p_mode==1) |
|
| 5567 | + { |
|
| 5568 | + while ($p_size != 0) |
|
| 5569 | + { |
|
| 5570 | + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5571 | + $v_buffer = @gzread($p_src, $v_read_size); |
|
| 5572 | + @fwrite($p_dest, $v_buffer, $v_read_size); |
|
| 5573 | + $p_size -= $v_read_size; |
|
| 5574 | + } |
|
| 5575 | + } |
|
| 5576 | + else if ($p_mode==2) |
|
| 5577 | + { |
|
| 5578 | + while ($p_size != 0) |
|
| 5579 | + { |
|
| 5580 | + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5581 | + $v_buffer = @fread($p_src, $v_read_size); |
|
| 5582 | + @gzwrite($p_dest, $v_buffer, $v_read_size); |
|
| 5583 | + $p_size -= $v_read_size; |
|
| 5584 | + } |
|
| 5585 | + } |
|
| 5586 | + else if ($p_mode==3) |
|
| 5587 | + { |
|
| 5588 | + while ($p_size != 0) |
|
| 5589 | + { |
|
| 5590 | + $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); |
|
| 5591 | + $v_buffer = @gzread($p_src, $v_read_size); |
|
| 5592 | + @gzwrite($p_dest, $v_buffer, $v_read_size); |
|
| 5593 | + $p_size -= $v_read_size; |
|
| 5594 | + } |
|
| 5595 | + } |
|
| 5596 | 5596 | |
| 5597 | - // ----- Return |
|
| 5598 | - return $v_result; |
|
| 5597 | + // ----- Return |
|
| 5598 | + return $v_result; |
|
| 5599 | 5599 | } |
| 5600 | 5600 | // -------------------------------------------------------------------------------- |
| 5601 | 5601 | |
@@ -5613,22 +5613,22 @@ discard block |
||
| 5613 | 5613 | // -------------------------------------------------------------------------------- |
| 5614 | 5614 | function PclZipUtilRename($p_src, $p_dest) |
| 5615 | 5615 | { |
| 5616 | - $v_result = 1; |
|
| 5616 | + $v_result = 1; |
|
| 5617 | 5617 | |
| 5618 | - // ----- Try to rename the files |
|
| 5619 | - if (!@rename($p_src, $p_dest)) { |
|
| 5618 | + // ----- Try to rename the files |
|
| 5619 | + if (!@rename($p_src, $p_dest)) { |
|
| 5620 | 5620 | |
| 5621 | - // ----- Try to copy & unlink the src |
|
| 5622 | - if (!@copy($p_src, $p_dest)) { |
|
| 5623 | - $v_result = 0; |
|
| 5624 | - } |
|
| 5625 | - else if (!@unlink($p_src)) { |
|
| 5626 | - $v_result = 0; |
|
| 5627 | - } |
|
| 5628 | - } |
|
| 5621 | + // ----- Try to copy & unlink the src |
|
| 5622 | + if (!@copy($p_src, $p_dest)) { |
|
| 5623 | + $v_result = 0; |
|
| 5624 | + } |
|
| 5625 | + else if (!@unlink($p_src)) { |
|
| 5626 | + $v_result = 0; |
|
| 5627 | + } |
|
| 5628 | + } |
|
| 5629 | 5629 | |
| 5630 | - // ----- Return |
|
| 5631 | - return $v_result; |
|
| 5630 | + // ----- Return |
|
| 5631 | + return $v_result; |
|
| 5632 | 5632 | } |
| 5633 | 5633 | // -------------------------------------------------------------------------------- |
| 5634 | 5634 | |
@@ -5644,20 +5644,20 @@ discard block |
||
| 5644 | 5644 | function PclZipUtilOptionText($p_option) |
| 5645 | 5645 | { |
| 5646 | 5646 | |
| 5647 | - $v_list = get_defined_constants(); |
|
| 5648 | - for (reset($v_list); $v_key = key($v_list); next($v_list)) { |
|
| 5649 | - $v_prefix = substr($v_key, 0, 10); |
|
| 5650 | - if (( ($v_prefix == 'PCLZIP_OPT') |
|
| 5651 | - || ($v_prefix == 'PCLZIP_CB_') |
|
| 5652 | - || ($v_prefix == 'PCLZIP_ATT')) |
|
| 5653 | - && ($v_list[$v_key] == $p_option)) { |
|
| 5654 | - return $v_key; |
|
| 5655 | - } |
|
| 5656 | - } |
|
| 5647 | + $v_list = get_defined_constants(); |
|
| 5648 | + for (reset($v_list); $v_key = key($v_list); next($v_list)) { |
|
| 5649 | + $v_prefix = substr($v_key, 0, 10); |
|
| 5650 | + if (( ($v_prefix == 'PCLZIP_OPT') |
|
| 5651 | + || ($v_prefix == 'PCLZIP_CB_') |
|
| 5652 | + || ($v_prefix == 'PCLZIP_ATT')) |
|
| 5653 | + && ($v_list[$v_key] == $p_option)) { |
|
| 5654 | + return $v_key; |
|
| 5655 | + } |
|
| 5656 | + } |
|
| 5657 | 5657 | |
| 5658 | - $v_result = 'Unknown'; |
|
| 5658 | + $v_result = 'Unknown'; |
|
| 5659 | 5659 | |
| 5660 | - return $v_result; |
|
| 5660 | + return $v_result; |
|
| 5661 | 5661 | } |
| 5662 | 5662 | // -------------------------------------------------------------------------------- |
| 5663 | 5663 | |
@@ -5674,17 +5674,17 @@ discard block |
||
| 5674 | 5674 | // -------------------------------------------------------------------------------- |
| 5675 | 5675 | function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true) |
| 5676 | 5676 | { |
| 5677 | - if (stristr(php_uname(), 'windows')) { |
|
| 5678 | - // ----- Look for potential disk letter |
|
| 5679 | - if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { |
|
| 5680 | - $p_path = substr($p_path, $v_position+1); |
|
| 5681 | - } |
|
| 5682 | - // ----- Change potential windows directory separator |
|
| 5683 | - if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { |
|
| 5684 | - $p_path = strtr($p_path, '\\', '/'); |
|
| 5685 | - } |
|
| 5686 | - } |
|
| 5687 | - return $p_path; |
|
| 5677 | + if (stristr(php_uname(), 'windows')) { |
|
| 5678 | + // ----- Look for potential disk letter |
|
| 5679 | + if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { |
|
| 5680 | + $p_path = substr($p_path, $v_position+1); |
|
| 5681 | + } |
|
| 5682 | + // ----- Change potential windows directory separator |
|
| 5683 | + if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { |
|
| 5684 | + $p_path = strtr($p_path, '\\', '/'); |
|
| 5685 | + } |
|
| 5686 | + } |
|
| 5687 | + return $p_path; |
|
| 5688 | 5688 | } |
| 5689 | 5689 | // -------------------------------------------------------------------------------- |
| 5690 | 5690 | |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | // -------------------------------------------------------------------------------- |
| 27 | 27 | |
| 28 | 28 | // ----- Constants |
| 29 | - if (!defined('PCLZIP_READ_BLOCK_SIZE')) { |
|
| 30 | - define( 'PCLZIP_READ_BLOCK_SIZE', 2048 ); |
|
| 29 | + if ( ! defined('PCLZIP_READ_BLOCK_SIZE')) { |
|
| 30 | + define('PCLZIP_READ_BLOCK_SIZE', 2048); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | // ----- File list separator |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | // Recommanded values for compatibility with older versions : |
| 41 | 41 | //define( 'PCLZIP_SEPARATOR', ' ' ); |
| 42 | 42 | // Recommanded values for smart separation of filenames. |
| 43 | - if (!defined('PCLZIP_SEPARATOR')) { |
|
| 44 | - define( 'PCLZIP_SEPARATOR', ',' ); |
|
| 43 | + if ( ! defined('PCLZIP_SEPARATOR')) { |
|
| 44 | + define('PCLZIP_SEPARATOR', ','); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // ----- Error configuration |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | // 1 : PclError external library error handling. By enabling this |
| 50 | 50 | // you must ensure that you have included PclError library. |
| 51 | 51 | // [2,...] : reserved for futur use |
| 52 | - if (!defined('PCLZIP_ERROR_EXTERNAL')) { |
|
| 53 | - define( 'PCLZIP_ERROR_EXTERNAL', 0 ); |
|
| 52 | + if ( ! defined('PCLZIP_ERROR_EXTERNAL')) { |
|
| 53 | + define('PCLZIP_ERROR_EXTERNAL', 0); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // ----- Optional static temporary directory |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | // Samples : |
| 63 | 63 | // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' ); |
| 64 | 64 | // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' ); |
| 65 | - if (!defined('PCLZIP_TEMPORARY_DIR')) { |
|
| 66 | - define( 'PCLZIP_TEMPORARY_DIR', '' ); |
|
| 65 | + if ( ! defined('PCLZIP_TEMPORARY_DIR')) { |
|
| 66 | + define('PCLZIP_TEMPORARY_DIR', ''); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // ----- Optional threshold ratio for use of temporary files |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | // Recommended values are under 0.5. Default 0.47. |
| 75 | 75 | // Samples : |
| 76 | 76 | // define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 ); |
| 77 | - if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) { |
|
| 78 | - define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 ); |
|
| 77 | + if ( ! defined('PCLZIP_TEMPORARY_FILE_RATIO')) { |
|
| 78 | + define('PCLZIP_TEMPORARY_FILE_RATIO', 0.47); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | // -------------------------------------------------------------------------------- |
@@ -100,72 +100,72 @@ discard block |
||
| 100 | 100 | // -12 : Unable to rename file (rename) |
| 101 | 101 | // -13 : Invalid header checksum |
| 102 | 102 | // -14 : Invalid archive size |
| 103 | - define( 'PCLZIP_ERR_USER_ABORTED', 2 ); |
|
| 104 | - define( 'PCLZIP_ERR_NO_ERROR', 0 ); |
|
| 105 | - define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 ); |
|
| 106 | - define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 ); |
|
| 107 | - define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 ); |
|
| 108 | - define( 'PCLZIP_ERR_MISSING_FILE', -4 ); |
|
| 109 | - define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 ); |
|
| 110 | - define( 'PCLZIP_ERR_INVALID_ZIP', -6 ); |
|
| 111 | - define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 ); |
|
| 112 | - define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 ); |
|
| 113 | - define( 'PCLZIP_ERR_BAD_EXTENSION', -9 ); |
|
| 114 | - define( 'PCLZIP_ERR_BAD_FORMAT', -10 ); |
|
| 115 | - define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 ); |
|
| 116 | - define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 ); |
|
| 117 | - define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 ); |
|
| 118 | - define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 ); |
|
| 119 | - define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 ); |
|
| 120 | - define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 ); |
|
| 121 | - define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 ); |
|
| 122 | - define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 ); |
|
| 123 | - define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 ); |
|
| 124 | - define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 ); |
|
| 125 | - define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 ); |
|
| 103 | + define('PCLZIP_ERR_USER_ABORTED', 2); |
|
| 104 | + define('PCLZIP_ERR_NO_ERROR', 0); |
|
| 105 | + define('PCLZIP_ERR_WRITE_OPEN_FAIL', -1); |
|
| 106 | + define('PCLZIP_ERR_READ_OPEN_FAIL', -2); |
|
| 107 | + define('PCLZIP_ERR_INVALID_PARAMETER', -3); |
|
| 108 | + define('PCLZIP_ERR_MISSING_FILE', -4); |
|
| 109 | + define('PCLZIP_ERR_FILENAME_TOO_LONG', -5); |
|
| 110 | + define('PCLZIP_ERR_INVALID_ZIP', -6); |
|
| 111 | + define('PCLZIP_ERR_BAD_EXTRACTED_FILE', -7); |
|
| 112 | + define('PCLZIP_ERR_DIR_CREATE_FAIL', -8); |
|
| 113 | + define('PCLZIP_ERR_BAD_EXTENSION', -9); |
|
| 114 | + define('PCLZIP_ERR_BAD_FORMAT', -10); |
|
| 115 | + define('PCLZIP_ERR_DELETE_FILE_FAIL', -11); |
|
| 116 | + define('PCLZIP_ERR_RENAME_FILE_FAIL', -12); |
|
| 117 | + define('PCLZIP_ERR_BAD_CHECKSUM', -13); |
|
| 118 | + define('PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14); |
|
| 119 | + define('PCLZIP_ERR_MISSING_OPTION_VALUE', -15); |
|
| 120 | + define('PCLZIP_ERR_INVALID_OPTION_VALUE', -16); |
|
| 121 | + define('PCLZIP_ERR_ALREADY_A_DIRECTORY', -17); |
|
| 122 | + define('PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18); |
|
| 123 | + define('PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19); |
|
| 124 | + define('PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20); |
|
| 125 | + define('PCLZIP_ERR_DIRECTORY_RESTRICTION', -21); |
|
| 126 | 126 | |
| 127 | 127 | // ----- Options values |
| 128 | - define( 'PCLZIP_OPT_PATH', 77001 ); |
|
| 129 | - define( 'PCLZIP_OPT_ADD_PATH', 77002 ); |
|
| 130 | - define( 'PCLZIP_OPT_REMOVE_PATH', 77003 ); |
|
| 131 | - define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 ); |
|
| 132 | - define( 'PCLZIP_OPT_SET_CHMOD', 77005 ); |
|
| 133 | - define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 ); |
|
| 134 | - define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 ); |
|
| 135 | - define( 'PCLZIP_OPT_BY_NAME', 77008 ); |
|
| 136 | - define( 'PCLZIP_OPT_BY_INDEX', 77009 ); |
|
| 137 | - define( 'PCLZIP_OPT_BY_EREG', 77010 ); |
|
| 138 | - define( 'PCLZIP_OPT_BY_PREG', 77011 ); |
|
| 139 | - define( 'PCLZIP_OPT_COMMENT', 77012 ); |
|
| 140 | - define( 'PCLZIP_OPT_ADD_COMMENT', 77013 ); |
|
| 141 | - define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 ); |
|
| 142 | - define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 ); |
|
| 143 | - define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 ); |
|
| 144 | - define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 ); |
|
| 128 | + define('PCLZIP_OPT_PATH', 77001); |
|
| 129 | + define('PCLZIP_OPT_ADD_PATH', 77002); |
|
| 130 | + define('PCLZIP_OPT_REMOVE_PATH', 77003); |
|
| 131 | + define('PCLZIP_OPT_REMOVE_ALL_PATH', 77004); |
|
| 132 | + define('PCLZIP_OPT_SET_CHMOD', 77005); |
|
| 133 | + define('PCLZIP_OPT_EXTRACT_AS_STRING', 77006); |
|
| 134 | + define('PCLZIP_OPT_NO_COMPRESSION', 77007); |
|
| 135 | + define('PCLZIP_OPT_BY_NAME', 77008); |
|
| 136 | + define('PCLZIP_OPT_BY_INDEX', 77009); |
|
| 137 | + define('PCLZIP_OPT_BY_EREG', 77010); |
|
| 138 | + define('PCLZIP_OPT_BY_PREG', 77011); |
|
| 139 | + define('PCLZIP_OPT_COMMENT', 77012); |
|
| 140 | + define('PCLZIP_OPT_ADD_COMMENT', 77013); |
|
| 141 | + define('PCLZIP_OPT_PREPEND_COMMENT', 77014); |
|
| 142 | + define('PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015); |
|
| 143 | + define('PCLZIP_OPT_REPLACE_NEWER', 77016); |
|
| 144 | + define('PCLZIP_OPT_STOP_ON_ERROR', 77017); |
|
| 145 | 145 | // Having big trouble with crypt. Need to multiply 2 long int |
| 146 | 146 | // which is not correctly supported by PHP ... |
| 147 | 147 | //define( 'PCLZIP_OPT_CRYPT', 77018 ); |
| 148 | - define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 ); |
|
| 149 | - define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 ); |
|
| 150 | - define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias |
|
| 151 | - define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 ); |
|
| 152 | - define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias |
|
| 153 | - define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 ); |
|
| 154 | - define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias |
|
| 148 | + define('PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019); |
|
| 149 | + define('PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020); |
|
| 150 | + define('PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020); // alias |
|
| 151 | + define('PCLZIP_OPT_TEMP_FILE_ON', 77021); |
|
| 152 | + define('PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021); // alias |
|
| 153 | + define('PCLZIP_OPT_TEMP_FILE_OFF', 77022); |
|
| 154 | + define('PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022); // alias |
|
| 155 | 155 | |
| 156 | 156 | // ----- File description attributes |
| 157 | - define( 'PCLZIP_ATT_FILE_NAME', 79001 ); |
|
| 158 | - define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 ); |
|
| 159 | - define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 ); |
|
| 160 | - define( 'PCLZIP_ATT_FILE_MTIME', 79004 ); |
|
| 161 | - define( 'PCLZIP_ATT_FILE_CONTENT', 79005 ); |
|
| 162 | - define( 'PCLZIP_ATT_FILE_COMMENT', 79006 ); |
|
| 157 | + define('PCLZIP_ATT_FILE_NAME', 79001); |
|
| 158 | + define('PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002); |
|
| 159 | + define('PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003); |
|
| 160 | + define('PCLZIP_ATT_FILE_MTIME', 79004); |
|
| 161 | + define('PCLZIP_ATT_FILE_CONTENT', 79005); |
|
| 162 | + define('PCLZIP_ATT_FILE_COMMENT', 79006); |
|
| 163 | 163 | |
| 164 | 164 | // ----- Call backs values |
| 165 | - define( 'PCLZIP_CB_PRE_EXTRACT', 78001 ); |
|
| 166 | - define( 'PCLZIP_CB_POST_EXTRACT', 78002 ); |
|
| 167 | - define( 'PCLZIP_CB_PRE_ADD', 78003 ); |
|
| 168 | - define( 'PCLZIP_CB_POST_ADD', 78004 ); |
|
| 165 | + define('PCLZIP_CB_PRE_EXTRACT', 78001); |
|
| 166 | + define('PCLZIP_CB_POST_EXTRACT', 78002); |
|
| 167 | + define('PCLZIP_CB_PRE_ADD', 78003); |
|
| 168 | + define('PCLZIP_CB_POST_ADD', 78004); |
|
| 169 | 169 | /* For futur use |
| 170 | 170 | define( 'PCLZIP_CB_PRE_LIST', 78005 ); |
| 171 | 171 | define( 'PCLZIP_CB_POST_LIST', 78006 ); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | { |
| 217 | 217 | |
| 218 | 218 | // ----- Tests the zlib |
| 219 | - if (!function_exists('gzopen')) |
|
| 219 | + if ( ! function_exists('gzopen')) |
|
| 220 | 220 | { |
| 221 | 221 | die('Abort '.basename(__FILE__).' : Missing zlib extensions'); |
| 222 | 222 | } |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | // -------------------------------------------------------------------------------- |
| 275 | 275 | function create($p_filelist) |
| 276 | 276 | { |
| 277 | - $v_result=1; |
|
| 277 | + $v_result = 1; |
|
| 278 | 278 | |
| 279 | 279 | // ----- Reset the error handler |
| 280 | 280 | $this->privErrorReset(); |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | // ----- Parse the options |
| 302 | 302 | $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
| 303 | - array (PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 303 | + array(PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 304 | 304 | PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
| 305 | 305 | PCLZIP_OPT_ADD_PATH => 'optional', |
| 306 | 306 | PCLZIP_CB_PRE_ADD => 'optional', |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | |
| 387 | 387 | // ----- For each file in the list check the attributes |
| 388 | 388 | $v_supported_attributes |
| 389 | - = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 389 | + = array(PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 390 | 390 | ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
| 391 | 391 | ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
| 392 | 392 | ,PCLZIP_ATT_FILE_MTIME => 'optional' |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | // -------------------------------------------------------------------------------- |
| 458 | 458 | function add($p_filelist) |
| 459 | 459 | { |
| 460 | - $v_result=1; |
|
| 460 | + $v_result = 1; |
|
| 461 | 461 | |
| 462 | 462 | // ----- Reset the error handler |
| 463 | 463 | $this->privErrorReset(); |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | |
| 484 | 484 | // ----- Parse the options |
| 485 | 485 | $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
| 486 | - array (PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 486 | + array(PCLZIP_OPT_REMOVE_PATH => 'optional', |
|
| 487 | 487 | PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
| 488 | 488 | PCLZIP_OPT_ADD_PATH => 'optional', |
| 489 | 489 | PCLZIP_CB_PRE_ADD => 'optional', |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | |
| 570 | 570 | // ----- For each file in the list check the attributes |
| 571 | 571 | $v_supported_attributes |
| 572 | - = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 572 | + = array(PCLZIP_ATT_FILE_NAME => 'mandatory' |
|
| 573 | 573 | ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' |
| 574 | 574 | ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' |
| 575 | 575 | ,PCLZIP_ATT_FILE_MTIME => 'optional' |
@@ -646,13 +646,13 @@ discard block |
||
| 646 | 646 | // -------------------------------------------------------------------------------- |
| 647 | 647 | function listContent() |
| 648 | 648 | { |
| 649 | - $v_result=1; |
|
| 649 | + $v_result = 1; |
|
| 650 | 650 | |
| 651 | 651 | // ----- Reset the error handler |
| 652 | 652 | $this->privErrorReset(); |
| 653 | 653 | |
| 654 | 654 | // ----- Check archive |
| 655 | - if (!$this->privCheckFormat()) { |
|
| 655 | + if ( ! $this->privCheckFormat()) { |
|
| 656 | 656 | return(0); |
| 657 | 657 | } |
| 658 | 658 | |
@@ -703,13 +703,13 @@ discard block |
||
| 703 | 703 | // -------------------------------------------------------------------------------- |
| 704 | 704 | function extract() |
| 705 | 705 | { |
| 706 | - $v_result=1; |
|
| 706 | + $v_result = 1; |
|
| 707 | 707 | |
| 708 | 708 | // ----- Reset the error handler |
| 709 | 709 | $this->privErrorReset(); |
| 710 | 710 | |
| 711 | 711 | // ----- Check archive |
| 712 | - if (!$this->privCheckFormat()) { |
|
| 712 | + if ( ! $this->privCheckFormat()) { |
|
| 713 | 713 | return(0); |
| 714 | 714 | } |
| 715 | 715 | |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | |
| 737 | 737 | // ----- Parse the options |
| 738 | 738 | $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
| 739 | - array (PCLZIP_OPT_PATH => 'optional', |
|
| 739 | + array(PCLZIP_OPT_PATH => 'optional', |
|
| 740 | 740 | PCLZIP_OPT_REMOVE_PATH => 'optional', |
| 741 | 741 | PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
| 742 | 742 | PCLZIP_OPT_ADD_PATH => 'optional', |
@@ -860,13 +860,13 @@ discard block |
||
| 860 | 860 | //function extractByIndex($p_index, options...) |
| 861 | 861 | function extractByIndex($p_index) |
| 862 | 862 | { |
| 863 | - $v_result=1; |
|
| 863 | + $v_result = 1; |
|
| 864 | 864 | |
| 865 | 865 | // ----- Reset the error handler |
| 866 | 866 | $this->privErrorReset(); |
| 867 | 867 | |
| 868 | 868 | // ----- Check archive |
| 869 | - if (!$this->privCheckFormat()) { |
|
| 869 | + if ( ! $this->privCheckFormat()) { |
|
| 870 | 870 | return(0); |
| 871 | 871 | } |
| 872 | 872 | |
@@ -897,7 +897,7 @@ discard block |
||
| 897 | 897 | |
| 898 | 898 | // ----- Parse the options |
| 899 | 899 | $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
| 900 | - array (PCLZIP_OPT_PATH => 'optional', |
|
| 900 | + array(PCLZIP_OPT_PATH => 'optional', |
|
| 901 | 901 | PCLZIP_OPT_REMOVE_PATH => 'optional', |
| 902 | 902 | PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', |
| 903 | 903 | PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', |
@@ -933,7 +933,7 @@ discard block |
||
| 933 | 933 | } |
| 934 | 934 | $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; |
| 935 | 935 | } |
| 936 | - if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) { |
|
| 936 | + if ( ! isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) { |
|
| 937 | 937 | $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; |
| 938 | 938 | } |
| 939 | 939 | else { |
@@ -967,10 +967,10 @@ discard block |
||
| 967 | 967 | // ----- Trick |
| 968 | 968 | // Here I want to reuse extractByRule(), so I need to parse the $p_index |
| 969 | 969 | // with privParseOptions() |
| 970 | - $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index); |
|
| 970 | + $v_arg_trick = array(PCLZIP_OPT_BY_INDEX, $p_index); |
|
| 971 | 971 | $v_options_trick = array(); |
| 972 | 972 | $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick, |
| 973 | - array (PCLZIP_OPT_BY_INDEX => 'optional' )); |
|
| 973 | + array(PCLZIP_OPT_BY_INDEX => 'optional')); |
|
| 974 | 974 | if ($v_result != 1) { |
| 975 | 975 | return 0; |
| 976 | 976 | } |
@@ -1009,13 +1009,13 @@ discard block |
||
| 1009 | 1009 | // -------------------------------------------------------------------------------- |
| 1010 | 1010 | function delete() |
| 1011 | 1011 | { |
| 1012 | - $v_result=1; |
|
| 1012 | + $v_result = 1; |
|
| 1013 | 1013 | |
| 1014 | 1014 | // ----- Reset the error handler |
| 1015 | 1015 | $this->privErrorReset(); |
| 1016 | 1016 | |
| 1017 | 1017 | // ----- Check archive |
| 1018 | - if (!$this->privCheckFormat()) { |
|
| 1018 | + if ( ! $this->privCheckFormat()) { |
|
| 1019 | 1019 | return(0); |
| 1020 | 1020 | } |
| 1021 | 1021 | |
@@ -1032,10 +1032,10 @@ discard block |
||
| 1032 | 1032 | |
| 1033 | 1033 | // ----- Parse the options |
| 1034 | 1034 | $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, |
| 1035 | - array (PCLZIP_OPT_BY_NAME => 'optional', |
|
| 1035 | + array(PCLZIP_OPT_BY_NAME => 'optional', |
|
| 1036 | 1036 | PCLZIP_OPT_BY_EREG => 'optional', |
| 1037 | 1037 | PCLZIP_OPT_BY_PREG => 'optional', |
| 1038 | - PCLZIP_OPT_BY_INDEX => 'optional' )); |
|
| 1038 | + PCLZIP_OPT_BY_INDEX => 'optional')); |
|
| 1039 | 1039 | if ($v_result != 1) { |
| 1040 | 1040 | return 0; |
| 1041 | 1041 | } |
@@ -1100,7 +1100,7 @@ discard block |
||
| 1100 | 1100 | $this->privDisableMagicQuotes(); |
| 1101 | 1101 | |
| 1102 | 1102 | // ----- Check archive |
| 1103 | - if (!$this->privCheckFormat()) { |
|
| 1103 | + if ( ! $this->privCheckFormat()) { |
|
| 1104 | 1104 | $this->privSwapBackMagicQuotes(); |
| 1105 | 1105 | return(0); |
| 1106 | 1106 | } |
@@ -1184,7 +1184,7 @@ discard block |
||
| 1184 | 1184 | |
| 1185 | 1185 | // ----- Check that $p_archive is a valid zip file |
| 1186 | 1186 | // TBC : Should also check the archive format |
| 1187 | - if (!is_file($p_archive)) { |
|
| 1187 | + if ( ! is_file($p_archive)) { |
|
| 1188 | 1188 | // ----- Error log |
| 1189 | 1189 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'"); |
| 1190 | 1190 | $v_result = PCLZIP_ERR_MISSING_FILE; |
@@ -1230,7 +1230,7 @@ discard block |
||
| 1230 | 1230 | $this->privErrorReset(); |
| 1231 | 1231 | |
| 1232 | 1232 | // ----- Check archive |
| 1233 | - if (!$this->privCheckFormat()) { |
|
| 1233 | + if ( ! $this->privCheckFormat()) { |
|
| 1234 | 1234 | return(0); |
| 1235 | 1235 | } |
| 1236 | 1236 | |
@@ -1289,9 +1289,9 @@ discard block |
||
| 1289 | 1289 | // Description : |
| 1290 | 1290 | // Parameters : |
| 1291 | 1291 | // -------------------------------------------------------------------------------- |
| 1292 | - function errorName($p_with_code=false) |
|
| 1292 | + function errorName($p_with_code = false) |
|
| 1293 | 1293 | { |
| 1294 | - $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR', |
|
| 1294 | + $v_name = array(PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR', |
|
| 1295 | 1295 | PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL', |
| 1296 | 1296 | PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL', |
| 1297 | 1297 | PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER', |
@@ -1335,7 +1335,7 @@ discard block |
||
| 1335 | 1335 | // Description : |
| 1336 | 1336 | // Parameters : |
| 1337 | 1337 | // -------------------------------------------------------------------------------- |
| 1338 | - function errorInfo($p_full=false) |
|
| 1338 | + function errorInfo($p_full = false) |
|
| 1339 | 1339 | { |
| 1340 | 1340 | if (PCLZIP_ERROR_EXTERNAL == 1) { |
| 1341 | 1341 | return(PclErrorString()); |
@@ -1374,7 +1374,7 @@ discard block |
||
| 1374 | 1374 | // true on success, |
| 1375 | 1375 | // false on error, the error code is set. |
| 1376 | 1376 | // -------------------------------------------------------------------------------- |
| 1377 | - function privCheckFormat($p_level=0) |
|
| 1377 | + function privCheckFormat($p_level = 0) |
|
| 1378 | 1378 | { |
| 1379 | 1379 | $v_result = true; |
| 1380 | 1380 | |
@@ -1385,14 +1385,14 @@ discard block |
||
| 1385 | 1385 | $this->privErrorReset(); |
| 1386 | 1386 | |
| 1387 | 1387 | // ----- Look if the file exits |
| 1388 | - if (!is_file($this->zipname)) { |
|
| 1388 | + if ( ! is_file($this->zipname)) { |
|
| 1389 | 1389 | // ----- Error log |
| 1390 | 1390 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'"); |
| 1391 | 1391 | return(false); |
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | 1394 | // ----- Check that the file is readeable |
| 1395 | - if (!is_readable($this->zipname)) { |
|
| 1395 | + if ( ! is_readable($this->zipname)) { |
|
| 1396 | 1396 | // ----- Error log |
| 1397 | 1397 | PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'"); |
| 1398 | 1398 | return(false); |
@@ -1427,16 +1427,16 @@ discard block |
||
| 1427 | 1427 | // 1 on success. |
| 1428 | 1428 | // 0 on failure. |
| 1429 | 1429 | // -------------------------------------------------------------------------------- |
| 1430 | - function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false) |
|
| 1430 | + function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options = false) |
|
| 1431 | 1431 | { |
| 1432 | - $v_result=1; |
|
| 1432 | + $v_result = 1; |
|
| 1433 | 1433 | |
| 1434 | 1434 | // ----- Read the options |
| 1435 | - $i=0; |
|
| 1436 | - while ($i<$p_size) { |
|
| 1435 | + $i = 0; |
|
| 1436 | + while ($i < $p_size) { |
|
| 1437 | 1437 | |
| 1438 | 1438 | // ----- Check if the option is supported |
| 1439 | - if (!isset($v_requested_options[$p_options_list[$i]])) { |
|
| 1439 | + if ( ! isset($v_requested_options[$p_options_list[$i]])) { |
|
| 1440 | 1440 | // ----- Error log |
| 1441 | 1441 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method"); |
| 1442 | 1442 | |
@@ -1451,7 +1451,7 @@ discard block |
||
| 1451 | 1451 | case PCLZIP_OPT_REMOVE_PATH : |
| 1452 | 1452 | case PCLZIP_OPT_ADD_PATH : |
| 1453 | 1453 | // ----- Check the number of parameters |
| 1454 | - if (($i+1) >= $p_size) { |
|
| 1454 | + if (($i + 1) >= $p_size) { |
|
| 1455 | 1455 | // ----- Error log |
| 1456 | 1456 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1457 | 1457 | |
@@ -1460,13 +1460,13 @@ discard block |
||
| 1460 | 1460 | } |
| 1461 | 1461 | |
| 1462 | 1462 | // ----- Get the value |
| 1463 | - $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
|
| 1463 | + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i + 1], FALSE); |
|
| 1464 | 1464 | $i++; |
| 1465 | 1465 | break; |
| 1466 | 1466 | |
| 1467 | 1467 | case PCLZIP_OPT_TEMP_FILE_THRESHOLD : |
| 1468 | 1468 | // ----- Check the number of parameters |
| 1469 | - if (($i+1) >= $p_size) { |
|
| 1469 | + if (($i + 1) >= $p_size) { |
|
| 1470 | 1470 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1471 | 1471 | return PclZip::errorCode(); |
| 1472 | 1472 | } |
@@ -1478,14 +1478,14 @@ discard block |
||
| 1478 | 1478 | } |
| 1479 | 1479 | |
| 1480 | 1480 | // ----- Check the value |
| 1481 | - $v_value = $p_options_list[$i+1]; |
|
| 1482 | - if ((!is_integer($v_value)) || ($v_value<0)) { |
|
| 1481 | + $v_value = $p_options_list[$i + 1]; |
|
| 1482 | + if (( ! is_integer($v_value)) || ($v_value < 0)) { |
|
| 1483 | 1483 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1484 | 1484 | return PclZip::errorCode(); |
| 1485 | 1485 | } |
| 1486 | 1486 | |
| 1487 | 1487 | // ----- Get the value (and convert it in bytes) |
| 1488 | - $v_result_list[$p_options_list[$i]] = $v_value*1048576; |
|
| 1488 | + $v_result_list[$p_options_list[$i]] = $v_value * 1048576; |
|
| 1489 | 1489 | $i++; |
| 1490 | 1490 | break; |
| 1491 | 1491 | |
@@ -1516,7 +1516,7 @@ discard block |
||
| 1516 | 1516 | |
| 1517 | 1517 | case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION : |
| 1518 | 1518 | // ----- Check the number of parameters |
| 1519 | - if (($i+1) >= $p_size) { |
|
| 1519 | + if (($i + 1) >= $p_size) { |
|
| 1520 | 1520 | // ----- Error log |
| 1521 | 1521 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1522 | 1522 | |
@@ -1525,9 +1525,9 @@ discard block |
||
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | 1527 | // ----- Get the value |
| 1528 | - if ( is_string($p_options_list[$i+1]) |
|
| 1529 | - && ($p_options_list[$i+1] != '')) { |
|
| 1530 | - $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
|
| 1528 | + if (is_string($p_options_list[$i + 1]) |
|
| 1529 | + && ($p_options_list[$i + 1] != '')) { |
|
| 1530 | + $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i + 1], FALSE); |
|
| 1531 | 1531 | $i++; |
| 1532 | 1532 | } |
| 1533 | 1533 | else { |
@@ -1537,7 +1537,7 @@ discard block |
||
| 1537 | 1537 | // ----- Look for options that request an array of string for value |
| 1538 | 1538 | case PCLZIP_OPT_BY_NAME : |
| 1539 | 1539 | // ----- Check the number of parameters |
| 1540 | - if (($i+1) >= $p_size) { |
|
| 1540 | + if (($i + 1) >= $p_size) { |
|
| 1541 | 1541 | // ----- Error log |
| 1542 | 1542 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1543 | 1543 | |
@@ -1546,11 +1546,11 @@ discard block |
||
| 1546 | 1546 | } |
| 1547 | 1547 | |
| 1548 | 1548 | // ----- Get the value |
| 1549 | - if (is_string($p_options_list[$i+1])) { |
|
| 1550 | - $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1]; |
|
| 1549 | + if (is_string($p_options_list[$i + 1])) { |
|
| 1550 | + $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i + 1]; |
|
| 1551 | 1551 | } |
| 1552 | - else if (is_array($p_options_list[$i+1])) { |
|
| 1553 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1552 | + else if (is_array($p_options_list[$i + 1])) { |
|
| 1553 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1]; |
|
| 1554 | 1554 | } |
| 1555 | 1555 | else { |
| 1556 | 1556 | // ----- Error log |
@@ -1570,7 +1570,7 @@ discard block |
||
| 1570 | 1570 | case PCLZIP_OPT_BY_PREG : |
| 1571 | 1571 | //case PCLZIP_OPT_CRYPT : |
| 1572 | 1572 | // ----- Check the number of parameters |
| 1573 | - if (($i+1) >= $p_size) { |
|
| 1573 | + if (($i + 1) >= $p_size) { |
|
| 1574 | 1574 | // ----- Error log |
| 1575 | 1575 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1576 | 1576 | |
@@ -1579,8 +1579,8 @@ discard block |
||
| 1579 | 1579 | } |
| 1580 | 1580 | |
| 1581 | 1581 | // ----- Get the value |
| 1582 | - if (is_string($p_options_list[$i+1])) { |
|
| 1583 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1582 | + if (is_string($p_options_list[$i + 1])) { |
|
| 1583 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1]; |
|
| 1584 | 1584 | } |
| 1585 | 1585 | else { |
| 1586 | 1586 | // ----- Error log |
@@ -1597,7 +1597,7 @@ discard block |
||
| 1597 | 1597 | case PCLZIP_OPT_ADD_COMMENT : |
| 1598 | 1598 | case PCLZIP_OPT_PREPEND_COMMENT : |
| 1599 | 1599 | // ----- Check the number of parameters |
| 1600 | - if (($i+1) >= $p_size) { |
|
| 1600 | + if (($i + 1) >= $p_size) { |
|
| 1601 | 1601 | // ----- Error log |
| 1602 | 1602 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, |
| 1603 | 1603 | "Missing parameter value for option '" |
@@ -1609,8 +1609,8 @@ discard block |
||
| 1609 | 1609 | } |
| 1610 | 1610 | |
| 1611 | 1611 | // ----- Get the value |
| 1612 | - if (is_string($p_options_list[$i+1])) { |
|
| 1613 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1612 | + if (is_string($p_options_list[$i + 1])) { |
|
| 1613 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1]; |
|
| 1614 | 1614 | } |
| 1615 | 1615 | else { |
| 1616 | 1616 | // ----- Error log |
@@ -1628,7 +1628,7 @@ discard block |
||
| 1628 | 1628 | // ----- Look for options that request an array of index |
| 1629 | 1629 | case PCLZIP_OPT_BY_INDEX : |
| 1630 | 1630 | // ----- Check the number of parameters |
| 1631 | - if (($i+1) >= $p_size) { |
|
| 1631 | + if (($i + 1) >= $p_size) { |
|
| 1632 | 1632 | // ----- Error log |
| 1633 | 1633 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1634 | 1634 | |
@@ -1638,19 +1638,19 @@ discard block |
||
| 1638 | 1638 | |
| 1639 | 1639 | // ----- Get the value |
| 1640 | 1640 | $v_work_list = array(); |
| 1641 | - if (is_string($p_options_list[$i+1])) { |
|
| 1641 | + if (is_string($p_options_list[$i + 1])) { |
|
| 1642 | 1642 | |
| 1643 | 1643 | // ----- Remove spaces |
| 1644 | - $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', ''); |
|
| 1644 | + $p_options_list[$i + 1] = strtr($p_options_list[$i + 1], ' ', ''); |
|
| 1645 | 1645 | |
| 1646 | 1646 | // ----- Parse items |
| 1647 | - $v_work_list = explode(",", $p_options_list[$i+1]); |
|
| 1647 | + $v_work_list = explode(",", $p_options_list[$i + 1]); |
|
| 1648 | 1648 | } |
| 1649 | - else if (is_integer($p_options_list[$i+1])) { |
|
| 1650 | - $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; |
|
| 1649 | + else if (is_integer($p_options_list[$i + 1])) { |
|
| 1650 | + $v_work_list[0] = $p_options_list[$i + 1].'-'.$p_options_list[$i + 1]; |
|
| 1651 | 1651 | } |
| 1652 | - else if (is_array($p_options_list[$i+1])) { |
|
| 1653 | - $v_work_list = $p_options_list[$i+1]; |
|
| 1652 | + else if (is_array($p_options_list[$i + 1])) { |
|
| 1653 | + $v_work_list = $p_options_list[$i + 1]; |
|
| 1654 | 1654 | } |
| 1655 | 1655 | else { |
| 1656 | 1656 | // ----- Error log |
@@ -1664,9 +1664,9 @@ discard block |
||
| 1664 | 1664 | // each index item in the list must be a couple with a start and |
| 1665 | 1665 | // an end value : [0,3], [5-5], [8-10], ... |
| 1666 | 1666 | // ----- Check the format of each item |
| 1667 | - $v_sort_flag=false; |
|
| 1668 | - $v_sort_value=0; |
|
| 1669 | - for ($j=0; $j<sizeof($v_work_list); $j++) { |
|
| 1667 | + $v_sort_flag = false; |
|
| 1668 | + $v_sort_value = 0; |
|
| 1669 | + for ($j = 0; $j < sizeof($v_work_list); $j++) { |
|
| 1670 | 1670 | // ----- Explode the item |
| 1671 | 1671 | $v_item_list = explode("-", $v_work_list[$j]); |
| 1672 | 1672 | $v_size_item_list = sizeof($v_item_list); |
@@ -1696,7 +1696,7 @@ discard block |
||
| 1696 | 1696 | |
| 1697 | 1697 | // ----- Look for list sort |
| 1698 | 1698 | if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) { |
| 1699 | - $v_sort_flag=true; |
|
| 1699 | + $v_sort_flag = true; |
|
| 1700 | 1700 | |
| 1701 | 1701 | // ----- TBC : An automatic sort should be writen ... |
| 1702 | 1702 | // ----- Error log |
@@ -1730,7 +1730,7 @@ discard block |
||
| 1730 | 1730 | // ----- Look for options that request an octal value |
| 1731 | 1731 | case PCLZIP_OPT_SET_CHMOD : |
| 1732 | 1732 | // ----- Check the number of parameters |
| 1733 | - if (($i+1) >= $p_size) { |
|
| 1733 | + if (($i + 1) >= $p_size) { |
|
| 1734 | 1734 | // ----- Error log |
| 1735 | 1735 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1736 | 1736 | |
@@ -1739,7 +1739,7 @@ discard block |
||
| 1739 | 1739 | } |
| 1740 | 1740 | |
| 1741 | 1741 | // ----- Get the value |
| 1742 | - $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
|
| 1742 | + $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1]; |
|
| 1743 | 1743 | $i++; |
| 1744 | 1744 | break; |
| 1745 | 1745 | |
@@ -1755,7 +1755,7 @@ discard block |
||
| 1755 | 1755 | case PCLZIP_CB_POST_LIST : |
| 1756 | 1756 | */ |
| 1757 | 1757 | // ----- Check the number of parameters |
| 1758 | - if (($i+1) >= $p_size) { |
|
| 1758 | + if (($i + 1) >= $p_size) { |
|
| 1759 | 1759 | // ----- Error log |
| 1760 | 1760 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1761 | 1761 | |
@@ -1764,10 +1764,10 @@ discard block |
||
| 1764 | 1764 | } |
| 1765 | 1765 | |
| 1766 | 1766 | // ----- Get the value |
| 1767 | - $v_function_name = $p_options_list[$i+1]; |
|
| 1767 | + $v_function_name = $p_options_list[$i + 1]; |
|
| 1768 | 1768 | |
| 1769 | 1769 | // ----- Check that the value is a valid existing function |
| 1770 | - if (!function_exists($v_function_name)) { |
|
| 1770 | + if ( ! function_exists($v_function_name)) { |
|
| 1771 | 1771 | // ----- Error log |
| 1772 | 1772 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1773 | 1773 | |
@@ -1796,11 +1796,11 @@ discard block |
||
| 1796 | 1796 | |
| 1797 | 1797 | // ----- Look for mandatory options |
| 1798 | 1798 | if ($v_requested_options !== false) { |
| 1799 | - for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { |
|
| 1799 | + for ($key = reset($v_requested_options); $key = key($v_requested_options); $key = next($v_requested_options)) { |
|
| 1800 | 1800 | // ----- Look for mandatory option |
| 1801 | 1801 | if ($v_requested_options[$key] == 'mandatory') { |
| 1802 | 1802 | // ----- Look if present |
| 1803 | - if (!isset($v_result_list[$key])) { |
|
| 1803 | + if ( ! isset($v_result_list[$key])) { |
|
| 1804 | 1804 | // ----- Error log |
| 1805 | 1805 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); |
| 1806 | 1806 | |
@@ -1812,7 +1812,7 @@ discard block |
||
| 1812 | 1812 | } |
| 1813 | 1813 | |
| 1814 | 1814 | // ----- Look for default values |
| 1815 | - if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { |
|
| 1815 | + if ( ! isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { |
|
| 1816 | 1816 | |
| 1817 | 1817 | } |
| 1818 | 1818 | |
@@ -1829,7 +1829,7 @@ discard block |
||
| 1829 | 1829 | // -------------------------------------------------------------------------------- |
| 1830 | 1830 | function privOptionDefaultThreshold(&$p_options) |
| 1831 | 1831 | { |
| 1832 | - $v_result=1; |
|
| 1832 | + $v_result = 1; |
|
| 1833 | 1833 | |
| 1834 | 1834 | if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
| 1835 | 1835 | || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) { |
@@ -1842,16 +1842,16 @@ discard block |
||
| 1842 | 1842 | $v_memory_limit_int = (int) $v_memory_limit; |
| 1843 | 1843 | $last = strtolower(substr($v_memory_limit, -1)); |
| 1844 | 1844 | |
| 1845 | - if($last == 'g') |
|
| 1845 | + if ($last == 'g') |
|
| 1846 | 1846 | //$v_memory_limit_int = $v_memory_limit_int*1024*1024*1024; |
| 1847 | - $v_memory_limit_int = $v_memory_limit_int*1073741824; |
|
| 1848 | - if($last == 'm') |
|
| 1847 | + $v_memory_limit_int = $v_memory_limit_int * 1073741824; |
|
| 1848 | + if ($last == 'm') |
|
| 1849 | 1849 | //$v_memory_limit_int = $v_memory_limit_int*1024*1024; |
| 1850 | - $v_memory_limit_int = $v_memory_limit_int*1048576; |
|
| 1851 | - if($last == 'k') |
|
| 1852 | - $v_memory_limit_int = $v_memory_limit_int*1024; |
|
| 1850 | + $v_memory_limit_int = $v_memory_limit_int * 1048576; |
|
| 1851 | + if ($last == 'k') |
|
| 1852 | + $v_memory_limit_int = $v_memory_limit_int * 1024; |
|
| 1853 | 1853 | |
| 1854 | - $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit_int*PCLZIP_TEMPORARY_FILE_RATIO); |
|
| 1854 | + $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit_int * PCLZIP_TEMPORARY_FILE_RATIO); |
|
| 1855 | 1855 | |
| 1856 | 1856 | |
| 1857 | 1857 | // ----- Sanity check : No threshold if value lower than 1M |
@@ -1872,15 +1872,15 @@ discard block |
||
| 1872 | 1872 | // 1 on success. |
| 1873 | 1873 | // 0 on failure. |
| 1874 | 1874 | // -------------------------------------------------------------------------------- |
| 1875 | - function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false) |
|
| 1875 | + function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options = false) |
|
| 1876 | 1876 | { |
| 1877 | - $v_result=1; |
|
| 1877 | + $v_result = 1; |
|
| 1878 | 1878 | |
| 1879 | 1879 | // ----- For each file in the list check the attributes |
| 1880 | 1880 | foreach ($p_file_list as $v_key => $v_value) { |
| 1881 | 1881 | |
| 1882 | 1882 | // ----- Check if the option is supported |
| 1883 | - if (!isset($v_requested_options[$v_key])) { |
|
| 1883 | + if ( ! isset($v_requested_options[$v_key])) { |
|
| 1884 | 1884 | // ----- Error log |
| 1885 | 1885 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file"); |
| 1886 | 1886 | |
@@ -1891,7 +1891,7 @@ discard block |
||
| 1891 | 1891 | // ----- Look for attribute |
| 1892 | 1892 | switch ($v_key) { |
| 1893 | 1893 | case PCLZIP_ATT_FILE_NAME : |
| 1894 | - if (!is_string($v_value)) { |
|
| 1894 | + if ( ! is_string($v_value)) { |
|
| 1895 | 1895 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
| 1896 | 1896 | return PclZip::errorCode(); |
| 1897 | 1897 | } |
@@ -1906,7 +1906,7 @@ discard block |
||
| 1906 | 1906 | break; |
| 1907 | 1907 | |
| 1908 | 1908 | case PCLZIP_ATT_FILE_NEW_SHORT_NAME : |
| 1909 | - if (!is_string($v_value)) { |
|
| 1909 | + if ( ! is_string($v_value)) { |
|
| 1910 | 1910 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
| 1911 | 1911 | return PclZip::errorCode(); |
| 1912 | 1912 | } |
@@ -1920,7 +1920,7 @@ discard block |
||
| 1920 | 1920 | break; |
| 1921 | 1921 | |
| 1922 | 1922 | case PCLZIP_ATT_FILE_NEW_FULL_NAME : |
| 1923 | - if (!is_string($v_value)) { |
|
| 1923 | + if ( ! is_string($v_value)) { |
|
| 1924 | 1924 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
| 1925 | 1925 | return PclZip::errorCode(); |
| 1926 | 1926 | } |
@@ -1935,7 +1935,7 @@ discard block |
||
| 1935 | 1935 | |
| 1936 | 1936 | // ----- Look for options that takes a string |
| 1937 | 1937 | case PCLZIP_ATT_FILE_COMMENT : |
| 1938 | - if (!is_string($v_value)) { |
|
| 1938 | + if ( ! is_string($v_value)) { |
|
| 1939 | 1939 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
| 1940 | 1940 | return PclZip::errorCode(); |
| 1941 | 1941 | } |
@@ -1944,7 +1944,7 @@ discard block |
||
| 1944 | 1944 | break; |
| 1945 | 1945 | |
| 1946 | 1946 | case PCLZIP_ATT_FILE_MTIME : |
| 1947 | - if (!is_integer($v_value)) { |
|
| 1947 | + if ( ! is_integer($v_value)) { |
|
| 1948 | 1948 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'"); |
| 1949 | 1949 | return PclZip::errorCode(); |
| 1950 | 1950 | } |
@@ -1967,11 +1967,11 @@ discard block |
||
| 1967 | 1967 | |
| 1968 | 1968 | // ----- Look for mandatory options |
| 1969 | 1969 | if ($v_requested_options !== false) { |
| 1970 | - for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { |
|
| 1970 | + for ($key = reset($v_requested_options); $key = key($v_requested_options); $key = next($v_requested_options)) { |
|
| 1971 | 1971 | // ----- Look for mandatory option |
| 1972 | 1972 | if ($v_requested_options[$key] == 'mandatory') { |
| 1973 | 1973 | // ----- Look if present |
| 1974 | - if (!isset($p_file_list[$key])) { |
|
| 1974 | + if ( ! isset($p_file_list[$key])) { |
|
| 1975 | 1975 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); |
| 1976 | 1976 | return PclZip::errorCode(); |
| 1977 | 1977 | } |
@@ -2003,13 +2003,13 @@ discard block |
||
| 2003 | 2003 | // -------------------------------------------------------------------------------- |
| 2004 | 2004 | function privFileDescrExpand(&$p_filedescr_list, &$p_options) |
| 2005 | 2005 | { |
| 2006 | - $v_result=1; |
|
| 2006 | + $v_result = 1; |
|
| 2007 | 2007 | |
| 2008 | 2008 | // ----- Create a result list |
| 2009 | 2009 | $v_result_list = array(); |
| 2010 | 2010 | |
| 2011 | 2011 | // ----- Look each entry |
| 2012 | - for ($i=0; $i<sizeof($p_filedescr_list); $i++) { |
|
| 2012 | + for ($i = 0; $i < sizeof($p_filedescr_list); $i++) { |
|
| 2013 | 2013 | |
| 2014 | 2014 | // ----- Get filedescr |
| 2015 | 2015 | $v_descr = $p_filedescr_list[$i]; |
@@ -2076,7 +2076,7 @@ discard block |
||
| 2076 | 2076 | // Because the name of the folder was changed, the name of the |
| 2077 | 2077 | // files/sub-folders also change |
| 2078 | 2078 | if (($v_descr['stored_filename'] != $v_descr['filename']) |
| 2079 | - && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) { |
|
| 2079 | + && ( ! isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) { |
|
| 2080 | 2080 | if ($v_descr['stored_filename'] != '') { |
| 2081 | 2081 | $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; |
| 2082 | 2082 | } |
@@ -2128,7 +2128,7 @@ discard block |
||
| 2128 | 2128 | // -------------------------------------------------------------------------------- |
| 2129 | 2129 | function privCreate($p_filedescr_list, &$p_result_list, &$p_options) |
| 2130 | 2130 | { |
| 2131 | - $v_result=1; |
|
| 2131 | + $v_result = 1; |
|
| 2132 | 2132 | $v_list_detail = array(); |
| 2133 | 2133 | |
| 2134 | 2134 | // ----- Magic quotes trick |
@@ -2163,11 +2163,11 @@ discard block |
||
| 2163 | 2163 | // -------------------------------------------------------------------------------- |
| 2164 | 2164 | function privAdd($p_filedescr_list, &$p_result_list, &$p_options) |
| 2165 | 2165 | { |
| 2166 | - $v_result=1; |
|
| 2166 | + $v_result = 1; |
|
| 2167 | 2167 | $v_list_detail = array(); |
| 2168 | 2168 | |
| 2169 | 2169 | // ----- Look if the archive exists or is empty |
| 2170 | - if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0)) |
|
| 2170 | + if (( ! is_file($this->zipname)) || (filesize($this->zipname) == 0)) |
|
| 2171 | 2171 | { |
| 2172 | 2172 | |
| 2173 | 2173 | // ----- Do a create |
@@ -2180,7 +2180,7 @@ discard block |
||
| 2180 | 2180 | $this->privDisableMagicQuotes(); |
| 2181 | 2181 | |
| 2182 | 2182 | // ----- Open the zip file |
| 2183 | - if (($v_result=$this->privOpenFd('rb')) != 1) |
|
| 2183 | + if (($v_result = $this->privOpenFd('rb')) != 1) |
|
| 2184 | 2184 | { |
| 2185 | 2185 | // ----- Magic quotes trick |
| 2186 | 2186 | $this->privSwapBackMagicQuotes(); |
@@ -2261,7 +2261,7 @@ discard block |
||
| 2261 | 2261 | } |
| 2262 | 2262 | |
| 2263 | 2263 | // ----- Create the Central Dir files header |
| 2264 | - for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++) |
|
| 2264 | + for ($i = 0, $v_count = 0; $i < sizeof($v_header_list); $i++) |
|
| 2265 | 2265 | { |
| 2266 | 2266 | // ----- Create the file header |
| 2267 | 2267 | if ($v_header_list[$i]['status'] == 'ok') { |
@@ -2294,10 +2294,10 @@ discard block |
||
| 2294 | 2294 | } |
| 2295 | 2295 | |
| 2296 | 2296 | // ----- Calculate the size of the central header |
| 2297 | - $v_size = @ftell($this->zip_fd)-$v_offset; |
|
| 2297 | + $v_size = @ftell($this->zip_fd) - $v_offset; |
|
| 2298 | 2298 | |
| 2299 | 2299 | // ----- Create the central dir footer |
| 2300 | - if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 2300 | + if (($v_result = $this->privWriteCentralHeader($v_count + $v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 2301 | 2301 | { |
| 2302 | 2302 | // ----- Reset the file list |
| 2303 | 2303 | unset($v_header_list); |
@@ -2342,7 +2342,7 @@ discard block |
||
| 2342 | 2342 | // -------------------------------------------------------------------------------- |
| 2343 | 2343 | function privOpenFd($p_mode) |
| 2344 | 2344 | { |
| 2345 | - $v_result=1; |
|
| 2345 | + $v_result = 1; |
|
| 2346 | 2346 | |
| 2347 | 2347 | // ----- Look if already open |
| 2348 | 2348 | if ($this->zip_fd != 0) |
@@ -2376,7 +2376,7 @@ discard block |
||
| 2376 | 2376 | // -------------------------------------------------------------------------------- |
| 2377 | 2377 | function privCloseFd() |
| 2378 | 2378 | { |
| 2379 | - $v_result=1; |
|
| 2379 | + $v_result = 1; |
|
| 2380 | 2380 | |
| 2381 | 2381 | if ($this->zip_fd != 0) |
| 2382 | 2382 | @fclose($this->zip_fd); |
@@ -2403,7 +2403,7 @@ discard block |
||
| 2403 | 2403 | // function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options) |
| 2404 | 2404 | function privAddList($p_filedescr_list, &$p_result_list, &$p_options) |
| 2405 | 2405 | { |
| 2406 | - $v_result=1; |
|
| 2406 | + $v_result = 1; |
|
| 2407 | 2407 | |
| 2408 | 2408 | // ----- Add the files |
| 2409 | 2409 | $v_header_list = array(); |
@@ -2417,7 +2417,7 @@ discard block |
||
| 2417 | 2417 | $v_offset = @ftell($this->zip_fd); |
| 2418 | 2418 | |
| 2419 | 2419 | // ----- Create the Central Dir files header |
| 2420 | - for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++) |
|
| 2420 | + for ($i = 0, $v_count = 0; $i < sizeof($v_header_list); $i++) |
|
| 2421 | 2421 | { |
| 2422 | 2422 | // ----- Create the file header |
| 2423 | 2423 | if ($v_header_list[$i]['status'] == 'ok') { |
@@ -2439,7 +2439,7 @@ discard block |
||
| 2439 | 2439 | } |
| 2440 | 2440 | |
| 2441 | 2441 | // ----- Calculate the size of the central header |
| 2442 | - $v_size = @ftell($this->zip_fd)-$v_offset; |
|
| 2442 | + $v_size = @ftell($this->zip_fd) - $v_offset; |
|
| 2443 | 2443 | |
| 2444 | 2444 | // ----- Create the central dir footer |
| 2445 | 2445 | if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1) |
@@ -2467,14 +2467,14 @@ discard block |
||
| 2467 | 2467 | // -------------------------------------------------------------------------------- |
| 2468 | 2468 | function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options) |
| 2469 | 2469 | { |
| 2470 | - $v_result=1; |
|
| 2470 | + $v_result = 1; |
|
| 2471 | 2471 | $v_header = array(); |
| 2472 | 2472 | |
| 2473 | 2473 | // ----- Recuperate the current number of elt in list |
| 2474 | 2474 | $v_nb = sizeof($p_result_list); |
| 2475 | 2475 | |
| 2476 | 2476 | // ----- Loop on the files |
| 2477 | - for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) { |
|
| 2477 | + for ($j = 0; ($j < sizeof($p_filedescr_list)) && ($v_result == 1); $j++) { |
|
| 2478 | 2478 | // ----- Format the filename |
| 2479 | 2479 | $p_filedescr_list[$j]['filename'] |
| 2480 | 2480 | = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false); |
@@ -2487,8 +2487,8 @@ discard block |
||
| 2487 | 2487 | } |
| 2488 | 2488 | |
| 2489 | 2489 | // ----- Check the filename |
| 2490 | - if ( ($p_filedescr_list[$j]['type'] != 'virtual_file') |
|
| 2491 | - && (!file_exists($p_filedescr_list[$j]['filename']))) { |
|
| 2490 | + if (($p_filedescr_list[$j]['type'] != 'virtual_file') |
|
| 2491 | + && ( ! file_exists($p_filedescr_list[$j]['filename']))) { |
|
| 2492 | 2492 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist"); |
| 2493 | 2493 | return PclZip::errorCode(); |
| 2494 | 2494 | } |
@@ -2497,11 +2497,11 @@ discard block |
||
| 2497 | 2497 | // or a dir with all its path removed |
| 2498 | 2498 | // if ( (is_file($p_filedescr_list[$j]['filename'])) |
| 2499 | 2499 | // || ( is_dir($p_filedescr_list[$j]['filename']) |
| 2500 | - if ( ($p_filedescr_list[$j]['type'] == 'file') |
|
| 2500 | + if (($p_filedescr_list[$j]['type'] == 'file') |
|
| 2501 | 2501 | || ($p_filedescr_list[$j]['type'] == 'virtual_file') |
| 2502 | - || ( ($p_filedescr_list[$j]['type'] == 'folder') |
|
| 2503 | - && ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]) |
|
| 2504 | - || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) |
|
| 2502 | + || (($p_filedescr_list[$j]['type'] == 'folder') |
|
| 2503 | + && ( ! isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]) |
|
| 2504 | + || ! $p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) |
|
| 2505 | 2505 | ) { |
| 2506 | 2506 | |
| 2507 | 2507 | // ----- Add the file |
@@ -2529,7 +2529,7 @@ discard block |
||
| 2529 | 2529 | // -------------------------------------------------------------------------------- |
| 2530 | 2530 | function privAddFile($p_filedescr, &$p_header, &$p_options) |
| 2531 | 2531 | { |
| 2532 | - $v_result=1; |
|
| 2532 | + $v_result = 1; |
|
| 2533 | 2533 | |
| 2534 | 2534 | // ----- Working variable |
| 2535 | 2535 | $p_filename = $p_filedescr['filename']; |
@@ -2574,13 +2574,13 @@ discard block |
||
| 2574 | 2574 | $p_header['index'] = -1; |
| 2575 | 2575 | |
| 2576 | 2576 | // ----- Look for regular file |
| 2577 | - if ($p_filedescr['type']=='file') { |
|
| 2577 | + if ($p_filedescr['type'] == 'file') { |
|
| 2578 | 2578 | $p_header['external'] = 0x00000000; |
| 2579 | 2579 | $p_header['size'] = filesize($p_filename); |
| 2580 | 2580 | } |
| 2581 | 2581 | |
| 2582 | 2582 | // ----- Look for regular folder |
| 2583 | - else if ($p_filedescr['type']=='folder') { |
|
| 2583 | + else if ($p_filedescr['type'] == 'folder') { |
|
| 2584 | 2584 | $p_header['external'] = 0x00000010; |
| 2585 | 2585 | $p_header['mtime'] = filemtime($p_filename); |
| 2586 | 2586 | $p_header['size'] = filesize($p_filename); |
@@ -2654,10 +2654,10 @@ discard block |
||
| 2654 | 2654 | // ----- Look for a file |
| 2655 | 2655 | if ($p_filedescr['type'] == 'file') { |
| 2656 | 2656 | // ----- Look for using temporary file to zip |
| 2657 | - if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 2657 | + if (( ! isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 2658 | 2658 | && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) |
| 2659 | 2659 | || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
| 2660 | - && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) { |
|
| 2660 | + && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])))) { |
|
| 2661 | 2661 | $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options); |
| 2662 | 2662 | if ($v_result < PCLZIP_ERR_NO_ERROR) { |
| 2663 | 2663 | return $v_result; |
@@ -2757,7 +2757,7 @@ discard block |
||
| 2757 | 2757 | // ----- Set the file properties |
| 2758 | 2758 | $p_header['size'] = 0; |
| 2759 | 2759 | //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked |
| 2760 | - $p_header['external'] = 0x00000010; // Value for a folder : to be checked |
|
| 2760 | + $p_header['external'] = 0x00000010; // Value for a folder : to be checked |
|
| 2761 | 2761 | |
| 2762 | 2762 | // ----- Call the header generation |
| 2763 | 2763 | if (($v_result = $this->privWriteFileHeader($p_header)) != 1) |
@@ -2800,7 +2800,7 @@ discard block |
||
| 2800 | 2800 | // -------------------------------------------------------------------------------- |
| 2801 | 2801 | function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options) |
| 2802 | 2802 | { |
| 2803 | - $v_result=PCLZIP_ERR_NO_ERROR; |
|
| 2803 | + $v_result = PCLZIP_ERR_NO_ERROR; |
|
| 2804 | 2804 | |
| 2805 | 2805 | // ----- Working variable |
| 2806 | 2806 | $p_filename = $p_filedescr['filename']; |
@@ -2854,7 +2854,7 @@ discard block |
||
| 2854 | 2854 | $v_data_header['os'] = bin2hex($v_data_header['os']); |
| 2855 | 2855 | |
| 2856 | 2856 | // ----- Read the gzip file footer |
| 2857 | - @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8); |
|
| 2857 | + @fseek($v_file_compressed, filesize($v_gzip_temp_name) - 8); |
|
| 2858 | 2858 | $v_binary_data = @fread($v_file_compressed, 8); |
| 2859 | 2859 | $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data); |
| 2860 | 2860 | |
@@ -2862,7 +2862,7 @@ discard block |
||
| 2862 | 2862 | $p_header['compression'] = ord($v_data_header['cm']); |
| 2863 | 2863 | //$p_header['mtime'] = $v_data_header['mtime']; |
| 2864 | 2864 | $p_header['crc'] = $v_data_footer['crc']; |
| 2865 | - $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18; |
|
| 2865 | + $p_header['compressed_size'] = filesize($v_gzip_temp_name) - 18; |
|
| 2866 | 2866 | |
| 2867 | 2867 | // ----- Close the file |
| 2868 | 2868 | @fclose($v_file_compressed); |
@@ -2912,7 +2912,7 @@ discard block |
||
| 2912 | 2912 | // -------------------------------------------------------------------------------- |
| 2913 | 2913 | function privCalculateStoredFilename(&$p_filedescr, &$p_options) |
| 2914 | 2914 | { |
| 2915 | - $v_result=1; |
|
| 2915 | + $v_result = 1; |
|
| 2916 | 2916 | |
| 2917 | 2917 | // ----- Working variables |
| 2918 | 2918 | $p_filename = $p_filedescr['filename']; |
@@ -2969,14 +2969,14 @@ discard block |
||
| 2969 | 2969 | if (substr($p_remove_dir, -1) != '/') |
| 2970 | 2970 | $p_remove_dir .= "/"; |
| 2971 | 2971 | |
| 2972 | - if ( (substr($p_filename, 0, 2) == "./") |
|
| 2972 | + if ((substr($p_filename, 0, 2) == "./") |
|
| 2973 | 2973 | || (substr($p_remove_dir, 0, 2) == "./")) { |
| 2974 | 2974 | |
| 2975 | - if ( (substr($p_filename, 0, 2) == "./") |
|
| 2975 | + if ((substr($p_filename, 0, 2) == "./") |
|
| 2976 | 2976 | && (substr($p_remove_dir, 0, 2) != "./")) { |
| 2977 | 2977 | $p_remove_dir = "./".$p_remove_dir; |
| 2978 | 2978 | } |
| 2979 | - if ( (substr($p_filename, 0, 2) != "./") |
|
| 2979 | + if ((substr($p_filename, 0, 2) != "./") |
|
| 2980 | 2980 | && (substr($p_remove_dir, 0, 2) == "./")) { |
| 2981 | 2981 | $p_remove_dir = substr($p_remove_dir, 2); |
| 2982 | 2982 | } |
@@ -3024,15 +3024,15 @@ discard block |
||
| 3024 | 3024 | // -------------------------------------------------------------------------------- |
| 3025 | 3025 | function privWriteFileHeader(&$p_header) |
| 3026 | 3026 | { |
| 3027 | - $v_result=1; |
|
| 3027 | + $v_result = 1; |
|
| 3028 | 3028 | |
| 3029 | 3029 | // ----- Store the offset position of the file |
| 3030 | 3030 | $p_header['offset'] = ftell($this->zip_fd); |
| 3031 | 3031 | |
| 3032 | 3032 | // ----- Transform UNIX mtime to DOS format mdate/mtime |
| 3033 | 3033 | $v_date = getdate($p_header['mtime']); |
| 3034 | - $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 3035 | - $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 3034 | + $v_mtime = ($v_date['hours'] << 11) + ($v_date['minutes'] << 5) + $v_date['seconds'] / 2; |
|
| 3035 | + $v_mdate = (($v_date['year'] - 1980) << 9) + ($v_date['mon'] << 5) + $v_date['mday']; |
|
| 3036 | 3036 | |
| 3037 | 3037 | // ----- Packed data |
| 3038 | 3038 | $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, |
@@ -3069,7 +3069,7 @@ discard block |
||
| 3069 | 3069 | // -------------------------------------------------------------------------------- |
| 3070 | 3070 | function privWriteCentralFileHeader(&$p_header) |
| 3071 | 3071 | { |
| 3072 | - $v_result=1; |
|
| 3072 | + $v_result = 1; |
|
| 3073 | 3073 | |
| 3074 | 3074 | // TBC |
| 3075 | 3075 | //for(reset($p_header); $key = key($p_header); next($p_header)) { |
@@ -3077,8 +3077,8 @@ discard block |
||
| 3077 | 3077 | |
| 3078 | 3078 | // ----- Transform UNIX mtime to DOS format mdate/mtime |
| 3079 | 3079 | $v_date = getdate($p_header['mtime']); |
| 3080 | - $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 3081 | - $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 3080 | + $v_mtime = ($v_date['hours'] << 11) + ($v_date['minutes'] << 5) + $v_date['seconds'] / 2; |
|
| 3081 | + $v_mdate = (($v_date['year'] - 1980) << 9) + ($v_date['mon'] << 5) + $v_date['mday']; |
|
| 3082 | 3082 | |
| 3083 | 3083 | |
| 3084 | 3084 | // ----- Packed data |
@@ -3122,7 +3122,7 @@ discard block |
||
| 3122 | 3122 | // -------------------------------------------------------------------------------- |
| 3123 | 3123 | function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) |
| 3124 | 3124 | { |
| 3125 | - $v_result=1; |
|
| 3125 | + $v_result = 1; |
|
| 3126 | 3126 | |
| 3127 | 3127 | // ----- Packed data |
| 3128 | 3128 | $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, |
@@ -3151,7 +3151,7 @@ discard block |
||
| 3151 | 3151 | // -------------------------------------------------------------------------------- |
| 3152 | 3152 | function privList(&$p_list) |
| 3153 | 3153 | { |
| 3154 | - $v_result=1; |
|
| 3154 | + $v_result = 1; |
|
| 3155 | 3155 | |
| 3156 | 3156 | // ----- Magic quotes trick |
| 3157 | 3157 | $this->privDisableMagicQuotes(); |
@@ -3191,7 +3191,7 @@ discard block |
||
| 3191 | 3191 | } |
| 3192 | 3192 | |
| 3193 | 3193 | // ----- Read each entry |
| 3194 | - for ($i=0; $i<$v_central_dir['entries']; $i++) |
|
| 3194 | + for ($i = 0; $i < $v_central_dir['entries']; $i++) |
|
| 3195 | 3195 | { |
| 3196 | 3196 | // ----- Read the file header |
| 3197 | 3197 | if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) |
@@ -3238,7 +3238,7 @@ discard block |
||
| 3238 | 3238 | // -------------------------------------------------------------------------------- |
| 3239 | 3239 | function privConvertHeader2FileInfo($p_header, &$p_info) |
| 3240 | 3240 | { |
| 3241 | - $v_result=1; |
|
| 3241 | + $v_result = 1; |
|
| 3242 | 3242 | |
| 3243 | 3243 | // ----- Get the interesting attributes |
| 3244 | 3244 | $v_temp_path = PclZipUtilPathReduction($p_header['filename']); |
@@ -3249,7 +3249,7 @@ discard block |
||
| 3249 | 3249 | $p_info['compressed_size'] = $p_header['compressed_size']; |
| 3250 | 3250 | $p_info['mtime'] = $p_header['mtime']; |
| 3251 | 3251 | $p_info['comment'] = $p_header['comment']; |
| 3252 | - $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); |
|
| 3252 | + $p_info['folder'] = (($p_header['external'] & 0x00000010) == 0x00000010); |
|
| 3253 | 3253 | $p_info['index'] = $p_header['index']; |
| 3254 | 3254 | $p_info['status'] = $p_header['status']; |
| 3255 | 3255 | $p_info['crc'] = $p_header['crc']; |
@@ -3277,16 +3277,16 @@ discard block |
||
| 3277 | 3277 | // -------------------------------------------------------------------------------- |
| 3278 | 3278 | function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) |
| 3279 | 3279 | { |
| 3280 | - $v_result=1; |
|
| 3280 | + $v_result = 1; |
|
| 3281 | 3281 | |
| 3282 | 3282 | // ----- Magic quotes trick |
| 3283 | 3283 | $this->privDisableMagicQuotes(); |
| 3284 | 3284 | |
| 3285 | 3285 | // ----- Check the path |
| 3286 | - if ( ($p_path == "") |
|
| 3287 | - || ( (substr($p_path, 0, 1) != "/") |
|
| 3286 | + if (($p_path == "") |
|
| 3287 | + || ((substr($p_path, 0, 1) != "/") |
|
| 3288 | 3288 | && (substr($p_path, 0, 3) != "../") |
| 3289 | - && (substr($p_path,1,2)!=":/"))) |
|
| 3289 | + && (substr($p_path, 1, 2) != ":/"))) |
|
| 3290 | 3290 | $p_path = "./".$p_path; |
| 3291 | 3291 | |
| 3292 | 3292 | // ----- Reduce the path last (and duplicated) '/' |
@@ -3295,7 +3295,7 @@ discard block |
||
| 3295 | 3295 | // ----- Look for the path end '/' |
| 3296 | 3296 | while (substr($p_path, -1) == "/") |
| 3297 | 3297 | { |
| 3298 | - $p_path = substr($p_path, 0, strlen($p_path)-1); |
|
| 3298 | + $p_path = substr($p_path, 0, strlen($p_path) - 1); |
|
| 3299 | 3299 | } |
| 3300 | 3300 | } |
| 3301 | 3301 | |
@@ -3329,7 +3329,7 @@ discard block |
||
| 3329 | 3329 | |
| 3330 | 3330 | // ----- Read each entry |
| 3331 | 3331 | $j_start = 0; |
| 3332 | - for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) |
|
| 3332 | + for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++) |
|
| 3333 | 3333 | { |
| 3334 | 3334 | |
| 3335 | 3335 | // ----- Read next Central dir entry |
@@ -3368,17 +3368,17 @@ discard block |
||
| 3368 | 3368 | $v_extract = false; |
| 3369 | 3369 | |
| 3370 | 3370 | // ----- Look for extract by name rule |
| 3371 | - if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 3371 | + if ((isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 3372 | 3372 | && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { |
| 3373 | 3373 | |
| 3374 | 3374 | // ----- Look if the filename is in the list |
| 3375 | - for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) { |
|
| 3375 | + for ($j = 0; ($j < sizeof($p_options[PCLZIP_OPT_BY_NAME])) && ( ! $v_extract); $j++) { |
|
| 3376 | 3376 | |
| 3377 | 3377 | // ----- Look for a directory |
| 3378 | 3378 | if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") { |
| 3379 | 3379 | |
| 3380 | 3380 | // ----- Look if the directory is in the filename path |
| 3381 | - if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 3381 | + if ((strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 3382 | 3382 | && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { |
| 3383 | 3383 | $v_extract = true; |
| 3384 | 3384 | } |
@@ -3403,7 +3403,7 @@ discard block |
||
| 3403 | 3403 | */ |
| 3404 | 3404 | |
| 3405 | 3405 | // ----- Look for extract by preg rule |
| 3406 | - else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 3406 | + else if ((isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 3407 | 3407 | && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { |
| 3408 | 3408 | |
| 3409 | 3409 | if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) { |
@@ -3412,20 +3412,20 @@ discard block |
||
| 3412 | 3412 | } |
| 3413 | 3413 | |
| 3414 | 3414 | // ----- Look for extract by index rule |
| 3415 | - else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 3415 | + else if ((isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 3416 | 3416 | && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { |
| 3417 | 3417 | |
| 3418 | 3418 | // ----- Look if the index is in the list |
| 3419 | - for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) { |
|
| 3419 | + for ($j = $j_start; ($j < sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && ( ! $v_extract); $j++) { |
|
| 3420 | 3420 | |
| 3421 | - if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { |
|
| 3421 | + if (($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i <= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { |
|
| 3422 | 3422 | $v_extract = true; |
| 3423 | 3423 | } |
| 3424 | - if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { |
|
| 3425 | - $j_start = $j+1; |
|
| 3424 | + if ($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { |
|
| 3425 | + $j_start = $j + 1; |
|
| 3426 | 3426 | } |
| 3427 | 3427 | |
| 3428 | - if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { |
|
| 3428 | + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start'] > $i) { |
|
| 3429 | 3429 | break; |
| 3430 | 3430 | } |
| 3431 | 3431 | } |
@@ -3437,14 +3437,14 @@ discard block |
||
| 3437 | 3437 | } |
| 3438 | 3438 | |
| 3439 | 3439 | // ----- Check compression method |
| 3440 | - if ( ($v_extract) |
|
| 3441 | - && ( ($v_header['compression'] != 8) |
|
| 3440 | + if (($v_extract) |
|
| 3441 | + && (($v_header['compression'] != 8) |
|
| 3442 | 3442 | && ($v_header['compression'] != 0))) { |
| 3443 | 3443 | $v_header['status'] = 'unsupported_compression'; |
| 3444 | 3444 | |
| 3445 | 3445 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
| 3446 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3447 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3446 | + if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3447 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) { |
|
| 3448 | 3448 | |
| 3449 | 3449 | $this->privSwapBackMagicQuotes(); |
| 3450 | 3450 | |
@@ -3462,8 +3462,8 @@ discard block |
||
| 3462 | 3462 | $v_header['status'] = 'unsupported_encryption'; |
| 3463 | 3463 | |
| 3464 | 3464 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
| 3465 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3466 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3465 | + if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3466 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) { |
|
| 3467 | 3467 | |
| 3468 | 3468 | $this->privSwapBackMagicQuotes(); |
| 3469 | 3469 | |
@@ -3544,7 +3544,7 @@ discard block |
||
| 3544 | 3544 | } |
| 3545 | 3545 | } |
| 3546 | 3546 | // ----- Look for extraction in standard output |
| 3547 | - elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) |
|
| 3547 | + elseif ((isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) |
|
| 3548 | 3548 | && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) { |
| 3549 | 3549 | // ----- Extracting the file in standard output |
| 3550 | 3550 | $v_result1 = $this->privExtractFileInOutput($v_header, $p_options); |
@@ -3617,7 +3617,7 @@ discard block |
||
| 3617 | 3617 | // -------------------------------------------------------------------------------- |
| 3618 | 3618 | function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) |
| 3619 | 3619 | { |
| 3620 | - $v_result=1; |
|
| 3620 | + $v_result = 1; |
|
| 3621 | 3621 | |
| 3622 | 3622 | // ----- Read the file header |
| 3623 | 3623 | if (($v_result = $this->privReadFileHeader($v_header)) != 1) |
@@ -3635,7 +3635,7 @@ discard block |
||
| 3635 | 3635 | // ----- Look for all path to remove |
| 3636 | 3636 | if ($p_remove_all_path == true) { |
| 3637 | 3637 | // ----- Look for folder entry that not need to be extracted |
| 3638 | - if (($p_entry['external']&0x00000010)==0x00000010) { |
|
| 3638 | + if (($p_entry['external'] & 0x00000010) == 0x00000010) { |
|
| 3639 | 3639 | |
| 3640 | 3640 | $p_entry['status'] = "filtered"; |
| 3641 | 3641 | |
@@ -3736,8 +3736,8 @@ discard block |
||
| 3736 | 3736 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
| 3737 | 3737 | // For historical reason first PclZip implementation does not stop |
| 3738 | 3738 | // when this kind of error occurs. |
| 3739 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3740 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3739 | + if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3740 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) { |
|
| 3741 | 3741 | |
| 3742 | 3742 | PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY, |
| 3743 | 3743 | "Filename '".$p_entry['filename']."' is " |
@@ -3747,7 +3747,7 @@ discard block |
||
| 3747 | 3747 | } |
| 3748 | 3748 | } |
| 3749 | 3749 | // ----- Look if file is write protected |
| 3750 | - else if (!is_writeable($p_entry['filename'])) |
|
| 3750 | + else if ( ! is_writeable($p_entry['filename'])) |
|
| 3751 | 3751 | { |
| 3752 | 3752 | |
| 3753 | 3753 | // ----- Change the file status |
@@ -3756,8 +3756,8 @@ discard block |
||
| 3756 | 3756 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
| 3757 | 3757 | // For historical reason first PclZip implementation does not stop |
| 3758 | 3758 | // when this kind of error occurs. |
| 3759 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3760 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3759 | + if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3760 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) { |
|
| 3761 | 3761 | |
| 3762 | 3762 | PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, |
| 3763 | 3763 | "Filename '".$p_entry['filename']."' exists " |
@@ -3771,8 +3771,8 @@ discard block |
||
| 3771 | 3771 | else if (filemtime($p_entry['filename']) > $p_entry['mtime']) |
| 3772 | 3772 | { |
| 3773 | 3773 | // ----- Change the file status |
| 3774 | - if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) |
|
| 3775 | - && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) { |
|
| 3774 | + if ((isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) |
|
| 3775 | + && ($p_options[PCLZIP_OPT_REPLACE_NEWER] === true)) { |
|
| 3776 | 3776 | } |
| 3777 | 3777 | else { |
| 3778 | 3778 | $p_entry['status'] = "newer_exist"; |
@@ -3780,8 +3780,8 @@ discard block |
||
| 3780 | 3780 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
| 3781 | 3781 | // For historical reason first PclZip implementation does not stop |
| 3782 | 3782 | // when this kind of error occurs. |
| 3783 | - if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3784 | - && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { |
|
| 3783 | + if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) |
|
| 3784 | + && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) { |
|
| 3785 | 3785 | |
| 3786 | 3786 | PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, |
| 3787 | 3787 | "Newer version of '".$p_entry['filename']."' exists " |
@@ -3797,14 +3797,14 @@ discard block |
||
| 3797 | 3797 | |
| 3798 | 3798 | // ----- Check the directory availability and create it if necessary |
| 3799 | 3799 | else { |
| 3800 | - if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) |
|
| 3800 | + if ((($p_entry['external'] & 0x00000010) == 0x00000010) || (substr($p_entry['filename'], -1) == '/')) |
|
| 3801 | 3801 | $v_dir_to_check = $p_entry['filename']; |
| 3802 | - else if (!strstr($p_entry['filename'], "/")) |
|
| 3802 | + else if ( ! strstr($p_entry['filename'], "/")) |
|
| 3803 | 3803 | $v_dir_to_check = ""; |
| 3804 | 3804 | else |
| 3805 | 3805 | $v_dir_to_check = dirname($p_entry['filename']); |
| 3806 | 3806 | |
| 3807 | - if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) { |
|
| 3807 | + if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external'] & 0x00000010) == 0x00000010))) != 1) { |
|
| 3808 | 3808 | |
| 3809 | 3809 | // ----- Change the file status |
| 3810 | 3810 | $p_entry['status'] = "path_creation_fail"; |
@@ -3820,7 +3820,7 @@ discard block |
||
| 3820 | 3820 | if ($p_entry['status'] == 'ok') { |
| 3821 | 3821 | |
| 3822 | 3822 | // ----- Do the extraction (if not a folder) |
| 3823 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) |
|
| 3823 | + if ( ! (($p_entry['external'] & 0x00000010) == 0x00000010)) |
|
| 3824 | 3824 | { |
| 3825 | 3825 | // ----- Look for not compressed file |
| 3826 | 3826 | if ($p_entry['compression'] == 0) { |
@@ -3869,10 +3869,10 @@ discard block |
||
| 3869 | 3869 | |
| 3870 | 3870 | |
| 3871 | 3871 | // ----- Look for using temporary file to unzip |
| 3872 | - if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 3872 | + if (( ! isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) |
|
| 3873 | 3873 | && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) |
| 3874 | 3874 | || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) |
| 3875 | - && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) { |
|
| 3875 | + && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])))) { |
|
| 3876 | 3876 | $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options); |
| 3877 | 3877 | if ($v_result < PCLZIP_ERR_NO_ERROR) { |
| 3878 | 3878 | return $v_result; |
@@ -3966,7 +3966,7 @@ discard block |
||
| 3966 | 3966 | // -------------------------------------------------------------------------------- |
| 3967 | 3967 | function privExtractFileUsingTempFile(&$p_entry, &$p_options) |
| 3968 | 3968 | { |
| 3969 | - $v_result=1; |
|
| 3969 | + $v_result = 1; |
|
| 3970 | 3970 | |
| 3971 | 3971 | // ----- Creates a temporary file |
| 3972 | 3972 | $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz'; |
@@ -4042,7 +4042,7 @@ discard block |
||
| 4042 | 4042 | // -------------------------------------------------------------------------------- |
| 4043 | 4043 | function privExtractFileInOutput(&$p_entry, &$p_options) |
| 4044 | 4044 | { |
| 4045 | - $v_result=1; |
|
| 4045 | + $v_result = 1; |
|
| 4046 | 4046 | |
| 4047 | 4047 | // ----- Read the file header |
| 4048 | 4048 | if (($v_result = $this->privReadFileHeader($v_header)) != 1) { |
@@ -4091,7 +4091,7 @@ discard block |
||
| 4091 | 4091 | if ($p_entry['status'] == 'ok') { |
| 4092 | 4092 | |
| 4093 | 4093 | // ----- Do the extraction (if not a folder) |
| 4094 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
|
| 4094 | + if ( ! (($p_entry['external'] & 0x00000010) == 0x00000010)) { |
|
| 4095 | 4095 | // ----- Look for not compressed file |
| 4096 | 4096 | if ($p_entry['compressed_size'] == $p_entry['size']) { |
| 4097 | 4097 | |
@@ -4153,7 +4153,7 @@ discard block |
||
| 4153 | 4153 | // -------------------------------------------------------------------------------- |
| 4154 | 4154 | function privExtractFileAsString(&$p_entry, &$p_string, &$p_options) |
| 4155 | 4155 | { |
| 4156 | - $v_result=1; |
|
| 4156 | + $v_result = 1; |
|
| 4157 | 4157 | |
| 4158 | 4158 | // ----- Read the file header |
| 4159 | 4159 | $v_header = array(); |
@@ -4203,7 +4203,7 @@ discard block |
||
| 4203 | 4203 | if ($p_entry['status'] == 'ok') { |
| 4204 | 4204 | |
| 4205 | 4205 | // ----- Do the extraction (if not a folder) |
| 4206 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
|
| 4206 | + if ( ! (($p_entry['external'] & 0x00000010) == 0x00000010)) { |
|
| 4207 | 4207 | // ----- Look for not compressed file |
| 4208 | 4208 | // if ($p_entry['compressed_size'] == $p_entry['size']) |
| 4209 | 4209 | if ($p_entry['compression'] == 0) { |
@@ -4274,7 +4274,7 @@ discard block |
||
| 4274 | 4274 | // -------------------------------------------------------------------------------- |
| 4275 | 4275 | function privReadFileHeader(&$p_header) |
| 4276 | 4276 | { |
| 4277 | - $v_result=1; |
|
| 4277 | + $v_result = 1; |
|
| 4278 | 4278 | |
| 4279 | 4279 | // ----- Read the 4 bytes signature |
| 4280 | 4280 | $v_binary_data = @fread($this->zip_fd, 4); |
@@ -4338,7 +4338,7 @@ discard block |
||
| 4338 | 4338 | // ----- Extract time |
| 4339 | 4339 | $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
| 4340 | 4340 | $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
| 4341 | - $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 4341 | + $v_seconde = ($p_header['mtime'] & 0x001F) * 2; |
|
| 4342 | 4342 | |
| 4343 | 4343 | // ----- Extract date |
| 4344 | 4344 | $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
@@ -4377,7 +4377,7 @@ discard block |
||
| 4377 | 4377 | // -------------------------------------------------------------------------------- |
| 4378 | 4378 | function privReadCentralFileHeader(&$p_header) |
| 4379 | 4379 | { |
| 4380 | - $v_result=1; |
|
| 4380 | + $v_result = 1; |
|
| 4381 | 4381 | |
| 4382 | 4382 | // ----- Read the 4 bytes signature |
| 4383 | 4383 | $v_binary_data = @fread($this->zip_fd, 4); |
@@ -4441,7 +4441,7 @@ discard block |
||
| 4441 | 4441 | // ----- Extract time |
| 4442 | 4442 | $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
| 4443 | 4443 | $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
| 4444 | - $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 4444 | + $v_seconde = ($p_header['mtime'] & 0x001F) * 2; |
|
| 4445 | 4445 | |
| 4446 | 4446 | // ----- Extract date |
| 4447 | 4447 | $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
@@ -4485,7 +4485,7 @@ discard block |
||
| 4485 | 4485 | // -------------------------------------------------------------------------------- |
| 4486 | 4486 | function privCheckFileHeaders(&$p_local_header, &$p_central_header) |
| 4487 | 4487 | { |
| 4488 | - $v_result=1; |
|
| 4488 | + $v_result = 1; |
|
| 4489 | 4489 | |
| 4490 | 4490 | // ----- Check the static values |
| 4491 | 4491 | // TBC |
@@ -4522,7 +4522,7 @@ discard block |
||
| 4522 | 4522 | // -------------------------------------------------------------------------------- |
| 4523 | 4523 | function privReadEndCentralDir(&$p_central_dir) |
| 4524 | 4524 | { |
| 4525 | - $v_result=1; |
|
| 4525 | + $v_result = 1; |
|
| 4526 | 4526 | |
| 4527 | 4527 | // ----- Go to the end of the zip file |
| 4528 | 4528 | $v_size = filesize($this->zipname); |
@@ -4540,8 +4540,8 @@ discard block |
||
| 4540 | 4540 | // in this case the end of central dir is at 22 bytes of the file end |
| 4541 | 4541 | $v_found = 0; |
| 4542 | 4542 | if ($v_size > 26) { |
| 4543 | - @fseek($this->zip_fd, $v_size-22); |
|
| 4544 | - if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22)) |
|
| 4543 | + @fseek($this->zip_fd, $v_size - 22); |
|
| 4544 | + if (($v_pos = @ftell($this->zip_fd)) != ($v_size - 22)) |
|
| 4545 | 4545 | { |
| 4546 | 4546 | // ----- Error log |
| 4547 | 4547 | PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); |
@@ -4563,12 +4563,12 @@ discard block |
||
| 4563 | 4563 | } |
| 4564 | 4564 | |
| 4565 | 4565 | // ----- Go back to the maximum possible size of the Central Dir End Record |
| 4566 | - if (!$v_found) { |
|
| 4566 | + if ( ! $v_found) { |
|
| 4567 | 4567 | $v_maximum_size = 65557; // 0xFFFF + 22; |
| 4568 | 4568 | if ($v_maximum_size > $v_size) |
| 4569 | 4569 | $v_maximum_size = $v_size; |
| 4570 | - @fseek($this->zip_fd, $v_size-$v_maximum_size); |
|
| 4571 | - if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) |
|
| 4570 | + @fseek($this->zip_fd, $v_size - $v_maximum_size); |
|
| 4571 | + if (@ftell($this->zip_fd) != ($v_size - $v_maximum_size)) |
|
| 4572 | 4572 | { |
| 4573 | 4573 | // ----- Error log |
| 4574 | 4574 | PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); |
@@ -4589,7 +4589,7 @@ discard block |
||
| 4589 | 4589 | //$v_bytes = ($v_bytes << 8) | Ord($v_byte); |
| 4590 | 4590 | // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number |
| 4591 | 4591 | // Otherwise on systems where we have 64bit integers the check below for the magic number will fail. |
| 4592 | - $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); |
|
| 4592 | + $v_bytes = (($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); |
|
| 4593 | 4593 | |
| 4594 | 4594 | // ----- Compare the bytes |
| 4595 | 4595 | if ($v_bytes == 0x504b0506) |
@@ -4679,11 +4679,11 @@ discard block |
||
| 4679 | 4679 | // -------------------------------------------------------------------------------- |
| 4680 | 4680 | function privDeleteByRule(&$p_result_list, &$p_options) |
| 4681 | 4681 | { |
| 4682 | - $v_result=1; |
|
| 4682 | + $v_result = 1; |
|
| 4683 | 4683 | $v_list_detail = array(); |
| 4684 | 4684 | |
| 4685 | 4685 | // ----- Open the zip file |
| 4686 | - if (($v_result=$this->privOpenFd('rb')) != 1) |
|
| 4686 | + if (($v_result = $this->privOpenFd('rb')) != 1) |
|
| 4687 | 4687 | { |
| 4688 | 4688 | // ----- Return |
| 4689 | 4689 | return $v_result; |
@@ -4719,7 +4719,7 @@ discard block |
||
| 4719 | 4719 | // ----- Read each entry |
| 4720 | 4720 | $v_header_list = array(); |
| 4721 | 4721 | $j_start = 0; |
| 4722 | - for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) |
|
| 4722 | + for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++) |
|
| 4723 | 4723 | { |
| 4724 | 4724 | |
| 4725 | 4725 | // ----- Read the file header |
@@ -4740,21 +4740,21 @@ discard block |
||
| 4740 | 4740 | $v_found = false; |
| 4741 | 4741 | |
| 4742 | 4742 | // ----- Look for extract by name rule |
| 4743 | - if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 4743 | + if ((isset($p_options[PCLZIP_OPT_BY_NAME])) |
|
| 4744 | 4744 | && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { |
| 4745 | 4745 | |
| 4746 | 4746 | // ----- Look if the filename is in the list |
| 4747 | - for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) { |
|
| 4747 | + for ($j = 0; ($j < sizeof($p_options[PCLZIP_OPT_BY_NAME])) && ( ! $v_found); $j++) { |
|
| 4748 | 4748 | |
| 4749 | 4749 | // ----- Look for a directory |
| 4750 | 4750 | if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") { |
| 4751 | 4751 | |
| 4752 | 4752 | // ----- Look if the directory is in the filename path |
| 4753 | - if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 4753 | + if ((strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
|
| 4754 | 4754 | && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { |
| 4755 | 4755 | $v_found = true; |
| 4756 | 4756 | } |
| 4757 | - elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
| 4757 | + elseif ((($v_header_list[$v_nb_extracted]['external'] & 0x00000010) == 0x00000010) /* Indicates a folder */ |
|
| 4758 | 4758 | && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) { |
| 4759 | 4759 | $v_found = true; |
| 4760 | 4760 | } |
@@ -4779,7 +4779,7 @@ discard block |
||
| 4779 | 4779 | */ |
| 4780 | 4780 | |
| 4781 | 4781 | // ----- Look for extract by preg rule |
| 4782 | - else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 4782 | + else if ((isset($p_options[PCLZIP_OPT_BY_PREG])) |
|
| 4783 | 4783 | && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { |
| 4784 | 4784 | |
| 4785 | 4785 | if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { |
@@ -4788,20 +4788,20 @@ discard block |
||
| 4788 | 4788 | } |
| 4789 | 4789 | |
| 4790 | 4790 | // ----- Look for extract by index rule |
| 4791 | - else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 4791 | + else if ((isset($p_options[PCLZIP_OPT_BY_INDEX])) |
|
| 4792 | 4792 | && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { |
| 4793 | 4793 | |
| 4794 | 4794 | // ----- Look if the index is in the list |
| 4795 | - for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) { |
|
| 4795 | + for ($j = $j_start; ($j < sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && ( ! $v_found); $j++) { |
|
| 4796 | 4796 | |
| 4797 | - if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { |
|
| 4797 | + if (($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i <= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { |
|
| 4798 | 4798 | $v_found = true; |
| 4799 | 4799 | } |
| 4800 | - if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { |
|
| 4801 | - $j_start = $j+1; |
|
| 4800 | + if ($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { |
|
| 4801 | + $j_start = $j + 1; |
|
| 4802 | 4802 | } |
| 4803 | 4803 | |
| 4804 | - if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { |
|
| 4804 | + if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start'] > $i) { |
|
| 4805 | 4805 | break; |
| 4806 | 4806 | } |
| 4807 | 4807 | } |
@@ -4839,11 +4839,11 @@ discard block |
||
| 4839 | 4839 | } |
| 4840 | 4840 | |
| 4841 | 4841 | // ----- Look which file need to be kept |
| 4842 | - for ($i=0; $i<sizeof($v_header_list); $i++) { |
|
| 4842 | + for ($i = 0; $i < sizeof($v_header_list); $i++) { |
|
| 4843 | 4843 | |
| 4844 | 4844 | // ----- Calculate the position of the header |
| 4845 | 4845 | @rewind($this->zip_fd); |
| 4846 | - if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) { |
|
| 4846 | + if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) { |
|
| 4847 | 4847 | // ----- Close the zip file |
| 4848 | 4848 | $this->privCloseFd(); |
| 4849 | 4849 | $v_temp_zip->privCloseFd(); |
@@ -4902,7 +4902,7 @@ discard block |
||
| 4902 | 4902 | $v_offset = @ftell($v_temp_zip->zip_fd); |
| 4903 | 4903 | |
| 4904 | 4904 | // ----- Re-Create the Central Dir files header |
| 4905 | - for ($i=0; $i<sizeof($v_header_list); $i++) { |
|
| 4905 | + for ($i = 0; $i < sizeof($v_header_list); $i++) { |
|
| 4906 | 4906 | // ----- Create the file header |
| 4907 | 4907 | if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) { |
| 4908 | 4908 | $v_temp_zip->privCloseFd(); |
@@ -4925,7 +4925,7 @@ discard block |
||
| 4925 | 4925 | } |
| 4926 | 4926 | |
| 4927 | 4927 | // ----- Calculate the size of the central header |
| 4928 | - $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset; |
|
| 4928 | + $v_size = @ftell($v_temp_zip->zip_fd) - $v_offset; |
|
| 4929 | 4929 | |
| 4930 | 4930 | // ----- Create the central dir footer |
| 4931 | 4931 | if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) { |
@@ -4987,15 +4987,15 @@ discard block |
||
| 4987 | 4987 | // 1 : OK |
| 4988 | 4988 | // -1 : Unable to create directory |
| 4989 | 4989 | // -------------------------------------------------------------------------------- |
| 4990 | - function privDirCheck($p_dir, $p_is_dir=false) |
|
| 4990 | + function privDirCheck($p_dir, $p_is_dir = false) |
|
| 4991 | 4991 | { |
| 4992 | 4992 | $v_result = 1; |
| 4993 | 4993 | |
| 4994 | 4994 | |
| 4995 | 4995 | // ----- Remove the final '/' |
| 4996 | - if (($p_is_dir) && (substr($p_dir, -1)=='/')) |
|
| 4996 | + if (($p_is_dir) && (substr($p_dir, -1) == '/')) |
|
| 4997 | 4997 | { |
| 4998 | - $p_dir = substr($p_dir, 0, strlen($p_dir)-1); |
|
| 4998 | + $p_dir = substr($p_dir, 0, strlen($p_dir) - 1); |
|
| 4999 | 4999 | } |
| 5000 | 5000 | |
| 5001 | 5001 | // ----- Check the directory availability |
@@ -5021,7 +5021,7 @@ discard block |
||
| 5021 | 5021 | } |
| 5022 | 5022 | |
| 5023 | 5023 | // ----- Create the directory |
| 5024 | - if (!@mkdir($p_dir, 0777)) |
|
| 5024 | + if ( ! @mkdir($p_dir, 0777)) |
|
| 5025 | 5025 | { |
| 5026 | 5026 | // ----- Error log |
| 5027 | 5027 | PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'"); |
@@ -5044,10 +5044,10 @@ discard block |
||
| 5044 | 5044 | // -------------------------------------------------------------------------------- |
| 5045 | 5045 | function privMerge(&$p_archive_to_add) |
| 5046 | 5046 | { |
| 5047 | - $v_result=1; |
|
| 5047 | + $v_result = 1; |
|
| 5048 | 5048 | |
| 5049 | 5049 | // ----- Look if the archive_to_add exists |
| 5050 | - if (!is_file($p_archive_to_add->zipname)) |
|
| 5050 | + if ( ! is_file($p_archive_to_add->zipname)) |
|
| 5051 | 5051 | { |
| 5052 | 5052 | |
| 5053 | 5053 | // ----- Nothing to merge, so merge is a success |
@@ -5058,7 +5058,7 @@ discard block |
||
| 5058 | 5058 | } |
| 5059 | 5059 | |
| 5060 | 5060 | // ----- Look if the archive exists |
| 5061 | - if (!is_file($this->zipname)) |
|
| 5061 | + if ( ! is_file($this->zipname)) |
|
| 5062 | 5062 | { |
| 5063 | 5063 | |
| 5064 | 5064 | // ----- Do a duplicate |
@@ -5069,7 +5069,7 @@ discard block |
||
| 5069 | 5069 | } |
| 5070 | 5070 | |
| 5071 | 5071 | // ----- Open the zip file |
| 5072 | - if (($v_result=$this->privOpenFd('rb')) != 1) |
|
| 5072 | + if (($v_result = $this->privOpenFd('rb')) != 1) |
|
| 5073 | 5073 | { |
| 5074 | 5074 | // ----- Return |
| 5075 | 5075 | return $v_result; |
@@ -5087,7 +5087,7 @@ discard block |
||
| 5087 | 5087 | @rewind($this->zip_fd); |
| 5088 | 5088 | |
| 5089 | 5089 | // ----- Open the archive_to_add file |
| 5090 | - if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1) |
|
| 5090 | + if (($v_result = $p_archive_to_add->privOpenFd('rb')) != 1) |
|
| 5091 | 5091 | { |
| 5092 | 5092 | $this->privCloseFd(); |
| 5093 | 5093 | |
@@ -5171,7 +5171,7 @@ discard block |
||
| 5171 | 5171 | $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment']; |
| 5172 | 5172 | |
| 5173 | 5173 | // ----- Calculate the size of the (new) central header |
| 5174 | - $v_size = @ftell($v_zip_temp_fd)-$v_offset; |
|
| 5174 | + $v_size = @ftell($v_zip_temp_fd) - $v_offset; |
|
| 5175 | 5175 | |
| 5176 | 5176 | // ----- Swap the file descriptor |
| 5177 | 5177 | // Here is a trick : I swap the temporary fd with the zip fd, in order to use |
@@ -5181,7 +5181,7 @@ discard block |
||
| 5181 | 5181 | $v_zip_temp_fd = $v_swap; |
| 5182 | 5182 | |
| 5183 | 5183 | // ----- Create the central dir footer |
| 5184 | - if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 5184 | + if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries'] + $v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1) |
|
| 5185 | 5185 | { |
| 5186 | 5186 | $this->privCloseFd(); |
| 5187 | 5187 | $p_archive_to_add->privCloseFd(); |
@@ -5229,10 +5229,10 @@ discard block |
||
| 5229 | 5229 | // -------------------------------------------------------------------------------- |
| 5230 | 5230 | function privDuplicate($p_archive_filename) |
| 5231 | 5231 | { |
| 5232 | - $v_result=1; |
|
| 5232 | + $v_result = 1; |
|
| 5233 | 5233 | |
| 5234 | 5234 | // ----- Look if the $p_archive_filename exists |
| 5235 | - if (!is_file($p_archive_filename)) |
|
| 5235 | + if ( ! is_file($p_archive_filename)) |
|
| 5236 | 5236 | { |
| 5237 | 5237 | |
| 5238 | 5238 | // ----- Nothing to duplicate, so duplicate is a success. |
@@ -5243,7 +5243,7 @@ discard block |
||
| 5243 | 5243 | } |
| 5244 | 5244 | |
| 5245 | 5245 | // ----- Open the zip file |
| 5246 | - if (($v_result=$this->privOpenFd('wb')) != 1) |
|
| 5246 | + if (($v_result = $this->privOpenFd('wb')) != 1) |
|
| 5247 | 5247 | { |
| 5248 | 5248 | // ----- Return |
| 5249 | 5249 | return $v_result; |
@@ -5287,7 +5287,7 @@ discard block |
||
| 5287 | 5287 | // Description : |
| 5288 | 5288 | // Parameters : |
| 5289 | 5289 | // -------------------------------------------------------------------------------- |
| 5290 | - function privErrorLog($p_error_code=0, $p_error_string='') |
|
| 5290 | + function privErrorLog($p_error_code = 0, $p_error_string = '') |
|
| 5291 | 5291 | { |
| 5292 | 5292 | if (PCLZIP_ERROR_EXTERNAL == 1) { |
| 5293 | 5293 | PclError($p_error_code, $p_error_string); |
@@ -5324,11 +5324,11 @@ discard block |
||
| 5324 | 5324 | // -------------------------------------------------------------------------------- |
| 5325 | 5325 | function privDisableMagicQuotes() |
| 5326 | 5326 | { |
| 5327 | - $v_result=1; |
|
| 5327 | + $v_result = 1; |
|
| 5328 | 5328 | |
| 5329 | 5329 | // ----- Look if function exists |
| 5330 | - if ( (!function_exists("get_magic_quotes_runtime")) |
|
| 5331 | - || (!function_exists("set_magic_quotes_runtime"))) { |
|
| 5330 | + if (( ! function_exists("get_magic_quotes_runtime")) |
|
| 5331 | + || ( ! function_exists("set_magic_quotes_runtime"))) { |
|
| 5332 | 5332 | return $v_result; |
| 5333 | 5333 | } |
| 5334 | 5334 | |
@@ -5358,11 +5358,11 @@ discard block |
||
| 5358 | 5358 | // -------------------------------------------------------------------------------- |
| 5359 | 5359 | function privSwapBackMagicQuotes() |
| 5360 | 5360 | { |
| 5361 | - $v_result=1; |
|
| 5361 | + $v_result = 1; |
|
| 5362 | 5362 | |
| 5363 | 5363 | // ----- Look if function exists |
| 5364 | - if ( (!function_exists("get_magic_quotes_runtime")) |
|
| 5365 | - || (!function_exists("set_magic_quotes_runtime"))) { |
|
| 5364 | + if (( ! function_exists("get_magic_quotes_runtime")) |
|
| 5365 | + || ( ! function_exists("set_magic_quotes_runtime"))) { |
|
| 5366 | 5366 | return $v_result; |
| 5367 | 5367 | } |
| 5368 | 5368 | |
@@ -5402,7 +5402,7 @@ discard block |
||
| 5402 | 5402 | |
| 5403 | 5403 | // ----- Study directories from last to first |
| 5404 | 5404 | $v_skip = 0; |
| 5405 | - for ($i=sizeof($v_list)-1; $i>=0; $i--) { |
|
| 5405 | + for ($i = sizeof($v_list) - 1; $i >= 0; $i--) { |
|
| 5406 | 5406 | // ----- Look for current path |
| 5407 | 5407 | if ($v_list[$i] == ".") { |
| 5408 | 5408 | // ----- Ignore this directory |
@@ -5423,7 +5423,7 @@ discard block |
||
| 5423 | 5423 | } |
| 5424 | 5424 | } |
| 5425 | 5425 | // ----- Last '/' i.e. indicates a directory |
| 5426 | - else if ($i == (sizeof($v_list)-1)) { |
|
| 5426 | + else if ($i == (sizeof($v_list) - 1)) { |
|
| 5427 | 5427 | $v_result = $v_list[$i]; |
| 5428 | 5428 | } |
| 5429 | 5429 | // ----- Double '/' inside the path |
@@ -5438,7 +5438,7 @@ discard block |
||
| 5438 | 5438 | $v_skip--; |
| 5439 | 5439 | } |
| 5440 | 5440 | else { |
| 5441 | - $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); |
|
| 5441 | + $v_result = $v_list[$i].($i != (sizeof($v_list) - 1) ? "/".$v_result : ""); |
|
| 5442 | 5442 | } |
| 5443 | 5443 | } |
| 5444 | 5444 | } |
@@ -5477,12 +5477,12 @@ discard block |
||
| 5477 | 5477 | $v_result = 1; |
| 5478 | 5478 | |
| 5479 | 5479 | // ----- Look for path beginning by ./ |
| 5480 | - if ( ($p_dir == '.') |
|
| 5481 | - || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { |
|
| 5480 | + if (($p_dir == '.') |
|
| 5481 | + || ((strlen($p_dir) >= 2) && (substr($p_dir, 0, 2) == './'))) { |
|
| 5482 | 5482 | $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); |
| 5483 | 5483 | } |
| 5484 | - if ( ($p_path == '.') |
|
| 5485 | - || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) { |
|
| 5484 | + if (($p_path == '.') |
|
| 5485 | + || ((strlen($p_path) >= 2) && (substr($p_path, 0, 2) == './'))) { |
|
| 5486 | 5486 | $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); |
| 5487 | 5487 | } |
| 5488 | 5488 | |
@@ -5508,7 +5508,7 @@ discard block |
||
| 5508 | 5508 | } |
| 5509 | 5509 | |
| 5510 | 5510 | // ----- Compare the items |
| 5511 | - if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) { |
|
| 5511 | + if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ($v_list_path[$j] != '')) { |
|
| 5512 | 5512 | $v_result = 0; |
| 5513 | 5513 | } |
| 5514 | 5514 | |
@@ -5549,11 +5549,11 @@ discard block |
||
| 5549 | 5549 | // 3 : src & dest gzip |
| 5550 | 5550 | // Return Values : |
| 5551 | 5551 | // -------------------------------------------------------------------------------- |
| 5552 | - function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0) |
|
| 5552 | + function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode = 0) |
|
| 5553 | 5553 | { |
| 5554 | 5554 | $v_result = 1; |
| 5555 | 5555 | |
| 5556 | - if ($p_mode==0) |
|
| 5556 | + if ($p_mode == 0) |
|
| 5557 | 5557 | { |
| 5558 | 5558 | while ($p_size != 0) |
| 5559 | 5559 | { |
@@ -5563,7 +5563,7 @@ discard block |
||
| 5563 | 5563 | $p_size -= $v_read_size; |
| 5564 | 5564 | } |
| 5565 | 5565 | } |
| 5566 | - else if ($p_mode==1) |
|
| 5566 | + else if ($p_mode == 1) |
|
| 5567 | 5567 | { |
| 5568 | 5568 | while ($p_size != 0) |
| 5569 | 5569 | { |
@@ -5573,7 +5573,7 @@ discard block |
||
| 5573 | 5573 | $p_size -= $v_read_size; |
| 5574 | 5574 | } |
| 5575 | 5575 | } |
| 5576 | - else if ($p_mode==2) |
|
| 5576 | + else if ($p_mode == 2) |
|
| 5577 | 5577 | { |
| 5578 | 5578 | while ($p_size != 0) |
| 5579 | 5579 | { |
@@ -5583,7 +5583,7 @@ discard block |
||
| 5583 | 5583 | $p_size -= $v_read_size; |
| 5584 | 5584 | } |
| 5585 | 5585 | } |
| 5586 | - else if ($p_mode==3) |
|
| 5586 | + else if ($p_mode == 3) |
|
| 5587 | 5587 | { |
| 5588 | 5588 | while ($p_size != 0) |
| 5589 | 5589 | { |
@@ -5616,13 +5616,13 @@ discard block |
||
| 5616 | 5616 | $v_result = 1; |
| 5617 | 5617 | |
| 5618 | 5618 | // ----- Try to rename the files |
| 5619 | - if (!@rename($p_src, $p_dest)) { |
|
| 5619 | + if ( ! @rename($p_src, $p_dest)) { |
|
| 5620 | 5620 | |
| 5621 | 5621 | // ----- Try to copy & unlink the src |
| 5622 | - if (!@copy($p_src, $p_dest)) { |
|
| 5622 | + if ( ! @copy($p_src, $p_dest)) { |
|
| 5623 | 5623 | $v_result = 0; |
| 5624 | 5624 | } |
| 5625 | - else if (!@unlink($p_src)) { |
|
| 5625 | + else if ( ! @unlink($p_src)) { |
|
| 5626 | 5626 | $v_result = 0; |
| 5627 | 5627 | } |
| 5628 | 5628 | } |
@@ -5647,7 +5647,7 @@ discard block |
||
| 5647 | 5647 | $v_list = get_defined_constants(); |
| 5648 | 5648 | for (reset($v_list); $v_key = key($v_list); next($v_list)) { |
| 5649 | 5649 | $v_prefix = substr($v_key, 0, 10); |
| 5650 | - if (( ($v_prefix == 'PCLZIP_OPT') |
|
| 5650 | + if ((($v_prefix == 'PCLZIP_OPT') |
|
| 5651 | 5651 | || ($v_prefix == 'PCLZIP_CB_') |
| 5652 | 5652 | || ($v_prefix == 'PCLZIP_ATT')) |
| 5653 | 5653 | && ($v_list[$v_key] == $p_option)) { |
@@ -5672,15 +5672,15 @@ discard block |
||
| 5672 | 5672 | // Return Values : |
| 5673 | 5673 | // The path translated. |
| 5674 | 5674 | // -------------------------------------------------------------------------------- |
| 5675 | - function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true) |
|
| 5675 | + function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter = true) |
|
| 5676 | 5676 | { |
| 5677 | 5677 | if (stristr(php_uname(), 'windows')) { |
| 5678 | 5678 | // ----- Look for potential disk letter |
| 5679 | 5679 | if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { |
| 5680 | - $p_path = substr($p_path, $v_position+1); |
|
| 5680 | + $p_path = substr($p_path, $v_position + 1); |
|
| 5681 | 5681 | } |
| 5682 | 5682 | // ----- Change potential windows directory separator |
| 5683 | - if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { |
|
| 5683 | + if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) { |
|
| 5684 | 5684 | $p_path = strtr($p_path, '\\', '/'); |
| 5685 | 5685 | } |
| 5686 | 5686 | } |
@@ -328,8 +328,7 @@ discard block |
||
| 328 | 328 | // ----- Look for the optional second argument |
| 329 | 329 | if ($v_size == 2) { |
| 330 | 330 | $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; |
| 331 | - } |
|
| 332 | - else if ($v_size > 2) { |
|
| 331 | + } else if ($v_size > 2) { |
|
| 333 | 332 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, |
| 334 | 333 | "Invalid number / type of arguments"); |
| 335 | 334 | return 0; |
@@ -378,8 +377,7 @@ discard block |
||
| 378 | 377 | foreach ($v_string_list as $v_string) { |
| 379 | 378 | if ($v_string != '') { |
| 380 | 379 | $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; |
| 381 | - } |
|
| 382 | - else { |
|
| 380 | + } else { |
|
| 383 | 381 | } |
| 384 | 382 | } |
| 385 | 383 | } |
@@ -513,8 +511,7 @@ discard block |
||
| 513 | 511 | // ----- Look for the optional second argument |
| 514 | 512 | if ($v_size == 2) { |
| 515 | 513 | $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; |
| 516 | - } |
|
| 517 | - else if ($v_size > 2) { |
|
| 514 | + } else if ($v_size > 2) { |
|
| 518 | 515 | // ----- Error log |
| 519 | 516 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
| 520 | 517 | |
@@ -790,8 +787,7 @@ discard block |
||
| 790 | 787 | // ----- Look for the optional second argument |
| 791 | 788 | if ($v_size == 2) { |
| 792 | 789 | $v_remove_path = $v_arg_list[1]; |
| 793 | - } |
|
| 794 | - else if ($v_size > 2) { |
|
| 790 | + } else if ($v_size > 2) { |
|
| 795 | 791 | // ----- Error log |
| 796 | 792 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
| 797 | 793 | |
@@ -935,8 +931,7 @@ discard block |
||
| 935 | 931 | } |
| 936 | 932 | if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) { |
| 937 | 933 | $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; |
| 938 | - } |
|
| 939 | - else { |
|
| 934 | + } else { |
|
| 940 | 935 | } |
| 941 | 936 | } |
| 942 | 937 | |
@@ -951,8 +946,7 @@ discard block |
||
| 951 | 946 | // ----- Look for the optional second argument |
| 952 | 947 | if ($v_size == 2) { |
| 953 | 948 | $v_remove_path = $v_arg_list[1]; |
| 954 | - } |
|
| 955 | - else if ($v_size > 2) { |
|
| 949 | + } else if ($v_size > 2) { |
|
| 956 | 950 | // ----- Error log |
| 957 | 951 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); |
| 958 | 952 | |
@@ -1188,8 +1182,7 @@ discard block |
||
| 1188 | 1182 | // ----- Error log |
| 1189 | 1183 | PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'"); |
| 1190 | 1184 | $v_result = PCLZIP_ERR_MISSING_FILE; |
| 1191 | - } |
|
| 1192 | - else { |
|
| 1185 | + } else { |
|
| 1193 | 1186 | // ----- Duplicate the archive |
| 1194 | 1187 | $v_result = $this->privDuplicate($p_archive); |
| 1195 | 1188 | } |
@@ -1277,8 +1270,7 @@ discard block |
||
| 1277 | 1270 | { |
| 1278 | 1271 | if (PCLZIP_ERROR_EXTERNAL == 1) { |
| 1279 | 1272 | return(PclErrorCode()); |
| 1280 | - } |
|
| 1281 | - else { |
|
| 1273 | + } else { |
|
| 1282 | 1274 | return($this->error_code); |
| 1283 | 1275 | } |
| 1284 | 1276 | } |
@@ -1316,15 +1308,13 @@ discard block |
||
| 1316 | 1308 | |
| 1317 | 1309 | if (isset($v_name[$this->error_code])) { |
| 1318 | 1310 | $v_value = $v_name[$this->error_code]; |
| 1319 | - } |
|
| 1320 | - else { |
|
| 1311 | + } else { |
|
| 1321 | 1312 | $v_value = 'NoName'; |
| 1322 | 1313 | } |
| 1323 | 1314 | |
| 1324 | 1315 | if ($p_with_code) { |
| 1325 | 1316 | return($v_value.' ('.$this->error_code.')'); |
| 1326 | - } |
|
| 1327 | - else { |
|
| 1317 | + } else { |
|
| 1328 | 1318 | return($v_value); |
| 1329 | 1319 | } |
| 1330 | 1320 | } |
@@ -1339,12 +1329,10 @@ discard block |
||
| 1339 | 1329 | { |
| 1340 | 1330 | if (PCLZIP_ERROR_EXTERNAL == 1) { |
| 1341 | 1331 | return(PclErrorString()); |
| 1342 | - } |
|
| 1343 | - else { |
|
| 1332 | + } else { |
|
| 1344 | 1333 | if ($p_full) { |
| 1345 | 1334 | return($this->errorName(true)." : ".$this->error_string); |
| 1346 | - } |
|
| 1347 | - else { |
|
| 1335 | + } else { |
|
| 1348 | 1336 | return($this->error_string." [code ".$this->error_code."]"); |
| 1349 | 1337 | } |
| 1350 | 1338 | } |
@@ -1529,8 +1517,7 @@ discard block |
||
| 1529 | 1517 | && ($p_options_list[$i+1] != '')) { |
| 1530 | 1518 | $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); |
| 1531 | 1519 | $i++; |
| 1532 | - } |
|
| 1533 | - else { |
|
| 1520 | + } else { |
|
| 1534 | 1521 | } |
| 1535 | 1522 | break; |
| 1536 | 1523 | |
@@ -1548,11 +1535,9 @@ discard block |
||
| 1548 | 1535 | // ----- Get the value |
| 1549 | 1536 | if (is_string($p_options_list[$i+1])) { |
| 1550 | 1537 | $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1]; |
| 1551 | - } |
|
| 1552 | - else if (is_array($p_options_list[$i+1])) { |
|
| 1538 | + } else if (is_array($p_options_list[$i+1])) { |
|
| 1553 | 1539 | $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
| 1554 | - } |
|
| 1555 | - else { |
|
| 1540 | + } else { |
|
| 1556 | 1541 | // ----- Error log |
| 1557 | 1542 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1558 | 1543 | |
@@ -1581,8 +1566,7 @@ discard block |
||
| 1581 | 1566 | // ----- Get the value |
| 1582 | 1567 | if (is_string($p_options_list[$i+1])) { |
| 1583 | 1568 | $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
| 1584 | - } |
|
| 1585 | - else { |
|
| 1569 | + } else { |
|
| 1586 | 1570 | // ----- Error log |
| 1587 | 1571 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1588 | 1572 | |
@@ -1611,8 +1595,7 @@ discard block |
||
| 1611 | 1595 | // ----- Get the value |
| 1612 | 1596 | if (is_string($p_options_list[$i+1])) { |
| 1613 | 1597 | $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; |
| 1614 | - } |
|
| 1615 | - else { |
|
| 1598 | + } else { |
|
| 1616 | 1599 | // ----- Error log |
| 1617 | 1600 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, |
| 1618 | 1601 | "Wrong parameter value for option '" |
@@ -1645,14 +1628,11 @@ discard block |
||
| 1645 | 1628 | |
| 1646 | 1629 | // ----- Parse items |
| 1647 | 1630 | $v_work_list = explode(",", $p_options_list[$i+1]); |
| 1648 | - } |
|
| 1649 | - else if (is_integer($p_options_list[$i+1])) { |
|
| 1631 | + } else if (is_integer($p_options_list[$i+1])) { |
|
| 1650 | 1632 | $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; |
| 1651 | - } |
|
| 1652 | - else if (is_array($p_options_list[$i+1])) { |
|
| 1633 | + } else if (is_array($p_options_list[$i+1])) { |
|
| 1653 | 1634 | $v_work_list = $p_options_list[$i+1]; |
| 1654 | - } |
|
| 1655 | - else { |
|
| 1635 | + } else { |
|
| 1656 | 1636 | // ----- Error log |
| 1657 | 1637 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1658 | 1638 | |
@@ -1679,13 +1659,11 @@ discard block |
||
| 1679 | 1659 | // ----- Set the option value |
| 1680 | 1660 | $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; |
| 1681 | 1661 | $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0]; |
| 1682 | - } |
|
| 1683 | - elseif ($v_size_item_list == 2) { |
|
| 1662 | + } elseif ($v_size_item_list == 2) { |
|
| 1684 | 1663 | // ----- Set the option value |
| 1685 | 1664 | $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; |
| 1686 | 1665 | $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1]; |
| 1687 | - } |
|
| 1688 | - else { |
|
| 1666 | + } else { |
|
| 1689 | 1667 | // ----- Error log |
| 1690 | 1668 | PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); |
| 1691 | 1669 | |
@@ -1842,14 +1820,17 @@ discard block |
||
| 1842 | 1820 | $v_memory_limit_int = (int) $v_memory_limit; |
| 1843 | 1821 | $last = strtolower(substr($v_memory_limit, -1)); |
| 1844 | 1822 | |
| 1845 | - if($last == 'g') |
|
| 1846 | - //$v_memory_limit_int = $v_memory_limit_int*1024*1024*1024; |
|
| 1823 | + if($last == 'g') { |
|
| 1824 | + //$v_memory_limit_int = $v_memory_limit_int*1024*1024*1024; |
|
| 1847 | 1825 | $v_memory_limit_int = $v_memory_limit_int*1073741824; |
| 1848 | - if($last == 'm') |
|
| 1849 | - //$v_memory_limit_int = $v_memory_limit_int*1024*1024; |
|
| 1826 | + } |
|
| 1827 | + if($last == 'm') { |
|
| 1828 | + //$v_memory_limit_int = $v_memory_limit_int*1024*1024; |
|
| 1850 | 1829 | $v_memory_limit_int = $v_memory_limit_int*1048576; |
| 1851 | - if($last == 'k') |
|
| 1852 | - $v_memory_limit_int = $v_memory_limit_int*1024; |
|
| 1830 | + } |
|
| 1831 | + if($last == 'k') { |
|
| 1832 | + $v_memory_limit_int = $v_memory_limit_int*1024; |
|
| 1833 | + } |
|
| 1853 | 1834 | |
| 1854 | 1835 | $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit_int*PCLZIP_TEMPORARY_FILE_RATIO); |
| 1855 | 1836 | |
@@ -2022,15 +2003,12 @@ discard block |
||
| 2022 | 2003 | if (file_exists($v_descr['filename'])) { |
| 2023 | 2004 | if (@is_file($v_descr['filename'])) { |
| 2024 | 2005 | $v_descr['type'] = 'file'; |
| 2025 | - } |
|
| 2026 | - else if (@is_dir($v_descr['filename'])) { |
|
| 2006 | + } else if (@is_dir($v_descr['filename'])) { |
|
| 2027 | 2007 | $v_descr['type'] = 'folder'; |
| 2028 | - } |
|
| 2029 | - else if (@is_link($v_descr['filename'])) { |
|
| 2008 | + } else if (@is_link($v_descr['filename'])) { |
|
| 2030 | 2009 | // skip |
| 2031 | 2010 | continue; |
| 2032 | - } |
|
| 2033 | - else { |
|
| 2011 | + } else { |
|
| 2034 | 2012 | // skip |
| 2035 | 2013 | continue; |
| 2036 | 2014 | } |
@@ -2079,8 +2057,7 @@ discard block |
||
| 2079 | 2057 | && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) { |
| 2080 | 2058 | if ($v_descr['stored_filename'] != '') { |
| 2081 | 2059 | $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; |
| 2082 | - } |
|
| 2083 | - else { |
|
| 2060 | + } else { |
|
| 2084 | 2061 | $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler; |
| 2085 | 2062 | } |
| 2086 | 2063 | } |
@@ -2089,8 +2066,7 @@ discard block |
||
| 2089 | 2066 | } |
| 2090 | 2067 | |
| 2091 | 2068 | @closedir($v_folder_handler); |
| 2092 | - } |
|
| 2093 | - else { |
|
| 2069 | + } else { |
|
| 2094 | 2070 | // TBC : unable to open folder in read mode |
| 2095 | 2071 | } |
| 2096 | 2072 | |
@@ -2103,8 +2079,7 @@ discard block |
||
| 2103 | 2079 | |
| 2104 | 2080 | // ----- Concat the resulting list |
| 2105 | 2081 | $v_result_list = array_merge($v_result_list, $v_dirlist_descr); |
| 2106 | - } |
|
| 2107 | - else { |
|
| 2082 | + } else { |
|
| 2108 | 2083 | } |
| 2109 | 2084 | |
| 2110 | 2085 | // ----- Free local array |
@@ -2378,8 +2353,9 @@ discard block |
||
| 2378 | 2353 | { |
| 2379 | 2354 | $v_result=1; |
| 2380 | 2355 | |
| 2381 | - if ($this->zip_fd != 0) |
|
| 2382 | - @fclose($this->zip_fd); |
|
| 2356 | + if ($this->zip_fd != 0) { |
|
| 2357 | + @fclose($this->zip_fd); |
|
| 2358 | + } |
|
| 2383 | 2359 | $this->zip_fd = 0; |
| 2384 | 2360 | |
| 2385 | 2361 | // ----- Return |
@@ -2596,11 +2572,9 @@ discard block |
||
| 2596 | 2572 | // ----- Look for filetime |
| 2597 | 2573 | if (isset($p_filedescr['mtime'])) { |
| 2598 | 2574 | $p_header['mtime'] = $p_filedescr['mtime']; |
| 2599 | - } |
|
| 2600 | - else if ($p_filedescr['type'] == 'virtual_file') { |
|
| 2575 | + } else if ($p_filedescr['type'] == 'virtual_file') { |
|
| 2601 | 2576 | $p_header['mtime'] = time(); |
| 2602 | - } |
|
| 2603 | - else { |
|
| 2577 | + } else { |
|
| 2604 | 2578 | $p_header['mtime'] = filemtime($p_filename); |
| 2605 | 2579 | } |
| 2606 | 2580 | |
@@ -2608,8 +2582,7 @@ discard block |
||
| 2608 | 2582 | if (isset($p_filedescr['comment'])) { |
| 2609 | 2583 | $p_header['comment_len'] = strlen($p_filedescr['comment']); |
| 2610 | 2584 | $p_header['comment'] = $p_filedescr['comment']; |
| 2611 | - } |
|
| 2612 | - else { |
|
| 2585 | + } else { |
|
| 2613 | 2586 | $p_header['comment_len'] = 0; |
| 2614 | 2587 | $p_header['comment'] = ''; |
| 2615 | 2588 | } |
@@ -2918,20 +2891,17 @@ discard block |
||
| 2918 | 2891 | $p_filename = $p_filedescr['filename']; |
| 2919 | 2892 | if (isset($p_options[PCLZIP_OPT_ADD_PATH])) { |
| 2920 | 2893 | $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH]; |
| 2921 | - } |
|
| 2922 | - else { |
|
| 2894 | + } else { |
|
| 2923 | 2895 | $p_add_dir = ''; |
| 2924 | 2896 | } |
| 2925 | 2897 | if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) { |
| 2926 | 2898 | $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH]; |
| 2927 | - } |
|
| 2928 | - else { |
|
| 2899 | + } else { |
|
| 2929 | 2900 | $p_remove_dir = ''; |
| 2930 | 2901 | } |
| 2931 | 2902 | if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { |
| 2932 | 2903 | $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH]; |
| 2933 | - } |
|
| 2934 | - else { |
|
| 2904 | + } else { |
|
| 2935 | 2905 | $p_remove_all_dir = 0; |
| 2936 | 2906 | } |
| 2937 | 2907 | |
@@ -2954,8 +2924,7 @@ discard block |
||
| 2954 | 2924 | $v_dir = $v_path_info['dirname'].'/'; |
| 2955 | 2925 | } |
| 2956 | 2926 | $v_stored_filename = $v_dir.$p_filedescr['new_short_name']; |
| 2957 | - } |
|
| 2958 | - else { |
|
| 2927 | + } else { |
|
| 2959 | 2928 | // ----- Calculate the stored filename |
| 2960 | 2929 | $v_stored_filename = $p_filename; |
| 2961 | 2930 | } |
@@ -2966,8 +2935,9 @@ discard block |
||
| 2966 | 2935 | } |
| 2967 | 2936 | // ----- Look for partial path remove |
| 2968 | 2937 | else if ($p_remove_dir != "") { |
| 2969 | - if (substr($p_remove_dir, -1) != '/') |
|
| 2970 | - $p_remove_dir .= "/"; |
|
| 2938 | + if (substr($p_remove_dir, -1) != '/') { |
|
| 2939 | + $p_remove_dir .= "/"; |
|
| 2940 | + } |
|
| 2971 | 2941 | |
| 2972 | 2942 | if ( (substr($p_filename, 0, 2) == "./") |
| 2973 | 2943 | || (substr($p_remove_dir, 0, 2) == "./")) { |
@@ -2987,8 +2957,7 @@ discard block |
||
| 2987 | 2957 | if ($v_compare > 0) { |
| 2988 | 2958 | if ($v_compare == 2) { |
| 2989 | 2959 | $v_stored_filename = ""; |
| 2990 | - } |
|
| 2991 | - else { |
|
| 2960 | + } else { |
|
| 2992 | 2961 | $v_stored_filename = substr($v_stored_filename, |
| 2993 | 2962 | strlen($p_remove_dir)); |
| 2994 | 2963 | } |
@@ -3000,10 +2969,11 @@ discard block |
||
| 3000 | 2969 | |
| 3001 | 2970 | // ----- Look for path to add |
| 3002 | 2971 | if ($p_add_dir != "") { |
| 3003 | - if (substr($p_add_dir, -1) == "/") |
|
| 3004 | - $v_stored_filename = $p_add_dir.$v_stored_filename; |
|
| 3005 | - else |
|
| 3006 | - $v_stored_filename = $p_add_dir."/".$v_stored_filename; |
|
| 2972 | + if (substr($p_add_dir, -1) == "/") { |
|
| 2973 | + $v_stored_filename = $p_add_dir.$v_stored_filename; |
|
| 2974 | + } else { |
|
| 2975 | + $v_stored_filename = $p_add_dir."/".$v_stored_filename; |
|
| 2976 | + } |
|
| 3007 | 2977 | } |
| 3008 | 2978 | } |
| 3009 | 2979 | |
@@ -3286,8 +3256,9 @@ discard block |
||
| 3286 | 3256 | if ( ($p_path == "") |
| 3287 | 3257 | || ( (substr($p_path, 0, 1) != "/") |
| 3288 | 3258 | && (substr($p_path, 0, 3) != "../") |
| 3289 | - && (substr($p_path,1,2)!=":/"))) |
|
| 3290 | - $p_path = "./".$p_path; |
|
| 3259 | + && (substr($p_path,1,2)!=":/"))) { |
|
| 3260 | + $p_path = "./".$p_path; |
|
| 3261 | + } |
|
| 3291 | 3262 | |
| 3292 | 3263 | // ----- Reduce the path last (and duplicated) '/' |
| 3293 | 3264 | if (($p_path != "./") && ($p_path != "/")) |
@@ -3773,8 +3744,7 @@ discard block |
||
| 3773 | 3744 | // ----- Change the file status |
| 3774 | 3745 | if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) |
| 3775 | 3746 | && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) { |
| 3776 | - } |
|
| 3777 | - else { |
|
| 3747 | + } else { |
|
| 3778 | 3748 | $p_entry['status'] = "newer_exist"; |
| 3779 | 3749 | |
| 3780 | 3750 | // ----- Look for PCLZIP_OPT_STOP_ON_ERROR |
@@ -3790,19 +3760,19 @@ discard block |
||
| 3790 | 3760 | return PclZip::errorCode(); |
| 3791 | 3761 | } |
| 3792 | 3762 | } |
| 3793 | - } |
|
| 3794 | - else { |
|
| 3763 | + } else { |
|
| 3795 | 3764 | } |
| 3796 | 3765 | } |
| 3797 | 3766 | |
| 3798 | 3767 | // ----- Check the directory availability and create it if necessary |
| 3799 | 3768 | else { |
| 3800 | - if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) |
|
| 3801 | - $v_dir_to_check = $p_entry['filename']; |
|
| 3802 | - else if (!strstr($p_entry['filename'], "/")) |
|
| 3803 | - $v_dir_to_check = ""; |
|
| 3804 | - else |
|
| 3805 | - $v_dir_to_check = dirname($p_entry['filename']); |
|
| 3769 | + if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) { |
|
| 3770 | + $v_dir_to_check = $p_entry['filename']; |
|
| 3771 | + } else if (!strstr($p_entry['filename'], "/")) { |
|
| 3772 | + $v_dir_to_check = ""; |
|
| 3773 | + } else { |
|
| 3774 | + $v_dir_to_check = dirname($p_entry['filename']); |
|
| 3775 | + } |
|
| 3806 | 3776 | |
| 3807 | 3777 | if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) { |
| 3808 | 3778 | |
@@ -3858,8 +3828,7 @@ discard block |
||
| 3858 | 3828 | touch($p_entry['filename'], $p_entry['mtime']); |
| 3859 | 3829 | |
| 3860 | 3830 | |
| 3861 | - } |
|
| 3862 | - else { |
|
| 3831 | + } else { |
|
| 3863 | 3832 | // ----- TBC |
| 3864 | 3833 | // Need to be finished |
| 3865 | 3834 | if (($p_entry['flag'] & 1) == 1) { |
@@ -4101,8 +4070,7 @@ discard block |
||
| 4101 | 4070 | // ----- Send the file to the output |
| 4102 | 4071 | echo $v_buffer; |
| 4103 | 4072 | unset($v_buffer); |
| 4104 | - } |
|
| 4105 | - else { |
|
| 4073 | + } else { |
|
| 4106 | 4074 | |
| 4107 | 4075 | // ----- Read the compressed file in a buffer (one shot) |
| 4108 | 4076 | $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); |
@@ -4210,8 +4178,7 @@ discard block |
||
| 4210 | 4178 | |
| 4211 | 4179 | // ----- Reading the file |
| 4212 | 4180 | $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); |
| 4213 | - } |
|
| 4214 | - else { |
|
| 4181 | + } else { |
|
| 4215 | 4182 | |
| 4216 | 4183 | // ----- Reading the file |
| 4217 | 4184 | $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); |
@@ -4223,8 +4190,7 @@ discard block |
||
| 4223 | 4190 | } |
| 4224 | 4191 | |
| 4225 | 4192 | // ----- Trace |
| 4226 | - } |
|
| 4227 | - else { |
|
| 4193 | + } else { |
|
| 4228 | 4194 | // TBC : error : can not extract a folder in a string |
| 4229 | 4195 | } |
| 4230 | 4196 | |
@@ -4316,8 +4282,7 @@ discard block |
||
| 4316 | 4282 | // ----- Get extra_fields |
| 4317 | 4283 | if ($v_data['extra_len'] != 0) { |
| 4318 | 4284 | $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']); |
| 4319 | - } |
|
| 4320 | - else { |
|
| 4285 | + } else { |
|
| 4321 | 4286 | $p_header['extra'] = ''; |
| 4322 | 4287 | } |
| 4323 | 4288 | |
@@ -4348,8 +4313,7 @@ discard block |
||
| 4348 | 4313 | // ----- Get UNIX date format |
| 4349 | 4314 | $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
| 4350 | 4315 | |
| 4351 | - } |
|
| 4352 | - else |
|
| 4316 | + } else |
|
| 4353 | 4317 | { |
| 4354 | 4318 | $p_header['mtime'] = time(); |
| 4355 | 4319 | } |
@@ -4414,22 +4378,25 @@ discard block |
||
| 4414 | 4378 | $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data); |
| 4415 | 4379 | |
| 4416 | 4380 | // ----- Get filename |
| 4417 | - if ($p_header['filename_len'] != 0) |
|
| 4418 | - $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']); |
|
| 4419 | - else |
|
| 4420 | - $p_header['filename'] = ''; |
|
| 4381 | + if ($p_header['filename_len'] != 0) { |
|
| 4382 | + $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']); |
|
| 4383 | + } else { |
|
| 4384 | + $p_header['filename'] = ''; |
|
| 4385 | + } |
|
| 4421 | 4386 | |
| 4422 | 4387 | // ----- Get extra |
| 4423 | - if ($p_header['extra_len'] != 0) |
|
| 4424 | - $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); |
|
| 4425 | - else |
|
| 4426 | - $p_header['extra'] = ''; |
|
| 4388 | + if ($p_header['extra_len'] != 0) { |
|
| 4389 | + $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); |
|
| 4390 | + } else { |
|
| 4391 | + $p_header['extra'] = ''; |
|
| 4392 | + } |
|
| 4427 | 4393 | |
| 4428 | 4394 | // ----- Get comment |
| 4429 | - if ($p_header['comment_len'] != 0) |
|
| 4430 | - $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); |
|
| 4431 | - else |
|
| 4432 | - $p_header['comment'] = ''; |
|
| 4395 | + if ($p_header['comment_len'] != 0) { |
|
| 4396 | + $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); |
|
| 4397 | + } else { |
|
| 4398 | + $p_header['comment'] = ''; |
|
| 4399 | + } |
|
| 4433 | 4400 | |
| 4434 | 4401 | // ----- Extract properties |
| 4435 | 4402 | |
@@ -4451,8 +4418,7 @@ discard block |
||
| 4451 | 4418 | // ----- Get UNIX date format |
| 4452 | 4419 | $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
| 4453 | 4420 | |
| 4454 | - } |
|
| 4455 | - else |
|
| 4421 | + } else |
|
| 4456 | 4422 | { |
| 4457 | 4423 | $p_header['mtime'] = time(); |
| 4458 | 4424 | } |
@@ -4565,8 +4531,9 @@ discard block |
||
| 4565 | 4531 | // ----- Go back to the maximum possible size of the Central Dir End Record |
| 4566 | 4532 | if (!$v_found) { |
| 4567 | 4533 | $v_maximum_size = 65557; // 0xFFFF + 22; |
| 4568 | - if ($v_maximum_size > $v_size) |
|
| 4569 | - $v_maximum_size = $v_size; |
|
| 4534 | + if ($v_maximum_size > $v_size) { |
|
| 4535 | + $v_maximum_size = $v_size; |
|
| 4536 | + } |
|
| 4570 | 4537 | @fseek($this->zip_fd, $v_size-$v_maximum_size); |
| 4571 | 4538 | if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) |
| 4572 | 4539 | { |
@@ -4651,9 +4618,9 @@ discard block |
||
| 4651 | 4618 | // ----- Get comment |
| 4652 | 4619 | if ($v_data['comment_size'] != 0) { |
| 4653 | 4620 | $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']); |
| 4621 | + } else { |
|
| 4622 | + $p_central_dir['comment'] = ''; |
|
| 4654 | 4623 | } |
| 4655 | - else |
|
| 4656 | - $p_central_dir['comment'] = ''; |
|
| 4657 | 4624 | |
| 4658 | 4625 | $p_central_dir['entries'] = $v_data['entries']; |
| 4659 | 4626 | $p_central_dir['disk_entries'] = $v_data['disk_entries']; |
@@ -4753,8 +4720,7 @@ discard block |
||
| 4753 | 4720 | if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) |
| 4754 | 4721 | && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { |
| 4755 | 4722 | $v_found = true; |
| 4756 | - } |
|
| 4757 | - elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
| 4723 | + } elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
| 4758 | 4724 | && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) { |
| 4759 | 4725 | $v_found = true; |
| 4760 | 4726 | } |
@@ -4805,8 +4771,7 @@ discard block |
||
| 4805 | 4771 | break; |
| 4806 | 4772 | } |
| 4807 | 4773 | } |
| 4808 | - } |
|
| 4809 | - else { |
|
| 4774 | + } else { |
|
| 4810 | 4775 | $v_found = true; |
| 4811 | 4776 | } |
| 4812 | 4777 | |
@@ -4814,8 +4779,7 @@ discard block |
||
| 4814 | 4779 | if ($v_found) |
| 4815 | 4780 | { |
| 4816 | 4781 | unset($v_header_list[$v_nb_extracted]); |
| 4817 | - } |
|
| 4818 | - else |
|
| 4782 | + } else |
|
| 4819 | 4783 | { |
| 4820 | 4784 | $v_nb_extracted++; |
| 4821 | 4785 | } |
@@ -5291,8 +5255,7 @@ discard block |
||
| 5291 | 5255 | { |
| 5292 | 5256 | if (PCLZIP_ERROR_EXTERNAL == 1) { |
| 5293 | 5257 | PclError($p_error_code, $p_error_string); |
| 5294 | - } |
|
| 5295 | - else { |
|
| 5258 | + } else { |
|
| 5296 | 5259 | $this->error_code = $p_error_code; |
| 5297 | 5260 | $this->error_string = $p_error_string; |
| 5298 | 5261 | } |
@@ -5308,8 +5271,7 @@ discard block |
||
| 5308 | 5271 | { |
| 5309 | 5272 | if (PCLZIP_ERROR_EXTERNAL == 1) { |
| 5310 | 5273 | PclErrorReset(); |
| 5311 | - } |
|
| 5312 | - else { |
|
| 5274 | + } else { |
|
| 5313 | 5275 | $this->error_code = 0; |
| 5314 | 5276 | $this->error_string = ''; |
| 5315 | 5277 | } |
@@ -5407,11 +5369,9 @@ discard block |
||
| 5407 | 5369 | if ($v_list[$i] == ".") { |
| 5408 | 5370 | // ----- Ignore this directory |
| 5409 | 5371 | // Should be the first $i=0, but no check is done |
| 5410 | - } |
|
| 5411 | - else if ($v_list[$i] == "..") { |
|
| 5372 | + } else if ($v_list[$i] == "..") { |
|
| 5412 | 5373 | $v_skip++; |
| 5413 | - } |
|
| 5414 | - else if ($v_list[$i] == "") { |
|
| 5374 | + } else if ($v_list[$i] == "") { |
|
| 5415 | 5375 | // ----- First '/' i.e. root slash |
| 5416 | 5376 | if ($i == 0) { |
| 5417 | 5377 | $v_result = "/".$v_result; |
@@ -5431,13 +5391,11 @@ discard block |
||
| 5431 | 5391 | // ----- Ignore only the double '//' in path, |
| 5432 | 5392 | // but not the first and last '/' |
| 5433 | 5393 | } |
| 5434 | - } |
|
| 5435 | - else { |
|
| 5394 | + } else { |
|
| 5436 | 5395 | // ----- Look for item to skip |
| 5437 | 5396 | if ($v_skip > 0) { |
| 5438 | 5397 | $v_skip--; |
| 5439 | - } |
|
| 5440 | - else { |
|
| 5398 | + } else { |
|
| 5441 | 5399 | $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); |
| 5442 | 5400 | } |
| 5443 | 5401 | } |
@@ -5520,14 +5478,17 @@ discard block |
||
| 5520 | 5478 | // ----- Look if everything seems to be the same |
| 5521 | 5479 | if ($v_result) { |
| 5522 | 5480 | // ----- Skip all the empty items |
| 5523 | - while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; |
|
| 5524 | - while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; |
|
| 5481 | + while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) { |
|
| 5482 | + $j++; |
|
| 5483 | + } |
|
| 5484 | + while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) { |
|
| 5485 | + $i++; |
|
| 5486 | + } |
|
| 5525 | 5487 | |
| 5526 | 5488 | if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { |
| 5527 | 5489 | // ----- There are exactly the same |
| 5528 | 5490 | $v_result = 2; |
| 5529 | - } |
|
| 5530 | - else if ($i < $v_list_dir_size) { |
|
| 5491 | + } else if ($i < $v_list_dir_size) { |
|
| 5531 | 5492 | // ----- The path is shorter than the dir |
| 5532 | 5493 | $v_result = 0; |
| 5533 | 5494 | } |
@@ -5562,8 +5523,7 @@ discard block |
||
| 5562 | 5523 | @fwrite($p_dest, $v_buffer, $v_read_size); |
| 5563 | 5524 | $p_size -= $v_read_size; |
| 5564 | 5525 | } |
| 5565 | - } |
|
| 5566 | - else if ($p_mode==1) |
|
| 5526 | + } else if ($p_mode==1) |
|
| 5567 | 5527 | { |
| 5568 | 5528 | while ($p_size != 0) |
| 5569 | 5529 | { |
@@ -5572,8 +5532,7 @@ discard block |
||
| 5572 | 5532 | @fwrite($p_dest, $v_buffer, $v_read_size); |
| 5573 | 5533 | $p_size -= $v_read_size; |
| 5574 | 5534 | } |
| 5575 | - } |
|
| 5576 | - else if ($p_mode==2) |
|
| 5535 | + } else if ($p_mode==2) |
|
| 5577 | 5536 | { |
| 5578 | 5537 | while ($p_size != 0) |
| 5579 | 5538 | { |
@@ -5582,8 +5541,7 @@ discard block |
||
| 5582 | 5541 | @gzwrite($p_dest, $v_buffer, $v_read_size); |
| 5583 | 5542 | $p_size -= $v_read_size; |
| 5584 | 5543 | } |
| 5585 | - } |
|
| 5586 | - else if ($p_mode==3) |
|
| 5544 | + } else if ($p_mode==3) |
|
| 5587 | 5545 | { |
| 5588 | 5546 | while ($p_size != 0) |
| 5589 | 5547 | { |
@@ -5621,8 +5579,7 @@ discard block |
||
| 5621 | 5579 | // ----- Try to copy & unlink the src |
| 5622 | 5580 | if (!@copy($p_src, $p_dest)) { |
| 5623 | 5581 | $v_result = 0; |
| 5624 | - } |
|
| 5625 | - else if (!@unlink($p_src)) { |
|
| 5582 | + } else if (!@unlink($p_src)) { |
|
| 5626 | 5583 | $v_result = 0; |
| 5627 | 5584 | } |
| 5628 | 5585 | } |